While someone has a workspace open, the gateway asks the API for a 15-minute write token for the project's platform repository on behalf of that person (membership and role checked each time) and delivers it to the workspace backend. The backend writes it to a Git config file outside the repository (a memory volume in Kubernetes) that the clone includes, and on the first delivery clones the target branch into a folder named after the project. The workspace cannot mint credentials itself, so access ends with the last session. - People commit and push to the target branch like with any Git server; the platform only accepts fast-forwards, and the next wish starts from that commit (covered end to end in the local loop test). - Commits are authored by whoever opened the latest session, from the name and email in their sign-in; their own git config overrides it. - Only the gateway can reach the delivery endpoint: it needs Theia's connection token, and the gateway refuses the path for browsers. - The provisioner pins the workspace to its repository and lets the pod reach the Git service; the Kubernetes baseline admits that traffic. External repositories are not cloned. - The local shared Theia clones each project into its own folder. - The Theia image installs Git, and its stage is named theia: the default build target of that Dockerfile is the gateway. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
48 lines
1.8 KiB
JavaScript
48 lines
1.8 KiB
JavaScript
import { existsSync, mkdirSync } from 'node:fs';
|
|
import { resolve } from 'node:path';
|
|
import { environment, loadLocalEnvironment, startServices } from './local-services.mjs';
|
|
|
|
loadLocalEnvironment();
|
|
const root = process.cwd();
|
|
if (!existsSync(resolve(root, 'apps/ide/src-gen/backend/main.js')))
|
|
throw new Error('Theia is not built yet; run npm run ide:install and npm run ide:build first');
|
|
// Local mode: every workspace opens this one directory in the one local Theia, and each
|
|
// project is cloned into a folder of its own there when its workspace is first opened.
|
|
const workspace = resolve(root, '.wishforge/ide-workspace');
|
|
mkdirSync(workspace, { recursive: true });
|
|
// Repository tokens stay outside the workspace folder.
|
|
const credentials = resolve(root, '.wishforge/ide-credentials');
|
|
mkdirSync(credentials, { recursive: true, mode: 0o700 });
|
|
const gitOrigin = new URL(process.env.WF_GIT_PUBLIC_BASE_URL ?? 'http://127.0.0.1:4504').origin;
|
|
await startServices(
|
|
[
|
|
{
|
|
name: 'theia',
|
|
cwd: resolve(root, 'apps/ide'),
|
|
args: ['scripts/start.mjs'],
|
|
env: environment([/^WF_COLLABORATION_/], {
|
|
WISHFORGE_IDE_PORT: '4300',
|
|
WISHFORGE_WORKSPACE_PATH: workspace,
|
|
WISHFORGE_GIT_ORIGIN: gitOrigin,
|
|
WISHFORGE_GIT_CREDENTIAL_DIR: credentials,
|
|
}),
|
|
url: 'http://127.0.0.1:4300/',
|
|
},
|
|
{
|
|
name: 'ide-gateway',
|
|
cwd: resolve(root, 'apps/ide'),
|
|
args: ['gateway/main.mjs'],
|
|
env: environment([
|
|
/^WF_API_URL$/,
|
|
/^WF_TENANT_ID$/,
|
|
/^WF_WORKSPACE_GATEWAY_TOKEN$/,
|
|
/^WF_IDE_PUBLIC_URL$/,
|
|
/^WF_IDE_ALLOWED_UPSTREAM_ORIGINS$/,
|
|
/^WF_COLLABORATION_ALLOWED_UPSTREAM_ORIGINS$/,
|
|
]),
|
|
url: 'http://127.0.0.1:4400/healthz',
|
|
},
|
|
],
|
|
'Cloud IDE: request a workspace on a project page, then open it (gateway http://127.0.0.1:4400).',
|
|
);
|