mirror of
https://github.com/siteboon/claudecodeui.git
synced 2026-06-14 18:41:57 +08:00
Compare commits
13 Commits
refactor/b
...
refactor/r
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fce8ad0893 | ||
|
|
cc7f652044 | ||
|
|
2207d05c1c | ||
|
|
a8dab0edcf | ||
|
|
e61f8a543d | ||
|
|
388134c7a5 | ||
|
|
ef51de259e | ||
|
|
1628868470 | ||
|
|
8f1042cf25 | ||
|
|
051a6b1e74 | ||
|
|
f1063fd339 | ||
|
|
27cd12432b | ||
|
|
004135ef01 |
47
.github/workflows/cross-platform-server.yml
vendored
47
.github/workflows/cross-platform-server.yml
vendored
@@ -1,47 +0,0 @@
|
||||
name: Cross Platform Server Verification
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
push:
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
verify:
|
||||
name: Verify on ${{ matrix.os }}
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os:
|
||||
- ubuntu-latest
|
||||
- windows-latest
|
||||
node:
|
||||
- 22
|
||||
|
||||
steps:
|
||||
# This step checks out the repository so the matrix job can build and test it.
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
# This step installs the Node.js version the README already declares as the project baseline.
|
||||
- name: Set up Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: ${{ matrix.node }}
|
||||
cache: npm
|
||||
|
||||
# This step installs dependencies exactly as locked so native and shell behavior stays reproducible.
|
||||
- name: Install dependencies
|
||||
run: npm ci
|
||||
|
||||
# This step verifies the TypeScript server code before runtime checks.
|
||||
- name: Typecheck server
|
||||
run: npm run typecheck:server
|
||||
|
||||
# This step runs the built-in Node tests that exercise the OS adapter layer directly.
|
||||
- name: Test server adapters
|
||||
run: npm run test:server
|
||||
|
||||
# This step ensures the in-progress TypeScript backend still compiles in each OS environment.
|
||||
- name: Build server
|
||||
run: npm run server:build
|
||||
3
.github/workflows/release.yml
vendored
3
.github/workflows/release.yml
vendored
@@ -23,6 +23,7 @@ jobs:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
token: ${{ secrets.RELEASE_PAT }}
|
||||
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
@@ -44,6 +45,6 @@ jobs:
|
||||
fi
|
||||
npx release-it $ARGS
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
GITHUB_TOKEN: ${{ secrets.RELEASE_PAT }}
|
||||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||
|
||||
3
.gitignore
vendored
3
.gitignore
vendored
@@ -8,7 +8,6 @@ lerna-debug.log*
|
||||
|
||||
# Build outputs
|
||||
dist/
|
||||
server/dist/
|
||||
dist-ssr/
|
||||
build/
|
||||
out/
|
||||
@@ -139,4 +138,4 @@ tasks/
|
||||
!src/i18n/locales/de/tasks.json
|
||||
|
||||
# Git worktrees
|
||||
.worktrees/
|
||||
.worktrees/
|
||||
@@ -6,7 +6,8 @@
|
||||
"requireCleanWorkingDir": true
|
||||
},
|
||||
"npm": {
|
||||
"publish": true
|
||||
"publish": true,
|
||||
"publishArgs": ["--access public"]
|
||||
},
|
||||
"github": {
|
||||
"release": true,
|
||||
|
||||
24
CHANGELOG.md
24
CHANGELOG.md
@@ -3,6 +3,30 @@
|
||||
All notable changes to CloudCLI UI will be documented in this file.
|
||||
|
||||
|
||||
## [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)
|
||||
|
||||
@@ -153,4 +153,4 @@ This automatically:
|
||||
|
||||
## License
|
||||
|
||||
By contributing, you agree that your contributions will be licensed under the [GPL-3.0 License](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
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.
|
||||
@@ -79,13 +79,13 @@ Der schnellste Einstieg – keine lokale Einrichtung erforderlich. Erhalte eine
|
||||
CloudCLI UI sofort mit **npx** ausprobieren (erfordert **Node.js** v22+):
|
||||
|
||||
```bash
|
||||
npx @siteboon/claude-code-ui
|
||||
npx @cloudcli-ai/cloudcli
|
||||
```
|
||||
|
||||
Oder **global** installieren für regelmäßige Nutzung:
|
||||
|
||||
```bash
|
||||
npm install -g @siteboon/claude-code-ui
|
||||
npm install -g @cloudcli-ai/cloudcli
|
||||
cloudcli
|
||||
```
|
||||
|
||||
@@ -104,7 +104,7 @@ CloudCLI UI ist die Open-Source-UI-Schicht, die CloudCLI Cloud antreibt. Du kann
|
||||
|---|---|---|
|
||||
| **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 @siteboon/claude-code-ui` | Keine Einrichtung erforderlich |
|
||||
| **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 |
|
||||
|
||||
@@ -75,13 +75,13 @@
|
||||
**npx** で今すぐ CloudCLI UI を試せます(**Node.js** v22+ が必要):
|
||||
|
||||
```bash
|
||||
npx @siteboon/claude-code-ui
|
||||
npx @cloudcli-ai/cloudcli
|
||||
```
|
||||
|
||||
または、普段使いするなら **グローバル** にインストール:
|
||||
|
||||
```bash
|
||||
npm install -g @siteboon/claude-code-ui
|
||||
npm install -g @cloudcli-ai/cloudcli
|
||||
cloudcli
|
||||
```
|
||||
|
||||
@@ -100,7 +100,7 @@ CloudCLI UI は、CloudCLI Cloud を支えるオープンソースの UI レイ
|
||||
|---|---|---|
|
||||
| **対象ユーザー** | 自分のマシン上でローカルの agent セッションに対してフル UI を使いたい開発者 | クラウド上で動く agents をどこからでも利用したいチーム/開発者 |
|
||||
| **アクセス方法** | ブラウザ(`[yourip]:port`) | ブラウザ、任意の IDE、REST API、n8n |
|
||||
| **セットアップ** | `npx @siteboon/claude-code-ui` | セットアップ不要 |
|
||||
| **セットアップ** | `npx @cloudcli-ai/cloudcli` | セットアップ不要 |
|
||||
| **マシンの稼働継続** | はい | いいえ |
|
||||
| **モバイルアクセス** | 同一ネットワーク内の任意のブラウザ | 任意のデバイス(ネイティブアプリも準備中) |
|
||||
| **利用可能なセッション** | `~/.claude` から全セッションを自動検出 | クラウド環境内の全セッション |
|
||||
|
||||
@@ -75,13 +75,13 @@
|
||||
**npx**로 즉시 CloudCLI UI를 실행하세요 (Node.js v22+ 필요):
|
||||
|
||||
```bash
|
||||
npx @siteboon/claude-code-ui
|
||||
npx @cloudcli-ai/cloudcli
|
||||
```
|
||||
|
||||
**정기적으로 사용한다면 전역 설치:**
|
||||
|
||||
```bash
|
||||
npm install -g @siteboon/claude-code-ui
|
||||
npm install -g @cloudcli-ai/cloudcli
|
||||
cloudcli
|
||||
```
|
||||
|
||||
@@ -99,7 +99,7 @@ CloudCLI UI는 CloudCLI Cloud를 구동하는 오픈 소스 UI 계층입니다.
|
||||
|---|---|---|
|
||||
| **적합한 대상** | 로컬 에이전트 세션을 위한 전체 UI가 필요한 개발자 | 어디서든 접근 가능한 클라우드에서 에이전트를 운영하고자 하는 팀 및 개발자 |
|
||||
| **접근 방법** | `[yourip]:port`를 통해 브라우저 접속 | 브라우저, IDE, REST API, n8n |
|
||||
| **설정** | `npx @siteboon/claude-code-ui` | 설정 불필요 |
|
||||
| **설정** | `npx @cloudcli-ai/cloudcli` | 설정 불필요 |
|
||||
| **기기 유지 필요 여부** | 예 (머신 켜둬야 함) | 아니오 |
|
||||
| **모바일 접근** | 네트워크 내 브라우저 | 모든 기기 (네이티브 앱 예정) |
|
||||
| **세션 접근** | `~/.claude`에서 자동 발견 | 클라우드 환경 내 세션 |
|
||||
|
||||
12
README.md
12
README.md
@@ -79,13 +79,13 @@ The fastest way to get started — no local setup required. Get a fully managed,
|
||||
Try CloudCLI UI instantly with **npx** (requires **Node.js** v22+):
|
||||
|
||||
```
|
||||
npx @siteboon/claude-code-ui
|
||||
npx @cloudcli-ai/cloudcli
|
||||
```
|
||||
|
||||
Or install **globally** for regular use:
|
||||
|
||||
```
|
||||
npm install -g @siteboon/claude-code-ui
|
||||
npm install -g @cloudcli-ai/cloudcli
|
||||
cloudcli
|
||||
```
|
||||
|
||||
@@ -104,7 +104,7 @@ CloudCLI UI is the open source UI layer that powers CloudCLI Cloud. You can self
|
||||
|---|---|---|
|
||||
| **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 @siteboon/claude-code-ui` | No setup required |
|
||||
| **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 |
|
||||
@@ -213,9 +213,11 @@ Yes, for self-hosted. CloudCLI UI reads from and writes to the same `~/.claude`
|
||||
|
||||
## 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
|
||||
|
||||
|
||||
@@ -79,13 +79,13 @@
|
||||
Попробовать CloudCLI UI можно сразу через **npx** (требуется **Node.js** v22+):
|
||||
|
||||
```bash
|
||||
npx @siteboon/claude-code-ui
|
||||
npx @cloudcli-ai/cloudcli
|
||||
```
|
||||
|
||||
Или установить **глобально** для регулярного использования:
|
||||
|
||||
```bash
|
||||
npm install -g @siteboon/claude-code-ui
|
||||
npm install -g @cloudcli-ai/cloudcli
|
||||
cloudcli
|
||||
```
|
||||
|
||||
@@ -104,7 +104,7 @@ CloudCLI UI — это open source UI-слой, на котором постро
|
||||
|---|---|---|
|
||||
| **Лучше всего подходит для** | Разработчиков, которым нужен полноценный UI для локальных агентских сессий на своей машине | Команд и разработчиков, которым нужны агенты в облаке с доступом откуда угодно |
|
||||
| **Как вы получаете доступ** | Браузер через `[yourip]:port` | Браузер, любая IDE, REST API, n8n |
|
||||
| **Настройка** | `npx @siteboon/claude-code-ui` | Настройка не требуется |
|
||||
| **Настройка** | `npx @cloudcli-ai/cloudcli` | Настройка не требуется |
|
||||
| **Машина должна оставаться включённой** | Да | Нет |
|
||||
| **Доступ с мобильных устройств** | Любой браузер в вашей сети | Любое устройство, нативное приложение в разработке |
|
||||
| **Доступные сессии** | Все сессии автоматически обнаруживаются из `~/.claude` | Все сессии внутри вашей облачной среды |
|
||||
|
||||
@@ -75,13 +75,13 @@
|
||||
启动 CloudCLI UI,只需一行 `npx`(需要 Node.js v22+):
|
||||
|
||||
```bash
|
||||
npx @siteboon/claude-code-ui
|
||||
npx @cloudcli-ai/cloudcli
|
||||
```
|
||||
|
||||
或进行全局安装,便于日常使用:
|
||||
|
||||
```bash
|
||||
npm install -g @siteboon/claude-code-ui
|
||||
npm install -g @cloudcli-ai/cloudcli
|
||||
cloudcli
|
||||
```
|
||||
|
||||
@@ -99,7 +99,7 @@ CloudCLI UI 是 CloudCLI Cloud 的开源 UI 层。你可以在本地机器上自
|
||||
|---|---|---|
|
||||
| **适合对象** | 需要为本地代理会话提供完整 UI 的开发者 | 需要部署在云端,随时从任何地方访问代理的团队与开发者 |
|
||||
| **访问方式** | 通过 `[yourip]:port` 在浏览器中访问 | 浏览器、任意 IDE、REST API、n8n |
|
||||
| **设置** | `npx @siteboon/claude-code-ui` | 无需设置 |
|
||||
| **设置** | `npx @cloudcli-ai/cloudcli` | 无需设置 |
|
||||
| **机器需保持开机吗** | 是 | 否 |
|
||||
| **移动端访问** | 网络内任意浏览器 | 任意设备(原生应用即将推出) |
|
||||
| **可用会话** | 自动发现 `~/.claude` 中的所有会话 | 云端环境内的会话 |
|
||||
|
||||
89
docker/README.md
Normal file
89
docker/README.md
Normal file
@@ -0,0 +1,89 @@
|
||||
# CloudCLI — Docker Sandbox Templates
|
||||
|
||||
Run AI coding agents with a full web IDE inside [Docker Sandboxes](https://docs.docker.com/ai/sandboxes/).
|
||||
|
||||
Instead of a terminal-only experience, get a browser-based interface with chat, file explorer, git panel, shell, and MCP configuration — all running safely inside an isolated sandbox.
|
||||
|
||||
## Available Templates
|
||||
|
||||
| Template | Base Image | Agent |
|
||||
|----------|-----------|-------|
|
||||
| `cloudcli-ai/sandbox:claude-code` | `docker/sandbox-templates:claude-code` | Claude Code |
|
||||
| `cloudcli-ai/sandbox:codex` | `docker/sandbox-templates:codex` | OpenAI Codex |
|
||||
| `cloudcli-ai/sandbox:gemini` | `docker/sandbox-templates:gemini` | Gemini CLI |
|
||||
|
||||
## Quick Start
|
||||
|
||||
### 1. Start a sandbox with the template
|
||||
|
||||
```bash
|
||||
sbx run --template docker.io/cloudcli-ai/sandbox:claude-code claude ~/my-project
|
||||
```
|
||||
|
||||
### 2. Forward the UI port
|
||||
|
||||
```bash
|
||||
sbx ports <sandbox-name> --publish 3001:3001
|
||||
```
|
||||
|
||||
### 3. Open the browser
|
||||
|
||||
```
|
||||
http://localhost:3001
|
||||
```
|
||||
|
||||
On first visit you'll set a password — this protects the UI if the port is ever exposed beyond localhost.
|
||||
|
||||
## What You Get
|
||||
|
||||
- **Chat** — Rich conversation UI with markdown rendering, code blocks, and message history
|
||||
- **Files** — Visual file tree with syntax-highlighted editor
|
||||
- **Git** — Diff viewer, staging, branch switching, and commit — all visual
|
||||
- **Shell** — Built-in terminal emulator
|
||||
- **MCP** — Configure Model Context Protocol servers through the UI
|
||||
- **Mobile** — Works on tablet and phone browsers
|
||||
|
||||
## Building Locally
|
||||
|
||||
All Dockerfiles share scripts from `shared/`. Build with the `docker/` directory as context:
|
||||
|
||||
```bash
|
||||
# Claude Code variant
|
||||
docker build -f docker/claude-code/Dockerfile -t cloudcli-sandbox:claude-code docker/
|
||||
|
||||
# Codex variant
|
||||
docker build -f docker/codex/Dockerfile -t cloudcli-sandbox:codex docker/
|
||||
|
||||
# Gemini variant
|
||||
docker build -f docker/gemini/Dockerfile -t cloudcli-sandbox:gemini docker/
|
||||
```
|
||||
|
||||
## How It Works
|
||||
|
||||
Each template extends Docker's official sandbox base image and adds:
|
||||
|
||||
1. **Node.js 22** — Runtime for CloudCLI
|
||||
2. **CloudCLI** — Installed globally via `npm install -g @cloudcli-ai/cloudcli`
|
||||
3. **Auto-start** — The UI server starts in the background when the sandbox shell opens (port 3001)
|
||||
|
||||
The agent (Claude Code, Codex, or Gemini) comes from the base image. CloudCLI connects to it and provides the web interface on top.
|
||||
|
||||
## Configuration
|
||||
|
||||
| Environment Variable | Default | Description |
|
||||
|---------------------|---------|-------------|
|
||||
| `SERVER_PORT` | `3001` | Port for the web UI |
|
||||
| `HOST` | `0.0.0.0` | Bind address |
|
||||
| `DATABASE_PATH` | `~/.cloudcli/auth.db` | SQLite database location |
|
||||
|
||||
## Network Policies
|
||||
|
||||
If your sandbox uses restricted network policies, allow the UI port:
|
||||
|
||||
```bash
|
||||
sbx policy allow network "localhost:3001"
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
These templates are free and open-source under the same license as CloudCLI (AGPL-3.0-or-later).
|
||||
11
docker/claude-code/Dockerfile
Normal file
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
|
||||
|
||||
COPY shared/start-cloudcli.sh /home/agent/.cloudcli-start.sh
|
||||
RUN echo '. ~/.cloudcli-start.sh' >> /home/agent/.bashrc
|
||||
11
docker/codex/Dockerfile
Normal file
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
|
||||
|
||||
COPY shared/start-cloudcli.sh /home/agent/.cloudcli-start.sh
|
||||
RUN echo '. ~/.cloudcli-start.sh' >> /home/agent/.bashrc
|
||||
11
docker/gemini/Dockerfile
Normal file
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
|
||||
|
||||
COPY shared/start-cloudcli.sh /home/agent/.cloudcli-start.sh
|
||||
RUN echo '. ~/.cloudcli-start.sh' >> /home/agent/.bashrc
|
||||
14
docker/shared/install-cloudcli.sh
Normal file
14
docker/shared/install-cloudcli.sh
Normal file
@@ -0,0 +1,14 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
# Install Node.js 22 LTS
|
||||
curl -fsSL https://deb.nodesource.com/setup_22.x | bash -
|
||||
|
||||
# Install Node.js + build tools needed for native modules (node-pty, better-sqlite3, bcrypt)
|
||||
# Node.js + build tools for native modules + common dev tools
|
||||
apt-get install -y --no-install-recommends \
|
||||
nodejs 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/*
|
||||
23
docker/shared/start-cloudcli.sh
Normal file
23
docker/shared/start-cloudcli.sh
Normal file
@@ -0,0 +1,23 @@
|
||||
#!/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
|
||||
# Start the pre-installed version immediately
|
||||
nohup cloudcli start --port 3001 > /tmp/cloudcli-ui.log 2>&1 &
|
||||
disown
|
||||
|
||||
# Check for updates in the background (non-blocking)
|
||||
nohup npm update -g @cloudcli-ai/cloudcli > /tmp/cloudcli-update.log 2>&1 &
|
||||
disown
|
||||
|
||||
echo ""
|
||||
echo " CloudCLI is starting on port 3001..."
|
||||
echo ""
|
||||
echo " To access the web UI, forward the port:"
|
||||
echo " sbx ports \$(hostname) --publish 3001:3001"
|
||||
echo ""
|
||||
echo " Then open: http://localhost:3001"
|
||||
echo ""
|
||||
fi
|
||||
@@ -1,144 +0,0 @@
|
||||
transport,method,path,tag,authMode,sourceFile,sourceLine,purpose,consumerFiles,pathParams,queryParams,bodyHints,successShape,errorShape,sideEffects,priority
|
||||
"http","GET","/health","System","public","server/index.js","345","Expose server health, timestamp, and install mode for diagnostics.","src/hooks/useVersionCheck.ts","","","","Structured JSON object response.","Handler-specific error behavior.","Read-only backend query.","low"
|
||||
"http","POST","/api/system/update","System","bearer_token","server/index.js","425","Run the application update workflow on the host machine.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","","","","Structured JSON object response.","JSON error response with HTTP status code.","Mutates backend or external state.","low"
|
||||
"http","GET","/api/projects","Projects","bearer_token","server/index.js","491","List detected projects and workspaces.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","","","","JSON payload returned directly from service logic.","JSON object with error message and optional details.","Touches local workspace files or directories.","high"
|
||||
"http","GET","/api/projects/:projectName/sessions","Sessions","bearer_token","server/index.js","500","List or manage sessions associated with a project or provider.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","projectName","offset; try {
|
||||
const { limit","","JSON payload returned directly from service logic.","JSON object with error message and optional details.","Touches local workspace files or directories.","high"
|
||||
"http","GET","/api/projects/:projectName/sessions/:sessionId/messages","Sessions","bearer_token","server/index.js","512","Return paginated messages for a stored session.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","projectName; sessionId","limit; offset","","Structured JSON object response.","JSON object with error message and optional details.","Touches local workspace files or directories.","high"
|
||||
"http","PUT","/api/projects/:projectName/rename","Projects","bearer_token","server/index.js","537","PUT /api/projects/:projectName/rename for backend runtime support.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","projectName","","try {
|
||||
const { displayName","JSON object with an explicit success flag and payload.","JSON object with error message and optional details.","Mutates backend or external state.; Touches local workspace files or directories.","high"
|
||||
"http","DELETE","/api/projects/:projectName/sessions/:sessionId","Sessions","bearer_token","server/index.js","548","List or manage sessions associated with a project or provider.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","projectName; sessionId","","","JSON object with an explicit success flag and payload.","JSON object with error message and optional details.","Mutates backend or external state.; Touches local workspace files or directories.","high"
|
||||
"http","PUT","/api/sessions/:sessionId/rename","Sessions","bearer_token","server/index.js","563","List or manage sessions associated with a project or provider.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","sessionId","","provider; summary","JSON object with an explicit success flag and payload.","JSON object with error message and optional details.","Mutates backend or external state.","low"
|
||||
"http","DELETE","/api/projects/:projectName","Projects","bearer_token","server/index.js","589","DELETE /api/projects/:projectName for backend runtime support.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","projectName","force","","JSON object with an explicit success flag and payload.","JSON object with error message and optional details.","Mutates backend or external state.; Touches local workspace files or directories.","high"
|
||||
"http","POST","/api/projects/create","Projects","bearer_token","server/index.js","601","Manually add a project path to the workspace list.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","","","try {
|
||||
const { path","JSON object with an explicit success flag and payload.","JSON object with error message and optional details.","Mutates backend or external state.; Touches local workspace files or directories.","high"
|
||||
"sse","GET","/api/search/conversations","Sessions","bearer_token","server/index.js","618","Search conversation history across stored projects and stream results.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","","limit; q","","Server-sent events stream with progress/result/error events.","Streamed error event or JSON error fallback.","Read-only backend query.","high"
|
||||
"http","GET","/api/browse-filesystem","Realtime","bearer_token","server/index.js","674","Browse local directories so the UI can suggest workspace locations.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","","try {
|
||||
const { path","","Structured JSON object response.","JSON object with error message and optional details.","Read-only backend query.","low"
|
||||
"http","POST","/api/create-folder","Projects","bearer_token","server/index.js","754","Create a new directory on the local filesystem.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","","","try {
|
||||
const { path","JSON object with an explicit success flag and payload.","JSON object with error message and optional details.","Mutates backend or external state.","low"
|
||||
"http","GET","/api/projects/:projectName/file","Files","bearer_token","server/index.js","795","Read, write, create, rename, delete, or upload project files.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","projectName","filePath","","Structured JSON object response.","JSON object with error message and optional details.","Touches local workspace files or directories.","high"
|
||||
"http","GET","/api/projects/:projectName/files/content","Files","bearer_token","server/index.js","835","Read, write, create, rename, delete, or upload project files.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","projectName","path","","Mixed response shape; inspect handler during refactor.","JSON object with error message and optional details.","Touches local workspace files or directories.","high"
|
||||
"http","PUT","/api/projects/:projectName/file","Files","bearer_token","server/index.js","888","Read, write, create, rename, delete, or upload project files.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","projectName","","content; filePath","Structured JSON object response.","JSON object with error message and optional details.","Mutates backend or external state.; Touches local workspace files or directories.","high"
|
||||
"http","GET","/api/projects/:projectName/files","Files","bearer_token","server/index.js","937","Read, write, create, rename, delete, or upload project files.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","projectName","","","JSON payload returned directly from service logic.","JSON object with error message and optional details.","Touches local workspace files or directories.","high"
|
||||
"http","POST","/api/projects/:projectName/files/create","Files","bearer_token","server/index.js","1016","Read, write, create, rename, delete, or upload project files.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","projectName","","name; path; type","Structured JSON object response.","JSON object with error message and optional details.","Mutates backend or external state.; Touches local workspace files or directories.","high"
|
||||
"http","PUT","/api/projects/:projectName/files/rename","Files","bearer_token","server/index.js","1093","Read, write, create, rename, delete, or upload project files.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","projectName","","newName; oldPath","Structured JSON object response.","JSON object with error message and optional details.","Mutates backend or external state.; Touches local workspace files or directories.","high"
|
||||
"http","DELETE","/api/projects/:projectName/files","Files","bearer_token","server/index.js","1170","Read, write, create, rename, delete, or upload project files.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","projectName","","path; relativePaths; targetPath; type","Structured JSON object response.","JSON object with error message and optional details.","Mutates backend or external state.; Touches local workspace files or directories.","high"
|
||||
"http","POST","/api/projects/:projectName/files/upload","Files","bearer_token","server/index.js","1396","Read, write, create, rename, delete, or upload project files.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","projectName","","","Mixed response shape; inspect handler during refactor.","Handler-specific error behavior.","Mutates backend or external state.; Touches local workspace files or directories.","high"
|
||||
"http","POST","/api/transcribe","Realtime","bearer_token","server/index.js","1964","Transcribe uploaded audio and optionally enhance the result for prompts or tasks.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","","","mode","Structured JSON object response.","JSON object with error message and optional details.","Mutates backend or external state.; Processes uploaded files and external model responses.","low"
|
||||
"http","POST","/api/projects/:projectName/upload-images","Files","bearer_token","server/index.js","2113","Upload images for chat use and return browser-safe data URLs.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","projectName","","","Structured JSON object response.","JSON object with error message and optional details.","Mutates backend or external state.; Touches local workspace files or directories.","high"
|
||||
"http","GET","/api/projects/:projectName/sessions/:sessionId/token-usage","Sessions","bearer_token","server/index.js","2198","Report token usage for a stored provider session.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","projectName; sessionId","provider","","Structured JSON object response.","JSON object with error message and optional details.","Touches local workspace files or directories.","high"
|
||||
"http","GET","*","System","public","server/index.js","2386","Serve the React application fallback for non-API routes.","","","","","Static file or HTML response.","JSON error response with HTTP status code.","Read-only backend query.","low"
|
||||
"http","GET","/api/auth/status","Auth","public","server/routes/auth.js","9","Report whether authentication is configured.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","","","","Structured JSON object response.","JSON object with error message and optional details.","Reads or writes local authentication or credential state.","medium"
|
||||
"http","POST","/api/auth/register","Auth","public","server/routes/auth.js","23","Create the first local user account.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","","","password; try {
|
||||
const { username","Structured JSON object response.","JSON object with error message and optional details.","Mutates backend or external state.; Reads or writes local authentication or credential state.","medium"
|
||||
"http","POST","/api/auth/login","Auth","public","server/routes/auth.js","82","Authenticate a local user and issue a token.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","","","password; try {
|
||||
const { username","Structured JSON object response.","JSON object with error message and optional details.","Mutates backend or external state.; Reads or writes local authentication or credential state.","medium"
|
||||
"http","GET","/api/auth/user","Auth","bearer_token","server/routes/auth.js","122","Return the currently authenticated user.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","","","","Structured JSON object response.","Handler-specific error behavior.","Reads or writes local authentication or credential state.","medium"
|
||||
"http","POST","/api/auth/logout","Auth","bearer_token","server/routes/auth.js","129","Invalidate the current authenticated session.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","","","","JSON object with an explicit success flag and payload.","Handler-specific error behavior.","Mutates backend or external state.; Reads or writes local authentication or credential state.","medium"
|
||||
"http","POST","/api/projects/create-workspace","Projects","bearer_token","server/routes/projects.js","175","Create or register a workspace and optionally clone a GitHub repository into it.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","","","githubTokenId; githubUrl; newGithubToken; path; try {
|
||||
const { workspaceType","Structured JSON object response.","JSON validation error response.","Mutates backend or external state.; Touches local workspace files or directories.","high"
|
||||
"sse","GET","/api/projects/clone-progress","Projects","bearer_token","server/routes/projects.js","335","Stream workspace cloning progress events to the frontend.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","","const { path; githubTokenId; githubUrl; newGithubToken","","Server-sent events stream with progress/result/error events.","Streamed error event or JSON error fallback.","Touches local workspace files or directories.","high"
|
||||
"http","GET","/api/git/status","Git","bearer_token","server/routes/git.js","291","Read git status information for a project.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","","const { project","","Structured JSON object response.","JSON validation error response.","Touches git repositories or local git config.","high"
|
||||
"http","GET","/api/git/diff","Git","bearer_token","server/routes/git.js","354","Return git diff output for a project or file.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","","const { project; file","","Structured JSON object response.","JSON validation error response.","Touches git repositories or local git config.","high"
|
||||
"http","GET","/api/git/file-with-diff","Git","bearer_token","server/routes/git.js","437","Read, write, create, rename, delete, or upload project files.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","","const { project; file","","Structured JSON object response.","JSON validation error response.","Touches git repositories or local git config.; Touches local workspace files or directories.","high"
|
||||
"http","POST","/api/git/initial-commit","Git","bearer_token","server/routes/git.js","517","POST /api/git/initial-commit for backend runtime support.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","","","const { project","JSON object with an explicit success flag and payload.","JSON object with error message and optional details.","Mutates backend or external state.; Touches git repositories or local git config.","high"
|
||||
"http","POST","/api/git/commit","Git","bearer_token","server/routes/git.js","561","POST /api/git/commit for backend runtime support.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","","","const { project; files; message","JSON object with an explicit success flag and payload.","JSON object with error message and optional details.","Mutates backend or external state.; Touches git repositories or local git config.","high"
|
||||
"http","POST","/api/git/revert-local-commit","Git","bearer_token","server/routes/git.js","592","POST /api/git/revert-local-commit for backend runtime support.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","","","const { project","Structured JSON object response.","JSON object with error message and optional details.","Mutates backend or external state.; Touches git repositories or local git config.","high"
|
||||
"http","GET","/api/git/branches","Git","bearer_token","server/routes/git.js","639","List git branches for a project.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","","const { project","","Structured JSON object response.","JSON validation error response.","Touches git repositories or local git config.","high"
|
||||
"http","POST","/api/git/checkout","Git","bearer_token","server/routes/git.js","681","POST /api/git/checkout for backend runtime support.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","","","branch; const { project","JSON object with an explicit success flag and payload.","JSON object with error message and optional details.","Mutates backend or external state.; Touches git repositories or local git config.","high"
|
||||
"http","POST","/api/git/create-branch","Git","bearer_token","server/routes/git.js","703","POST /api/git/create-branch for backend runtime support.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","","","branch; const { project","JSON object with an explicit success flag and payload.","JSON object with error message and optional details.","Mutates backend or external state.; Touches git repositories or local git config.","high"
|
||||
"http","GET","/api/git/commits","Git","bearer_token","server/routes/git.js","725","List recent commits for a project.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","","const { project; limit","","Structured JSON object response.","JSON validation error response.","Touches git repositories or local git config.","high"
|
||||
"http","GET","/api/git/commit-diff","Git","bearer_token","server/routes/git.js","782","Return diff details for a specific commit.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","","commit; const { project","","Structured JSON object response.","JSON validation error response.","Touches git repositories or local git config.","high"
|
||||
"http","POST","/api/git/generate-commit-message","Git","bearer_token","server/routes/git.js","814","Generate an AI-assisted commit message from the current diff.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","","","const { project; files; provider","Structured JSON object response.","JSON object with error message and optional details.","Mutates backend or external state.; Touches git repositories or local git config.","high"
|
||||
"http","GET","/api/git/remote-status","Git","bearer_token","server/routes/git.js","1019","Report remote sync status for a project repository.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","","const { project","","Structured JSON object response.","JSON validation error response.","Touches git repositories or local git config.","high"
|
||||
"http","POST","/api/git/fetch","Git","bearer_token","server/routes/git.js","1097","POST /api/git/fetch for backend runtime support.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","","","const { project","JSON object with an explicit success flag and payload.","JSON validation error response.","Mutates backend or external state.; Touches git repositories or local git config.","high"
|
||||
"http","POST","/api/git/pull","Git","bearer_token","server/routes/git.js","1138","POST /api/git/pull for backend runtime support.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","","","const { project","Structured JSON object response.","JSON validation error response.","Mutates backend or external state.; Touches git repositories or local git config.","high"
|
||||
"http","POST","/api/git/push","Git","bearer_token","server/routes/git.js","1206","POST /api/git/push for backend runtime support.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","","","const { project","Structured JSON object response.","JSON validation error response.","Mutates backend or external state.; Touches git repositories or local git config.","high"
|
||||
"http","POST","/api/git/publish","Git","bearer_token","server/routes/git.js","1277","POST /api/git/publish for backend runtime support.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","","","branch; const { project","Structured JSON object response.","JSON validation error response.","Mutates backend or external state.; Touches git repositories or local git config.","high"
|
||||
"http","POST","/api/git/discard","Git","bearer_token","server/routes/git.js","1356","POST /api/git/discard for backend runtime support.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","","","const { project; file","JSON object with an explicit success flag and payload.","JSON object with error message and optional details.","Mutates backend or external state.; Touches git repositories or local git config.","high"
|
||||
"http","POST","/api/git/delete-untracked","Git","bearer_token","server/routes/git.js","1410","POST /api/git/delete-untracked for backend runtime support.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","","","const { project; file","JSON object with an explicit success flag and payload.","JSON object with error message and optional details.","Mutates backend or external state.; Touches git repositories or local git config.","high"
|
||||
"http","GET","/api/mcp/cli/list","MCP","bearer_token","server/routes/mcp.js","16","Manage Claude MCP CLI and configuration state.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","","","","JSON object with an explicit success flag and payload.","JSON object with error message and optional details.","Reads or writes MCP CLI configuration.","medium"
|
||||
"http","POST","/api/mcp/cli/add","MCP","bearer_token","server/routes/mcp.js","59","Manage Claude MCP CLI and configuration state.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","","","","JSON object with an explicit success flag and payload.","JSON object with error message and optional details.","Mutates backend or external state.; Reads or writes MCP CLI configuration.","medium"
|
||||
"http","POST","/api/mcp/cli/add-json","MCP","bearer_token","server/routes/mcp.js","142","Manage Claude MCP CLI and configuration state.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","","","jsonConfig; projectPath; scope; try {
|
||||
const { name","JSON object with an explicit success flag and payload.","JSON object with error message and optional details.","Mutates backend or external state.; Reads or writes MCP CLI configuration.","medium"
|
||||
"http","DELETE","/api/mcp/cli/remove/:name","MCP","bearer_token","server/routes/mcp.js","235","Manage Claude MCP CLI and configuration state.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","name","scope","","JSON object with an explicit success flag and payload.","JSON object with error message and optional details.","Mutates backend or external state.; Reads or writes MCP CLI configuration.","medium"
|
||||
"http","GET","/api/mcp/cli/get/:name","MCP","bearer_token","server/routes/mcp.js","305","Manage Claude MCP CLI and configuration state.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","name","","","JSON object with an explicit success flag and payload.","JSON object with error message and optional details.","Reads or writes MCP CLI configuration.","medium"
|
||||
"http","GET","/api/mcp/config/read","MCP","bearer_token","server/routes/mcp.js","348","Manage Claude MCP CLI and configuration state.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","","","","Structured JSON object response.","JSON error response with HTTP status code.","Reads or writes MCP CLI configuration.","medium"
|
||||
"http","GET","/api/cursor/config","Providers","bearer_token","server/routes/cursor.js","15","Manage Cursor configuration, MCP settings, and stored sessions.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","","","","Structured JSON object response.","JSON error response with HTTP status code.","Read-only backend query.","medium"
|
||||
"http","POST","/api/cursor/config","Providers","bearer_token","server/routes/cursor.js","59","Manage Cursor configuration, MCP settings, and stored sessions.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","","","model; try {
|
||||
const { permissions","Structured JSON object response.","JSON error response with HTTP status code.","Mutates backend or external state.","medium"
|
||||
"http","GET","/api/cursor/mcp","Providers","bearer_token","server/routes/cursor.js","122","Manage Cursor configuration, MCP settings, and stored sessions.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","","","","Structured JSON object response.","JSON error response with HTTP status code.","Reads or writes MCP CLI configuration.","medium"
|
||||
"http","POST","/api/cursor/mcp/add","Providers","bearer_token","server/routes/cursor.js","183","Manage Cursor configuration, MCP settings, and stored sessions.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","","","","Structured JSON object response.","JSON error response with HTTP status code.","Mutates backend or external state.; Reads or writes MCP CLI configuration.","medium"
|
||||
"http","DELETE","/api/cursor/mcp/:name","Providers","bearer_token","server/routes/cursor.js","245","Manage Cursor configuration, MCP settings, and stored sessions.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","name","","","Structured JSON object response.","JSON error response with HTTP status code.","Mutates backend or external state.; Reads or writes MCP CLI configuration.","medium"
|
||||
"http","POST","/api/cursor/mcp/add-json","Providers","bearer_token","server/routes/cursor.js","292","Manage Cursor configuration, MCP settings, and stored sessions.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","","","jsonConfig; try {
|
||||
const { name","Structured JSON object response.","JSON error response with HTTP status code.","Mutates backend or external state.; Reads or writes MCP CLI configuration.","medium"
|
||||
"http","GET","/api/cursor/sessions","Providers","bearer_token","server/routes/cursor.js","348","List or manage sessions associated with a project or provider.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","","try {
|
||||
const { projectPath","","Structured JSON object response.","JSON error response with HTTP status code.","Read-only backend query.","medium"
|
||||
"http","GET","/api/cursor/sessions/:sessionId","Providers","bearer_token","server/routes/cursor.js","583","List or manage sessions associated with a project or provider.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","sessionId","projectPath","","Structured JSON object response.","JSON error response with HTTP status code.","Read-only backend query.","medium"
|
||||
"http","GET","/api/taskmaster/installation-status","TaskMaster","bearer_token","server/routes/taskmaster.js","243","Manage TaskMaster detection, PRDs, tasks, templates, and automation for a project.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","","","","Structured JSON object response.","JSON error response with HTTP status code.","Reads or writes TaskMaster project assets.","high"
|
||||
"http","GET","/api/taskmaster/detect/:projectName","TaskMaster","bearer_token","server/routes/taskmaster.js","278","Manage TaskMaster detection, PRDs, tasks, templates, and automation for a project.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","projectName","","","JSON payload returned directly from service logic.","JSON error response with HTTP status code.","Reads or writes TaskMaster project assets.","high"
|
||||
"http","GET","/api/taskmaster/detect-all","TaskMaster","bearer_token","server/routes/taskmaster.js","350","Manage TaskMaster detection, PRDs, tasks, templates, and automation for a project.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","","","","Structured JSON object response.","JSON error response with HTTP status code.","Reads or writes TaskMaster project assets.","high"
|
||||
"http","POST","/api/taskmaster/initialize/:projectName","TaskMaster","bearer_token","server/routes/taskmaster.js","434","Manage TaskMaster detection, PRDs, tasks, templates, and automation for a project.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","projectName","","rules","Mixed response shape; inspect handler during refactor.","JSON error response with HTTP status code.","Mutates backend or external state.; Reads or writes TaskMaster project assets.","high"
|
||||
"http","GET","/api/taskmaster/next/:projectName","TaskMaster","bearer_token","server/routes/taskmaster.js","460","Manage TaskMaster detection, PRDs, tasks, templates, and automation for a project.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","projectName","","","Structured JSON object response.","JSON error response with HTTP status code.","Reads or writes TaskMaster project assets.","high"
|
||||
"http","GET","/api/taskmaster/tasks/:projectName","TaskMaster","bearer_token","server/routes/taskmaster.js","570","Manage TaskMaster detection, PRDs, tasks, templates, and automation for a project.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","projectName","","","Structured JSON object response.","JSON error response with HTTP status code.","Reads or writes TaskMaster project assets.","high"
|
||||
"http","GET","/api/taskmaster/prd/:projectName","TaskMaster","bearer_token","server/routes/taskmaster.js","685","Manage TaskMaster detection, PRDs, tasks, templates, and automation for a project.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","projectName","","","Structured JSON object response.","JSON error response with HTTP status code.","Reads or writes TaskMaster project assets.","high"
|
||||
"http","POST","/api/taskmaster/prd/:projectName","TaskMaster","bearer_token","server/routes/taskmaster.js","761","Manage TaskMaster detection, PRDs, tasks, templates, and automation for a project.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","projectName","","content; fileName","Structured JSON object response.","JSON error response with HTTP status code.","Mutates backend or external state.; Reads or writes TaskMaster project assets.","high"
|
||||
"http","GET","/api/taskmaster/prd/:projectName/:fileName","TaskMaster","bearer_token","server/routes/taskmaster.js","846","Manage TaskMaster detection, PRDs, tasks, templates, and automation for a project.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","projectName; fileName","","","Structured JSON object response.","JSON error response with HTTP status code.","Reads or writes TaskMaster project assets.","high"
|
||||
"http","DELETE","/api/taskmaster/prd/:projectName/:fileName","TaskMaster","bearer_token","server/routes/taskmaster.js","911","Manage TaskMaster detection, PRDs, tasks, templates, and automation for a project.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","projectName; fileName","","","Structured JSON object response.","JSON error response with HTTP status code.","Mutates backend or external state.; Reads or writes TaskMaster project assets.","high"
|
||||
"http","POST","/api/taskmaster/init/:projectName","TaskMaster","bearer_token","server/routes/taskmaster.js","971","Manage TaskMaster detection, PRDs, tasks, templates, and automation for a project.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","projectName","","","Structured JSON object response.","JSON error response with HTTP status code.","Mutates backend or external state.; Reads or writes TaskMaster project assets.","high"
|
||||
"http","POST","/api/taskmaster/add-task/:projectName","TaskMaster","bearer_token","server/routes/taskmaster.js","1060","Manage TaskMaster detection, PRDs, tasks, templates, and automation for a project.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","projectName","","dependencies; description; priority; prompt; title","Structured JSON object response.","JSON error response with HTTP status code.","Mutates backend or external state.; Reads or writes TaskMaster project assets.","high"
|
||||
"http","PUT","/api/taskmaster/update-task/:projectName/:taskId","TaskMaster","bearer_token","server/routes/taskmaster.js","1164","Manage TaskMaster detection, PRDs, tasks, templates, and automation for a project.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","projectName; taskId","","description; details; priority; status; title","Structured JSON object response.","JSON error response with HTTP status code.","Mutates backend or external state.; Reads or writes TaskMaster project assets.","high"
|
||||
"http","POST","/api/taskmaster/parse-prd/:projectName","TaskMaster","bearer_token","server/routes/taskmaster.js","1291","Manage TaskMaster detection, PRDs, tasks, templates, and automation for a project.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","projectName","","append; fileName; numTasks","Structured JSON object response.","JSON error response with HTTP status code.","Mutates backend or external state.; Reads or writes TaskMaster project assets.","high"
|
||||
"http","GET","/api/taskmaster/prd-templates","TaskMaster","bearer_token","server/routes/taskmaster.js","1392","Manage TaskMaster detection, PRDs, tasks, templates, and automation for a project.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","","","","Structured JSON object response.","JSON error response with HTTP status code.","Reads or writes TaskMaster project assets.","high"
|
||||
"http","POST","/api/taskmaster/apply-template/:projectName","TaskMaster","bearer_token","server/routes/taskmaster.js","1838","Manage TaskMaster detection, PRDs, tasks, templates, and automation for a project.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","projectName","","","Structured JSON object response.","JSON error response with HTTP status code.","Mutates backend or external state.; Reads or writes TaskMaster project assets.","high"
|
||||
"http","GET","/api/mcp-utils/taskmaster-server","MCP","bearer_token","server/routes/mcp-utils.js","18","Return MCP helper information used by setup flows.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","","","","JSON payload returned directly from service logic.","JSON error response with HTTP status code.","Reads or writes TaskMaster project assets.; Reads or writes MCP CLI configuration.","medium"
|
||||
"http","GET","/api/mcp-utils/all-servers","MCP","bearer_token","server/routes/mcp-utils.js","35","Return MCP helper information used by setup flows.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","","","","JSON payload returned directly from service logic.","JSON error response with HTTP status code.","Reads or writes MCP CLI configuration.","medium"
|
||||
"http","POST","/api/commands/list","Commands","bearer_token","server/routes/commands.js","406","List, load, or execute slash commands available to the chat experience.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","","","try {
|
||||
const { projectPath","Structured JSON object response.","JSON error response with HTTP status code.","Mutates backend or external state.","medium"
|
||||
"http","POST","/api/commands/load","Commands","bearer_token","server/routes/commands.js","456","List, load, or execute slash commands available to the chat experience.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","","","commandPath; try {
|
||||
const { commandPath","Structured JSON object response.","JSON error response with HTTP status code.","Mutates backend or external state.","medium"
|
||||
"http","POST","/api/commands/execute","Commands","bearer_token","server/routes/commands.js","507","List, load, or execute slash commands available to the chat experience.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","","","commandPath","Structured JSON object response.","JSON error response with HTTP status code.","Mutates backend or external state.","medium"
|
||||
"http","GET","/api/settings/api-keys","Settings","bearer_token","server/routes/settings.js","11","Manage local API keys used to access the backend.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","","","","Structured JSON object response.","JSON object with error message and optional details.","Reads or writes local authentication or credential state.","medium"
|
||||
"http","POST","/api/settings/api-keys","Settings","bearer_token","server/routes/settings.js","27","Manage local API keys used to access the backend.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","","","try {
|
||||
const { keyName","Structured JSON object response.","JSON object with error message and optional details.","Mutates backend or external state.; Reads or writes local authentication or credential state.","medium"
|
||||
"http","DELETE","/api/settings/api-keys/:keyId","Settings","bearer_token","server/routes/settings.js","47","Manage local API keys used to access the backend.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","keyId","","","JSON object with an explicit success flag and payload.","JSON object with error message and optional details.","Mutates backend or external state.; Reads or writes local authentication or credential state.","medium"
|
||||
"http","PATCH","/api/settings/api-keys/:keyId/toggle","Settings","bearer_token","server/routes/settings.js","64","Manage local API keys used to access the backend.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","keyId","","isActive","JSON object with an explicit success flag and payload.","JSON object with error message and optional details.","Mutates backend or external state.; Reads or writes local authentication or credential state.","medium"
|
||||
"http","GET","/api/settings/credentials","Settings","bearer_token","server/routes/settings.js","91","Manage stored provider and GitHub credentials.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","","try {
|
||||
const { type","","Structured JSON object response.","JSON object with error message and optional details.","Reads or writes local authentication or credential state.","medium"
|
||||
"http","POST","/api/settings/credentials","Settings","bearer_token","server/routes/settings.js","104","Manage stored provider and GitHub credentials.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","","","credentialType; credentialValue; description; try {
|
||||
const { credentialName","Structured JSON object response.","JSON object with error message and optional details.","Mutates backend or external state.; Reads or writes local authentication or credential state.","medium"
|
||||
"http","DELETE","/api/settings/credentials/:credentialId","Settings","bearer_token","server/routes/settings.js","139","Manage stored provider and GitHub credentials.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","credentialId","","","JSON object with an explicit success flag and payload.","JSON object with error message and optional details.","Mutates backend or external state.; Reads or writes local authentication or credential state.","medium"
|
||||
"http","PATCH","/api/settings/credentials/:credentialId/toggle","Settings","bearer_token","server/routes/settings.js","156","Manage stored provider and GitHub credentials.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","credentialId","","isActive","JSON object with an explicit success flag and payload.","JSON object with error message and optional details.","Mutates backend or external state.; Reads or writes local authentication or credential state.","medium"
|
||||
"http","GET","/api/cli/claude/status","CLI Auth","bearer_token","server/routes/cli-auth.js","9","Report local authentication status for provider CLIs.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","","","","Structured JSON object response.","JSON error response with HTTP status code.","Read-only backend query.","low"
|
||||
"http","GET","/api/cli/cursor/status","CLI Auth","bearer_token","server/routes/cli-auth.js","39","Report local authentication status for provider CLIs.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","","","","Structured JSON object response.","JSON error response with HTTP status code.","Read-only backend query.","low"
|
||||
"http","GET","/api/cli/codex/status","CLI Auth","bearer_token","server/routes/cli-auth.js","59","Report local authentication status for provider CLIs.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","","","","Structured JSON object response.","JSON error response with HTTP status code.","Read-only backend query.","low"
|
||||
"http","GET","/api/cli/gemini/status","CLI Auth","bearer_token","server/routes/cli-auth.js","79","Report local authentication status for provider CLIs.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","","","","Structured JSON object response.","JSON error response with HTTP status code.","Read-only backend query.","low"
|
||||
"http","GET","/api/user/git-config","User","bearer_token","server/routes/user.js","28","Read or update stored git identity settings.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","","","","Structured JSON object response.","JSON object with error message and optional details.","Touches git repositories or local git config.","medium"
|
||||
"http","POST","/api/user/git-config","User","bearer_token","server/routes/user.js","57","Read or update stored git identity settings.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","","","gitEmail; try {
|
||||
const userId = req.user.id;
|
||||
const { gitName","Structured JSON object response.","JSON object with error message and optional details.","Mutates backend or external state.; Touches git repositories or local git config.","medium"
|
||||
"http","POST","/api/user/complete-onboarding","User","bearer_token","server/routes/user.js","93","Mark onboarding as completed for the current user.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","","","","Structured JSON object response.","JSON object with error message and optional details.","Mutates backend or external state.","medium"
|
||||
"http","GET","/api/user/onboarding-status","User","bearer_token","server/routes/user.js","108","Return onboarding completion status for the current user.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","","","","Structured JSON object response.","JSON object with error message and optional details.","Read-only backend query.","medium"
|
||||
"http","GET","/api/codex/config","Providers","bearer_token","server/routes/codex.js","23","Manage Codex configuration, MCP settings, and stored sessions.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","","","","Structured JSON object response.","JSON error response with HTTP status code.","Read-only backend query.","medium"
|
||||
"http","GET","/api/codex/sessions","Providers","bearer_token","server/routes/codex.js","54","List or manage sessions associated with a project or provider.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","","try {
|
||||
const { projectPath","","JSON object with an explicit success flag and payload.","JSON error response with HTTP status code.","Read-only backend query.","medium"
|
||||
"http","GET","/api/codex/sessions/:sessionId/messages","Providers","bearer_token","server/routes/codex.js","71","Return paginated messages for a stored session.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","sessionId","limit; offset","","JSON object with an explicit success flag and payload.","JSON error response with HTTP status code.","Read-only backend query.","medium"
|
||||
"http","DELETE","/api/codex/sessions/:sessionId","Providers","bearer_token","server/routes/codex.js","89","List or manage sessions associated with a project or provider.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","sessionId","","","JSON object with an explicit success flag and payload.","JSON error response with HTTP status code.","Mutates backend or external state.","medium"
|
||||
"http","GET","/api/codex/mcp/cli/list","Providers","bearer_token","server/routes/codex.js","103","Manage Codex configuration, MCP settings, and stored sessions.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","","","","Mixed response shape; inspect handler during refactor.","JSON object with error message and optional details.","Reads or writes MCP CLI configuration.","medium"
|
||||
"http","POST","/api/codex/mcp/cli/add","Providers","bearer_token","server/routes/codex.js","135","Manage Codex configuration, MCP settings, and stored sessions.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","","","","Mixed response shape; inspect handler during refactor.","JSON object with error message and optional details.","Mutates backend or external state.; Reads or writes MCP CLI configuration.","medium"
|
||||
"http","DELETE","/api/codex/mcp/cli/remove/:name","Providers","bearer_token","server/routes/codex.js","186","Manage Codex configuration, MCP settings, and stored sessions.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","name","","","Mixed response shape; inspect handler during refactor.","JSON object with error message and optional details.","Mutates backend or external state.; Reads or writes MCP CLI configuration.","medium"
|
||||
"http","GET","/api/codex/mcp/cli/get/:name","Providers","bearer_token","server/routes/codex.js","220","Manage Codex configuration, MCP settings, and stored sessions.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","name","","","Mixed response shape; inspect handler during refactor.","JSON object with error message and optional details.","Reads or writes MCP CLI configuration.","medium"
|
||||
"http","GET","/api/codex/mcp/config/read","Providers","bearer_token","server/routes/codex.js","254","Manage Codex configuration, MCP settings, and stored sessions.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","","","","JSON object with an explicit success flag and payload.","JSON object with error message and optional details.","Reads or writes MCP CLI configuration.","medium"
|
||||
"http","GET","/api/gemini/sessions/:sessionId/messages","Providers","bearer_token","server/routes/gemini.js","8","Return paginated messages for a stored session.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","sessionId","","","Structured JSON object response.","JSON error response with HTTP status code.","Read-only backend query.","medium"
|
||||
"http","DELETE","/api/gemini/sessions/:sessionId","Providers","bearer_token","server/routes/gemini.js","37","List or manage sessions associated with a project or provider.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","sessionId","","","JSON object with an explicit success flag and payload.","JSON error response with HTTP status code.","Mutates backend or external state.","medium"
|
||||
"http","GET","/api/plugins","Plugins","bearer_token","server/routes/plugins.js","27","List, install, update, serve, enable, or remove plugins.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","","","","Structured JSON object response.","JSON object with error message and optional details.","Installs, updates, or serves plugin assets/processes.","medium"
|
||||
"http","GET","/api/plugins/:name/manifest","Plugins","bearer_token","server/routes/plugins.js","40","List, install, update, serve, enable, or remove plugins.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","name","","","JSON payload returned directly from service logic.","JSON object with error message and optional details.","Installs, updates, or serves plugin assets/processes.","medium"
|
||||
"http","GET","/api/plugins/:name/assets/*","Plugins","bearer_token","server/routes/plugins.js","57","List, install, update, serve, enable, or remove plugins.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","name","","","Mixed response shape; inspect handler during refactor.","JSON object with error message and optional details.","Installs, updates, or serves plugin assets/processes.","medium"
|
||||
"http","PUT","/api/plugins/:name/enable","Plugins","bearer_token","server/routes/plugins.js","96","List, install, update, serve, enable, or remove plugins.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","name","","try {
|
||||
const { enabled","JSON object with an explicit success flag and payload.","JSON object with error message and optional details.","Mutates backend or external state.; Installs, updates, or serves plugin assets/processes.","medium"
|
||||
"http","POST","/api/plugins/install","Plugins","bearer_token","server/routes/plugins.js","136","List, install, update, serve, enable, or remove plugins.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","","","try {
|
||||
const { url","JSON object with an explicit success flag and payload.","JSON validation error response.","Mutates backend or external state.; Installs, updates, or serves plugin assets/processes.","medium"
|
||||
"http","POST","/api/plugins/:name/update","Plugins","bearer_token","server/routes/plugins.js","169","List, install, update, serve, enable, or remove plugins.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","name","","","JSON object with an explicit success flag and payload.","JSON validation error response.","Mutates backend or external state.; Installs, updates, or serves plugin assets/processes.","medium"
|
||||
"http","DELETE","/api/plugins/:name","Plugins","bearer_token","server/routes/plugins.js","282","List, install, update, serve, enable, or remove plugins.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","name","","","JSON object with an explicit success flag and payload.","JSON validation error response.","Mutates backend or external state.; Installs, updates, or serves plugin assets/processes.","medium"
|
||||
"sse","POST","/api/agent","Agent","api_key_or_platform","server/routes/agent.js","839","Accept external agent jobs that run a provider against a local or cloned project.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","","","branchName; cleanup; const { githubUrl; createBranch; createPR; githubToken; message; model; projectPath; provider; stream","Server-sent events stream with progress/result/error events.","Streamed error event or JSON error fallback.","Mutates backend or external state.; Invokes external AI providers and may modify project files.","high"
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -1,217 +0,0 @@
|
||||
# Backend Inventory
|
||||
|
||||
Generated on 2026-03-11T17:31:18.119Z.
|
||||
|
||||
## Summary
|
||||
|
||||
- HTTP routes: 118
|
||||
- SSE routes: 3
|
||||
- Modular routes: 96
|
||||
- Inline routes: 25
|
||||
- Route files scanned: 16
|
||||
|
||||
## Realtime Contracts
|
||||
|
||||
- Incoming websocket message types (14): abort-session, check-session-status, claude-command, claude-permission-response, codex-command, cursor-abort, cursor-command, cursor-resume, gemini-command, get-active-sessions, get-pending-permissions, init, input, resize
|
||||
- Outgoing websocket message types (7): active-sessions, auth_url, error, output, pending-permissions-response, session-aborted, session-status
|
||||
|
||||
## Agent
|
||||
|
||||
| Method | Path | Auth | Purpose | Consumers | Source |
|
||||
| --- | --- | --- | --- | --- | --- |
|
||||
| POST | `/api/agent` | api_key_or_platform | Accept external agent jobs that run a provider against a local or cloned project. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/agent.js:839 |
|
||||
|
||||
## Auth
|
||||
|
||||
| Method | Path | Auth | Purpose | Consumers | Source |
|
||||
| --- | --- | --- | --- | --- | --- |
|
||||
| POST | `/api/auth/login` | public | Authenticate a local user and issue a token. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/auth.js:82 |
|
||||
| POST | `/api/auth/logout` | bearer_token | Invalidate the current authenticated session. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/auth.js:129 |
|
||||
| POST | `/api/auth/register` | public | Create the first local user account. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/auth.js:23 |
|
||||
| GET | `/api/auth/status` | public | Report whether authentication is configured. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/auth.js:9 |
|
||||
| GET | `/api/auth/user` | bearer_token | Return the currently authenticated user. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/auth.js:122 |
|
||||
|
||||
## CLI Auth
|
||||
|
||||
| Method | Path | Auth | Purpose | Consumers | Source |
|
||||
| --- | --- | --- | --- | --- | --- |
|
||||
| GET | `/api/cli/claude/status` | bearer_token | Report local authentication status for provider CLIs. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/cli-auth.js:9 |
|
||||
| GET | `/api/cli/codex/status` | bearer_token | Report local authentication status for provider CLIs. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/cli-auth.js:59 |
|
||||
| GET | `/api/cli/cursor/status` | bearer_token | Report local authentication status for provider CLIs. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/cli-auth.js:39 |
|
||||
| GET | `/api/cli/gemini/status` | bearer_token | Report local authentication status for provider CLIs. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/cli-auth.js:79 |
|
||||
|
||||
## Commands
|
||||
|
||||
| Method | Path | Auth | Purpose | Consumers | Source |
|
||||
| --- | --- | --- | --- | --- | --- |
|
||||
| POST | `/api/commands/execute` | bearer_token | List, load, or execute slash commands available to the chat experience. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/commands.js:507 |
|
||||
| POST | `/api/commands/list` | bearer_token | List, load, or execute slash commands available to the chat experience. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/commands.js:406 |
|
||||
| POST | `/api/commands/load` | bearer_token | List, load, or execute slash commands available to the chat experience. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/commands.js:456 |
|
||||
|
||||
## Files
|
||||
|
||||
| Method | Path | Auth | Purpose | Consumers | Source |
|
||||
| --- | --- | --- | --- | --- | --- |
|
||||
| GET | `/api/projects/:projectName/file` | bearer_token | Read, write, create, rename, delete, or upload project files. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/index.js:795 |
|
||||
| PUT | `/api/projects/:projectName/file` | bearer_token | Read, write, create, rename, delete, or upload project files. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/index.js:888 |
|
||||
| GET | `/api/projects/:projectName/files` | bearer_token | Read, write, create, rename, delete, or upload project files. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/index.js:937 |
|
||||
| DELETE | `/api/projects/:projectName/files` | bearer_token | Read, write, create, rename, delete, or upload project files. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/index.js:1170 |
|
||||
| GET | `/api/projects/:projectName/files/content` | bearer_token | Read, write, create, rename, delete, or upload project files. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/index.js:835 |
|
||||
| POST | `/api/projects/:projectName/files/create` | bearer_token | Read, write, create, rename, delete, or upload project files. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/index.js:1016 |
|
||||
| PUT | `/api/projects/:projectName/files/rename` | bearer_token | Read, write, create, rename, delete, or upload project files. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/index.js:1093 |
|
||||
| POST | `/api/projects/:projectName/files/upload` | bearer_token | Read, write, create, rename, delete, or upload project files. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/index.js:1396 |
|
||||
| POST | `/api/projects/:projectName/upload-images` | bearer_token | Upload images for chat use and return browser-safe data URLs. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/index.js:2113 |
|
||||
|
||||
## Git
|
||||
|
||||
| Method | Path | Auth | Purpose | Consumers | Source |
|
||||
| --- | --- | --- | --- | --- | --- |
|
||||
| GET | `/api/git/branches` | bearer_token | List git branches for a project. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/git.js:639 |
|
||||
| POST | `/api/git/checkout` | bearer_token | POST /api/git/checkout for backend runtime support. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/git.js:681 |
|
||||
| POST | `/api/git/commit` | bearer_token | POST /api/git/commit for backend runtime support. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/git.js:561 |
|
||||
| GET | `/api/git/commit-diff` | bearer_token | Return diff details for a specific commit. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/git.js:782 |
|
||||
| GET | `/api/git/commits` | bearer_token | List recent commits for a project. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/git.js:725 |
|
||||
| POST | `/api/git/create-branch` | bearer_token | POST /api/git/create-branch for backend runtime support. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/git.js:703 |
|
||||
| POST | `/api/git/delete-untracked` | bearer_token | POST /api/git/delete-untracked for backend runtime support. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/git.js:1410 |
|
||||
| GET | `/api/git/diff` | bearer_token | Return git diff output for a project or file. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/git.js:354 |
|
||||
| POST | `/api/git/discard` | bearer_token | POST /api/git/discard for backend runtime support. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/git.js:1356 |
|
||||
| POST | `/api/git/fetch` | bearer_token | POST /api/git/fetch for backend runtime support. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/git.js:1097 |
|
||||
| GET | `/api/git/file-with-diff` | bearer_token | Read, write, create, rename, delete, or upload project files. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/git.js:437 |
|
||||
| POST | `/api/git/generate-commit-message` | bearer_token | Generate an AI-assisted commit message from the current diff. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/git.js:814 |
|
||||
| POST | `/api/git/initial-commit` | bearer_token | POST /api/git/initial-commit for backend runtime support. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/git.js:517 |
|
||||
| POST | `/api/git/publish` | bearer_token | POST /api/git/publish for backend runtime support. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/git.js:1277 |
|
||||
| POST | `/api/git/pull` | bearer_token | POST /api/git/pull for backend runtime support. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/git.js:1138 |
|
||||
| POST | `/api/git/push` | bearer_token | POST /api/git/push for backend runtime support. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/git.js:1206 |
|
||||
| GET | `/api/git/remote-status` | bearer_token | Report remote sync status for a project repository. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/git.js:1019 |
|
||||
| POST | `/api/git/revert-local-commit` | bearer_token | POST /api/git/revert-local-commit for backend runtime support. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/git.js:592 |
|
||||
| GET | `/api/git/status` | bearer_token | Read git status information for a project. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/git.js:291 |
|
||||
|
||||
## MCP
|
||||
|
||||
| Method | Path | Auth | Purpose | Consumers | Source |
|
||||
| --- | --- | --- | --- | --- | --- |
|
||||
| GET | `/api/mcp-utils/all-servers` | bearer_token | Return MCP helper information used by setup flows. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/mcp-utils.js:35 |
|
||||
| GET | `/api/mcp-utils/taskmaster-server` | bearer_token | Return MCP helper information used by setup flows. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/mcp-utils.js:18 |
|
||||
| POST | `/api/mcp/cli/add` | bearer_token | Manage Claude MCP CLI and configuration state. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/mcp.js:59 |
|
||||
| POST | `/api/mcp/cli/add-json` | bearer_token | Manage Claude MCP CLI and configuration state. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/mcp.js:142 |
|
||||
| GET | `/api/mcp/cli/get/:name` | bearer_token | Manage Claude MCP CLI and configuration state. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/mcp.js:305 |
|
||||
| GET | `/api/mcp/cli/list` | bearer_token | Manage Claude MCP CLI and configuration state. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/mcp.js:16 |
|
||||
| DELETE | `/api/mcp/cli/remove/:name` | bearer_token | Manage Claude MCP CLI and configuration state. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/mcp.js:235 |
|
||||
| GET | `/api/mcp/config/read` | bearer_token | Manage Claude MCP CLI and configuration state. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/mcp.js:348 |
|
||||
|
||||
## Plugins
|
||||
|
||||
| Method | Path | Auth | Purpose | Consumers | Source |
|
||||
| --- | --- | --- | --- | --- | --- |
|
||||
| GET | `/api/plugins` | bearer_token | List, install, update, serve, enable, or remove plugins. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/plugins.js:27 |
|
||||
| DELETE | `/api/plugins/:name` | bearer_token | List, install, update, serve, enable, or remove plugins. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/plugins.js:282 |
|
||||
| GET | `/api/plugins/:name/assets/*` | bearer_token | List, install, update, serve, enable, or remove plugins. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/plugins.js:57 |
|
||||
| PUT | `/api/plugins/:name/enable` | bearer_token | List, install, update, serve, enable, or remove plugins. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/plugins.js:96 |
|
||||
| GET | `/api/plugins/:name/manifest` | bearer_token | List, install, update, serve, enable, or remove plugins. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/plugins.js:40 |
|
||||
| POST | `/api/plugins/:name/update` | bearer_token | List, install, update, serve, enable, or remove plugins. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/plugins.js:169 |
|
||||
| POST | `/api/plugins/install` | bearer_token | List, install, update, serve, enable, or remove plugins. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/plugins.js:136 |
|
||||
|
||||
## Projects
|
||||
|
||||
| Method | Path | Auth | Purpose | Consumers | Source |
|
||||
| --- | --- | --- | --- | --- | --- |
|
||||
| POST | `/api/create-folder` | bearer_token | Create a new directory on the local filesystem. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/index.js:754 |
|
||||
| GET | `/api/projects` | bearer_token | List detected projects and workspaces. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/index.js:491 |
|
||||
| DELETE | `/api/projects/:projectName` | bearer_token | DELETE /api/projects/:projectName for backend runtime support. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/index.js:589 |
|
||||
| PUT | `/api/projects/:projectName/rename` | bearer_token | PUT /api/projects/:projectName/rename for backend runtime support. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/index.js:537 |
|
||||
| GET | `/api/projects/clone-progress` | bearer_token | Stream workspace cloning progress events to the frontend. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/projects.js:335 |
|
||||
| POST | `/api/projects/create` | bearer_token | Manually add a project path to the workspace list. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/index.js:601 |
|
||||
| POST | `/api/projects/create-workspace` | bearer_token | Create or register a workspace and optionally clone a GitHub repository into it. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/projects.js:175 |
|
||||
|
||||
## Providers
|
||||
|
||||
| Method | Path | Auth | Purpose | Consumers | Source |
|
||||
| --- | --- | --- | --- | --- | --- |
|
||||
| GET | `/api/codex/config` | bearer_token | Manage Codex configuration, MCP settings, and stored sessions. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/codex.js:23 |
|
||||
| POST | `/api/codex/mcp/cli/add` | bearer_token | Manage Codex configuration, MCP settings, and stored sessions. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/codex.js:135 |
|
||||
| GET | `/api/codex/mcp/cli/get/:name` | bearer_token | Manage Codex configuration, MCP settings, and stored sessions. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/codex.js:220 |
|
||||
| GET | `/api/codex/mcp/cli/list` | bearer_token | Manage Codex configuration, MCP settings, and stored sessions. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/codex.js:103 |
|
||||
| DELETE | `/api/codex/mcp/cli/remove/:name` | bearer_token | Manage Codex configuration, MCP settings, and stored sessions. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/codex.js:186 |
|
||||
| GET | `/api/codex/mcp/config/read` | bearer_token | Manage Codex configuration, MCP settings, and stored sessions. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/codex.js:254 |
|
||||
| GET | `/api/codex/sessions` | bearer_token | List or manage sessions associated with a project or provider. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/codex.js:54 |
|
||||
| DELETE | `/api/codex/sessions/:sessionId` | bearer_token | List or manage sessions associated with a project or provider. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/codex.js:89 |
|
||||
| GET | `/api/codex/sessions/:sessionId/messages` | bearer_token | Return paginated messages for a stored session. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/codex.js:71 |
|
||||
| GET | `/api/cursor/config` | bearer_token | Manage Cursor configuration, MCP settings, and stored sessions. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/cursor.js:15 |
|
||||
| POST | `/api/cursor/config` | bearer_token | Manage Cursor configuration, MCP settings, and stored sessions. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/cursor.js:59 |
|
||||
| GET | `/api/cursor/mcp` | bearer_token | Manage Cursor configuration, MCP settings, and stored sessions. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/cursor.js:122 |
|
||||
| DELETE | `/api/cursor/mcp/:name` | bearer_token | Manage Cursor configuration, MCP settings, and stored sessions. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/cursor.js:245 |
|
||||
| POST | `/api/cursor/mcp/add` | bearer_token | Manage Cursor configuration, MCP settings, and stored sessions. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/cursor.js:183 |
|
||||
| POST | `/api/cursor/mcp/add-json` | bearer_token | Manage Cursor configuration, MCP settings, and stored sessions. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/cursor.js:292 |
|
||||
| GET | `/api/cursor/sessions` | bearer_token | List or manage sessions associated with a project or provider. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/cursor.js:348 |
|
||||
| GET | `/api/cursor/sessions/:sessionId` | bearer_token | List or manage sessions associated with a project or provider. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/cursor.js:583 |
|
||||
| DELETE | `/api/gemini/sessions/:sessionId` | bearer_token | List or manage sessions associated with a project or provider. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/gemini.js:37 |
|
||||
| GET | `/api/gemini/sessions/:sessionId/messages` | bearer_token | Return paginated messages for a stored session. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/gemini.js:8 |
|
||||
|
||||
## Realtime
|
||||
|
||||
| Method | Path | Auth | Purpose | Consumers | Source |
|
||||
| --- | --- | --- | --- | --- | --- |
|
||||
| GET | `/api/browse-filesystem` | bearer_token | Browse local directories so the UI can suggest workspace locations. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/index.js:674 |
|
||||
| POST | `/api/transcribe` | bearer_token | Transcribe uploaded audio and optionally enhance the result for prompts or tasks. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/index.js:1964 |
|
||||
|
||||
## Sessions
|
||||
|
||||
| Method | Path | Auth | Purpose | Consumers | Source |
|
||||
| --- | --- | --- | --- | --- | --- |
|
||||
| GET | `/api/projects/:projectName/sessions` | bearer_token | List or manage sessions associated with a project or provider. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/index.js:500 |
|
||||
| DELETE | `/api/projects/:projectName/sessions/:sessionId` | bearer_token | List or manage sessions associated with a project or provider. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/index.js:548 |
|
||||
| GET | `/api/projects/:projectName/sessions/:sessionId/messages` | bearer_token | Return paginated messages for a stored session. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/index.js:512 |
|
||||
| GET | `/api/projects/:projectName/sessions/:sessionId/token-usage` | bearer_token | Report token usage for a stored provider session. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/index.js:2198 |
|
||||
| GET | `/api/search/conversations` | bearer_token | Search conversation history across stored projects and stream results. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/index.js:618 |
|
||||
| PUT | `/api/sessions/:sessionId/rename` | bearer_token | List or manage sessions associated with a project or provider. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/index.js:563 |
|
||||
|
||||
## Settings
|
||||
|
||||
| Method | Path | Auth | Purpose | Consumers | Source |
|
||||
| --- | --- | --- | --- | --- | --- |
|
||||
| GET | `/api/settings/api-keys` | bearer_token | Manage local API keys used to access the backend. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/settings.js:11 |
|
||||
| POST | `/api/settings/api-keys` | bearer_token | Manage local API keys used to access the backend. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/settings.js:27 |
|
||||
| DELETE | `/api/settings/api-keys/:keyId` | bearer_token | Manage local API keys used to access the backend. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/settings.js:47 |
|
||||
| PATCH | `/api/settings/api-keys/:keyId/toggle` | bearer_token | Manage local API keys used to access the backend. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/settings.js:64 |
|
||||
| GET | `/api/settings/credentials` | bearer_token | Manage stored provider and GitHub credentials. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/settings.js:91 |
|
||||
| POST | `/api/settings/credentials` | bearer_token | Manage stored provider and GitHub credentials. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/settings.js:104 |
|
||||
| DELETE | `/api/settings/credentials/:credentialId` | bearer_token | Manage stored provider and GitHub credentials. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/settings.js:139 |
|
||||
| PATCH | `/api/settings/credentials/:credentialId/toggle` | bearer_token | Manage stored provider and GitHub credentials. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/settings.js:156 |
|
||||
|
||||
## System
|
||||
|
||||
| Method | Path | Auth | Purpose | Consumers | Source |
|
||||
| --- | --- | --- | --- | --- | --- |
|
||||
| GET | `*` | public | Serve the React application fallback for non-API routes. | - | server/index.js:2386 |
|
||||
| POST | `/api/system/update` | bearer_token | Run the application update workflow on the host machine. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/index.js:425 |
|
||||
| GET | `/health` | public | Expose server health, timestamp, and install mode for diagnostics. | src/hooks/useVersionCheck.ts | server/index.js:345 |
|
||||
|
||||
## TaskMaster
|
||||
|
||||
| Method | Path | Auth | Purpose | Consumers | Source |
|
||||
| --- | --- | --- | --- | --- | --- |
|
||||
| POST | `/api/taskmaster/add-task/:projectName` | bearer_token | Manage TaskMaster detection, PRDs, tasks, templates, and automation for a project. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/taskmaster.js:1060 |
|
||||
| POST | `/api/taskmaster/apply-template/:projectName` | bearer_token | Manage TaskMaster detection, PRDs, tasks, templates, and automation for a project. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/taskmaster.js:1838 |
|
||||
| GET | `/api/taskmaster/detect-all` | bearer_token | Manage TaskMaster detection, PRDs, tasks, templates, and automation for a project. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/taskmaster.js:350 |
|
||||
| GET | `/api/taskmaster/detect/:projectName` | bearer_token | Manage TaskMaster detection, PRDs, tasks, templates, and automation for a project. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/taskmaster.js:278 |
|
||||
| POST | `/api/taskmaster/init/:projectName` | bearer_token | Manage TaskMaster detection, PRDs, tasks, templates, and automation for a project. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/taskmaster.js:971 |
|
||||
| POST | `/api/taskmaster/initialize/:projectName` | bearer_token | Manage TaskMaster detection, PRDs, tasks, templates, and automation for a project. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/taskmaster.js:434 |
|
||||
| GET | `/api/taskmaster/installation-status` | bearer_token | Manage TaskMaster detection, PRDs, tasks, templates, and automation for a project. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/taskmaster.js:243 |
|
||||
| GET | `/api/taskmaster/next/:projectName` | bearer_token | Manage TaskMaster detection, PRDs, tasks, templates, and automation for a project. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/taskmaster.js:460 |
|
||||
| POST | `/api/taskmaster/parse-prd/:projectName` | bearer_token | Manage TaskMaster detection, PRDs, tasks, templates, and automation for a project. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/taskmaster.js:1291 |
|
||||
| GET | `/api/taskmaster/prd-templates` | bearer_token | Manage TaskMaster detection, PRDs, tasks, templates, and automation for a project. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/taskmaster.js:1392 |
|
||||
| GET | `/api/taskmaster/prd/:projectName` | bearer_token | Manage TaskMaster detection, PRDs, tasks, templates, and automation for a project. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/taskmaster.js:685 |
|
||||
| POST | `/api/taskmaster/prd/:projectName` | bearer_token | Manage TaskMaster detection, PRDs, tasks, templates, and automation for a project. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/taskmaster.js:761 |
|
||||
| GET | `/api/taskmaster/prd/:projectName/:fileName` | bearer_token | Manage TaskMaster detection, PRDs, tasks, templates, and automation for a project. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/taskmaster.js:846 |
|
||||
| DELETE | `/api/taskmaster/prd/:projectName/:fileName` | bearer_token | Manage TaskMaster detection, PRDs, tasks, templates, and automation for a project. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/taskmaster.js:911 |
|
||||
| GET | `/api/taskmaster/tasks/:projectName` | bearer_token | Manage TaskMaster detection, PRDs, tasks, templates, and automation for a project. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/taskmaster.js:570 |
|
||||
| PUT | `/api/taskmaster/update-task/:projectName/:taskId` | bearer_token | Manage TaskMaster detection, PRDs, tasks, templates, and automation for a project. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/taskmaster.js:1164 |
|
||||
|
||||
## User
|
||||
|
||||
| Method | Path | Auth | Purpose | Consumers | Source |
|
||||
| --- | --- | --- | --- | --- | --- |
|
||||
| POST | `/api/user/complete-onboarding` | bearer_token | Mark onboarding as completed for the current user. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/user.js:93 |
|
||||
| GET | `/api/user/git-config` | bearer_token | Read or update stored git identity settings. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/user.js:28 |
|
||||
| POST | `/api/user/git-config` | bearer_token | Read or update stored git identity settings. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/user.js:57 |
|
||||
| GET | `/api/user/onboarding-status` | bearer_token | Return onboarding completion status for the current user. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/user.js:108 |
|
||||
@@ -1,314 +0,0 @@
|
||||
# Cross-Platform Input Parsing Notes
|
||||
## Why This Matters In This Repo
|
||||
CloudCLI is not only an HTTP API plus React UI. From the README and current backend layout, it also launches CLIs, keeps interactive terminal sessions alive, reads and writes local files, parses process output, and forwards terminal input from the browser into local shells. That puts the backend on the boundary between browser input, terminal behavior, child process behavior, and filesystem behavior. Linux and Windows differ at each of those boundaries.
|
||||
|
||||
For the TypeScript migration, the OS adapter layer now lives in:
|
||||
- [server/src/shared/platform/index.ts](/c:/Users/OMEN6/Desktop/Projects/Paid/ClaudeCodeUI%20-%20Siteboon/claudecodeui/server/src/shared/platform/index.ts)
|
||||
|
||||
Use those helpers in new `server/src` code so feature modules do not branch on the operating system.
|
||||
|
||||
## Assumptions
|
||||
- The legacy runtime in `server/index.js` stays untouched for now.
|
||||
- New backend code will be added under `server/src`.
|
||||
- Node.js 22 is the baseline because the README already requires Node 22+.
|
||||
- The main instability is text handling around shells, streams, and files, not business logic.
|
||||
|
||||
## Where Parsing Happens In This Repo
|
||||
- `server/index.js`: PTY shell input/output and session reuse
|
||||
- `server/cursor-cli.js`: streaming line-delimited JSON from `cursor-agent`
|
||||
- `server/gemini-response-handler.js`: incremental parsing of Gemini JSON lines
|
||||
- `server/routes/mcp.js` and `server/routes/codex.js`: parsing human-readable CLI output
|
||||
- `server/cli.js` and `server/load-env.js`: parsing command-line args and `.env` text
|
||||
- `server/routes/git.js` and related routes: parsing Git stdout line by line
|
||||
|
||||
Those are not all the same problem. In this repo, "input parsing" means terminal input parsing, stream parsing, file parsing, shell command construction, and path normalization.
|
||||
|
||||
## Core Terms
|
||||
### Process
|
||||
A process is a running program such as `node server/start.js`, `git`, `codex`, or `cursor-agent`. When your backend launches one of these, the backend is the parent process and the launched program is the child process.
|
||||
|
||||
### Child Process
|
||||
A child process is a process started by another process. Examples:
|
||||
- CloudCLI launches `git status`
|
||||
- CloudCLI launches `codex mcp list`
|
||||
- CloudCLI launches `cursor-agent --output-format stream-json`
|
||||
|
||||
Important point: a child process usually does not hand you one final string. It emits output over time.
|
||||
|
||||
### stdin, stdout, stderr
|
||||
These are the three standard streams:
|
||||
- `stdin`: data going into the process
|
||||
- `stdout`: normal output coming out
|
||||
- `stderr`: diagnostics, warnings, and errors
|
||||
|
||||
Node example:
|
||||
```ts
|
||||
const child = spawn('git', ['status']);
|
||||
child.stdout.on('data', (chunk) => {
|
||||
// normal output from git
|
||||
});
|
||||
child.stderr.on('data', (chunk) => {
|
||||
// warnings or errors
|
||||
});
|
||||
child.stdin.write('yes\n');
|
||||
child.stdin.end();
|
||||
```
|
||||
|
||||
Repo examples:
|
||||
- terminal keystrokes go to `stdin`
|
||||
- `cursor-agent` JSON events arrive on `stdout`
|
||||
- many CLI failures appear on `stderr`
|
||||
|
||||
### TTY and PTY
|
||||
- `TTY`: a terminal device
|
||||
- `PTY`: a pseudo-terminal, meaning software that behaves like a terminal
|
||||
|
||||
Why it matters:
|
||||
- `spawn()` is best for non-interactive commands like `git status`
|
||||
- `node-pty` is best for interactive shells like PowerShell or bash sessions
|
||||
|
||||
Repo example: `server/index.js` uses `node-pty` for the integrated shell because agents and shells expect terminal behavior, not just plain pipes.
|
||||
|
||||
### argv
|
||||
`argv` means argument vector: the list of command-line arguments passed to a program.
|
||||
|
||||
Example:
|
||||
```ts
|
||||
spawn('git', ['log', '--oneline', '-5']);
|
||||
```
|
||||
|
||||
Here the executable is `git` and the argv is `['log', '--oneline', '-5']`. This is safer than building one big shell string because Node passes arguments directly instead of asking a shell to reinterpret them.
|
||||
|
||||
### cwd
|
||||
`cwd` means current working directory. Examples:
|
||||
- run `git status` in the project root
|
||||
- run `claude mcp add --scope local` inside the current project
|
||||
- run a terminal session inside a selected workspace
|
||||
|
||||
If `cwd` is wrong, parsing may look broken even when the parser is correct, because the command itself is operating in the wrong place.
|
||||
|
||||
### Buffer, String, and Decoding
|
||||
A `Buffer` is raw bytes. A string is decoded text. Processes emit bytes first, then you decode them, and only after that should you parse lines, JSON, or tokens.
|
||||
|
||||
Example:
|
||||
```ts
|
||||
child.stdout.on('data', (chunk: Buffer) => {
|
||||
const text = chunk.toString('utf8');
|
||||
});
|
||||
```
|
||||
|
||||
### Line Ending
|
||||
A line ending marks the end of a text line:
|
||||
- Linux/macOS usually use LF: `\n`
|
||||
- Windows often uses CRLF: `\r\n`
|
||||
- older tools sometimes emit CR alone: `\r`
|
||||
|
||||
Classic bug:
|
||||
```ts
|
||||
'a\r\nb\r\n'.split('\n');
|
||||
// ['a\r', 'b\r', '']
|
||||
```
|
||||
|
||||
That hidden trailing `\r` is one of the most common Windows parsing bugs.
|
||||
|
||||
### BOM
|
||||
BOM means byte order mark. In UTF-8 text it appears as `\uFEFF` at the start. Typical failures:
|
||||
- first key becomes `\uFEFFNAME` instead of `NAME`
|
||||
- JSON parsing fails because the first character is not what the parser expected
|
||||
- `.env` parsing silently produces the wrong first variable name
|
||||
|
||||
The adapter layer strips BOM explicitly for that reason.
|
||||
|
||||
### Chunk
|
||||
A chunk is one partial piece of stream data. Chunks are transport boundaries, not logical message boundaries. Important rules:
|
||||
- one line can arrive in multiple chunks
|
||||
- one chunk can contain many lines
|
||||
- one JSON object can be split across chunk boundaries
|
||||
|
||||
Example:
|
||||
```txt
|
||||
Chunk 1: {"type":"message","text":"hel
|
||||
Chunk 2: lo"}\r\n{"type":"message","text":"next"}\r\n
|
||||
```
|
||||
|
||||
If you parse each chunk independently, you corrupt the first JSON object.
|
||||
|
||||
## The Backend Parsing Lifecycle
|
||||
Most backend parsing problems in this repo can be viewed as a four-step pipeline:
|
||||
1. Receive raw bytes or raw text.
|
||||
2. Normalize transport details.
|
||||
3. Parse business structure.
|
||||
4. Return normalized data to the rest of the app.
|
||||
|
||||
Examples:
|
||||
- file bytes -> UTF-8 string -> normalize line endings -> split lines -> parse fields
|
||||
- stdout chunks -> accumulate partial lines -> parse JSON per line -> emit events
|
||||
- browser terminal input -> normalize Enter/newlines -> write to PTY
|
||||
|
||||
The operating system mainly affects step 2. That is why the new adapter layer exists.
|
||||
|
||||
## Linux vs Windows Differences That Usually Matter
|
||||
### 1. Newlines In Files And Process Output
|
||||
Linux usually gives LF. Windows often gives CRLF. Some tools mix them.
|
||||
|
||||
Bad pattern:
|
||||
```ts
|
||||
const lines = output.split('\n');
|
||||
```
|
||||
|
||||
Safer pattern:
|
||||
```ts
|
||||
import { splitLines } from '@/shared/platform/index.js';
|
||||
|
||||
const lines = splitLines(output, {
|
||||
preserveEmptyLines: false,
|
||||
trimTrailingEmptyLine: true,
|
||||
});
|
||||
```
|
||||
|
||||
Use `splitLines()` when you already have the whole string in memory.
|
||||
|
||||
### 2. Chunked Streams
|
||||
A process stream is not line-oriented by default.
|
||||
|
||||
Bad pattern:
|
||||
```ts
|
||||
child.stdout.on('data', (chunk) => {
|
||||
const event = JSON.parse(chunk.toString());
|
||||
});
|
||||
```
|
||||
|
||||
This fails when one JSON object is split across chunks.
|
||||
|
||||
Safer pattern:
|
||||
```ts
|
||||
import { createStreamLineAccumulator } from '@/shared/platform/index.js';
|
||||
|
||||
const lines = createStreamLineAccumulator({ preserveEmptyLines: false });
|
||||
child.stdout.on('data', (chunk) => {
|
||||
for (const line of lines.push(chunk)) {
|
||||
const event = JSON.parse(line);
|
||||
}
|
||||
});
|
||||
child.on('close', () => {
|
||||
for (const line of lines.flush()) {
|
||||
const event = JSON.parse(line);
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
Use this for Cursor, Gemini, JSONL, NDJSON, or any line-based CLI protocol.
|
||||
|
||||
### 3. Shell Syntax And Fallback Logic
|
||||
POSIX shells and PowerShell do not use the same syntax.
|
||||
- POSIX fallback: `cmd1 || cmd2`
|
||||
- PowerShell fallback: `cmd1; if ($LASTEXITCODE -ne 0) { cmd2 }`
|
||||
|
||||
Use:
|
||||
```ts
|
||||
import { buildFallbackCommand, createShellSpawnPlan } from '@/shared/platform/index.js';
|
||||
|
||||
const shellCommand = buildFallbackCommand('codex resume 123', 'codex', 'windows');
|
||||
const spawnPlan = createShellSpawnPlan(shellCommand, 'windows');
|
||||
```
|
||||
|
||||
This keeps feature code from hardcoding bash rules into Windows paths or PowerShell rules into Linux code.
|
||||
|
||||
### 4. Quoting Rules
|
||||
Even when two shells both support quotes, they do not escape them the same way.
|
||||
- POSIX single quote escape is awkward: `'it'"'"'s'`
|
||||
- PowerShell single quote escape doubles the quote: `'it''s'`
|
||||
|
||||
Use:
|
||||
```ts
|
||||
import { quoteShellArgument } from '@/shared/platform/index.js';
|
||||
|
||||
const safe = quoteShellArgument("it's", 'windows');
|
||||
```
|
||||
|
||||
### 5. Path Separators And Case
|
||||
- Linux paths use `/`
|
||||
- Windows paths typically use `\`
|
||||
- Linux is usually case-sensitive
|
||||
- Windows is usually case-insensitive
|
||||
|
||||
Examples:
|
||||
- `/repo/File.ts` and `/repo/file.ts` are different on Linux
|
||||
- `C:\Repo\File.ts` and `c:\repo\file.ts` usually refer to the same file on Windows
|
||||
|
||||
Use:
|
||||
```ts
|
||||
import { arePathsEquivalent, normalizePathForPlatform, toPortablePath } from '@/shared/platform/index.js';
|
||||
```
|
||||
|
||||
Guideline:
|
||||
- use platform-specific paths when calling the OS
|
||||
- use portable slash paths for logs, keys, and serialized payloads
|
||||
|
||||
### 6. Terminal Input
|
||||
Terminal input is not the same as a normal HTML form submission.
|
||||
- pressing Enter may arrive as `\r`
|
||||
- pasted text may contain `\n` or `\r\n`
|
||||
- terminal apps often expect carriage return behavior
|
||||
|
||||
Use:
|
||||
```ts
|
||||
import { normalizeTerminalInput } from '@/shared/platform/index.js';
|
||||
```
|
||||
|
||||
This matters for PTY writes because terminal software often treats `\r` as the real Enter key behavior.
|
||||
|
||||
## The New Adapter Functions
|
||||
- `normalizeTextForParsing()`: use when your goal is parsing text consistently, not preserving original file style; good for `.env`, JSONL, human-readable CLI output, and buffered command output.
|
||||
- `splitLines()`: use when the full text is already in memory and you want clean logical lines; good for config files, buffered Git output, and fully collected CLI output.
|
||||
- `createStreamLineAccumulator()`: use when text arrives incrementally over time; good for `stdout`, `stderr`, line-based streaming JSON, and long-lived child processes.
|
||||
- `createShellSpawnPlan()`: use when the command must go through a shell because shell syntax is required; good for fallback commands, resume-or-start command chains, and interactive shell launch plans.
|
||||
- `quoteShellArgument()`: use before interpolating dynamic values into shell command strings; good for session IDs, file paths, branch names, and user-provided subcommands.
|
||||
- `buildFallbackCommand()`: use when the same logic must work in bash and PowerShell; a repo-shaped example is "resume Codex session if it exists, otherwise start a fresh one."
|
||||
- `preserveExistingLineEndings()`: use when writing text files back to disk and you want to avoid noisy diffs; good for markdown files, config files, and user-managed text artifacts.
|
||||
|
||||
## Practical Backend Rules For This Repo
|
||||
1. If you already have the full text, normalize once and then parse.
|
||||
2. If the source is a stream, use an accumulator and never parse per chunk.
|
||||
3. Prefer `spawn(executable, argv, { shell: false })` whenever possible.
|
||||
4. Only use a shell when shell syntax is actually needed.
|
||||
5. When you must use a shell, push all shell-specific behavior into the adapter layer.
|
||||
6. Preserve existing line endings on user files unless you intentionally want normalization.
|
||||
7. Separate transport normalization from business parsing.
|
||||
|
||||
## Common Mistakes To Avoid
|
||||
- Parsing stdout chunk-by-chunk. Symptom: random JSON parse failures or truncated events. Fix: accumulate complete lines first.
|
||||
- Using `split('\n')` on Windows text. Symptom: values end with `\r` and equality checks fail. Fix: normalize line endings or use `splitLines()`.
|
||||
- Building one huge shell string for everything. Symptom: quoting bugs, OS-specific failures, and injection risk. Fix: prefer `spawn()` with argv; if shell is required, use `quoteShellArgument()` and `createShellSpawnPlan()`.
|
||||
- Rewriting files with a different line-ending style. Symptom: huge git diffs and noisy file changes. Fix: use `preserveExistingLineEndings()`.
|
||||
|
||||
## Testing Strategy Implemented Here
|
||||
This strategy intentionally does not add Jest, Vitest, or another test framework.
|
||||
|
||||
It uses:
|
||||
- Node's built-in `node:test`
|
||||
- `tsx` only to execute TypeScript tests
|
||||
- a GitHub Actions matrix on Ubuntu and Windows
|
||||
|
||||
Local verification:
|
||||
```bash
|
||||
npm run test:server
|
||||
npm run verify:server
|
||||
```
|
||||
|
||||
CI verification:
|
||||
- `npm run typecheck:server`
|
||||
- `npm run test:server`
|
||||
- `npm run server:build`
|
||||
|
||||
This gives you two kinds of confidence:
|
||||
- contract confidence: the adapter functions behave as designed
|
||||
- environment confidence: the same checks pass on real Linux and Windows runners
|
||||
|
||||
## Final Mental Model
|
||||
Think in three layers:
|
||||
1. Raw transport layer. Examples: chunks, bytes, terminal keystrokes, raw file text.
|
||||
2. Normalization layer. Examples: strip BOM, normalize line endings, normalize terminal input, normalize shell behavior.
|
||||
3. Business parsing layer. Examples: parse JSON, parse CLI output, parse `.env`, parse Git status, parse session files.
|
||||
|
||||
If you keep layer 2 in shared adapters, layer 3 stops caring about Linux vs Windows.
|
||||
@@ -1,190 +0,0 @@
|
||||
# LLM Module Structure (Refactor Runtime)
|
||||
|
||||
This document describes the current backend structure under `server/src/modules/llm`, how execution/session state works, and how the provider abstraction is designed.
|
||||
|
||||
## High-Level Layout
|
||||
|
||||
```text
|
||||
server/src/modules/llm/
|
||||
llm.routes.ts
|
||||
llm.registry.ts
|
||||
providers/
|
||||
provider.interface.ts
|
||||
abstract.provider.ts
|
||||
base-sdk.provider.ts
|
||||
base-cli.provider.ts
|
||||
claude.provider.ts
|
||||
codex.provider.ts
|
||||
cursor.provider.ts
|
||||
gemini.provider.ts
|
||||
services/
|
||||
llm.service.ts
|
||||
sessions.service.ts
|
||||
sessions-watcher.service.ts
|
||||
messages-unifier.service.ts
|
||||
assets.service.ts
|
||||
mcp.service.ts
|
||||
skills.service.ts
|
||||
session-indexers/
|
||||
session-indexer.interface.ts
|
||||
session-indexer.utils.ts
|
||||
claude.session-indexer.ts
|
||||
codex.session-indexer.ts
|
||||
cursor.session-indexer.ts
|
||||
gemini.session-indexer.ts
|
||||
index.ts
|
||||
tests/
|
||||
llm-unifier.providers.test.ts
|
||||
llm-unifier.sessions.test.ts
|
||||
llm-unifier.images.test.ts
|
||||
llm-unifier.mcp.test.ts
|
||||
llm-unifier.skills.test.ts
|
||||
llm-unifier.messages.test.ts
|
||||
```
|
||||
|
||||
## Responsibilities By File Group
|
||||
|
||||
- `llm.routes.ts`
|
||||
- HTTP API for provider runtime sessions (start/resume/stop/model/thinking), normalized session/history messages, assets upload, MCP config/probe, skills listing, indexed session CRUD/sync.
|
||||
- `llm.registry.ts`
|
||||
- Singleton provider registry. Instantiates one provider class per provider id.
|
||||
- `providers/*`
|
||||
- Runtime execution and live event collection.
|
||||
- SDK family (`BaseSdkProvider`) for Claude/Codex.
|
||||
- CLI family (`BaseCliProvider`) for Cursor/Gemini.
|
||||
- `services/llm.service.ts`
|
||||
- Input validation + capability gating + facade over provider registry.
|
||||
- `services/sessions.service.ts`
|
||||
- DB-backed indexed sessions and history file parsing.
|
||||
- Returns normalized message history via `messages-unifier.service.ts`.
|
||||
- `services/sessions-watcher.service.ts`
|
||||
- `chokidar` watchers for provider artifact folders.
|
||||
- On filesystem update, triggers `synchronizeProviderFile(provider, filePath)`.
|
||||
- `services/messages-unifier.service.ts`
|
||||
- Provider-specific raw event/history -> unified message contract for frontend.
|
||||
- `services/assets.service.ts`
|
||||
- Stores uploaded images in `.cloudcli/assets`.
|
||||
- `services/mcp.service.ts`
|
||||
- Unified MCP CRUD/probe across provider-native config formats/scopes/transports.
|
||||
- `services/skills.service.ts`
|
||||
- Provider-specific skill directory discovery and metadata extraction.
|
||||
- `session-indexers/*`
|
||||
- Scans provider artifacts from disk and upserts indexed sessions into `sessions` DB table.
|
||||
|
||||
## Runtime Flow (Provider Sessions)
|
||||
|
||||
1. `POST /api/llm/providers/:provider/sessions/start` hits `llm.routes.ts`.
|
||||
2. Route calls `llmService.startSession(...)`.
|
||||
3. `llm.service.ts` validates payload and capability constraints.
|
||||
4. `llm.registry.ts` resolves provider instance.
|
||||
5. Provider (`BaseSdkProvider` or `BaseCliProvider`) creates an in-memory session record and starts execution.
|
||||
6. Stream/process output is appended as in-memory `ProviderSessionEvent[]`.
|
||||
7. Route can either:
|
||||
- return `202` immediately with snapshot, or
|
||||
- await completion via `waitForSession`.
|
||||
8. Snapshots are enriched with unified `messages` via `llmMessagesUnifier.normalizeSessionEvents(...)`.
|
||||
|
||||
## Indexed History Flow (Disk/DB)
|
||||
|
||||
1. Watcher or manual sync scans provider folders.
|
||||
2. Provider-specific indexer extracts minimal metadata and upserts `sessionsDb`.
|
||||
3. History endpoints (`/sessions/:sessionId/history`, `/sessions/:sessionId/messages`) read transcript path from DB.
|
||||
4. JSON/JSONL is parsed and transformed via `llmMessagesUnifier.normalizeHistoryEntries(...)`.
|
||||
|
||||
## Interface + Abstract + Base-Class Design
|
||||
|
||||
### `IProvider` (interface)
|
||||
`providers/provider.interface.ts`
|
||||
|
||||
- Consumer contract used by registry/service layer.
|
||||
- Exposes:
|
||||
- `launchSession`, `resumeSession`, `stopSession`, `waitForSession`
|
||||
- `setSessionModel`, `setSessionThinkingMode`
|
||||
- `getSession`, `listSessions`
|
||||
- `listModels`
|
||||
- Exposes `capabilities` so callers can gate unsupported features before calling provider-specific logic.
|
||||
|
||||
### `AbstractProvider` (abstract class)
|
||||
`providers/abstract.provider.ts`
|
||||
|
||||
- Shared lifecycle state and rules:
|
||||
- `sessions: Map<string, MutableProviderSession>`
|
||||
- `sessionPreferences: Map<string, { model?, thinkingMode? }>`
|
||||
- Implements:
|
||||
- in-memory session reads (`getSession`, `listSessions`, `waitForSession`)
|
||||
- stop handling + session status events
|
||||
- model/thinking updates with capability checks
|
||||
- event ring-buffer logic (`MAX_EVENT_BUFFER_SIZE`)
|
||||
- Leaves provider execution specifics abstract (`listModels`, `launchSession`, `resumeSession`).
|
||||
|
||||
### `BaseSdkProvider` and `BaseCliProvider`
|
||||
|
||||
- `BaseSdkProvider`
|
||||
- shared async iterable stream consumption.
|
||||
- handles completion/error transitions and completion system event emission.
|
||||
- `BaseCliProvider`
|
||||
- shared child-process spawn + stdout/stderr line accumulation + JSON line parsing.
|
||||
- graceful stop (`SIGTERM` then `SIGKILL`) and completion/error transitions.
|
||||
|
||||
### Concrete provider classes
|
||||
|
||||
- `ClaudeProvider` (SDK)
|
||||
- uses `@anthropic-ai/claude-agent-sdk`.
|
||||
- supports runtime permission requests and emits permission events.
|
||||
- image payload support via base64 content blocks.
|
||||
- `CodexProvider` (SDK)
|
||||
- dynamic import of `@openai/codex-sdk`.
|
||||
- supports text + `local_image` prompt items.
|
||||
- `CursorProvider` (CLI)
|
||||
- `cursor-agent` invocation builder + model list parsing.
|
||||
- `GeminiProvider` (CLI)
|
||||
- `gemini` invocation builder + curated model catalog.
|
||||
|
||||
## In-Memory Session Setup: How It Works
|
||||
|
||||
The in-memory part is inside `AbstractProvider` + base classes:
|
||||
|
||||
- Session record is created at launch/resume in memory (`Map`).
|
||||
- Events are appended in real-time while stream/process runs.
|
||||
- Snapshot endpoints read this map directly (`/providers/:provider/sessions...`).
|
||||
- Stop/wait/model/thinking controls operate on this same in-memory handle.
|
||||
- Completed sessions currently remain in map (bounded event history per session, but no map eviction).
|
||||
|
||||
Key characteristics:
|
||||
|
||||
- Process-local only (not shared across instances).
|
||||
- Lost on server restart.
|
||||
- Good for immediate live control and progress.
|
||||
- Not the source of truth for historical transcripts (disk/DB is).
|
||||
|
||||
## Is In-Memory Session State Necessary, Or Useless?
|
||||
|
||||
Short answer: **not useless**, but **not sufficient as a durable architecture**.
|
||||
|
||||
### Why it is necessary in the current design
|
||||
|
||||
- You need live handles for:
|
||||
- `stopSession` (abort process/stream now),
|
||||
- `waitForSession`,
|
||||
- real-time event buffering for immediate API responses.
|
||||
- These are runtime concerns and cannot be satisfied by session-index DB rows alone.
|
||||
|
||||
### Where it is weak
|
||||
|
||||
- No eviction/pruning for completed session map entries.
|
||||
- No persistence across restart.
|
||||
- No cross-instance coordination (if horizontally scaled, only the owning instance can control that session).
|
||||
|
||||
### Practical conclusion
|
||||
|
||||
- Keep in-memory runtime state for **active execution control**.
|
||||
- Treat DB/indexed history as the durable read model.
|
||||
- If you need reliability across restarts/instances, move execution ownership to a durable worker/orchestrator and store live session metadata in a shared store.
|
||||
|
||||
## Suggested Hardening (Incremental)
|
||||
|
||||
1. Add session map eviction policy (TTL/LRU for completed/failed/stopped sessions).
|
||||
2. Add ownership metadata (`instanceId`) if multiple backend instances will run.
|
||||
3. Add explicit `activeSessions` metric endpoint.
|
||||
4. Optionally persist minimal runtime state (status transitions + timestamps) to DB for auditability.
|
||||
|
||||
@@ -1,456 +0,0 @@
|
||||
# How each provider supports image uploading
|
||||
|
||||
Universally: First, we should upload the images in `.cloudcli/assets` folder. Then, it should just reference that path later on.
|
||||
|
||||
## Claude
|
||||
- When clicking send, attach the images in the content list with the type of 'image'.
|
||||
- https://platform.claude.com/docs/en/api/messages#message_param
|
||||
```js
|
||||
const imageBytes = await fs.readFile(imagePath);
|
||||
const sdkPrompt = (async function*: AsyncIterable<SDKUserMessage> () {
|
||||
yield {
|
||||
type: 'user',
|
||||
message: {
|
||||
role: 'user',
|
||||
content: [
|
||||
{ type: 'text', text: prompt },
|
||||
{
|
||||
type: 'image',
|
||||
source: {
|
||||
type: 'base64',
|
||||
media_type: 'image/jpeg',
|
||||
data: imageBytes.toString('base64'),
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
parent_tool_use_id: null,
|
||||
timestamp: new Date().toISOString(),
|
||||
};
|
||||
})(); // automatically executed because of the `()` in the end.
|
||||
```
|
||||
|
||||
### Some useful types
|
||||
```ts
|
||||
export interface MessageParam {
|
||||
content: string | Array<ContentBlockParam>;
|
||||
|
||||
role: 'user' | 'assistant'; // when we send the message for prompting, the role will be 'user'
|
||||
}
|
||||
|
||||
/**
|
||||
* Regular text content.
|
||||
*/
|
||||
export type ContentBlockParam =
|
||||
| TextBlockParam
|
||||
| ImageBlockParam
|
||||
| DocumentBlockParam
|
||||
| SearchResultBlockParam
|
||||
| ThinkingBlockParam
|
||||
| RedactedThinkingBlockParam
|
||||
| ToolUseBlockParam
|
||||
| ToolResultBlockParam
|
||||
| ServerToolUseBlockParam
|
||||
| WebSearchToolResultBlockParam;
|
||||
|
||||
|
||||
export interface TextBlockParam {
|
||||
text: string;
|
||||
type: 'text';
|
||||
}
|
||||
|
||||
export interface ImageBlockParam {
|
||||
source: Base64ImageSource | URLImageSource; // I'll be using only base 64 for now.
|
||||
type: 'image';
|
||||
}
|
||||
|
||||
export interface Base64ImageSource {
|
||||
data: string;
|
||||
media_type: 'image/jpeg' | 'image/png' | 'image/gif' | 'image/webp';
|
||||
type: 'base64';
|
||||
}
|
||||
```
|
||||
|
||||
### Explanations about async generators and yield
|
||||
To understand why `async function*` is used, it helps to stop thinking of functions as "machines that run and finish" and start thinking of them as **"factories that stay open."**
|
||||
```ts
|
||||
async function* getTaskStatus(): AsyncIterable<string> {
|
||||
yield "Checking permissions...";
|
||||
await new Promise(r => setTimeout(r, 500)); // Simulate work
|
||||
|
||||
yield "Searching database...";
|
||||
await new Promise(r => setTimeout(r, 500));
|
||||
|
||||
yield "Formatting prompt...";
|
||||
}
|
||||
|
||||
// CONSUMPTION
|
||||
async function run() {
|
||||
const statusGenerator = getTaskStatus();
|
||||
|
||||
for await (const status of statusGenerator) {
|
||||
console.log(`Current Status: ${status}`);
|
||||
}
|
||||
|
||||
console.log("Done!");
|
||||
}
|
||||
```
|
||||
|
||||
## Codex
|
||||
```ts
|
||||
const streamed = await thread.runStreamed([ {type: "text", text: "Describe this image:"}, {type: "local_image", path: "scripts/pic.jpg"}
|
||||
```
|
||||
- Don't add the above query lines for codex. We can directly use the `sdk`.
|
||||
|
||||
## Gemini and Cursor
|
||||
- Just add the path to the end of the prompt when clicking send for paths including images. For e.g.
|
||||
```
|
||||
<some-user-prompt>
|
||||
|
||||
<images_input>
|
||||
---- IGNORE THE <images_input> QUERY LINES. Just use the attached list of an array of paths for images below and use it with the above prompt.
|
||||
|
||||
["scripts\pic.jpg", "<path-for-second-image>", ...]
|
||||
```
|
||||
|
||||
|
||||
|
||||
# MCP servers (how to add/remove one and run it)
|
||||
|
||||
**What is the Model Context Protocol (MCP)?**
|
||||
Think of MCP as the USB-C cable for AI.
|
||||
- Historically, if you wanted an AI model to read your GitHub repository, query your database, or search your company's Notion workspace, developers had to write custom, one-off integrations for every single AI tool.
|
||||
- Created by Anthropic as an open-source standard, the Model Context Protocol fixes this. It is a universal language that allows AI applications (the "clients") to securely connect to external data sources and tools (the "servers") using a single, unified protocol.
|
||||
|
||||
**What is an MCP Server?**
|
||||
- If MCP is the USB-C cable, an **MCP Server** is the hard drive or webcam you are plugging in.
|
||||
- It is a lightweight program that acts as a secure bridge between your specific data and the AI. When the AI needs context—like checking the current state of a file or executing a search—it asks the MCP server. The server translates the AI's request, securely fetches the data or performs the action, and hands the result back to the AI.
|
||||
|
||||
**Different transport mechanisms for MCP servers**
|
||||
1. `stdio` - This is the default and most common transport for local development. When using `stdio`, the AI client directly launches the MCP server as a background "child process" on your machine. The client and server then talk to each other locally by writing to and reading from standard input (`stdin`) and standard output (`stdout`).
|
||||
- **Clear Example:** A local **File System Server**. You want the AI to read your local `package.json` file. The AI client spawns the file system server via `stdio`. Because the server is running locally on your hardware, it inherently has access to your files without needing complex authentication. It reads the file and prints the contents back to the AI.
|
||||
2. `https` (Streamable HTTP) - Streamable HTTP replaces older remote methods. It uses a single HTTP or HTTPS endpoint for bidirectional communication. The client sends standard `POST` requests, and the server can respond instantly or keep the connection open to stream data back. It behaves exactly like a modern web API. Because it runs over HTTP, it supports standard web security features like OAuth, Bearer tokens, and CORS.
|
||||
- **Clear Example:** A **Cloud Database Server**. If you work on a team and want everyone's AI to be able to query a shared staging database, you would deploy an MCP server to the cloud. Your AI connects to `https://api.yourcompany.com/mcp` using Streamable HTTP and passes an API key in the headers to securely run queries.
|
||||
3. `sse` (Server sent events) - SSE is the legacy transport mechanism for remote servers. While still widely supported, it is actively being phased out in favor of Streamable HTTP because it is slightly more cumbersome to build and maintain.
|
||||
- **How it works:** Unlike Streamable HTTP which uses a single unified endpoint, SSE requires _two_ distinct network connections. The client connects to an SSE endpoint (via an HTTP `GET` request) strictly to listen for incoming messages from the server, and uses a separate HTTP `POST` endpoint to send messages to the server.
|
||||
|
||||
- **Clear Example:** An older **Slack Integration Server**. The AI client connects to the server's SSE stream to listen for real-time incoming messages from a Slack channel. When the AI wants to reply, it sends a payload to a separate `/message` POST endpoint.
|
||||
|
||||
**Frontend coordination**
|
||||
- When listing the MCP servers for a provider, go to the appropriate files where the configuration is stored to fetch all of them. When listing, the User/Local/Project MCPs should be grouped separately.
|
||||
- To add/remove an MCP server, go to the appropriate file and add/remove it there keeping in mind whether it is configured as User/Local/Project.
|
||||
- To update the server, go to the appropriate file and update it from there.
|
||||
- There should also be one big mcp adder that supports `http` and `stdio` only. When it's added from there, the server will automatically be added to every provider.
|
||||
|
||||
## Claude
|
||||
Supports all 3 transports.
|
||||
### `stdio`
|
||||
- We can have arguments and env variables input when executing the command.
|
||||
- `args` and `env` are optional.
|
||||
```json
|
||||
{
|
||||
"mcpServers": {
|
||||
"local-weather": {
|
||||
"type": "stdio",
|
||||
"command": "/path/to/weather-cli",
|
||||
"args": ["--api-key", "abc123"],
|
||||
"env": {
|
||||
"CACHE_DIR": "/tmp"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### `http`
|
||||
- We don't pass `env` inputs for now. It's supported but we will add it only later.
|
||||
- `headers` is optional.
|
||||
```json
|
||||
{
|
||||
"mcpServers": {
|
||||
"weather-api": {
|
||||
"type": "http",
|
||||
"url": "https://api.weather.com/mcp",
|
||||
"headers": {
|
||||
"Authorization": "Bearer token"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### `sse`
|
||||
- similar with `http` format.
|
||||
```json
|
||||
{
|
||||
"mcpServers": {
|
||||
"private-api": {
|
||||
"type": "sse",
|
||||
"url": "https://api.company.com/sse",
|
||||
"headers": {
|
||||
"X-API-Key": "your-key-here"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Support for different modes (Local, user, project)
|
||||
|
||||
#### Local
|
||||
- stored in `~/.claude.json` under the project’s path.
|
||||
#### User
|
||||
- stored in `~/.claude.json` under the main object with the key `"mcpServers"
|
||||
#### Project specific
|
||||
- add it in the `.mcp.json` file in the project root directory.
|
||||
|
||||
## Codex
|
||||
|
||||
### Configuration (Only `stdio` and `http` are supported.)
|
||||
|
||||
#### `stdio`
|
||||
- `command` (required): The command that starts the server.
|
||||
- `args` (optional): Arguments to pass to the server.
|
||||
- `env` (optional): Environment variables to set for the server.
|
||||
- `env_vars` (optional): Environment variables to allow and forward.
|
||||
- `cwd` (optional): Working directory to start the server from.
|
||||
|
||||
```toml
|
||||
[mcp_servers.my_stdio]
|
||||
command = "npx"
|
||||
args = ["-y", "@upstash/context7-mcp"]
|
||||
|
||||
[mcp_servers.my_stdio.env]
|
||||
API_KEY = "your-key"
|
||||
```
|
||||
|
||||
With forwarded host env vars.
|
||||
```toml
|
||||
[mcp_servers.my_stdio]
|
||||
command = "python"
|
||||
args = ["server.py"]
|
||||
env_vars = ["API_KEY", "DEBUG"]
|
||||
cwd = "/path/to/project"
|
||||
```
|
||||
#### `http`
|
||||
- `url` (required): The server address.
|
||||
- `bearer_token_env_var` (optional): Environment variable name for a bearer token to send in `Authorization`.
|
||||
- `http_headers` (optional): Map of header names to static values.
|
||||
- `env_http_headers` (optional): Map of header names to environment variable names (values pulled from the environment).
|
||||
```toml
|
||||
[mcp_servers.my_http]
|
||||
url = "https://example.com/mcp"
|
||||
bearer_token_env_var = "MY_API_TOKEN"
|
||||
http_headers = { "X-Custom-Header" = "custom-value" }
|
||||
env_http_headers = { "X-Api-Key" = "MY_API_KEY_ENV" }
|
||||
```
|
||||
|
||||
### Support for different modes (user, project)
|
||||
#### User
|
||||
- add it to the global `~/.codex/config.toml` file.
|
||||
|
||||
#### Project specific
|
||||
- add it in `.codex/config.toml` file in the project's root directory.
|
||||
|
||||
## Gemini
|
||||
Supports all 3 transports.
|
||||
### `stdio`
|
||||
- We can have arguments and env variables as inputs when executing the command.
|
||||
- `args` and `env` are optional.
|
||||
- No `type` attribute like Claude for `stdio`. If there is no type, we can infer that it must be `stdio` since the rest have it.
|
||||
```json
|
||||
|
||||
{
|
||||
"mcpServers": {
|
||||
"serverName": {
|
||||
"command": "path/to/server",
|
||||
"args": ["--arg1", "value1"],
|
||||
"env": {
|
||||
"API_KEY": "$MY_API_TOKEN"
|
||||
},
|
||||
"cwd": "./server-directory"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### `http`
|
||||
- We don't pass `env` inputs. Notice the type is set here like Claude.
|
||||
- `headers` is optional.
|
||||
- EXACTLY same as Claude `http`.
|
||||
```json
|
||||
{
|
||||
"mcpServers": {
|
||||
"weather-api": {
|
||||
"type": "http",
|
||||
"url": "https://api.weather.com/mcp",
|
||||
"headers": {
|
||||
"Authorization": "Bearer token"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### `sse`
|
||||
- similar with `http` format.
|
||||
- EXACT with Claude `sse` format.
|
||||
```json
|
||||
{
|
||||
"mcpServers": {
|
||||
"private-api": {
|
||||
"type": "sse",
|
||||
"url": "https://api.company.com/sse",
|
||||
"headers": {
|
||||
"X-API-Key": "your-key-here"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Support for different modes (user, project)
|
||||
|
||||
#### User
|
||||
- stored in `~/.gemini/settings.json`.
|
||||
|
||||
#### Project specific
|
||||
- add it in the `.gemini/settings.json` file in the project root directory.
|
||||
|
||||
|
||||
|
||||
## Cursor
|
||||
|
||||
Supports all 3 transports. There is no `type` attribute for all 3. Here are the structures:
|
||||
|
||||
#### `stdio`
|
||||
```json
|
||||
{
|
||||
"mcpServers": {
|
||||
"server-name": {
|
||||
"command": "npx",
|
||||
"args": ["-y", "mcp-server"],
|
||||
"env": {
|
||||
"API_KEY": "value"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
#### `http` / `sse`
|
||||
```json
|
||||
// MCP server using HTTP or SSE - runs on a server
|
||||
{
|
||||
"mcpServers": {
|
||||
"server-name": {
|
||||
"url": "http://localhost:3000/mcp",
|
||||
"headers": {
|
||||
"API_KEY": "value"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
### Support for different modes (user, project)
|
||||
|
||||
#### User
|
||||
- stored in `~/.cursor/mcp.json`.
|
||||
|
||||
#### Project specific
|
||||
- add it in the `.cursor/mcp.json` file in the project root directory.
|
||||
|
||||
|
||||
|
||||
|
||||
# Skills management (ONLY Fetching support needed for now)
|
||||
## Claude
|
||||
- To get user skills, fetch all `~/.claude/skills/<skill-name>/SKILL.md`.
|
||||
- To get project skills, fetch from `.claude/skills/<skill-name>/SKILL.md`.
|
||||
- To get plugin skills:
|
||||
- Find all the enabled plugins in `~/.claude/settings.json`.
|
||||
```json
|
||||
{
|
||||
"apiKeyHelper": "...",
|
||||
"enabledPlugins": {
|
||||
"example-skills@anthropic-agent-skills": true
|
||||
},
|
||||
...
|
||||
}
|
||||
```
|
||||
- Then go to `~/.claude/plugins/installed_plugins.json` file to find where the plugin is installed.
|
||||
```json
|
||||
{
|
||||
"version": 2,
|
||||
"plugins": {
|
||||
"example-skills@anthropic-agent-skills": [
|
||||
{
|
||||
"scope": "user",
|
||||
"installPath": "C:\\Users\\OMEN6\\.claude\\plugins\\cache\\anthropic-agent-skills\\example-skills\\3d5951151859",
|
||||
"version": "3d5951151859",
|
||||
"installedAt": "2026-03-03T12:52:08.024Z",
|
||||
"lastUpdated": "2026-03-03T12:52:08.024Z",
|
||||
"gitCommitSha": "3d59511518591fa82e6cfcf0438d68dd5dad3e76"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
- Then go the `installPath` directory. If there is a `skills` folder there, go to each of the skills in `<install-path>/skills/<skill-name>/SKILL.md`.
|
||||
|
||||
Then, parse the name and description of the skills from the md for every `SKILL.md`.
|
||||
|
||||
- The command for invoking skills is `/<skill-name>` .
|
||||
|
||||
- Whenever a skill is from a plugin, doing `/skill-name` should automatically be updated with `/plugin-name:skill-name`. This is because plugin skills use a `plugin-name:skill-name` namespace, so they cannot conflict with other levels.
|
||||
|
||||
I have attached the first initial contents of a sample `SKILL.md` file below.
|
||||
|
||||
```md
|
||||
---
|
||||
|
||||
name: mcp-builder
|
||||
|
||||
description: Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node/TypeScript (MCP SDK).
|
||||
|
||||
license: Complete terms in LICENSE.txt
|
||||
|
||||
---
|
||||
```
|
||||
## Codex
|
||||
|
||||
|
||||
Codex reads skills from repository, user, admin, and system locations.
|
||||
|
||||
|
||||
| Skill Scope | Location | Suggested use |
|
||||
| ----------- | ------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| `REPO` | `$CWD/.agents/skills` <br>Current working directory: where you launch Codex. | If you’re in a repository or code environment, teams can check in skills relevant to a working folder. For example, skills only relevant to a microservice or a module. |
|
||||
| `REPO` | ` $CWD/../.agents/skills` <br>A folder above CWD when you launch Codex inside a Git repository. | If you’re in a repository with nested folders, organizations can check in skills relevant to a shared area in a parent folder. |
|
||||
| `REPO` | `$REPO_ROOT/.agents/skills` <br>The topmost root folder when you launch Codex inside a Git repository. | If you’re in a repository with nested folders, organizations can check in skills relevant to everyone using the repository. These serve as root skills available to any subfolder in the repository. |
|
||||
| `USER` | `$HOME/.agents/skills` <br>Any skills checked into the user’s personal folder. | Use to curate skills relevant to a user that apply to any repository the user may work in. |
|
||||
| `ADMIN` | `/etc/codex/skills` <br>Any skills checked into the machine or container in a shared, system location. | Use for SDK scripts, automation, and for checking in default admin skills available to each user on the machine. |
|
||||
| `SYSTEM` | `~/.codex/skills/.system` | Useful skills relevant to a broad audience such as the skill-creator and plan skills. Available to everyone when they start Codex. |
|
||||
|
||||
Then, parse the name and description of the skills from the md for every `SKILL.md`.
|
||||
|
||||
- The command for invoking skills is `$<skill-name>`
|
||||
## Gemini
|
||||
- Gets all skills from `~/.gemini/skills`, `~/.agents/skills`, `.gemini/skills`, `.agents/skills`
|
||||
- command for invoking skills is same as Claude.
|
||||
|
||||
|
||||
## Cursor
|
||||
[Skill directories](https://cursor.com/docs/skills?utm_source=chatgpt.com#skill-directories)
|
||||
Skills are automatically loaded from these locations:
|
||||
|
||||
|Location|Scope|
|
||||
|---|---|
|
||||
|`.agents/skills/`|Project-level|
|
||||
|`.cursor/skills/`|Project-level|
|
||||
|`~/.cursor/skills/`|User-level (global)|
|
||||
Then, parse the name and description of the skills from the md for every `SKILL.md`.
|
||||
|
||||
- command for invoking skills is same as Claude.
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,461 +0,0 @@
|
||||
# How each session processes sessions
|
||||
- The way each session processes the sessions is already setup in `server/src/modules/providers`. Port over the existing logic to the new classes if possible.
|
||||
|
||||
# How to start, resume, and stop a session
|
||||
|
||||
## Claude
|
||||
A new session is created by calling `query({ prompt, options })` which yields an async stream of SDK messages. The session ID can be provided explicitly by using `resume` option and passing the session id (`sdkOptions.resume = sessionId;`).
|
||||
|
||||
https://platform.claude.com/docs/en/agent-sdk/typescript#types
|
||||
|
||||
Session can be stopped midway using `queryInstance.interrupt()`
|
||||
https://platform.claude.com/docs/en/agent-sdk/typescript#methods
|
||||
|
||||
## Codex
|
||||
- Starting - `const thread = codex.startThread(threadOptions)`
|
||||
- Resuming - `codex.resumeThread(sessionId, threadOptions);`
|
||||
- Stop a session
|
||||
```
|
||||
// Execute with streaming
|
||||
|
||||
const streamedTurn = await thread.runStreamed(command, {
|
||||
|
||||
signal: abortController.signal
|
||||
|
||||
});
|
||||
```
|
||||
### About Abort controllers
|
||||
- Think of `AbortController` as a **cancel button for async work**.
|
||||
- **Controller** = thing that sends the cancel command.
|
||||
- **Signal** = thing that receives or carries the cancel state
|
||||
|
||||
```js
|
||||
const controller = new AbortController();
|
||||
|
||||
fetch("https://api.example.com/data", {
|
||||
signal: controller.signal
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
console.log("Finished:", data);
|
||||
})
|
||||
.catch(error => {
|
||||
if (error.name === "AbortError") {
|
||||
console.log("The request was cancelled");
|
||||
} else {
|
||||
console.error("Real error:", error);
|
||||
}
|
||||
});
|
||||
|
||||
// Cancel it after 2 seconds
|
||||
setTimeout(() => {
|
||||
controller.abort();
|
||||
}, 2000);
|
||||
```
|
||||
- `AbortController` does **not magically stop all JavaScript everywhere**. It only works if the API or function you are using actually supports cancellation via a signal. `fetch` does. Your own custom async functions can too, but you have to write that support yourself. In codex, the method `runStreamed` supports it as well.
|
||||
```js
|
||||
function wait(ms, { signal } = {}) {
|
||||
return new Promise((resolve, reject) => {
|
||||
// if signal was aborted EVEN BEFORE the function started, return back.
|
||||
// This catches the case where someone did this first:
|
||||
// controller.abort("Cancelled already");
|
||||
// wait(5000, { signal: controller.signal });
|
||||
if (signal?.aborted) {
|
||||
reject(signal.reason); // it supports custom reasoning as well.
|
||||
return;
|
||||
}
|
||||
|
||||
const timeoutId = setTimeout(() => {
|
||||
resolve("Done waiting");
|
||||
}, ms);
|
||||
|
||||
// when the signal.abort event is fired (when controller.abort() is called somewhere else), it sends an `abort` event.
|
||||
// When we get this, remove the timeoutId
|
||||
signal?.addEventListener("abort", () => {
|
||||
clearTimeout(timeoutId);
|
||||
reject(signal.reason);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
// ---------------- USAGE --------------------
|
||||
const controller = new AbortController();
|
||||
|
||||
wait(5000, { signal: controller.signal })
|
||||
.then(result => {
|
||||
console.log(result);
|
||||
})
|
||||
.catch(error => {
|
||||
console.log("Cancelled:", error);
|
||||
});
|
||||
|
||||
setTimeout(() => {
|
||||
controller.abort("User cancelled the wait");
|
||||
}, 1000);
|
||||
|
||||
```
|
||||
|
||||
|
||||
## Gemini
|
||||
### Start
|
||||
|
||||
spawn `gemini --prompt "actualprompt" --model "actual model", --output-format 'stream-json'`
|
||||
|
||||
- Stream `json` output format send responses in terms of a series of `json` chunks. If we store it, we would use .`jsonl` format.
|
||||
- Allowed tools aren't needed as it's depreciated.
|
||||
```
|
||||
--allowed-tools [DEPRECATED: Use Policy Engine instead See
|
||||
https://geminicli.com/docs/core/policy-engine] Tools that are allowed
|
||||
to run without confirmation
|
||||
```
|
||||
|
||||
- `--prompt` allows us to run just one prompt in headless mode. It will automatically trust the workspace directory so it won't ask us whether we trust the workspace or not.
|
||||
|
||||
### Stop/Abort a session
|
||||
```js
|
||||
try {
|
||||
geminiProc.kill('SIGTERM'); // gracefully terminates the process. It ASKS the process to shut down cleanly. The process can catch it, save state, close files, and exit
|
||||
setTimeout(() => {
|
||||
geminiProc.kill('SIGKILL'); // kills it immediately
|
||||
}
|
||||
}, 2000); // Wait 2 seconds before force kill
|
||||
|
||||
return true;
|
||||
} catch (error) {
|
||||
return false;
|
||||
}
|
||||
```
|
||||
|
||||
### resume
|
||||
- spawn `gemini <the above formats> --resume <sessionId>`
|
||||
|
||||
### To receive a response
|
||||
```
|
||||
child.stdout.on('data', (chunk) => {
|
||||
const text = chunk.toString();
|
||||
...
|
||||
})
|
||||
|
||||
child.stderr.on('data', (chunk) => {
|
||||
const text = chunk.toString();
|
||||
...
|
||||
}
|
||||
```
|
||||
|
||||
## Cursor
|
||||
### Start
|
||||
- spawn `cursor-agent --print --trust --output-format 'stream-json' <actual-prompt'>`
|
||||
This won't be able to run shell commands like `git init`. To be able to run those, `--yolo` must be passed.
|
||||
|
||||
### Resume
|
||||
- spawn `cursor-agent <above commands> --resume <sessionID>`
|
||||
|
||||
### abort
|
||||
- same approach as gemini.
|
||||
|
||||
|
||||
# How to fetch (list the model types supported for each model...find out if there is an easy way to fetch automatically from the files)
|
||||
|
||||
## Claude
|
||||
|
||||
`query.supportedModels()` returns `ModelInfo[]`.
|
||||
```ts
|
||||
/**
|
||||
* Information about an available model.
|
||||
*/
|
||||
export declare type ModelInfo = {
|
||||
/**
|
||||
* Model identifier to use in API calls
|
||||
*/
|
||||
value: string;
|
||||
/**
|
||||
* Human-readable display name
|
||||
*/
|
||||
displayName: string;
|
||||
/**
|
||||
* Description of the model's capabilities
|
||||
*/
|
||||
description: string;
|
||||
/**
|
||||
* Whether this model supports effort levels
|
||||
*/
|
||||
supportsEffort?: boolean;
|
||||
/**
|
||||
* Available effort levels for this model
|
||||
*/
|
||||
supportedEffortLevels?: ('low' | 'medium' | 'high' | 'max')[];
|
||||
/**
|
||||
* Whether this model supports adaptive thinking (Claude decides when and how much to think)
|
||||
*/
|
||||
supportsAdaptiveThinking?: boolean;
|
||||
};
|
||||
```
|
||||
|
||||
```
|
||||
supported models = [
|
||||
{
|
||||
value: 'default',
|
||||
displayName: 'Default (recommended)',
|
||||
description: 'Use the default model (currently Sonnet 4.6) · $3/$15 per Mtok',
|
||||
supportsEffort: true,
|
||||
supportedEffortLevels: [ 'low', 'medium', 'high', 'max' ],
|
||||
supportsAdaptiveThinking: true
|
||||
},
|
||||
{
|
||||
value: 'sonnet[1m]',
|
||||
displayName: 'Sonnet (1M context)',
|
||||
description: 'Sonnet 4.6 for long sessions · $6/$22.50 per Mtok',
|
||||
supportsEffort: true,
|
||||
supportedEffortLevels: [ 'low', 'medium', 'high', 'max' ],
|
||||
supportsAdaptiveThinking: true
|
||||
},
|
||||
{
|
||||
value: 'opus',
|
||||
displayName: 'Opus',
|
||||
description: 'Opus 4.6 · Most capable for complex work · $5/$25 per Mtok',
|
||||
supportsEffort: true,
|
||||
supportedEffortLevels: [ 'low', 'medium', 'high', 'max' ],
|
||||
supportsAdaptiveThinking: true
|
||||
},
|
||||
{
|
||||
value: 'opus[1m]',
|
||||
displayName: 'Opus (1M context)',
|
||||
description: 'Opus 4.6 for long sessions · $10/$37.50 per Mtok',
|
||||
supportsEffort: true,
|
||||
supportedEffortLevels: [ 'low', 'medium', 'high', 'max' ],
|
||||
supportsAdaptiveThinking: true
|
||||
},
|
||||
{
|
||||
value: 'haiku',
|
||||
displayName: 'Haiku',
|
||||
description: 'Haiku 4.5 · Fastest for quick answers · $1/$5 per Mtok'
|
||||
},
|
||||
{
|
||||
value: 'sonnet',
|
||||
displayName: 'sonnet',
|
||||
description: 'Custom model',
|
||||
supportsEffort: true,
|
||||
supportedEffortLevels: [ 'low', 'medium', 'high', 'max' ],
|
||||
supportsAdaptiveThinking: true
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
## Codex
|
||||
|
||||
- Found in `.codex/models_cache.json`. It's in the `models` attribute.
|
||||
```json
|
||||
{
|
||||
...,
|
||||
"models": [
|
||||
{
|
||||
"slug": "gpt-5.4",
|
||||
"display_name": "gpt-5.4",
|
||||
"description": "Latest frontier agentic coding model.",
|
||||
"default_reasoning_level": "medium",
|
||||
"supported_reasoning_levels": [
|
||||
{
|
||||
"effort": "low",
|
||||
"description": "Fast responses with lighter reasoning"
|
||||
},
|
||||
{
|
||||
"effort": "medium",
|
||||
"description": "Balances speed and reasoning depth for everyday tasks"
|
||||
},
|
||||
{
|
||||
"effort": "high",
|
||||
"description": "Greater reasoning depth for complex problems"
|
||||
},
|
||||
{
|
||||
"effort": "xhigh",
|
||||
"description": "Extra high reasoning depth for complex problems"
|
||||
}
|
||||
],
|
||||
"shell_type": "shell_command",
|
||||
"visibility": "list",
|
||||
"supported_in_api": true,
|
||||
"priority": 1,
|
||||
"availability_nux": null,
|
||||
"upgrade": null,
|
||||
"base_instructions": "...",
|
||||
"model_messages": {
|
||||
"instructions_template": "...",
|
||||
"instructions_variables": {
|
||||
"personality_default": "",
|
||||
"personality_friendly": "..."
|
||||
}
|
||||
},
|
||||
"supports_reasoning_summaries": true,
|
||||
"default_reasoning_summary": "none",
|
||||
"support_verbosity": true,
|
||||
"default_verbosity": "low",
|
||||
"apply_patch_tool_type": "freeform",
|
||||
"web_search_tool_type": "text_and_image",
|
||||
"truncation_policy": {
|
||||
"mode": "tokens",
|
||||
"limit": 10000
|
||||
},
|
||||
"supports_parallel_tool_calls": true,
|
||||
"supports_image_detail_original": true,
|
||||
"context_window": 272000,
|
||||
"effective_context_window_percent": 95,
|
||||
"experimental_supported_tools": [],
|
||||
"input_modalities": [
|
||||
"text",
|
||||
"image"
|
||||
],
|
||||
"supports_search_tool": true
|
||||
},
|
||||
{
|
||||
...
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## Gemini
|
||||
- There is no way to automatically do this. So, use this
|
||||
![[Pasted image 20260401124033.png]]
|
||||
|
||||
The above is for free one. The below contains for all.
|
||||
|
||||
```
|
||||
OPTIONS: [
|
||||
{ value: 'gemini-3.1-pro-preview', label: 'Gemini 3.1 Pro Preview' },
|
||||
{ value: 'gemini-3-pro-preview', label: 'Gemini 3 Pro Preview' },
|
||||
{ value: 'gemini-3-flash-preview', label: 'Gemini 3 Flash Preview' },
|
||||
{ value: 'gemini-2.5-flash', label: 'Gemini 2.5 Flash' },
|
||||
{ value: 'gemini-2.5-pro', label: 'Gemini 2.5 Pro' },
|
||||
{ value: 'gemini-2.0-flash-lite', label: 'Gemini 2.0 Flash Lite' },
|
||||
{ value: 'gemini-2.0-flash', label: 'Gemini 2.0 Flash' },
|
||||
{ value: 'gemini-2.0-pro-exp', label: 'Gemini 2.0 Pro Experimental' },
|
||||
{ value: 'gemini-2.0-flash-thinking-exp', label: 'Gemini 2.0 Flash Thinking' }
|
||||
],
|
||||
```
|
||||
|
||||
## Cursor
|
||||
- spawn `cursor-agent --list-models` and parse the ANSI output.
|
||||
```js
|
||||
function parseModelLine(line) {
|
||||
const trimmed = line.trim();
|
||||
|
||||
if (!trimmed || trimmed === 'Available models' || trimmed.startsWith('Loading models') || trimmed.startsWith('Tip:')) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const match = trimmed.match(/^(.+?)\s+-\s+(.+)$/);
|
||||
if (!match) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const name = match[1].trim();
|
||||
let description = match[2].trim();
|
||||
const current = /\(current\)/i.test(description);
|
||||
const defaultModel = /\(default\)/i.test(description);
|
||||
|
||||
description = description.replace(/\s*\((current|default)\)/gi, '').replace(/\s{2,}/g, ' ').trim();
|
||||
|
||||
return {
|
||||
name,
|
||||
description,
|
||||
current,
|
||||
default: defaultModel,
|
||||
};
|
||||
}
|
||||
|
||||
function parseModelsOutput(text) {
|
||||
const models = [];
|
||||
|
||||
for (const line of stripAnsi(text).split(/\r?\n/)) {
|
||||
const parsed = parseModelLine(line);
|
||||
if (parsed) {
|
||||
models.push(parsed);
|
||||
}
|
||||
}
|
||||
|
||||
return models;
|
||||
}
|
||||
|
||||
|
||||
// ------------ tHE ABOVE RETURNS ------------
|
||||
[
|
||||
{
|
||||
"name": "auto",
|
||||
"description": "Auto",
|
||||
"current": true,
|
||||
"default": false
|
||||
},
|
||||
{
|
||||
"name": "composer-2-fast",
|
||||
"description": "Composer 2 Fast",
|
||||
"current": false,
|
||||
"default": true
|
||||
},
|
||||
{
|
||||
"name": "composer-2",
|
||||
"description": "Composer 2",
|
||||
"current": false,
|
||||
"default": false
|
||||
},
|
||||
...
|
||||
]
|
||||
```
|
||||
|
||||
# How to fetch session history
|
||||
- In the sessions table, there is a `jsonl_path` column. Go to directly that and parse the JSONLs from there. For `gemini`, the `jsonl_path` actually points to a gemini JSON file (since Gemini stores information in JSON rather than JSONL). DON'T use the LEGACY fetcher.
|
||||
|
||||
# How to search conversations for each provider
|
||||
- Go to all the JSONL path directories from the database and use `@vscode/ripgrep` library for searching something.
|
||||
|
||||
|
||||
# How to change thinking modes for each model
|
||||
## Claude
|
||||
- Passed through `query` options through `effort: <'low' | 'medium' | 'high' | 'max'>`
|
||||
|
||||
Default is high.
|
||||
|
||||
## Codex
|
||||
- passed through `threadOptions`
|
||||
|
||||
```
|
||||
|
||||
type ModelReasoningEffort = "minimal" | "low" | "medium" | "high" | "xhigh";
|
||||
|
||||
type ThreadOptions = {
|
||||
model?: string;
|
||||
sandboxMode?: SandboxMode;
|
||||
workingDirectory?: string;
|
||||
skipGitRepoCheck?: boolean;
|
||||
modelReasoningEffort?: ModelReasoningEffort;
|
||||
networkAccessEnabled?: boolean;
|
||||
webSearchMode?: WebSearchMode;
|
||||
webSearchEnabled?: boolean;
|
||||
approvalPolicy?: ApprovalMode;
|
||||
additionalDirectories?: string[];
|
||||
};
|
||||
|
||||
|
||||
```
|
||||
- `minimal` is supported only by `GPT-5`
|
||||
|
||||
## Gemini
|
||||
- Not changeable. We can only select the different providers that have different thinking levels by themselves.
|
||||
|
||||
## Cursor
|
||||
- Same as gemini.
|
||||
|
||||
|
||||
# How to set/change models at start/after a session response respectively?
|
||||
## Claude
|
||||
- Initially can be set at start using `queryOptions.model`
|
||||
- Just resume the session by updating the model in `threadoptions`
|
||||
|
||||
## Codex
|
||||
- Same as claude
|
||||
|
||||
## Gemini
|
||||
- Just add the `--model <model-name>` property in the new spawned command. If there is something to resume, add `--resume <sessionID>`
|
||||
## Cursor
|
||||
- Just add the `--model <model-name>` property in the new spawned command. If there is something to resume, add `--resume <sessionID>`. In other words, same as gemini.
|
||||
|
||||
@@ -1,41 +0,0 @@
|
||||
# LLM Unifier Backend Testing Report
|
||||
|
||||
Date: 2026-04-06
|
||||
|
||||
## Scope
|
||||
This report validates the backend functionality checklist in `docs/backend/llm-unifier-helper.md`.
|
||||
|
||||
## Test Files Added
|
||||
- `server/src/modules/llm/llm-unifier.providers.test.ts`
|
||||
- `server/src/modules/llm/llm-unifier.sessions.test.ts`
|
||||
|
||||
Each test case includes an inline comment describing which helper requirement it covers.
|
||||
|
||||
## Command Used
|
||||
```powershell
|
||||
$env:TSX_TSCONFIG_PATH='server/tsconfig.json'; npm run test:server -- server/src/modules/llm/llm-unifier.providers.test.ts server/src/modules/llm/llm-unifier.sessions.test.ts
|
||||
```
|
||||
|
||||
## Result
|
||||
- Total tests: 32
|
||||
- Passed: 32
|
||||
- Failed: 0
|
||||
|
||||
## Requirement Coverage Matrix
|
||||
| Helper requirement | Coverage |
|
||||
| --- | --- |
|
||||
| Session processing logic orchestration | `llmSessionsService.synchronizeSessions aggregates processed counts and failures`, `llmSessionsService.synchronizeProvider honors fullRescan option` |
|
||||
| Start/resume behavior: Cursor | `cursor provider builds start/resume CLI invocations correctly` |
|
||||
| Start/resume behavior: Gemini | `gemini provider builds start/resume CLI invocations and exposes curated models` |
|
||||
| Start/resume/stop behavior: Codex (`startThread`, `resumeThread`, abort controller) | `codex provider start/resume use correct SDK thread methods and stop aborts signal` |
|
||||
| Claude helper behavior (effort mapping, runtime permission handler, event normalization) | `claude provider helper mappings match unifier contract` |
|
||||
| Model listing: Cursor (`--list-models` parsing) | `cursor provider parses model list output into normalized models` |
|
||||
| Model listing: Gemini (curated options) | `gemini provider builds start/resume CLI invocations and exposes curated models` |
|
||||
| Model listing: Codex (`~/.codex/models_cache.json`) | `codex provider reads models_cache.json and maps model metadata` |
|
||||
| Runtime permission/thinking support constraints | `llmService rejects unsupported runtime permission and thinking mode combinations`, `providers enforce capability gates for model/thinking updates` |
|
||||
| Thinking mode + model preference persistence across launches | `codex provider applies saved model/thinking preferences on subsequent launch` |
|
||||
| Session history from DB `jsonl_path` (JSONL + Gemini JSON), no legacy fetcher path | `llmSessionsService.getSessionHistory parses JSONL and Gemini JSON correctly` |
|
||||
| Session artifact deletion using processor path | `llmSessionsService.deleteSessionArtifacts validates ids and deletes disk/db artifacts` |
|
||||
| Session rename/update path | `llmSessionsService.updateSessionCustomName validates existence before updating` |
|
||||
| Conversation search over indexed transcript paths with provider/case filters | `conversationSearchService searches indexed transcripts with provider and case filters` |
|
||||
|
||||
@@ -1,56 +0,0 @@
|
||||
# LLM Unifier Helper-2 Backend Testing Report
|
||||
|
||||
Date: 2026-04-06
|
||||
|
||||
## Scope
|
||||
This report validates every backend functionality listed in:
|
||||
- `docs/backend/llm-unifier-helper-2.md`
|
||||
|
||||
All test cases include inline comments that describe which helper-2 requirement they cover.
|
||||
|
||||
## Test Files
|
||||
- `server/src/modules/llm/llm-unifier.providers.test.ts`
|
||||
- `server/src/modules/llm/llm-unifier.sessions.test.ts`
|
||||
- `server/src/modules/llm/llm-unifier.images.test.ts`
|
||||
- `server/src/modules/llm/llm-unifier.mcp.test.ts`
|
||||
- `server/src/modules/llm/llm-unifier.skills.test.ts`
|
||||
|
||||
## package.json Scripts
|
||||
- `test:server` now includes the full unifier suite.
|
||||
- Added `test:server:llm-unifier-2` for running only helper-2 unifier coverage.
|
||||
|
||||
## Commands Used
|
||||
```powershell
|
||||
npm run typecheck:server
|
||||
npm run test:server:llm-unifier-2
|
||||
npm run test:server
|
||||
```
|
||||
|
||||
## Results
|
||||
- `typecheck:server`: pass
|
||||
- `test:server:llm-unifier-2`: pass (`30/30`)
|
||||
- `test:server`: pass (`30/30`)
|
||||
|
||||
## Requirement Coverage Matrix
|
||||
| Helper-2 requirement | Test coverage |
|
||||
| --- | --- |
|
||||
| Universal image upload into `.cloudcli/assets` | `llmAssetsService stores uploaded images in .cloudcli/assets` |
|
||||
| Image upload validation for supported image mime types | `llmAssetsService rejects unsupported image mime types` |
|
||||
| Claude image prompt as content blocks with base64 images | `claude provider builds async prompt payload with base64 image blocks` |
|
||||
| Codex image prompt via `local_image` entries | `codex provider sends local_image prompt items when image paths are provided` |
|
||||
| Gemini/Cursor image handling by appending image path array to prompt | `gemini and cursor providers append image path arrays to prompts` |
|
||||
| Start payload imagePaths validation | `llmService rejects invalid imagePaths payloads before provider execution` |
|
||||
| MCP list grouped by User/Local/Project | `llmMcpService handles claude MCP scopes/transports with file-backed persistence` |
|
||||
| MCP add/remove/update behavior backed by provider config files | `llmMcpService handles claude MCP scopes/transports with file-backed persistence`, `llmMcpService handles codex MCP TOML config and capability validation`, `llmMcpService handles gemini and cursor MCP JSON config formats` |
|
||||
| Claude MCP transports: stdio/http/sse and scopes: user/local/project | `llmMcpService handles claude MCP scopes/transports with file-backed persistence` |
|
||||
| Codex MCP transports: stdio/http and scopes: user/project | `llmMcpService handles codex MCP TOML config and capability validation` |
|
||||
| Gemini MCP transports: stdio/http/sse and scopes: user/project | `llmMcpService handles gemini and cursor MCP JSON config formats` |
|
||||
| Cursor MCP transports: stdio/http/sse and scopes: user/project | `llmMcpService handles gemini and cursor MCP JSON config formats` |
|
||||
| Global MCP adder supports only `http` and `stdio` and applies to all providers | `llmMcpService global adder writes to all providers and rejects unsupported transports` |
|
||||
| MCP run/connectivity checks (stdio and http) | `llmMcpService runProviderServer probes stdio and http MCP servers` |
|
||||
| Claude skills fetch (user/project/plugin) and plugin namespacing | `llmSkillsService lists claude user/project/plugin skills with proper invocation names` |
|
||||
| Codex skills fetch (repo/user/admin/system path model; tested repo/user/system paths) and `$` invocation | `llmSkillsService lists codex skills from repo/user/system locations with dollar invocation` |
|
||||
| Gemini skills fetch from documented directories and `/` invocation | `llmSkillsService lists gemini skills from documented directories` |
|
||||
| Cursor skills fetch from documented directories and `/` invocation | `llmSkillsService lists cursor skills from documented directories` |
|
||||
| Existing unifier provider/session baseline behaviors remain passing | `llm-unifier.providers.test.ts`, `llm-unifier.sessions.test.ts` full suite |
|
||||
|
||||
871
package-lock.json
generated
871
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
50
package.json
50
package.json
@@ -1,11 +1,10 @@
|
||||
{
|
||||
"name": "@siteboon/claude-code-ui",
|
||||
"version": "1.26.3",
|
||||
"name": "@cloudcli-ai/cloudcli",
|
||||
"version": "1.28.0",
|
||||
"description": "A web-based UI for Claude Code CLI",
|
||||
"type": "module",
|
||||
"main": "server/start.js",
|
||||
"main": "server/index.js",
|
||||
"bin": {
|
||||
"claude-code-ui": "server/cli.js",
|
||||
"cloudcli": "server/cli.js"
|
||||
},
|
||||
"files": [
|
||||
@@ -25,35 +24,39 @@
|
||||
},
|
||||
"scripts": {
|
||||
"dev": "concurrently --kill-others \"npm run server\" \"npm run client\"",
|
||||
"server:dev": "tsx watch --tsconfig server/tsconfig.json server/src/bootstrap.ts",
|
||||
"server": "tsx --tsconfig server/tsconfig.json server/src/bootstrap.ts",
|
||||
"server:build": "tsc -p server/tsconfig.json && tsc-alias -p server/tsconfig.json",
|
||||
"server:start": "node server/start.js",
|
||||
"server": "node server/index.js",
|
||||
"client": "vite",
|
||||
"build": "vite build",
|
||||
"preview": "vite preview",
|
||||
"typecheck:client": "tsc --noEmit -p tsconfig.json",
|
||||
"typecheck:server": "tsc --noEmit -p server/tsconfig.json",
|
||||
"test:server": "tsx --tsconfig server/tsconfig.json --test server/src/modules/ai-runtime/tests/*.test.ts",
|
||||
"verify:server": "npm run typecheck:server && npm run test:server && npm run server:build",
|
||||
"typecheck": "npm run typecheck:client && npm run typecheck:server",
|
||||
"typecheck": "tsc --noEmit -p tsconfig.json",
|
||||
"lint": "eslint src/",
|
||||
"lint:fix": "eslint src/ --fix",
|
||||
"start": "npm run build && npm run server:build && npm run server:start",
|
||||
"start": "npm run build && npm run server",
|
||||
"release": "./release.sh",
|
||||
"prepublishOnly": "npm run build && npm run server:build",
|
||||
"prepublishOnly": "npm run build",
|
||||
"postinstall": "node scripts/fix-node-pty.js",
|
||||
"prepare": "husky"
|
||||
},
|
||||
"keywords": [
|
||||
"claude code",
|
||||
"ai",
|
||||
"claude-code",
|
||||
"claude-code-ui",
|
||||
"cloudcli",
|
||||
"codex",
|
||||
"gemini",
|
||||
"gemini-cli",
|
||||
"cursor",
|
||||
"cursor-cli",
|
||||
"anthropic",
|
||||
"openai",
|
||||
"google",
|
||||
"coding-agent",
|
||||
"web-ui",
|
||||
"ui",
|
||||
"mobile"
|
||||
"mobile IDE"
|
||||
],
|
||||
"author": "CloudCLI UI Contributors",
|
||||
"license": "GPL-3.0",
|
||||
"license": "AGPL-3.0-or-later",
|
||||
"dependencies": {
|
||||
"@anthropic-ai/claude-agent-sdk": "^0.2.59",
|
||||
"@codemirror/lang-css": "^6.3.1",
|
||||
@@ -69,7 +72,6 @@
|
||||
"@openai/codex-sdk": "^0.101.0",
|
||||
"@replit/codemirror-minimap": "^0.5.2",
|
||||
"@tailwindcss/typography": "^0.5.16",
|
||||
"@types/multer": "^2.1.0",
|
||||
"@uiw/react-codemirror": "^4.23.13",
|
||||
"@xterm/addon-clipboard": "^0.1.0",
|
||||
"@xterm/addon-fit": "^0.10.0",
|
||||
@@ -119,17 +121,9 @@
|
||||
"@commitlint/config-conventional": "^20.4.3",
|
||||
"@eslint/js": "^9.39.3",
|
||||
"@release-it/conventional-changelog": "^10.0.5",
|
||||
"@types/bcrypt": "^6.0.0",
|
||||
"@types/better-sqlite3": "^7.6.13",
|
||||
"@types/cors": "^2.8.19",
|
||||
"@types/cross-spawn": "^6.0.6",
|
||||
"@types/express": "^5.0.3",
|
||||
"@types/jsonwebtoken": "^9.0.10",
|
||||
"@types/node": "^22.19.7",
|
||||
"@types/react": "^18.2.43",
|
||||
"@types/react-dom": "^18.2.17",
|
||||
"@types/web-push": "^3.6.4",
|
||||
"@types/ws": "^8.18.1",
|
||||
"@vitejs/plugin-react": "^4.6.0",
|
||||
"auto-changelog": "^2.5.0",
|
||||
"autoprefixer": "^10.4.16",
|
||||
@@ -149,8 +143,6 @@
|
||||
"release-it": "^19.0.5",
|
||||
"sharp": "^0.34.2",
|
||||
"tailwindcss": "^3.4.0",
|
||||
"tsc-alias": "^1.8.16",
|
||||
"tsx": "^4.20.6",
|
||||
"typescript": "^5.9.3",
|
||||
"typescript-eslint": "^8.56.1",
|
||||
"vite": "^7.0.4"
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<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/png" href="/favicon.png" />
|
||||
|
||||
@@ -418,7 +418,7 @@
|
||||
</svg>
|
||||
</div>
|
||||
<div class="brand-text">
|
||||
<h1>Claude Code UI</h1>
|
||||
<h1>CloudCLI</h1>
|
||||
<div class="subtitle">API Documentation</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -585,7 +585,7 @@
|
||||
<p>Server-sent events (SSE) format with real-time updates. Content-Type: <code>text/event-stream</code></p>
|
||||
|
||||
<h4>Response (Non-Streaming)</h4>
|
||||
<p>JSON object containing session details, assistant messages only (filtered), and token usage summary. Content-Type: <code>application/json</code></p>
|
||||
<p>JSON object containing session details and assistant messages only (filtered). Content-Type: <code>application/json</code></p>
|
||||
|
||||
<h4>Error Response</h4>
|
||||
<p>Returns error details with appropriate HTTP status code.</p>
|
||||
@@ -674,21 +674,10 @@ data: {"type":"done"}</code></pre>
|
||||
"type": "text",
|
||||
"text": "I've completed the task..."
|
||||
}
|
||||
],
|
||||
"usage": {
|
||||
"input_tokens": 150,
|
||||
"output_tokens": 50
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"tokens": {
|
||||
"inputTokens": 150,
|
||||
"outputTokens": 50,
|
||||
"cacheReadTokens": 0,
|
||||
"cacheCreationTokens": 0,
|
||||
"totalTokens": 200
|
||||
},
|
||||
"projectPath": "/path/to/project",
|
||||
"branch": {
|
||||
"name": "fix-authentication-bug-abc123",
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Service Worker for Claude Code UI PWA
|
||||
// Service Worker for CloudCLI PWA
|
||||
// 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';
|
||||
@@ -79,7 +79,7 @@ self.addEventListener('push', event => {
|
||||
try {
|
||||
payload = event.data.json();
|
||||
} catch {
|
||||
payload = { title: 'Claude Code UI', body: event.data.text() };
|
||||
payload = { title: 'CloudCLI', body: event.data.text() };
|
||||
}
|
||||
|
||||
const options = {
|
||||
@@ -92,7 +92,7 @@ self.addEventListener('push', event => {
|
||||
};
|
||||
|
||||
event.waitUntil(
|
||||
self.registration.showNotification(payload.title || 'Claude Code UI', options)
|
||||
self.registration.showNotification(payload.title || 'CloudCLI', options)
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
248
redirect-package/README.md
Normal file
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
2
redirect-package/bin.js
Normal file
@@ -0,0 +1,2 @@
|
||||
#!/usr/bin/env node
|
||||
import('@cloudcli-ai/cloudcli/server/cli.js');
|
||||
2
redirect-package/index.js
Normal file
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
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"
|
||||
}
|
||||
@@ -1,657 +0,0 @@
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import { fileURLToPath } from 'url';
|
||||
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = path.dirname(__filename);
|
||||
const projectRoot = path.resolve(__dirname, '..');
|
||||
const serverRoot = path.join(projectRoot, 'server');
|
||||
const clientRoot = path.join(projectRoot, 'src');
|
||||
const docsRoot = path.join(projectRoot, 'docs', 'backend');
|
||||
|
||||
const HTTP_METHODS = ['get', 'post', 'put', 'delete', 'patch'];
|
||||
const routeDefinitionPattern = /\b(app|router)\.(get|post|put|delete|patch)\(\s*(['"`])(.+?)\3/g;
|
||||
const defaultImportPattern =
|
||||
/^import\s+([A-Za-z0-9_$]+)(?:\s*,\s*\{[^}]+\})?\s+from\s+['"](.+?)['"];$/gm;
|
||||
const incomingRealtimePattern = /data\.type === '([^']+)'/g;
|
||||
const outgoingRealtimePattern = /type:\s*'([^']+)'/g;
|
||||
|
||||
fs.mkdirSync(docsRoot, { recursive: true });
|
||||
|
||||
function toPosix(value) {
|
||||
return value.split(path.sep).join('/');
|
||||
}
|
||||
|
||||
function readText(filePath) {
|
||||
return fs.readFileSync(filePath, 'utf8');
|
||||
}
|
||||
|
||||
function walkFiles(dirPath, files = []) {
|
||||
for (const entry of fs.readdirSync(dirPath, { withFileTypes: true })) {
|
||||
if (entry.name === 'dist' || entry.name === 'node_modules') {
|
||||
continue;
|
||||
}
|
||||
|
||||
const fullPath = path.join(dirPath, entry.name);
|
||||
if (entry.isDirectory()) {
|
||||
walkFiles(fullPath, files);
|
||||
continue;
|
||||
}
|
||||
|
||||
files.push(fullPath);
|
||||
}
|
||||
|
||||
return files;
|
||||
}
|
||||
|
||||
function getLineNumber(content, index) {
|
||||
return content.slice(0, index).split(/\r?\n/).length;
|
||||
}
|
||||
|
||||
function splitArgs(argumentSource) {
|
||||
return argumentSource
|
||||
.split(',')
|
||||
.map(part => part.trim())
|
||||
.filter(Boolean);
|
||||
}
|
||||
|
||||
function sanitizeObjectKey(key) {
|
||||
return key
|
||||
.replace(/^[\s{]+|[\s}]+$/g, '')
|
||||
.replace(/=.*$/, '')
|
||||
.replace(/:.+$/, '')
|
||||
.replace(/\?/g, '')
|
||||
.trim();
|
||||
}
|
||||
|
||||
function collectObjectKeys(block, accessor) {
|
||||
const keys = new Set();
|
||||
const directPattern = new RegExp(`req\\.${accessor}\\.([A-Za-z0-9_]+)`, 'g');
|
||||
const destructuringPattern = new RegExp(`\\{([^}]*)\\}\\s*=\\s*req\\.${accessor}`, 'gs');
|
||||
|
||||
for (const match of block.matchAll(directPattern)) {
|
||||
keys.add(match[1]);
|
||||
}
|
||||
|
||||
for (const match of block.matchAll(destructuringPattern)) {
|
||||
for (const rawKey of match[1].split(',')) {
|
||||
const key = sanitizeObjectKey(rawKey);
|
||||
if (key) {
|
||||
keys.add(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return [...keys].sort();
|
||||
}
|
||||
|
||||
function normalizeJoinedPath(basePath, routePath) {
|
||||
const safeBase = basePath.endsWith('/') ? basePath.slice(0, -1) : basePath;
|
||||
if (!routePath || routePath === '/') {
|
||||
return safeBase || '/';
|
||||
}
|
||||
|
||||
if (routePath === '*') {
|
||||
return routePath;
|
||||
}
|
||||
|
||||
const safeRoute = routePath.startsWith('/') ? routePath : `/${routePath}`;
|
||||
return `${safeBase}${safeRoute}` || '/';
|
||||
}
|
||||
|
||||
function getStaticSearchTokens(routePath) {
|
||||
const cleaned = routePath.replace(/:[A-Za-z0-9_]+/g, '').replace(/\*/g, '');
|
||||
const segments = cleaned.split('/').filter(Boolean);
|
||||
const tokens = new Set();
|
||||
|
||||
if (cleaned && cleaned !== '/') {
|
||||
tokens.add(cleaned.endsWith('/') ? cleaned : `${cleaned}`);
|
||||
}
|
||||
|
||||
for (let index = segments.length; index >= 2; index -= 1) {
|
||||
tokens.add(`/${segments.slice(0, index).join('/')}/`);
|
||||
}
|
||||
|
||||
if (segments.length > 0) {
|
||||
tokens.add(`/${segments.slice(0, 1).join('/')}/`);
|
||||
}
|
||||
|
||||
return [...tokens].filter(Boolean);
|
||||
}
|
||||
|
||||
function classifyTag(routePath) {
|
||||
if (routePath === '*' || routePath === '/health' || routePath.startsWith('/api/system')) {
|
||||
return 'System';
|
||||
}
|
||||
|
||||
if (routePath.startsWith('/api/auth')) return 'Auth';
|
||||
if (routePath.startsWith('/api/user')) return 'User';
|
||||
if (routePath.startsWith('/api/settings')) return 'Settings';
|
||||
if (routePath.startsWith('/api/git')) return 'Git';
|
||||
if (routePath.startsWith('/api/taskmaster')) return 'TaskMaster';
|
||||
if (routePath.startsWith('/api/plugins')) return 'Plugins';
|
||||
if (routePath.startsWith('/api/agent')) return 'Agent';
|
||||
if (routePath.startsWith('/api/commands')) return 'Commands';
|
||||
if (routePath.startsWith('/api/mcp')) return 'MCP';
|
||||
if (routePath.startsWith('/api/cli')) return 'CLI Auth';
|
||||
if (
|
||||
routePath.startsWith('/api/cursor') ||
|
||||
routePath.startsWith('/api/codex') ||
|
||||
routePath.startsWith('/api/gemini')
|
||||
) {
|
||||
return 'Providers';
|
||||
}
|
||||
|
||||
if (routePath.startsWith('/api/search') || routePath.includes('/sessions')) {
|
||||
return 'Sessions';
|
||||
}
|
||||
|
||||
if (routePath.includes('/files') || routePath.includes('/file') || routePath.includes('/upload')) {
|
||||
return 'Files';
|
||||
}
|
||||
|
||||
if (routePath.startsWith('/api/projects') || routePath.startsWith('/api/create-folder')) {
|
||||
return 'Projects';
|
||||
}
|
||||
|
||||
return 'Realtime';
|
||||
}
|
||||
|
||||
function classifyPriority(tag, routePath) {
|
||||
if (
|
||||
tag === 'Agent' ||
|
||||
tag === 'TaskMaster' ||
|
||||
tag === 'Git' ||
|
||||
routePath.startsWith('/api/projects') ||
|
||||
routePath.startsWith('/api/search')
|
||||
) {
|
||||
return 'high';
|
||||
}
|
||||
|
||||
if (
|
||||
tag === 'Providers' ||
|
||||
tag === 'Commands' ||
|
||||
tag === 'MCP' ||
|
||||
tag === 'Plugins' ||
|
||||
tag === 'Settings' ||
|
||||
tag === 'Auth' ||
|
||||
tag === 'User'
|
||||
) {
|
||||
return 'medium';
|
||||
}
|
||||
|
||||
return 'low';
|
||||
}
|
||||
|
||||
function describePurpose(method, routePath) {
|
||||
const verb = method.toUpperCase();
|
||||
|
||||
if (routePath === '/health') {
|
||||
return 'Expose server health, timestamp, and install mode for diagnostics.';
|
||||
}
|
||||
|
||||
if (routePath === '*') {
|
||||
return 'Serve the React application fallback for non-API routes.';
|
||||
}
|
||||
|
||||
if (routePath.startsWith('/api/system/update')) {
|
||||
return 'Run the application update workflow on the host machine.';
|
||||
}
|
||||
|
||||
if (routePath.startsWith('/api/auth/status')) return 'Report whether authentication is configured.';
|
||||
if (routePath.startsWith('/api/auth/register')) return 'Create the first local user account.';
|
||||
if (routePath.startsWith('/api/auth/login')) return 'Authenticate a local user and issue a token.';
|
||||
if (routePath.startsWith('/api/auth/user')) return 'Return the currently authenticated user.';
|
||||
if (routePath.startsWith('/api/auth/logout')) return 'Invalidate the current authenticated session.';
|
||||
|
||||
if (routePath.startsWith('/api/user/git-config')) return 'Read or update stored git identity settings.';
|
||||
if (routePath.startsWith('/api/user/complete-onboarding')) return 'Mark onboarding as completed for the current user.';
|
||||
if (routePath.startsWith('/api/user/onboarding-status')) return 'Return onboarding completion status for the current user.';
|
||||
|
||||
if (routePath.startsWith('/api/settings/api-keys')) return 'Manage local API keys used to access the backend.';
|
||||
if (routePath.startsWith('/api/settings/credentials')) return 'Manage stored provider and GitHub credentials.';
|
||||
|
||||
if (routePath.startsWith('/api/projects/create-workspace')) {
|
||||
return 'Create or register a workspace and optionally clone a GitHub repository into it.';
|
||||
}
|
||||
|
||||
if (routePath.startsWith('/api/projects/clone-progress')) {
|
||||
return 'Stream workspace cloning progress events to the frontend.';
|
||||
}
|
||||
|
||||
if (routePath === '/api/projects') return 'List detected projects and workspaces.';
|
||||
if (routePath.startsWith('/api/projects/create')) return 'Manually add a project path to the workspace list.';
|
||||
if (routePath.startsWith('/api/projects/:projectName/sessions/:sessionId/token-usage')) {
|
||||
return 'Report token usage for a stored provider session.';
|
||||
}
|
||||
|
||||
if (routePath.includes('/sessions/:sessionId/messages')) {
|
||||
return 'Return paginated messages for a stored session.';
|
||||
}
|
||||
|
||||
if (routePath.includes('/sessions')) {
|
||||
return 'List or manage sessions associated with a project or provider.';
|
||||
}
|
||||
|
||||
if (routePath.includes('/files') || routePath.includes('/file')) {
|
||||
return 'Read, write, create, rename, delete, or upload project files.';
|
||||
}
|
||||
|
||||
if (routePath.startsWith('/api/search/conversations')) {
|
||||
return 'Search conversation history across stored projects and stream results.';
|
||||
}
|
||||
|
||||
if (routePath.startsWith('/api/browse-filesystem')) {
|
||||
return 'Browse local directories so the UI can suggest workspace locations.';
|
||||
}
|
||||
|
||||
if (routePath.startsWith('/api/create-folder')) {
|
||||
return 'Create a new directory on the local filesystem.';
|
||||
}
|
||||
|
||||
if (routePath.startsWith('/api/transcribe')) {
|
||||
return 'Transcribe uploaded audio and optionally enhance the result for prompts or tasks.';
|
||||
}
|
||||
|
||||
if (routePath.includes('/upload-images')) {
|
||||
return 'Upload images for chat use and return browser-safe data URLs.';
|
||||
}
|
||||
|
||||
if (routePath.startsWith('/api/git/status')) return 'Read git status information for a project.';
|
||||
if (routePath.startsWith('/api/git/diff')) return 'Return git diff output for a project or file.';
|
||||
if (routePath.startsWith('/api/git/file-with-diff')) return 'Return file content together with diff context.';
|
||||
if (routePath.startsWith('/api/git/branches')) return 'List git branches for a project.';
|
||||
if (routePath.startsWith('/api/git/commits')) return 'List recent commits for a project.';
|
||||
if (routePath.startsWith('/api/git/commit-diff')) return 'Return diff details for a specific commit.';
|
||||
if (routePath.startsWith('/api/git/remote-status')) return 'Report remote sync status for a project repository.';
|
||||
if (routePath.startsWith('/api/git/generate-commit-message')) return 'Generate an AI-assisted commit message from the current diff.';
|
||||
|
||||
if (routePath.startsWith('/api/taskmaster')) {
|
||||
return 'Manage TaskMaster detection, PRDs, tasks, templates, and automation for a project.';
|
||||
}
|
||||
|
||||
if (routePath.startsWith('/api/commands')) {
|
||||
return 'List, load, or execute slash commands available to the chat experience.';
|
||||
}
|
||||
|
||||
if (routePath.startsWith('/api/mcp-utils')) {
|
||||
return 'Return MCP helper information used by setup flows.';
|
||||
}
|
||||
|
||||
if (routePath.startsWith('/api/mcp')) {
|
||||
return 'Manage Claude MCP CLI and configuration state.';
|
||||
}
|
||||
|
||||
if (routePath.startsWith('/api/cursor')) {
|
||||
return 'Manage Cursor configuration, MCP settings, and stored sessions.';
|
||||
}
|
||||
|
||||
if (routePath.startsWith('/api/codex')) {
|
||||
return 'Manage Codex configuration, MCP settings, and stored sessions.';
|
||||
}
|
||||
|
||||
if (routePath.startsWith('/api/gemini')) {
|
||||
return 'Manage Gemini session history for the UI.';
|
||||
}
|
||||
|
||||
if (routePath.startsWith('/api/cli')) {
|
||||
return 'Report local authentication status for provider CLIs.';
|
||||
}
|
||||
|
||||
if (routePath.startsWith('/api/plugins')) {
|
||||
return 'List, install, update, serve, enable, or remove plugins.';
|
||||
}
|
||||
|
||||
if (routePath.startsWith('/api/agent')) {
|
||||
return 'Accept external agent jobs that run a provider against a local or cloned project.';
|
||||
}
|
||||
|
||||
return `${verb} ${routePath} for backend runtime support.`;
|
||||
}
|
||||
|
||||
function describeSuccessShape(block, transport) {
|
||||
if (transport === 'sse' || block.includes('text/event-stream')) {
|
||||
return 'Server-sent events stream with progress/result/error events.';
|
||||
}
|
||||
|
||||
if (block.includes('res.sendFile')) {
|
||||
return 'Static file or HTML response.';
|
||||
}
|
||||
|
||||
if (block.includes('res.redirect')) {
|
||||
return 'HTTP redirect response.';
|
||||
}
|
||||
|
||||
if (block.includes('res.json({ success: true')) {
|
||||
return 'JSON object with an explicit success flag and payload.';
|
||||
}
|
||||
|
||||
if (block.includes('res.json({')) {
|
||||
return 'Structured JSON object response.';
|
||||
}
|
||||
|
||||
if (block.includes('res.json(')) {
|
||||
return 'JSON payload returned directly from service logic.';
|
||||
}
|
||||
|
||||
return 'Mixed response shape; inspect handler during refactor.';
|
||||
}
|
||||
|
||||
function describeErrorShape(block, transport) {
|
||||
if (transport === 'sse' || block.includes('text/event-stream')) {
|
||||
return 'Streamed error event or JSON error fallback.';
|
||||
}
|
||||
|
||||
if (block.includes("res.status(500).json({ error:")) {
|
||||
return 'JSON object with error message and optional details.';
|
||||
}
|
||||
|
||||
if (block.includes("res.status(400).json({ error:")) {
|
||||
return 'JSON validation error response.';
|
||||
}
|
||||
|
||||
if (block.includes('res.status(')) {
|
||||
return 'JSON error response with HTTP status code.';
|
||||
}
|
||||
|
||||
return 'Handler-specific error behavior.';
|
||||
}
|
||||
|
||||
function describeSideEffects(method, routePath) {
|
||||
const effects = [];
|
||||
|
||||
if (method !== 'get') {
|
||||
effects.push('Mutates backend or external state.');
|
||||
}
|
||||
|
||||
if (routePath.includes('/git')) effects.push('Touches git repositories or local git config.');
|
||||
if (routePath.includes('/projects') || routePath.includes('/file') || routePath.includes('/files')) {
|
||||
effects.push('Touches local workspace files or directories.');
|
||||
}
|
||||
if (routePath.includes('/agent')) effects.push('Invokes external AI providers and may modify project files.');
|
||||
if (routePath.includes('/taskmaster')) effects.push('Reads or writes TaskMaster project assets.');
|
||||
if (routePath.includes('/plugins')) effects.push('Installs, updates, or serves plugin assets/processes.');
|
||||
if (routePath.includes('/settings') || routePath.includes('/auth') || routePath.includes('/credentials')) {
|
||||
effects.push('Reads or writes local authentication or credential state.');
|
||||
}
|
||||
if (routePath.includes('/mcp')) effects.push('Reads or writes MCP CLI configuration.');
|
||||
if (routePath.includes('/transcribe')) effects.push('Processes uploaded files and external model responses.');
|
||||
|
||||
return effects.length > 0 ? effects : ['Read-only backend query.'];
|
||||
}
|
||||
|
||||
function collectFrontendConsumers(routePath, clientFiles) {
|
||||
const tokens = getStaticSearchTokens(routePath);
|
||||
const consumers = new Set();
|
||||
|
||||
for (const file of clientFiles) {
|
||||
const content = readText(file);
|
||||
if (tokens.some(token => token && content.includes(token))) {
|
||||
consumers.add(toPosix(path.relative(projectRoot, file)));
|
||||
}
|
||||
}
|
||||
|
||||
return [...consumers].sort();
|
||||
}
|
||||
|
||||
function detectTransport(block) {
|
||||
if (block.includes('text/event-stream')) {
|
||||
return 'sse';
|
||||
}
|
||||
|
||||
return 'http';
|
||||
}
|
||||
|
||||
function parseMounts(runtimeContent) {
|
||||
const routeImports = new Map();
|
||||
|
||||
for (const match of runtimeContent.matchAll(defaultImportPattern)) {
|
||||
if (match[2].includes('/routes/')) {
|
||||
routeImports.set(match[1], match[2]);
|
||||
}
|
||||
}
|
||||
|
||||
const mounts = new Map();
|
||||
const mountPattern = /app\.use\(\s*(['"`])([^'"`]+)\1\s*,\s*([^)]+?)\);/g;
|
||||
|
||||
for (const match of runtimeContent.matchAll(mountPattern)) {
|
||||
const basePath = match[2];
|
||||
const args = splitArgs(match[3]);
|
||||
const routeVariable = args.at(-1);
|
||||
if (!routeVariable || !routeImports.has(routeVariable)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
mounts.set(routeVariable, {
|
||||
basePath,
|
||||
routeImport: routeImports.get(routeVariable),
|
||||
authMode: args.includes('authenticateToken')
|
||||
? 'bearer_token'
|
||||
: args.includes('validateExternalApiKey')
|
||||
? 'api_key_or_platform'
|
||||
: 'public_or_optional_api_key',
|
||||
});
|
||||
}
|
||||
|
||||
return mounts;
|
||||
}
|
||||
|
||||
function parseRoutes(filePath, fullPathPrefix, authMode, clientFiles) {
|
||||
const content = readText(filePath);
|
||||
const matches = [...content.matchAll(routeDefinitionPattern)];
|
||||
const routes = [];
|
||||
|
||||
for (let index = 0; index < matches.length; index += 1) {
|
||||
const match = matches[index];
|
||||
const nextMatch = matches[index + 1];
|
||||
const routeMethod = match[2].toUpperCase();
|
||||
const routePath = match[4];
|
||||
const startIndex = match.index ?? 0;
|
||||
const endIndex = nextMatch?.index ?? content.length;
|
||||
const block = content.slice(startIndex, endIndex);
|
||||
const declarationEnd = block.indexOf('=>');
|
||||
const declarationSnippet = declarationEnd === -1 ? block : block.slice(0, declarationEnd);
|
||||
const fullPath = fullPathPrefix
|
||||
? normalizeJoinedPath(fullPathPrefix, routePath)
|
||||
: routePath;
|
||||
const transport = detectTransport(block);
|
||||
const tag = classifyTag(fullPath);
|
||||
const pathParams = [...fullPath.matchAll(/:([A-Za-z0-9_]+)/g)].map(token => token[1]);
|
||||
const queryParams = collectObjectKeys(block, 'query');
|
||||
const bodyHints = collectObjectKeys(block, 'body');
|
||||
const localAuthMode =
|
||||
fullPath === '/health' ||
|
||||
fullPath === '/api/auth/status' ||
|
||||
fullPath === '/api/auth/register' ||
|
||||
fullPath === '/api/auth/login' ||
|
||||
fullPath === '*'
|
||||
? 'public'
|
||||
: declarationSnippet.includes('authenticateToken')
|
||||
? 'bearer_token'
|
||||
: declarationSnippet.includes('validateExternalApiKey')
|
||||
? 'api_key_or_platform'
|
||||
: authMode;
|
||||
|
||||
routes.push({
|
||||
transport,
|
||||
method: routeMethod,
|
||||
path: fullPath,
|
||||
tag,
|
||||
authMode: localAuthMode,
|
||||
sourceFile: toPosix(path.relative(projectRoot, filePath)),
|
||||
sourceLine: getLineNumber(content, startIndex),
|
||||
purpose: describePurpose(routeMethod, fullPath),
|
||||
consumerFiles: collectFrontendConsumers(fullPath, clientFiles),
|
||||
inputs: {
|
||||
pathParams,
|
||||
queryParams,
|
||||
bodyHints,
|
||||
},
|
||||
successShape: describeSuccessShape(block, transport),
|
||||
errorShape: describeErrorShape(block, transport),
|
||||
sideEffects: describeSideEffects(routeMethod.toLowerCase(), fullPath),
|
||||
priority: classifyPriority(tag, fullPath),
|
||||
});
|
||||
}
|
||||
|
||||
return routes;
|
||||
}
|
||||
|
||||
function parseRealtimeContracts(runtimeFile) {
|
||||
const content = readText(runtimeFile);
|
||||
const incoming = new Set();
|
||||
const outgoing = new Set();
|
||||
|
||||
for (const match of content.matchAll(incomingRealtimePattern)) {
|
||||
incoming.add(match[1]);
|
||||
}
|
||||
|
||||
const websocketSectionIndex = content.indexOf("wss.on('connection'");
|
||||
const websocketSection = websocketSectionIndex === -1 ? content : content.slice(websocketSectionIndex);
|
||||
|
||||
for (const match of websocketSection.matchAll(outgoingRealtimePattern)) {
|
||||
outgoing.add(match[1]);
|
||||
}
|
||||
|
||||
return {
|
||||
incomingMessageTypes: [...incoming].sort(),
|
||||
outgoingMessageTypes: [...outgoing].sort(),
|
||||
};
|
||||
}
|
||||
|
||||
function escapeCsv(value) {
|
||||
const stringValue = Array.isArray(value) ? value.join('; ') : String(value ?? '');
|
||||
const escaped = stringValue.replace(/"/g, '""');
|
||||
return `"${escaped}"`;
|
||||
}
|
||||
|
||||
function writeCsv(filePath, records) {
|
||||
const header = [
|
||||
'transport',
|
||||
'method',
|
||||
'path',
|
||||
'tag',
|
||||
'authMode',
|
||||
'sourceFile',
|
||||
'sourceLine',
|
||||
'purpose',
|
||||
'consumerFiles',
|
||||
'pathParams',
|
||||
'queryParams',
|
||||
'bodyHints',
|
||||
'successShape',
|
||||
'errorShape',
|
||||
'sideEffects',
|
||||
'priority',
|
||||
];
|
||||
|
||||
const rows = [
|
||||
header.join(','),
|
||||
...records.map(record => [
|
||||
record.transport,
|
||||
record.method,
|
||||
record.path,
|
||||
record.tag,
|
||||
record.authMode,
|
||||
record.sourceFile,
|
||||
record.sourceLine,
|
||||
record.purpose,
|
||||
record.consumerFiles,
|
||||
record.inputs.pathParams,
|
||||
record.inputs.queryParams,
|
||||
record.inputs.bodyHints,
|
||||
record.successShape,
|
||||
record.errorShape,
|
||||
record.sideEffects,
|
||||
record.priority,
|
||||
].map(escapeCsv).join(',')),
|
||||
];
|
||||
|
||||
fs.writeFileSync(filePath, `${rows.join('\n')}\n`);
|
||||
}
|
||||
|
||||
function writeMarkdown(filePath, summary, records, realtimeContracts) {
|
||||
const grouped = new Map();
|
||||
|
||||
for (const record of records) {
|
||||
if (!grouped.has(record.tag)) {
|
||||
grouped.set(record.tag, []);
|
||||
}
|
||||
|
||||
grouped.get(record.tag).push(record);
|
||||
}
|
||||
|
||||
const lines = [
|
||||
'# Backend Inventory',
|
||||
'',
|
||||
`Generated on ${summary.generatedAt}.`,
|
||||
'',
|
||||
'## Summary',
|
||||
'',
|
||||
`- HTTP routes: ${summary.httpRoutes}`,
|
||||
`- SSE routes: ${summary.sseRoutes}`,
|
||||
`- Modular routes: ${summary.modularRoutes}`,
|
||||
`- Inline routes: ${summary.inlineRoutes}`,
|
||||
`- Route files scanned: ${summary.routeFilesScanned}`,
|
||||
'',
|
||||
'## Realtime Contracts',
|
||||
'',
|
||||
`- Incoming websocket message types (${realtimeContracts.incomingMessageTypes.length}): ${realtimeContracts.incomingMessageTypes.join(', ')}`,
|
||||
`- Outgoing websocket message types (${realtimeContracts.outgoingMessageTypes.length}): ${realtimeContracts.outgoingMessageTypes.join(', ')}`,
|
||||
'',
|
||||
];
|
||||
|
||||
for (const [tag, tagRecords] of [...grouped.entries()].sort(([left], [right]) => left.localeCompare(right))) {
|
||||
lines.push(`## ${tag}`);
|
||||
lines.push('');
|
||||
lines.push('| Method | Path | Auth | Purpose | Consumers | Source |');
|
||||
lines.push('| --- | --- | --- | --- | --- | --- |');
|
||||
|
||||
for (const record of tagRecords.sort((left, right) => left.path.localeCompare(right.path))) {
|
||||
lines.push(
|
||||
`| ${record.method} | \`${record.path}\` | ${record.authMode} | ${record.purpose} | ${record.consumerFiles.join('<br>') || '-'} | ${record.sourceFile}:${record.sourceLine} |`
|
||||
);
|
||||
}
|
||||
|
||||
lines.push('');
|
||||
}
|
||||
|
||||
fs.writeFileSync(filePath, `${lines.join('\n')}\n`);
|
||||
}
|
||||
|
||||
const clientFiles = walkFiles(clientRoot).filter(filePath => /\.(js|jsx|ts|tsx)$/.test(filePath));
|
||||
const legacyRuntimePath = path.join(serverRoot, 'index.js');
|
||||
const runtimeContent = readText(legacyRuntimePath);
|
||||
const mounts = parseMounts(runtimeContent);
|
||||
const records = [];
|
||||
|
||||
records.push(...parseRoutes(legacyRuntimePath, '', 'mixed_or_inline', clientFiles));
|
||||
|
||||
for (const [routeVariable, mount] of mounts.entries()) {
|
||||
const relativeImport = mount.routeImport.replace('./', '');
|
||||
const routeFilePath = path.join(serverRoot, relativeImport);
|
||||
records.push(...parseRoutes(routeFilePath, mount.basePath, mount.authMode, clientFiles));
|
||||
}
|
||||
|
||||
const realtimeContracts = parseRealtimeContracts(legacyRuntimePath);
|
||||
const summary = {
|
||||
generatedAt: new Date().toISOString(),
|
||||
httpRoutes: records.filter(record => record.transport === 'http').length,
|
||||
sseRoutes: records.filter(record => record.transport === 'sse').length,
|
||||
modularRoutes: records.filter(record => record.sourceFile.includes('/routes/')).length,
|
||||
inlineRoutes: records.filter(record => record.sourceFile === 'server/index.js').length,
|
||||
routeFilesScanned: new Set(records.map(record => record.sourceFile)).size,
|
||||
};
|
||||
|
||||
fs.writeFileSync(
|
||||
path.join(docsRoot, 'endpoint-inventory.json'),
|
||||
JSON.stringify({ summary, realtimeContracts, records }, null, 2)
|
||||
);
|
||||
|
||||
writeCsv(path.join(docsRoot, 'endpoint-inventory.csv'), records);
|
||||
writeMarkdown(path.join(docsRoot, 'endpoint-inventory.md'), summary, records, realtimeContracts);
|
||||
|
||||
console.log('[inventory] Generated docs/backend/endpoint-inventory.{json,csv,md}');
|
||||
console.log(
|
||||
`[inventory] HTTP=${summary.httpRoutes} SSE=${summary.sseRoutes} Modular=${summary.modularRoutes} Inline=${summary.inlineRoutes}`
|
||||
);
|
||||
@@ -274,46 +274,6 @@ function transformMessage(sdkMessage) {
|
||||
return sdkMessage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extracts token usage from SDK result messages
|
||||
* @param {Object} resultMessage - SDK result message
|
||||
* @returns {Object|null} Token budget object or null
|
||||
*/
|
||||
function extractTokenBudget(resultMessage) {
|
||||
if (resultMessage.type !== 'result' || !resultMessage.modelUsage) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Get the first model's usage data
|
||||
const modelKey = Object.keys(resultMessage.modelUsage)[0];
|
||||
const modelData = resultMessage.modelUsage[modelKey];
|
||||
|
||||
if (!modelData) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Use cumulative tokens if available (tracks total for the session)
|
||||
// Otherwise fall back to per-request tokens
|
||||
const inputTokens = modelData.cumulativeInputTokens || modelData.inputTokens || 0;
|
||||
const outputTokens = modelData.cumulativeOutputTokens || modelData.outputTokens || 0;
|
||||
const cacheReadTokens = modelData.cumulativeCacheReadInputTokens || modelData.cacheReadInputTokens || 0;
|
||||
const cacheCreationTokens = modelData.cumulativeCacheCreationInputTokens || modelData.cacheCreationInputTokens || 0;
|
||||
|
||||
// Total used = input + output + cache tokens
|
||||
const totalUsed = inputTokens + outputTokens + cacheReadTokens + cacheCreationTokens;
|
||||
|
||||
// Use configured context window budget from environment (default 160000)
|
||||
// This is the user's budget limit, not the model's context window
|
||||
const contextWindow = parseInt(process.env.CONTEXT_WINDOW) || 160000;
|
||||
|
||||
// Token calc logged via token-budget WS event
|
||||
|
||||
return {
|
||||
used: totalUsed,
|
||||
total: contextWindow
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles image processing for SDK queries
|
||||
* Saves base64 images to temporary files and returns modified prompt with file paths
|
||||
@@ -657,18 +617,6 @@ async function queryClaudeSDK(command, options = {}, ws) {
|
||||
}
|
||||
ws.send(msg);
|
||||
}
|
||||
|
||||
// Extract and send token budget updates from result messages
|
||||
if (message.type === 'result') {
|
||||
const models = Object.keys(message.modelUsage || {});
|
||||
if (models.length > 0) {
|
||||
// Model info available in result message
|
||||
}
|
||||
const tokenBudgetData = extractTokenBudget(message);
|
||||
if (tokenBudgetData) {
|
||||
ws.send(createNormalizedMessage({ kind: 'status', text: 'token_budget', tokenBudget: tokenBudgetData, sessionId: capturedSessionId || sessionId || null, provider: 'claude' }));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Clean up session on completion
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#!/usr/bin/env node
|
||||
/**
|
||||
* Claude Code UI CLI
|
||||
* CloudCLI CLI
|
||||
*
|
||||
* Provides command-line utilities for managing Claude Code UI
|
||||
* Provides command-line utilities for managing CloudCLI
|
||||
*
|
||||
* Commands:
|
||||
* (no args) - Start the server (default)
|
||||
@@ -84,7 +84,7 @@ function getInstallDir() {
|
||||
|
||||
// Show status command
|
||||
function showStatus() {
|
||||
console.log(`\n${c.bright('Claude Code UI - Status')}\n`);
|
||||
console.log(`\n${c.bright('CloudCLI UI - Status')}\n`);
|
||||
console.log(c.dim('═'.repeat(60)));
|
||||
|
||||
// Version info
|
||||
@@ -141,7 +141,7 @@ function showStatus() {
|
||||
function showHelp() {
|
||||
console.log(`
|
||||
╔═══════════════════════════════════════════════════════════════╗
|
||||
║ Claude Code UI - Command Line Tool ║
|
||||
║ CloudCLI - Command Line Tool ║
|
||||
╚═══════════════════════════════════════════════════════════════╝
|
||||
|
||||
Usage:
|
||||
@@ -149,7 +149,7 @@ Usage:
|
||||
cloudcli [command] [options]
|
||||
|
||||
Commands:
|
||||
start Start the Claude Code UI server (default)
|
||||
start Start the CloudCLI server (default)
|
||||
status Show configuration and data locations
|
||||
update Update to the latest version
|
||||
help Show this help information
|
||||
@@ -203,7 +203,7 @@ function isNewerVersion(v1, v2) {
|
||||
async function checkForUpdates(silent = false) {
|
||||
try {
|
||||
const { execSync } = await import('child_process');
|
||||
const latestVersion = execSync('npm show @siteboon/claude-code-ui version', { encoding: 'utf8' }).trim();
|
||||
const latestVersion = execSync('npm show @cloudcli-ai/cloudcli version', { encoding: 'utf8' }).trim();
|
||||
const currentVersion = packageJson.version;
|
||||
|
||||
if (isNewerVersion(latestVersion, currentVersion)) {
|
||||
@@ -236,11 +236,11 @@ async function updatePackage() {
|
||||
}
|
||||
|
||||
console.log(`${c.info('[INFO]')} Updating from ${currentVersion} to ${latestVersion}...`);
|
||||
execSync('npm update -g @siteboon/claude-code-ui', { stdio: 'inherit' });
|
||||
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 @siteboon/claude-code-ui`);
|
||||
console.log(`${c.tip('[TIP]')} Try running manually: npm update -g @cloudcli-ai/cloudcli`);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
200
server/index.js
200
server/index.js
@@ -438,7 +438,7 @@ app.post('/api/system/update', authenticateToken, async (req, res) => {
|
||||
// Run the update command based on install mode
|
||||
const updateCommand = installMode === 'git'
|
||||
? 'git checkout main && git pull && npm install'
|
||||
: 'npm install -g @siteboon/claude-code-ui@latest';
|
||||
: 'npm install -g @cloudcli-ai/cloudcli@latest';
|
||||
|
||||
const child = spawn('sh', ['-c', updateCommand], {
|
||||
cwd: installMode === 'git' ? projectRoot : os.homedir(),
|
||||
@@ -812,7 +812,7 @@ app.get('/api/projects/:projectName/file', authenticateToken, async (req, res) =
|
||||
}
|
||||
});
|
||||
|
||||
// Serve binary file content endpoint (for images, etc.)
|
||||
// Serve raw file bytes for previews and downloads.
|
||||
app.get('/api/projects/:projectName/files/content', authenticateToken, async (req, res) => {
|
||||
try {
|
||||
const { projectName } = req.params;
|
||||
@@ -829,7 +829,11 @@ app.get('/api/projects/:projectName/files/content', authenticateToken, async (re
|
||||
return res.status(404).json({ error: 'Project not found' });
|
||||
}
|
||||
|
||||
const resolved = path.resolve(filePath);
|
||||
// Match the text reader endpoint so callers can pass either project-relative
|
||||
// or absolute paths without changing how the bytes are served.
|
||||
const resolved = path.isAbsolute(filePath)
|
||||
? path.resolve(filePath)
|
||||
: path.resolve(projectRoot, filePath);
|
||||
const normalizedRoot = path.resolve(projectRoot) + path.sep;
|
||||
if (!resolved.startsWith(normalizedRoot)) {
|
||||
return res.status(403).json({ error: 'Path must be under project root' });
|
||||
@@ -2214,194 +2218,6 @@ app.post('/api/projects/:projectName/upload-images', authenticateToken, async (r
|
||||
}
|
||||
});
|
||||
|
||||
// Get token usage for a specific session
|
||||
app.get('/api/projects/:projectName/sessions/:sessionId/token-usage', authenticateToken, async (req, res) => {
|
||||
try {
|
||||
const { projectName, sessionId } = req.params;
|
||||
const { provider = 'claude' } = req.query;
|
||||
const homeDir = os.homedir();
|
||||
|
||||
// Allow only safe characters in sessionId
|
||||
const safeSessionId = String(sessionId).replace(/[^a-zA-Z0-9._-]/g, '');
|
||||
if (!safeSessionId || safeSessionId !== String(sessionId)) {
|
||||
return res.status(400).json({ error: 'Invalid sessionId' });
|
||||
}
|
||||
|
||||
// Handle Cursor sessions - they use SQLite and don't have token usage info
|
||||
if (provider === 'cursor') {
|
||||
return res.json({
|
||||
used: 0,
|
||||
total: 0,
|
||||
breakdown: { input: 0, cacheCreation: 0, cacheRead: 0 },
|
||||
unsupported: true,
|
||||
message: 'Token usage tracking not available for Cursor sessions'
|
||||
});
|
||||
}
|
||||
|
||||
// Handle Gemini sessions - they are raw logs in our current setup
|
||||
if (provider === 'gemini') {
|
||||
return res.json({
|
||||
used: 0,
|
||||
total: 0,
|
||||
breakdown: { input: 0, cacheCreation: 0, cacheRead: 0 },
|
||||
unsupported: true,
|
||||
message: 'Token usage tracking not available for Gemini sessions'
|
||||
});
|
||||
}
|
||||
|
||||
// Handle Codex sessions
|
||||
if (provider === 'codex') {
|
||||
const codexSessionsDir = path.join(homeDir, '.codex', 'sessions');
|
||||
|
||||
// Find the session file by searching for the session ID
|
||||
const findSessionFile = async (dir) => {
|
||||
try {
|
||||
const entries = await fsPromises.readdir(dir, { withFileTypes: true });
|
||||
for (const entry of entries) {
|
||||
const fullPath = path.join(dir, entry.name);
|
||||
if (entry.isDirectory()) {
|
||||
const found = await findSessionFile(fullPath);
|
||||
if (found) return found;
|
||||
} else if (entry.name.includes(safeSessionId) && entry.name.endsWith('.jsonl')) {
|
||||
return fullPath;
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
// Skip directories we can't read
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
const sessionFilePath = await findSessionFile(codexSessionsDir);
|
||||
|
||||
if (!sessionFilePath) {
|
||||
return res.status(404).json({ error: 'Codex session file not found', sessionId: safeSessionId });
|
||||
}
|
||||
|
||||
// Read and parse the Codex JSONL file
|
||||
let fileContent;
|
||||
try {
|
||||
fileContent = await fsPromises.readFile(sessionFilePath, 'utf8');
|
||||
} catch (error) {
|
||||
if (error.code === 'ENOENT') {
|
||||
return res.status(404).json({ error: 'Session file not found', path: sessionFilePath });
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
const lines = fileContent.trim().split('\n');
|
||||
let totalTokens = 0;
|
||||
let contextWindow = 200000; // Default for Codex/OpenAI
|
||||
|
||||
// Find the latest token_count event with info (scan from end)
|
||||
for (let i = lines.length - 1; i >= 0; i--) {
|
||||
try {
|
||||
const entry = JSON.parse(lines[i]);
|
||||
|
||||
// Codex stores token info in event_msg with type: "token_count"
|
||||
if (entry.type === 'event_msg' && entry.payload?.type === 'token_count' && entry.payload?.info) {
|
||||
const tokenInfo = entry.payload.info;
|
||||
if (tokenInfo.total_token_usage) {
|
||||
totalTokens = tokenInfo.total_token_usage.total_tokens || 0;
|
||||
}
|
||||
if (tokenInfo.model_context_window) {
|
||||
contextWindow = tokenInfo.model_context_window;
|
||||
}
|
||||
break; // Stop after finding the latest token count
|
||||
}
|
||||
} catch (parseError) {
|
||||
// Skip lines that can't be parsed
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
return res.json({
|
||||
used: totalTokens,
|
||||
total: contextWindow
|
||||
});
|
||||
}
|
||||
|
||||
// Handle Claude sessions (default)
|
||||
// Extract actual project path
|
||||
let projectPath;
|
||||
try {
|
||||
projectPath = await extractProjectDirectory(projectName);
|
||||
} catch (error) {
|
||||
console.error('Error extracting project directory:', error);
|
||||
return res.status(500).json({ error: 'Failed to determine project path' });
|
||||
}
|
||||
|
||||
// Construct the JSONL file path
|
||||
// Claude stores session files in ~/.claude/projects/[encoded-project-path]/[session-id].jsonl
|
||||
// The encoding replaces any non-alphanumeric character (except -) with -
|
||||
const encodedPath = projectPath.replace(/[^a-zA-Z0-9-]/g, '-');
|
||||
const projectDir = path.join(homeDir, '.claude', 'projects', encodedPath);
|
||||
|
||||
const jsonlPath = path.join(projectDir, `${safeSessionId}.jsonl`);
|
||||
|
||||
// Constrain to projectDir
|
||||
const rel = path.relative(path.resolve(projectDir), path.resolve(jsonlPath));
|
||||
if (rel.startsWith('..') || path.isAbsolute(rel)) {
|
||||
return res.status(400).json({ error: 'Invalid path' });
|
||||
}
|
||||
|
||||
// Read and parse the JSONL file
|
||||
let fileContent;
|
||||
try {
|
||||
fileContent = await fsPromises.readFile(jsonlPath, 'utf8');
|
||||
} catch (error) {
|
||||
if (error.code === 'ENOENT') {
|
||||
return res.status(404).json({ error: 'Session file not found', path: jsonlPath });
|
||||
}
|
||||
throw error; // Re-throw other errors to be caught by outer try-catch
|
||||
}
|
||||
const lines = fileContent.trim().split('\n');
|
||||
|
||||
const parsedContextWindow = parseInt(process.env.CONTEXT_WINDOW, 10);
|
||||
const contextWindow = Number.isFinite(parsedContextWindow) ? parsedContextWindow : 160000;
|
||||
let inputTokens = 0;
|
||||
let cacheCreationTokens = 0;
|
||||
let cacheReadTokens = 0;
|
||||
|
||||
// Find the latest assistant message with usage data (scan from end)
|
||||
for (let i = lines.length - 1; i >= 0; i--) {
|
||||
try {
|
||||
const entry = JSON.parse(lines[i]);
|
||||
|
||||
// Only count assistant messages which have usage data
|
||||
if (entry.type === 'assistant' && entry.message?.usage) {
|
||||
const usage = entry.message.usage;
|
||||
|
||||
// Use token counts from latest assistant message only
|
||||
inputTokens = usage.input_tokens || 0;
|
||||
cacheCreationTokens = usage.cache_creation_input_tokens || 0;
|
||||
cacheReadTokens = usage.cache_read_input_tokens || 0;
|
||||
|
||||
break; // Stop after finding the latest assistant message
|
||||
}
|
||||
} catch (parseError) {
|
||||
// Skip lines that can't be parsed
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// Calculate total context usage (excluding output_tokens, as per ccusage)
|
||||
const totalUsed = inputTokens + cacheCreationTokens + cacheReadTokens;
|
||||
|
||||
res.json({
|
||||
used: totalUsed,
|
||||
total: contextWindow,
|
||||
breakdown: {
|
||||
input: inputTokens,
|
||||
cacheCreation: cacheCreationTokens,
|
||||
cacheRead: cacheReadTokens
|
||||
}
|
||||
});
|
||||
} catch (error) {
|
||||
console.error('Error reading session token usage:', error);
|
||||
res.status(500).json({ error: 'Failed to read session token usage' });
|
||||
}
|
||||
});
|
||||
|
||||
// Serve React app for all other routes (excluding static files)
|
||||
app.get('*', (req, res) => {
|
||||
// Skip requests for static assets (files with extensions)
|
||||
@@ -2544,7 +2360,7 @@ async function startServer() {
|
||||
|
||||
console.log('');
|
||||
console.log(c.dim('═'.repeat(63)));
|
||||
console.log(` ${c.bright('Claude Code UI Server - Ready')}`);
|
||||
console.log(` ${c.bright('CloudCLI Server - Ready')}`);
|
||||
console.log(c.dim('═'.repeat(63)));
|
||||
console.log('');
|
||||
console.log(`${c.info('[INFO]')} Server URL: ${c.bright('http://' + DISPLAY_HOST + ':' + SERVER_PORT)}`);
|
||||
|
||||
@@ -129,8 +129,7 @@ function transformCodexEvent(event) {
|
||||
|
||||
case 'turn.completed':
|
||||
return {
|
||||
type: 'turn_complete',
|
||||
usage: event.usage
|
||||
type: 'turn_complete'
|
||||
};
|
||||
|
||||
case 'turn.failed':
|
||||
@@ -279,12 +278,6 @@ export async function queryCodex(command, options = {}, ws) {
|
||||
error: terminalFailure
|
||||
});
|
||||
}
|
||||
|
||||
// Extract and send token usage if available (normalized to match Claude format)
|
||||
if (event.type === 'turn.completed' && event.usage) {
|
||||
const totalTokens = (event.usage.input_tokens || 0) + (event.usage.output_tokens || 0);
|
||||
sendMessage(ws, createNormalizedMessage({ kind: 'status', text: 'token_budget', tokenBudget: { used: totalTokens, total: 200000 }, sessionId: currentSessionId, provider: 'codex' }));
|
||||
}
|
||||
}
|
||||
|
||||
// Send completion event
|
||||
|
||||
@@ -1618,7 +1618,6 @@ async function getCodexSessionMessages(sessionId, limit = null, offset = 0) {
|
||||
}
|
||||
|
||||
const messages = [];
|
||||
let tokenUsage = null;
|
||||
const fileStream = fsSync.createReadStream(sessionFilePath);
|
||||
const rl = readline.createInterface({
|
||||
input: fileStream,
|
||||
@@ -1647,17 +1646,6 @@ async function getCodexSessionMessages(sessionId, limit = null, offset = 0) {
|
||||
try {
|
||||
const entry = JSON.parse(line);
|
||||
|
||||
// Extract token usage from token_count events (keep latest)
|
||||
if (entry.type === 'event_msg' && entry.payload?.type === 'token_count' && entry.payload?.info) {
|
||||
const info = entry.payload.info;
|
||||
if (info.total_token_usage) {
|
||||
tokenUsage = {
|
||||
used: info.total_token_usage.total_tokens || 0,
|
||||
total: info.model_context_window || 200000
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
// Use event_msg.user_message for user-visible inputs.
|
||||
if (entry.type === 'event_msg' && isVisibleCodexUserMessage(entry.payload)) {
|
||||
messages.push({
|
||||
@@ -1820,11 +1808,10 @@ async function getCodexSessionMessages(sessionId, limit = null, offset = 0) {
|
||||
hasMore,
|
||||
offset,
|
||||
limit,
|
||||
tokenUsage
|
||||
};
|
||||
}
|
||||
|
||||
return { messages, tokenUsage };
|
||||
return { messages };
|
||||
|
||||
} catch (error) {
|
||||
console.error(`Error reading Codex session messages for ${sessionId}:`, error);
|
||||
|
||||
@@ -214,7 +214,6 @@ export const codexAdapter = {
|
||||
const rawMessages = Array.isArray(result) ? result : (result.messages || []);
|
||||
const total = Array.isArray(result) ? rawMessages.length : (result.total || 0);
|
||||
const hasMore = Array.isArray(result) ? false : Boolean(result.hasMore);
|
||||
const tokenUsage = result.tokenUsage || null;
|
||||
|
||||
const normalized = [];
|
||||
for (const raw of rawMessages) {
|
||||
@@ -242,7 +241,6 @@ export const codexAdapter = {
|
||||
hasMore,
|
||||
offset,
|
||||
limit,
|
||||
tokenUsage,
|
||||
};
|
||||
},
|
||||
};
|
||||
|
||||
@@ -53,14 +53,7 @@ export function normalizeMessage(raw, sessionId) {
|
||||
}
|
||||
|
||||
if (raw.type === 'result') {
|
||||
const msgs = [createNormalizedMessage({ sessionId, timestamp: ts, provider: PROVIDER, kind: 'stream_end' })];
|
||||
if (raw.stats?.total_tokens) {
|
||||
msgs.push(createNormalizedMessage({
|
||||
sessionId, timestamp: ts, provider: PROVIDER,
|
||||
kind: 'status', text: 'Complete', tokens: raw.stats.total_tokens, canInterrupt: false,
|
||||
}));
|
||||
}
|
||||
return msgs;
|
||||
return [createNormalizedMessage({ sessionId, timestamp: ts, provider: PROVIDER, kind: 'stream_end' })];
|
||||
}
|
||||
|
||||
if (raw.type === 'error') {
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
* - stream_end: (no extra fields)
|
||||
* - error: content
|
||||
* - complete: (no extra fields)
|
||||
* - status: text, tokens?, canInterrupt?
|
||||
* - status: text, canInterrupt?
|
||||
* - permission_request: requestId, toolName, input, context?
|
||||
* - permission_cancelled: requestId
|
||||
* - session_created: newSessionId
|
||||
@@ -66,7 +66,6 @@
|
||||
* @property {boolean} hasMore - Whether more messages exist before the current page
|
||||
* @property {number} offset - Current offset
|
||||
* @property {number|null} limit - Page size used
|
||||
* @property {object} [tokenUsage] - Token usage data (provider-specific)
|
||||
*/
|
||||
|
||||
// ─── Provider Adapter Interface ──────────────────────────────────────────────
|
||||
|
||||
@@ -475,6 +475,7 @@ class SSEStreamWriter {
|
||||
|
||||
setSessionId(sessionId) {
|
||||
this.sessionId = sessionId;
|
||||
this.send({ type: 'session-id', sessionId });
|
||||
}
|
||||
|
||||
getSessionId() {
|
||||
@@ -545,7 +546,12 @@ class ResponseCollector {
|
||||
const parsed = JSON.parse(msg);
|
||||
// Only include claude-response messages with assistant type
|
||||
if (parsed.type === 'claude-response' && parsed.data && parsed.data.type === 'assistant') {
|
||||
assistantMessages.push(parsed.data);
|
||||
const assistantMessage = { ...parsed.data };
|
||||
if (assistantMessage.message?.usage) {
|
||||
assistantMessage.message = { ...assistantMessage.message };
|
||||
delete assistantMessage.message.usage;
|
||||
}
|
||||
assistantMessages.push(assistantMessage);
|
||||
}
|
||||
} catch (e) {
|
||||
// Not JSON, skip
|
||||
@@ -555,49 +561,6 @@ class ResponseCollector {
|
||||
|
||||
return assistantMessages;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate total tokens from all messages
|
||||
*/
|
||||
getTotalTokens() {
|
||||
let totalInput = 0;
|
||||
let totalOutput = 0;
|
||||
let totalCacheRead = 0;
|
||||
let totalCacheCreation = 0;
|
||||
|
||||
for (const msg of this.messages) {
|
||||
let data = msg;
|
||||
|
||||
// Parse if string
|
||||
if (typeof msg === 'string') {
|
||||
try {
|
||||
data = JSON.parse(msg);
|
||||
} catch (e) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// Extract usage from claude-response messages
|
||||
if (data && data.type === 'claude-response' && data.data) {
|
||||
const msgData = data.data;
|
||||
if (msgData.message && msgData.message.usage) {
|
||||
const usage = msgData.message.usage;
|
||||
totalInput += usage.input_tokens || 0;
|
||||
totalOutput += usage.output_tokens || 0;
|
||||
totalCacheRead += usage.cache_read_input_tokens || 0;
|
||||
totalCacheCreation += usage.cache_creation_input_tokens || 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
inputTokens: totalInput,
|
||||
outputTokens: totalOutput,
|
||||
cacheReadTokens: totalCacheRead,
|
||||
cacheCreationTokens: totalCacheCreation,
|
||||
totalTokens: totalInput + totalOutput + totalCacheRead + totalCacheCreation
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
// ===============================
|
||||
@@ -788,13 +751,6 @@ class ResponseCollector {
|
||||
* success: true,
|
||||
* sessionId: "session-123",
|
||||
* messages: [...], // Assistant messages only (filtered)
|
||||
* tokens: {
|
||||
* inputTokens: 150,
|
||||
* outputTokens: 50,
|
||||
* cacheReadTokens: 0,
|
||||
* cacheCreationTokens: 0,
|
||||
* totalTokens: 200
|
||||
* },
|
||||
* projectPath: "/path/to/project",
|
||||
* branch: { // Only if createBranch=true
|
||||
* name: "feature/xyz",
|
||||
@@ -839,7 +795,7 @@ class ResponseCollector {
|
||||
* }
|
||||
*/
|
||||
router.post('/', validateExternalApiKey, async (req, res) => {
|
||||
const { githubUrl, projectPath, message, provider = 'claude', model, githubToken, branchName } = req.body;
|
||||
const { githubUrl, projectPath, message, provider = 'claude', model, githubToken, branchName, sessionId } = req.body;
|
||||
|
||||
// Parse stream and cleanup as booleans (handle string "true"/"false" from curl)
|
||||
const stream = req.body.stream === undefined ? true : (req.body.stream === true || req.body.stream === 'true');
|
||||
@@ -875,9 +831,8 @@ router.post('/', validateExternalApiKey, async (req, res) => {
|
||||
// Determine the final project path
|
||||
if (githubUrl) {
|
||||
// Clone repository (to projectPath if provided, otherwise generate path)
|
||||
// TODO: use credinitalsDB when refactoring
|
||||
const tokenToUse = githubToken || githubTokensDb.getActiveGithubToken(req.user.id);
|
||||
|
||||
|
||||
let targetPath;
|
||||
if (projectPath) {
|
||||
targetPath = projectPath;
|
||||
@@ -950,7 +905,7 @@ router.post('/', validateExternalApiKey, async (req, res) => {
|
||||
await queryClaudeSDK(message.trim(), {
|
||||
projectPath: finalProjectPath,
|
||||
cwd: finalProjectPath,
|
||||
sessionId: null, // New session
|
||||
sessionId: sessionId || null,
|
||||
model: model,
|
||||
permissionMode: 'bypassPermissions' // Bypass all permissions for API calls
|
||||
}, writer);
|
||||
@@ -961,7 +916,7 @@ router.post('/', validateExternalApiKey, async (req, res) => {
|
||||
await spawnCursor(message.trim(), {
|
||||
projectPath: finalProjectPath,
|
||||
cwd: finalProjectPath,
|
||||
sessionId: null, // New session
|
||||
sessionId: sessionId || null,
|
||||
model: model || undefined,
|
||||
skipPermissions: true // Bypass permissions for Cursor
|
||||
}, writer);
|
||||
@@ -971,7 +926,7 @@ router.post('/', validateExternalApiKey, async (req, res) => {
|
||||
await queryCodex(message.trim(), {
|
||||
projectPath: finalProjectPath,
|
||||
cwd: finalProjectPath,
|
||||
sessionId: null,
|
||||
sessionId: sessionId || null,
|
||||
model: model || CODEX_MODELS.DEFAULT,
|
||||
permissionMode: 'bypassPermissions'
|
||||
}, writer);
|
||||
@@ -981,7 +936,7 @@ router.post('/', validateExternalApiKey, async (req, res) => {
|
||||
await spawnGemini(message.trim(), {
|
||||
projectPath: finalProjectPath,
|
||||
cwd: finalProjectPath,
|
||||
sessionId: null,
|
||||
sessionId: sessionId || null,
|
||||
model: model,
|
||||
skipPermissions: true // CLI mode bypasses permissions
|
||||
}, writer);
|
||||
@@ -996,7 +951,6 @@ router.post('/', validateExternalApiKey, async (req, res) => {
|
||||
console.log('🔄 Starting GitHub branch/PR creation workflow...');
|
||||
|
||||
// Get GitHub token
|
||||
// TODO: use credinitalsDB when refactoring
|
||||
const tokenToUse = githubToken || githubTokensDb.getActiveGithubToken(req.user.id);
|
||||
|
||||
if (!tokenToUse) {
|
||||
@@ -1126,7 +1080,7 @@ router.post('/', validateExternalApiKey, async (req, res) => {
|
||||
} else {
|
||||
prBody += `Agent task: ${message}`;
|
||||
}
|
||||
prBody += '\n\n---\n*This pull request was automatically created by Claude Code UI Agent.*';
|
||||
prBody += '\n\n---\n*This pull request was automatically created by CloudCLI.ai Agent.*';
|
||||
|
||||
console.log(`📝 PR Title: ${prTitle}`);
|
||||
|
||||
@@ -1174,15 +1128,13 @@ router.post('/', validateExternalApiKey, async (req, res) => {
|
||||
// Streaming mode: end the SSE stream
|
||||
writer.end();
|
||||
} else {
|
||||
// Non-streaming mode: send filtered messages and token summary as JSON
|
||||
// Non-streaming mode: send filtered messages as JSON
|
||||
const assistantMessages = writer.getAssistantMessages();
|
||||
const tokenSummary = writer.getTotalTokens();
|
||||
|
||||
const response = {
|
||||
success: true,
|
||||
sessionId: writer.getSessionId(),
|
||||
messages: assistantMessages,
|
||||
tokens: tokenSummary,
|
||||
projectPath: finalProjectPath
|
||||
};
|
||||
|
||||
|
||||
@@ -97,12 +97,6 @@ const builtInCommands = [
|
||||
namespace: 'builtin',
|
||||
metadata: { type: 'builtin' }
|
||||
},
|
||||
{
|
||||
name: '/cost',
|
||||
description: 'Display token usage and cost information',
|
||||
namespace: 'builtin',
|
||||
metadata: { type: 'builtin' }
|
||||
},
|
||||
{
|
||||
name: '/memory',
|
||||
description: 'Open CLAUDE.md memory file for editing',
|
||||
@@ -209,86 +203,6 @@ Custom commands can be created in:
|
||||
};
|
||||
},
|
||||
|
||||
'/cost': async (args, context) => {
|
||||
const tokenUsage = context?.tokenUsage || {};
|
||||
const provider = context?.provider || 'claude';
|
||||
const model =
|
||||
context?.model ||
|
||||
(provider === 'cursor'
|
||||
? CURSOR_MODELS.DEFAULT
|
||||
: provider === 'codex'
|
||||
? CODEX_MODELS.DEFAULT
|
||||
: CLAUDE_MODELS.DEFAULT);
|
||||
|
||||
const used = Number(tokenUsage.used ?? tokenUsage.totalUsed ?? tokenUsage.total_tokens ?? 0) || 0;
|
||||
const total =
|
||||
Number(
|
||||
tokenUsage.total ??
|
||||
tokenUsage.contextWindow ??
|
||||
parseInt(process.env.CONTEXT_WINDOW || '160000', 10),
|
||||
) || 160000;
|
||||
const percentage = total > 0 ? Number(((used / total) * 100).toFixed(1)) : 0;
|
||||
|
||||
const inputTokensRaw =
|
||||
Number(
|
||||
tokenUsage.inputTokens ??
|
||||
tokenUsage.input ??
|
||||
tokenUsage.cumulativeInputTokens ??
|
||||
tokenUsage.promptTokens ??
|
||||
0,
|
||||
) || 0;
|
||||
const outputTokens =
|
||||
Number(
|
||||
tokenUsage.outputTokens ??
|
||||
tokenUsage.output ??
|
||||
tokenUsage.cumulativeOutputTokens ??
|
||||
tokenUsage.completionTokens ??
|
||||
0,
|
||||
) || 0;
|
||||
const cacheTokens =
|
||||
Number(
|
||||
tokenUsage.cacheReadTokens ??
|
||||
tokenUsage.cacheCreationTokens ??
|
||||
tokenUsage.cacheTokens ??
|
||||
tokenUsage.cachedTokens ??
|
||||
0,
|
||||
) || 0;
|
||||
|
||||
// If we only have total used tokens, treat them as input for display/estimation.
|
||||
const inputTokens =
|
||||
inputTokensRaw > 0 || outputTokens > 0 || cacheTokens > 0 ? inputTokensRaw + cacheTokens : used;
|
||||
|
||||
// Rough default rates by provider (USD / 1M tokens).
|
||||
const pricingByProvider = {
|
||||
claude: { input: 3, output: 15 },
|
||||
cursor: { input: 3, output: 15 },
|
||||
codex: { input: 1.5, output: 6 },
|
||||
};
|
||||
const rates = pricingByProvider[provider] || pricingByProvider.claude;
|
||||
|
||||
const inputCost = (inputTokens / 1_000_000) * rates.input;
|
||||
const outputCost = (outputTokens / 1_000_000) * rates.output;
|
||||
const totalCost = inputCost + outputCost;
|
||||
|
||||
return {
|
||||
type: 'builtin',
|
||||
action: 'cost',
|
||||
data: {
|
||||
tokenUsage: {
|
||||
used,
|
||||
total,
|
||||
percentage,
|
||||
},
|
||||
cost: {
|
||||
input: inputCost.toFixed(4),
|
||||
output: outputCost.toFixed(4),
|
||||
total: totalCost.toFixed(4),
|
||||
},
|
||||
model,
|
||||
},
|
||||
};
|
||||
},
|
||||
|
||||
'/status': async (args, context) => {
|
||||
// Read version from package.json
|
||||
const packageJsonPath = path.join(path.dirname(__dirname), '..', 'package.json');
|
||||
|
||||
@@ -125,7 +125,7 @@ function buildPushBody(event) {
|
||||
const message = CODE_MAP[event.code] || 'You have a new notification';
|
||||
|
||||
return {
|
||||
title: sessionName || 'Claude Code UI',
|
||||
title: sessionName || 'CloudCLI',
|
||||
body: `${providerLabel}: ${message}`,
|
||||
data: {
|
||||
sessionId: event.sessionId || null,
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
import './config/load-env-vars.js';
|
||||
|
||||
import { pathToFileURL } from 'url';
|
||||
|
||||
import { getRuntimePaths } from '@/config/runtime.js';
|
||||
import type { ServerApplication } from '@/shared/types/app.js';
|
||||
import { logger } from '@/shared/utils/logger.js';
|
||||
|
||||
export function createServerApplication(): ServerApplication {
|
||||
const runtimePaths = getRuntimePaths();
|
||||
|
||||
return {
|
||||
runtimePaths,
|
||||
start: async () => {
|
||||
// ----------------------------------------------
|
||||
// Legacy backend Runner
|
||||
// logger.info('Bootstrapping backend via legacy runtime bridge', {
|
||||
// legacyRuntime: runtimePaths.legacyRuntimePath,
|
||||
// });
|
||||
// await import(pathToFileURL(runtimePaths.legacyRuntimePath).href);
|
||||
// ----------------------------------------------
|
||||
|
||||
|
||||
// ----------------------------------------------
|
||||
// Refactor backend Runner
|
||||
logger.info('Bootstrapping backend via refactor runtime', {
|
||||
refactorRuntime: runtimePaths.refactorRuntimePath,
|
||||
});
|
||||
await import(pathToFileURL(runtimePaths.refactorRuntimePath).href);
|
||||
},
|
||||
};
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
import { createServerApplication } from '@/app.js';
|
||||
|
||||
async function startServerApplication(): Promise<void> {
|
||||
const application = createServerApplication();
|
||||
await application.start();
|
||||
}
|
||||
|
||||
await startServerApplication();
|
||||
@@ -1,5 +0,0 @@
|
||||
/**
|
||||
* 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,30 +0,0 @@
|
||||
// Load environment variables from .env before other imports execute.
|
||||
import fs from 'fs';
|
||||
import os from 'os';
|
||||
import path from 'path';
|
||||
import { fileURLToPath } from 'url';
|
||||
import { dirname } from 'path';
|
||||
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = dirname(__filename);
|
||||
|
||||
try {
|
||||
const envPath = path.join(__dirname, '../../../.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: any) {
|
||||
console.log('No .env file found or error reading it:', e.message);
|
||||
}
|
||||
|
||||
// Set a default DATABASE_PATH if not already set by .env to ~/.cloudcli/auth.db
|
||||
if (!process.env.DATABASE_PATH) {
|
||||
process.env.DATABASE_PATH = path.join(os.homedir(), '.cloudcli', 'auth.db');
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
import path from 'path';
|
||||
import { fileURLToPath } from 'url';
|
||||
|
||||
import type { RuntimePaths } from '@/shared/types/app.js';
|
||||
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = path.dirname(__filename);
|
||||
|
||||
const RUN_REFACTOR_WITH_SRC = true;
|
||||
|
||||
export function getRuntimePaths(): RuntimePaths {
|
||||
const serverSrcDir = path.resolve(__dirname, '..');
|
||||
const serverDir = path.resolve(serverSrcDir, '..');
|
||||
const refactorRuntimePath =
|
||||
RUN_REFACTOR_WITH_SRC
|
||||
? path.join(serverDir, 'src', 'runner.ts')
|
||||
: path.join(serverDir, 'dist', 'runner.js');
|
||||
|
||||
return {
|
||||
serverSrcDir,
|
||||
serverDir,
|
||||
projectRoot: path.resolve(serverDir, '..'),
|
||||
legacyRuntimePath: path.join(serverDir, 'index.js'),
|
||||
bootstrapEntrypointPath: path.join(serverDir, 'dist', 'bootstrap.js'),
|
||||
refactorRuntimePath
|
||||
};
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,42 +0,0 @@
|
||||
import type { IProvider } from '@/modules/ai-runtime/types/index.js';
|
||||
import { ClaudeProvider } from '@/modules/ai-runtime/providers/claude/claude.provider.js';
|
||||
import { CodexProvider } from '@/modules/ai-runtime/providers/codex/codex.provider.js';
|
||||
import { CursorProvider } from '@/modules/ai-runtime/providers/cursor/cursor.provider.js';
|
||||
import { GeminiProvider } from '@/modules/ai-runtime/providers/gemini/gemini.provider.js';
|
||||
import type { LLMProvider } from '@/shared/types/app.js';
|
||||
import { AppError } from '@/shared/utils/app-error.js';
|
||||
|
||||
const providers: Record<LLMProvider, IProvider> = {
|
||||
claude: new ClaudeProvider(),
|
||||
codex: new CodexProvider(),
|
||||
cursor: new CursorProvider(),
|
||||
gemini: new GeminiProvider(),
|
||||
};
|
||||
|
||||
/**
|
||||
* Central registry for resolving provider implementations by id.
|
||||
*/
|
||||
export const llmProviderRegistry = {
|
||||
/**
|
||||
* Returns all registered providers.
|
||||
*/
|
||||
listProviders(): IProvider[] {
|
||||
return Object.values(providers);
|
||||
},
|
||||
|
||||
/**
|
||||
* Resolves one provider or throws a typed 400 error.
|
||||
*/
|
||||
resolveProvider(provider: string): IProvider {
|
||||
const key = provider as LLMProvider;
|
||||
const resolvedProvider = providers[key];
|
||||
if (!resolvedProvider) {
|
||||
throw new AppError(`Unsupported provider "${provider}".`, {
|
||||
code: 'UNSUPPORTED_PROVIDER',
|
||||
statusCode: 400,
|
||||
});
|
||||
}
|
||||
|
||||
return resolvedProvider;
|
||||
},
|
||||
};
|
||||
@@ -1,563 +0,0 @@
|
||||
import express, { type NextFunction, type Request, type Response } from 'express';
|
||||
|
||||
import { asyncHandler } from '@/shared/http/async-handler.js';
|
||||
import { AppError } from '@/shared/utils/app-error.js';
|
||||
import { createApiErrorResponse, createApiSuccessResponse } from '@/shared/http/api-response.js';
|
||||
import { llmService } from '@/modules/ai-runtime/services/ai-runtime.service.js';
|
||||
import { llmAuthService } from '@/modules/ai-runtime/services/auth.service.js';
|
||||
import { llmSessionsService } from '@/modules/ai-runtime/services/sessions.service.js';
|
||||
import { llmMcpService } from '@/modules/ai-runtime/services/mcp.service.js';
|
||||
import { llmSkillsService } from '@/modules/ai-runtime/services/skills.service.js';
|
||||
import type { McpScope, McpTransport, UpsertProviderMcpServerInput } from '@/modules/ai-runtime/types/index.js';
|
||||
import { llmMessagesUnifier } from '@/modules/ai-runtime/services/messages-unifier.service.js';
|
||||
import type { LLMProvider } from '@/shared/types/app.js';
|
||||
import { logger } from '@/shared/utils/logger.js';
|
||||
|
||||
const router = express.Router();
|
||||
|
||||
/**
|
||||
* Safely reads an Express path parameter that may arrive as string or string[].
|
||||
*/
|
||||
const readPathParam = (value: unknown, name: string): string => {
|
||||
if (typeof value === 'string') {
|
||||
return value;
|
||||
}
|
||||
|
||||
if (Array.isArray(value) && typeof value[0] === 'string') {
|
||||
return value[0];
|
||||
}
|
||||
|
||||
throw new AppError(`${name} path parameter is invalid.`, {
|
||||
code: 'INVALID_PATH_PARAMETER',
|
||||
statusCode: 400,
|
||||
});
|
||||
};
|
||||
|
||||
const normalizeProviderParam = (value: unknown): string =>
|
||||
readPathParam(value, 'provider').trim().toLowerCase();
|
||||
|
||||
/**
|
||||
* Validates and normalizes rename payload.
|
||||
*/
|
||||
const parseRenamePayload = (payload: unknown): { summary: string } => {
|
||||
if (!payload || typeof payload !== 'object') {
|
||||
throw new AppError('Request body must be an object.', {
|
||||
code: 'INVALID_REQUEST_BODY',
|
||||
statusCode: 400,
|
||||
});
|
||||
}
|
||||
|
||||
const body = payload as Record<string, unknown>;
|
||||
const summary = typeof body.summary === 'string' ? body.summary.trim() : '';
|
||||
if (!summary) {
|
||||
throw new AppError('summary is required.', {
|
||||
code: 'SUMMARY_REQUIRED',
|
||||
statusCode: 400,
|
||||
});
|
||||
}
|
||||
|
||||
if (summary.length > 500) {
|
||||
throw new AppError('summary must not exceed 500 characters.', {
|
||||
code: 'SUMMARY_TOO_LONG',
|
||||
statusCode: 400,
|
||||
});
|
||||
}
|
||||
|
||||
return { summary };
|
||||
};
|
||||
|
||||
/**
|
||||
* Reads optional query values and trims surrounding whitespace.
|
||||
*/
|
||||
const readOptionalQueryString = (value: unknown): string | undefined => {
|
||||
if (typeof value !== 'string') {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const normalized = value.trim();
|
||||
return normalized.length > 0 ? normalized : undefined;
|
||||
};
|
||||
|
||||
/**
|
||||
* Validates MCP scope query/body values.
|
||||
*/
|
||||
const parseMcpScope = (value: unknown): McpScope | undefined => {
|
||||
if (value === undefined) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const normalized = readOptionalQueryString(value);
|
||||
if (!normalized) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
if (normalized === 'user' || normalized === 'local' || normalized === 'project') {
|
||||
return normalized;
|
||||
}
|
||||
|
||||
throw new AppError(`Unsupported MCP scope "${normalized}".`, {
|
||||
code: 'INVALID_MCP_SCOPE',
|
||||
statusCode: 400,
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Validates MCP transport query/body values.
|
||||
*/
|
||||
const parseMcpTransport = (value: unknown): McpTransport => {
|
||||
const normalized = readOptionalQueryString(value);
|
||||
if (!normalized) {
|
||||
throw new AppError('transport is required.', {
|
||||
code: 'MCP_TRANSPORT_REQUIRED',
|
||||
statusCode: 400,
|
||||
});
|
||||
}
|
||||
|
||||
if (normalized === 'stdio' || normalized === 'http' || normalized === 'sse') {
|
||||
return normalized;
|
||||
}
|
||||
|
||||
throw new AppError(`Unsupported MCP transport "${normalized}".`, {
|
||||
code: 'INVALID_MCP_TRANSPORT',
|
||||
statusCode: 400,
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Parses and validates MCP upsert payload.
|
||||
*/
|
||||
const parseMcpUpsertPayload = (payload: unknown): UpsertProviderMcpServerInput => {
|
||||
if (!payload || typeof payload !== 'object') {
|
||||
throw new AppError('Request body must be an object.', {
|
||||
code: 'INVALID_REQUEST_BODY',
|
||||
statusCode: 400,
|
||||
});
|
||||
}
|
||||
|
||||
const body = payload as Record<string, unknown>;
|
||||
const name = readOptionalQueryString(body.name);
|
||||
if (!name) {
|
||||
throw new AppError('name is required.', {
|
||||
code: 'MCP_NAME_REQUIRED',
|
||||
statusCode: 400,
|
||||
});
|
||||
}
|
||||
|
||||
const transport = parseMcpTransport(body.transport);
|
||||
const scope = parseMcpScope(body.scope);
|
||||
const workspacePath = readOptionalQueryString(body.workspacePath);
|
||||
|
||||
return {
|
||||
name,
|
||||
transport,
|
||||
scope,
|
||||
workspacePath,
|
||||
command: readOptionalQueryString(body.command),
|
||||
args: Array.isArray(body.args) ? body.args.filter((entry): entry is string => typeof entry === 'string') : undefined,
|
||||
env: typeof body.env === 'object' && body.env !== null
|
||||
? Object.fromEntries(
|
||||
Object.entries(body.env as Record<string, unknown>).filter(
|
||||
(entry): entry is [string, string] => typeof entry[1] === 'string',
|
||||
),
|
||||
)
|
||||
: undefined,
|
||||
cwd: readOptionalQueryString(body.cwd),
|
||||
url: readOptionalQueryString(body.url),
|
||||
headers: typeof body.headers === 'object' && body.headers !== null
|
||||
? Object.fromEntries(
|
||||
Object.entries(body.headers as Record<string, unknown>).filter(
|
||||
(entry): entry is [string, string] => typeof entry[1] === 'string',
|
||||
),
|
||||
)
|
||||
: undefined,
|
||||
envVars: Array.isArray(body.envVars)
|
||||
? body.envVars.filter((entry): entry is string => typeof entry === 'string')
|
||||
: undefined,
|
||||
bearerTokenEnvVar: readOptionalQueryString(body.bearerTokenEnvVar),
|
||||
envHttpHeaders: typeof body.envHttpHeaders === 'object' && body.envHttpHeaders !== null
|
||||
? Object.fromEntries(
|
||||
Object.entries(body.envHttpHeaders as Record<string, unknown>).filter(
|
||||
(entry): entry is [string, string] => typeof entry[1] === 'string',
|
||||
),
|
||||
)
|
||||
: undefined,
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* Converts any provider route parameter into the strongly typed provider union.
|
||||
*/
|
||||
const parseProvider = (value: unknown): LLMProvider => {
|
||||
const normalized = normalizeProviderParam(value);
|
||||
if (normalized === 'claude' || normalized === 'codex' || normalized === 'cursor' || normalized === 'gemini') {
|
||||
return normalized;
|
||||
}
|
||||
|
||||
throw new AppError(`Unsupported provider "${normalized}".`, {
|
||||
code: 'UNSUPPORTED_PROVIDER',
|
||||
statusCode: 400,
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Enriches provider session snapshots with normalized message types for frontend rendering.
|
||||
*/
|
||||
const formatSessionSnapshot = (
|
||||
provider: LLMProvider,
|
||||
snapshot: {
|
||||
sessionId: string;
|
||||
events: Array<{
|
||||
timestamp: string;
|
||||
channel: 'sdk' | 'stdout' | 'stderr' | 'json' | 'system' | 'error';
|
||||
message?: string;
|
||||
data?: unknown;
|
||||
}>;
|
||||
},
|
||||
) => ({
|
||||
...snapshot,
|
||||
messages: llmMessagesUnifier.normalizeSessionEvents(provider, snapshot.sessionId, snapshot.events),
|
||||
});
|
||||
|
||||
router.get(
|
||||
'/providers',
|
||||
asyncHandler(async (_req: Request, res: Response) => {
|
||||
res.json(createApiSuccessResponse({ providers: llmService.listProviders() }));
|
||||
}),
|
||||
);
|
||||
|
||||
router.get(
|
||||
'/providers/:provider/models',
|
||||
asyncHandler(async (req: Request, res: Response) => {
|
||||
const provider = parseProvider(req.params.provider);
|
||||
const models = await llmService.listModels(provider);
|
||||
res.json(createApiSuccessResponse({ provider, models }));
|
||||
}),
|
||||
);
|
||||
|
||||
router.get(
|
||||
'/providers/:provider/auth/status',
|
||||
asyncHandler(async (req: Request, res: Response) => {
|
||||
const provider = parseProvider(req.params.provider);
|
||||
const auth = await llmAuthService.getProviderAuthStatus(provider);
|
||||
res.json(createApiSuccessResponse({ provider, auth }));
|
||||
}),
|
||||
);
|
||||
|
||||
router.get(
|
||||
'/providers/:provider/sessions',
|
||||
asyncHandler(async (req: Request, res: Response) => {
|
||||
const provider = parseProvider(req.params.provider);
|
||||
const sessions = llmService.listSessions(provider).map((session) => formatSessionSnapshot(provider, session));
|
||||
res.json(createApiSuccessResponse({ provider, sessions }));
|
||||
}),
|
||||
);
|
||||
|
||||
router.get(
|
||||
'/providers/:provider/sessions/:sessionId',
|
||||
asyncHandler(async (req: Request, res: Response) => {
|
||||
const provider = parseProvider(req.params.provider);
|
||||
const sessionId = readPathParam(req.params.sessionId, 'sessionId');
|
||||
const session = llmService.getSession(provider, sessionId);
|
||||
if (!session) {
|
||||
throw new AppError(`Session "${sessionId}" not found for provider "${provider}".`, {
|
||||
code: 'SESSION_NOT_FOUND',
|
||||
statusCode: 404,
|
||||
});
|
||||
}
|
||||
|
||||
res.json(createApiSuccessResponse({ provider, session: formatSessionSnapshot(provider, session) }));
|
||||
}),
|
||||
);
|
||||
|
||||
router.post(
|
||||
'/providers/:provider/sessions/start',
|
||||
asyncHandler(async (req: Request, res: Response) => {
|
||||
const provider = parseProvider(req.params.provider);
|
||||
const snapshot = await llmService.startSession(provider, req.body);
|
||||
const formattedSnapshot = formatSessionSnapshot(provider, snapshot);
|
||||
res.status(202).json(
|
||||
createApiSuccessResponse({
|
||||
provider,
|
||||
session: formattedSnapshot,
|
||||
}),
|
||||
);
|
||||
}),
|
||||
);
|
||||
|
||||
router.post(
|
||||
'/providers/:provider/sessions/:sessionId/resume',
|
||||
asyncHandler(async (req: Request, res: Response) => {
|
||||
const provider = parseProvider(req.params.provider);
|
||||
const sessionId = readPathParam(req.params.sessionId, 'sessionId');
|
||||
|
||||
const snapshot = await llmService.resumeSession(provider, sessionId, req.body);
|
||||
res.status(202).json(createApiSuccessResponse({ provider, session: formatSessionSnapshot(provider, snapshot) }));
|
||||
}),
|
||||
);
|
||||
|
||||
router.post(
|
||||
'/providers/:provider/sessions/:sessionId/stop',
|
||||
asyncHandler(async (req: Request, res: Response) => {
|
||||
const provider = parseProvider(req.params.provider);
|
||||
const sessionId = readPathParam(req.params.sessionId, 'sessionId');
|
||||
const stopped = await llmService.stopSession(provider, sessionId);
|
||||
res.json(createApiSuccessResponse({ provider, sessionId, stopped }));
|
||||
}),
|
||||
);
|
||||
|
||||
/**
|
||||
* Lists MCP servers for one provider grouped by user/local/project scopes.
|
||||
*/
|
||||
router.get(
|
||||
'/providers/:provider/mcp/servers',
|
||||
asyncHandler(async (req: Request, res: Response) => {
|
||||
const provider = parseProvider(req.params.provider);
|
||||
const workspacePath = readOptionalQueryString(req.query.workspacePath);
|
||||
const scope = parseMcpScope(req.query.scope);
|
||||
|
||||
if (scope) {
|
||||
const servers = await llmMcpService.listProviderMcpServersForScope(provider, scope, { workspacePath });
|
||||
res.json(createApiSuccessResponse({ provider, scope, servers }));
|
||||
return;
|
||||
}
|
||||
|
||||
const groupedServers = await llmMcpService.listProviderMcpServers(provider, { workspacePath });
|
||||
res.json(createApiSuccessResponse({ provider, scopes: groupedServers }));
|
||||
}),
|
||||
);
|
||||
|
||||
/**
|
||||
* Adds one MCP server for one provider and scope.
|
||||
*/
|
||||
router.post(
|
||||
'/providers/:provider/mcp/servers',
|
||||
asyncHandler(async (req: Request, res: Response) => {
|
||||
const provider = parseProvider(req.params.provider);
|
||||
const payload = parseMcpUpsertPayload(req.body);
|
||||
const server = await llmMcpService.upsertProviderMcpServer(provider, payload);
|
||||
res.status(201).json(createApiSuccessResponse({ server }));
|
||||
}),
|
||||
);
|
||||
|
||||
/**
|
||||
* Updates one provider MCP server definition.
|
||||
*/
|
||||
router.put(
|
||||
'/providers/:provider/mcp/servers/:name',
|
||||
asyncHandler(async (req: Request, res: Response) => {
|
||||
const provider = parseProvider(req.params.provider);
|
||||
const payload = parseMcpUpsertPayload({
|
||||
...((req.body && typeof req.body === 'object') ? req.body as Record<string, unknown> : {}),
|
||||
name: readPathParam(req.params.name, 'name'),
|
||||
});
|
||||
const server = await llmMcpService.upsertProviderMcpServer(provider, payload);
|
||||
res.json(createApiSuccessResponse({ server }));
|
||||
}),
|
||||
);
|
||||
|
||||
/**
|
||||
* Removes one provider MCP server from its configured scope.
|
||||
*/
|
||||
router.delete(
|
||||
'/providers/:provider/mcp/servers/:name',
|
||||
asyncHandler(async (req: Request, res: Response) => {
|
||||
const provider = parseProvider(req.params.provider);
|
||||
const scope = parseMcpScope(req.query.scope);
|
||||
const workspacePath = readOptionalQueryString(req.query.workspacePath);
|
||||
const result = await llmMcpService.removeProviderMcpServer(provider, {
|
||||
name: readPathParam(req.params.name, 'name'),
|
||||
scope,
|
||||
workspacePath,
|
||||
});
|
||||
res.json(createApiSuccessResponse(result));
|
||||
}),
|
||||
);
|
||||
|
||||
/**
|
||||
* Executes a lightweight startup/connectivity probe for one provider MCP server.
|
||||
*/
|
||||
router.post(
|
||||
'/providers/:provider/mcp/servers/:name/run',
|
||||
asyncHandler(async (req: Request, res: Response) => {
|
||||
const provider = parseProvider(req.params.provider);
|
||||
const body = (req.body as Record<string, unknown> | undefined) ?? {};
|
||||
const scope = parseMcpScope(body.scope ?? req.query.scope);
|
||||
const workspacePath = readOptionalQueryString(body.workspacePath ?? req.query.workspacePath);
|
||||
const result = await llmMcpService.runProviderMcpServer(provider, {
|
||||
name: readPathParam(req.params.name, 'name'),
|
||||
scope,
|
||||
workspacePath,
|
||||
});
|
||||
res.json(createApiSuccessResponse(result));
|
||||
}),
|
||||
);
|
||||
|
||||
/**
|
||||
* Adds one HTTP/stdio MCP server to every provider.
|
||||
*/
|
||||
router.post(
|
||||
'/mcp/servers/global',
|
||||
asyncHandler(async (req: Request, res: Response) => {
|
||||
const payload = parseMcpUpsertPayload(req.body);
|
||||
if (payload.scope === 'local') {
|
||||
throw new AppError('Global MCP add supports only "user" or "project" scopes.', {
|
||||
code: 'INVALID_GLOBAL_MCP_SCOPE',
|
||||
statusCode: 400,
|
||||
});
|
||||
}
|
||||
const results = await llmMcpService.addMcpServerToAllProviders({
|
||||
...payload,
|
||||
scope: payload.scope === 'user' ? 'user' : 'project',
|
||||
});
|
||||
res.status(201).json(createApiSuccessResponse({ results }));
|
||||
}),
|
||||
);
|
||||
|
||||
/**
|
||||
* Lists provider-specific skills from all documented skill directories.
|
||||
*/
|
||||
router.get(
|
||||
'/providers/:provider/skills',
|
||||
asyncHandler(async (req: Request, res: Response) => {
|
||||
const provider = parseProvider(req.params.provider);
|
||||
const workspacePath = readOptionalQueryString(req.query.workspacePath);
|
||||
const skills = await llmSkillsService.listProviderSkills(provider, { workspacePath });
|
||||
res.json(createApiSuccessResponse({ provider, skills }));
|
||||
}),
|
||||
);
|
||||
|
||||
/**
|
||||
* Lists skills for one provider or for all providers in a single response.
|
||||
*/
|
||||
router.get(
|
||||
'/skills',
|
||||
asyncHandler(async (req: Request, res: Response) => {
|
||||
const providerQuery = readOptionalQueryString(req.query.provider);
|
||||
const workspacePath = readOptionalQueryString(req.query.workspacePath);
|
||||
if (providerQuery) {
|
||||
const provider = parseProvider(providerQuery);
|
||||
const skills = await llmSkillsService.listProviderSkills(provider, { workspacePath });
|
||||
res.json(createApiSuccessResponse({ provider, skills }));
|
||||
return;
|
||||
}
|
||||
|
||||
const providers: LLMProvider[] = ['claude', 'codex', 'cursor', 'gemini'];
|
||||
const byProvider = Object.fromEntries(
|
||||
await Promise.all(
|
||||
providers.map(async (provider) => ([
|
||||
provider,
|
||||
await llmSkillsService.listProviderSkills(provider, { workspacePath }),
|
||||
])),
|
||||
),
|
||||
);
|
||||
res.json(createApiSuccessResponse({ providers: byProvider }));
|
||||
}),
|
||||
);
|
||||
|
||||
router.get(
|
||||
'/sessions/:sessionId/messages',
|
||||
asyncHandler(async (req: Request, res: Response) => {
|
||||
const sessionId = readPathParam(req.params.sessionId, 'sessionId');
|
||||
const history = await llmSessionsService.getSessionHistory(sessionId);
|
||||
res.json(createApiSuccessResponse({
|
||||
sessionId,
|
||||
provider: history.provider,
|
||||
messages: history.messages,
|
||||
}));
|
||||
}),
|
||||
);
|
||||
|
||||
router.get(
|
||||
'/sessions/:sessionId/history',
|
||||
asyncHandler(async (req: Request, res: Response) => {
|
||||
const sessionId = readPathParam(req.params.sessionId, 'sessionId');
|
||||
const history = await llmSessionsService.getSessionHistory(sessionId);
|
||||
res.json(createApiSuccessResponse(history));
|
||||
}),
|
||||
);
|
||||
|
||||
/**
|
||||
* Renames one indexed session by writing the custom summary into DB.
|
||||
*/
|
||||
router.put(
|
||||
'/sessions/:sessionId/rename',
|
||||
asyncHandler(async (req: Request, res: Response) => {
|
||||
const sessionId = readPathParam(req.params.sessionId, 'sessionId');
|
||||
const { summary } = parseRenamePayload(req.body);
|
||||
llmSessionsService.updateSessionCustomName(sessionId, summary);
|
||||
res.json(createApiSuccessResponse({ sessionId, summary }));
|
||||
}),
|
||||
);
|
||||
|
||||
/**
|
||||
* Returns DB-indexed sessions discovered by the session-processor scan.
|
||||
*/
|
||||
router.get(
|
||||
'/sessions/index',
|
||||
asyncHandler(async (req: Request, res: Response) => {
|
||||
const provider =
|
||||
typeof req.query.provider === 'string' ? req.query.provider.trim().toLowerCase() : undefined;
|
||||
const sessions = llmSessionsService.listIndexedSessions(provider);
|
||||
res.json(createApiSuccessResponse({ provider: provider ?? null, sessions }));
|
||||
}),
|
||||
);
|
||||
|
||||
/**
|
||||
* Returns one DB-indexed session metadata row.
|
||||
*/
|
||||
router.get(
|
||||
'/sessions/:sessionId',
|
||||
asyncHandler(async (req: Request, res: Response) => {
|
||||
const sessionId = readPathParam(req.params.sessionId, 'sessionId');
|
||||
const session = llmSessionsService.getIndexedSession(sessionId);
|
||||
res.json(createApiSuccessResponse({ session }));
|
||||
}),
|
||||
);
|
||||
|
||||
/**
|
||||
* Triggers provider disk scans and refreshes the shared sessions table.
|
||||
*/
|
||||
router.post(
|
||||
'/sessions/sync',
|
||||
asyncHandler(async (_req: Request, res: Response) => {
|
||||
const syncResult = await llmSessionsService.synchronizeSessions();
|
||||
res.json(createApiSuccessResponse(syncResult));
|
||||
}),
|
||||
);
|
||||
|
||||
/**
|
||||
* Deletes provider-specific session artifacts and removes the DB row.
|
||||
*/
|
||||
router.delete(
|
||||
'/sessions/:sessionId',
|
||||
asyncHandler(async (req: Request, res: Response) => {
|
||||
const sessionId = readPathParam(req.params.sessionId, 'sessionId');
|
||||
const result = await llmSessionsService.deleteSessionArtifacts(sessionId);
|
||||
res.json(createApiSuccessResponse(result));
|
||||
}),
|
||||
);
|
||||
|
||||
/**
|
||||
* Normalizes route-level failures to a consistent JSON API shape.
|
||||
*/
|
||||
router.use((error: unknown, _req: Request, res: Response, _next: NextFunction) => {
|
||||
if (res.headersSent) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (error instanceof AppError) {
|
||||
res
|
||||
.status(error.statusCode)
|
||||
.json(createApiErrorResponse(error.code, error.message, undefined, error.details));
|
||||
return;
|
||||
}
|
||||
|
||||
const message = error instanceof Error ? error.message : 'Unexpected LLM route failure.';
|
||||
logger.error(message, {
|
||||
module: 'ai-runtime.routes',
|
||||
});
|
||||
|
||||
res.status(500).json(createApiErrorResponse('INTERNAL_ERROR', message));
|
||||
});
|
||||
|
||||
export default router;
|
||||
@@ -1,173 +0,0 @@
|
||||
import type {
|
||||
IProvider,
|
||||
IProviderAuthRuntime,
|
||||
IProviderMcpRuntime,
|
||||
IProviderSessionSynchronizerRuntime,
|
||||
IProviderSkillsRuntime,
|
||||
MutableProviderSession,
|
||||
ProviderCapabilities,
|
||||
ProviderExecutionFamily,
|
||||
ProviderModel,
|
||||
ProviderSessionEvent,
|
||||
ProviderSessionSnapshot,
|
||||
StartSessionInput,
|
||||
} from '@/modules/ai-runtime/types/index.js';
|
||||
import type { LLMProvider } from '@/shared/types/app.js';
|
||||
|
||||
const MAX_EVENT_BUFFER_SIZE = 2_000;
|
||||
|
||||
/**
|
||||
* Shared provider base for session lifecycle state and capability gating.
|
||||
*/
|
||||
export abstract class AbstractProvider implements IProvider {
|
||||
readonly id: LLMProvider;
|
||||
readonly family: ProviderExecutionFamily;
|
||||
readonly capabilities: ProviderCapabilities;
|
||||
abstract readonly mcp: IProviderMcpRuntime;
|
||||
abstract readonly skills: IProviderSkillsRuntime;
|
||||
abstract readonly sessionSynchronizer: IProviderSessionSynchronizerRuntime;
|
||||
abstract readonly auth: IProviderAuthRuntime;
|
||||
|
||||
protected readonly sessions = new Map<string, MutableProviderSession>();
|
||||
|
||||
protected constructor(
|
||||
id: LLMProvider,
|
||||
family: ProviderExecutionFamily,
|
||||
capabilities: ProviderCapabilities,
|
||||
) {
|
||||
this.id = id;
|
||||
this.family = family;
|
||||
this.capabilities = capabilities;
|
||||
}
|
||||
|
||||
abstract listModels(): Promise<ProviderModel[]>;
|
||||
abstract launchSession(input: StartSessionInput): Promise<ProviderSessionSnapshot>;
|
||||
abstract resumeSession(
|
||||
input: StartSessionInput & { sessionId: string },
|
||||
): Promise<ProviderSessionSnapshot>;
|
||||
|
||||
/**
|
||||
* Returns one in-memory session snapshot when present.
|
||||
*/
|
||||
getSession(sessionId: string): ProviderSessionSnapshot | null {
|
||||
const session = this.sessions.get(sessionId);
|
||||
if (!session) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return this.toSnapshot(session);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns snapshots of all in-memory sessions.
|
||||
*/
|
||||
listSessions(): ProviderSessionSnapshot[] {
|
||||
return [...this.sessions.values()].map((session) => this.toSnapshot(session));
|
||||
}
|
||||
|
||||
/**
|
||||
* Requests a graceful session stop.
|
||||
*/
|
||||
async stopSession(sessionId: string): Promise<boolean> {
|
||||
const session = this.sessions.get(sessionId);
|
||||
if (!session) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const stopped = await session.stop();
|
||||
if (stopped && session.status === 'running') {
|
||||
this.updateSessionStatus(session, 'stopped');
|
||||
this.appendEvent(session, {
|
||||
timestamp: new Date().toISOString(),
|
||||
channel: 'system',
|
||||
message: 'Session stop requested.',
|
||||
data: {
|
||||
sessionId,
|
||||
sessionStatus: 'SESSION_ABORTED',
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
return stopped;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates mutable internal session state and registers it in memory.
|
||||
*/
|
||||
protected createSessionRecord(
|
||||
sessionId: string,
|
||||
input: {
|
||||
model?: string;
|
||||
thinkingMode?: string;
|
||||
},
|
||||
): MutableProviderSession {
|
||||
const session: MutableProviderSession = {
|
||||
sessionId,
|
||||
provider: this.id,
|
||||
family: this.family,
|
||||
status: 'running',
|
||||
startedAt: new Date().toISOString(),
|
||||
model: input.model,
|
||||
thinkingMode: input.thinkingMode,
|
||||
events: [],
|
||||
completion: Promise.resolve(),
|
||||
stop: async () => false,
|
||||
};
|
||||
|
||||
this.sessions.set(sessionId, session);
|
||||
|
||||
this.appendEvent(session, {
|
||||
timestamp: session.startedAt,
|
||||
channel: 'system',
|
||||
message: 'Session started.',
|
||||
data: {
|
||||
sessionId,
|
||||
sessionStatus: 'STARTED',
|
||||
},
|
||||
});
|
||||
|
||||
return session;
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends an event while enforcing the configured ring-buffer size.
|
||||
*/
|
||||
protected appendEvent(session: MutableProviderSession, event: ProviderSessionEvent): void {
|
||||
session.events.push(event);
|
||||
|
||||
if (session.events.length > MAX_EVENT_BUFFER_SIZE) {
|
||||
session.events.splice(0, session.events.length - MAX_EVENT_BUFFER_SIZE);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Marks the terminal state for a session.
|
||||
*/
|
||||
protected updateSessionStatus(
|
||||
session: MutableProviderSession,
|
||||
status: MutableProviderSession['status'],
|
||||
error?: string,
|
||||
): void {
|
||||
session.status = status;
|
||||
session.endedAt = new Date().toISOString();
|
||||
session.error = error;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts mutable internal session state to an external snapshot.
|
||||
*/
|
||||
protected toSnapshot(session: MutableProviderSession): ProviderSessionSnapshot {
|
||||
return {
|
||||
sessionId: session.sessionId,
|
||||
provider: session.provider,
|
||||
family: session.family,
|
||||
status: session.status,
|
||||
startedAt: session.startedAt,
|
||||
endedAt: session.endedAt,
|
||||
model: session.model,
|
||||
thinkingMode: session.thinkingMode,
|
||||
events: [...session.events],
|
||||
error: session.error,
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1,296 +0,0 @@
|
||||
import { randomUUID } from 'node:crypto';
|
||||
import { once } from 'node:events';
|
||||
import type { ChildProcessWithoutNullStreams } from 'node:child_process';
|
||||
|
||||
import spawn from 'cross-spawn';
|
||||
|
||||
import { AbstractProvider } from '@/modules/ai-runtime/providers/base/abstract.provider.js';
|
||||
import type {
|
||||
MutableProviderSession,
|
||||
ProviderCapabilities,
|
||||
ProviderSessionEvent,
|
||||
ProviderSessionSnapshot,
|
||||
StartSessionInput,
|
||||
} from '@/modules/ai-runtime/types/index.js';
|
||||
import { createStreamLineAccumulator } from '@/shared/platform/stream.js';
|
||||
import type { LLMProvider } from '@/shared/types/app.js';
|
||||
|
||||
type CreateCliInvocationInput = StartSessionInput & {
|
||||
sessionId: string;
|
||||
isResume: boolean;
|
||||
};
|
||||
|
||||
type CliInvocation = {
|
||||
command: string;
|
||||
args: string[];
|
||||
cwd?: string;
|
||||
env?: Record<string, string | undefined>;
|
||||
};
|
||||
|
||||
const PROCESS_SHUTDOWN_GRACE_PERIOD_MS = 2_000;
|
||||
|
||||
/**
|
||||
* Base class for CLI-driven providers with streamed stdout/stderr parsing.
|
||||
*/
|
||||
export abstract class BaseCliProvider extends AbstractProvider {
|
||||
protected constructor(providerId: LLMProvider, capabilities: ProviderCapabilities) {
|
||||
super(providerId, 'cli', capabilities);
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts a new CLI session and begins process output streaming.
|
||||
*/
|
||||
async launchSession(input: StartSessionInput): Promise<ProviderSessionSnapshot> {
|
||||
return this.startSessionInternal({
|
||||
...input,
|
||||
sessionId: input.sessionId ?? randomUUID(),
|
||||
isResume: false,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Resumes an existing CLI session and begins process output streaming.
|
||||
*/
|
||||
async resumeSession(input: StartSessionInput & { sessionId: string }): Promise<ProviderSessionSnapshot> {
|
||||
return this.startSessionInternal({
|
||||
...input,
|
||||
isResume: true,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Implemented by concrete CLI providers to describe command invocation.
|
||||
*/
|
||||
protected abstract createCliInvocation(input: CreateCliInvocationInput): CliInvocation;
|
||||
|
||||
/**
|
||||
* Appends uploaded image paths to prompt text for CLI providers that only accept string prompts.
|
||||
*/
|
||||
protected appendImagePathsToPrompt(prompt: string, imagePaths?: string[]): string {
|
||||
if (!imagePaths || imagePaths.length === 0) {
|
||||
return prompt;
|
||||
}
|
||||
|
||||
return `${prompt}\n\n${JSON.stringify(imagePaths)}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Maps one stdout/stderr line into either JSON or plain-text event shapes.
|
||||
*/
|
||||
protected mapCliOutputLine(line: string, channel: 'stdout' | 'stderr'): ProviderSessionEvent {
|
||||
const parsedJson = this.tryParseJson(line);
|
||||
if (parsedJson !== null) {
|
||||
return {
|
||||
timestamp: new Date().toISOString(),
|
||||
channel: 'json',
|
||||
data: parsedJson,
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
timestamp: new Date().toISOString(),
|
||||
channel,
|
||||
message: line,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs a one-off CLI command and returns full stdout text on success.
|
||||
*/
|
||||
protected async runCommandForOutput(command: string, args: string[]): Promise<string> {
|
||||
const child = spawn(command, args, {
|
||||
stdio: ['ignore', 'pipe', 'pipe'],
|
||||
cwd: process.cwd(),
|
||||
env: process.env,
|
||||
});
|
||||
|
||||
let stdout = '';
|
||||
let stderr = '';
|
||||
|
||||
child.stdout?.on('data', (chunk) => {
|
||||
stdout += chunk.toString();
|
||||
});
|
||||
child.stderr?.on('data', (chunk) => {
|
||||
stderr += chunk.toString();
|
||||
});
|
||||
|
||||
const closePromise = once(child, 'close');
|
||||
const errorPromise = once(child, 'error').then(([error]) => {
|
||||
throw error;
|
||||
});
|
||||
|
||||
await Promise.race([closePromise, errorPromise]);
|
||||
|
||||
if ((child.exitCode ?? 1) !== 0) {
|
||||
const message = stderr.trim() || `Command "${command}" failed with code ${child.exitCode}`;
|
||||
throw new Error(message);
|
||||
}
|
||||
|
||||
return stdout;
|
||||
}
|
||||
|
||||
/**
|
||||
* Boots one CLI child process and wires stream handlers to the session buffer.
|
||||
*/
|
||||
private async startSessionInternal(input: CreateCliInvocationInput): Promise<ProviderSessionSnapshot> {
|
||||
const session = this.createSessionRecord(input.sessionId, {
|
||||
model: input.model,
|
||||
thinkingMode: input.thinkingMode,
|
||||
});
|
||||
|
||||
const invocation = this.createCliInvocation(input);
|
||||
|
||||
const child = spawn(invocation.command, invocation.args, {
|
||||
cwd: invocation.cwd ?? input.workspacePath ?? process.cwd(),
|
||||
env: {
|
||||
...process.env,
|
||||
...invocation.env,
|
||||
},
|
||||
stdio: ['ignore', 'pipe', 'pipe'],
|
||||
}) as ChildProcessWithoutNullStreams;
|
||||
|
||||
const stop = async (): Promise<boolean> => this.terminateChildProcess(child);
|
||||
session.stop = stop;
|
||||
|
||||
const stdoutAccumulator = createStreamLineAccumulator({ preserveEmptyLines: false });
|
||||
const stderrAccumulator = createStreamLineAccumulator({ preserveEmptyLines: false });
|
||||
|
||||
child.stdout.on('data', (chunk) => {
|
||||
const lines = stdoutAccumulator.push(chunk);
|
||||
for (const line of lines) {
|
||||
const event = this.mapCliOutputLine(line, 'stdout');
|
||||
this.appendEvent(session, event);
|
||||
}
|
||||
});
|
||||
|
||||
child.stderr.on('data', (chunk) => {
|
||||
const lines = stderrAccumulator.push(chunk);
|
||||
for (const line of lines) {
|
||||
const event = this.mapCliOutputLine(line, 'stderr');
|
||||
this.appendEvent(session, event);
|
||||
}
|
||||
});
|
||||
|
||||
session.completion = this.waitForCliProcess(
|
||||
session,
|
||||
child,
|
||||
stdoutAccumulator,
|
||||
stderrAccumulator,
|
||||
);
|
||||
return this.toSnapshot(session);
|
||||
}
|
||||
|
||||
/**
|
||||
* Waits for process completion/error and marks final session status.
|
||||
*/
|
||||
private async waitForCliProcess(
|
||||
session: MutableProviderSession,
|
||||
child: ChildProcessWithoutNullStreams,
|
||||
stdoutAccumulator: { flush: () => string[] },
|
||||
stderrAccumulator: { flush: () => string[] },
|
||||
): Promise<void> {
|
||||
const closePromise = once(child, 'close') as Promise<[number | null, NodeJS.Signals | null]>;
|
||||
const errorPromise = once(child, 'error') as Promise<[Error]>;
|
||||
const raceResult = await Promise.race([
|
||||
closePromise.then((result) => ({ type: 'close' as const, result })),
|
||||
errorPromise.then((result) => ({ type: 'error' as const, result })),
|
||||
]);
|
||||
|
||||
const pendingStdout = stdoutAccumulator.flush();
|
||||
const pendingStderr = stderrAccumulator.flush();
|
||||
|
||||
for (const line of pendingStdout) {
|
||||
this.appendEvent(session, this.mapCliOutputLine(line, 'stdout'));
|
||||
}
|
||||
|
||||
for (const line of pendingStderr) {
|
||||
this.appendEvent(session, this.mapCliOutputLine(line, 'stderr'));
|
||||
}
|
||||
|
||||
if (raceResult.type === 'error') {
|
||||
const [error] = raceResult.result;
|
||||
const message = error.message || 'CLI process failed before start.';
|
||||
this.updateSessionStatus(session, 'failed', message);
|
||||
this.appendEvent(session, {
|
||||
timestamp: new Date().toISOString(),
|
||||
channel: 'error',
|
||||
message,
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
const [code, signal] = raceResult.result;
|
||||
|
||||
if (session.status === 'stopped') {
|
||||
this.appendEvent(session, {
|
||||
timestamp: new Date().toISOString(),
|
||||
channel: 'system',
|
||||
message: `Session stopped (${signal ?? 'SIGTERM'}).`,
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
if (code === 0) {
|
||||
this.updateSessionStatus(session, 'completed');
|
||||
this.appendEvent(session, {
|
||||
timestamp: new Date().toISOString(),
|
||||
channel: 'system',
|
||||
message: 'Session completed.',
|
||||
data: {
|
||||
sessionId: session.sessionId,
|
||||
sessionStatus: 'COMPLETED',
|
||||
},
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
const message = `CLI command exited with code ${code ?? 'null'}${signal ? ` (signal: ${signal})` : ''}`;
|
||||
this.updateSessionStatus(session, 'failed', message);
|
||||
this.appendEvent(session, {
|
||||
timestamp: new Date().toISOString(),
|
||||
channel: 'error',
|
||||
message,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempts graceful termination first, then force-kills when necessary.
|
||||
*/
|
||||
private async terminateChildProcess(child: ChildProcessWithoutNullStreams): Promise<boolean> {
|
||||
if (child.killed || child.exitCode !== null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
try {
|
||||
child.kill('SIGTERM');
|
||||
await Promise.race([
|
||||
once(child, 'close'),
|
||||
new Promise((resolve) => setTimeout(resolve, PROCESS_SHUTDOWN_GRACE_PERIOD_MS)),
|
||||
]);
|
||||
|
||||
if (child.exitCode === null) {
|
||||
child.kill('SIGKILL');
|
||||
}
|
||||
|
||||
return true;
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Best-effort JSON parser for stream-json providers.
|
||||
*/
|
||||
private tryParseJson(line: string): unknown | null {
|
||||
const trimmed = line.trim();
|
||||
if (!trimmed || (!trimmed.startsWith('{') && !trimmed.startsWith('['))) {
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
return JSON.parse(trimmed);
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,151 +0,0 @@
|
||||
import { randomUUID } from 'node:crypto';
|
||||
|
||||
import { AbstractProvider } from '@/modules/ai-runtime/providers/base/abstract.provider.js';
|
||||
import type {
|
||||
MutableProviderSession,
|
||||
ProviderCapabilities,
|
||||
ProviderSessionEvent,
|
||||
ProviderSessionSnapshot,
|
||||
StartSessionInput,
|
||||
} from '@/modules/ai-runtime/types/index.js';
|
||||
import type { LLMProvider } from '@/shared/types/app.js';
|
||||
|
||||
type CreateSdkExecutionInput = StartSessionInput & {
|
||||
sessionId: string;
|
||||
isResume: boolean;
|
||||
emitEvent?: (event: ProviderSessionEvent) => void;
|
||||
};
|
||||
|
||||
type SdkExecution = {
|
||||
stream: AsyncIterable<unknown>;
|
||||
stop: () => Promise<boolean>;
|
||||
};
|
||||
|
||||
/**
|
||||
* Base class for SDK-driven providers with async stream consumption.
|
||||
*/
|
||||
export abstract class BaseSdkProvider extends AbstractProvider {
|
||||
protected constructor(providerId: LLMProvider, capabilities: ProviderCapabilities) {
|
||||
super(providerId, 'sdk', capabilities);
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts a new SDK session and begins event streaming.
|
||||
*/
|
||||
async launchSession(input: StartSessionInput): Promise<ProviderSessionSnapshot> {
|
||||
return this.startSessionInternal({
|
||||
...input,
|
||||
sessionId: input.sessionId ?? randomUUID(),
|
||||
isResume: false,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Resumes an existing SDK session and begins event streaming.
|
||||
*/
|
||||
async resumeSession(input: StartSessionInput & { sessionId: string }): Promise<ProviderSessionSnapshot> {
|
||||
return this.startSessionInternal({
|
||||
...input,
|
||||
isResume: true,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Implemented by concrete SDK providers to create a running execution.
|
||||
*/
|
||||
protected abstract createSdkExecution(input: CreateSdkExecutionInput): Promise<SdkExecution>;
|
||||
|
||||
/**
|
||||
* Normalizes raw SDK events to the shared event shape.
|
||||
*/
|
||||
protected mapSdkEvent(rawEvent: unknown): ProviderSessionEvent | null {
|
||||
return {
|
||||
timestamp: new Date().toISOString(),
|
||||
channel: 'sdk',
|
||||
data: rawEvent,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes one SDK execution and wires it to the internal session record.
|
||||
*/
|
||||
private async startSessionInternal(input: CreateSdkExecutionInput): Promise<ProviderSessionSnapshot> {
|
||||
const session = this.createSessionRecord(input.sessionId, {
|
||||
model: input.model,
|
||||
thinkingMode: input.thinkingMode,
|
||||
});
|
||||
|
||||
let execution: SdkExecution;
|
||||
try {
|
||||
execution = await this.createSdkExecution({
|
||||
...input,
|
||||
emitEvent: (event) => {
|
||||
this.appendEvent(session, event);
|
||||
},
|
||||
});
|
||||
} catch (error) {
|
||||
const message = error instanceof Error ? error.message : 'Failed to start SDK session';
|
||||
this.updateSessionStatus(session, 'failed', message);
|
||||
this.appendEvent(session, {
|
||||
timestamp: new Date().toISOString(),
|
||||
channel: 'error',
|
||||
message,
|
||||
});
|
||||
throw error;
|
||||
}
|
||||
|
||||
session.stop = execution.stop;
|
||||
|
||||
session.completion = this.consumeStream(session, execution.stream);
|
||||
return this.toSnapshot(session);
|
||||
}
|
||||
|
||||
/**
|
||||
* Drains SDK events until completion/error and updates final status.
|
||||
*/
|
||||
private async consumeStream(
|
||||
session: MutableProviderSession,
|
||||
stream: AsyncIterable<unknown>,
|
||||
): Promise<void> {
|
||||
try {
|
||||
for await (const sdkEvent of stream) {
|
||||
const normalized = this.mapSdkEvent(sdkEvent);
|
||||
if (normalized) {
|
||||
this.appendEvent(session, normalized);
|
||||
}
|
||||
}
|
||||
|
||||
// after stream completion, only update status if not already stopped by user
|
||||
if (session.status === 'running') {
|
||||
this.updateSessionStatus(session, 'completed');
|
||||
this.appendEvent(session, {
|
||||
timestamp: new Date().toISOString(),
|
||||
channel: 'system',
|
||||
message: 'Session completed.',
|
||||
data: {
|
||||
sessionId: session.sessionId,
|
||||
sessionStatus: 'COMPLETED',
|
||||
},
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
const message = error instanceof Error ? error.message : 'Unknown SDK execution failure';
|
||||
|
||||
if (session.status === 'stopped') {
|
||||
this.appendEvent(session, {
|
||||
timestamp: new Date().toISOString(),
|
||||
channel: 'system',
|
||||
message: 'Session stopped.',
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
this.updateSessionStatus(session, 'failed', message);
|
||||
this.appendEvent(session, {
|
||||
timestamp: new Date().toISOString(),
|
||||
channel: 'error',
|
||||
message,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,120 +0,0 @@
|
||||
import os from 'node:os';
|
||||
import path from 'node:path';
|
||||
import { readFile } from 'node:fs/promises';
|
||||
|
||||
import type { IProviderAuthRuntime, ProviderAuthStatus } from '@/modules/ai-runtime/types/index.js';
|
||||
|
||||
type ClaudeCredentialsFile = {
|
||||
email?: string;
|
||||
user?: string;
|
||||
claudeAiOauth?: {
|
||||
accessToken?: string;
|
||||
expiresAt?: number | string;
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* Reads auth status for Claude from env/settings and OAuth credentials.
|
||||
*/
|
||||
export class ClaudeAuthRuntime implements IProviderAuthRuntime {
|
||||
async getStatus(): Promise<ProviderAuthStatus> {
|
||||
try {
|
||||
if (process.env.ANTHROPIC_API_KEY?.trim()) {
|
||||
return {
|
||||
provider: 'claude',
|
||||
authenticated: true,
|
||||
email: 'API Key Auth',
|
||||
method: 'api_key',
|
||||
};
|
||||
}
|
||||
|
||||
const settingsEnv = await this.loadClaudeSettingsEnv();
|
||||
if (settingsEnv.ANTHROPIC_API_KEY?.trim()) {
|
||||
return {
|
||||
provider: 'claude',
|
||||
authenticated: true,
|
||||
email: 'API Key Auth',
|
||||
method: 'api_key',
|
||||
};
|
||||
}
|
||||
|
||||
if (settingsEnv.ANTHROPIC_AUTH_TOKEN?.trim()) {
|
||||
return {
|
||||
provider: 'claude',
|
||||
authenticated: true,
|
||||
email: 'Configured via settings.json',
|
||||
method: 'api_key',
|
||||
};
|
||||
}
|
||||
|
||||
const credentialsPath = path.join(os.homedir(), '.claude', '.credentials.json');
|
||||
const content = await readFile(credentialsPath, 'utf8');
|
||||
const credentials = JSON.parse(content) as ClaudeCredentialsFile;
|
||||
const oauth = credentials.claudeAiOauth;
|
||||
const accessToken = oauth?.accessToken;
|
||||
|
||||
if (accessToken && !this.isExpired(oauth?.expiresAt)) {
|
||||
return {
|
||||
provider: 'claude',
|
||||
authenticated: true,
|
||||
email: credentials.email ?? credentials.user ?? null,
|
||||
method: 'credentials_file',
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
provider: 'claude',
|
||||
authenticated: false,
|
||||
email: null,
|
||||
method: null,
|
||||
error: 'Not authenticated',
|
||||
};
|
||||
} catch {
|
||||
return {
|
||||
provider: 'claude',
|
||||
authenticated: false,
|
||||
email: null,
|
||||
method: null,
|
||||
error: 'Not authenticated',
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads optional env values from ~/.claude/settings.json.
|
||||
*/
|
||||
private async loadClaudeSettingsEnv(): Promise<Record<string, string>> {
|
||||
try {
|
||||
const settingsPath = path.join(os.homedir(), '.claude', 'settings.json');
|
||||
const content = await readFile(settingsPath, 'utf8');
|
||||
const settings = JSON.parse(content) as { env?: unknown };
|
||||
if (!settings.env || typeof settings.env !== 'object') {
|
||||
return {};
|
||||
}
|
||||
|
||||
return Object.fromEntries(
|
||||
Object.entries(settings.env as Record<string, unknown>).filter(
|
||||
(entry): entry is [string, string] => typeof entry[1] === 'string',
|
||||
),
|
||||
);
|
||||
} catch {
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true when an OAuth expiration timestamp is in the past.
|
||||
*/
|
||||
private isExpired(expiresAt: number | string | undefined): boolean {
|
||||
if (expiresAt === undefined) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (typeof expiresAt === 'number') {
|
||||
return Date.now() >= expiresAt;
|
||||
}
|
||||
|
||||
const numeric = Number.parseInt(expiresAt, 10);
|
||||
return Number.isFinite(numeric) ? Date.now() >= numeric : false;
|
||||
}
|
||||
}
|
||||
@@ -1,154 +0,0 @@
|
||||
import os from 'node:os';
|
||||
import path from 'node:path';
|
||||
|
||||
import { AppError } from '@/shared/utils/app-error.js';
|
||||
import type {
|
||||
McpScope,
|
||||
ProviderMcpServer,
|
||||
UpsertProviderMcpServerInput,
|
||||
} from '@/modules/ai-runtime/types/index.js';
|
||||
import { BaseProviderMcpRuntime } from '@/modules/ai-runtime/providers/shared/mcp/base-provider-mcp.runtime.js';
|
||||
import {
|
||||
readJsonConfig,
|
||||
readObjectRecord,
|
||||
readOptionalString,
|
||||
readStringArray,
|
||||
readStringRecord,
|
||||
writeJsonConfig,
|
||||
} from '@/modules/ai-runtime/providers/shared/mcp/mcp-runtime.utils.js';
|
||||
|
||||
/**
|
||||
* Claude MCP runtime backed by `~/.claude.json` and project `.mcp.json`.
|
||||
*/
|
||||
export class ClaudeMcpRuntime extends BaseProviderMcpRuntime {
|
||||
constructor() {
|
||||
super('claude', ['user', 'local', 'project'], ['stdio', 'http', 'sse']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads Claude MCP servers from user/local/project config locations.
|
||||
*/
|
||||
protected async readScopedServers(scope: McpScope, workspacePath: string): Promise<Record<string, unknown>> {
|
||||
if (scope === 'project') {
|
||||
const filePath = path.join(workspacePath, '.mcp.json');
|
||||
const config = await readJsonConfig(filePath);
|
||||
return readObjectRecord(config.mcpServers) ?? {};
|
||||
}
|
||||
|
||||
const filePath = path.join(os.homedir(), '.claude.json');
|
||||
const config = await readJsonConfig(filePath);
|
||||
if (scope === 'user') {
|
||||
return readObjectRecord(config.mcpServers) ?? {};
|
||||
}
|
||||
|
||||
const projects = readObjectRecord(config.projects) ?? {};
|
||||
const projectConfig = readObjectRecord(projects[workspacePath]) ?? {};
|
||||
return readObjectRecord(projectConfig.mcpServers) ?? {};
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes Claude MCP servers to user/local/project config locations.
|
||||
*/
|
||||
protected async writeScopedServers(
|
||||
scope: McpScope,
|
||||
workspacePath: string,
|
||||
servers: Record<string, unknown>,
|
||||
): Promise<void> {
|
||||
if (scope === 'project') {
|
||||
const filePath = path.join(workspacePath, '.mcp.json');
|
||||
const config = await readJsonConfig(filePath);
|
||||
config.mcpServers = servers;
|
||||
await writeJsonConfig(filePath, config);
|
||||
return;
|
||||
}
|
||||
|
||||
const filePath = path.join(os.homedir(), '.claude.json');
|
||||
const config = await readJsonConfig(filePath);
|
||||
if (scope === 'user') {
|
||||
config.mcpServers = servers;
|
||||
await writeJsonConfig(filePath, config);
|
||||
return;
|
||||
}
|
||||
|
||||
const projects = readObjectRecord(config.projects) ?? {};
|
||||
const projectConfig = readObjectRecord(projects[workspacePath]) ?? {};
|
||||
projectConfig.mcpServers = servers;
|
||||
projects[workspacePath] = projectConfig;
|
||||
config.projects = projects;
|
||||
await writeJsonConfig(filePath, config);
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds one Claude-native server object from the unified input payload.
|
||||
*/
|
||||
protected buildServerConfig(input: UpsertProviderMcpServerInput): Record<string, unknown> {
|
||||
if (input.transport === 'stdio') {
|
||||
if (!input.command?.trim()) {
|
||||
throw new AppError('command is required for stdio MCP servers.', {
|
||||
code: 'MCP_COMMAND_REQUIRED',
|
||||
statusCode: 400,
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
type: 'stdio',
|
||||
command: input.command,
|
||||
args: input.args ?? [],
|
||||
env: input.env ?? {},
|
||||
};
|
||||
}
|
||||
|
||||
if (!input.url?.trim()) {
|
||||
throw new AppError('url is required for http/sse MCP servers.', {
|
||||
code: 'MCP_URL_REQUIRED',
|
||||
statusCode: 400,
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
type: input.transport,
|
||||
url: input.url,
|
||||
headers: input.headers ?? {},
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Normalizes one Claude server object.
|
||||
*/
|
||||
protected normalizeServerConfig(
|
||||
scope: McpScope,
|
||||
name: string,
|
||||
rawConfig: unknown,
|
||||
): ProviderMcpServer | null {
|
||||
if (!rawConfig || typeof rawConfig !== 'object') {
|
||||
return null;
|
||||
}
|
||||
|
||||
const config = rawConfig as Record<string, unknown>;
|
||||
if (typeof config.command === 'string') {
|
||||
return {
|
||||
provider: 'claude',
|
||||
name,
|
||||
scope,
|
||||
transport: 'stdio',
|
||||
command: config.command,
|
||||
args: readStringArray(config.args),
|
||||
env: readStringRecord(config.env),
|
||||
};
|
||||
}
|
||||
|
||||
if (typeof config.url === 'string') {
|
||||
const transport = readOptionalString(config.type) === 'sse' ? 'sse' : 'http';
|
||||
return {
|
||||
provider: 'claude',
|
||||
name,
|
||||
scope,
|
||||
transport,
|
||||
url: config.url,
|
||||
headers: readStringRecord(config.headers),
|
||||
};
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -1,112 +0,0 @@
|
||||
import os from 'node:os';
|
||||
import path from 'node:path';
|
||||
|
||||
import { sessionsDb } from '@/shared/database/repositories/sessions.db.js';
|
||||
import {
|
||||
buildLookupMap,
|
||||
extractFirstValidJsonlData,
|
||||
findFilesRecursivelyCreatedAfter,
|
||||
normalizeSessionName,
|
||||
readFileTimestamps,
|
||||
} from '@/modules/ai-runtime/providers/shared/session-synchronizer/session-synchronizer.utils.js';
|
||||
import type { IProviderSessionSynchronizerRuntime } from '@/modules/ai-runtime/types/index.js';
|
||||
|
||||
type ParsedSession = {
|
||||
sessionId: string;
|
||||
workspacePath: string;
|
||||
sessionName?: string;
|
||||
};
|
||||
|
||||
/**
|
||||
* Session indexer for Claude transcript artifacts.
|
||||
*/
|
||||
export class ClaudeSessionSynchronizerRuntime implements IProviderSessionSynchronizerRuntime {
|
||||
private readonly provider = 'claude' as const;
|
||||
private readonly claudeHome = path.join(os.homedir(), '.claude');
|
||||
|
||||
/**
|
||||
* Scans ~/.claude projects and upserts discovered sessions into DB.
|
||||
*/
|
||||
async synchronize(since?: Date): Promise<number> {
|
||||
const nameMap = await buildLookupMap(path.join(this.claudeHome, 'history.jsonl'), 'sessionId', 'display');
|
||||
const files = await findFilesRecursivelyCreatedAfter(
|
||||
path.join(this.claudeHome, 'projects'),
|
||||
'.jsonl',
|
||||
since ?? null,
|
||||
);
|
||||
|
||||
let processed = 0;
|
||||
for (const filePath of files) {
|
||||
const parsed = await this.processSessionFile(filePath, nameMap);
|
||||
if (!parsed) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const timestamps = await readFileTimestamps(filePath);
|
||||
sessionsDb.createSession(
|
||||
parsed.sessionId,
|
||||
this.provider,
|
||||
parsed.workspacePath,
|
||||
parsed.sessionName,
|
||||
timestamps.createdAt,
|
||||
timestamps.updatedAt,
|
||||
filePath,
|
||||
);
|
||||
processed += 1;
|
||||
}
|
||||
|
||||
return processed;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses and upserts one Claude session JSONL file.
|
||||
*/
|
||||
async synchronizeFile(filePath: string): Promise<boolean> {
|
||||
if (!filePath.endsWith('.jsonl')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const nameMap = await buildLookupMap(path.join(this.claudeHome, 'history.jsonl'), 'sessionId', 'display');
|
||||
const parsed = await this.processSessionFile(filePath, nameMap);
|
||||
if (!parsed) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const timestamps = await readFileTimestamps(filePath);
|
||||
sessionsDb.createSession(
|
||||
parsed.sessionId,
|
||||
this.provider,
|
||||
parsed.workspacePath,
|
||||
parsed.sessionName,
|
||||
timestamps.createdAt,
|
||||
timestamps.updatedAt,
|
||||
filePath,
|
||||
);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extracts session metadata from one Claude JSONL session file.
|
||||
*/
|
||||
private async processSessionFile(
|
||||
filePath: string,
|
||||
nameMap: Map<string, string>,
|
||||
): Promise<ParsedSession | null> {
|
||||
return extractFirstValidJsonlData(filePath, (rawData) => {
|
||||
const data = rawData as Record<string, unknown>;
|
||||
const sessionId = typeof data.sessionId === 'string' ? data.sessionId : undefined;
|
||||
const workspacePath = typeof data.cwd === 'string' ? data.cwd : undefined;
|
||||
|
||||
if (!sessionId || !workspacePath) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return {
|
||||
sessionId,
|
||||
workspacePath,
|
||||
sessionName: normalizeSessionName(nameMap.get(sessionId), 'Untitled Claude Session'),
|
||||
};
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,133 +0,0 @@
|
||||
import { readFile } from 'node:fs/promises';
|
||||
import os from 'node:os';
|
||||
import path from 'node:path';
|
||||
|
||||
import type { IProviderSkillsRuntime, ProviderSkill } from '@/modules/ai-runtime/types/index.js';
|
||||
import { deduplicateSkills, listSkillsFromDirectory } from '@/modules/ai-runtime/providers/shared/skills/skills-runtime.utils.js';
|
||||
|
||||
/**
|
||||
* Claude skills runtime backed by user/project/plugin skill directories.
|
||||
*/
|
||||
export class ClaudeSkillsRuntime implements IProviderSkillsRuntime {
|
||||
/**
|
||||
* Lists all available Claude skills from user/project/plugin locations.
|
||||
*/
|
||||
async listSkills(options?: { workspacePath?: string }): Promise<ProviderSkill[]> {
|
||||
const workspacePath = path.resolve(options?.workspacePath ?? process.cwd());
|
||||
const home = os.homedir();
|
||||
const skills: ProviderSkill[] = [];
|
||||
|
||||
skills.push(
|
||||
...(await listSkillsFromDirectory({
|
||||
provider: 'claude',
|
||||
scope: 'user',
|
||||
skillsDirectory: path.join(home, '.claude', 'skills'),
|
||||
invocationPrefix: '/',
|
||||
})),
|
||||
);
|
||||
|
||||
skills.push(
|
||||
...(await listSkillsFromDirectory({
|
||||
provider: 'claude',
|
||||
scope: 'project',
|
||||
skillsDirectory: path.join(workspacePath, '.claude', 'skills'),
|
||||
invocationPrefix: '/',
|
||||
})),
|
||||
);
|
||||
|
||||
const enabledPlugins = await this.readClaudeEnabledPlugins();
|
||||
if (!enabledPlugins.length) {
|
||||
return skills;
|
||||
}
|
||||
|
||||
const installedPluginIndex = await this.readClaudeInstalledPluginIndex();
|
||||
for (const pluginId of enabledPlugins) {
|
||||
const pluginInstalls = installedPluginIndex[pluginId];
|
||||
if (!Array.isArray(pluginInstalls)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const pluginNamespace = pluginId.split('@')[0] ?? pluginId;
|
||||
for (const install of pluginInstalls) {
|
||||
if (!install || typeof install !== 'object') {
|
||||
continue;
|
||||
}
|
||||
const installPath = typeof (install as Record<string, unknown>).installPath === 'string'
|
||||
? (install as Record<string, unknown>).installPath as string
|
||||
: '';
|
||||
if (!installPath) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const pluginSkills = await listSkillsFromDirectory({
|
||||
provider: 'claude',
|
||||
scope: 'plugin',
|
||||
skillsDirectory: path.join(installPath, 'skills'),
|
||||
invocationPrefix: '/',
|
||||
pluginName: pluginNamespace,
|
||||
});
|
||||
|
||||
for (const skill of pluginSkills) {
|
||||
skill.invocation = `/${pluginNamespace}:${skill.name}`;
|
||||
skill.pluginName = pluginNamespace;
|
||||
}
|
||||
|
||||
skills.push(...pluginSkills);
|
||||
}
|
||||
}
|
||||
|
||||
return deduplicateSkills(skills);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads Claude enabled plugin map from `~/.claude/settings.json`.
|
||||
*/
|
||||
private async readClaudeEnabledPlugins(): Promise<string[]> {
|
||||
const settingsPath = path.join(os.homedir(), '.claude', 'settings.json');
|
||||
try {
|
||||
const settingsContent = await readFile(settingsPath, 'utf8');
|
||||
const settings = JSON.parse(settingsContent) as Record<string, unknown>;
|
||||
const enabledPlugins = settings.enabledPlugins;
|
||||
if (!enabledPlugins || typeof enabledPlugins !== 'object' || Array.isArray(enabledPlugins)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
const enabledRecords = enabledPlugins as Record<string, unknown>;
|
||||
return Object.entries(enabledRecords)
|
||||
.filter(([, enabled]) => enabled === true)
|
||||
.map(([pluginId]) => pluginId);
|
||||
} catch (error) {
|
||||
if ((error as NodeJS.ErrnoException).code === 'ENOENT') {
|
||||
return [];
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads Claude installed plugin index from `~/.claude/plugins/installed_plugins.json`.
|
||||
*/
|
||||
private async readClaudeInstalledPluginIndex(): Promise<Record<string, unknown[]>> {
|
||||
const pluginIndexPath = path.join(os.homedir(), '.claude', 'plugins', 'installed_plugins.json');
|
||||
try {
|
||||
const indexContent = await readFile(pluginIndexPath, 'utf8');
|
||||
const index = JSON.parse(indexContent) as Record<string, unknown>;
|
||||
const plugins = index.plugins;
|
||||
if (!plugins || typeof plugins !== 'object' || Array.isArray(plugins)) {
|
||||
return {};
|
||||
}
|
||||
|
||||
const normalized: Record<string, unknown[]> = {};
|
||||
for (const [pluginId, entries] of Object.entries(plugins as Record<string, unknown>)) {
|
||||
normalized[pluginId] = Array.isArray(entries) ? entries : [];
|
||||
}
|
||||
|
||||
return normalized;
|
||||
} catch (error) {
|
||||
if ((error as NodeJS.ErrnoException).code === 'ENOENT') {
|
||||
return {};
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,325 +0,0 @@
|
||||
import {
|
||||
query,
|
||||
type CanUseTool,
|
||||
type ModelInfo,
|
||||
type Options,
|
||||
} from '@anthropic-ai/claude-agent-sdk';
|
||||
import path from 'node:path';
|
||||
import { readFile } from 'node:fs/promises';
|
||||
|
||||
import { BaseSdkProvider } from '@/modules/ai-runtime/providers/base/base-sdk.provider.js';
|
||||
import type {
|
||||
IProviderAuthRuntime,
|
||||
IProviderMcpRuntime,
|
||||
IProviderSessionSynchronizerRuntime,
|
||||
IProviderSkillsRuntime,
|
||||
ProviderModel,
|
||||
ProviderSessionEvent,
|
||||
RuntimePermissionMode,
|
||||
StartSessionInput,
|
||||
} from '@/modules/ai-runtime/types/index.js';
|
||||
import { ClaudeMcpRuntime } from '@/modules/ai-runtime/providers/claude/claude-mcp.runtime.js';
|
||||
import { ClaudeAuthRuntime } from '@/modules/ai-runtime/providers/claude/claude-auth.runtime.js';
|
||||
import { ClaudeSkillsRuntime } from '@/modules/ai-runtime/providers/claude/claude-skills.runtime.js';
|
||||
import { ClaudeSessionSynchronizerRuntime } from '@/modules/ai-runtime/providers/claude/claude-session-synchronizer.runtime.js';
|
||||
|
||||
type ClaudeExecutionInput = StartSessionInput & {
|
||||
sessionId: string;
|
||||
isResume: boolean;
|
||||
emitEvent?: (event: ProviderSessionEvent) => void;
|
||||
};
|
||||
|
||||
const CLAUDE_THINKING_LEVELS = new Set(['low', 'medium', 'high', 'max']);
|
||||
const SUPPORTED_CLAUDE_IMAGE_TYPES = new Map<string, 'image/jpeg' | 'image/png' | 'image/gif' | 'image/webp'>([
|
||||
['.jpg', 'image/jpeg'],
|
||||
['.jpeg', 'image/jpeg'],
|
||||
['.png', 'image/png'],
|
||||
['.gif', 'image/gif'],
|
||||
['.webp', 'image/webp'],
|
||||
]);
|
||||
|
||||
type ClaudeUserPromptMessage = {
|
||||
type: 'user';
|
||||
message: {
|
||||
role: 'user';
|
||||
content: Array<
|
||||
| {
|
||||
type: 'text';
|
||||
text: string;
|
||||
}
|
||||
| {
|
||||
type: 'image';
|
||||
source: {
|
||||
type: 'base64';
|
||||
media_type: 'image/jpeg' | 'image/png' | 'image/gif' | 'image/webp';
|
||||
data: string;
|
||||
};
|
||||
}
|
||||
>;
|
||||
};
|
||||
parent_tool_use_id: null;
|
||||
timestamp: string;
|
||||
};
|
||||
|
||||
/**
|
||||
* Safely reads one optional string value from unknown data.
|
||||
*/
|
||||
const readString = (value: unknown): string | undefined => {
|
||||
if (typeof value !== 'string') {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const normalized = value.trim();
|
||||
return normalized.length ? normalized : undefined;
|
||||
};
|
||||
|
||||
/**
|
||||
* Claude SDK provider implementation.
|
||||
*/
|
||||
export class ClaudeProvider extends BaseSdkProvider {
|
||||
readonly auth: IProviderAuthRuntime = new ClaudeAuthRuntime();
|
||||
readonly mcp: IProviderMcpRuntime = new ClaudeMcpRuntime();
|
||||
readonly skills: IProviderSkillsRuntime = new ClaudeSkillsRuntime();
|
||||
readonly sessionSynchronizer: IProviderSessionSynchronizerRuntime = new ClaudeSessionSynchronizerRuntime();
|
||||
|
||||
constructor() {
|
||||
super('claude', {
|
||||
supportsRuntimePermissionRequests: true,
|
||||
supportsThinkingModeControl: true,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves available Claude models from the SDK.
|
||||
*/
|
||||
async listModels(): Promise<ProviderModel[]> {
|
||||
const probe = query({
|
||||
prompt: 'model_probe',
|
||||
options: {
|
||||
permissionMode: 'plan',
|
||||
},
|
||||
});
|
||||
|
||||
try {
|
||||
const models = await probe.supportedModels();
|
||||
return models.map((model) => this.mapModelInfo(model));
|
||||
} finally {
|
||||
probe.close();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a Claude SDK query execution for start/resume flows.
|
||||
*/
|
||||
protected async createSdkExecution(input: ClaudeExecutionInput): Promise<{
|
||||
stream: AsyncIterable<unknown>;
|
||||
stop: () => Promise<boolean>;
|
||||
}> {
|
||||
const options: Options = {
|
||||
cwd: input.workspacePath,
|
||||
model: input.model,
|
||||
effort: this.resolveClaudeEffort(input.thinkingMode),
|
||||
canUseTool: this.resolvePermissionHandler(input.runtimePermissionMode, input.emitEvent),
|
||||
};
|
||||
|
||||
if (input.isResume) {
|
||||
options.resume = input.sessionId;
|
||||
} else {
|
||||
options.sessionId = input.sessionId;
|
||||
}
|
||||
|
||||
const promptInput = await this.buildPromptInput(input.prompt, input.imagePaths, input.workspacePath);
|
||||
const queryInstance = query({
|
||||
prompt: promptInput as any,
|
||||
options,
|
||||
});
|
||||
|
||||
return {
|
||||
stream: queryInstance,
|
||||
stop: async () => {
|
||||
await queryInstance.interrupt();
|
||||
return true;
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds a Claude prompt payload. When images are present, this returns an async iterable user message.
|
||||
*/
|
||||
private async buildPromptInput(
|
||||
prompt: string,
|
||||
imagePaths?: string[],
|
||||
workspacePath?: string,
|
||||
): Promise<string | AsyncIterable<ClaudeUserPromptMessage>> {
|
||||
if (!imagePaths || imagePaths.length === 0) {
|
||||
return prompt;
|
||||
}
|
||||
|
||||
const content: ClaudeUserPromptMessage['message']['content'] = [
|
||||
{ type: 'text', text: prompt },
|
||||
];
|
||||
|
||||
for (const imagePath of imagePaths) {
|
||||
const resolvedPath = path.isAbsolute(imagePath)
|
||||
? imagePath
|
||||
: path.resolve(workspacePath ?? process.cwd(), imagePath);
|
||||
const extension = path.extname(resolvedPath).toLowerCase();
|
||||
const mediaType = SUPPORTED_CLAUDE_IMAGE_TYPES.get(extension);
|
||||
if (!mediaType) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const imageBytes = await readFile(resolvedPath);
|
||||
content.push({
|
||||
type: 'image',
|
||||
source: {
|
||||
type: 'base64',
|
||||
media_type: mediaType,
|
||||
data: imageBytes.toString('base64'),
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
const sdkPrompt = (async function* (): AsyncIterable<ClaudeUserPromptMessage> {
|
||||
yield {
|
||||
type: 'user',
|
||||
message: {
|
||||
role: 'user',
|
||||
content,
|
||||
},
|
||||
parent_tool_use_id: null,
|
||||
timestamp: new Date().toISOString(),
|
||||
};
|
||||
})();
|
||||
|
||||
return sdkPrompt;
|
||||
}
|
||||
|
||||
/**
|
||||
* Produces compact event metadata for frontend stream rendering.
|
||||
*/
|
||||
protected mapSdkEvent(rawEvent: unknown): ProviderSessionEvent | null {
|
||||
if (typeof rawEvent !== 'object' || rawEvent === null) {
|
||||
return {
|
||||
timestamp: new Date().toISOString(),
|
||||
channel: 'sdk',
|
||||
message: String(rawEvent),
|
||||
};
|
||||
}
|
||||
|
||||
const messageType = this.getStringProperty(rawEvent, 'type');
|
||||
const messageSubtype = this.getStringProperty(rawEvent, 'subtype');
|
||||
const message = [messageType, messageSubtype].filter(Boolean).join(':') || 'claude_event';
|
||||
|
||||
return {
|
||||
timestamp: new Date().toISOString(),
|
||||
channel: 'sdk',
|
||||
message,
|
||||
data: rawEvent,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Normalizes Claude model metadata to the shared model shape.
|
||||
*/
|
||||
private mapModelInfo(model: ModelInfo): ProviderModel {
|
||||
return {
|
||||
value: model.value,
|
||||
displayName: model.displayName,
|
||||
description: model.description,
|
||||
supportsThinkingModes: Boolean(model.supportsEffort),
|
||||
supportedThinkingModes: model.supportedEffortLevels,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Maps requested thinking mode to Claude effort levels.
|
||||
*/
|
||||
private resolveClaudeEffort(thinkingMode?: string): Options['effort'] {
|
||||
if (!thinkingMode) {
|
||||
return 'high';
|
||||
}
|
||||
|
||||
const normalized = thinkingMode.trim().toLowerCase();
|
||||
if (CLAUDE_THINKING_LEVELS.has(normalized)) {
|
||||
return normalized as Options['effort'];
|
||||
}
|
||||
|
||||
return 'high';
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds a runtime permission callback when explicit allow/deny is requested.
|
||||
*/
|
||||
private resolvePermissionHandler(
|
||||
mode?: RuntimePermissionMode,
|
||||
emitEvent?: (event: ProviderSessionEvent) => void,
|
||||
): CanUseTool | undefined {
|
||||
if (!mode || mode === 'ask') {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
if (mode === 'allow') {
|
||||
return async (toolName, input, options) => {
|
||||
const optionsRecord = options as Record<string, unknown>;
|
||||
emitEvent?.({
|
||||
timestamp: new Date().toISOString(),
|
||||
channel: 'system',
|
||||
message: `Tool permission requested for "${toolName}".`,
|
||||
data: {
|
||||
type: 'tool_use_request',
|
||||
toolName,
|
||||
input,
|
||||
toolUseID: options.toolUseID,
|
||||
title: readString(optionsRecord.title),
|
||||
displayName: readString(optionsRecord.displayName),
|
||||
description: readString(optionsRecord.description),
|
||||
blockedPath: options.blockedPath,
|
||||
},
|
||||
});
|
||||
return { behavior: 'allow' };
|
||||
};
|
||||
}
|
||||
|
||||
return async (toolName, input, options) => {
|
||||
const optionsRecord = options as Record<string, unknown>;
|
||||
emitEvent?.({
|
||||
timestamp: new Date().toISOString(),
|
||||
channel: 'system',
|
||||
message: `Tool permission denied for "${toolName}".`,
|
||||
data: {
|
||||
type: 'tool_use_request',
|
||||
toolName,
|
||||
input,
|
||||
toolUseID: options.toolUseID,
|
||||
title: readString(optionsRecord.title),
|
||||
displayName: readString(optionsRecord.displayName),
|
||||
description: readString(optionsRecord.description),
|
||||
blockedPath: options.blockedPath,
|
||||
},
|
||||
});
|
||||
return {
|
||||
behavior: 'deny',
|
||||
message: 'Permission denied by runtime permission mode.',
|
||||
interrupt: false,
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads one optional string property from an unknown event object.
|
||||
*/
|
||||
private getStringProperty(value: unknown, key: string): string | undefined {
|
||||
if (!value || typeof value !== 'object') {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const record = value as Record<string, unknown>;
|
||||
const rawValue = record[key];
|
||||
if (typeof rawValue !== 'string') {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return rawValue;
|
||||
}
|
||||
}
|
||||
@@ -1,88 +0,0 @@
|
||||
import os from 'node:os';
|
||||
import path from 'node:path';
|
||||
import { readFile } from 'node:fs/promises';
|
||||
|
||||
import type { IProviderAuthRuntime, ProviderAuthStatus } from '@/modules/ai-runtime/types/index.js';
|
||||
|
||||
type CodexAuthFile = {
|
||||
OPENAI_API_KEY?: string;
|
||||
tokens?: {
|
||||
id_token?: string;
|
||||
access_token?: string;
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* Reads auth status from ~/.codex/auth.json.
|
||||
*/
|
||||
export class CodexAuthRuntime implements IProviderAuthRuntime {
|
||||
async getStatus(): Promise<ProviderAuthStatus> {
|
||||
try {
|
||||
const authPath = path.join(os.homedir(), '.codex', 'auth.json');
|
||||
const content = await readFile(authPath, 'utf8');
|
||||
const auth = JSON.parse(content) as CodexAuthFile;
|
||||
const tokens = auth.tokens ?? {};
|
||||
|
||||
if (tokens.id_token || tokens.access_token) {
|
||||
return {
|
||||
provider: 'codex',
|
||||
authenticated: true,
|
||||
email: this.extractEmail(tokens.id_token),
|
||||
method: 'token_file',
|
||||
};
|
||||
}
|
||||
|
||||
if (auth.OPENAI_API_KEY?.trim()) {
|
||||
return {
|
||||
provider: 'codex',
|
||||
authenticated: true,
|
||||
email: 'API Key Auth',
|
||||
method: 'api_key',
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
provider: 'codex',
|
||||
authenticated: false,
|
||||
email: null,
|
||||
method: null,
|
||||
error: 'No valid tokens found',
|
||||
};
|
||||
} catch (error) {
|
||||
const code = (error as NodeJS.ErrnoException)?.code;
|
||||
return {
|
||||
provider: 'codex',
|
||||
authenticated: false,
|
||||
email: null,
|
||||
method: null,
|
||||
error: code === 'ENOENT'
|
||||
? 'Codex not configured'
|
||||
: (error instanceof Error ? error.message : 'Failed to read Codex auth state'),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Best-effort id_token email extraction from JWT payload.
|
||||
*/
|
||||
private extractEmail(idToken: string | undefined): string {
|
||||
if (!idToken) {
|
||||
return 'Authenticated';
|
||||
}
|
||||
|
||||
try {
|
||||
const parts = idToken.split('.');
|
||||
if (parts.length < 2) {
|
||||
return 'Authenticated';
|
||||
}
|
||||
|
||||
const payload = JSON.parse(Buffer.from(parts[1], 'base64url').toString('utf8')) as {
|
||||
email?: string;
|
||||
user?: string;
|
||||
};
|
||||
return payload.email ?? payload.user ?? 'Authenticated';
|
||||
} catch {
|
||||
return 'Authenticated';
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,133 +0,0 @@
|
||||
import os from 'node:os';
|
||||
import path from 'node:path';
|
||||
|
||||
import { AppError } from '@/shared/utils/app-error.js';
|
||||
import type {
|
||||
McpScope,
|
||||
ProviderMcpServer,
|
||||
UpsertProviderMcpServerInput,
|
||||
} from '@/modules/ai-runtime/types/index.js';
|
||||
import { BaseProviderMcpRuntime } from '@/modules/ai-runtime/providers/shared/mcp/base-provider-mcp.runtime.js';
|
||||
import {
|
||||
readObjectRecord,
|
||||
readOptionalString,
|
||||
readStringArray,
|
||||
readStringRecord,
|
||||
readTomlConfig,
|
||||
writeTomlConfig,
|
||||
} from '@/modules/ai-runtime/providers/shared/mcp/mcp-runtime.utils.js';
|
||||
|
||||
/**
|
||||
* Codex MCP runtime backed by user/project `.codex/config.toml`.
|
||||
*/
|
||||
export class CodexMcpRuntime extends BaseProviderMcpRuntime {
|
||||
constructor() {
|
||||
super('codex', ['user', 'project'], ['stdio', 'http']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads Codex MCP servers from user/project config.toml scopes.
|
||||
*/
|
||||
protected async readScopedServers(scope: McpScope, workspacePath: string): Promise<Record<string, unknown>> {
|
||||
const filePath = scope === 'user'
|
||||
? path.join(os.homedir(), '.codex', 'config.toml')
|
||||
: path.join(workspacePath, '.codex', 'config.toml');
|
||||
const config = await readTomlConfig(filePath);
|
||||
return readObjectRecord(config.mcp_servers) ?? {};
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes Codex MCP servers to user/project config.toml scopes.
|
||||
*/
|
||||
protected async writeScopedServers(
|
||||
scope: McpScope,
|
||||
workspacePath: string,
|
||||
servers: Record<string, unknown>,
|
||||
): Promise<void> {
|
||||
const filePath = scope === 'user'
|
||||
? path.join(os.homedir(), '.codex', 'config.toml')
|
||||
: path.join(workspacePath, '.codex', 'config.toml');
|
||||
const config = await readTomlConfig(filePath);
|
||||
config.mcp_servers = servers;
|
||||
await writeTomlConfig(filePath, config);
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds one Codex-native server object from the unified input payload.
|
||||
*/
|
||||
protected buildServerConfig(input: UpsertProviderMcpServerInput): Record<string, unknown> {
|
||||
if (input.transport === 'stdio') {
|
||||
if (!input.command?.trim()) {
|
||||
throw new AppError('command is required for stdio MCP servers.', {
|
||||
code: 'MCP_COMMAND_REQUIRED',
|
||||
statusCode: 400,
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
command: input.command,
|
||||
args: input.args ?? [],
|
||||
env: input.env ?? {},
|
||||
env_vars: input.envVars ?? [],
|
||||
cwd: input.cwd,
|
||||
};
|
||||
}
|
||||
|
||||
if (!input.url?.trim()) {
|
||||
throw new AppError('url is required for http MCP servers.', {
|
||||
code: 'MCP_URL_REQUIRED',
|
||||
statusCode: 400,
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
url: input.url,
|
||||
bearer_token_env_var: input.bearerTokenEnvVar,
|
||||
http_headers: input.headers ?? {},
|
||||
env_http_headers: input.envHttpHeaders ?? {},
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Normalizes one Codex server object.
|
||||
*/
|
||||
protected normalizeServerConfig(
|
||||
scope: McpScope,
|
||||
name: string,
|
||||
rawConfig: unknown,
|
||||
): ProviderMcpServer | null {
|
||||
if (!rawConfig || typeof rawConfig !== 'object') {
|
||||
return null;
|
||||
}
|
||||
|
||||
const config = rawConfig as Record<string, unknown>;
|
||||
if (typeof config.command === 'string') {
|
||||
return {
|
||||
provider: 'codex',
|
||||
name,
|
||||
scope,
|
||||
transport: 'stdio',
|
||||
command: config.command,
|
||||
args: readStringArray(config.args),
|
||||
env: readStringRecord(config.env),
|
||||
cwd: readOptionalString(config.cwd),
|
||||
envVars: readStringArray(config.env_vars),
|
||||
};
|
||||
}
|
||||
|
||||
if (typeof config.url === 'string') {
|
||||
return {
|
||||
provider: 'codex',
|
||||
name,
|
||||
scope,
|
||||
transport: 'http',
|
||||
url: config.url,
|
||||
headers: readStringRecord(config.http_headers),
|
||||
bearerTokenEnvVar: readOptionalString(config.bearer_token_env_var),
|
||||
envHttpHeaders: readStringRecord(config.env_http_headers),
|
||||
};
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -1,113 +0,0 @@
|
||||
import os from 'node:os';
|
||||
import path from 'node:path';
|
||||
|
||||
import { sessionsDb } from '@/shared/database/repositories/sessions.db.js';
|
||||
import {
|
||||
buildLookupMap,
|
||||
extractFirstValidJsonlData,
|
||||
findFilesRecursivelyCreatedAfter,
|
||||
normalizeSessionName,
|
||||
readFileTimestamps,
|
||||
} from '@/modules/ai-runtime/providers/shared/session-synchronizer/session-synchronizer.utils.js';
|
||||
import type { IProviderSessionSynchronizerRuntime } from '@/modules/ai-runtime/types/index.js';
|
||||
|
||||
type ParsedSession = {
|
||||
sessionId: string;
|
||||
workspacePath: string;
|
||||
sessionName?: string;
|
||||
};
|
||||
|
||||
/**
|
||||
* Session indexer for Codex transcript artifacts.
|
||||
*/
|
||||
export class CodexSessionSynchronizerRuntime implements IProviderSessionSynchronizerRuntime {
|
||||
private readonly provider = 'codex' as const;
|
||||
private readonly codexHome = path.join(os.homedir(), '.codex');
|
||||
|
||||
/**
|
||||
* Scans ~/.codex sessions and upserts discovered sessions into DB.
|
||||
*/
|
||||
async synchronize(since?: Date): Promise<number> {
|
||||
const nameMap = await buildLookupMap(path.join(this.codexHome, 'session_index.jsonl'), 'id', 'thread_name');
|
||||
const files = await findFilesRecursivelyCreatedAfter(
|
||||
path.join(this.codexHome, 'sessions'),
|
||||
'.jsonl',
|
||||
since ?? null,
|
||||
);
|
||||
|
||||
let processed = 0;
|
||||
for (const filePath of files) {
|
||||
const parsed = await this.processSessionFile(filePath, nameMap);
|
||||
if (!parsed) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const timestamps = await readFileTimestamps(filePath);
|
||||
sessionsDb.createSession(
|
||||
parsed.sessionId,
|
||||
this.provider,
|
||||
parsed.workspacePath,
|
||||
parsed.sessionName,
|
||||
timestamps.createdAt,
|
||||
timestamps.updatedAt,
|
||||
filePath,
|
||||
);
|
||||
processed += 1;
|
||||
}
|
||||
|
||||
return processed;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses and upserts one Codex session JSONL file.
|
||||
*/
|
||||
async synchronizeFile(filePath: string): Promise<boolean> {
|
||||
if (!filePath.endsWith('.jsonl')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const nameMap = await buildLookupMap(path.join(this.codexHome, 'session_index.jsonl'), 'id', 'thread_name');
|
||||
const parsed = await this.processSessionFile(filePath, nameMap);
|
||||
if (!parsed) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const timestamps = await readFileTimestamps(filePath);
|
||||
sessionsDb.createSession(
|
||||
parsed.sessionId,
|
||||
this.provider,
|
||||
parsed.workspacePath,
|
||||
parsed.sessionName,
|
||||
timestamps.createdAt,
|
||||
timestamps.updatedAt,
|
||||
filePath,
|
||||
);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extracts session metadata from one Codex JSONL session file.
|
||||
*/
|
||||
private async processSessionFile(
|
||||
filePath: string,
|
||||
nameMap: Map<string, string>,
|
||||
): Promise<ParsedSession | null> {
|
||||
return extractFirstValidJsonlData(filePath, (rawData) => {
|
||||
const data = rawData as Record<string, unknown>;
|
||||
const payload = data.payload as Record<string, unknown> | undefined;
|
||||
const sessionId = typeof payload?.id === 'string' ? payload.id : undefined;
|
||||
const workspacePath = typeof payload?.cwd === 'string' ? payload.cwd : undefined;
|
||||
|
||||
if (!sessionId || !workspacePath) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return {
|
||||
sessionId,
|
||||
workspacePath,
|
||||
sessionName: normalizeSessionName(nameMap.get(sessionId), 'Untitled Codex Session'),
|
||||
};
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
import os from 'node:os';
|
||||
import path from 'node:path';
|
||||
|
||||
import type { IProviderSkillsRuntime, ProviderSkill, ProviderSkillScope } from '@/modules/ai-runtime/types/index.js';
|
||||
import {
|
||||
deduplicateDirectories,
|
||||
deduplicateSkills,
|
||||
findGitRepoRoot,
|
||||
listSkillsFromDirectory,
|
||||
} from '@/modules/ai-runtime/providers/shared/skills/skills-runtime.utils.js';
|
||||
|
||||
/**
|
||||
* Codex skills runtime backed by repo/user/admin/system skill directories.
|
||||
*/
|
||||
export class CodexSkillsRuntime implements IProviderSkillsRuntime {
|
||||
/**
|
||||
* Lists all available Codex skills from documented directories.
|
||||
*/
|
||||
async listSkills(options?: { workspacePath?: string }): Promise<ProviderSkill[]> {
|
||||
const workspacePath = path.resolve(options?.workspacePath ?? process.cwd());
|
||||
const home = os.homedir();
|
||||
const repoRoot = await findGitRepoRoot(workspacePath);
|
||||
const candidateDirectories: Array<{ scope: ProviderSkillScope; directory: string }> = [
|
||||
{ scope: 'repo', directory: path.join(workspacePath, '.agents', 'skills') },
|
||||
{ scope: 'repo', directory: path.join(workspacePath, '..', '.agents', 'skills') },
|
||||
{ scope: 'user', directory: path.join(home, '.agents', 'skills') },
|
||||
{ scope: 'admin', directory: path.join(path.sep, 'etc', 'codex', 'skills') },
|
||||
{ scope: 'system', directory: path.join(home, '.codex', 'skills', '.system') },
|
||||
];
|
||||
if (repoRoot) {
|
||||
candidateDirectories.push({ scope: 'repo', directory: path.join(repoRoot, '.agents', 'skills') });
|
||||
}
|
||||
|
||||
const skills: ProviderSkill[] = [];
|
||||
for (const candidate of deduplicateDirectories(candidateDirectories)) {
|
||||
const loadedSkills = await listSkillsFromDirectory({
|
||||
provider: 'codex',
|
||||
scope: candidate.scope,
|
||||
skillsDirectory: candidate.directory,
|
||||
invocationPrefix: '$',
|
||||
});
|
||||
skills.push(...loadedSkills);
|
||||
}
|
||||
|
||||
return deduplicateSkills(skills);
|
||||
}
|
||||
}
|
||||
@@ -1,241 +0,0 @@
|
||||
import os from 'node:os';
|
||||
import path from 'node:path';
|
||||
import { readFile } from 'node:fs/promises';
|
||||
|
||||
import { BaseSdkProvider } from '@/modules/ai-runtime/providers/base/base-sdk.provider.js';
|
||||
import type {
|
||||
IProviderAuthRuntime,
|
||||
IProviderMcpRuntime,
|
||||
IProviderSessionSynchronizerRuntime,
|
||||
IProviderSkillsRuntime,
|
||||
ProviderModel,
|
||||
ProviderSessionEvent,
|
||||
StartSessionInput,
|
||||
} from '@/modules/ai-runtime/types/index.js';
|
||||
import { CodexMcpRuntime } from '@/modules/ai-runtime/providers/codex/codex-mcp.runtime.js';
|
||||
import { CodexAuthRuntime } from '@/modules/ai-runtime/providers/codex/codex-auth.runtime.js';
|
||||
import { CodexSkillsRuntime } from '@/modules/ai-runtime/providers/codex/codex-skills.runtime.js';
|
||||
import { CodexSessionSynchronizerRuntime } from '@/modules/ai-runtime/providers/codex/codex-session-synchronizer.runtime.js';
|
||||
import { AppError } from '@/shared/utils/app-error.js';
|
||||
|
||||
type CodexExecutionInput = StartSessionInput & {
|
||||
sessionId: string;
|
||||
isResume: boolean;
|
||||
};
|
||||
|
||||
type CodexModelCacheEntry = {
|
||||
slug?: string;
|
||||
display_name?: string;
|
||||
description?: string;
|
||||
supported_reasoning_levels?: Array<{
|
||||
effort?: string;
|
||||
description?: string;
|
||||
}>;
|
||||
priority?: number;
|
||||
};
|
||||
|
||||
type CodexSdkClient = {
|
||||
startThread: (options?: Record<string, unknown>) => CodexThread;
|
||||
resumeThread: (sessionId: string, options?: Record<string, unknown>) => CodexThread;
|
||||
};
|
||||
|
||||
type CodexThread = {
|
||||
runStreamed: (
|
||||
prompt:
|
||||
| string
|
||||
| Array<
|
||||
| {
|
||||
type: 'text';
|
||||
text: string;
|
||||
}
|
||||
| {
|
||||
type: 'local_image';
|
||||
path: string;
|
||||
}
|
||||
>,
|
||||
options?: {
|
||||
signal?: AbortSignal;
|
||||
},
|
||||
) => Promise<{
|
||||
events: AsyncIterable<unknown>;
|
||||
}>;
|
||||
};
|
||||
|
||||
type CodexSdkModule = {
|
||||
Codex: new () => CodexSdkClient;
|
||||
};
|
||||
|
||||
/**
|
||||
* Codex SDK provider implementation.
|
||||
*/
|
||||
export class CodexProvider extends BaseSdkProvider {
|
||||
readonly auth: IProviderAuthRuntime = new CodexAuthRuntime();
|
||||
readonly mcp: IProviderMcpRuntime = new CodexMcpRuntime();
|
||||
readonly skills: IProviderSkillsRuntime = new CodexSkillsRuntime();
|
||||
readonly sessionSynchronizer: IProviderSessionSynchronizerRuntime = new CodexSessionSynchronizerRuntime();
|
||||
|
||||
private codexClientPromise: Promise<CodexSdkClient> | null = null;
|
||||
|
||||
constructor() {
|
||||
super('codex', {
|
||||
supportsRuntimePermissionRequests: false,
|
||||
supportsThinkingModeControl: true,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads codex models from ~/.codex/models_cache.json.
|
||||
*/
|
||||
async listModels(): Promise<ProviderModel[]> {
|
||||
const modelCachePath = path.join(os.homedir(), '.codex', 'models_cache.json');
|
||||
let content: string;
|
||||
try {
|
||||
content = await readFile(modelCachePath, 'utf8');
|
||||
} catch (error) {
|
||||
const code = (error as NodeJS.ErrnoException)?.code;
|
||||
if (code === 'ENOENT') {
|
||||
throw new AppError('Codex model cache was not found. Expected ~/.codex/models_cache.json.', {
|
||||
code: 'CODEX_MODEL_CACHE_NOT_FOUND',
|
||||
statusCode: 404,
|
||||
});
|
||||
}
|
||||
|
||||
throw error;
|
||||
}
|
||||
|
||||
const parsed = JSON.parse(content) as { models?: CodexModelCacheEntry[] };
|
||||
|
||||
const models = parsed.models ?? [];
|
||||
return models
|
||||
.filter((entry) => Boolean(entry.slug))
|
||||
.map((entry) => ({
|
||||
value: entry.slug as string,
|
||||
displayName: entry.display_name ?? entry.slug ?? 'unknown',
|
||||
description: entry.description,
|
||||
default: entry.priority === 1,
|
||||
supportsThinkingModes: Boolean(entry.supported_reasoning_levels?.length),
|
||||
supportedThinkingModes: entry.supported_reasoning_levels
|
||||
?.map((level) => level.effort)
|
||||
.filter((effort): effort is string => typeof effort === 'string'),
|
||||
}));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a Codex thread execution and wires abort support.
|
||||
*/
|
||||
protected async createSdkExecution(input: CodexExecutionInput): Promise<{
|
||||
stream: AsyncIterable<unknown>;
|
||||
stop: () => Promise<boolean>;
|
||||
}> {
|
||||
const client = await this.getCodexClient();
|
||||
|
||||
const threadOptions: Record<string, unknown> = {
|
||||
model: input.model,
|
||||
workingDirectory: input.workspacePath,
|
||||
modelReasoningEffort: input.thinkingMode,
|
||||
};
|
||||
|
||||
const thread = input.isResume
|
||||
? client.resumeThread(input.sessionId, threadOptions)
|
||||
: client.startThread(threadOptions);
|
||||
|
||||
const abortController = new AbortController();
|
||||
const promptInput = this.buildPromptInput(input.prompt, input.imagePaths, input.workspacePath);
|
||||
const streamedTurn = await thread.runStreamed(promptInput, {
|
||||
signal: abortController.signal,
|
||||
});
|
||||
|
||||
return {
|
||||
stream: streamedTurn.events,
|
||||
stop: async () => {
|
||||
abortController.abort('Session stop requested');
|
||||
return true;
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a shared Codex SDK client instance for this provider.
|
||||
*/
|
||||
private async getCodexClient(): Promise<CodexSdkClient> {
|
||||
if (!this.codexClientPromise) {
|
||||
this.codexClientPromise = this.loadCodexSdkModule()
|
||||
.then((sdkModule) => new sdkModule.Codex())
|
||||
.catch((error) => {
|
||||
this.codexClientPromise = null;
|
||||
throw error;
|
||||
});
|
||||
}
|
||||
|
||||
return this.codexClientPromise;
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds Codex prompt items. Images are sent as `local_image` entries for SDK-native image support.
|
||||
*/
|
||||
private buildPromptInput(
|
||||
prompt: string,
|
||||
imagePaths?: string[],
|
||||
workspacePath?: string,
|
||||
): string | Array<{ type: 'text'; text: string } | { type: 'local_image'; path: string }> {
|
||||
if (!imagePaths || imagePaths.length === 0) {
|
||||
return prompt;
|
||||
}
|
||||
|
||||
const resolvedImagePaths = imagePaths.map((imagePath) => (
|
||||
path.isAbsolute(imagePath)
|
||||
? imagePath
|
||||
: path.resolve(workspacePath ?? process.cwd(), imagePath)
|
||||
));
|
||||
|
||||
return [
|
||||
{ type: 'text', text: prompt },
|
||||
...resolvedImagePaths.map((resolvedPath) => ({
|
||||
type: 'local_image' as const,
|
||||
path: resolvedPath,
|
||||
})),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Normalizes Codex stream events into the shared event shape.
|
||||
*/
|
||||
protected mapSdkEvent(rawEvent: unknown): ProviderSessionEvent | null {
|
||||
if (typeof rawEvent !== 'object' || rawEvent === null) {
|
||||
return {
|
||||
timestamp: new Date().toISOString(),
|
||||
channel: 'sdk',
|
||||
message: String(rawEvent),
|
||||
};
|
||||
}
|
||||
|
||||
const record = rawEvent as Record<string, unknown>;
|
||||
const message = typeof record.type === 'string' ? record.type : 'codex_event';
|
||||
|
||||
return {
|
||||
timestamp: new Date().toISOString(),
|
||||
channel: 'sdk',
|
||||
message,
|
||||
data: rawEvent,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Dynamically imports the Codex SDK to support environments where it is optional.
|
||||
*/
|
||||
private async loadCodexSdkModule(): Promise<CodexSdkModule> {
|
||||
try {
|
||||
const sdkModule = (await import('@openai/codex-sdk')) as unknown as CodexSdkModule;
|
||||
if (!sdkModule?.Codex) {
|
||||
throw new Error('Codex SDK did not export "Codex".');
|
||||
}
|
||||
return sdkModule;
|
||||
} catch (error) {
|
||||
const message = error instanceof Error ? error.message : 'Failed to import Codex SDK';
|
||||
throw new AppError(`Codex SDK is unavailable: ${message}`, {
|
||||
code: 'CODEX_SDK_UNAVAILABLE',
|
||||
statusCode: 503,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,126 +0,0 @@
|
||||
import spawn from 'cross-spawn';
|
||||
|
||||
import type { IProviderAuthRuntime, ProviderAuthStatus } from '@/modules/ai-runtime/types/index.js';
|
||||
|
||||
const CURSOR_STATUS_TIMEOUT_MS = 5_000;
|
||||
|
||||
/**
|
||||
* Reads auth status from `cursor-agent status`.
|
||||
*/
|
||||
export class CursorAuthRuntime implements IProviderAuthRuntime {
|
||||
async getStatus(): Promise<ProviderAuthStatus> {
|
||||
return new Promise((resolve) => {
|
||||
let completed = false;
|
||||
let childProcess: ReturnType<typeof spawn> | null = null;
|
||||
const timeout = setTimeout(() => {
|
||||
if (completed) {
|
||||
return;
|
||||
}
|
||||
|
||||
completed = true;
|
||||
if (childProcess) {
|
||||
childProcess.kill();
|
||||
}
|
||||
|
||||
resolve({
|
||||
provider: 'cursor',
|
||||
authenticated: false,
|
||||
email: null,
|
||||
method: null,
|
||||
error: 'Command timeout',
|
||||
});
|
||||
}, CURSOR_STATUS_TIMEOUT_MS);
|
||||
|
||||
try {
|
||||
childProcess = spawn('cursor-agent', ['status']);
|
||||
} catch {
|
||||
clearTimeout(timeout);
|
||||
completed = true;
|
||||
resolve({
|
||||
provider: 'cursor',
|
||||
authenticated: false,
|
||||
email: null,
|
||||
method: null,
|
||||
error: 'Cursor CLI not found or not installed',
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
let stdout = '';
|
||||
let stderr = '';
|
||||
|
||||
childProcess.stdout?.on('data', (chunk) => {
|
||||
stdout += chunk.toString();
|
||||
});
|
||||
|
||||
childProcess.stderr?.on('data', (chunk) => {
|
||||
stderr += chunk.toString();
|
||||
});
|
||||
|
||||
childProcess.on('close', (code) => {
|
||||
if (completed) {
|
||||
return;
|
||||
}
|
||||
|
||||
completed = true;
|
||||
clearTimeout(timeout);
|
||||
|
||||
if (code === 0) {
|
||||
const emailMatch = stdout.match(/Logged in as ([a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,})/i);
|
||||
if (emailMatch) {
|
||||
resolve({
|
||||
provider: 'cursor',
|
||||
authenticated: true,
|
||||
email: emailMatch[1],
|
||||
method: null,
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
if (stdout.includes('Logged in')) {
|
||||
resolve({
|
||||
provider: 'cursor',
|
||||
authenticated: true,
|
||||
email: 'Logged in',
|
||||
method: null,
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
resolve({
|
||||
provider: 'cursor',
|
||||
authenticated: false,
|
||||
email: null,
|
||||
method: null,
|
||||
error: 'Not logged in',
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
resolve({
|
||||
provider: 'cursor',
|
||||
authenticated: false,
|
||||
email: null,
|
||||
method: null,
|
||||
error: stderr.trim() || 'Not logged in',
|
||||
});
|
||||
});
|
||||
|
||||
childProcess.on('error', () => {
|
||||
if (completed) {
|
||||
return;
|
||||
}
|
||||
|
||||
completed = true;
|
||||
clearTimeout(timeout);
|
||||
resolve({
|
||||
provider: 'cursor',
|
||||
authenticated: false,
|
||||
email: null,
|
||||
method: null,
|
||||
error: 'Cursor CLI not found or not installed',
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,127 +0,0 @@
|
||||
import os from 'node:os';
|
||||
import path from 'node:path';
|
||||
|
||||
import { AppError } from '@/shared/utils/app-error.js';
|
||||
import type {
|
||||
McpScope,
|
||||
ProviderMcpServer,
|
||||
UpsertProviderMcpServerInput,
|
||||
} from '@/modules/ai-runtime/types/index.js';
|
||||
import { BaseProviderMcpRuntime } from '@/modules/ai-runtime/providers/shared/mcp/base-provider-mcp.runtime.js';
|
||||
import {
|
||||
readJsonConfig,
|
||||
readObjectRecord,
|
||||
readOptionalString,
|
||||
readStringArray,
|
||||
readStringRecord,
|
||||
writeJsonConfig,
|
||||
} from '@/modules/ai-runtime/providers/shared/mcp/mcp-runtime.utils.js';
|
||||
|
||||
/**
|
||||
* Cursor MCP runtime backed by user/project `.cursor/mcp.json`.
|
||||
*/
|
||||
export class CursorMcpRuntime extends BaseProviderMcpRuntime {
|
||||
constructor() {
|
||||
super('cursor', ['user', 'project'], ['stdio', 'http', 'sse']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads Cursor MCP servers from user/project config files.
|
||||
*/
|
||||
protected async readScopedServers(scope: McpScope, workspacePath: string): Promise<Record<string, unknown>> {
|
||||
const filePath = scope === 'user'
|
||||
? path.join(os.homedir(), '.cursor', 'mcp.json')
|
||||
: path.join(workspacePath, '.cursor', 'mcp.json');
|
||||
const config = await readJsonConfig(filePath);
|
||||
return readObjectRecord(config.mcpServers) ?? {};
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes Cursor MCP servers to user/project config files.
|
||||
*/
|
||||
protected async writeScopedServers(
|
||||
scope: McpScope,
|
||||
workspacePath: string,
|
||||
servers: Record<string, unknown>,
|
||||
): Promise<void> {
|
||||
const filePath = scope === 'user'
|
||||
? path.join(os.homedir(), '.cursor', 'mcp.json')
|
||||
: path.join(workspacePath, '.cursor', 'mcp.json');
|
||||
const config = await readJsonConfig(filePath);
|
||||
config.mcpServers = servers;
|
||||
await writeJsonConfig(filePath, config);
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds one Cursor-native server object from the unified input payload.
|
||||
*/
|
||||
protected buildServerConfig(input: UpsertProviderMcpServerInput): Record<string, unknown> {
|
||||
if (input.transport === 'stdio') {
|
||||
if (!input.command?.trim()) {
|
||||
throw new AppError('command is required for stdio MCP servers.', {
|
||||
code: 'MCP_COMMAND_REQUIRED',
|
||||
statusCode: 400,
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
command: input.command,
|
||||
args: input.args ?? [],
|
||||
env: input.env ?? {},
|
||||
cwd: input.cwd,
|
||||
};
|
||||
}
|
||||
|
||||
if (!input.url?.trim()) {
|
||||
throw new AppError('url is required for http/sse MCP servers.', {
|
||||
code: 'MCP_URL_REQUIRED',
|
||||
statusCode: 400,
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
url: input.url,
|
||||
headers: input.headers ?? {},
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Normalizes one Cursor server object.
|
||||
*/
|
||||
protected normalizeServerConfig(
|
||||
scope: McpScope,
|
||||
name: string,
|
||||
rawConfig: unknown,
|
||||
): ProviderMcpServer | null {
|
||||
if (!rawConfig || typeof rawConfig !== 'object') {
|
||||
return null;
|
||||
}
|
||||
|
||||
const config = rawConfig as Record<string, unknown>;
|
||||
if (typeof config.command === 'string') {
|
||||
return {
|
||||
provider: 'cursor',
|
||||
name,
|
||||
scope,
|
||||
transport: 'stdio',
|
||||
command: config.command,
|
||||
args: readStringArray(config.args),
|
||||
env: readStringRecord(config.env),
|
||||
cwd: readOptionalString(config.cwd),
|
||||
};
|
||||
}
|
||||
|
||||
if (typeof config.url === 'string') {
|
||||
return {
|
||||
provider: 'cursor',
|
||||
name,
|
||||
scope,
|
||||
transport: 'http',
|
||||
url: config.url,
|
||||
headers: readStringRecord(config.headers),
|
||||
};
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -1,165 +0,0 @@
|
||||
import crypto from 'node:crypto';
|
||||
import fs from 'node:fs';
|
||||
import os from 'node:os';
|
||||
import path from 'node:path';
|
||||
import readline from 'node:readline';
|
||||
|
||||
import { sessionsDb } from '@/shared/database/repositories/sessions.db.js';
|
||||
import {
|
||||
extractFirstValidJsonlData,
|
||||
findFilesRecursivelyCreatedAfter,
|
||||
listDirectoryEntriesSafe,
|
||||
normalizeSessionName,
|
||||
readFileTimestamps,
|
||||
} from '@/modules/ai-runtime/providers/shared/session-synchronizer/session-synchronizer.utils.js';
|
||||
import type { IProviderSessionSynchronizerRuntime } from '@/modules/ai-runtime/types/index.js';
|
||||
|
||||
type ParsedSession = {
|
||||
sessionId: string;
|
||||
workspacePath: string;
|
||||
sessionName?: string;
|
||||
};
|
||||
|
||||
/**
|
||||
* Session indexer for Cursor transcript artifacts.
|
||||
*/
|
||||
export class CursorSessionSynchronizerRuntime implements IProviderSessionSynchronizerRuntime {
|
||||
private readonly provider = 'cursor' as const;
|
||||
private readonly cursorHome = path.join(os.homedir(), '.cursor');
|
||||
|
||||
/**
|
||||
* Scans Cursor chats and upserts discovered sessions into DB.
|
||||
*/
|
||||
async synchronize(since?: Date): Promise<number> {
|
||||
const projectsDir = path.join(this.cursorHome, 'projects');
|
||||
const projectEntries = await listDirectoryEntriesSafe(projectsDir);
|
||||
const seenWorkspacePaths = new Set<string>();
|
||||
|
||||
let processed = 0;
|
||||
for (const entry of projectEntries) {
|
||||
if (!entry.isDirectory()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const workerLogPath = path.join(projectsDir, entry.name, 'worker.log');
|
||||
const workspacePath = await this.extractWorkspacePathFromWorkerLog(workerLogPath);
|
||||
if (!workspacePath || seenWorkspacePaths.has(workspacePath)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
seenWorkspacePaths.add(workspacePath);
|
||||
const workspaceHash = this.md5(workspacePath);
|
||||
const chatsDir = path.join(this.cursorHome, 'chats', workspaceHash);
|
||||
const files = await findFilesRecursivelyCreatedAfter(chatsDir, '.jsonl', since ?? null);
|
||||
|
||||
for (const filePath of files) {
|
||||
const parsed = await this.processSessionFile(filePath);
|
||||
if (!parsed) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const timestamps = await readFileTimestamps(filePath);
|
||||
sessionsDb.createSession(
|
||||
parsed.sessionId,
|
||||
this.provider,
|
||||
parsed.workspacePath,
|
||||
parsed.sessionName,
|
||||
timestamps.createdAt,
|
||||
timestamps.updatedAt,
|
||||
filePath,
|
||||
);
|
||||
processed += 1;
|
||||
}
|
||||
}
|
||||
|
||||
return processed;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses and upserts one Cursor session JSONL file.
|
||||
*/
|
||||
async synchronizeFile(filePath: string): Promise<boolean> {
|
||||
if (!filePath.endsWith('.jsonl')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const parsed = await this.processSessionFile(filePath);
|
||||
if (!parsed) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const timestamps = await readFileTimestamps(filePath);
|
||||
sessionsDb.createSession(
|
||||
parsed.sessionId,
|
||||
this.provider,
|
||||
parsed.workspacePath,
|
||||
parsed.sessionName,
|
||||
timestamps.createdAt,
|
||||
timestamps.updatedAt,
|
||||
filePath,
|
||||
);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Produces the same workspace hash Cursor uses in chat directory names.
|
||||
*/
|
||||
private md5(input: string): string {
|
||||
return crypto.createHash('md5').update(input).digest('hex');
|
||||
}
|
||||
|
||||
/**
|
||||
* Extracts workspace path from Cursor worker.log.
|
||||
*/
|
||||
private async extractWorkspacePathFromWorkerLog(filePath: string): Promise<string | null> {
|
||||
try {
|
||||
const fileStream = fs.createReadStream(filePath, { encoding: 'utf8' });
|
||||
const lineReader = readline.createInterface({ input: fileStream, crlfDelay: Infinity });
|
||||
|
||||
for await (const line of lineReader) {
|
||||
const match = line.match(/workspacePath=(.*)$/);
|
||||
const workspacePath = match?.[1]?.trim();
|
||||
if (workspacePath) {
|
||||
lineReader.close();
|
||||
fileStream.close();
|
||||
return workspacePath;
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
// Missing worker logs are valid for partial/incomplete session data.
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extracts session metadata from one Cursor JSONL session file.
|
||||
*/
|
||||
private async processSessionFile(filePath: string): Promise<ParsedSession | null> {
|
||||
const sessionId = path.basename(filePath, '.jsonl');
|
||||
const grandparentDir = path.dirname(path.dirname(filePath));
|
||||
const workerLogPath = path.join(grandparentDir, 'worker.log');
|
||||
const workspacePath = await this.extractWorkspacePathFromWorkerLog(workerLogPath);
|
||||
|
||||
if (!workspacePath) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return extractFirstValidJsonlData(filePath, (rawData) => {
|
||||
const data = rawData as Record<string, any>;
|
||||
if (data.role !== 'user') {
|
||||
return null;
|
||||
}
|
||||
|
||||
const text = typeof data.message?.content?.[0]?.text === 'string' ? data.message.content[0].text : '';
|
||||
const firstLine = text.replace(/<\/?user_query>/g, '').trim().split('\n')[0];
|
||||
|
||||
return {
|
||||
sessionId,
|
||||
workspacePath,
|
||||
sessionName: normalizeSessionName(firstLine, 'Untitled Cursor Session'),
|
||||
};
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
import os from 'node:os';
|
||||
import path from 'node:path';
|
||||
|
||||
import type { IProviderSkillsRuntime, ProviderSkill, ProviderSkillScope } from '@/modules/ai-runtime/types/index.js';
|
||||
import {
|
||||
deduplicateDirectories,
|
||||
deduplicateSkills,
|
||||
listSkillsFromDirectory,
|
||||
} from '@/modules/ai-runtime/providers/shared/skills/skills-runtime.utils.js';
|
||||
|
||||
/**
|
||||
* Cursor skills runtime backed by user/project skill directories.
|
||||
*/
|
||||
export class CursorSkillsRuntime implements IProviderSkillsRuntime {
|
||||
/**
|
||||
* Lists all available Cursor skills from documented directories.
|
||||
*/
|
||||
async listSkills(options?: { workspacePath?: string }): Promise<ProviderSkill[]> {
|
||||
const workspacePath = path.resolve(options?.workspacePath ?? process.cwd());
|
||||
const home = os.homedir();
|
||||
const candidateDirectories: Array<{ scope: ProviderSkillScope; directory: string }> = [
|
||||
{ scope: 'project', directory: path.join(workspacePath, '.agents', 'skills') },
|
||||
{ scope: 'project', directory: path.join(workspacePath, '.cursor', 'skills') },
|
||||
{ scope: 'user', directory: path.join(home, '.cursor', 'skills') },
|
||||
];
|
||||
|
||||
const skills: ProviderSkill[] = [];
|
||||
for (const candidate of deduplicateDirectories(candidateDirectories)) {
|
||||
const loadedSkills = await listSkillsFromDirectory({
|
||||
provider: 'cursor',
|
||||
scope: candidate.scope,
|
||||
skillsDirectory: candidate.directory,
|
||||
invocationPrefix: '/',
|
||||
});
|
||||
skills.push(...loadedSkills);
|
||||
}
|
||||
|
||||
return deduplicateSkills(skills);
|
||||
}
|
||||
}
|
||||
@@ -1,137 +0,0 @@
|
||||
import { BaseCliProvider } from '@/modules/ai-runtime/providers/base/base-cli.provider.js';
|
||||
import type {
|
||||
IProviderAuthRuntime,
|
||||
IProviderMcpRuntime,
|
||||
IProviderSessionSynchronizerRuntime,
|
||||
IProviderSkillsRuntime,
|
||||
ProviderModel,
|
||||
StartSessionInput,
|
||||
} from '@/modules/ai-runtime/types/index.js';
|
||||
import { CursorMcpRuntime } from '@/modules/ai-runtime/providers/cursor/cursor-mcp.runtime.js';
|
||||
import { CursorAuthRuntime } from '@/modules/ai-runtime/providers/cursor/cursor-auth.runtime.js';
|
||||
import { CursorSkillsRuntime } from '@/modules/ai-runtime/providers/cursor/cursor-skills.runtime.js';
|
||||
import { CursorSessionSynchronizerRuntime } from '@/modules/ai-runtime/providers/cursor/cursor-session-synchronizer.runtime.js';
|
||||
|
||||
type CursorExecutionInput = StartSessionInput & {
|
||||
sessionId: string;
|
||||
isResume: boolean;
|
||||
};
|
||||
|
||||
const ANSI_REGEX =
|
||||
// biome-ignore lint/suspicious/noControlCharactersInRegex: ANSI escape stripping.
|
||||
/\u001b\[[0-9;]*m/g;
|
||||
|
||||
/**
|
||||
* Cursor CLI provider implementation.
|
||||
*/
|
||||
export class CursorProvider extends BaseCliProvider {
|
||||
readonly auth: IProviderAuthRuntime = new CursorAuthRuntime();
|
||||
readonly mcp: IProviderMcpRuntime = new CursorMcpRuntime();
|
||||
readonly skills: IProviderSkillsRuntime = new CursorSkillsRuntime();
|
||||
readonly sessionSynchronizer: IProviderSessionSynchronizerRuntime = new CursorSessionSynchronizerRuntime();
|
||||
|
||||
constructor() {
|
||||
super('cursor', {
|
||||
supportsRuntimePermissionRequests: false,
|
||||
supportsThinkingModeControl: false,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Lists cursor models by parsing `cursor-agent --list-models`.
|
||||
*/
|
||||
async listModels(): Promise<ProviderModel[]> {
|
||||
const output = await this.runCommandForOutput('cursor-agent', ['--list-models']);
|
||||
return this.parseModelsOutput(output);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the command invocation for cursor start/resume flows.
|
||||
*/
|
||||
protected createCliInvocation(input: CursorExecutionInput): {
|
||||
command: string;
|
||||
args: string[];
|
||||
cwd?: string;
|
||||
} {
|
||||
const promptWithImagePaths = this.appendImagePathsToPrompt(input.prompt, input.imagePaths);
|
||||
const args = ['--print', '--trust', '--output-format', 'stream-json'];
|
||||
|
||||
if (input.allowYolo) {
|
||||
args.push('--yolo');
|
||||
}
|
||||
|
||||
if (input.model) {
|
||||
args.push('--model', input.model);
|
||||
}
|
||||
|
||||
if (input.isResume) {
|
||||
args.push('--resume', input.sessionId);
|
||||
}
|
||||
|
||||
args.push(promptWithImagePaths);
|
||||
|
||||
return {
|
||||
command: 'cursor-agent',
|
||||
args,
|
||||
cwd: input.workspacePath,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses full model-list output into normalized model entries.
|
||||
*/
|
||||
private parseModelsOutput(output: string): ProviderModel[] {
|
||||
const models: ProviderModel[] = [];
|
||||
const lines = output.replace(ANSI_REGEX, '').split(/\r?\n/);
|
||||
|
||||
for (const line of lines) {
|
||||
const parsed = this.parseModelLine(line);
|
||||
if (!parsed) {
|
||||
continue;
|
||||
}
|
||||
models.push(parsed);
|
||||
}
|
||||
|
||||
return models;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses one cursor model line.
|
||||
*/
|
||||
private parseModelLine(line: string): ProviderModel | null {
|
||||
const trimmed = line.trim();
|
||||
if (
|
||||
!trimmed ||
|
||||
trimmed === 'Available models' ||
|
||||
trimmed.startsWith('Loading models') ||
|
||||
trimmed.startsWith('Tip:')
|
||||
) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const match = trimmed.match(/^(.+?)\s+-\s+(.+)$/);
|
||||
if (!match) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const value = match[1].trim();
|
||||
const descriptionRaw = match[2].trim();
|
||||
|
||||
const current = /\(current\)/i.test(descriptionRaw);
|
||||
const defaultModel = /\(default\)/i.test(descriptionRaw);
|
||||
const description = descriptionRaw
|
||||
.replace(/\s*\((current|default)\)/gi, '')
|
||||
.replace(/\s{2,}/g, ' ')
|
||||
.trim();
|
||||
|
||||
return {
|
||||
value,
|
||||
displayName: value,
|
||||
description,
|
||||
current,
|
||||
default: defaultModel,
|
||||
supportsThinkingModes: false,
|
||||
supportedThinkingModes: [],
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1,115 +0,0 @@
|
||||
import os from 'node:os';
|
||||
import path from 'node:path';
|
||||
import { readFile } from 'node:fs/promises';
|
||||
|
||||
import type { IProviderAuthRuntime, ProviderAuthStatus } from '@/modules/ai-runtime/types/index.js';
|
||||
|
||||
type GeminiOauthCreds = {
|
||||
access_token?: string;
|
||||
refresh_token?: string;
|
||||
};
|
||||
|
||||
/**
|
||||
* Reads auth status from env and Gemini OAuth files.
|
||||
*/
|
||||
export class GeminiAuthRuntime implements IProviderAuthRuntime {
|
||||
async getStatus(): Promise<ProviderAuthStatus> {
|
||||
if (process.env.GEMINI_API_KEY?.trim()) {
|
||||
return {
|
||||
provider: 'gemini',
|
||||
authenticated: true,
|
||||
email: 'API Key Auth',
|
||||
method: 'api_key',
|
||||
};
|
||||
}
|
||||
|
||||
try {
|
||||
const credsPath = path.join(os.homedir(), '.gemini', 'oauth_creds.json');
|
||||
const content = await readFile(credsPath, 'utf8');
|
||||
const creds = JSON.parse(content) as GeminiOauthCreds;
|
||||
if (!creds.access_token) {
|
||||
return {
|
||||
provider: 'gemini',
|
||||
authenticated: false,
|
||||
email: null,
|
||||
method: null,
|
||||
error: 'No valid tokens found in oauth_creds',
|
||||
};
|
||||
}
|
||||
|
||||
const validated = await this.resolveEmailFromAccessToken(creds.access_token);
|
||||
if (validated.email) {
|
||||
return {
|
||||
provider: 'gemini',
|
||||
authenticated: true,
|
||||
email: validated.email,
|
||||
method: 'oauth',
|
||||
};
|
||||
}
|
||||
|
||||
if (!validated.tokenValid && !creds.refresh_token) {
|
||||
return {
|
||||
provider: 'gemini',
|
||||
authenticated: false,
|
||||
email: null,
|
||||
method: null,
|
||||
error: 'Access token invalid and no refresh token found',
|
||||
};
|
||||
}
|
||||
|
||||
const fallbackEmail = await this.readActiveGoogleAccountEmail();
|
||||
return {
|
||||
provider: 'gemini',
|
||||
authenticated: true,
|
||||
email: fallbackEmail ?? 'OAuth Session',
|
||||
method: 'oauth',
|
||||
};
|
||||
} catch {
|
||||
return {
|
||||
provider: 'gemini',
|
||||
authenticated: false,
|
||||
email: null,
|
||||
method: null,
|
||||
error: 'Gemini CLI not configured',
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates token and extracts email via Google's tokeninfo endpoint.
|
||||
*/
|
||||
private async resolveEmailFromAccessToken(
|
||||
accessToken: string,
|
||||
): Promise<{ tokenValid: boolean; email: string | null }> {
|
||||
try {
|
||||
const response = await fetch(`https://oauth2.googleapis.com/tokeninfo?access_token=${accessToken}`);
|
||||
if (!response.ok) {
|
||||
return { tokenValid: false, email: null };
|
||||
}
|
||||
|
||||
const tokenInfo = await response.json() as { email?: string };
|
||||
return {
|
||||
tokenValid: true,
|
||||
email: tokenInfo.email ?? null,
|
||||
};
|
||||
} catch {
|
||||
return { tokenValid: false, email: null };
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads active Google account email from ~/.gemini/google_accounts.json.
|
||||
*/
|
||||
private async readActiveGoogleAccountEmail(): Promise<string | null> {
|
||||
try {
|
||||
const accountsPath = path.join(os.homedir(), '.gemini', 'google_accounts.json');
|
||||
const content = await readFile(accountsPath, 'utf8');
|
||||
const accounts = JSON.parse(content) as { active?: string };
|
||||
return typeof accounts.active === 'string' && accounts.active.trim()
|
||||
? accounts.active
|
||||
: null;
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,129 +0,0 @@
|
||||
import os from 'node:os';
|
||||
import path from 'node:path';
|
||||
|
||||
import { AppError } from '@/shared/utils/app-error.js';
|
||||
import type {
|
||||
McpScope,
|
||||
ProviderMcpServer,
|
||||
UpsertProviderMcpServerInput,
|
||||
} from '@/modules/ai-runtime/types/index.js';
|
||||
import { BaseProviderMcpRuntime } from '@/modules/ai-runtime/providers/shared/mcp/base-provider-mcp.runtime.js';
|
||||
import {
|
||||
readJsonConfig,
|
||||
readObjectRecord,
|
||||
readOptionalString,
|
||||
readStringArray,
|
||||
readStringRecord,
|
||||
writeJsonConfig,
|
||||
} from '@/modules/ai-runtime/providers/shared/mcp/mcp-runtime.utils.js';
|
||||
|
||||
/**
|
||||
* Gemini MCP runtime backed by user/project `.gemini/settings.json`.
|
||||
*/
|
||||
export class GeminiMcpRuntime extends BaseProviderMcpRuntime {
|
||||
constructor() {
|
||||
super('gemini', ['user', 'project'], ['stdio', 'http', 'sse']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads Gemini MCP servers from user/project config files.
|
||||
*/
|
||||
protected async readScopedServers(scope: McpScope, workspacePath: string): Promise<Record<string, unknown>> {
|
||||
const filePath = scope === 'user'
|
||||
? path.join(os.homedir(), '.gemini', 'settings.json')
|
||||
: path.join(workspacePath, '.gemini', 'settings.json');
|
||||
const config = await readJsonConfig(filePath);
|
||||
return readObjectRecord(config.mcpServers) ?? {};
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes Gemini MCP servers to user/project config files.
|
||||
*/
|
||||
protected async writeScopedServers(
|
||||
scope: McpScope,
|
||||
workspacePath: string,
|
||||
servers: Record<string, unknown>,
|
||||
): Promise<void> {
|
||||
const filePath = scope === 'user'
|
||||
? path.join(os.homedir(), '.gemini', 'settings.json')
|
||||
: path.join(workspacePath, '.gemini', 'settings.json');
|
||||
const config = await readJsonConfig(filePath);
|
||||
config.mcpServers = servers;
|
||||
await writeJsonConfig(filePath, config);
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds one Gemini-native server object from the unified input payload.
|
||||
*/
|
||||
protected buildServerConfig(input: UpsertProviderMcpServerInput): Record<string, unknown> {
|
||||
if (input.transport === 'stdio') {
|
||||
if (!input.command?.trim()) {
|
||||
throw new AppError('command is required for stdio MCP servers.', {
|
||||
code: 'MCP_COMMAND_REQUIRED',
|
||||
statusCode: 400,
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
command: input.command,
|
||||
args: input.args ?? [],
|
||||
env: input.env ?? {},
|
||||
cwd: input.cwd,
|
||||
};
|
||||
}
|
||||
|
||||
if (!input.url?.trim()) {
|
||||
throw new AppError('url is required for http/sse MCP servers.', {
|
||||
code: 'MCP_URL_REQUIRED',
|
||||
statusCode: 400,
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
type: input.transport,
|
||||
url: input.url,
|
||||
headers: input.headers ?? {},
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Normalizes one Gemini server object.
|
||||
*/
|
||||
protected normalizeServerConfig(
|
||||
scope: McpScope,
|
||||
name: string,
|
||||
rawConfig: unknown,
|
||||
): ProviderMcpServer | null {
|
||||
if (!rawConfig || typeof rawConfig !== 'object') {
|
||||
return null;
|
||||
}
|
||||
|
||||
const config = rawConfig as Record<string, unknown>;
|
||||
if (typeof config.command === 'string') {
|
||||
return {
|
||||
provider: 'gemini',
|
||||
name,
|
||||
scope,
|
||||
transport: 'stdio',
|
||||
command: config.command,
|
||||
args: readStringArray(config.args),
|
||||
env: readStringRecord(config.env),
|
||||
cwd: readOptionalString(config.cwd),
|
||||
};
|
||||
}
|
||||
|
||||
if (typeof config.url === 'string') {
|
||||
const transport = readOptionalString(config.type) === 'sse' ? 'sse' : 'http';
|
||||
return {
|
||||
provider: 'gemini',
|
||||
name,
|
||||
scope,
|
||||
transport,
|
||||
url: config.url,
|
||||
headers: readStringRecord(config.headers),
|
||||
};
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -1,162 +0,0 @@
|
||||
import os from 'node:os';
|
||||
import path from 'node:path';
|
||||
import { readFile } from 'node:fs/promises';
|
||||
|
||||
import { sessionsDb } from '@/shared/database/repositories/sessions.db.js';
|
||||
import {
|
||||
findFilesRecursivelyCreatedAfter,
|
||||
normalizeSessionName,
|
||||
readFileTimestamps,
|
||||
} from '@/modules/ai-runtime/providers/shared/session-synchronizer/session-synchronizer.utils.js';
|
||||
import type { IProviderSessionSynchronizerRuntime } from '@/modules/ai-runtime/types/index.js';
|
||||
|
||||
type ParsedSession = {
|
||||
sessionId: string;
|
||||
workspacePath: string;
|
||||
sessionName?: string;
|
||||
};
|
||||
|
||||
/**
|
||||
* Session indexer for Gemini transcript artifacts.
|
||||
*/
|
||||
export class GeminiSessionSynchronizerRuntime implements IProviderSessionSynchronizerRuntime {
|
||||
private readonly provider = 'gemini' as const;
|
||||
private readonly geminiHome = path.join(os.homedir(), '.gemini');
|
||||
|
||||
/**
|
||||
* Scans Gemini session JSON files and upserts discovered sessions into DB.
|
||||
*/
|
||||
async synchronize(since?: Date): Promise<number> {
|
||||
const legacySessionFiles = await findFilesRecursivelyCreatedAfter(
|
||||
path.join(this.geminiHome, 'sessions'),
|
||||
'.json',
|
||||
since ?? null,
|
||||
);
|
||||
const tempFiles = await findFilesRecursivelyCreatedAfter(
|
||||
path.join(this.geminiHome, 'tmp'),
|
||||
'.json',
|
||||
since ?? null,
|
||||
);
|
||||
const files = [...legacySessionFiles, ...tempFiles];
|
||||
|
||||
let processed = 0;
|
||||
for (const filePath of files) {
|
||||
if (
|
||||
filePath.startsWith(path.join(this.geminiHome, 'tmp')) &&
|
||||
!filePath.includes(`${path.sep}chats${path.sep}`)
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const parsed = await this.processSessionFile(filePath);
|
||||
if (!parsed) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const timestamps = await readFileTimestamps(filePath);
|
||||
sessionsDb.createSession(
|
||||
parsed.sessionId,
|
||||
this.provider,
|
||||
parsed.workspacePath,
|
||||
parsed.sessionName,
|
||||
timestamps.createdAt,
|
||||
timestamps.updatedAt,
|
||||
filePath,
|
||||
);
|
||||
processed += 1;
|
||||
}
|
||||
|
||||
return processed;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses and upserts one Gemini session JSON file.
|
||||
*/
|
||||
async synchronizeFile(filePath: string): Promise<boolean> {
|
||||
if (!filePath.endsWith('.json')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (
|
||||
filePath.startsWith(path.join(this.geminiHome, 'tmp')) &&
|
||||
!filePath.includes(`${path.sep}chats${path.sep}`)
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const parsed = await this.processSessionFile(filePath);
|
||||
if (!parsed) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const timestamps = await readFileTimestamps(filePath);
|
||||
sessionsDb.createSession(
|
||||
parsed.sessionId,
|
||||
this.provider,
|
||||
parsed.workspacePath,
|
||||
parsed.sessionName,
|
||||
timestamps.createdAt,
|
||||
timestamps.updatedAt,
|
||||
filePath,
|
||||
);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extracts session metadata from one Gemini JSON artifact.
|
||||
*/
|
||||
private async processSessionFile(filePath: string): Promise<ParsedSession | null> {
|
||||
try {
|
||||
const content = await readFile(filePath, 'utf8');
|
||||
const data = JSON.parse(content) as Record<string, any>;
|
||||
|
||||
const sessionId =
|
||||
typeof data.sessionId === 'string'
|
||||
? data.sessionId
|
||||
: typeof data.id === 'string'
|
||||
? data.id
|
||||
: undefined;
|
||||
if (!sessionId) {
|
||||
return null;
|
||||
}
|
||||
|
||||
let workspacePath = typeof data.projectPath === 'string' ? data.projectPath : '';
|
||||
|
||||
if (!workspacePath && filePath.includes(`${path.sep}chats${path.sep}`)) {
|
||||
const chatsDir = path.dirname(filePath);
|
||||
const workspaceDir = path.dirname(chatsDir);
|
||||
const projectRootPath = path.join(workspaceDir, '.project_root');
|
||||
|
||||
try {
|
||||
const rootContent = await readFile(projectRootPath, 'utf8');
|
||||
workspacePath = rootContent.trim();
|
||||
} catch {
|
||||
// Some Gemini artifacts do not ship a .project_root marker.
|
||||
}
|
||||
}
|
||||
|
||||
if (!workspacePath) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const messages = Array.isArray(data.messages) ? data.messages : [];
|
||||
const firstMessage = messages[0] as Record<string, any> | undefined;
|
||||
let rawName: string | undefined;
|
||||
|
||||
if (Array.isArray(firstMessage?.content) && typeof firstMessage.content[0]?.text === 'string') {
|
||||
rawName = firstMessage.content[0].text;
|
||||
} else if (typeof firstMessage?.content === 'string') {
|
||||
rawName = firstMessage.content;
|
||||
}
|
||||
|
||||
return {
|
||||
sessionId,
|
||||
workspacePath,
|
||||
sessionName: normalizeSessionName(rawName, 'New Gemini Chat'),
|
||||
};
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
import os from 'node:os';
|
||||
import path from 'node:path';
|
||||
|
||||
import type { IProviderSkillsRuntime, ProviderSkill, ProviderSkillScope } from '@/modules/ai-runtime/types/index.js';
|
||||
import {
|
||||
deduplicateDirectories,
|
||||
deduplicateSkills,
|
||||
listSkillsFromDirectory,
|
||||
} from '@/modules/ai-runtime/providers/shared/skills/skills-runtime.utils.js';
|
||||
|
||||
/**
|
||||
* Gemini skills runtime backed by user/project skill directories.
|
||||
*/
|
||||
export class GeminiSkillsRuntime implements IProviderSkillsRuntime {
|
||||
/**
|
||||
* Lists all available Gemini skills from documented directories.
|
||||
*/
|
||||
async listSkills(options?: { workspacePath?: string }): Promise<ProviderSkill[]> {
|
||||
const workspacePath = path.resolve(options?.workspacePath ?? process.cwd());
|
||||
const home = os.homedir();
|
||||
const candidateDirectories: Array<{ scope: ProviderSkillScope; directory: string }> = [
|
||||
{ scope: 'user', directory: path.join(home, '.gemini', 'skills') },
|
||||
{ scope: 'user', directory: path.join(home, '.agents', 'skills') },
|
||||
{ scope: 'project', directory: path.join(workspacePath, '.gemini', 'skills') },
|
||||
{ scope: 'project', directory: path.join(workspacePath, '.agents', 'skills') },
|
||||
];
|
||||
|
||||
const skills: ProviderSkill[] = [];
|
||||
for (const candidate of deduplicateDirectories(candidateDirectories)) {
|
||||
const loadedSkills = await listSkillsFromDirectory({
|
||||
provider: 'gemini',
|
||||
scope: candidate.scope,
|
||||
skillsDirectory: candidate.directory,
|
||||
invocationPrefix: '/',
|
||||
});
|
||||
skills.push(...loadedSkills);
|
||||
}
|
||||
|
||||
return deduplicateSkills(skills);
|
||||
}
|
||||
}
|
||||
@@ -1,80 +0,0 @@
|
||||
import { BaseCliProvider } from '@/modules/ai-runtime/providers/base/base-cli.provider.js';
|
||||
import type {
|
||||
IProviderAuthRuntime,
|
||||
IProviderMcpRuntime,
|
||||
IProviderSessionSynchronizerRuntime,
|
||||
IProviderSkillsRuntime,
|
||||
ProviderModel,
|
||||
StartSessionInput,
|
||||
} from '@/modules/ai-runtime/types/index.js';
|
||||
import { GeminiMcpRuntime } from '@/modules/ai-runtime/providers/gemini/gemini-mcp.runtime.js';
|
||||
import { GeminiAuthRuntime } from '@/modules/ai-runtime/providers/gemini/gemini-auth.runtime.js';
|
||||
import { GeminiSkillsRuntime } from '@/modules/ai-runtime/providers/gemini/gemini-skills.runtime.js';
|
||||
import { GeminiSessionSynchronizerRuntime } from '@/modules/ai-runtime/providers/gemini/gemini-session-synchronizer.runtime.js';
|
||||
|
||||
type GeminiExecutionInput = StartSessionInput & {
|
||||
sessionId: string;
|
||||
isResume: boolean;
|
||||
};
|
||||
|
||||
const GEMINI_MODELS: ProviderModel[] = [
|
||||
{ value: 'gemini-3.1-pro-preview', displayName: 'Gemini 3.1 Pro Preview' },
|
||||
{ value: 'gemini-3-pro-preview', displayName: 'Gemini 3 Pro Preview' },
|
||||
{ value: 'gemini-3-flash-preview', displayName: 'Gemini 3 Flash Preview' },
|
||||
{ value: 'gemini-2.5-flash', displayName: 'Gemini 2.5 Flash' },
|
||||
{ value: 'gemini-2.5-pro', displayName: 'Gemini 2.5 Pro' },
|
||||
{ value: 'gemini-2.0-flash-lite', displayName: 'Gemini 2.0 Flash Lite' },
|
||||
{ value: 'gemini-2.0-flash', displayName: 'Gemini 2.0 Flash' },
|
||||
{ value: 'gemini-2.0-pro-exp', displayName: 'Gemini 2.0 Pro Experimental' },
|
||||
{ value: 'gemini-2.0-flash-thinking-exp', displayName: 'Gemini 2.0 Flash Thinking' },
|
||||
];
|
||||
|
||||
/**
|
||||
* Gemini CLI provider implementation.
|
||||
*/
|
||||
export class GeminiProvider extends BaseCliProvider {
|
||||
readonly auth: IProviderAuthRuntime = new GeminiAuthRuntime();
|
||||
readonly mcp: IProviderMcpRuntime = new GeminiMcpRuntime();
|
||||
readonly skills: IProviderSkillsRuntime = new GeminiSkillsRuntime();
|
||||
readonly sessionSynchronizer: IProviderSessionSynchronizerRuntime = new GeminiSessionSynchronizerRuntime();
|
||||
|
||||
constructor() {
|
||||
super('gemini', {
|
||||
supportsRuntimePermissionRequests: false,
|
||||
supportsThinkingModeControl: false,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns curated Gemini model options from the refactor doc.
|
||||
*/
|
||||
async listModels(): Promise<ProviderModel[]> {
|
||||
return GEMINI_MODELS;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the command invocation for gemini start/resume flows.
|
||||
*/
|
||||
protected createCliInvocation(input: GeminiExecutionInput): {
|
||||
command: string;
|
||||
args: string[];
|
||||
cwd?: string;
|
||||
} {
|
||||
const promptWithImagePaths = this.appendImagePathsToPrompt(input.prompt, input.imagePaths);
|
||||
const args = ['--prompt', promptWithImagePaths, '--output-format', 'stream-json'];
|
||||
|
||||
if (input.model) {
|
||||
args.push('--model', input.model);
|
||||
}
|
||||
|
||||
if (input.isResume) {
|
||||
args.push('--resume', input.sessionId);
|
||||
}
|
||||
|
||||
return {
|
||||
command: 'gemini',
|
||||
args,
|
||||
cwd: input.workspacePath,
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
export * from '@/modules/ai-runtime/types/index.js';
|
||||
@@ -1,236 +0,0 @@
|
||||
import type { LLMProvider } from '@/shared/types/app.js';
|
||||
import { AppError } from '@/shared/utils/app-error.js';
|
||||
import type {
|
||||
IProviderMcpRuntime,
|
||||
McpScope,
|
||||
McpTransport,
|
||||
ProviderMcpServer,
|
||||
UpsertProviderMcpServerInput,
|
||||
} from '@/modules/ai-runtime/types/index.js';
|
||||
import {
|
||||
normalizeServerName,
|
||||
resolveWorkspacePath,
|
||||
runHttpServerProbe,
|
||||
runStdioServerProbe,
|
||||
} from '@/modules/ai-runtime/providers/shared/mcp/mcp-runtime.utils.js';
|
||||
|
||||
/**
|
||||
* Shared MCP runtime for provider-specific config readers/writers.
|
||||
*/
|
||||
export abstract class BaseProviderMcpRuntime implements IProviderMcpRuntime {
|
||||
protected readonly provider: LLMProvider;
|
||||
protected readonly supportedScopes: McpScope[];
|
||||
protected readonly supportedTransports: McpTransport[];
|
||||
|
||||
protected constructor(
|
||||
provider: LLMProvider,
|
||||
supportedScopes: McpScope[],
|
||||
supportedTransports: McpTransport[],
|
||||
) {
|
||||
this.provider = provider;
|
||||
this.supportedScopes = supportedScopes;
|
||||
this.supportedTransports = supportedTransports;
|
||||
}
|
||||
|
||||
/**
|
||||
* Lists MCP servers grouped by user/local/project scopes.
|
||||
*/
|
||||
async listServers(options?: { workspacePath?: string }): Promise<Record<McpScope, ProviderMcpServer[]>> {
|
||||
const grouped: Record<McpScope, ProviderMcpServer[]> = {
|
||||
user: [],
|
||||
local: [],
|
||||
project: [],
|
||||
};
|
||||
|
||||
for (const scope of this.supportedScopes) {
|
||||
grouped[scope] = await this.listServersForScope(scope, options);
|
||||
}
|
||||
|
||||
return grouped;
|
||||
}
|
||||
|
||||
/**
|
||||
* Lists MCP servers for one scope.
|
||||
*/
|
||||
async listServersForScope(
|
||||
scope: McpScope,
|
||||
options?: { workspacePath?: string },
|
||||
): Promise<ProviderMcpServer[]> {
|
||||
if (!this.supportedScopes.includes(scope)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
const workspacePath = resolveWorkspacePath(options?.workspacePath);
|
||||
const scopedServers = await this.readScopedServers(scope, workspacePath);
|
||||
return Object.entries(scopedServers)
|
||||
.map(([name, rawConfig]) => this.normalizeServerConfig(scope, name, rawConfig))
|
||||
.filter((entry): entry is ProviderMcpServer => entry !== null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds or updates one MCP server.
|
||||
*/
|
||||
async upsertServer(input: UpsertProviderMcpServerInput): Promise<ProviderMcpServer> {
|
||||
const scope = input.scope ?? 'project';
|
||||
this.assertScopeAndTransport(scope, input.transport);
|
||||
|
||||
const workspacePath = resolveWorkspacePath(input.workspacePath);
|
||||
const normalizedName = normalizeServerName(input.name);
|
||||
const scopedServers = await this.readScopedServers(scope, workspacePath);
|
||||
scopedServers[normalizedName] = this.buildServerConfig(input);
|
||||
await this.writeScopedServers(scope, workspacePath, scopedServers);
|
||||
|
||||
return {
|
||||
provider: this.provider,
|
||||
name: normalizedName,
|
||||
scope,
|
||||
transport: input.transport,
|
||||
command: input.command,
|
||||
args: input.args,
|
||||
env: input.env,
|
||||
cwd: input.cwd,
|
||||
url: input.url,
|
||||
headers: input.headers,
|
||||
envVars: input.envVars,
|
||||
bearerTokenEnvVar: input.bearerTokenEnvVar,
|
||||
envHttpHeaders: input.envHttpHeaders,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes one MCP server for the selected scope.
|
||||
*/
|
||||
async removeServer(
|
||||
input: { name: string; scope?: McpScope; workspacePath?: string },
|
||||
): Promise<{ removed: boolean; provider: LLMProvider; name: string; scope: McpScope }> {
|
||||
const scope = input.scope ?? 'project';
|
||||
this.assertScope(scope);
|
||||
|
||||
const workspacePath = resolveWorkspacePath(input.workspacePath);
|
||||
const normalizedName = normalizeServerName(input.name);
|
||||
const scopedServers = await this.readScopedServers(scope, workspacePath);
|
||||
const removed = Object.prototype.hasOwnProperty.call(scopedServers, normalizedName);
|
||||
if (removed) {
|
||||
delete scopedServers[normalizedName];
|
||||
await this.writeScopedServers(scope, workspacePath, scopedServers);
|
||||
}
|
||||
|
||||
return { removed, provider: this.provider, name: normalizedName, scope };
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes a lightweight startup/connectivity probe for one configured MCP server.
|
||||
*/
|
||||
async runServer(
|
||||
input: { name: string; scope?: McpScope; workspacePath?: string },
|
||||
): Promise<{
|
||||
provider: LLMProvider;
|
||||
name: string;
|
||||
scope: McpScope;
|
||||
transport: McpTransport;
|
||||
reachable: boolean;
|
||||
statusCode?: number;
|
||||
error?: string;
|
||||
}> {
|
||||
const scope = input.scope ?? 'project';
|
||||
this.assertScope(scope);
|
||||
|
||||
const workspacePath = resolveWorkspacePath(input.workspacePath);
|
||||
const normalizedName = normalizeServerName(input.name);
|
||||
const scopedServers = await this.readScopedServers(scope, workspacePath);
|
||||
const rawConfig = scopedServers[normalizedName];
|
||||
if (!rawConfig || typeof rawConfig !== 'object') {
|
||||
throw new AppError(`MCP server "${normalizedName}" was not found.`, {
|
||||
code: 'MCP_SERVER_NOT_FOUND',
|
||||
statusCode: 404,
|
||||
});
|
||||
}
|
||||
|
||||
const normalized = this.normalizeServerConfig(scope, normalizedName, rawConfig);
|
||||
if (!normalized) {
|
||||
throw new AppError(`MCP server "${normalizedName}" has an invalid configuration.`, {
|
||||
code: 'MCP_SERVER_INVALID_CONFIG',
|
||||
statusCode: 400,
|
||||
});
|
||||
}
|
||||
|
||||
if (normalized.transport === 'stdio') {
|
||||
const result = await runStdioServerProbe(normalized, workspacePath);
|
||||
return {
|
||||
provider: this.provider,
|
||||
name: normalizedName,
|
||||
scope,
|
||||
transport: normalized.transport,
|
||||
reachable: result.reachable,
|
||||
error: result.error,
|
||||
};
|
||||
}
|
||||
|
||||
const result = await runHttpServerProbe(normalized.url ?? '');
|
||||
return {
|
||||
provider: this.provider,
|
||||
name: normalizedName,
|
||||
scope,
|
||||
transport: normalized.transport,
|
||||
reachable: result.reachable,
|
||||
statusCode: result.statusCode,
|
||||
error: result.error,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads one scope's raw server map from provider-native files.
|
||||
*/
|
||||
protected abstract readScopedServers(
|
||||
scope: McpScope,
|
||||
workspacePath: string,
|
||||
): Promise<Record<string, unknown>>;
|
||||
|
||||
/**
|
||||
* Persists one scope's raw server map back to provider-native files.
|
||||
*/
|
||||
protected abstract writeScopedServers(
|
||||
scope: McpScope,
|
||||
workspacePath: string,
|
||||
servers: Record<string, unknown>,
|
||||
): Promise<void>;
|
||||
|
||||
/**
|
||||
* Creates one provider-native config object from a unified input payload.
|
||||
*/
|
||||
protected abstract buildServerConfig(input: UpsertProviderMcpServerInput): Record<string, unknown>;
|
||||
|
||||
/**
|
||||
* Maps one provider-native server object into the unified response shape.
|
||||
*/
|
||||
protected abstract normalizeServerConfig(
|
||||
scope: McpScope,
|
||||
name: string,
|
||||
rawConfig: unknown,
|
||||
): ProviderMcpServer | null;
|
||||
|
||||
/**
|
||||
* Ensures one scope is supported for the current provider.
|
||||
*/
|
||||
protected assertScope(scope: McpScope): void {
|
||||
if (!this.supportedScopes.includes(scope)) {
|
||||
throw new AppError(`Provider "${this.provider}" does not support "${scope}" MCP scope.`, {
|
||||
code: 'MCP_SCOPE_NOT_SUPPORTED',
|
||||
statusCode: 400,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures one scope + transport pair is supported for the current provider.
|
||||
*/
|
||||
protected assertScopeAndTransport(scope: McpScope, transport: McpTransport): void {
|
||||
this.assertScope(scope);
|
||||
if (!this.supportedTransports.includes(transport)) {
|
||||
throw new AppError(`Provider "${this.provider}" does not support "${transport}" MCP transport.`, {
|
||||
code: 'MCP_TRANSPORT_NOT_SUPPORTED',
|
||||
statusCode: 400,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,207 +0,0 @@
|
||||
import { mkdir, readFile, writeFile } from 'node:fs/promises';
|
||||
import path from 'node:path';
|
||||
import { once } from 'node:events';
|
||||
|
||||
import spawn from 'cross-spawn';
|
||||
import TOML from '@iarna/toml';
|
||||
|
||||
import type { ProviderMcpServer } from '@/modules/ai-runtime/types/index.js';
|
||||
import { AppError } from '@/shared/utils/app-error.js';
|
||||
|
||||
/**
|
||||
* Resolves workspace paths once so all scope loaders read from a consistent absolute root.
|
||||
*/
|
||||
export const resolveWorkspacePath = (workspacePath?: string): string =>
|
||||
path.resolve(workspacePath ?? process.cwd());
|
||||
|
||||
/**
|
||||
* Restricts MCP server names to non-empty trimmed strings.
|
||||
*/
|
||||
export const normalizeServerName = (name: string): string => {
|
||||
const normalized = name.trim();
|
||||
if (!normalized) {
|
||||
throw new AppError('MCP server name is required.', {
|
||||
code: 'MCP_SERVER_NAME_REQUIRED',
|
||||
statusCode: 400,
|
||||
});
|
||||
}
|
||||
|
||||
return normalized;
|
||||
};
|
||||
|
||||
/**
|
||||
* Reads plain object records.
|
||||
*/
|
||||
export const readObjectRecord = (value: unknown): Record<string, unknown> | null => {
|
||||
if (!value || typeof value !== 'object' || Array.isArray(value)) {
|
||||
return null;
|
||||
}
|
||||
return value as Record<string, unknown>;
|
||||
};
|
||||
|
||||
/**
|
||||
* Reads optional strings.
|
||||
*/
|
||||
export const readOptionalString = (value: unknown): string | undefined => {
|
||||
if (typeof value !== 'string') {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const normalized = value.trim();
|
||||
return normalized.length ? normalized : undefined;
|
||||
};
|
||||
|
||||
/**
|
||||
* Reads optional string arrays.
|
||||
*/
|
||||
export const readStringArray = (value: unknown): string[] | undefined => {
|
||||
if (!Array.isArray(value)) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return value.filter((entry): entry is string => typeof entry === 'string');
|
||||
};
|
||||
|
||||
/**
|
||||
* Reads optional string maps.
|
||||
*/
|
||||
export const readStringRecord = (value: unknown): Record<string, string> | undefined => {
|
||||
const record = readObjectRecord(value);
|
||||
if (!record) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const normalized: Record<string, string> = {};
|
||||
for (const [key, entry] of Object.entries(record)) {
|
||||
if (typeof entry === 'string') {
|
||||
normalized[key] = entry;
|
||||
}
|
||||
}
|
||||
|
||||
return Object.keys(normalized).length > 0 ? normalized : undefined;
|
||||
};
|
||||
|
||||
/**
|
||||
* Safely reads a JSON config file and returns an empty object when missing.
|
||||
*/
|
||||
export const readJsonConfig = async (filePath: string): Promise<Record<string, unknown>> => {
|
||||
try {
|
||||
const content = await readFile(filePath, 'utf8');
|
||||
const parsed = JSON.parse(content) as Record<string, unknown>;
|
||||
return readObjectRecord(parsed) ?? {};
|
||||
} catch (error) {
|
||||
const code = (error as NodeJS.ErrnoException).code;
|
||||
if (code === 'ENOENT') {
|
||||
return {};
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Writes one JSON config with stable formatting.
|
||||
*/
|
||||
export const writeJsonConfig = async (filePath: string, data: Record<string, unknown>): Promise<void> => {
|
||||
await mkdir(path.dirname(filePath), { recursive: true });
|
||||
await writeFile(filePath, `${JSON.stringify(data, null, 2)}\n`, 'utf8');
|
||||
};
|
||||
|
||||
/**
|
||||
* Safely reads a TOML config and returns an empty object when missing.
|
||||
*/
|
||||
export const readTomlConfig = async (filePath: string): Promise<Record<string, unknown>> => {
|
||||
try {
|
||||
const content = await readFile(filePath, 'utf8');
|
||||
const parsed = TOML.parse(content) as Record<string, unknown>;
|
||||
return readObjectRecord(parsed) ?? {};
|
||||
} catch (error) {
|
||||
const code = (error as NodeJS.ErrnoException).code;
|
||||
if (code === 'ENOENT') {
|
||||
return {};
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Writes one TOML config file.
|
||||
*/
|
||||
export const writeTomlConfig = async (filePath: string, data: Record<string, unknown>): Promise<void> => {
|
||||
await mkdir(path.dirname(filePath), { recursive: true });
|
||||
const toml = TOML.stringify(data as any);
|
||||
await writeFile(filePath, toml, 'utf8');
|
||||
};
|
||||
|
||||
/**
|
||||
* Runs a short stdio process startup probe.
|
||||
*/
|
||||
export const runStdioServerProbe = async (
|
||||
server: ProviderMcpServer,
|
||||
workspacePath: string,
|
||||
): Promise<{ reachable: boolean; error?: string }> => {
|
||||
if (!server.command) {
|
||||
return { reachable: false, error: 'Missing stdio command.' };
|
||||
}
|
||||
|
||||
try {
|
||||
const child = spawn(server.command, server.args ?? [], {
|
||||
cwd: server.cwd ? path.resolve(workspacePath, server.cwd) : workspacePath,
|
||||
env: {
|
||||
...process.env,
|
||||
...(server.env ?? {}),
|
||||
},
|
||||
stdio: ['ignore', 'pipe', 'pipe'],
|
||||
});
|
||||
|
||||
const timeout = setTimeout(() => {
|
||||
if (!child.killed && child.exitCode === null) {
|
||||
child.kill('SIGTERM');
|
||||
}
|
||||
}, 1_500);
|
||||
|
||||
const errorPromise = once(child, 'error').then(([error]) => {
|
||||
throw error;
|
||||
});
|
||||
const closePromise = once(child, 'close');
|
||||
await Promise.race([closePromise, errorPromise]);
|
||||
clearTimeout(timeout);
|
||||
|
||||
if (typeof child.exitCode === 'number' && child.exitCode !== 0) {
|
||||
return {
|
||||
reachable: false,
|
||||
error: `Process exited with code ${child.exitCode}.`,
|
||||
};
|
||||
}
|
||||
|
||||
return { reachable: true };
|
||||
} catch (error) {
|
||||
return {
|
||||
reachable: false,
|
||||
error: error instanceof Error ? error.message : 'Failed to start stdio process',
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Runs a lightweight HTTP/SSE reachability probe.
|
||||
*/
|
||||
export const runHttpServerProbe = async (
|
||||
url: string,
|
||||
): Promise<{ reachable: boolean; statusCode?: number; error?: string }> => {
|
||||
const controller = new AbortController();
|
||||
const timeout = setTimeout(() => controller.abort(), 3_000);
|
||||
try {
|
||||
const response = await fetch(url, { method: 'GET', signal: controller.signal });
|
||||
clearTimeout(timeout);
|
||||
return {
|
||||
reachable: true,
|
||||
statusCode: response.status,
|
||||
};
|
||||
} catch (error) {
|
||||
clearTimeout(timeout);
|
||||
return {
|
||||
reachable: false,
|
||||
error: error instanceof Error ? error.message : 'Network probe failed',
|
||||
};
|
||||
}
|
||||
};
|
||||
@@ -1,154 +0,0 @@
|
||||
import fs from 'node:fs';
|
||||
import fsp from 'node:fs/promises';
|
||||
import path from 'node:path';
|
||||
import readline from 'node:readline';
|
||||
/**
|
||||
* Keeps extracted session names compact and UI-safe.
|
||||
*/
|
||||
export function normalizeSessionName(rawValue: string | undefined, fallback: string): string {
|
||||
const normalized = (rawValue ?? '').replace(/\s+/g, ' ').trim();
|
||||
if (!normalized) {
|
||||
return fallback;
|
||||
}
|
||||
|
||||
return normalized.slice(0, 120);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns directory entries or an empty array when the directory does not exist.
|
||||
*/
|
||||
export async function listDirectoryEntriesSafe(
|
||||
directoryPath: string,
|
||||
): Promise<import('node:fs').Dirent[]> {
|
||||
try {
|
||||
return await fsp.readdir(directoryPath, { withFileTypes: true });
|
||||
} catch {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds a lookup map from a JSONL index file by extracting a key/value pair per row.
|
||||
* The first occurrence of a key wins so we preserve earliest metadata.
|
||||
*/
|
||||
export async function buildLookupMap(
|
||||
filePath: string,
|
||||
keyField: string,
|
||||
valueField: string,
|
||||
): Promise<Map<string, string>> {
|
||||
const lookup = new Map<string, string>();
|
||||
|
||||
try {
|
||||
const fileStream = fs.createReadStream(filePath);
|
||||
const lineReader = readline.createInterface({ input: fileStream, crlfDelay: Infinity });
|
||||
|
||||
for await (const line of lineReader) {
|
||||
const trimmed = line.trim();
|
||||
if (!trimmed) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const parsed = JSON.parse(trimmed) as Record<string, unknown>;
|
||||
const key = parsed[keyField];
|
||||
const value = parsed[valueField];
|
||||
|
||||
if (typeof key === 'string' && typeof value === 'string' && !lookup.has(key)) {
|
||||
lookup.set(key, value);
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
// Missing index files are normal for users who have not used a provider yet.
|
||||
}
|
||||
|
||||
return lookup;
|
||||
}
|
||||
|
||||
/**
|
||||
* Recursively scans for files with a given extension and optionally filters
|
||||
* them to only files created after `lastScanAt`.
|
||||
*/
|
||||
export async function findFilesRecursivelyCreatedAfter(
|
||||
rootDir: string,
|
||||
extension: string,
|
||||
lastScanAt: Date | null,
|
||||
fileList: string[] = [],
|
||||
): Promise<string[]> {
|
||||
try {
|
||||
const entries = await fsp.readdir(rootDir, { withFileTypes: true });
|
||||
for (const entry of entries) {
|
||||
const fullPath = path.join(rootDir, entry.name);
|
||||
|
||||
if (entry.isDirectory()) {
|
||||
await findFilesRecursivelyCreatedAfter(fullPath, extension, lastScanAt, fileList);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!entry.isFile() || !entry.name.endsWith(extension)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!lastScanAt) {
|
||||
fileList.push(fullPath);
|
||||
continue;
|
||||
}
|
||||
|
||||
const stats = await fsp.stat(fullPath);
|
||||
if (stats.birthtime > lastScanAt) {
|
||||
fileList.push(fullPath);
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
// Missing provider directories should not fail the full sync.
|
||||
}
|
||||
|
||||
return fileList;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads JSONL rows until the extractor yields a valid session identity.
|
||||
*/
|
||||
export async function extractFirstValidJsonlData<T>(
|
||||
filePath: string,
|
||||
extractor: (parsedJson: unknown) => T | null | undefined,
|
||||
): Promise<T | null> {
|
||||
try {
|
||||
const fileStream = fs.createReadStream(filePath);
|
||||
const lineReader = readline.createInterface({ input: fileStream, crlfDelay: Infinity });
|
||||
|
||||
for await (const line of lineReader) {
|
||||
const trimmed = line.trim();
|
||||
if (!trimmed) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const parsed = JSON.parse(trimmed);
|
||||
const extracted = extractor(parsed);
|
||||
if (extracted) {
|
||||
lineReader.close();
|
||||
fileStream.close();
|
||||
return extracted;
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
// Ignore malformed session files and continue scanning.
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads filesystem timestamps for DB metadata fields.
|
||||
*/
|
||||
export async function readFileTimestamps(
|
||||
filePath: string,
|
||||
): Promise<{ createdAt?: string; updatedAt?: string }> {
|
||||
try {
|
||||
const stat = await fsp.stat(filePath);
|
||||
return {
|
||||
createdAt: stat.birthtime.toISOString(),
|
||||
updatedAt: stat.mtime.toISOString(),
|
||||
};
|
||||
} catch {
|
||||
return {};
|
||||
}
|
||||
}
|
||||
@@ -1,154 +0,0 @@
|
||||
import { access, readFile, readdir } from 'node:fs/promises';
|
||||
import path from 'node:path';
|
||||
|
||||
import type { LLMProvider } from '@/shared/types/app.js';
|
||||
import type { ProviderSkill, ProviderSkillScope } from '@/modules/ai-runtime/types/index.js';
|
||||
|
||||
/**
|
||||
* Tests whether a path exists.
|
||||
*/
|
||||
export const pathExists = async (targetPath: string): Promise<boolean> => {
|
||||
try {
|
||||
await access(targetPath);
|
||||
return true;
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Parses frontmatter metadata from SKILL.md files.
|
||||
*/
|
||||
export const parseSkillFrontmatter = (content: string): { name?: string; description?: string } => {
|
||||
if (!content.startsWith('---')) {
|
||||
return {};
|
||||
}
|
||||
|
||||
const closingDelimiterIndex = content.indexOf('\n---', 3);
|
||||
if (closingDelimiterIndex < 0) {
|
||||
return {};
|
||||
}
|
||||
|
||||
const frontmatter = content.slice(3, closingDelimiterIndex).trim();
|
||||
const metadata: { name?: string; description?: string } = {};
|
||||
for (const line of frontmatter.split(/\r?\n/)) {
|
||||
const separatorIndex = line.indexOf(':');
|
||||
if (separatorIndex <= 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const key = line.slice(0, separatorIndex).trim();
|
||||
const rawValue = line.slice(separatorIndex + 1).trim();
|
||||
const value = rawValue.replace(/^["']|["']$/g, '');
|
||||
if (key === 'name') {
|
||||
metadata.name = value;
|
||||
} else if (key === 'description') {
|
||||
metadata.description = value;
|
||||
}
|
||||
}
|
||||
|
||||
return metadata;
|
||||
};
|
||||
|
||||
/**
|
||||
* Reads SKILL.md files from a `<skills-dir>/<skill-name>/SKILL.md` directory layout.
|
||||
*/
|
||||
export const listSkillsFromDirectory = async (input: {
|
||||
provider: LLMProvider;
|
||||
scope: ProviderSkillScope;
|
||||
skillsDirectory: string;
|
||||
invocationPrefix: '/' | '$';
|
||||
pluginName?: string;
|
||||
}): Promise<ProviderSkill[]> => {
|
||||
if (!(await pathExists(input.skillsDirectory))) {
|
||||
return [];
|
||||
}
|
||||
|
||||
const entries = await readdir(input.skillsDirectory, { withFileTypes: true });
|
||||
const skills: ProviderSkill[] = [];
|
||||
for (const entry of entries) {
|
||||
if (!entry.isDirectory()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const skillDirectory = path.join(input.skillsDirectory, entry.name);
|
||||
const skillFilePath = path.join(skillDirectory, 'SKILL.md');
|
||||
if (!(await pathExists(skillFilePath))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const skillMarkdown = await readFile(skillFilePath, 'utf8');
|
||||
const metadata = parseSkillFrontmatter(skillMarkdown);
|
||||
const skillName = metadata.name ?? entry.name;
|
||||
const invocation = `${input.invocationPrefix}${skillName}`;
|
||||
skills.push({
|
||||
provider: input.provider,
|
||||
scope: input.scope,
|
||||
name: skillName,
|
||||
description: metadata.description,
|
||||
invocation,
|
||||
filePath: skillFilePath,
|
||||
pluginName: input.pluginName,
|
||||
});
|
||||
}
|
||||
|
||||
return skills;
|
||||
};
|
||||
|
||||
/**
|
||||
* Finds the closest git root by walking up from the current workspace path.
|
||||
*/
|
||||
export const findGitRepoRoot = async (startPath: string): Promise<string | null> => {
|
||||
let currentPath = path.resolve(startPath);
|
||||
while (true) {
|
||||
const gitPath = path.join(currentPath, '.git');
|
||||
if (await pathExists(gitPath)) {
|
||||
return currentPath;
|
||||
}
|
||||
|
||||
const parentPath = path.dirname(currentPath);
|
||||
if (parentPath === currentPath) {
|
||||
return null;
|
||||
}
|
||||
|
||||
currentPath = parentPath;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Deduplicates directory candidates by absolute path.
|
||||
*/
|
||||
export const deduplicateDirectories = (
|
||||
entries: Array<{ scope: ProviderSkillScope; directory: string }>,
|
||||
): Array<{ scope: ProviderSkillScope; directory: string }> => {
|
||||
const seen = new Set<string>();
|
||||
const deduplicated: Array<{ scope: ProviderSkillScope; directory: string }> = [];
|
||||
for (const entry of entries) {
|
||||
const normalizedDirectory = path.resolve(entry.directory);
|
||||
if (seen.has(normalizedDirectory)) {
|
||||
continue;
|
||||
}
|
||||
seen.add(normalizedDirectory);
|
||||
deduplicated.push({ scope: entry.scope, directory: normalizedDirectory });
|
||||
}
|
||||
|
||||
return deduplicated;
|
||||
};
|
||||
|
||||
/**
|
||||
* Deduplicates skills by provider + invocation command.
|
||||
*/
|
||||
export const deduplicateSkills = (skills: ProviderSkill[]): ProviderSkill[] => {
|
||||
const seen = new Set<string>();
|
||||
const deduplicated: ProviderSkill[] = [];
|
||||
for (const skill of skills) {
|
||||
const key = `${skill.provider}:${skill.invocation}`;
|
||||
if (seen.has(key)) {
|
||||
continue;
|
||||
}
|
||||
seen.add(key);
|
||||
deduplicated.push(skill);
|
||||
}
|
||||
|
||||
return deduplicated;
|
||||
};
|
||||
@@ -1,191 +0,0 @@
|
||||
import type { LLMProvider } from '@/shared/types/app.js';
|
||||
import { AppError } from '@/shared/utils/app-error.js';
|
||||
import { llmProviderRegistry } from '@/modules/ai-runtime/ai-runtime.registry.js';
|
||||
import type {
|
||||
ProviderModel,
|
||||
ProviderSessionSnapshot,
|
||||
RuntimePermissionMode,
|
||||
StartSessionInput,
|
||||
} from '@/modules/ai-runtime/types/index.js';
|
||||
|
||||
/**
|
||||
* Converts unknown request values into optional trimmed strings.
|
||||
*/
|
||||
const normalizeOptionalString = (value: unknown): string | undefined => {
|
||||
if (typeof value !== 'string') {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const normalized = value.trim();
|
||||
return normalized.length > 0 ? normalized : undefined;
|
||||
};
|
||||
|
||||
/**
|
||||
* Validates and normalizes optional image path arrays.
|
||||
*/
|
||||
const normalizeImagePaths = (value: unknown): string[] | undefined => {
|
||||
if (value === undefined) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
if (!Array.isArray(value)) {
|
||||
throw new AppError('imagePaths must be an array of strings.', {
|
||||
code: 'INVALID_IMAGE_PATHS',
|
||||
statusCode: 400,
|
||||
});
|
||||
}
|
||||
|
||||
const normalizedPaths = value
|
||||
.map((entry) => (typeof entry === 'string' ? entry.trim() : ''))
|
||||
.filter((entry) => entry.length > 0);
|
||||
|
||||
if (normalizedPaths.length !== value.length) {
|
||||
throw new AppError('imagePaths must contain non-empty strings only.', {
|
||||
code: 'INVALID_IMAGE_PATHS',
|
||||
statusCode: 400,
|
||||
});
|
||||
}
|
||||
|
||||
return normalizedPaths;
|
||||
};
|
||||
|
||||
/**
|
||||
* Validates and normalizes runtime permission mode.
|
||||
*/
|
||||
const normalizePermissionMode = (value: unknown): RuntimePermissionMode | undefined => {
|
||||
const normalized = normalizeOptionalString(value);
|
||||
if (!normalized) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
if (normalized === 'ask' || normalized === 'allow' || normalized === 'deny') {
|
||||
return normalized;
|
||||
}
|
||||
|
||||
throw new AppError(`Unsupported runtimePermissionMode "${normalized}".`, {
|
||||
code: 'INVALID_RUNTIME_PERMISSION_MODE',
|
||||
statusCode: 400,
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Facade over provider implementations with payload validation and capability checks.
|
||||
*/
|
||||
export const llmService = {
|
||||
listProviders(): Array<{
|
||||
id: LLMProvider;
|
||||
family: 'sdk' | 'cli';
|
||||
capabilities: {
|
||||
supportsRuntimePermissionRequests: boolean;
|
||||
supportsThinkingModeControl: boolean;
|
||||
};
|
||||
}> {
|
||||
return llmProviderRegistry.listProviders().map((provider) => ({
|
||||
id: provider.id,
|
||||
family: provider.family,
|
||||
capabilities: {
|
||||
supportsRuntimePermissionRequests: provider.capabilities.supportsRuntimePermissionRequests,
|
||||
supportsThinkingModeControl: provider.capabilities.supportsThinkingModeControl,
|
||||
},
|
||||
}));
|
||||
},
|
||||
|
||||
async listModels(providerName: string): Promise<ProviderModel[]> {
|
||||
const provider = llmProviderRegistry.resolveProvider(providerName);
|
||||
return provider.listModels();
|
||||
},
|
||||
|
||||
listSessions(providerName: string): ProviderSessionSnapshot[] {
|
||||
const provider = llmProviderRegistry.resolveProvider(providerName);
|
||||
return provider.listSessions();
|
||||
},
|
||||
|
||||
getSession(providerName: string, sessionId: string): ProviderSessionSnapshot | null {
|
||||
const provider = llmProviderRegistry.resolveProvider(providerName);
|
||||
return provider.getSession(sessionId);
|
||||
},
|
||||
|
||||
async startSession(providerName: string, payload: unknown): Promise<ProviderSessionSnapshot> {
|
||||
const provider = llmProviderRegistry.resolveProvider(providerName);
|
||||
const input = parseStartPayload(payload);
|
||||
validateCapabilityContracts(provider.capabilities, input);
|
||||
return provider.launchSession(input);
|
||||
},
|
||||
|
||||
async resumeSession(
|
||||
providerName: string,
|
||||
sessionId: string,
|
||||
payload: unknown,
|
||||
): Promise<ProviderSessionSnapshot> {
|
||||
const provider = llmProviderRegistry.resolveProvider(providerName);
|
||||
const input = parseStartPayload(payload);
|
||||
validateCapabilityContracts(provider.capabilities, input);
|
||||
return provider.resumeSession({ ...input, sessionId });
|
||||
},
|
||||
|
||||
async stopSession(providerName: string, sessionId: string): Promise<boolean> {
|
||||
const provider = llmProviderRegistry.resolveProvider(providerName);
|
||||
return provider.stopSession(sessionId);
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* Parses and validates session start/resume request payloads.
|
||||
*/
|
||||
function parseStartPayload(payload: unknown): StartSessionInput {
|
||||
if (!payload || typeof payload !== 'object') {
|
||||
throw new AppError('Request body must be an object.', {
|
||||
code: 'INVALID_REQUEST_BODY',
|
||||
statusCode: 400,
|
||||
});
|
||||
}
|
||||
|
||||
const body = payload as Record<string, unknown>;
|
||||
const prompt = normalizeOptionalString(body.prompt);
|
||||
if (!prompt) {
|
||||
throw new AppError('prompt is required.', {
|
||||
code: 'PROMPT_REQUIRED',
|
||||
statusCode: 400,
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
prompt,
|
||||
workspacePath: normalizeOptionalString(body.workspacePath),
|
||||
sessionId: normalizeOptionalString(body.sessionId),
|
||||
model: normalizeOptionalString(body.model),
|
||||
thinkingMode: normalizeOptionalString(body.thinkingMode),
|
||||
imagePaths: normalizeImagePaths(body.imagePaths),
|
||||
runtimePermissionMode: normalizePermissionMode(body.runtimePermissionMode),
|
||||
allowYolo: body.allowYolo === true,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Enforces capability contracts before provider invocation.
|
||||
*/
|
||||
function validateCapabilityContracts(
|
||||
capabilities: {
|
||||
supportsRuntimePermissionRequests: boolean;
|
||||
supportsThinkingModeControl: boolean;
|
||||
},
|
||||
input: StartSessionInput,
|
||||
): void {
|
||||
if (
|
||||
input.runtimePermissionMode &&
|
||||
input.runtimePermissionMode !== 'ask' &&
|
||||
!capabilities.supportsRuntimePermissionRequests
|
||||
) {
|
||||
throw new AppError('Runtime permission requests are not supported by this provider.', {
|
||||
code: 'RUNTIME_PERMISSION_NOT_SUPPORTED',
|
||||
statusCode: 400,
|
||||
});
|
||||
}
|
||||
|
||||
if (input.thinkingMode && !capabilities.supportsThinkingModeControl) {
|
||||
throw new AppError('Thinking mode is not supported by this provider.', {
|
||||
code: 'THINKING_MODE_NOT_SUPPORTED',
|
||||
statusCode: 400,
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
import { llmProviderRegistry } from '@/modules/ai-runtime/ai-runtime.registry.js';
|
||||
import type { ProviderAuthStatus } from '@/modules/ai-runtime/types/index.js';
|
||||
|
||||
export const llmAuthService = {
|
||||
/**
|
||||
* Returns auth status for one provider.
|
||||
*/
|
||||
async getProviderAuthStatus(providerName: string): Promise<ProviderAuthStatus> {
|
||||
const provider = llmProviderRegistry.resolveProvider(providerName);
|
||||
return provider.auth.getStatus();
|
||||
},
|
||||
};
|
||||
@@ -1,106 +0,0 @@
|
||||
import type { LLMProvider } from '@/shared/types/app.js';
|
||||
import { AppError } from '@/shared/utils/app-error.js';
|
||||
import { llmProviderRegistry } from '@/modules/ai-runtime/ai-runtime.registry.js';
|
||||
import type {
|
||||
McpScope,
|
||||
ProviderMcpServer,
|
||||
UpsertProviderMcpServerInput,
|
||||
} from '@/modules/ai-runtime/types/index.js';
|
||||
|
||||
export const llmMcpService = {
|
||||
/**
|
||||
* Lists MCP servers for one provider grouped by supported scopes.
|
||||
*/
|
||||
async listProviderMcpServers(
|
||||
providerName: string,
|
||||
options?: { workspacePath?: string },
|
||||
): Promise<Record<McpScope, ProviderMcpServer[]>> {
|
||||
const provider = llmProviderRegistry.resolveProvider(providerName);
|
||||
return provider.mcp.listServers(options);
|
||||
},
|
||||
|
||||
/**
|
||||
* Lists MCP servers for one provider scope.
|
||||
*/
|
||||
async listProviderMcpServersForScope(
|
||||
providerName: string,
|
||||
scope: McpScope,
|
||||
options?: { workspacePath?: string },
|
||||
): Promise<ProviderMcpServer[]> {
|
||||
const provider = llmProviderRegistry.resolveProvider(providerName);
|
||||
return provider.mcp.listServersForScope(scope, options);
|
||||
},
|
||||
|
||||
/**
|
||||
* Adds or updates one provider MCP server.
|
||||
*/
|
||||
async upsertProviderMcpServer(
|
||||
providerName: string,
|
||||
input: UpsertProviderMcpServerInput,
|
||||
): Promise<ProviderMcpServer> {
|
||||
const provider = llmProviderRegistry.resolveProvider(providerName);
|
||||
return provider.mcp.upsertServer(input);
|
||||
},
|
||||
|
||||
/**
|
||||
* Removes one provider MCP server.
|
||||
*/
|
||||
async removeProviderMcpServer(
|
||||
providerName: string,
|
||||
input: { name: string; scope?: McpScope; workspacePath?: string },
|
||||
): Promise<{ removed: boolean; provider: LLMProvider; name: string; scope: McpScope }> {
|
||||
const provider = llmProviderRegistry.resolveProvider(providerName);
|
||||
return provider.mcp.removeServer(input);
|
||||
},
|
||||
|
||||
/**
|
||||
* Runs one provider MCP server probe.
|
||||
*/
|
||||
async runProviderMcpServer(
|
||||
providerName: string,
|
||||
input: { name: string; scope?: McpScope; workspacePath?: string },
|
||||
): Promise<{
|
||||
provider: LLMProvider;
|
||||
name: string;
|
||||
scope: McpScope;
|
||||
transport: 'stdio' | 'http' | 'sse';
|
||||
reachable: boolean;
|
||||
statusCode?: number;
|
||||
error?: string;
|
||||
}> {
|
||||
const provider = llmProviderRegistry.resolveProvider(providerName);
|
||||
return provider.mcp.runServer(input);
|
||||
},
|
||||
|
||||
/**
|
||||
* Adds one HTTP/stdio MCP server to every provider.
|
||||
*/
|
||||
async addMcpServerToAllProviders(
|
||||
input: Omit<UpsertProviderMcpServerInput, 'scope'> & { scope?: Exclude<McpScope, 'local'> },
|
||||
): Promise<Array<{ provider: LLMProvider; created: boolean; error?: string }>> {
|
||||
if (input.transport !== 'stdio' && input.transport !== 'http') {
|
||||
throw new AppError('Global MCP add supports only "stdio" and "http".', {
|
||||
code: 'INVALID_GLOBAL_MCP_TRANSPORT',
|
||||
statusCode: 400,
|
||||
});
|
||||
}
|
||||
|
||||
const scope = input.scope ?? 'project';
|
||||
const results: Array<{ provider: LLMProvider; created: boolean; error?: string }> = [];
|
||||
const providers = llmProviderRegistry.listProviders();
|
||||
for (const provider of providers) {
|
||||
try {
|
||||
await provider.mcp.upsertServer({ ...input, scope });
|
||||
results.push({ provider: provider.id, created: true });
|
||||
} catch (error) {
|
||||
results.push({
|
||||
provider: provider.id,
|
||||
created: false,
|
||||
error: error instanceof Error ? error.message : 'Unknown error',
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return results;
|
||||
},
|
||||
};
|
||||
@@ -1,908 +0,0 @@
|
||||
import type { ProviderSessionEvent } from '@/modules/ai-runtime/types/index.js';
|
||||
import type { LLMProvider } from '@/shared/types/app.js';
|
||||
|
||||
export type UnifiedMessageType =
|
||||
| 'user_message'
|
||||
| 'thinking_message'
|
||||
| 'assistant_message'
|
||||
| 'assistant_error_message'
|
||||
| 'tool_use_request'
|
||||
| 'tool_call_success'
|
||||
| 'tool_call_error'
|
||||
| 'todo_task_list'
|
||||
| 'session_started'
|
||||
| 'session_completed'
|
||||
| 'session_interrupted';
|
||||
|
||||
export type UnifiedSessionStatus = 'STARTED' | 'COMPLETED' | 'SESSION_ABORTED';
|
||||
|
||||
export type UnifiedChatMessage = {
|
||||
timestamp: string;
|
||||
provider: LLMProvider;
|
||||
sessionId: string;
|
||||
type: UnifiedMessageType;
|
||||
text?: string;
|
||||
images?: string[];
|
||||
toolName?: string;
|
||||
toolCallId?: string;
|
||||
status?: 'success' | 'error';
|
||||
has_progress_indicator?: boolean;
|
||||
sessionStatus?: UnifiedSessionStatus;
|
||||
data?: unknown;
|
||||
raw?: unknown;
|
||||
};
|
||||
|
||||
type MessageContext = {
|
||||
provider: LLMProvider;
|
||||
sessionId: string;
|
||||
timestamp?: string;
|
||||
};
|
||||
|
||||
/**
|
||||
* Unifies provider-specific history/event payloads into one frontend-safe message contract.
|
||||
*/
|
||||
export const llmMessagesUnifier = {
|
||||
/**
|
||||
* Converts in-memory provider session events to unified chat messages.
|
||||
*/
|
||||
normalizeSessionEvents(
|
||||
provider: LLMProvider,
|
||||
sessionId: string,
|
||||
events: ProviderSessionEvent[],
|
||||
): UnifiedChatMessage[] {
|
||||
const messages: UnifiedChatMessage[] = [];
|
||||
for (const event of events) {
|
||||
const normalized = this.normalizeUnknown(provider, sessionId, event.data ?? event.message ?? event, event.timestamp);
|
||||
if (normalized.length === 0 && event.message) {
|
||||
messages.push(createMessage({
|
||||
provider,
|
||||
sessionId,
|
||||
timestamp: event.timestamp,
|
||||
type: event.channel === 'error' ? 'assistant_error_message' : 'assistant_message',
|
||||
text: event.message,
|
||||
raw: event,
|
||||
}));
|
||||
continue;
|
||||
}
|
||||
|
||||
messages.push(...normalized);
|
||||
}
|
||||
|
||||
return messages;
|
||||
},
|
||||
|
||||
/**
|
||||
* Converts DB history payload entries to unified chat messages.
|
||||
*/
|
||||
normalizeHistoryEntries(
|
||||
provider: LLMProvider,
|
||||
sessionId: string,
|
||||
entries: unknown[],
|
||||
): UnifiedChatMessage[] {
|
||||
const messages: UnifiedChatMessage[] = [];
|
||||
for (const entry of entries) {
|
||||
messages.push(...this.normalizeUnknown(provider, sessionId, entry));
|
||||
}
|
||||
|
||||
return messages;
|
||||
},
|
||||
|
||||
/**
|
||||
* Converts one raw provider payload to zero-or-more normalized messages.
|
||||
*/
|
||||
normalizeUnknown(
|
||||
provider: LLMProvider,
|
||||
sessionId: string,
|
||||
raw: unknown,
|
||||
timestamp?: string,
|
||||
): UnifiedChatMessage[] {
|
||||
const context: MessageContext = { provider, sessionId, timestamp };
|
||||
if (!raw || typeof raw !== 'object') {
|
||||
return [];
|
||||
}
|
||||
|
||||
const preUnified = normalizePreUnifiedPayload(raw as Record<string, unknown>, context);
|
||||
if (preUnified) {
|
||||
return preUnified;
|
||||
}
|
||||
|
||||
if (provider === 'claude') {
|
||||
return normalizeClaudePayload(raw as Record<string, unknown>, context);
|
||||
}
|
||||
|
||||
if (provider === 'codex') {
|
||||
return normalizeCodexPayload(raw as Record<string, unknown>, context);
|
||||
}
|
||||
|
||||
if (provider === 'gemini') {
|
||||
return normalizeGeminiPayload(raw as Record<string, unknown>, context);
|
||||
}
|
||||
|
||||
return normalizeCursorPayload(raw as Record<string, unknown>, context);
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* Maps already-unified custom payloads (for example permission callbacks) without provider parsing.
|
||||
*/
|
||||
function normalizePreUnifiedPayload(
|
||||
raw: Record<string, unknown>,
|
||||
context: MessageContext,
|
||||
): UnifiedChatMessage[] | null {
|
||||
const type = readString(raw.type);
|
||||
if (!type) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (
|
||||
type !== 'user_message' &&
|
||||
type !== 'thinking_message' &&
|
||||
type !== 'assistant_message' &&
|
||||
type !== 'assistant_error_message' &&
|
||||
type !== 'tool_use_request' &&
|
||||
type !== 'tool_call_success' &&
|
||||
type !== 'tool_call_error' &&
|
||||
type !== 'todo_task_list' &&
|
||||
type !== 'session_started' &&
|
||||
type !== 'session_completed' &&
|
||||
type !== 'session_interrupted'
|
||||
) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const statusValue = readString(raw.status);
|
||||
const status =
|
||||
statusValue === 'success' || statusValue === 'error'
|
||||
? statusValue
|
||||
: undefined;
|
||||
const sessionStatus = readString(raw.sessionStatus);
|
||||
const normalizedSessionStatus =
|
||||
sessionStatus === 'STARTED' || sessionStatus === 'COMPLETED' || sessionStatus === 'SESSION_ABORTED'
|
||||
? sessionStatus
|
||||
: undefined;
|
||||
const hasProgressIndicator =
|
||||
readBoolean(raw.has_progress_indicator) ?? readBoolean(raw.hasProgressIndicator);
|
||||
|
||||
return [
|
||||
createMessage({
|
||||
...context,
|
||||
timestamp: readString(raw.timestamp) ?? context.timestamp,
|
||||
type,
|
||||
text: readString(raw.text) ?? readString(raw.message),
|
||||
images: readStringArray(raw.images),
|
||||
toolName: readString(raw.toolName) ?? readString(raw.name),
|
||||
toolCallId: readString(raw.toolCallId) ?? readString(raw.toolUseID) ?? readString(raw.call_id),
|
||||
status,
|
||||
has_progress_indicator: hasProgressIndicator,
|
||||
sessionStatus: normalizedSessionStatus,
|
||||
data: raw.data ?? raw.input ?? raw.payload,
|
||||
raw,
|
||||
}),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Normalizes Claude payloads from both SDK stream and disk history.
|
||||
*/
|
||||
function normalizeClaudePayload(
|
||||
raw: Record<string, unknown>,
|
||||
context: MessageContext,
|
||||
): UnifiedChatMessage[] {
|
||||
const sessionStatusMessage = normalizeSessionStatus(raw, context);
|
||||
if (sessionStatusMessage) {
|
||||
return [sessionStatusMessage];
|
||||
}
|
||||
|
||||
const type = readString(raw.type);
|
||||
const timestamp = readString(raw.timestamp) ?? context.timestamp;
|
||||
|
||||
if (type === 'assistant') {
|
||||
const messages: UnifiedChatMessage[] = [];
|
||||
if (readString(raw.error)) {
|
||||
messages.push(createMessage({
|
||||
...context,
|
||||
timestamp,
|
||||
type: 'assistant_error_message',
|
||||
text: readString(raw.error),
|
||||
raw,
|
||||
}));
|
||||
}
|
||||
|
||||
const messageRecord = readRecord(raw.message);
|
||||
const contentBlocks = readArray(messageRecord?.content);
|
||||
for (const contentBlock of contentBlocks) {
|
||||
const block = readRecord(contentBlock);
|
||||
if (!block) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const blockType = readString(block.type);
|
||||
if (blockType === 'thinking') {
|
||||
const thinkingText = readString(block.thinking) ?? 'Thinking';
|
||||
messages.push(createMessage({
|
||||
...context,
|
||||
timestamp,
|
||||
type: 'thinking_message',
|
||||
text: thinkingText.length ? thinkingText : 'Thinking',
|
||||
raw: block,
|
||||
}));
|
||||
continue;
|
||||
}
|
||||
|
||||
if (blockType === 'text') {
|
||||
const text = readString(block.text);
|
||||
if (text) {
|
||||
messages.push(createMessage({
|
||||
...context,
|
||||
timestamp,
|
||||
type: 'assistant_message',
|
||||
text,
|
||||
raw: block,
|
||||
}));
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if (blockType === 'tool_use') {
|
||||
const toolName = readString(block.name);
|
||||
const toolInput = readRecord(block.input) ?? block.input;
|
||||
|
||||
if (toolName === 'TaskCreate' || toolName === 'TaskUpdate') {
|
||||
messages.push(createMessage({
|
||||
...context,
|
||||
timestamp,
|
||||
type: 'todo_task_list',
|
||||
toolName,
|
||||
has_progress_indicator: true,
|
||||
data: toolInput,
|
||||
raw: block,
|
||||
}));
|
||||
continue;
|
||||
}
|
||||
|
||||
messages.push(createMessage({
|
||||
...context,
|
||||
timestamp,
|
||||
type: 'tool_use_request',
|
||||
toolName,
|
||||
toolCallId: readString(block.id),
|
||||
data: toolInput,
|
||||
raw: block,
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
return messages;
|
||||
}
|
||||
|
||||
if (type === 'user') {
|
||||
// Tool results are emitted as user messages in Claude JSONL and should be treated as assistant tool results.
|
||||
if (raw.toolUseResult !== undefined) {
|
||||
const toolUseResult = readRecord(raw.toolUseResult) ?? raw.toolUseResult;
|
||||
const successValue = readBoolean((toolUseResult as Record<string, unknown>)?.success);
|
||||
const status: 'success' | 'error' = successValue === false ? 'error' : 'success';
|
||||
|
||||
return [
|
||||
createMessage({
|
||||
...context,
|
||||
timestamp,
|
||||
type: status === 'success' ? 'tool_call_success' : 'tool_call_error',
|
||||
status,
|
||||
data: toolUseResult,
|
||||
raw,
|
||||
}),
|
||||
];
|
||||
}
|
||||
|
||||
const messageRecord = readRecord(raw.message);
|
||||
const content = readArray(messageRecord?.content);
|
||||
const textParts: string[] = [];
|
||||
const images: string[] = [];
|
||||
for (const contentBlock of content) {
|
||||
const block = readRecord(contentBlock);
|
||||
if (!block) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (readString(block.type) === 'text') {
|
||||
const text = readString(block.text);
|
||||
if (text) {
|
||||
textParts.push(text);
|
||||
}
|
||||
}
|
||||
|
||||
if (readString(block.type) === 'image') {
|
||||
const source = readRecord(block.source);
|
||||
const data = readString(source?.data);
|
||||
if (data) {
|
||||
images.push(data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!textParts.length && !images.length) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return [
|
||||
createMessage({
|
||||
...context,
|
||||
timestamp,
|
||||
type: 'user_message',
|
||||
text: textParts.join('\n'),
|
||||
images: images.length ? images : undefined,
|
||||
raw,
|
||||
}),
|
||||
];
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Normalizes Codex payloads from SDK stream/history JSONL.
|
||||
*/
|
||||
function normalizeCodexPayload(
|
||||
raw: Record<string, unknown>,
|
||||
context: MessageContext,
|
||||
): UnifiedChatMessage[] {
|
||||
const sessionStatusMessage = normalizeSessionStatus(raw, context);
|
||||
if (sessionStatusMessage) {
|
||||
return [sessionStatusMessage];
|
||||
}
|
||||
|
||||
const timestamp = readString(raw.timestamp) ?? context.timestamp;
|
||||
const type = readString(raw.type);
|
||||
|
||||
if (type === 'error') {
|
||||
return [
|
||||
createMessage({
|
||||
...context,
|
||||
timestamp,
|
||||
type: 'assistant_error_message',
|
||||
text: readString(raw.message) ?? 'Codex stream error',
|
||||
raw,
|
||||
}),
|
||||
];
|
||||
}
|
||||
|
||||
if (type === 'event_msg') {
|
||||
const payload = readRecord(raw.payload);
|
||||
const payloadType = readString(payload?.type);
|
||||
if (payloadType === 'user_message') {
|
||||
const text = readString(payload?.message);
|
||||
const localImages = readStringArray(payload?.local_images);
|
||||
const remoteImages = readStringArray(payload?.images);
|
||||
return [
|
||||
createMessage({
|
||||
...context,
|
||||
timestamp,
|
||||
type: 'user_message',
|
||||
text,
|
||||
images: [...localImages, ...remoteImages],
|
||||
raw,
|
||||
}),
|
||||
];
|
||||
}
|
||||
|
||||
if (payloadType === 'exec_command_end') {
|
||||
const status = readString(payload?.status) === 'failed' ? 'error' : 'success';
|
||||
return [
|
||||
createMessage({
|
||||
...context,
|
||||
timestamp,
|
||||
type: status === 'success' ? 'tool_call_success' : 'tool_call_error',
|
||||
status,
|
||||
toolName: 'shell_command',
|
||||
toolCallId: readString(payload?.call_id),
|
||||
data: payload,
|
||||
raw,
|
||||
}),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
if (type === 'response_item') {
|
||||
const payload = readRecord(raw.payload);
|
||||
const payloadType = readString(payload?.type);
|
||||
if (payloadType === 'reasoning') {
|
||||
const summary = readArray(payload?.summary);
|
||||
const summaryText = summary
|
||||
.map((entry) => {
|
||||
if (typeof entry === 'string') {
|
||||
return entry;
|
||||
}
|
||||
const record = readRecord(entry);
|
||||
return readString(record?.text) ?? readString(record?.summary) ?? '';
|
||||
})
|
||||
.filter((entry) => entry.length > 0)
|
||||
.join('\n');
|
||||
|
||||
return [
|
||||
createMessage({
|
||||
...context,
|
||||
timestamp,
|
||||
type: 'thinking_message',
|
||||
text: summaryText || 'Reasoning',
|
||||
data: payload,
|
||||
raw,
|
||||
}),
|
||||
];
|
||||
}
|
||||
|
||||
if (payloadType === 'function_call') {
|
||||
const toolName = readString(payload?.name);
|
||||
const toolCallId = readString(payload?.call_id);
|
||||
const argsText = readString(payload?.arguments);
|
||||
const parsedArgs = parseJsonSafely(argsText) ?? argsText;
|
||||
|
||||
if (toolName === 'update_plan') {
|
||||
return [
|
||||
createMessage({
|
||||
...context,
|
||||
timestamp,
|
||||
type: 'todo_task_list',
|
||||
toolName,
|
||||
toolCallId,
|
||||
has_progress_indicator: true,
|
||||
data: parsedArgs,
|
||||
raw,
|
||||
}),
|
||||
];
|
||||
}
|
||||
|
||||
return [
|
||||
createMessage({
|
||||
...context,
|
||||
timestamp,
|
||||
type: 'tool_use_request',
|
||||
toolName,
|
||||
toolCallId,
|
||||
data: parsedArgs,
|
||||
raw,
|
||||
}),
|
||||
];
|
||||
}
|
||||
|
||||
if (payloadType === 'function_call_output') {
|
||||
const output = readString(payload?.output) ?? '';
|
||||
const status: 'success' | 'error' = /exit code:\s*0/i.test(output) ? 'success' : 'error';
|
||||
return [
|
||||
createMessage({
|
||||
...context,
|
||||
timestamp,
|
||||
type: status === 'success' ? 'tool_call_success' : 'tool_call_error',
|
||||
status,
|
||||
toolCallId: readString(payload?.call_id),
|
||||
text: output,
|
||||
data: payload,
|
||||
raw,
|
||||
}),
|
||||
];
|
||||
}
|
||||
|
||||
if (payloadType === 'message') {
|
||||
const role = readString(payload?.role);
|
||||
const content = readArray(payload?.content);
|
||||
const text = content
|
||||
.map((entry) => {
|
||||
const block = readRecord(entry);
|
||||
return readString(block?.text) ?? '';
|
||||
})
|
||||
.filter(Boolean)
|
||||
.join('\n');
|
||||
|
||||
if (role === 'user' && text.includes('<turn_aborted>')) {
|
||||
return [
|
||||
createMessage({
|
||||
...context,
|
||||
timestamp,
|
||||
type: 'session_interrupted',
|
||||
sessionStatus: 'SESSION_ABORTED',
|
||||
text,
|
||||
raw,
|
||||
}),
|
||||
];
|
||||
}
|
||||
|
||||
return [
|
||||
createMessage({
|
||||
...context,
|
||||
timestamp,
|
||||
type: role === 'user' ? 'user_message' : 'assistant_message',
|
||||
text,
|
||||
data: payload,
|
||||
raw,
|
||||
}),
|
||||
];
|
||||
}
|
||||
|
||||
if (payloadType === 'error') {
|
||||
return [
|
||||
createMessage({
|
||||
...context,
|
||||
timestamp,
|
||||
type: 'assistant_error_message',
|
||||
text: readString(payload?.message) ?? 'Codex error',
|
||||
data: payload,
|
||||
raw,
|
||||
}),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
// SDK thread item-based events
|
||||
const item = readRecord(raw.item);
|
||||
if (!item) {
|
||||
return [];
|
||||
}
|
||||
|
||||
const itemType = readString(item.type);
|
||||
if (itemType === 'reasoning') {
|
||||
const text = readString(item.summary) ?? 'Reasoning';
|
||||
return [createMessage({ ...context, timestamp, type: 'thinking_message', text, raw })];
|
||||
}
|
||||
|
||||
if (itemType === 'error') {
|
||||
return [
|
||||
createMessage({
|
||||
...context,
|
||||
timestamp,
|
||||
type: 'assistant_error_message',
|
||||
text: readString(item.message) ?? 'Codex item error',
|
||||
raw,
|
||||
}),
|
||||
];
|
||||
}
|
||||
|
||||
if (itemType === 'todo_list') {
|
||||
return [
|
||||
createMessage({
|
||||
...context,
|
||||
timestamp,
|
||||
type: 'todo_task_list',
|
||||
has_progress_indicator: true,
|
||||
data: item,
|
||||
raw,
|
||||
}),
|
||||
];
|
||||
}
|
||||
|
||||
if (itemType === 'agent_message') {
|
||||
return [
|
||||
createMessage({
|
||||
...context,
|
||||
timestamp,
|
||||
type: 'assistant_message',
|
||||
text: readString(item.message) ?? '',
|
||||
raw,
|
||||
}),
|
||||
];
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Normalizes Gemini payloads from JSON history files and runtime stream chunks.
|
||||
*/
|
||||
function normalizeGeminiPayload(
|
||||
raw: Record<string, unknown>,
|
||||
context: MessageContext,
|
||||
): UnifiedChatMessage[] {
|
||||
const sessionStatusMessage = normalizeSessionStatus(raw, context);
|
||||
if (sessionStatusMessage) {
|
||||
return [sessionStatusMessage];
|
||||
}
|
||||
|
||||
if (Array.isArray(raw.messages)) {
|
||||
const messages: UnifiedChatMessage[] = [];
|
||||
for (const message of raw.messages) {
|
||||
const parsedMessage = readRecord(message);
|
||||
if (!parsedMessage) {
|
||||
continue;
|
||||
}
|
||||
|
||||
messages.push(...normalizeGeminiPayload(parsedMessage, context));
|
||||
}
|
||||
return messages;
|
||||
}
|
||||
|
||||
const timestamp = readString(raw.timestamp) ?? context.timestamp;
|
||||
const type = readString(raw.type);
|
||||
const unified: UnifiedChatMessage[] = [];
|
||||
|
||||
if (type === 'user') {
|
||||
const text = readArray(raw.content)
|
||||
.map((entry) => readString(readRecord(entry)?.text) ?? '')
|
||||
.filter(Boolean)
|
||||
.join('\n');
|
||||
unified.push(createMessage({
|
||||
...context,
|
||||
timestamp,
|
||||
type: 'user_message',
|
||||
text,
|
||||
raw,
|
||||
}));
|
||||
}
|
||||
|
||||
if (type === 'gemini') {
|
||||
const assistantText = readString(raw.content) ?? '';
|
||||
if (assistantText.length) {
|
||||
unified.push(createMessage({
|
||||
...context,
|
||||
timestamp,
|
||||
type: 'assistant_message',
|
||||
text: assistantText,
|
||||
raw,
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
const thoughts = readArray(raw.thoughts);
|
||||
for (const thought of thoughts) {
|
||||
const thoughtRecord = readRecord(thought);
|
||||
if (!thoughtRecord) {
|
||||
continue;
|
||||
}
|
||||
const text = readString(thoughtRecord.description) ?? readString(thoughtRecord.subject) ?? 'Thinking';
|
||||
unified.push(createMessage({
|
||||
...context,
|
||||
timestamp: readString(thoughtRecord.timestamp) ?? timestamp,
|
||||
type: 'thinking_message',
|
||||
text,
|
||||
raw: thoughtRecord,
|
||||
}));
|
||||
}
|
||||
|
||||
const toolCalls = readArray(raw.toolCalls);
|
||||
for (const toolCall of toolCalls) {
|
||||
const toolRecord = readRecord(toolCall);
|
||||
if (!toolRecord) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const status = readString(toolRecord.status) === 'error' ? 'error' : 'success';
|
||||
unified.push(createMessage({
|
||||
...context,
|
||||
timestamp: readString(toolRecord.timestamp) ?? timestamp,
|
||||
type: status === 'success' ? 'tool_call_success' : 'tool_call_error',
|
||||
status,
|
||||
toolName: readString(toolRecord.displayName) ?? readString(toolRecord.name),
|
||||
toolCallId: readString(toolRecord.id),
|
||||
data: {
|
||||
args: toolRecord.args,
|
||||
result: toolRecord.result,
|
||||
resultDisplay: toolRecord.resultDisplay,
|
||||
},
|
||||
raw: toolRecord,
|
||||
}));
|
||||
}
|
||||
|
||||
return unified;
|
||||
}
|
||||
|
||||
/**
|
||||
* Normalizes Cursor payloads from JSONL entries.
|
||||
*/
|
||||
function normalizeCursorPayload(
|
||||
raw: Record<string, unknown>,
|
||||
context: MessageContext,
|
||||
): UnifiedChatMessage[] {
|
||||
const sessionStatusMessage = normalizeSessionStatus(raw, context);
|
||||
if (sessionStatusMessage) {
|
||||
return [sessionStatusMessage];
|
||||
}
|
||||
|
||||
const role = readString(raw.role);
|
||||
const timestamp = readString(raw.timestamp) ?? context.timestamp;
|
||||
const message = readRecord(raw.message);
|
||||
const content = readArray(message?.content);
|
||||
const normalized: UnifiedChatMessage[] = [];
|
||||
|
||||
if (role === 'user') {
|
||||
const text = content
|
||||
.map((entry) => readString(readRecord(entry)?.text) ?? '')
|
||||
.filter(Boolean)
|
||||
.join('\n');
|
||||
const strippedText = stripCursorUserQueryTags(text);
|
||||
if (!strippedText) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return [
|
||||
createMessage({
|
||||
...context,
|
||||
timestamp,
|
||||
type: 'user_message',
|
||||
text: strippedText,
|
||||
raw,
|
||||
}),
|
||||
];
|
||||
}
|
||||
|
||||
if (role !== 'assistant') {
|
||||
return [];
|
||||
}
|
||||
|
||||
for (const entry of content) {
|
||||
const block = readRecord(entry);
|
||||
if (!block) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const blockType = readString(block.type);
|
||||
if (blockType === 'text') {
|
||||
const text = readString(block.text);
|
||||
if (!text) {
|
||||
continue;
|
||||
}
|
||||
|
||||
normalized.push(createMessage({
|
||||
...context,
|
||||
timestamp,
|
||||
type: 'assistant_message',
|
||||
text,
|
||||
raw: block,
|
||||
}));
|
||||
continue;
|
||||
}
|
||||
|
||||
if (blockType === 'tool_use') {
|
||||
const toolName = readString(block.name);
|
||||
const input = block.input;
|
||||
if (toolName === 'CreatePlan') {
|
||||
normalized.push(createMessage({
|
||||
...context,
|
||||
timestamp,
|
||||
type: 'todo_task_list',
|
||||
toolName,
|
||||
has_progress_indicator: false,
|
||||
data: input,
|
||||
raw: block,
|
||||
}));
|
||||
continue;
|
||||
}
|
||||
|
||||
normalized.push(createMessage({
|
||||
...context,
|
||||
timestamp,
|
||||
type: 'tool_call_success',
|
||||
status: 'success',
|
||||
toolName,
|
||||
data: input,
|
||||
raw: block,
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
return normalized;
|
||||
}
|
||||
|
||||
/**
|
||||
* Maps shared session status payloads into unified session event message types.
|
||||
*/
|
||||
function normalizeSessionStatus(
|
||||
raw: Record<string, unknown>,
|
||||
context: MessageContext,
|
||||
): UnifiedChatMessage | null {
|
||||
const sessionStatus = readString(raw.sessionStatus);
|
||||
if (!sessionStatus) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (sessionStatus === 'STARTED') {
|
||||
return createMessage({
|
||||
...context,
|
||||
timestamp: readString(raw.timestamp) ?? context.timestamp,
|
||||
type: 'session_started',
|
||||
sessionStatus: 'STARTED',
|
||||
raw,
|
||||
});
|
||||
}
|
||||
|
||||
if (sessionStatus === 'COMPLETED') {
|
||||
return createMessage({
|
||||
...context,
|
||||
timestamp: readString(raw.timestamp) ?? context.timestamp,
|
||||
type: 'session_completed',
|
||||
sessionStatus: 'COMPLETED',
|
||||
raw,
|
||||
});
|
||||
}
|
||||
|
||||
if (sessionStatus === 'SESSION_ABORTED') {
|
||||
return createMessage({
|
||||
...context,
|
||||
timestamp: readString(raw.timestamp) ?? context.timestamp,
|
||||
type: 'session_interrupted',
|
||||
sessionStatus: 'SESSION_ABORTED',
|
||||
raw,
|
||||
});
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Strips cursor `<user_query>...</user_query>` wrappers from user messages.
|
||||
*/
|
||||
function stripCursorUserQueryTags(value: string): string {
|
||||
return value
|
||||
.replace(/<user_query>/gi, '')
|
||||
.replace(/<\/user_query>/gi, '')
|
||||
.trim();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates one normalized message with defaults.
|
||||
*/
|
||||
function createMessage(input: Omit<UnifiedChatMessage, 'timestamp'> & { timestamp?: string }): UnifiedChatMessage {
|
||||
return {
|
||||
...input,
|
||||
timestamp: input.timestamp ?? new Date().toISOString(),
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Safe object record cast.
|
||||
*/
|
||||
function readRecord(value: unknown): Record<string, unknown> | null {
|
||||
if (!value || typeof value !== 'object' || Array.isArray(value)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return value as Record<string, unknown>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Safe array cast.
|
||||
*/
|
||||
function readArray(value: unknown): unknown[] {
|
||||
return Array.isArray(value) ? value : [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Safe string parser.
|
||||
*/
|
||||
function readString(value: unknown): string | undefined {
|
||||
if (typeof value !== 'string') {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const normalized = value.trim();
|
||||
return normalized.length > 0 ? normalized : undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Safe boolean parser.
|
||||
*/
|
||||
function readBoolean(value: unknown): boolean | undefined {
|
||||
return typeof value === 'boolean' ? value : undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Safe string-array parser.
|
||||
*/
|
||||
function readStringArray(value: unknown): string[] {
|
||||
if (!Array.isArray(value)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return value.filter((entry): entry is string => typeof entry === 'string');
|
||||
}
|
||||
|
||||
/**
|
||||
* Best-effort JSON parse helper.
|
||||
*/
|
||||
function parseJsonSafely(value?: string): unknown {
|
||||
if (!value) {
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
return JSON.parse(value);
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -1,146 +0,0 @@
|
||||
import chokidar from 'chokidar';
|
||||
import os from 'node:os';
|
||||
import path from 'node:path';
|
||||
import { promises as fsPromises } from 'node:fs';
|
||||
|
||||
import { llmSessionsService } from '@/modules/ai-runtime/services/sessions.service.js';
|
||||
import type { LLMProvider } from '@/shared/types/app.js';
|
||||
import { logger } from '@/shared/utils/logger.js';
|
||||
|
||||
// File system watchers for provider project/session folders
|
||||
const PROVIDER_WATCH_PATHS: Array<{ provider: LLMProvider; rootPath: string }> = [
|
||||
{
|
||||
provider: 'claude',
|
||||
rootPath: path.join(os.homedir(), '.claude', 'projects'),
|
||||
},
|
||||
{
|
||||
provider: 'cursor',
|
||||
rootPath: path.join(os.homedir(), '.cursor', 'chats'),
|
||||
},
|
||||
{
|
||||
provider: 'codex',
|
||||
rootPath: path.join(os.homedir(), '.codex', 'sessions'),
|
||||
},
|
||||
{
|
||||
provider: 'gemini',
|
||||
rootPath: path.join(os.homedir(), '.gemini', 'sessions'),
|
||||
},
|
||||
{
|
||||
provider: 'gemini',
|
||||
rootPath: path.join(os.homedir(), '.gemini', 'tmp'),
|
||||
},
|
||||
];
|
||||
|
||||
const WATCHER_IGNORED_PATTERNS = [
|
||||
'**/node_modules/**',
|
||||
'**/.git/**',
|
||||
'**/dist/**',
|
||||
'**/build/**',
|
||||
'**/*.tmp',
|
||||
'**/*.swp',
|
||||
'**/.DS_Store',
|
||||
];
|
||||
|
||||
|
||||
const watchers: any[] = [];
|
||||
type EventType = 'add' | 'change';
|
||||
|
||||
/**
|
||||
* Handles watcher update events and triggers provider index synchronization.
|
||||
*/
|
||||
async function onUpdate(
|
||||
eventType: EventType,
|
||||
filePath: string,
|
||||
provider: LLMProvider,
|
||||
): Promise<void> {
|
||||
if (!isWatcherTargetFile(provider, filePath)) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const result = await llmSessionsService.synchronizeProviderFile(provider, filePath);
|
||||
logger.info(`LLM watcher sync complete for provider "${provider}" after ${eventType}`, {
|
||||
filePath,
|
||||
indexed: result.indexed,
|
||||
});
|
||||
} catch (error) {
|
||||
const message = error instanceof Error ? error.message : String(error);
|
||||
logger.error(`LLM watcher sync failed for provider "${provider}"`, {
|
||||
eventType,
|
||||
filePath,
|
||||
error: message,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Filters watcher events to provider-specific transcript artifact file types.
|
||||
*/
|
||||
function isWatcherTargetFile(provider: LLMProvider, filePath: string): boolean {
|
||||
if (provider === 'gemini') {
|
||||
return filePath.endsWith('.json');
|
||||
}
|
||||
|
||||
return filePath.endsWith('.jsonl');
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes LLM session watchers and performs an initial index sync.
|
||||
*/
|
||||
export async function initializeWatcher(): Promise<void> {
|
||||
logger.info('Setting up LLM session watchers...');
|
||||
|
||||
const initialSync = await llmSessionsService.synchronizeSessions();
|
||||
logger.info('Initial LLM session sync complete.', {
|
||||
processedByProvider: initialSync.processedByProvider,
|
||||
failures: initialSync.failures,
|
||||
});
|
||||
|
||||
for (const { provider, rootPath } of PROVIDER_WATCH_PATHS) {
|
||||
try {
|
||||
// chokidar v4 emits ENOENT via the "error" event for missing roots and will not auto-recover.
|
||||
// Ensure provider folders exist before creating the watcher so watching stays active.
|
||||
await fsPromises.mkdir(rootPath, { recursive: true });
|
||||
|
||||
const watcher = chokidar.watch(rootPath, {
|
||||
ignored: WATCHER_IGNORED_PATTERNS,
|
||||
persistent: true,
|
||||
// Don't fire events for existing files on startup
|
||||
ignoreInitial: true,
|
||||
followSymlinks: false,
|
||||
// Reasonable depth limit
|
||||
depth: 6,
|
||||
// Use polling to fix Windows fs.watch buffering/batching issues.
|
||||
// It now stops relying on native filesystem events and checks for changes at intervals.
|
||||
usePolling: true,
|
||||
// Poll every 2000ms
|
||||
interval: 2_000,
|
||||
// Large binary files are more expensive to poll than text files.
|
||||
binaryInterval: 6_000,
|
||||
// Removed awaitWriteFinish to prevent delays when LLM streams to the file
|
||||
});
|
||||
|
||||
watcher
|
||||
.on('add', (filePath: string) => {
|
||||
void onUpdate('add', filePath, provider);
|
||||
})
|
||||
.on('change', (filePath: string) => {
|
||||
void onUpdate('change', filePath, provider);
|
||||
})
|
||||
.on('error', (error: unknown) => {
|
||||
const message = error instanceof Error ? error.message : String(error);
|
||||
logger.error(`LLM watcher error for provider "${provider}"`, {
|
||||
error: message,
|
||||
});
|
||||
});
|
||||
|
||||
watchers.push(watcher);
|
||||
} catch (error) {
|
||||
const message = error instanceof Error ? error.message : String(error);
|
||||
logger.error(`Failed to initialize LLM watcher for provider "${provider}"`, {
|
||||
rootPath,
|
||||
error: message,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,260 +0,0 @@
|
||||
import path from 'node:path';
|
||||
import fsp, { readFile } from 'node:fs/promises';
|
||||
|
||||
import { scanStateDb } from '@/shared/database/repositories/scan-state.db.js';
|
||||
import { sessionsDb } from '@/shared/database/repositories/sessions.db.js';
|
||||
import { workspaceOriginalPathsDb } from '@/shared/database/repositories/workspace-original-paths.db.js';
|
||||
import type { LLMProvider } from '@/shared/types/app.js';
|
||||
import { AppError } from '@/shared/utils/app-error.js';
|
||||
import { llmProviderRegistry } from '@/modules/ai-runtime/ai-runtime.registry.js';
|
||||
import { llmMessagesUnifier, type UnifiedChatMessage } from '@/modules/ai-runtime/services/messages-unifier.service.js';
|
||||
|
||||
type SyncResult = {
|
||||
processedByProvider: Record<LLMProvider, number>;
|
||||
failures: string[];
|
||||
};
|
||||
|
||||
type SessionHistoryPayload = {
|
||||
sessionId: string;
|
||||
provider: string;
|
||||
workspacePath: string;
|
||||
filePath: string;
|
||||
fileType: 'jsonl' | 'json';
|
||||
entries: unknown[];
|
||||
messages: UnifiedChatMessage[];
|
||||
};
|
||||
|
||||
const SESSION_ID_PATTERN = /^[a-zA-Z0-9._-]{1,120}$/;
|
||||
|
||||
/**
|
||||
* Restricts session IDs before they are used in DB/filesystem operations.
|
||||
*/
|
||||
function sanitizeSessionId(sessionId: string): string {
|
||||
const value = String(sessionId).trim();
|
||||
if (!SESSION_ID_PATTERN.test(value)) {
|
||||
throw new AppError('Invalid session ID format.', {
|
||||
code: 'INVALID_SESSION_ID',
|
||||
statusCode: 400,
|
||||
});
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes one file if it exists.
|
||||
*/
|
||||
async function removeFileIfExists(filePath: string): Promise<boolean> {
|
||||
try {
|
||||
await fsp.unlink(filePath);
|
||||
return true;
|
||||
} catch (error) {
|
||||
const code = (error as NodeJS.ErrnoException).code;
|
||||
if (code === 'ENOENT') {
|
||||
return false;
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses newline-delimited JSON files and preserves malformed lines as raw entries.
|
||||
*/
|
||||
const parseJsonl = (content: string): unknown[] => {
|
||||
const entries: unknown[] = [];
|
||||
const lines = content.split(/\r?\n/);
|
||||
|
||||
for (const line of lines) {
|
||||
const trimmed = line.trim();
|
||||
if (!trimmed) {
|
||||
continue;
|
||||
}
|
||||
|
||||
try {
|
||||
entries.push(JSON.parse(trimmed));
|
||||
} catch {
|
||||
entries.push({ raw: trimmed, parseError: true });
|
||||
}
|
||||
}
|
||||
|
||||
return entries;
|
||||
};
|
||||
|
||||
/**
|
||||
* Parses JSON files and normalizes object payloads into a single-element array.
|
||||
*/
|
||||
const parseJson = (content: string): unknown[] => {
|
||||
try {
|
||||
const parsed = JSON.parse(content) as unknown;
|
||||
return Array.isArray(parsed) ? parsed : [parsed];
|
||||
} catch {
|
||||
return [{ raw: content, parseError: true }];
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Orchestrates provider-specific session indexers and DB-path based cleanup.
|
||||
*/
|
||||
export const llmSessionsService = {
|
||||
/**
|
||||
* Lists indexed sessions from the shared DB, optionally scoped to one provider.
|
||||
*/
|
||||
listIndexedSessions(provider?: string) {
|
||||
const allSessions = sessionsDb.getAllSessions();
|
||||
if (!provider) {
|
||||
return allSessions;
|
||||
}
|
||||
|
||||
return allSessions.filter((session) => session.provider === provider);
|
||||
},
|
||||
|
||||
/**
|
||||
* Reads one indexed session metadata row.
|
||||
*/
|
||||
getIndexedSession(sessionId: string) {
|
||||
const session = sessionsDb.getSessionById(sessionId);
|
||||
if (!session) {
|
||||
throw new AppError(`Session "${sessionId}" was not found.`, {
|
||||
code: 'SESSION_NOT_FOUND',
|
||||
statusCode: 404,
|
||||
});
|
||||
}
|
||||
|
||||
const workspace = workspaceOriginalPathsDb.getWorkspacePath(session.workspace_path);
|
||||
return {
|
||||
...session,
|
||||
workspace_id: workspace?.workspace_id ?? null,
|
||||
};
|
||||
},
|
||||
|
||||
/**
|
||||
* Runs all provider indexers and updates `scan_state.last_scanned_at`.
|
||||
*/
|
||||
async synchronizeSessions(): Promise<SyncResult> {
|
||||
const lastScanAt = scanStateDb.getLastScannedAt();
|
||||
const processedByProvider: Record<LLMProvider, number> = {
|
||||
claude: 0,
|
||||
codex: 0,
|
||||
cursor: 0,
|
||||
gemini: 0,
|
||||
};
|
||||
const failures: string[] = [];
|
||||
|
||||
// Provider-specific session indexers used by the sync orchestrator.
|
||||
const results = await Promise.allSettled(llmProviderRegistry.listProviders().map(async (provider) => ({
|
||||
provider: provider.id,
|
||||
processed: await provider.sessionSynchronizer.synchronize(lastScanAt ?? undefined),
|
||||
})));
|
||||
|
||||
for (const result of results) {
|
||||
if (result.status === 'fulfilled') {
|
||||
processedByProvider[result.value.provider] = result.value.processed;
|
||||
continue;
|
||||
}
|
||||
|
||||
const reason = result.reason instanceof Error ? result.reason.message : String(result.reason);
|
||||
failures.push(reason);
|
||||
}
|
||||
|
||||
scanStateDb.updateLastScannedAt();
|
||||
|
||||
return {
|
||||
processedByProvider,
|
||||
failures,
|
||||
};
|
||||
},
|
||||
|
||||
/**
|
||||
* Indexes one provider artifact file without running a full provider rescan.
|
||||
*/
|
||||
async synchronizeProviderFile(
|
||||
provider: LLMProvider,
|
||||
filePath: string,
|
||||
): Promise<{ provider: LLMProvider; indexed: boolean }> {
|
||||
const resolvedProvider = llmProviderRegistry.listProviders().find((entry) => entry.id === provider);
|
||||
if (!resolvedProvider) {
|
||||
throw new AppError(`No session indexer registered for provider "${provider}".`, {
|
||||
code: 'SESSION_INDEXER_NOT_FOUND',
|
||||
statusCode: 500,
|
||||
});
|
||||
}
|
||||
|
||||
const indexed = await resolvedProvider.sessionSynchronizer.synchronizeFile(filePath);
|
||||
return { provider, indexed };
|
||||
},
|
||||
|
||||
updateSessionCustomName(sessionId: string, sessionCustomName: string): void {
|
||||
const sessionMetadata = sessionsDb.getSessionById(sessionId);
|
||||
if (!sessionMetadata) {
|
||||
throw new AppError('Session not found.', {
|
||||
code: 'SESSION_NOT_FOUND',
|
||||
statusCode: 404,
|
||||
});
|
||||
}
|
||||
|
||||
sessionsDb.updateSessionCustomName(sessionId, sessionCustomName);
|
||||
},
|
||||
|
||||
/**
|
||||
* Deletes a session artifact using only DB `jsonl_path`, then removes the DB row.
|
||||
*/
|
||||
async deleteSessionArtifacts(rawSessionId: string): Promise<{
|
||||
sessionId: string;
|
||||
deletedFromDisk: boolean;
|
||||
deletedFromDatabase: boolean;
|
||||
}> {
|
||||
const sessionId = sanitizeSessionId(rawSessionId);
|
||||
const existingSession = sessionsDb.getSessionById(sessionId);
|
||||
const jsonlPath = existingSession?.jsonl_path ?? null;
|
||||
const deletedFromDisk = jsonlPath ? await removeFileIfExists(jsonlPath) : false;
|
||||
|
||||
if (existingSession) {
|
||||
sessionsDb.deleteSession(sessionId);
|
||||
}
|
||||
|
||||
return {
|
||||
sessionId,
|
||||
deletedFromDisk,
|
||||
deletedFromDatabase: Boolean(existingSession),
|
||||
};
|
||||
},
|
||||
|
||||
/**
|
||||
* Reads session history directly from `sessions.jsonl_path` without legacy fetchers.
|
||||
*/
|
||||
async getSessionHistory(sessionId: string): Promise<SessionHistoryPayload> {
|
||||
const session = sessionsDb.getSessionById(sessionId);
|
||||
if (!session) {
|
||||
throw new AppError(`Session "${sessionId}" was not found.`, {
|
||||
code: 'SESSION_NOT_FOUND',
|
||||
statusCode: 404,
|
||||
});
|
||||
}
|
||||
|
||||
if (!session.jsonl_path) {
|
||||
throw new AppError(`Session "${sessionId}" does not have a history file path.`, {
|
||||
code: 'SESSION_HISTORY_NOT_AVAILABLE',
|
||||
statusCode: 404,
|
||||
});
|
||||
}
|
||||
|
||||
const filePath = session.jsonl_path;
|
||||
const fileContent = await readFile(filePath, 'utf8');
|
||||
const extension = path.extname(filePath).toLowerCase();
|
||||
const isGeminiJson = session.provider === 'gemini' || extension === '.json';
|
||||
const entries = isGeminiJson ? parseJson(fileContent) : parseJsonl(fileContent);
|
||||
|
||||
return {
|
||||
sessionId: session.session_id,
|
||||
provider: session.provider,
|
||||
workspacePath: session.workspace_path,
|
||||
filePath,
|
||||
fileType: isGeminiJson ? 'json' : 'jsonl',
|
||||
entries,
|
||||
messages: llmMessagesUnifier.normalizeHistoryEntries(
|
||||
session.provider,
|
||||
session.session_id,
|
||||
entries,
|
||||
),
|
||||
};
|
||||
},
|
||||
};
|
||||
@@ -1,15 +0,0 @@
|
||||
import { llmProviderRegistry } from '@/modules/ai-runtime/ai-runtime.registry.js';
|
||||
import type { ProviderSkill } from '@/modules/ai-runtime/types/index.js';
|
||||
|
||||
export const llmSkillsService = {
|
||||
/**
|
||||
* Lists skills for one provider.
|
||||
*/
|
||||
async listProviderSkills(
|
||||
providerName: string,
|
||||
options?: { workspacePath?: string },
|
||||
): Promise<ProviderSkill[]> {
|
||||
const provider = llmProviderRegistry.resolveProvider(providerName);
|
||||
return provider.skills.listSkills(options);
|
||||
},
|
||||
};
|
||||
@@ -1,211 +0,0 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import fs from 'node:fs/promises';
|
||||
import os from 'node:os';
|
||||
import path from 'node:path';
|
||||
import test from 'node:test';
|
||||
|
||||
import { AppError } from '@/shared/utils/app-error.js';
|
||||
import { llmAssetsService } from '@/modules/assets/assets.service.js';
|
||||
import { ClaudeProvider } from '@/modules/ai-runtime/providers/claude/claude.provider.js';
|
||||
import { CodexProvider } from '@/modules/ai-runtime/providers/codex/codex.provider.js';
|
||||
import { CursorProvider } from '@/modules/ai-runtime/providers/cursor/cursor.provider.js';
|
||||
import { GeminiProvider } from '@/modules/ai-runtime/providers/gemini/gemini.provider.js';
|
||||
import { llmService } from '@/modules/ai-runtime/services/ai-runtime.service.js';
|
||||
|
||||
const asyncEvents = async function* (events: unknown[]) {
|
||||
for (const event of events) {
|
||||
yield event;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* This test covers the universal image-upload flow: store uploads under `.cloudcli/assets`.
|
||||
*/
|
||||
test('llmAssetsService stores uploaded images in .cloudcli/assets', { concurrency: false }, async () => {
|
||||
const workspaceRoot = await fs.mkdtemp(path.join(os.tmpdir(), 'llm-assets-'));
|
||||
try {
|
||||
const images = await llmAssetsService.storeUploadedImages(
|
||||
[
|
||||
{
|
||||
originalname: 'photo.jpg',
|
||||
mimetype: 'image/jpeg',
|
||||
size: 3,
|
||||
buffer: Buffer.from([0x01, 0x02, 0x03]),
|
||||
},
|
||||
{
|
||||
originalname: 'diagram.png',
|
||||
mimetype: 'image/png',
|
||||
size: 4,
|
||||
buffer: Buffer.from([0x11, 0x12, 0x13, 0x14]),
|
||||
},
|
||||
],
|
||||
{ workspacePath: workspaceRoot },
|
||||
);
|
||||
|
||||
assert.equal(images.length, 2);
|
||||
assert.ok(images[0]?.relativePath.startsWith('.cloudcli/assets/'));
|
||||
assert.ok(images[1]?.relativePath.startsWith('.cloudcli/assets/'));
|
||||
await fs.access(images[0]!.absolutePath);
|
||||
await fs.access(images[1]!.absolutePath);
|
||||
} finally {
|
||||
await fs.rm(workspaceRoot, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* This test covers upload validation: unsupported mime types are rejected.
|
||||
*/
|
||||
test('llmAssetsService rejects unsupported image mime types', async () => {
|
||||
await assert.rejects(
|
||||
llmAssetsService.storeUploadedImages([
|
||||
{
|
||||
originalname: 'file.bmp',
|
||||
mimetype: 'image/bmp',
|
||||
size: 4,
|
||||
buffer: Buffer.from([0x10, 0x20, 0x30, 0x40]),
|
||||
},
|
||||
]),
|
||||
(error: unknown) =>
|
||||
error instanceof AppError &&
|
||||
error.code === 'UNSUPPORTED_IMAGE_TYPE' &&
|
||||
error.statusCode === 400,
|
||||
);
|
||||
});
|
||||
|
||||
/**
|
||||
* This test covers Claude image input support: prompt becomes async iterable with text + base64 image blocks.
|
||||
*/
|
||||
test('claude provider builds async prompt payload with base64 image blocks', { concurrency: false }, async () => {
|
||||
const workspaceRoot = await fs.mkdtemp(path.join(os.tmpdir(), 'llm-claude-img-'));
|
||||
const imagePath = path.join(workspaceRoot, 'sample.jpg');
|
||||
const imageBytes = Buffer.from([0xaa, 0xbb, 0xcc]);
|
||||
await fs.writeFile(imagePath, imageBytes);
|
||||
|
||||
try {
|
||||
const provider = new ClaudeProvider() as any;
|
||||
const promptPayload = await provider.buildPromptInput(
|
||||
'describe this',
|
||||
[imagePath],
|
||||
workspaceRoot,
|
||||
);
|
||||
|
||||
assert.equal(typeof promptPayload[Symbol.asyncIterator], 'function');
|
||||
const iterator = promptPayload[Symbol.asyncIterator]();
|
||||
const first = await iterator.next();
|
||||
assert.equal(first.done, false);
|
||||
|
||||
const message = first.value as {
|
||||
type: string;
|
||||
message: {
|
||||
role: string;
|
||||
content: Array<Record<string, unknown>>;
|
||||
};
|
||||
};
|
||||
|
||||
assert.equal(message.type, 'user');
|
||||
assert.equal(message.message.role, 'user');
|
||||
assert.equal(message.message.content[0]?.type, 'text');
|
||||
assert.equal(message.message.content[0]?.text, 'describe this');
|
||||
assert.equal(message.message.content[1]?.type, 'image');
|
||||
const imageBlock = message.message.content[1] as {
|
||||
source: {
|
||||
type: string;
|
||||
media_type: string;
|
||||
data: string;
|
||||
};
|
||||
};
|
||||
assert.equal(imageBlock.source.type, 'base64');
|
||||
assert.equal(imageBlock.source.media_type, 'image/jpeg');
|
||||
assert.equal(imageBlock.source.data, imageBytes.toString('base64'));
|
||||
} finally {
|
||||
await fs.rm(workspaceRoot, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* This test covers Codex image input support: runStreamed receives text + local_image items.
|
||||
*/
|
||||
test('codex provider sends local_image prompt items when image paths are provided', async () => {
|
||||
const provider = new CodexProvider() as any;
|
||||
let capturedPrompt: unknown;
|
||||
|
||||
provider.loadCodexSdkModule = async () => ({
|
||||
Codex: class {
|
||||
startThread() {
|
||||
return {
|
||||
async runStreamed(prompt: unknown) {
|
||||
capturedPrompt = prompt;
|
||||
return { events: asyncEvents([]) };
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
resumeThread() {
|
||||
return {
|
||||
async runStreamed(prompt: unknown) {
|
||||
capturedPrompt = prompt;
|
||||
return { events: asyncEvents([]) };
|
||||
},
|
||||
};
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
await provider.createSdkExecution({
|
||||
prompt: 'analyze this image',
|
||||
sessionId: 'codex-image-1',
|
||||
isResume: false,
|
||||
imagePaths: ['assets/a.png'],
|
||||
workspacePath: '/tmp/workspace',
|
||||
});
|
||||
|
||||
assert.ok(Array.isArray(capturedPrompt));
|
||||
const promptItems = capturedPrompt as Array<Record<string, unknown>>;
|
||||
assert.equal(promptItems[0]?.type, 'text');
|
||||
assert.equal(promptItems[0]?.text, 'analyze this image');
|
||||
assert.equal(promptItems[1]?.type, 'local_image');
|
||||
assert.equal(promptItems[1]?.path, path.resolve('/tmp/workspace', 'assets/a.png'));
|
||||
});
|
||||
|
||||
/**
|
||||
* This test covers Gemini/Cursor image handling: image paths are appended to the prompt payload.
|
||||
*/
|
||||
test('gemini and cursor providers append image path arrays to prompts', () => {
|
||||
const geminiProvider = new GeminiProvider() as any;
|
||||
const cursorProvider = new CursorProvider() as any;
|
||||
|
||||
const geminiInvocation = geminiProvider.createCliInvocation({
|
||||
prompt: 'summarize',
|
||||
sessionId: 'g-1',
|
||||
isResume: false,
|
||||
imagePaths: ['scripts/pic.jpg'],
|
||||
});
|
||||
|
||||
const cursorInvocation = cursorProvider.createCliInvocation({
|
||||
prompt: 'summarize',
|
||||
sessionId: 'c-1',
|
||||
isResume: false,
|
||||
imagePaths: ['scripts/pic.jpg'],
|
||||
});
|
||||
|
||||
const geminiPrompt = geminiInvocation.args[1];
|
||||
const cursorPrompt = cursorInvocation.args[cursorInvocation.args.length - 1];
|
||||
assert.ok(typeof geminiPrompt === 'string' && geminiPrompt.includes('["scripts/pic.jpg"]'));
|
||||
assert.ok(typeof cursorPrompt === 'string' && cursorPrompt.includes('["scripts/pic.jpg"]'));
|
||||
});
|
||||
|
||||
/**
|
||||
* This test covers API payload validation: imagePaths must be an array of strings.
|
||||
*/
|
||||
test('llmService rejects invalid imagePaths payloads before provider execution', async () => {
|
||||
await assert.rejects(
|
||||
llmService.startSession('cursor', {
|
||||
prompt: 'hello',
|
||||
imagePaths: [1, 2, 3],
|
||||
}),
|
||||
(error: unknown) =>
|
||||
error instanceof AppError &&
|
||||
error.code === 'INVALID_IMAGE_PATHS' &&
|
||||
error.statusCode === 400,
|
||||
);
|
||||
});
|
||||
@@ -1,350 +0,0 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import fs from 'node:fs/promises';
|
||||
import http from 'node:http';
|
||||
import os from 'node:os';
|
||||
import path from 'node:path';
|
||||
import test from 'node:test';
|
||||
|
||||
import TOML from '@iarna/toml';
|
||||
|
||||
import { AppError } from '@/shared/utils/app-error.js';
|
||||
import { llmMcpService } from '@/modules/ai-runtime/services/mcp.service.js';
|
||||
|
||||
const patchHomeDir = (nextHomeDir: string) => {
|
||||
const original = os.homedir;
|
||||
(os as any).homedir = () => nextHomeDir;
|
||||
return () => {
|
||||
(os as any).homedir = original;
|
||||
};
|
||||
};
|
||||
|
||||
const readJson = async (filePath: string): Promise<Record<string, unknown>> => {
|
||||
const content = await fs.readFile(filePath, 'utf8');
|
||||
return JSON.parse(content) as Record<string, unknown>;
|
||||
};
|
||||
|
||||
/**
|
||||
* This test covers Claude MCP support for all scopes (user/local/project) and all transports (stdio/http/sse),
|
||||
* including add, update/list, and remove operations.
|
||||
*/
|
||||
test('llmMcpService handles claude MCP scopes/transports with file-backed persistence', { concurrency: false }, async () => {
|
||||
const tempRoot = await fs.mkdtemp(path.join(os.tmpdir(), 'llm-mcp-claude-'));
|
||||
const workspacePath = path.join(tempRoot, 'workspace');
|
||||
await fs.mkdir(workspacePath, { recursive: true });
|
||||
|
||||
const restoreHomeDir = patchHomeDir(tempRoot);
|
||||
try {
|
||||
await llmMcpService.upsertProviderMcpServer('claude', {
|
||||
name: 'claude-user-stdio',
|
||||
scope: 'user',
|
||||
transport: 'stdio',
|
||||
command: 'npx',
|
||||
args: ['-y', 'my-server'],
|
||||
env: { API_KEY: 'secret' },
|
||||
});
|
||||
|
||||
await llmMcpService.upsertProviderMcpServer('claude', {
|
||||
name: 'claude-local-http',
|
||||
scope: 'local',
|
||||
transport: 'http',
|
||||
url: 'https://example.com/mcp',
|
||||
headers: { Authorization: 'Bearer token' },
|
||||
workspacePath,
|
||||
});
|
||||
|
||||
await llmMcpService.upsertProviderMcpServer('claude', {
|
||||
name: 'claude-project-sse',
|
||||
scope: 'project',
|
||||
transport: 'sse',
|
||||
url: 'https://example.com/sse',
|
||||
headers: { 'X-API-Key': 'abc' },
|
||||
workspacePath,
|
||||
});
|
||||
|
||||
const grouped = await llmMcpService.listProviderMcpServers('claude', { workspacePath });
|
||||
assert.ok(grouped.user.some((server) => server.name === 'claude-user-stdio' && server.transport === 'stdio'));
|
||||
assert.ok(grouped.local.some((server) => server.name === 'claude-local-http' && server.transport === 'http'));
|
||||
assert.ok(grouped.project.some((server) => server.name === 'claude-project-sse' && server.transport === 'sse'));
|
||||
|
||||
// update behavior is the same upsert route with same name
|
||||
await llmMcpService.upsertProviderMcpServer('claude', {
|
||||
name: 'claude-project-sse',
|
||||
scope: 'project',
|
||||
transport: 'sse',
|
||||
url: 'https://example.com/sse-updated',
|
||||
headers: { 'X-API-Key': 'updated' },
|
||||
workspacePath,
|
||||
});
|
||||
|
||||
const projectConfig = await readJson(path.join(workspacePath, '.mcp.json'));
|
||||
const projectServers = projectConfig.mcpServers as Record<string, unknown>;
|
||||
const projectServer = projectServers['claude-project-sse'] as Record<string, unknown>;
|
||||
assert.equal(projectServer.url, 'https://example.com/sse-updated');
|
||||
|
||||
const removeResult = await llmMcpService.removeProviderMcpServer('claude', {
|
||||
name: 'claude-local-http',
|
||||
scope: 'local',
|
||||
workspacePath,
|
||||
});
|
||||
assert.equal(removeResult.removed, true);
|
||||
} finally {
|
||||
restoreHomeDir();
|
||||
await fs.rm(tempRoot, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* This test covers Codex MCP support for user/project scopes, stdio/http formats,
|
||||
* and validation for unsupported scope/transport combinations.
|
||||
*/
|
||||
test('llmMcpService handles codex MCP TOML config and capability validation', { concurrency: false }, async () => {
|
||||
const tempRoot = await fs.mkdtemp(path.join(os.tmpdir(), 'llm-mcp-codex-'));
|
||||
const workspacePath = path.join(tempRoot, 'workspace');
|
||||
await fs.mkdir(workspacePath, { recursive: true });
|
||||
|
||||
const restoreHomeDir = patchHomeDir(tempRoot);
|
||||
try {
|
||||
await llmMcpService.upsertProviderMcpServer('codex', {
|
||||
name: 'codex-user-stdio',
|
||||
scope: 'user',
|
||||
transport: 'stdio',
|
||||
command: 'python',
|
||||
args: ['server.py'],
|
||||
env: { API_KEY: 'x' },
|
||||
envVars: ['API_KEY'],
|
||||
cwd: '/tmp',
|
||||
});
|
||||
|
||||
await llmMcpService.upsertProviderMcpServer('codex', {
|
||||
name: 'codex-project-http',
|
||||
scope: 'project',
|
||||
transport: 'http',
|
||||
url: 'https://codex.example.com/mcp',
|
||||
headers: { 'X-Custom-Header': 'value' },
|
||||
envHttpHeaders: { 'X-API-Key': 'MY_API_KEY_ENV' },
|
||||
bearerTokenEnvVar: 'MY_API_TOKEN',
|
||||
workspacePath,
|
||||
});
|
||||
|
||||
const userTomlPath = path.join(tempRoot, '.codex', 'config.toml');
|
||||
const userConfig = TOML.parse(await fs.readFile(userTomlPath, 'utf8')) as Record<string, unknown>;
|
||||
const userServers = userConfig.mcp_servers as Record<string, unknown>;
|
||||
const userStdio = userServers['codex-user-stdio'] as Record<string, unknown>;
|
||||
assert.equal(userStdio.command, 'python');
|
||||
|
||||
const projectTomlPath = path.join(workspacePath, '.codex', 'config.toml');
|
||||
const projectConfig = TOML.parse(await fs.readFile(projectTomlPath, 'utf8')) as Record<string, unknown>;
|
||||
const projectServers = projectConfig.mcp_servers as Record<string, unknown>;
|
||||
const projectHttp = projectServers['codex-project-http'] as Record<string, unknown>;
|
||||
assert.equal(projectHttp.url, 'https://codex.example.com/mcp');
|
||||
|
||||
await assert.rejects(
|
||||
llmMcpService.upsertProviderMcpServer('codex', {
|
||||
name: 'codex-local',
|
||||
scope: 'local',
|
||||
transport: 'stdio',
|
||||
command: 'node',
|
||||
}),
|
||||
(error: unknown) =>
|
||||
error instanceof AppError &&
|
||||
error.code === 'MCP_SCOPE_NOT_SUPPORTED' &&
|
||||
error.statusCode === 400,
|
||||
);
|
||||
|
||||
await assert.rejects(
|
||||
llmMcpService.upsertProviderMcpServer('codex', {
|
||||
name: 'codex-sse',
|
||||
scope: 'project',
|
||||
transport: 'sse',
|
||||
url: 'https://example.com/sse',
|
||||
workspacePath,
|
||||
}),
|
||||
(error: unknown) =>
|
||||
error instanceof AppError &&
|
||||
error.code === 'MCP_TRANSPORT_NOT_SUPPORTED' &&
|
||||
error.statusCode === 400,
|
||||
);
|
||||
} finally {
|
||||
restoreHomeDir();
|
||||
await fs.rm(tempRoot, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* This test covers Gemini/Cursor MCP JSON formats and user/project scope persistence.
|
||||
*/
|
||||
test('llmMcpService handles gemini and cursor MCP JSON config formats', { concurrency: false }, async () => {
|
||||
const tempRoot = await fs.mkdtemp(path.join(os.tmpdir(), 'llm-mcp-gc-'));
|
||||
const workspacePath = path.join(tempRoot, 'workspace');
|
||||
await fs.mkdir(workspacePath, { recursive: true });
|
||||
|
||||
const restoreHomeDir = patchHomeDir(tempRoot);
|
||||
try {
|
||||
await llmMcpService.upsertProviderMcpServer('gemini', {
|
||||
name: 'gemini-stdio',
|
||||
scope: 'user',
|
||||
transport: 'stdio',
|
||||
command: 'node',
|
||||
args: ['server.js'],
|
||||
env: { TOKEN: '$TOKEN' },
|
||||
cwd: './server',
|
||||
});
|
||||
|
||||
await llmMcpService.upsertProviderMcpServer('gemini', {
|
||||
name: 'gemini-http',
|
||||
scope: 'project',
|
||||
transport: 'http',
|
||||
url: 'https://gemini.example.com/mcp',
|
||||
headers: { Authorization: 'Bearer token' },
|
||||
workspacePath,
|
||||
});
|
||||
|
||||
await llmMcpService.upsertProviderMcpServer('cursor', {
|
||||
name: 'cursor-stdio',
|
||||
scope: 'project',
|
||||
transport: 'stdio',
|
||||
command: 'npx',
|
||||
args: ['-y', 'mcp-server'],
|
||||
env: { API_KEY: 'value' },
|
||||
workspacePath,
|
||||
});
|
||||
|
||||
await llmMcpService.upsertProviderMcpServer('cursor', {
|
||||
name: 'cursor-http',
|
||||
scope: 'user',
|
||||
transport: 'http',
|
||||
url: 'http://localhost:3333/mcp',
|
||||
headers: { API_KEY: 'value' },
|
||||
});
|
||||
|
||||
const geminiUserConfig = await readJson(path.join(tempRoot, '.gemini', 'settings.json'));
|
||||
const geminiUserServer = (geminiUserConfig.mcpServers as Record<string, unknown>)['gemini-stdio'] as Record<string, unknown>;
|
||||
assert.equal(geminiUserServer.command, 'node');
|
||||
assert.equal(geminiUserServer.type, undefined);
|
||||
|
||||
const geminiProjectConfig = await readJson(path.join(workspacePath, '.gemini', 'settings.json'));
|
||||
const geminiProjectServer = (geminiProjectConfig.mcpServers as Record<string, unknown>)['gemini-http'] as Record<string, unknown>;
|
||||
assert.equal(geminiProjectServer.type, 'http');
|
||||
|
||||
const cursorUserConfig = await readJson(path.join(tempRoot, '.cursor', 'mcp.json'));
|
||||
const cursorHttpServer = (cursorUserConfig.mcpServers as Record<string, unknown>)['cursor-http'] as Record<string, unknown>;
|
||||
assert.equal(cursorHttpServer.url, 'http://localhost:3333/mcp');
|
||||
assert.equal(cursorHttpServer.type, undefined);
|
||||
} finally {
|
||||
restoreHomeDir();
|
||||
await fs.rm(tempRoot, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* This test covers the global MCP adder requirement: only http/stdio are allowed and
|
||||
* one payload is written to all providers.
|
||||
*/
|
||||
test('llmMcpService global adder writes to all providers and rejects unsupported transports', { concurrency: false }, async () => {
|
||||
const tempRoot = await fs.mkdtemp(path.join(os.tmpdir(), 'llm-mcp-global-'));
|
||||
const workspacePath = path.join(tempRoot, 'workspace');
|
||||
await fs.mkdir(workspacePath, { recursive: true });
|
||||
|
||||
const restoreHomeDir = patchHomeDir(tempRoot);
|
||||
try {
|
||||
const globalResult = await llmMcpService.addMcpServerToAllProviders({
|
||||
name: 'global-http',
|
||||
scope: 'project',
|
||||
transport: 'http',
|
||||
url: 'https://global.example.com/mcp',
|
||||
workspacePath,
|
||||
});
|
||||
|
||||
assert.equal(globalResult.length, 4);
|
||||
assert.ok(globalResult.every((entry) => entry.created === true));
|
||||
|
||||
const claudeProject = await readJson(path.join(workspacePath, '.mcp.json'));
|
||||
assert.ok((claudeProject.mcpServers as Record<string, unknown>)['global-http']);
|
||||
|
||||
const codexProject = TOML.parse(await fs.readFile(path.join(workspacePath, '.codex', 'config.toml'), 'utf8')) as Record<string, unknown>;
|
||||
assert.ok((codexProject.mcp_servers as Record<string, unknown>)['global-http']);
|
||||
|
||||
const geminiProject = await readJson(path.join(workspacePath, '.gemini', 'settings.json'));
|
||||
assert.ok((geminiProject.mcpServers as Record<string, unknown>)['global-http']);
|
||||
|
||||
const cursorProject = await readJson(path.join(workspacePath, '.cursor', 'mcp.json'));
|
||||
assert.ok((cursorProject.mcpServers as Record<string, unknown>)['global-http']);
|
||||
|
||||
await assert.rejects(
|
||||
llmMcpService.addMcpServerToAllProviders({
|
||||
name: 'global-sse',
|
||||
scope: 'project',
|
||||
transport: 'sse',
|
||||
url: 'https://example.com/sse',
|
||||
workspacePath,
|
||||
}),
|
||||
(error: unknown) =>
|
||||
error instanceof AppError &&
|
||||
error.code === 'INVALID_GLOBAL_MCP_TRANSPORT' &&
|
||||
error.statusCode === 400,
|
||||
);
|
||||
} finally {
|
||||
restoreHomeDir();
|
||||
await fs.rm(tempRoot, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* This test covers "run" behavior for both stdio and http MCP servers.
|
||||
*/
|
||||
test('llmMcpService runProviderServer probes stdio and http MCP servers', { concurrency: false }, async () => {
|
||||
const tempRoot = await fs.mkdtemp(path.join(os.tmpdir(), 'llm-mcp-run-'));
|
||||
const workspacePath = path.join(tempRoot, 'workspace');
|
||||
await fs.mkdir(workspacePath, { recursive: true });
|
||||
|
||||
const restoreHomeDir = patchHomeDir(tempRoot);
|
||||
const server = http.createServer((_req, res) => {
|
||||
res.statusCode = 200;
|
||||
res.end('ok');
|
||||
});
|
||||
|
||||
try {
|
||||
await new Promise<void>((resolve) => server.listen(0, '127.0.0.1', () => resolve()));
|
||||
const address = server.address();
|
||||
assert.ok(address && typeof address === 'object');
|
||||
const url = `http://127.0.0.1:${address.port}/mcp`;
|
||||
|
||||
await llmMcpService.upsertProviderMcpServer('gemini', {
|
||||
name: 'probe-http',
|
||||
scope: 'project',
|
||||
transport: 'http',
|
||||
url,
|
||||
workspacePath,
|
||||
});
|
||||
|
||||
await llmMcpService.upsertProviderMcpServer('cursor', {
|
||||
name: 'probe-stdio',
|
||||
scope: 'project',
|
||||
transport: 'stdio',
|
||||
command: process.execPath,
|
||||
args: ['-e', 'process.exit(0)'],
|
||||
workspacePath,
|
||||
});
|
||||
|
||||
const httpProbe = await llmMcpService.runProviderMcpServer('gemini', {
|
||||
name: 'probe-http',
|
||||
scope: 'project',
|
||||
workspacePath,
|
||||
});
|
||||
assert.equal(httpProbe.reachable, true);
|
||||
assert.equal(httpProbe.transport, 'http');
|
||||
|
||||
const stdioProbe = await llmMcpService.runProviderMcpServer('cursor', {
|
||||
name: 'probe-stdio',
|
||||
scope: 'project',
|
||||
workspacePath,
|
||||
});
|
||||
assert.equal(stdioProbe.reachable, true);
|
||||
assert.equal(stdioProbe.transport, 'stdio');
|
||||
} finally {
|
||||
server.close();
|
||||
restoreHomeDir();
|
||||
await fs.rm(tempRoot, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1,337 +0,0 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import test from 'node:test';
|
||||
|
||||
import { llmMessagesUnifier } from '@/modules/ai-runtime/services/messages-unifier.service.js';
|
||||
|
||||
/**
|
||||
* This test covers helper-3 Claude normalization: user/assistant/thinking/tool-use/tool-result/error.
|
||||
*/
|
||||
test('llmMessagesUnifier normalizes claude message categories', () => {
|
||||
const sessionId = 'claude-session-1';
|
||||
|
||||
const thinking = llmMessagesUnifier.normalizeUnknown('claude', sessionId, {
|
||||
type: 'assistant',
|
||||
timestamp: '2026-04-06T10:00:00.000Z',
|
||||
message: {
|
||||
content: [
|
||||
{ type: 'thinking', thinking: '' },
|
||||
{ type: 'text', text: 'Assistant response' },
|
||||
{ type: 'tool_use', id: 'toolu_1', name: 'Read', input: { file_path: 'a.txt' } },
|
||||
],
|
||||
},
|
||||
});
|
||||
assert.equal(thinking[0]?.type, 'thinking_message');
|
||||
assert.equal(thinking[0]?.text, 'Thinking');
|
||||
assert.equal(thinking[1]?.type, 'assistant_message');
|
||||
assert.equal(thinking[2]?.type, 'tool_use_request');
|
||||
|
||||
const user = llmMessagesUnifier.normalizeUnknown('claude', sessionId, {
|
||||
type: 'user',
|
||||
message: {
|
||||
content: [
|
||||
{ type: 'text', text: 'hello there' },
|
||||
{
|
||||
type: 'image',
|
||||
source: {
|
||||
type: 'base64',
|
||||
media_type: 'image/png',
|
||||
data: 'image-b64',
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
assert.equal(user[0]?.type, 'user_message');
|
||||
assert.equal(user[0]?.text, 'hello there');
|
||||
assert.deepEqual(user[0]?.images, ['image-b64']);
|
||||
|
||||
const toolResult = llmMessagesUnifier.normalizeUnknown('claude', sessionId, {
|
||||
type: 'user',
|
||||
toolUseResult: { success: false, reason: 'denied' },
|
||||
});
|
||||
assert.equal(toolResult[0]?.type, 'tool_call_error');
|
||||
|
||||
const toolResultSuccess = llmMessagesUnifier.normalizeUnknown('claude', sessionId, {
|
||||
type: 'user',
|
||||
toolUseResult: { type: 'create', filePath: 'hello.py' },
|
||||
});
|
||||
assert.equal(toolResultSuccess[0]?.type, 'tool_call_success');
|
||||
|
||||
const todo = llmMessagesUnifier.normalizeUnknown('claude', sessionId, {
|
||||
type: 'assistant',
|
||||
message: {
|
||||
content: [
|
||||
{
|
||||
type: 'tool_use',
|
||||
id: 'toolu_todo',
|
||||
name: 'TaskUpdate',
|
||||
input: { taskId: '1', status: 'in_progress' },
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
assert.equal(todo[0]?.type, 'todo_task_list');
|
||||
assert.equal(todo[0]?.has_progress_indicator, true);
|
||||
|
||||
const assistantError = llmMessagesUnifier.normalizeUnknown('claude', sessionId, {
|
||||
type: 'assistant',
|
||||
error: 'rate_limit',
|
||||
message: { content: [] },
|
||||
});
|
||||
assert.equal(assistantError[0]?.type, 'assistant_error_message');
|
||||
});
|
||||
|
||||
/**
|
||||
* This test covers helper-3 Codex normalization: user_message, reasoning fallback, tool request/success/error, todo plan updates.
|
||||
*/
|
||||
test('llmMessagesUnifier normalizes codex message categories', () => {
|
||||
const sessionId = 'codex-session-1';
|
||||
|
||||
const user = llmMessagesUnifier.normalizeUnknown('codex', sessionId, {
|
||||
type: 'event_msg',
|
||||
payload: {
|
||||
type: 'user_message',
|
||||
message: 'run command',
|
||||
local_images: ['a.png'],
|
||||
images: ['b.png'],
|
||||
},
|
||||
});
|
||||
assert.equal(user[0]?.type, 'user_message');
|
||||
assert.deepEqual(user[0]?.images, ['a.png', 'b.png']);
|
||||
|
||||
const reasoning = llmMessagesUnifier.normalizeUnknown('codex', sessionId, {
|
||||
type: 'response_item',
|
||||
payload: {
|
||||
type: 'reasoning',
|
||||
summary: [],
|
||||
},
|
||||
});
|
||||
assert.equal(reasoning[0]?.type, 'thinking_message');
|
||||
assert.equal(reasoning[0]?.text, 'Reasoning');
|
||||
|
||||
const toolRequest = llmMessagesUnifier.normalizeUnknown('codex', sessionId, {
|
||||
type: 'response_item',
|
||||
payload: {
|
||||
type: 'function_call',
|
||||
name: 'shell_command',
|
||||
arguments: '{"command":"echo hi"}',
|
||||
call_id: 'call_1',
|
||||
},
|
||||
});
|
||||
assert.equal(toolRequest[0]?.type, 'tool_use_request');
|
||||
|
||||
const assistantMessage = llmMessagesUnifier.normalizeUnknown('codex', sessionId, {
|
||||
type: 'response_item',
|
||||
payload: {
|
||||
type: 'message',
|
||||
role: 'assistant',
|
||||
content: [{ type: 'output_text', text: 'Command finished' }],
|
||||
},
|
||||
});
|
||||
assert.equal(assistantMessage[0]?.type, 'assistant_message');
|
||||
assert.equal(assistantMessage[0]?.text, 'Command finished');
|
||||
|
||||
const todo = llmMessagesUnifier.normalizeUnknown('codex', sessionId, {
|
||||
type: 'response_item',
|
||||
payload: {
|
||||
type: 'function_call',
|
||||
name: 'update_plan',
|
||||
arguments: '{"plan":[{"step":"A","status":"in_progress"}]}',
|
||||
call_id: 'call_2',
|
||||
},
|
||||
});
|
||||
assert.equal(todo[0]?.type, 'todo_task_list');
|
||||
assert.equal(todo[0]?.has_progress_indicator, true);
|
||||
|
||||
const toolError = llmMessagesUnifier.normalizeUnknown('codex', sessionId, {
|
||||
type: 'event_msg',
|
||||
payload: {
|
||||
type: 'exec_command_end',
|
||||
status: 'failed',
|
||||
call_id: 'call_3',
|
||||
},
|
||||
});
|
||||
assert.equal(toolError[0]?.type, 'tool_call_error');
|
||||
|
||||
const toolSuccess = llmMessagesUnifier.normalizeUnknown('codex', sessionId, {
|
||||
type: 'response_item',
|
||||
payload: {
|
||||
type: 'function_call_output',
|
||||
call_id: 'call_4',
|
||||
output: 'Exit code: 0\nWall time: 0.1 seconds',
|
||||
},
|
||||
});
|
||||
assert.equal(toolSuccess[0]?.type, 'tool_call_success');
|
||||
|
||||
const interruptedTurn = llmMessagesUnifier.normalizeUnknown('codex', sessionId, {
|
||||
type: 'response_item',
|
||||
payload: {
|
||||
type: 'message',
|
||||
role: 'user',
|
||||
content: [{ type: 'input_text', text: '<turn_aborted>\nInterrupted\n</turn_aborted>' }],
|
||||
},
|
||||
});
|
||||
assert.equal(interruptedTurn[0]?.type, 'session_interrupted');
|
||||
|
||||
const payloadError = llmMessagesUnifier.normalizeUnknown('codex', sessionId, {
|
||||
type: 'response_item',
|
||||
payload: {
|
||||
type: 'error',
|
||||
message: 'codex payload error',
|
||||
},
|
||||
});
|
||||
assert.equal(payloadError[0]?.type, 'assistant_error_message');
|
||||
|
||||
const streamError = llmMessagesUnifier.normalizeUnknown('codex', sessionId, {
|
||||
type: 'error',
|
||||
message: 'codex stream error',
|
||||
});
|
||||
assert.equal(streamError[0]?.type, 'assistant_error_message');
|
||||
});
|
||||
|
||||
/**
|
||||
* This test covers helper-3 Gemini normalization from JSON history: user/assistant/thought/tool-call success and error.
|
||||
*/
|
||||
test('llmMessagesUnifier normalizes gemini history categories', () => {
|
||||
const sessionId = 'gemini-session-1';
|
||||
const messages = llmMessagesUnifier.normalizeUnknown('gemini', sessionId, {
|
||||
sessionId,
|
||||
messages: [
|
||||
{
|
||||
type: 'user',
|
||||
timestamp: '2026-04-01T10:00:00.000Z',
|
||||
content: [{ text: 'create files' }],
|
||||
},
|
||||
{
|
||||
type: 'gemini',
|
||||
timestamp: '2026-04-01T10:00:01.000Z',
|
||||
content: 'I will do it',
|
||||
thoughts: [{ subject: 'Planning', description: 'Thinking path' }],
|
||||
toolCalls: [
|
||||
{ id: 't1', name: 'write_file', displayName: 'Write File', status: 'success' },
|
||||
{ id: 't2', name: 'write_file', status: 'error' },
|
||||
],
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
assert.ok(messages.some((message) => message.type === 'user_message'));
|
||||
assert.ok(messages.some((message) => message.type === 'assistant_message'));
|
||||
assert.ok(messages.some((message) => message.type === 'thinking_message'));
|
||||
assert.ok(messages.some((message) => message.type === 'tool_call_success'));
|
||||
assert.ok(messages.some((message) => message.type === 'tool_call_error'));
|
||||
|
||||
const assistantIndex = messages.findIndex((message) => message.type === 'assistant_message');
|
||||
const thinkingIndex = messages.findIndex((message) => message.type === 'thinking_message');
|
||||
assert.ok(assistantIndex >= 0);
|
||||
assert.ok(thinkingIndex > assistantIndex);
|
||||
|
||||
const successfulTool = messages.find((message) => message.type === 'tool_call_success');
|
||||
assert.equal(successfulTool?.toolName, 'Write File');
|
||||
});
|
||||
|
||||
/**
|
||||
* This test covers helper-3 Cursor normalization: strip user_query tags and parse CreatePlan as todo with no progress indicator.
|
||||
*/
|
||||
test('llmMessagesUnifier normalizes cursor categories and strips user_query tags', () => {
|
||||
const sessionId = 'cursor-session-1';
|
||||
const user = llmMessagesUnifier.normalizeUnknown('cursor', sessionId, {
|
||||
role: 'user',
|
||||
message: {
|
||||
content: [{ type: 'text', text: '<user_query>\nhello world\n</user_query>' }],
|
||||
},
|
||||
});
|
||||
assert.equal(user[0]?.type, 'user_message');
|
||||
assert.equal(user[0]?.text, 'hello world');
|
||||
|
||||
const assistant = llmMessagesUnifier.normalizeUnknown('cursor', sessionId, {
|
||||
role: 'assistant',
|
||||
message: {
|
||||
content: [
|
||||
{ type: 'text', text: 'Starting work' },
|
||||
{
|
||||
type: 'tool_use',
|
||||
name: 'CreatePlan',
|
||||
input: {
|
||||
todos: [{ id: '1', content: 'Do it' }],
|
||||
},
|
||||
},
|
||||
{
|
||||
type: 'tool_use',
|
||||
name: 'ApplyPatch',
|
||||
input: {
|
||||
patch: '*** Begin Patch',
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
|
||||
assert.ok(assistant.some((message) => message.type === 'assistant_message'));
|
||||
const todoMessage = assistant.find((message) => message.type === 'todo_task_list');
|
||||
assert.equal(todoMessage?.has_progress_indicator, false);
|
||||
assert.ok(assistant.some((message) => message.type === 'tool_call_success'));
|
||||
});
|
||||
|
||||
/**
|
||||
* This test covers shared session status normalization: started/completed/interrupted payloads.
|
||||
*/
|
||||
test('llmMessagesUnifier normalizes shared session status events', () => {
|
||||
const sessionId = 'shared-session-1';
|
||||
const started = llmMessagesUnifier.normalizeUnknown('codex', sessionId, {
|
||||
sessionId,
|
||||
sessionStatus: 'STARTED',
|
||||
});
|
||||
assert.equal(started[0]?.type, 'session_started');
|
||||
|
||||
const completed = llmMessagesUnifier.normalizeUnknown('gemini', sessionId, {
|
||||
sessionId,
|
||||
sessionStatus: 'COMPLETED',
|
||||
});
|
||||
assert.equal(completed[0]?.type, 'session_completed');
|
||||
|
||||
const interrupted = llmMessagesUnifier.normalizeUnknown('claude', sessionId, {
|
||||
sessionId,
|
||||
sessionStatus: 'SESSION_ABORTED',
|
||||
});
|
||||
assert.equal(interrupted[0]?.type, 'session_interrupted');
|
||||
});
|
||||
|
||||
/**
|
||||
* This test covers helper-3 notification flow: Claude permission callbacks should surface as tool_use_request.
|
||||
*/
|
||||
test('llmMessagesUnifier normalizes pre-unified tool_use_request payloads', () => {
|
||||
const sessionId = 'permission-session-1';
|
||||
const messages = llmMessagesUnifier.normalizeUnknown('claude', sessionId, {
|
||||
type: 'tool_use_request',
|
||||
toolName: 'Read',
|
||||
input: { filePath: 'notes.txt' },
|
||||
toolUseID: 'toolu_123',
|
||||
title: 'Claude wants to read notes.txt',
|
||||
});
|
||||
|
||||
assert.equal(messages[0]?.type, 'tool_use_request');
|
||||
assert.equal(messages[0]?.toolName, 'Read');
|
||||
assert.equal(messages[0]?.toolCallId, 'toolu_123');
|
||||
});
|
||||
|
||||
/**
|
||||
* This test covers helper-3 runtime-event fallback behavior for non-JSON stdout/stderr stream messages.
|
||||
*/
|
||||
test('llmMessagesUnifier normalizes fallback session events with channel-aware error typing', () => {
|
||||
const messages = llmMessagesUnifier.normalizeSessionEvents('gemini', 'runtime-session-1', [
|
||||
{
|
||||
timestamp: '2026-04-06T12:00:00.000Z',
|
||||
channel: 'stdout',
|
||||
message: 'Process started',
|
||||
},
|
||||
{
|
||||
timestamp: '2026-04-06T12:00:01.000Z',
|
||||
channel: 'error',
|
||||
message: 'Process failed',
|
||||
},
|
||||
]);
|
||||
|
||||
assert.equal(messages[0]?.type, 'assistant_message');
|
||||
assert.equal(messages[1]?.type, 'assistant_error_message');
|
||||
});
|
||||
@@ -1,326 +0,0 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import fs from 'node:fs/promises';
|
||||
import os from 'node:os';
|
||||
import path from 'node:path';
|
||||
import test from 'node:test';
|
||||
|
||||
import { AppError } from '@/shared/utils/app-error.js';
|
||||
import { llmService } from '@/modules/ai-runtime/services/ai-runtime.service.js';
|
||||
import { CursorProvider } from '@/modules/ai-runtime/providers/cursor/cursor.provider.js';
|
||||
import { GeminiProvider } from '@/modules/ai-runtime/providers/gemini/gemini.provider.js';
|
||||
import { CodexProvider } from '@/modules/ai-runtime/providers/codex/codex.provider.js';
|
||||
import { ClaudeProvider } from '@/modules/ai-runtime/providers/claude/claude.provider.js';
|
||||
|
||||
const asyncEvents = async function* (events: unknown[]) {
|
||||
for (const event of events) {
|
||||
yield event;
|
||||
}
|
||||
};
|
||||
|
||||
// This test covers Cursor start/resume command construction, including yolo/model/resume flags.
|
||||
test('cursor provider builds start/resume CLI invocations correctly', () => {
|
||||
const provider = new CursorProvider() as any;
|
||||
|
||||
const start = provider.createCliInvocation({
|
||||
prompt: 'build feature',
|
||||
sessionId: 'cursor-session-1',
|
||||
isResume: false,
|
||||
model: 'composer-2',
|
||||
allowYolo: true,
|
||||
workspacePath: '/tmp/workspace',
|
||||
});
|
||||
assert.equal(start.command, 'cursor-agent');
|
||||
assert.deepEqual(start.args, [
|
||||
'--print',
|
||||
'--trust',
|
||||
'--output-format',
|
||||
'stream-json',
|
||||
'--yolo',
|
||||
'--model',
|
||||
'composer-2',
|
||||
'build feature',
|
||||
]);
|
||||
|
||||
const resume = provider.createCliInvocation({
|
||||
prompt: 'continue',
|
||||
sessionId: 'cursor-session-1',
|
||||
isResume: true,
|
||||
workspacePath: '/tmp/workspace',
|
||||
});
|
||||
assert.equal(resume.command, 'cursor-agent');
|
||||
assert.deepEqual(resume.args, [
|
||||
'--print',
|
||||
'--trust',
|
||||
'--output-format',
|
||||
'stream-json',
|
||||
'--resume',
|
||||
'cursor-session-1',
|
||||
'continue',
|
||||
]);
|
||||
});
|
||||
|
||||
// This test covers Cursor model-list parsing, including ANSI stripping and current/default flags.
|
||||
test('cursor provider parses model list output into normalized models', async () => {
|
||||
const provider = new CursorProvider() as any;
|
||||
|
||||
provider.runCommandForOutput = async () => [
|
||||
'\u001b[32mAvailable models\u001b[0m',
|
||||
'auto - Auto (current)',
|
||||
'composer-2-fast - Composer 2 Fast (default)',
|
||||
'Tip: use --model',
|
||||
].join('\n');
|
||||
|
||||
const models = await provider.listModels();
|
||||
assert.equal(models.length, 2);
|
||||
assert.deepEqual(models[0], {
|
||||
value: 'auto',
|
||||
displayName: 'auto',
|
||||
description: 'Auto',
|
||||
current: true,
|
||||
default: false,
|
||||
supportsThinkingModes: false,
|
||||
supportedThinkingModes: [],
|
||||
});
|
||||
assert.equal(models[1].value, 'composer-2-fast');
|
||||
assert.equal(models[1].default, true);
|
||||
});
|
||||
|
||||
// This test covers Gemini start/resume CLI construction and curated model list contract.
|
||||
test('gemini provider builds start/resume CLI invocations and exposes curated models', async () => {
|
||||
const provider = new GeminiProvider() as any;
|
||||
|
||||
const start = provider.createCliInvocation({
|
||||
prompt: 'explain architecture',
|
||||
sessionId: 'gemini-session-1',
|
||||
isResume: false,
|
||||
model: 'gemini-2.5-pro',
|
||||
workspacePath: '/tmp/workspace',
|
||||
});
|
||||
assert.equal(start.command, 'gemini');
|
||||
assert.deepEqual(start.args, [
|
||||
'--prompt',
|
||||
'explain architecture',
|
||||
'--output-format',
|
||||
'stream-json',
|
||||
'--model',
|
||||
'gemini-2.5-pro',
|
||||
]);
|
||||
|
||||
const resume = provider.createCliInvocation({
|
||||
prompt: 'continue',
|
||||
sessionId: 'gemini-session-1',
|
||||
isResume: true,
|
||||
workspacePath: '/tmp/workspace',
|
||||
});
|
||||
assert.deepEqual(resume.args, [
|
||||
'--prompt',
|
||||
'continue',
|
||||
'--output-format',
|
||||
'stream-json',
|
||||
'--resume',
|
||||
'gemini-session-1',
|
||||
]);
|
||||
|
||||
const models = await provider.listModels();
|
||||
assert.ok(models.some((model: { value?: string }) => model.value === 'gemini-2.5-pro'));
|
||||
});
|
||||
|
||||
// This test covers Codex start/resume behavior and abort-controller based stop behavior.
|
||||
test('codex provider start/resume use correct SDK thread methods and stop aborts signal', async () => {
|
||||
const provider = new CodexProvider() as any;
|
||||
|
||||
const calls: Array<{ fn: 'start' | 'resume'; sessionId?: string; options: Record<string, unknown> }> = [];
|
||||
let capturedSignal: AbortSignal | undefined;
|
||||
|
||||
const fakeThread = {
|
||||
async runStreamed(_prompt: string, options?: { signal?: AbortSignal }) {
|
||||
capturedSignal = options?.signal;
|
||||
return { events: asyncEvents([{ type: 'chunk' }]) };
|
||||
},
|
||||
};
|
||||
|
||||
provider.loadCodexSdkModule = async () => ({
|
||||
Codex: class {
|
||||
startThread(options?: Record<string, unknown>) {
|
||||
calls.push({ fn: 'start', options: options ?? {} });
|
||||
return fakeThread;
|
||||
}
|
||||
|
||||
resumeThread(sessionId: string, options?: Record<string, unknown>) {
|
||||
calls.push({ fn: 'resume', sessionId, options: options ?? {} });
|
||||
return fakeThread;
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
const startExec = await provider.createSdkExecution({
|
||||
prompt: 'start codex',
|
||||
sessionId: 'codex-session-1',
|
||||
isResume: false,
|
||||
model: 'gpt-5.4',
|
||||
thinkingMode: 'high',
|
||||
workspacePath: '/tmp/workspace',
|
||||
});
|
||||
assert.equal(calls[0]?.fn, 'start');
|
||||
assert.equal(calls[0]?.options.model, 'gpt-5.4');
|
||||
assert.equal(calls[0]?.options.modelReasoningEffort, 'high');
|
||||
assert.equal(calls[0]?.options.workingDirectory, '/tmp/workspace');
|
||||
|
||||
assert.equal(await startExec.stop(), true);
|
||||
assert.equal(capturedSignal?.aborted, true);
|
||||
|
||||
await provider.createSdkExecution({
|
||||
prompt: 'resume codex',
|
||||
sessionId: 'codex-session-1',
|
||||
isResume: true,
|
||||
workspacePath: '/tmp/workspace',
|
||||
});
|
||||
assert.equal(calls[1]?.fn, 'resume');
|
||||
assert.equal(calls[1]?.sessionId, 'codex-session-1');
|
||||
});
|
||||
|
||||
// This test covers Codex model-list loading from ~/.codex/models_cache.json and model-shape mapping.
|
||||
test('codex provider reads models_cache.json and maps model metadata', async () => {
|
||||
const provider = new CodexProvider();
|
||||
const tempRoot = await fs.mkdtemp(path.join(os.tmpdir(), 'codex-models-'));
|
||||
const codexDir = path.join(tempRoot, '.codex');
|
||||
await fs.mkdir(codexDir, { recursive: true });
|
||||
await fs.writeFile(
|
||||
path.join(codexDir, 'models_cache.json'),
|
||||
JSON.stringify({
|
||||
models: [
|
||||
{
|
||||
slug: 'gpt-5.4',
|
||||
display_name: 'GPT-5.4',
|
||||
description: 'Latest frontier agentic coding model.',
|
||||
priority: 1,
|
||||
supported_reasoning_levels: [
|
||||
{ effort: 'low' },
|
||||
{ effort: 'medium' },
|
||||
{ effort: 'high' },
|
||||
],
|
||||
},
|
||||
],
|
||||
}),
|
||||
'utf8',
|
||||
);
|
||||
|
||||
const originalHomeDir = os.homedir;
|
||||
(os as any).homedir = () => tempRoot;
|
||||
|
||||
try {
|
||||
const models = await provider.listModels();
|
||||
assert.equal(models.length, 1);
|
||||
assert.equal(models[0]?.value, 'gpt-5.4');
|
||||
assert.equal(models[0]?.default, true);
|
||||
assert.deepEqual(models[0]?.supportedThinkingModes, ['low', 'medium', 'high']);
|
||||
} finally {
|
||||
(os as any).homedir = originalHomeDir;
|
||||
await fs.rm(tempRoot, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
|
||||
// This test covers explicit start/resume payload control for model/thinking without implicit persistence.
|
||||
test('codex provider does not persist model/thinking between launches', async () => {
|
||||
const provider = new CodexProvider() as any;
|
||||
const threadOptionsHistory: Record<string, unknown>[] = [];
|
||||
|
||||
provider.loadCodexSdkModule = async () => ({
|
||||
Codex: class {
|
||||
startThread(options?: Record<string, unknown>) {
|
||||
threadOptionsHistory.push(options ?? {});
|
||||
return {
|
||||
async runStreamed() {
|
||||
return { events: asyncEvents([]) };
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
resumeThread() {
|
||||
return {
|
||||
async runStreamed() {
|
||||
return { events: asyncEvents([]) };
|
||||
},
|
||||
};
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
await provider.launchSession({
|
||||
prompt: 'explicit launch options',
|
||||
sessionId: 'codex-pref-1',
|
||||
model: 'gpt-5.4',
|
||||
thinkingMode: 'xhigh',
|
||||
});
|
||||
|
||||
await provider.launchSession({
|
||||
prompt: 'follow-up launch without options',
|
||||
sessionId: 'codex-pref-1',
|
||||
});
|
||||
|
||||
assert.equal(threadOptionsHistory.length, 2);
|
||||
assert.equal((threadOptionsHistory[0] as { model?: string }).model, 'gpt-5.4');
|
||||
assert.equal((threadOptionsHistory[0] as { modelReasoningEffort?: string }).modelReasoningEffort, 'xhigh');
|
||||
assert.equal((threadOptionsHistory[1] as { model?: string }).model, undefined);
|
||||
assert.equal((threadOptionsHistory[1] as { modelReasoningEffort?: string }).modelReasoningEffort, undefined);
|
||||
});
|
||||
|
||||
// This test covers Claude thinking-level mapping, runtime permission handlers, and model/event normalization.
|
||||
test('claude provider helper mappings match unifier contract', async () => {
|
||||
const provider = new ClaudeProvider() as any;
|
||||
|
||||
assert.equal(provider.resolveClaudeEffort(undefined), 'high');
|
||||
assert.equal(provider.resolveClaudeEffort('low'), 'low');
|
||||
assert.equal(provider.resolveClaudeEffort('not-real'), 'high');
|
||||
|
||||
const allowHandler = provider.resolvePermissionHandler('allow');
|
||||
const denyHandler = provider.resolvePermissionHandler('deny');
|
||||
const askHandler = provider.resolvePermissionHandler('ask');
|
||||
assert.equal(typeof allowHandler, 'function');
|
||||
assert.equal(typeof denyHandler, 'function');
|
||||
assert.equal(askHandler, undefined);
|
||||
|
||||
const allowResult = await allowHandler?.();
|
||||
const denyResult = await denyHandler?.();
|
||||
assert.deepEqual(allowResult, { behavior: 'allow' });
|
||||
assert.equal(denyResult?.behavior, 'deny');
|
||||
|
||||
const mappedModel = provider.mapModelInfo({
|
||||
value: 'default',
|
||||
displayName: 'Default',
|
||||
description: 'Default Claude model',
|
||||
supportsEffort: true,
|
||||
supportedEffortLevels: ['low', 'medium', 'high', 'max'],
|
||||
});
|
||||
assert.equal(mappedModel.value, 'default');
|
||||
assert.equal(mappedModel.supportsThinkingModes, true);
|
||||
assert.deepEqual(mappedModel.supportedThinkingModes, ['low', 'medium', 'high', 'max']);
|
||||
|
||||
const mappedEvent = provider.mapSdkEvent({ type: 'message', subtype: 'delta' });
|
||||
assert.equal(mappedEvent?.message, 'message:delta');
|
||||
});
|
||||
|
||||
// This test covers service-level capability validation for runtime permissions and thinking mode support.
|
||||
test('llmService rejects unsupported runtime permission and thinking mode combinations', async () => {
|
||||
await assert.rejects(
|
||||
llmService.startSession('cursor', {
|
||||
prompt: 'hello',
|
||||
runtimePermissionMode: 'allow',
|
||||
}),
|
||||
(error: unknown) =>
|
||||
error instanceof AppError &&
|
||||
error.code === 'RUNTIME_PERMISSION_NOT_SUPPORTED' &&
|
||||
error.statusCode === 400,
|
||||
);
|
||||
|
||||
await assert.rejects(
|
||||
llmService.startSession('cursor', {
|
||||
prompt: 'hello',
|
||||
thinkingMode: 'high',
|
||||
}),
|
||||
(error: unknown) =>
|
||||
error instanceof AppError &&
|
||||
error.code === 'THINKING_MODE_NOT_SUPPORTED' &&
|
||||
error.statusCode === 400,
|
||||
);
|
||||
});
|
||||
@@ -1,378 +0,0 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import fs from 'node:fs/promises';
|
||||
import os from 'node:os';
|
||||
import path from 'node:path';
|
||||
import test from 'node:test';
|
||||
|
||||
import { AppError } from '@/shared/utils/app-error.js';
|
||||
import { scanStateDb } from '@/shared/database/repositories/scan-state.db.js';
|
||||
import { sessionsDb } from '@/shared/database/repositories/sessions.db.js';
|
||||
import { workspaceOriginalPathsDb } from '@/shared/database/repositories/workspace-original-paths.db.js';
|
||||
import { llmProviderRegistry } from '@/modules/ai-runtime/ai-runtime.registry.js';
|
||||
import { llmSessionsService } from '@/modules/ai-runtime/services/sessions.service.js';
|
||||
import { conversationSearchService } from '@/modules/conversations/conversation-search.service.js';
|
||||
|
||||
const patchMethod = <T extends object, K extends keyof T>(target: T, key: K, replacement: T[K]) => {
|
||||
const original = target[key];
|
||||
(target as any)[key] = replacement;
|
||||
return () => {
|
||||
(target as any)[key] = original;
|
||||
};
|
||||
};
|
||||
|
||||
// This test covers multi-provider synchronization orchestration and failure aggregation.
|
||||
test('llmSessionsService.synchronizeSessions aggregates processed counts and failures', { concurrency: false }, async () => {
|
||||
let updateLastScannedAtCalls = 0;
|
||||
const restoreScanDate = patchMethod(scanStateDb, 'getLastScannedAt', () => new Date('2026-04-01T00:00:00.000Z'));
|
||||
const restoreUpdateScanDate = patchMethod(scanStateDb, 'updateLastScannedAt', () => {
|
||||
updateLastScannedAtCalls += 1;
|
||||
});
|
||||
const restoreProviders = patchMethod(llmProviderRegistry, 'listProviders', () => ([
|
||||
{
|
||||
id: 'claude',
|
||||
sessionSynchronizer: {
|
||||
async synchronize() {
|
||||
return 3;
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'codex',
|
||||
sessionSynchronizer: {
|
||||
async synchronize() {
|
||||
throw new Error('codex index failed');
|
||||
},
|
||||
},
|
||||
},
|
||||
] as any));
|
||||
|
||||
try {
|
||||
const result = await llmSessionsService.synchronizeSessions();
|
||||
assert.equal(result.processedByProvider.claude, 3);
|
||||
assert.equal(result.processedByProvider.codex, 0);
|
||||
assert.equal(result.processedByProvider.cursor, 0);
|
||||
assert.equal(result.processedByProvider.gemini, 0);
|
||||
assert.equal(result.failures.length, 1);
|
||||
assert.equal(result.failures[0], 'codex index failed');
|
||||
assert.equal(updateLastScannedAtCalls, 1);
|
||||
} finally {
|
||||
restoreProviders();
|
||||
restoreUpdateScanDate();
|
||||
restoreScanDate();
|
||||
}
|
||||
});
|
||||
|
||||
// This test covers single-file indexing delegation used by the watcher (no full provider rescan).
|
||||
test('llmSessionsService.synchronizeProviderFile delegates to provider indexer file sync', { concurrency: false }, async () => {
|
||||
let synchronizeCalls = 0;
|
||||
let synchronizeFilePath: string | null = null;
|
||||
const restoreProviders = patchMethod(llmProviderRegistry, 'listProviders', () => ([
|
||||
{
|
||||
id: 'claude',
|
||||
sessionSynchronizer: {
|
||||
async synchronize() {
|
||||
synchronizeCalls += 1;
|
||||
return 0;
|
||||
},
|
||||
async synchronizeFile(filePath: string) {
|
||||
synchronizeFilePath = filePath;
|
||||
return true;
|
||||
},
|
||||
},
|
||||
},
|
||||
] as any));
|
||||
|
||||
try {
|
||||
const result = await llmSessionsService.synchronizeProviderFile('claude', '/tmp/claude-session.jsonl');
|
||||
assert.equal(result.provider, 'claude');
|
||||
assert.equal(result.indexed, true);
|
||||
assert.equal(synchronizeFilePath, '/tmp/claude-session.jsonl');
|
||||
assert.equal(synchronizeCalls, 0);
|
||||
} finally {
|
||||
restoreProviders();
|
||||
}
|
||||
});
|
||||
|
||||
// This test covers session rename persistence and not-found guardrails.
|
||||
test('llmSessionsService.updateSessionCustomName validates existence before updating', { concurrency: false }, () => {
|
||||
let updated: { sessionId: string; customName: string } | null = null;
|
||||
const restoreGetById = patchMethod(sessionsDb, 'getSessionById', (sessionId: string) => (
|
||||
sessionId === 'known-session'
|
||||
? {
|
||||
session_id: 'known-session',
|
||||
provider: 'claude',
|
||||
workspace_path: '/tmp/workspace',
|
||||
jsonl_path: null,
|
||||
custom_name: null,
|
||||
created_at: '2026-04-01T00:00:00.000Z',
|
||||
updated_at: '2026-04-01T00:00:00.000Z',
|
||||
}
|
||||
: null
|
||||
));
|
||||
const restoreUpdateName = patchMethod(sessionsDb, 'updateSessionCustomName', (sessionId: string, customName: string) => {
|
||||
updated = { sessionId, customName };
|
||||
});
|
||||
|
||||
try {
|
||||
llmSessionsService.updateSessionCustomName('known-session', 'New Session Name');
|
||||
assert.deepEqual(updated, {
|
||||
sessionId: 'known-session',
|
||||
customName: 'New Session Name',
|
||||
});
|
||||
|
||||
assert.throws(
|
||||
() => llmSessionsService.updateSessionCustomName('missing-session', 'Nope'),
|
||||
(error: unknown) =>
|
||||
error instanceof AppError &&
|
||||
error.code === 'SESSION_NOT_FOUND' &&
|
||||
error.statusCode === 404,
|
||||
);
|
||||
} finally {
|
||||
restoreUpdateName();
|
||||
restoreGetById();
|
||||
}
|
||||
});
|
||||
|
||||
// This test covers fetching one indexed DB session metadata row from getSessionById.
|
||||
test('llmSessionsService.getIndexedSession returns DB session metadata', { concurrency: false }, () => {
|
||||
const restoreGetById = patchMethod(sessionsDb, 'getSessionById', (sessionId: string) => (
|
||||
sessionId === 'known-session'
|
||||
? {
|
||||
session_id: 'known-session',
|
||||
provider: 'claude',
|
||||
workspace_path: '/tmp/workspace',
|
||||
jsonl_path: '/tmp/workspace/session.jsonl',
|
||||
custom_name: 'Custom Session Name',
|
||||
created_at: '2026-04-01T00:00:00.000Z',
|
||||
updated_at: '2026-04-02T00:00:00.000Z',
|
||||
}
|
||||
: null
|
||||
));
|
||||
const restoreGetWorkspacePath = patchMethod(workspaceOriginalPathsDb, 'getWorkspacePath', (workspacePath: string) => (
|
||||
workspacePath === '/tmp/workspace'
|
||||
? {
|
||||
workspace_id: 'workspace-123',
|
||||
workspace_path: workspacePath,
|
||||
custom_workspace_name: 'Workspace Custom Name',
|
||||
isStarred: 0,
|
||||
}
|
||||
: null
|
||||
));
|
||||
|
||||
try {
|
||||
const session = llmSessionsService.getIndexedSession('known-session');
|
||||
assert.deepEqual(session, {
|
||||
session_id: 'known-session',
|
||||
provider: 'claude',
|
||||
workspace_path: '/tmp/workspace',
|
||||
jsonl_path: '/tmp/workspace/session.jsonl',
|
||||
custom_name: 'Custom Session Name',
|
||||
created_at: '2026-04-01T00:00:00.000Z',
|
||||
updated_at: '2026-04-02T00:00:00.000Z',
|
||||
workspace_id: 'workspace-123',
|
||||
});
|
||||
|
||||
assert.throws(
|
||||
() => llmSessionsService.getIndexedSession('missing-session'),
|
||||
(error: unknown) =>
|
||||
error instanceof AppError &&
|
||||
error.code === 'SESSION_NOT_FOUND' &&
|
||||
error.statusCode === 404,
|
||||
);
|
||||
} finally {
|
||||
restoreGetWorkspacePath();
|
||||
restoreGetById();
|
||||
}
|
||||
});
|
||||
|
||||
// This test covers delete behavior using only DB jsonl_path, including invalid id validation.
|
||||
test('llmSessionsService.deleteSessionArtifacts validates ids and deletes disk/db artifacts', { concurrency: false }, async () => {
|
||||
const tempRoot = await fs.mkdtemp(path.join(os.tmpdir(), 'llm-delete-session-'));
|
||||
const transcriptPath = path.join(tempRoot, 'session.jsonl');
|
||||
await fs.writeFile(transcriptPath, '{"ok":true}\n', 'utf8');
|
||||
|
||||
let deletedSessionId: string | null = null;
|
||||
const restoreGetById = patchMethod(sessionsDb, 'getSessionById', (sessionId: string) => (
|
||||
sessionId === 'session-123'
|
||||
? {
|
||||
session_id: 'session-123',
|
||||
provider: 'cursor',
|
||||
workspace_path: '/tmp/workspace',
|
||||
jsonl_path: transcriptPath,
|
||||
custom_name: null,
|
||||
created_at: '2026-04-01T00:00:00.000Z',
|
||||
updated_at: '2026-04-01T00:00:00.000Z',
|
||||
}
|
||||
: null
|
||||
));
|
||||
const restoreDelete = patchMethod(sessionsDb, 'deleteSession', (sessionId: string) => {
|
||||
deletedSessionId = sessionId;
|
||||
});
|
||||
|
||||
try {
|
||||
await assert.rejects(
|
||||
llmSessionsService.deleteSessionArtifacts('../invalid'),
|
||||
(error: unknown) =>
|
||||
error instanceof AppError &&
|
||||
error.code === 'INVALID_SESSION_ID' &&
|
||||
error.statusCode === 400,
|
||||
);
|
||||
|
||||
const deleted = await llmSessionsService.deleteSessionArtifacts('session-123');
|
||||
assert.equal(deleted.sessionId, 'session-123');
|
||||
assert.equal(deleted.deletedFromDatabase, true);
|
||||
assert.equal(deleted.deletedFromDisk, true);
|
||||
assert.equal(deletedSessionId, 'session-123');
|
||||
await assert.rejects(fs.access(transcriptPath));
|
||||
|
||||
const missing = await llmSessionsService.deleteSessionArtifacts('session-404');
|
||||
assert.equal(missing.deletedFromDatabase, false);
|
||||
assert.equal(missing.deletedFromDisk, false);
|
||||
} finally {
|
||||
restoreDelete();
|
||||
restoreGetById();
|
||||
await fs.rm(tempRoot, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
|
||||
// This test covers session-history parsing for JSONL (including malformed lines) and Gemini JSON files.
|
||||
test('llmSessionsService.getSessionHistory parses JSONL and Gemini JSON correctly', { concurrency: false }, async () => {
|
||||
const tempRoot = await fs.mkdtemp(path.join(os.tmpdir(), 'llm-history-'));
|
||||
const jsonlPath = path.join(tempRoot, 'session.jsonl');
|
||||
const jsonPath = path.join(tempRoot, 'gemini.json');
|
||||
await fs.writeFile(jsonlPath, '{"message":"hello"}\nnot-json\n', 'utf8');
|
||||
await fs.writeFile(jsonPath, '{"messages":[{"text":"hi"}]}', 'utf8');
|
||||
|
||||
const restoreGetById = patchMethod(sessionsDb, 'getSessionById', (sessionId: string) => {
|
||||
if (sessionId === 'jsonl-session') {
|
||||
return {
|
||||
session_id: 'jsonl-session',
|
||||
provider: 'cursor',
|
||||
workspace_path: '/tmp/workspace',
|
||||
jsonl_path: jsonlPath,
|
||||
custom_name: null,
|
||||
created_at: '2026-04-01T00:00:00.000Z',
|
||||
updated_at: '2026-04-01T00:00:00.000Z',
|
||||
};
|
||||
}
|
||||
|
||||
if (sessionId === 'json-session') {
|
||||
return {
|
||||
session_id: 'json-session',
|
||||
provider: 'gemini',
|
||||
workspace_path: '/tmp/workspace',
|
||||
jsonl_path: jsonPath,
|
||||
custom_name: null,
|
||||
created_at: '2026-04-01T00:00:00.000Z',
|
||||
updated_at: '2026-04-01T00:00:00.000Z',
|
||||
};
|
||||
}
|
||||
|
||||
if (sessionId === 'missing-history-path') {
|
||||
return {
|
||||
session_id: 'missing-history-path',
|
||||
provider: 'claude',
|
||||
workspace_path: '/tmp/workspace',
|
||||
jsonl_path: null,
|
||||
custom_name: null,
|
||||
created_at: '2026-04-01T00:00:00.000Z',
|
||||
updated_at: '2026-04-01T00:00:00.000Z',
|
||||
};
|
||||
}
|
||||
|
||||
return null;
|
||||
});
|
||||
|
||||
try {
|
||||
const jsonlHistory = await llmSessionsService.getSessionHistory('jsonl-session');
|
||||
assert.equal(jsonlHistory.fileType, 'jsonl');
|
||||
assert.equal(Array.isArray(jsonlHistory.entries), true);
|
||||
assert.equal(jsonlHistory.entries.length, 2);
|
||||
assert.deepEqual(jsonlHistory.entries[0], { message: 'hello' });
|
||||
assert.deepEqual(jsonlHistory.entries[1], { raw: 'not-json', parseError: true });
|
||||
|
||||
const geminiHistory = await llmSessionsService.getSessionHistory('json-session');
|
||||
assert.equal(geminiHistory.fileType, 'json');
|
||||
assert.equal(geminiHistory.entries.length, 1);
|
||||
assert.deepEqual(geminiHistory.entries[0], { messages: [{ text: 'hi' }] });
|
||||
|
||||
await assert.rejects(
|
||||
llmSessionsService.getSessionHistory('unknown-session'),
|
||||
(error: unknown) =>
|
||||
error instanceof AppError &&
|
||||
error.code === 'SESSION_NOT_FOUND' &&
|
||||
error.statusCode === 404,
|
||||
);
|
||||
|
||||
await assert.rejects(
|
||||
llmSessionsService.getSessionHistory('missing-history-path'),
|
||||
(error: unknown) =>
|
||||
error instanceof AppError &&
|
||||
error.code === 'SESSION_HISTORY_NOT_AVAILABLE' &&
|
||||
error.statusCode === 404,
|
||||
);
|
||||
} finally {
|
||||
restoreGetById();
|
||||
await fs.rm(tempRoot, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
|
||||
// This test covers conversation search over indexed transcript files with provider/case filters.
|
||||
test('conversationSearchService searches indexed transcripts with provider and case filters', { concurrency: false }, async () => {
|
||||
const tempRoot = await fs.mkdtemp(path.join(os.tmpdir(), 'llm-search-'));
|
||||
const cursorPath = path.join(tempRoot, 'cursor.jsonl');
|
||||
const codexPath = path.join(tempRoot, 'codex.jsonl');
|
||||
await fs.writeFile(cursorPath, 'hello world\nNeedle lower\n', 'utf8');
|
||||
await fs.writeFile(codexPath, 'HELLO WORLD\nNEEDLE UPPER\n', 'utf8');
|
||||
|
||||
const restoreGetAll = patchMethod(sessionsDb, 'getAllSessions', () => ([
|
||||
{
|
||||
session_id: 'cursor-s',
|
||||
provider: 'cursor',
|
||||
workspace_path: '/tmp/workspace-cursor',
|
||||
jsonl_path: cursorPath,
|
||||
custom_name: null,
|
||||
created_at: '2026-04-01T00:00:00.000Z',
|
||||
updated_at: '2026-04-01T00:00:00.000Z',
|
||||
},
|
||||
{
|
||||
session_id: 'codex-s',
|
||||
provider: 'codex',
|
||||
workspace_path: '/tmp/workspace-codex',
|
||||
jsonl_path: codexPath,
|
||||
custom_name: null,
|
||||
created_at: '2026-04-01T00:00:00.000Z',
|
||||
updated_at: '2026-04-01T00:00:00.000Z',
|
||||
},
|
||||
]));
|
||||
|
||||
try {
|
||||
await assert.rejects(
|
||||
conversationSearchService.search({ query: ' ' }),
|
||||
(error: unknown) =>
|
||||
error instanceof AppError &&
|
||||
error.code === 'SEARCH_QUERY_REQUIRED' &&
|
||||
error.statusCode === 400,
|
||||
);
|
||||
|
||||
const anyProviderResults = await conversationSearchService.search({
|
||||
query: 'needle',
|
||||
caseSensitive: false,
|
||||
limit: 20,
|
||||
});
|
||||
assert.ok(anyProviderResults.some((entry) => entry.sessionId === 'cursor-s'));
|
||||
assert.ok(anyProviderResults.some((entry) => entry.sessionId === 'codex-s'));
|
||||
|
||||
const codexOnlyResults = await conversationSearchService.search({
|
||||
query: 'NEEDLE',
|
||||
caseSensitive: true,
|
||||
provider: 'codex',
|
||||
limit: 20,
|
||||
});
|
||||
assert.ok(codexOnlyResults.length >= 1);
|
||||
assert.ok(codexOnlyResults.every((entry) => entry.provider === 'codex'));
|
||||
} finally {
|
||||
restoreGetAll();
|
||||
await fs.rm(tempRoot, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
@@ -1,208 +0,0 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import fs from 'node:fs/promises';
|
||||
import os from 'node:os';
|
||||
import path from 'node:path';
|
||||
import test from 'node:test';
|
||||
|
||||
import { llmSkillsService } from '@/modules/ai-runtime/services/skills.service.js';
|
||||
|
||||
const patchHomeDir = (nextHomeDir: string) => {
|
||||
const original = os.homedir;
|
||||
(os as any).homedir = () => nextHomeDir;
|
||||
return () => {
|
||||
(os as any).homedir = original;
|
||||
};
|
||||
};
|
||||
|
||||
const createSkill = async (
|
||||
rootSkillsDirectory: string,
|
||||
directoryName: string,
|
||||
metadata: {
|
||||
name: string;
|
||||
description: string;
|
||||
},
|
||||
) => {
|
||||
const skillDirectory = path.join(rootSkillsDirectory, directoryName);
|
||||
await fs.mkdir(skillDirectory, { recursive: true });
|
||||
await fs.writeFile(
|
||||
path.join(skillDirectory, 'SKILL.md'),
|
||||
`---\nname: ${metadata.name}\ndescription: ${metadata.description}\n---\n\n# ${metadata.name}\n`,
|
||||
'utf8',
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* This test covers Claude skills fetching from user/project/plugin locations and plugin namespace invocation.
|
||||
*/
|
||||
test('llmSkillsService lists claude user/project/plugin skills with proper invocation names', { concurrency: false }, async () => {
|
||||
const tempRoot = await fs.mkdtemp(path.join(os.tmpdir(), 'llm-skills-claude-'));
|
||||
const workspacePath = path.join(tempRoot, 'workspace');
|
||||
const pluginInstallPath = path.join(tempRoot, 'plugin-install');
|
||||
await fs.mkdir(workspacePath, { recursive: true });
|
||||
|
||||
const restoreHomeDir = patchHomeDir(tempRoot);
|
||||
try {
|
||||
await createSkill(path.join(tempRoot, '.claude', 'skills'), 'user-helper', {
|
||||
name: 'user-helper',
|
||||
description: 'User skill description',
|
||||
});
|
||||
await createSkill(path.join(workspacePath, '.claude', 'skills'), 'project-helper', {
|
||||
name: 'project-helper',
|
||||
description: 'Project skill description',
|
||||
});
|
||||
await createSkill(path.join(pluginInstallPath, 'skills'), 'plugin-helper', {
|
||||
name: 'plugin-helper',
|
||||
description: 'Plugin skill description',
|
||||
});
|
||||
|
||||
await fs.mkdir(path.join(tempRoot, '.claude', 'plugins'), { recursive: true });
|
||||
await fs.writeFile(
|
||||
path.join(tempRoot, '.claude', 'settings.json'),
|
||||
JSON.stringify({
|
||||
enabledPlugins: {
|
||||
'example-skills@anthropic-agent-skills': true,
|
||||
},
|
||||
}),
|
||||
'utf8',
|
||||
);
|
||||
await fs.writeFile(
|
||||
path.join(tempRoot, '.claude', 'plugins', 'installed_plugins.json'),
|
||||
JSON.stringify({
|
||||
version: 2,
|
||||
plugins: {
|
||||
'example-skills@anthropic-agent-skills': [
|
||||
{
|
||||
installPath: pluginInstallPath,
|
||||
},
|
||||
],
|
||||
},
|
||||
}),
|
||||
'utf8',
|
||||
);
|
||||
|
||||
const skills = await llmSkillsService.listProviderSkills('claude', { workspacePath });
|
||||
assert.ok(skills.some((skill) => skill.scope === 'user' && skill.invocation === '/user-helper'));
|
||||
assert.ok(skills.some((skill) => skill.scope === 'project' && skill.invocation === '/project-helper'));
|
||||
assert.ok(skills.some((skill) => skill.scope === 'plugin' && skill.invocation === '/example-skills:plugin-helper'));
|
||||
} finally {
|
||||
restoreHomeDir();
|
||||
await fs.rm(tempRoot, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* This test covers Codex skills discovery across repo/user/system locations and `$` invocation prefix.
|
||||
*/
|
||||
test('llmSkillsService lists codex skills from repo/user/system locations with dollar invocation', { concurrency: false }, async () => {
|
||||
const tempRoot = await fs.mkdtemp(path.join(os.tmpdir(), 'llm-skills-codex-'));
|
||||
const repoRoot = path.join(tempRoot, 'repo');
|
||||
const workspacePath = path.join(repoRoot, 'packages', 'app');
|
||||
await fs.mkdir(workspacePath, { recursive: true });
|
||||
await fs.mkdir(path.join(repoRoot, '.git'), { recursive: true });
|
||||
|
||||
const restoreHomeDir = patchHomeDir(tempRoot);
|
||||
try {
|
||||
await createSkill(path.join(workspacePath, '.agents', 'skills'), 'cwd-skill', {
|
||||
name: 'cwd-skill',
|
||||
description: 'cwd skill',
|
||||
});
|
||||
await createSkill(path.join(workspacePath, '..', '.agents', 'skills'), 'parent-skill', {
|
||||
name: 'parent-skill',
|
||||
description: 'parent skill',
|
||||
});
|
||||
await createSkill(path.join(repoRoot, '.agents', 'skills'), 'repo-root-skill', {
|
||||
name: 'repo-root-skill',
|
||||
description: 'repo root skill',
|
||||
});
|
||||
await createSkill(path.join(tempRoot, '.agents', 'skills'), 'user-skill', {
|
||||
name: 'user-skill',
|
||||
description: 'user skill',
|
||||
});
|
||||
await createSkill(path.join(tempRoot, '.codex', 'skills', '.system'), 'system-skill', {
|
||||
name: 'system-skill',
|
||||
description: 'system skill',
|
||||
});
|
||||
|
||||
const skills = await llmSkillsService.listProviderSkills('codex', { workspacePath });
|
||||
assert.ok(skills.some((skill) => skill.name === 'cwd-skill' && skill.invocation === '$cwd-skill'));
|
||||
assert.ok(skills.some((skill) => skill.name === 'parent-skill' && skill.invocation === '$parent-skill'));
|
||||
assert.ok(skills.some((skill) => skill.name === 'repo-root-skill' && skill.invocation === '$repo-root-skill'));
|
||||
assert.ok(skills.some((skill) => skill.name === 'user-skill' && skill.invocation === '$user-skill'));
|
||||
assert.ok(skills.some((skill) => skill.name === 'system-skill' && skill.invocation === '$system-skill'));
|
||||
} finally {
|
||||
restoreHomeDir();
|
||||
await fs.rm(tempRoot, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* This test covers Gemini skill fetch locations and slash-based invocation format.
|
||||
*/
|
||||
test('llmSkillsService lists gemini skills from documented directories', { concurrency: false }, async () => {
|
||||
const tempRoot = await fs.mkdtemp(path.join(os.tmpdir(), 'llm-skills-gemini-'));
|
||||
const workspacePath = path.join(tempRoot, 'workspace');
|
||||
await fs.mkdir(workspacePath, { recursive: true });
|
||||
|
||||
const restoreHomeDir = patchHomeDir(tempRoot);
|
||||
try {
|
||||
await createSkill(path.join(tempRoot, '.gemini', 'skills'), 'home-gemini', {
|
||||
name: 'home-gemini',
|
||||
description: 'home gemini skill',
|
||||
});
|
||||
await createSkill(path.join(tempRoot, '.agents', 'skills'), 'home-agents', {
|
||||
name: 'home-agents',
|
||||
description: 'home agents skill',
|
||||
});
|
||||
await createSkill(path.join(workspacePath, '.gemini', 'skills'), 'project-gemini', {
|
||||
name: 'project-gemini',
|
||||
description: 'project gemini skill',
|
||||
});
|
||||
await createSkill(path.join(workspacePath, '.agents', 'skills'), 'project-agents', {
|
||||
name: 'project-agents',
|
||||
description: 'project agents skill',
|
||||
});
|
||||
|
||||
const skills = await llmSkillsService.listProviderSkills('gemini', { workspacePath });
|
||||
assert.ok(skills.some((skill) => skill.invocation === '/home-gemini'));
|
||||
assert.ok(skills.some((skill) => skill.invocation === '/home-agents'));
|
||||
assert.ok(skills.some((skill) => skill.invocation === '/project-gemini'));
|
||||
assert.ok(skills.some((skill) => skill.invocation === '/project-agents'));
|
||||
} finally {
|
||||
restoreHomeDir();
|
||||
await fs.rm(tempRoot, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* This test covers Cursor skill fetch locations and slash-based invocation format.
|
||||
*/
|
||||
test('llmSkillsService lists cursor skills from documented directories', { concurrency: false }, async () => {
|
||||
const tempRoot = await fs.mkdtemp(path.join(os.tmpdir(), 'llm-skills-cursor-'));
|
||||
const workspacePath = path.join(tempRoot, 'workspace');
|
||||
await fs.mkdir(workspacePath, { recursive: true });
|
||||
|
||||
const restoreHomeDir = patchHomeDir(tempRoot);
|
||||
try {
|
||||
await createSkill(path.join(workspacePath, '.agents', 'skills'), 'project-agents', {
|
||||
name: 'project-agents',
|
||||
description: 'project agents skill',
|
||||
});
|
||||
await createSkill(path.join(workspacePath, '.cursor', 'skills'), 'project-cursor', {
|
||||
name: 'project-cursor',
|
||||
description: 'project cursor skill',
|
||||
});
|
||||
await createSkill(path.join(tempRoot, '.cursor', 'skills'), 'user-cursor', {
|
||||
name: 'user-cursor',
|
||||
description: 'user cursor skill',
|
||||
});
|
||||
|
||||
const skills = await llmSkillsService.listProviderSkills('cursor', { workspacePath });
|
||||
assert.ok(skills.some((skill) => skill.invocation === '/project-agents'));
|
||||
assert.ok(skills.some((skill) => skill.invocation === '/project-cursor'));
|
||||
assert.ok(skills.some((skill) => skill.invocation === '/user-cursor'));
|
||||
} finally {
|
||||
restoreHomeDir();
|
||||
await fs.rm(tempRoot, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user