wishforge-ide/scripts/dev-ide.mjs
eust-w a9411f586b feat: run the whole loop locally with a local provisioner
Local development had no provisioner, so every wish stopped at "sandbox not
ready", and dev:all started neither the coordinator nor the deployer.

- The provisioner moves from apps/ide to apps/provisioner and gains a backend
  switch: `local` starts an executor and a verifier process per run generation
  on this host (WF_SANDBOX_MODE=host, own directories and run-scoped tokens,
  development mode only) and points workspaces at the local Theia; `kubernetes`
  keeps the Kata Jobs, now started with the image entrypoint instead of the npm dev
  script and allowed to reach the platform Git service.
- In development the resource grant needs no runtime image digest.
- setup:local is one idempotent script that creates or completes .env.local,
  including the deployment mode, provisioner and grant settings.
- dev:all starts Git, API, provisioner, coordinator, deployer and web; dev:ide
  starts Theia and the IDE gateway; ide:install and ide:build wrap the separate
  Theia package. npm test also runs the provisioner tests.
- Project settings accept the target branch and dependency install commands.
- Web development conveniences require WF_DEPLOYMENT_MODE=development.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-19 15:36:12 +08:00

41 lines
1.4 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.
const workspace = resolve(root, '.wishforge/ide-workspace');
mkdirSync(workspace, { recursive: true });
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,
}),
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).',
);