agent-mockingbird 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.agents/skills/btca-cli/SKILL.md +64 -0
- package/.agents/skills/btca-cli/agents/openai.yaml +3 -0
- package/.agents/skills/frontend-design/SKILL.md +42 -0
- package/.agents/skills/frontend-design/agents/openai.yaml +3 -0
- package/.env.example +36 -0
- package/.githooks/pre-commit +33 -0
- package/.github/workflows/ci.yml +309 -0
- package/.opencode/bun.lock +18 -0
- package/.opencode/package.json +5 -0
- package/.opencode/tools/agent_type_manager.ts +100 -0
- package/.opencode/tools/config_manager.ts +87 -0
- package/.opencode/tools/cron_manager.ts +145 -0
- package/.opencode/tools/memory_get.ts +43 -0
- package/.opencode/tools/memory_remember.ts +53 -0
- package/.opencode/tools/memory_search.ts +48 -0
- package/AGENTS.md +126 -0
- package/MEMORY.md +2 -0
- package/README.md +451 -0
- package/THIRD_PARTY_NOTICES.md +11 -0
- package/agent-mockingbird.config.example.json +135 -0
- package/apps/server/package.json +32 -0
- package/apps/server/src/backend/agents/bootstrapContext.ts +362 -0
- package/apps/server/src/backend/agents/openclawImport.test.ts +133 -0
- package/apps/server/src/backend/agents/openclawImport.ts +797 -0
- package/apps/server/src/backend/agents/opencodeConfig.ts +428 -0
- package/apps/server/src/backend/agents/service.ts +10 -0
- package/apps/server/src/backend/config/example-config.test.ts +20 -0
- package/apps/server/src/backend/config/orchestration.ts +243 -0
- package/apps/server/src/backend/config/policy.ts +158 -0
- package/apps/server/src/backend/config/schema.test.ts +15 -0
- package/apps/server/src/backend/config/schema.ts +391 -0
- package/apps/server/src/backend/config/semantic.test.ts +34 -0
- package/apps/server/src/backend/config/semantic.ts +149 -0
- package/apps/server/src/backend/config/service.test.ts +75 -0
- package/apps/server/src/backend/config/service.ts +207 -0
- package/apps/server/src/backend/config/smoke.ts +77 -0
- package/apps/server/src/backend/config/store.test.ts +123 -0
- package/apps/server/src/backend/config/store.ts +581 -0
- package/apps/server/src/backend/config/testFixtures.ts +5 -0
- package/apps/server/src/backend/config/types.ts +56 -0
- package/apps/server/src/backend/contracts/events.ts +320 -0
- package/apps/server/src/backend/contracts/runtime.ts +111 -0
- package/apps/server/src/backend/cron/executor.ts +435 -0
- package/apps/server/src/backend/cron/repository.ts +170 -0
- package/apps/server/src/backend/cron/service.ts +660 -0
- package/apps/server/src/backend/cron/storage.ts +92 -0
- package/apps/server/src/backend/cron/types.ts +138 -0
- package/apps/server/src/backend/cron/utils.ts +351 -0
- package/apps/server/src/backend/db/client.ts +20 -0
- package/apps/server/src/backend/db/migrate.ts +40 -0
- package/apps/server/src/backend/db/repository.ts +1762 -0
- package/apps/server/src/backend/db/schema.ts +113 -0
- package/apps/server/src/backend/db/usageDashboard.test.ts +102 -0
- package/apps/server/src/backend/db/wipe.ts +13 -0
- package/apps/server/src/backend/defaults.ts +32 -0
- package/apps/server/src/backend/env.ts +48 -0
- package/apps/server/src/backend/heartbeat/activeHours.ts +45 -0
- package/apps/server/src/backend/heartbeat/defaultJob.ts +88 -0
- package/apps/server/src/backend/heartbeat/heartbeat.test.ts +110 -0
- package/apps/server/src/backend/heartbeat/runtimeService.ts +190 -0
- package/apps/server/src/backend/heartbeat/service.ts +176 -0
- package/apps/server/src/backend/heartbeat/state.test.ts +63 -0
- package/apps/server/src/backend/heartbeat/state.ts +167 -0
- package/apps/server/src/backend/heartbeat/types.ts +54 -0
- package/apps/server/src/backend/http/boundedQueue.test.ts +49 -0
- package/apps/server/src/backend/http/boundedQueue.ts +92 -0
- package/apps/server/src/backend/http/parsers.ts +40 -0
- package/apps/server/src/backend/http/router.ts +61 -0
- package/apps/server/src/backend/http/routes/agentRoutes.ts +67 -0
- package/apps/server/src/backend/http/routes/backgroundRoutes.ts +203 -0
- package/apps/server/src/backend/http/routes/chatRoutes.ts +107 -0
- package/apps/server/src/backend/http/routes/configRoutes.ts +602 -0
- package/apps/server/src/backend/http/routes/cronRoutes.ts +221 -0
- package/apps/server/src/backend/http/routes/dashboardRoutes.ts +308 -0
- package/apps/server/src/backend/http/routes/eventRoutes.ts +7 -0
- package/apps/server/src/backend/http/routes/heartbeatRoutes.test.ts +41 -0
- package/apps/server/src/backend/http/routes/heartbeatRoutes.ts +28 -0
- package/apps/server/src/backend/http/routes/index.ts +101 -0
- package/apps/server/src/backend/http/routes/mcpRoutes.ts +213 -0
- package/apps/server/src/backend/http/routes/memoryRoutes.ts +154 -0
- package/apps/server/src/backend/http/routes/runRoutes.ts +310 -0
- package/apps/server/src/backend/http/routes/runtimeRoutes.ts +197 -0
- package/apps/server/src/backend/http/routes/skillRoutes.ts +112 -0
- package/apps/server/src/backend/http/routes/uiRoutes.test.ts +161 -0
- package/apps/server/src/backend/http/routes/uiRoutes.ts +177 -0
- package/apps/server/src/backend/http/routes/usageRoutes.test.ts +104 -0
- package/apps/server/src/backend/http/routes/usageRoutes.ts +767 -0
- package/apps/server/src/backend/http/schemas.ts +64 -0
- package/apps/server/src/backend/http/sse.ts +144 -0
- package/apps/server/src/backend/integration/backend-core.test.ts +2316 -0
- package/apps/server/src/backend/logging/logger.ts +64 -0
- package/apps/server/src/backend/mcp/service.ts +326 -0
- package/apps/server/src/backend/memory/cli.ts +170 -0
- package/apps/server/src/backend/memory/conceptExpansion.test.ts +28 -0
- package/apps/server/src/backend/memory/conceptExpansion.ts +80 -0
- package/apps/server/src/backend/memory/qmdPort.test.ts +54 -0
- package/apps/server/src/backend/memory/qmdPort.ts +61 -0
- package/apps/server/src/backend/memory/records.test.ts +66 -0
- package/apps/server/src/backend/memory/records.ts +229 -0
- package/apps/server/src/backend/memory/service.ts +2012 -0
- package/apps/server/src/backend/memory/sqliteVec.ts +58 -0
- package/apps/server/src/backend/memory/types.ts +104 -0
- package/apps/server/src/backend/opencode/agentMockingbirdPlugin.test.ts +396 -0
- package/apps/server/src/backend/opencode/client.ts +98 -0
- package/apps/server/src/backend/opencode/models.ts +41 -0
- package/apps/server/src/backend/opencode/systemPrompt.test.ts +146 -0
- package/apps/server/src/backend/opencode/systemPrompt.ts +284 -0
- package/apps/server/src/backend/paths.ts +57 -0
- package/apps/server/src/backend/prompts/service.ts +100 -0
- package/apps/server/src/backend/queue/queue.test.ts +189 -0
- package/apps/server/src/backend/queue/service.ts +177 -0
- package/apps/server/src/backend/queue/types.ts +39 -0
- package/apps/server/src/backend/run/service.ts +576 -0
- package/apps/server/src/backend/run/storage.ts +47 -0
- package/apps/server/src/backend/run/types.ts +44 -0
- package/apps/server/src/backend/runtime/errors.ts +61 -0
- package/apps/server/src/backend/runtime/index.ts +72 -0
- package/apps/server/src/backend/runtime/memoryPromptDedup.test.ts +153 -0
- package/apps/server/src/backend/runtime/memoryPromptDedup.ts +76 -0
- package/apps/server/src/backend/runtime/opencodeRuntime/backgroundMethods.ts +765 -0
- package/apps/server/src/backend/runtime/opencodeRuntime/coreMethods.ts +705 -0
- package/apps/server/src/backend/runtime/opencodeRuntime/eventMethods.ts +503 -0
- package/apps/server/src/backend/runtime/opencodeRuntime/memoryMethods.ts +462 -0
- package/apps/server/src/backend/runtime/opencodeRuntime/promptMethods.ts +1167 -0
- package/apps/server/src/backend/runtime/opencodeRuntime/shared.ts +254 -0
- package/apps/server/src/backend/runtime/opencodeRuntime.test.ts +2899 -0
- package/apps/server/src/backend/runtime/opencodeRuntime.ts +135 -0
- package/apps/server/src/backend/runtime/sessionScope.ts +45 -0
- package/apps/server/src/backend/skills/service.ts +442 -0
- package/apps/server/src/backend/workspace/resolve.ts +27 -0
- package/apps/server/src/cli/agent-mockingbird.mjs +2522 -0
- package/apps/server/src/cli/agent-mockingbird.test.ts +68 -0
- package/apps/server/src/cli/runtime-assets.mjs +269 -0
- package/apps/server/src/cli/runtime-assets.test.ts +52 -0
- package/apps/server/src/cli/runtime-layout.mjs +75 -0
- package/apps/server/src/cli/standaloneBuild.test.ts +19 -0
- package/apps/server/src/cli/standaloneBuild.ts +19 -0
- package/apps/server/src/cli/standaloneCronBinary.test.ts +187 -0
- package/apps/server/src/index.ts +178 -0
- package/apps/server/tsconfig.json +12 -0
- package/backlog.md +5 -0
- package/bin/agent-mockingbird +2522 -0
- package/bin/runtime-layout.mjs +75 -0
- package/build-bin.ts +34 -0
- package/build-cli.mjs +37 -0
- package/build.ts +40 -0
- package/bun-env.d.ts +11 -0
- package/bun.lock +888 -0
- package/bunfig.toml +2 -0
- package/components.json +21 -0
- package/config.json +130 -0
- package/deploy/RELEASE_INSTALL.md +112 -0
- package/deploy/docker-compose.yml +42 -0
- package/deploy/systemd/README.md +46 -0
- package/deploy/systemd/agent-mockingbird.service +28 -0
- package/deploy/systemd/opencode.service +25 -0
- package/docs/legacy-config-ui-reference.md +51 -0
- package/docs/memory-e2e-trace-2026-03-04.md +63 -0
- package/docs/memory-ops.md +96 -0
- package/docs/memory-runtime-contract.md +42 -0
- package/docs/memory-tuning-remote-2026-03-04.md +59 -0
- package/docs/opencode-rebase-workflow-plan.md +614 -0
- package/docs/opencode-startup-sync-plan.md +94 -0
- package/docs/vendor-opencode.md +41 -0
- package/drizzle/0000_famous_turbo.sql +49 -0
- package/drizzle/0001_cron_memory_aux.sql +160 -0
- package/drizzle/0002_runtime_session_bindings.sql +28 -0
- package/drizzle/0003_background_runs.sql +27 -0
- package/drizzle/0004_memory_open_write.sql +63 -0
- package/drizzle/0005_signal_channel.sql +47 -0
- package/drizzle/0006_usage_event_dimensions.sql +7 -0
- package/drizzle/meta/0000_snapshot.json +341 -0
- package/drizzle/meta/_journal.json +55 -0
- package/drizzle.config.ts +14 -0
- package/eslint.config.mjs +77 -0
- package/knip.json +18 -0
- package/memory/2026-03-04.md +4 -0
- package/opencode.lock.json +16 -0
- package/package.json +67 -0
- package/packages/agent-mockingbird-installer/README.md +31 -0
- package/packages/agent-mockingbird-installer/bin/agent-mockingbird-installer.mjs +44 -0
- package/packages/agent-mockingbird-installer/opencode.lock.json +16 -0
- package/packages/agent-mockingbird-installer/package.json +23 -0
- package/packages/contracts/package.json +19 -0
- package/packages/contracts/src/agentTypes.ts +122 -0
- package/packages/contracts/src/cron.ts +146 -0
- package/packages/contracts/src/dashboard.ts +378 -0
- package/packages/contracts/src/index.ts +3 -0
- package/packages/contracts/tsconfig.json +4 -0
- package/patches/opencode/0001-Wafflebot-OpenCode-baseline.patch +2341 -0
- package/patches/opencode/0002-Fix-OpenCode-web-entry-and-settings-icons.patch +104 -0
- package/patches/opencode/0003-fix-app-remove-duplicate-sidebar-mount.patch +32 -0
- package/patches/opencode/0004-Add-heartbeat-settings-and-usage-nav.patch +506 -0
- package/patches/opencode/0005-Use-chart-icon-for-usage-nav.patch +38 -0
- package/patches/opencode/0006-Modernize-cron-settings.patch +399 -0
- package/patches/opencode/0007-Rename-waffle-namespaces-to-mockingbird.patch +1110 -0
- package/patches/opencode/0008-Remove-cron-contract-section.patch +178 -0
- package/patches/opencode/0009-Rework-cron-tab-as-operations-console.patch +414 -0
- package/patches/opencode/0010-Refine-heartbeat-settings-controls.patch +208 -0
- package/runtime-assets/opencode-config/opencode.jsonc +25 -0
- package/runtime-assets/opencode-config/package.json +5 -0
- package/runtime-assets/opencode-config/plugins/agent-mockingbird.ts +715 -0
- package/runtime-assets/workspace/.agents/skills/config-auditor/SKILL.md +25 -0
- package/runtime-assets/workspace/.agents/skills/config-editor/SKILL.md +24 -0
- package/runtime-assets/workspace/.agents/skills/cron-manager/SKILL.md +57 -0
- package/runtime-assets/workspace/.agents/skills/memory-ops/SKILL.md +120 -0
- package/runtime-assets/workspace/.agents/skills/runtime-diagnose/SKILL.md +25 -0
- package/runtime-assets/workspace/AGENTS.md +56 -0
- package/runtime-assets/workspace/MEMORY.md +4 -0
- package/scripts/build-release-bundle.sh +66 -0
- package/scripts/check-ship.ts +383 -0
- package/scripts/dev-opencode.sh +17 -0
- package/scripts/dev-stack-opencode.sh +15 -0
- package/scripts/dev-stack.sh +61 -0
- package/scripts/install-systemd.sh +87 -0
- package/scripts/memory-e2e.sh +76 -0
- package/scripts/memory-trace-e2e.sh +141 -0
- package/scripts/migrate-opencode-env.ts +108 -0
- package/scripts/onboard/bootstrap.sh +32 -0
- package/scripts/opencode-swap.ts +78 -0
- package/scripts/opencode-sync.ts +715 -0
- package/scripts/runtime-assets-sync.mjs +83 -0
- package/scripts/setup-git-hooks.ts +39 -0
- package/tsconfig.json +45 -0
- package/tui.json +98 -0
- package/turbo.json +36 -0
- package/vendor/OPENCODE_VENDOR.md +13 -0
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import process from "node:process";
|
|
5
|
+
|
|
6
|
+
function workspaceFingerprint(workspaceDir) {
|
|
7
|
+
return createHash("sha256").update(path.resolve(workspaceDir)).digest("hex").slice(0, 16);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
function resolveManagedOpencodeConfigDir({
|
|
11
|
+
rootDir,
|
|
12
|
+
dataDir = path.join(rootDir, "data"),
|
|
13
|
+
workspaceDir = path.join(rootDir, "workspace"),
|
|
14
|
+
explicitConfigDir = process.env.OPENCODE_CONFIG_DIR,
|
|
15
|
+
}) {
|
|
16
|
+
if (typeof explicitConfigDir === "string" && explicitConfigDir.trim()) {
|
|
17
|
+
return path.resolve(explicitConfigDir.trim());
|
|
18
|
+
}
|
|
19
|
+
return path.join(dataDir, "opencode-config", workspaceFingerprint(workspaceDir));
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function opencodeEnvironment(paths, baseEnv = process.env) {
|
|
23
|
+
return {
|
|
24
|
+
...baseEnv,
|
|
25
|
+
OPENCODE_CONFIG_DIR: paths.opencodeConfigDir,
|
|
26
|
+
OPENCODE_DISABLE_PROJECT_CONFIG: "1",
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function pathsFor({ rootDir, scope, userUnitDir }) {
|
|
31
|
+
const normalizedScope = scope.replace(/^@/, "");
|
|
32
|
+
const npmPrefix = path.join(rootDir, "npm");
|
|
33
|
+
const workspaceDir = path.join(rootDir, "workspace");
|
|
34
|
+
const dataDir = path.join(rootDir, "data");
|
|
35
|
+
const localBinDir = path.join(process.env.HOME || "", ".local", "bin");
|
|
36
|
+
|
|
37
|
+
return {
|
|
38
|
+
rootDir,
|
|
39
|
+
npmPrefix,
|
|
40
|
+
localBinDir,
|
|
41
|
+
agentMockingbirdShimPath: path.join(localBinDir, "agent-mockingbird"),
|
|
42
|
+
opencodeShimPath: path.join(localBinDir, "opencode"),
|
|
43
|
+
dataDir,
|
|
44
|
+
workspaceDir,
|
|
45
|
+
opencodeConfigDir: resolveManagedOpencodeConfigDir({ rootDir, dataDir, workspaceDir }),
|
|
46
|
+
logsDir: path.join(rootDir, "logs"),
|
|
47
|
+
etcDir: path.join(rootDir, "etc"),
|
|
48
|
+
npmrcPath: path.join(rootDir, "etc", "npmrc"),
|
|
49
|
+
agentMockingbirdAppDirGlobal: path.join(npmPrefix, "lib", "node_modules", `@${normalizedScope}`, "agent-mockingbird"),
|
|
50
|
+
agentMockingbirdAppDirLocal: path.join(npmPrefix, "node_modules", `@${normalizedScope}`, "agent-mockingbird"),
|
|
51
|
+
agentMockingbirdBinGlobal: path.join(npmPrefix, "bin", "agent-mockingbird"),
|
|
52
|
+
agentMockingbirdBinLocal: path.join(npmPrefix, "node_modules", ".bin", "agent-mockingbird"),
|
|
53
|
+
opencodeBinGlobal: path.join(npmPrefix, "bin", "opencode"),
|
|
54
|
+
opencodeBinLocal: path.join(npmPrefix, "node_modules", ".bin", "opencode"),
|
|
55
|
+
bunBinManagedGlobal: path.join(npmPrefix, "bin", "bun"),
|
|
56
|
+
bunBinManagedLocal: path.join(npmPrefix, "node_modules", ".bin", "bun"),
|
|
57
|
+
bunBinTools: path.join(rootDir, "tools", "bun", "bin", "bun"),
|
|
58
|
+
opencodeUnitPath: path.join(userUnitDir, "opencode.service"),
|
|
59
|
+
agentMockingbirdUnitPath: path.join(userUnitDir, "agent-mockingbird.service"),
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export function prepareRuntimeAssetSources(agentMockingbirdAppDir) {
|
|
64
|
+
const workspaceSourceDir = path.join(agentMockingbirdAppDir, "runtime-assets", "workspace");
|
|
65
|
+
const opencodeConfigSourceDir = path.join(agentMockingbirdAppDir, "runtime-assets", "opencode-config");
|
|
66
|
+
if (!fs.existsSync(workspaceSourceDir) || !fs.existsSync(opencodeConfigSourceDir)) {
|
|
67
|
+
throw new Error(
|
|
68
|
+
`runtime assets missing in package: expected ${workspaceSourceDir} and ${opencodeConfigSourceDir}`,
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
return {
|
|
72
|
+
workspaceSourceDir,
|
|
73
|
+
opencodeConfigSourceDir,
|
|
74
|
+
};
|
|
75
|
+
}
|
package/build-bin.ts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
|
+
import { cpSync, existsSync, mkdirSync, rmSync } from "node:fs";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
|
|
5
|
+
import { createStandaloneBuildOptions } from "./apps/server/src/cli/standaloneBuild";
|
|
6
|
+
|
|
7
|
+
const repoRoot = import.meta.dir;
|
|
8
|
+
const outdir = path.join(repoRoot, "dist");
|
|
9
|
+
const outfile = path.join(outdir, "agent-mockingbird");
|
|
10
|
+
const drizzleOutdir = path.join(outdir, "drizzle");
|
|
11
|
+
|
|
12
|
+
mkdirSync(outdir, { recursive: true });
|
|
13
|
+
if (existsSync(outfile)) {
|
|
14
|
+
rmSync(outfile, { force: true });
|
|
15
|
+
}
|
|
16
|
+
if (existsSync(drizzleOutdir)) {
|
|
17
|
+
rmSync(drizzleOutdir, { recursive: true, force: true });
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
console.log("Building standalone binary...");
|
|
21
|
+
const result = await Bun.build(createStandaloneBuildOptions(repoRoot, outfile));
|
|
22
|
+
|
|
23
|
+
if (!result.success) {
|
|
24
|
+
for (const message of result.logs) {
|
|
25
|
+
console.error(message);
|
|
26
|
+
}
|
|
27
|
+
process.exit(1);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
console.log("Copying migrations...");
|
|
31
|
+
cpSync(path.join(repoRoot, "drizzle"), drizzleOutdir, { recursive: true });
|
|
32
|
+
|
|
33
|
+
console.log(`Build complete: ${outdir}/agent-mockingbird`);
|
|
34
|
+
console.log("\nTo deploy, copy the entire 'dist' folder to your target location.");
|
package/build-cli.mjs
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
|
+
import { chmodSync, copyFileSync, existsSync, mkdirSync } from "node:fs";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
|
|
5
|
+
const { console } = globalThis;
|
|
6
|
+
|
|
7
|
+
const repoRoot = import.meta.dir;
|
|
8
|
+
const src = path.join(repoRoot, "apps", "server", "src", "cli", "agent-mockingbird.mjs");
|
|
9
|
+
const runtimeAssetsSrc = path.join(repoRoot, "apps", "server", "src", "cli", "runtime-assets.mjs");
|
|
10
|
+
const runtimeLayoutSrc = path.join(repoRoot, "apps", "server", "src", "cli", "runtime-layout.mjs");
|
|
11
|
+
const outDir = path.join(repoRoot, "bin");
|
|
12
|
+
const out = path.join(outDir, "agent-mockingbird");
|
|
13
|
+
const runtimeAssetsOut = path.join(outDir, "runtime-assets.mjs");
|
|
14
|
+
const runtimeLayoutOut = path.join(outDir, "runtime-layout.mjs");
|
|
15
|
+
|
|
16
|
+
if (!existsSync(src)) {
|
|
17
|
+
console.error(`Missing CLI source: ${src}`);
|
|
18
|
+
process.exit(1);
|
|
19
|
+
}
|
|
20
|
+
if (!existsSync(runtimeAssetsSrc)) {
|
|
21
|
+
console.error(`Missing CLI helper source: ${runtimeAssetsSrc}`);
|
|
22
|
+
process.exit(1);
|
|
23
|
+
}
|
|
24
|
+
if (!existsSync(runtimeLayoutSrc)) {
|
|
25
|
+
console.error(`Missing CLI helper source: ${runtimeLayoutSrc}`);
|
|
26
|
+
process.exit(1);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
mkdirSync(outDir, { recursive: true });
|
|
30
|
+
copyFileSync(src, out);
|
|
31
|
+
copyFileSync(runtimeAssetsSrc, runtimeAssetsOut);
|
|
32
|
+
copyFileSync(runtimeLayoutSrc, runtimeLayoutOut);
|
|
33
|
+
chmodSync(out, 0o755);
|
|
34
|
+
|
|
35
|
+
console.log(`Built CLI: ${out}`);
|
|
36
|
+
console.log(`Built CLI helper: ${runtimeAssetsOut}`);
|
|
37
|
+
console.log(`Built CLI helper: ${runtimeLayoutOut}`);
|
package/build.ts
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
|
+
import { cpSync, existsSync, mkdirSync } from "node:fs";
|
|
3
|
+
import { rm } from "node:fs/promises";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
|
|
6
|
+
const repoRoot = import.meta.dir;
|
|
7
|
+
const outdir = path.join(repoRoot, "dist");
|
|
8
|
+
const vendorRoot = path.join(repoRoot, "vendor", "opencode");
|
|
9
|
+
const appSourceDir = path.join(repoRoot, "vendor", "opencode", "packages", "app", "dist");
|
|
10
|
+
const appOutdir = path.join(outdir, "app");
|
|
11
|
+
|
|
12
|
+
if (!existsSync(vendorRoot)) {
|
|
13
|
+
console.error(
|
|
14
|
+
"Missing generated OpenCode worktree at vendor/opencode. Run `bun run opencode:sync --rebuild-only` first.",
|
|
15
|
+
);
|
|
16
|
+
process.exit(1);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
if (!existsSync(path.join(vendorRoot, "node_modules"))) {
|
|
20
|
+
console.error(
|
|
21
|
+
"Missing OpenCode dependencies at vendor/opencode/node_modules. Run `bun install --cwd vendor/opencode` first.",
|
|
22
|
+
);
|
|
23
|
+
process.exit(1);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
if (existsSync(outdir)) {
|
|
27
|
+
await rm(outdir, { recursive: true, force: true });
|
|
28
|
+
}
|
|
29
|
+
mkdirSync(outdir, { recursive: true });
|
|
30
|
+
|
|
31
|
+
await Bun.$`bun run build`.cwd(path.join(vendorRoot, "packages", "app")).quiet();
|
|
32
|
+
|
|
33
|
+
cpSync(appSourceDir, appOutdir, { recursive: true });
|
|
34
|
+
|
|
35
|
+
if (!existsSync(path.join(appOutdir, "index.html"))) {
|
|
36
|
+
console.error(`Missing built OpenCode app assets in ${appOutdir}`);
|
|
37
|
+
process.exit(1);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
console.log(`Copied built OpenCode app assets into ${appOutdir}`);
|