wishforge-ide/scripts/setup-local.mjs
eust-w ba5fe56e88 refactor: replace platform meta-evolution with versioned agent configuration
The meta-evolution machinery (failure clustering meta-tasks, signed
offline evaluation, shadow/canary stages, external release receipts,
evaluator identity and its UI) could never take effect: promotions were
written to the system tenant only, the benchmark/runner/observer it
depended on did not exist, and its statistical gates were effectively
unreachable. It is removed as agreed in docs/requirements.md section 3.

What remains is the part every run actually uses, now explicit:

- packages/evolution becomes packages/agent and keeps only the bundle
  schema, content digest and prompt assembly; consumers import it as the
  @wishforge/agent workspace package instead of by relative path.
- apps/api/src/domain/agent-bundles.ts: immutable, content-addressed
  agent configurations per tenant, with create, activate and rollback
  restricted to human owners/admins. A run pins the active version at
  submission; later activations never change it.
- /v1/agent-bundles routes replace /v1/evolution*; all /internal
  evolution routes, the evaluator service token and the rsi:rollout
  script are gone.
- Web: the experiment page becomes an "Agent 配置" page.
- Tests for the deleted modules are removed; control-plane tests cover
  version pinning, rollback and authorization.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-19 13:38:53 +08:00

25 lines
1.6 KiB
JavaScript

import { randomBytes } from 'node:crypto';
import { readFile, writeFile, mkdir } from 'node:fs/promises';
try {
await readFile('.env.local');
console.log('.env.local already exists; preserving it.');
process.exit(0);
} catch {}
const secret = () => randomBytes(32).toString('hex');
const dbPassword = secret();
const devToken = secret();
const config = `# Local only. Generated secrets; never commit this file.\nDATABASE_ADMIN_URL=postgresql://wishforge:wishforge-dev-only@127.0.0.1:55432/wishforge\nDATABASE_URL=postgresql://wishforge_app:${dbPassword}@127.0.0.1:55432/wishforge\nWF_DATABASE_APP_PASSWORD=${dbPassword}\nWF_DEV_AUTH_TOKEN=${devToken}\nWF_WORKER_TOKEN=${secret()}\nWF_VERIFIER_TOKEN=${secret()}\nWF_DEPLOYER_TOKEN=${secret()}\nWF_VAULT_KEY=${secret()}\nWF_SESSION_SECRET=${secret()}\nWF_PUBLIC_URL=http://localhost:3000\nWF_API_URL=http://127.0.0.1:4000\nWF_REGION=local\nWF_DISPATCH_TENANTS=demo\nPORT=4000\nTEMPORAL_ADDRESS=127.0.0.1:7233\nOIDC_ISSUER=http://127.0.0.1:4100/realms/wishforge\nOIDC_AUDIENCE=wishforge-api\nOIDC_CLIENT_ID=wishforge-web\nWF_WEB_CLIENT_ID=wishforge-web\n`;
await writeFile('.env.local', config, { mode: 0o600, flag: 'wx' });
await mkdir('apps/web', { recursive: true });
const webOnly =
config
.split('\n')
.filter(line =>
/^(WF_DEV_AUTH_TOKEN|WF_SESSION_SECRET|WF_PUBLIC_URL|WF_API_URL|OIDC_ISSUER|OIDC_CLIENT_ID)=/.test(line),
)
.join('\n') + '\n';
await writeFile('apps/web/.env.local', webOnly, { mode: 0o600, flag: 'wx' }).catch(e => {
if (e.code !== 'EEXIST') throw e;
});
console.log('Created private .env.local files. Start infra, then run db:migrate and db:seed.');