diff --git a/package-lock.json b/package-lock.json index f9fa6ba..8a0f351 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8,6 +8,8 @@ "name": "roject", "version": "1.0.0", "dependencies": { + "@anthropic-ai/claude-code": "^2.1.220", + "@anthropic-ai/sdk": "^0.115.0", "@langchain/core": "^1.2.2", "@langchain/openai": "^1.5.4", "@types/cookie-parser": "^1.4.10", @@ -28,6 +30,163 @@ "typescript": "^5.3.3" } }, + "node_modules/@anthropic-ai/claude-code": { + "version": "2.1.220", + "resolved": "https://registry.npmjs.org/@anthropic-ai/claude-code/-/claude-code-2.1.220.tgz", + "integrity": "sha512-ogBrvwkqF9f8okmnXKxmRNHuvtFxFEffe5pWdqOV3iQDxlUOKirFqnyWC7NGXXnDA4WkkbPH8pvSbwyCR2Auyw==", + "hasInstallScript": true, + "license": "SEE LICENSE IN README.md", + "bin": { + "claude": "bin/claude.exe" + }, + "engines": { + "node": ">=22.0.0" + }, + "optionalDependencies": { + "@anthropic-ai/claude-code-darwin-arm64": "2.1.220", + "@anthropic-ai/claude-code-darwin-x64": "2.1.220", + "@anthropic-ai/claude-code-linux-arm64": "2.1.220", + "@anthropic-ai/claude-code-linux-arm64-musl": "2.1.220", + "@anthropic-ai/claude-code-linux-x64": "2.1.220", + "@anthropic-ai/claude-code-linux-x64-musl": "2.1.220", + "@anthropic-ai/claude-code-win32-arm64": "2.1.220", + "@anthropic-ai/claude-code-win32-x64": "2.1.220" + } + }, + "node_modules/@anthropic-ai/claude-code-darwin-arm64": { + "version": "2.1.220", + "resolved": "https://registry.npmjs.org/@anthropic-ai/claude-code-darwin-arm64/-/claude-code-darwin-arm64-2.1.220.tgz", + "integrity": "sha512-rmtd41Bf+n+YnhjSjtQ8WG5qy8KKogUp3YRfQrkLsTgPUD0H3j869rBInBJT3SHrKQ0hLghQLGM73CC1C+USLQ==", + "cpu": [ + "arm64" + ], + "license": "SEE LICENSE IN LICENSE.md", + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/@anthropic-ai/claude-code-darwin-x64": { + "version": "2.1.220", + "resolved": "https://registry.npmjs.org/@anthropic-ai/claude-code-darwin-x64/-/claude-code-darwin-x64-2.1.220.tgz", + "integrity": "sha512-hbuoG+YCo37VzSKzKJ47ymRmt/YjASc3dRcsZtCcftLYdopv8KL889x/IbCl3cfp/VqV2rRDZ0f3aUDpHUFweQ==", + "cpu": [ + "x64" + ], + "license": "SEE LICENSE IN LICENSE.md", + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/@anthropic-ai/claude-code-linux-arm64": { + "version": "2.1.220", + "resolved": "https://registry.npmjs.org/@anthropic-ai/claude-code-linux-arm64/-/claude-code-linux-arm64-2.1.220.tgz", + "integrity": "sha512-VHFI8mKruIntKn7eq81sbyS19/KWmQcmJQsS/C+j9M/E+w0s4UytgsL7DADPjBE/GByNiKoRtLYDMntCjRlOdA==", + "cpu": [ + "arm64" + ], + "license": "SEE LICENSE IN LICENSE.md", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@anthropic-ai/claude-code-linux-arm64-musl": { + "version": "2.1.220", + "resolved": "https://registry.npmjs.org/@anthropic-ai/claude-code-linux-arm64-musl/-/claude-code-linux-arm64-musl-2.1.220.tgz", + "integrity": "sha512-m37ALw8jcbSknuyG7xDQjGPY7Gth3eX8iFY1XFEWABVq1iUMVAUn96WC9eqwi8/JSqyG2t3oNRiqHdi2ZNKFGQ==", + "cpu": [ + "arm64" + ], + "license": "SEE LICENSE IN LICENSE.md", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@anthropic-ai/claude-code-linux-x64": { + "version": "2.1.220", + "resolved": "https://registry.npmjs.org/@anthropic-ai/claude-code-linux-x64/-/claude-code-linux-x64-2.1.220.tgz", + "integrity": "sha512-3CGFCnI0gpgsqNeJruFALBDGJaKXOuok3alQEg56ty2yOPpIrOx/r2Y0+T4uhJl7kP5Hzw4IFkxo4DZKWvzQ7Q==", + "cpu": [ + "x64" + ], + "license": "SEE LICENSE IN LICENSE.md", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@anthropic-ai/claude-code-linux-x64-musl": { + "version": "2.1.220", + "resolved": "https://registry.npmjs.org/@anthropic-ai/claude-code-linux-x64-musl/-/claude-code-linux-x64-musl-2.1.220.tgz", + "integrity": "sha512-+QyT1KikOdMRKReWFaBYGsroYx2vEjjx54DwhMoC24oE1DxjC+SlKjeOTRXAKiu0fr0O549Lkhg2tuT5xtQpAQ==", + "cpu": [ + "x64" + ], + "license": "SEE LICENSE IN LICENSE.md", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@anthropic-ai/claude-code-win32-arm64": { + "version": "2.1.220", + "resolved": "https://registry.npmjs.org/@anthropic-ai/claude-code-win32-arm64/-/claude-code-win32-arm64-2.1.220.tgz", + "integrity": "sha512-APqZwFBn38DBUwB65uUTetW7lbtUqFfAfOWKvkmOyqFDswDEsInaINuIwqMCl44WYcch10SaHhEZdXJU9MG3aQ==", + "cpu": [ + "arm64" + ], + "license": "SEE LICENSE IN LICENSE.md", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@anthropic-ai/claude-code-win32-x64": { + "version": "2.1.220", + "resolved": "https://registry.npmjs.org/@anthropic-ai/claude-code-win32-x64/-/claude-code-win32-x64-2.1.220.tgz", + "integrity": "sha512-UGrjH8cGhC6PzhTyZSdgf/RpKxpfk9XJZ/RT/wsG2AJg9yEJLjLg6/TrnlL8RFbEv6Zahu0Quytc02UOpA/GiA==", + "cpu": [ + "x64" + ], + "license": "SEE LICENSE IN LICENSE.md", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@anthropic-ai/sdk": { + "version": "0.115.0", + "resolved": "https://registry.npmjs.org/@anthropic-ai/sdk/-/sdk-0.115.0.tgz", + "integrity": "sha512-BJrFIVyjNuU8lfDyIJTvlRYzgQg+zEl78BxE7fq8esULsGz9IRQvGtW5spq3tydmtjQb/GFdooKGdGsetpx+lQ==", + "license": "MIT", + "dependencies": { + "json-schema-to-ts": "^3.1.1", + "standardwebhooks": "^1.0.0" + }, + "bin": { + "anthropic-ai-sdk": "bin/cli" + }, + "peerDependencies": { + "zod": "^3.25.0 || ^4.0.0" + }, + "peerDependenciesMeta": { + "zod": { + "optional": true + } + } + }, + "node_modules/@babel/runtime": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.29.7.tgz", + "integrity": "sha512-Nq8OhGWiZIZGV6hLHoyAKLLcJihP/xFeBMGJoUrxTX2psI8dCifzLhZISFb+VWS3wFMRDmCGw5R+dOySCqPLhw==", + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, "node_modules/@cfworker/json-schema": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/@cfworker/json-schema/-/json-schema-4.1.1.tgz", @@ -892,6 +1051,12 @@ "url": "https://github.com/sindresorhus/is?sponsor=1" } }, + "node_modules/@stablelib/base64": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@stablelib/base64/-/base64-1.0.1.tgz", + "integrity": "sha512-1bnPQqSxSuc3Ii6MhBysoWCg58j97aUjuCSZrGSmDxNqtytIi0k8utUenAwTZN4V5mXXYGsVUI9zeBqy+jBOSQ==", + "license": "MIT" + }, "node_modules/@standard-schema/spec": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/@standard-schema/spec/-/spec-1.1.0.tgz", @@ -2907,6 +3072,12 @@ "dev": true, "license": "MIT" }, + "node_modules/fast-sha256": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/fast-sha256/-/fast-sha256-1.3.0.tgz", + "integrity": "sha512-n11RGP/lrWEFI/bWdygLxhI+pVeo1ZYIVwvvPkW7azl/rOy+F3HYRZ2K5zeE9mmkhQppyv9sQFx0JM9UabnpPQ==", + "license": "Unlicense" + }, "node_modules/fast-uri": { "version": "3.1.3", "resolved": "https://registry.npmjs.org/fast-uri/-/fast-uri-3.1.3.tgz", @@ -3616,6 +3787,19 @@ "dev": true, "license": "MIT" }, + "node_modules/json-schema-to-ts": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/json-schema-to-ts/-/json-schema-to-ts-3.1.1.tgz", + "integrity": "sha512-+DWg8jCJG2TEnpy7kOm/7/AxaYoaRbjVB4LFZLySZlWn8exGs3A4OLJR966cVvU26N7X9TWxl+Jsw7dzAqKT6g==", + "license": "MIT", + "dependencies": { + "@babel/runtime": "^7.18.3", + "ts-algebra": "^2.0.0" + }, + "engines": { + "node": ">=16" + } + }, "node_modules/json-schema-traverse": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz", @@ -5072,6 +5256,16 @@ "license": "BSD-3-Clause", "optional": true }, + "node_modules/standardwebhooks": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/standardwebhooks/-/standardwebhooks-1.0.0.tgz", + "integrity": "sha512-BbHGOQK9olHPMvQNHWul6MYlrRTAOKn03rOe4A8O3CLWhNf4YHBqq2HJKKC+sfqpxiBY52pNeesD6jIiLDz8jg==", + "license": "MIT", + "dependencies": { + "@stablelib/base64": "^1.0.0", + "fast-sha256": "^1.3.0" + } + }, "node_modules/stat-mode": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/stat-mode/-/stat-mode-1.0.0.tgz", @@ -5353,6 +5547,12 @@ "utf8-byte-length": "^1.0.1" } }, + "node_modules/ts-algebra": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ts-algebra/-/ts-algebra-2.0.0.tgz", + "integrity": "sha512-FPAhNPFMrkwz76P7cdjdmiShwMynZYN6SgOujD1urY4oNm80Ou9oMdmbR45LotcKOXoy7wSmHkRFE6Mxbrhefw==", + "license": "MIT" + }, "node_modules/ts-node": { "version": "10.9.2", "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.9.2.tgz", @@ -5728,6 +5928,7 @@ "resolved": "https://registry.npmjs.org/zod/-/zod-4.4.3.tgz", "integrity": "sha512-ytENFjIJFl2UwYglde2jchW2Hwm4GJFLDiSXWdTrJQBIN9Fcyp7n4DhxJEiWNAJMV1/BqWfW/kkg71UDcHJyTQ==", "license": "MIT", + "peer": true, "funding": { "url": "https://github.com/sponsors/colinhacks" } diff --git a/package.json b/package.json index b3ad5b0..f2e0032 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,8 @@ "electron:dist": "npm run electron:build && electron-builder" }, "dependencies": { + "@anthropic-ai/claude-code": "^2.1.220", + "@anthropic-ai/sdk": "^0.115.0", "@langchain/core": "^1.2.2", "@langchain/openai": "^1.5.4", "@types/cookie-parser": "^1.4.10", diff --git a/source/components/rojo-chat-panel/rojo-chat-panel.ts b/source/components/rojo-chat-panel/rojo-chat-panel.ts index f792dad..6c0bdba 100644 --- a/source/components/rojo-chat-panel/rojo-chat-panel.ts +++ b/source/components/rojo-chat-panel/rojo-chat-panel.ts @@ -148,12 +148,26 @@ class RojoChatPanel extends HTMLElement async _loadRojos(): Promise { - const projectId = Editor.get().projectId; - if ( !projectId ) return; + const editor = Editor.get(); + let url: string; + + if ( editor.localRoot ) + { + url = `/api/local/rojos?root=${ encodeURIComponent( editor.localRoot ) }`; + } + else if ( editor.remoteProject ) + { + url = `/api/remote/rojos/${ editor.remoteProject }/list`; + } + else if ( editor.projectId ) + { + url = `/api/rojos/${ editor.projectId }/list`; + } + else { return; } try { - const res = await fetch( `/api/rojos/${ projectId }/list` ); + const res = await fetch( url ); if ( !res.ok ) return; this._rojos = await res.json() as RojoEntry[]; this._renderPicker(); @@ -184,22 +198,39 @@ class RojoChatPanel extends HTMLElement async _createRojo(): Promise { - const projectId = Editor.get().projectId; - if ( !projectId ) return; + const editor = Editor.get(); - // Place new rojo in the same directory as the currently selected one, - // or directly in workspace/rojos if nothing is selected. const dir = this._selectedPath ? parentDir( this._selectedPath ) : 'workspace/rojos'; + let url: string; + let body: Record; + + if ( editor.localRoot ) + { + url = '/api/local/rojos/create'; + body = { root: editor.localRoot, parentDir: dir }; + } + else if ( editor.remoteProject ) + { + url = `/api/remote/rojos/${ editor.remoteProject }/create`; + body = { parentDir: dir }; + } + else if ( editor.projectId ) + { + url = `/api/rojos/${ editor.projectId }/create`; + body = { parentDir: dir }; + } + else { return; } + try { - const res = await fetch( `/api/rojos/${ projectId }/create`, + const res = await fetch( url, { method: 'POST', headers: { 'Content-Type': 'application/json' }, - body: JSON.stringify( { parentDir: dir } ), + body: JSON.stringify( body ), } ); if ( !res.ok ) return; @@ -209,7 +240,7 @@ class RojoChatPanel extends HTMLElement this._selectedPath = newPath; ( this.querySelector( '.rcp-picker' ) as HTMLSelectElement ).value = newPath; - await Editor.get().openDocument( newPath ); + await editor.openDocument( newPath ); } catch {} } @@ -267,8 +298,12 @@ class RojoChatPanel extends HTMLElement if ( this._selectedPath ) { - body.projectId = Editor.get().projectId; - body.rojoPath = this._selectedPath; + const editor = Editor.get(); + body.rojoPath = this._selectedPath; + + if ( editor.localRoot ) { body.localRoot = editor.localRoot; } + else if ( editor.remoteProject ) { body.remoteProject = editor.remoteProject; } + else { body.projectId = editor.projectId; } } const response = await fetch( '/api/rojos/chat', diff --git a/source/components/rojo-settings-panel/rojo-settings-panel.ts b/source/components/rojo-settings-panel/rojo-settings-panel.ts index 4c0ae6f..35ee973 100644 --- a/source/components/rojo-settings-panel/rojo-settings-panel.ts +++ b/source/components/rojo-settings-panel/rojo-settings-panel.ts @@ -13,7 +13,7 @@ function inkscapeLabel( el: Element ): string interface RojoEndpoint { - type: 'external' | 'tunnel'; + type: 'external' | 'tunnel' | 'claude' | 'claude-code'; url: string; model: string; apiKey: string; @@ -159,12 +159,16 @@ class RojoSettingsPanel extends HTMLElement
- +
+ +
@@ -180,8 +184,16 @@ class RojoSettingsPanel extends HTMLElement
-