Skip to content

An open-source, faster Devin alternative

TypeScript

cli: preserve compiled model declarations in template build artifacts (#818)

devin-ai-integration[bot]df319a7792f5
diff --git a/cli/package-lock.json b/cli/package-lock.json
index cbe5c81c..d11aa404 100644
--- a/cli/package-lock.json
+++ b/cli/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "@opencomputer/cli",
- "version": "0.7.12",
+ "version": "0.7.13",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "@opencomputer/cli",
- "version": "0.7.12",
+ "version": "0.7.13",
"dependencies": {
"@opencode-ai/sdk": "1.18.4",
"ai": "^7.0.45",
diff --git a/cli/package.json b/cli/package.json
index f75570e5..af28771d 100644
--- a/cli/package.json
+++ b/cli/package.json
@@ -1,6 +1,6 @@
{
"name": "@opencomputer/cli",
- "version": "0.7.12",
+ "version": "0.7.13",
"description": "Build, test, deploy, and share OpenComputer agents as code.",
"type": "module",
"bin": {
diff --git a/cli/src/template.test.ts b/cli/src/template.test.ts
index 65650198..3ac68cc3 100644
--- a/cli/src/template.test.ts
+++ b/cli/src/template.test.ts
@@ -156,3 +156,61 @@ prompt = "Say hello."
await rm(parent, { recursive: true, force: true });
}
});
+
+const modelTemplate = `schema = 1
+[template]
+name = "Model template"
+description = "Declares a model."
+[template.first_run]
+agent = "hello-world"
+prompt = "Say hello."
+`;
+
+test("template build retains compiled model declarations per agent", async () => {
+ const parent = await mkdtemp(
+ resolve(tmpdir(), "opencomputer-template-models-"),
+ );
+ try {
+ const initialized = await initializeAgentProject(resolve(parent, "app"));
+ await writeFile(resolve(initialized.root, "oc-template.toml"), modelTemplate);
+ await writeFile(
+ resolve(initialized.agentRoot, "agent.ts"),
+ `import { useModel } from "@opencomputer/agent";
+
+export default function Agent() {
+ useModel("typesafe/jev-router");
+ return "Route the request.";
+}
+`,
+ );
+ const bundle = await buildTemplateProject(initialized.root);
+ assert.equal(bundle.artifacts.length, 1);
+ assert.deepEqual(bundle.artifacts[0]!.models, [
+ { provider: "openrouter", model: "typesafe/jev-router" },
+ ]);
+ } finally {
+ await rm(parent, { recursive: true, force: true });
+ }
+});
+
+test("template build emits an empty model list for agents without useModel", async () => {
+ const parent = await mkdtemp(
+ resolve(tmpdir(), "opencomputer-template-no-model-"),
+ );
+ try {
+ const initialized = await initializeAgentProject(resolve(parent, "app"));
+ await writeFile(resolve(initialized.root, "oc-template.toml"), modelTemplate);
+ await writeFile(
+ resolve(initialized.agentRoot, "agent.ts"),
+ `export default function Agent() {
+ return "Help with the request.";
+}
+`,
+ );
+ const bundle = await buildTemplateProject(initialized.root);
+ assert.equal(bundle.artifacts.length, 1);
+ assert.deepEqual(bundle.artifacts[0]!.models, []);
+ } finally {
+ await rm(parent, { recursive: true, force: true });
+ }
+});
diff --git a/cli/src/template.ts b/cli/src/template.ts
index d457d579..063a7185 100644
--- a/cli/src/template.ts
+++ b/cli/src/template.ts
@@ -52,6 +52,7 @@ export interface TemplateBuildArtifact {
httpConnections: HttpConnectionManifest[];
githubConnections: GitHubConnectionManifest[];
memory: MemoryDeclaration[];
+ models: Array<{ provider: string; model: string }>;
}
export interface TemplateBuildBundle {
@@ -330,6 +331,7 @@ export async function buildTemplateProject(
httpConnections: built.httpConnections,
githubConnections: built.githubConnections,
memory: built.memory,
+ models: built.models,
});
for (const connection of built.connections)
compiledConnections.add(connection);
diff --git a/create-start/package.json b/create-start/package.json
index b1b7415d..16e6216b 100644
--- a/create-start/package.json
+++ b/create-start/package.json
@@ -1,6 +1,6 @@
{
"name": "@opencomputer/create-start",
- "version": "0.7.12",
+ "version": "0.7.13",
"description": "Create a hello-world OpenComputer agent application.",
"type": "module",
"bin": {
@@ -18,7 +18,7 @@
"node": ">=22.0.0"
},
"dependencies": {
- "@opencomputer/cli": "0.7.12"
+ "@opencomputer/cli": "0.7.13"
},
"publishConfig": {
"access": "public"