Skip to content

Commit efd9c85

Browse files
author
Hweinstock
committed
feat(project): finish add implementation
1 parent a80d21c commit efd9c85

2 files changed

Lines changed: 12 additions & 6 deletions

File tree

src/core/project/manager.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import { createHarnessTreeFromSpec, createProjectTreeFromTemplate, TEMPLATES } f
2222
import { ProjectSpecSchema } from "../../projectSchemas/project";
2323
import { enclosingProjectRoot } from "./fsUtils";
2424
import { DeserializationError, InputValidationError, ProjectStateError } from "../../errors/errors";
25-
import type { HarnessSpec, HarnessSpecSchema } from "../../projectSchemas/harness";
25+
import type { HarnessSpecSchema } from "../../projectSchemas/harness";
2626
import type z from "zod";
2727

2828
type ProjectManagerConfig = {
@@ -140,7 +140,7 @@ export class FsProjectManager implements ProjectManager {
140140
const existingResources = existingProjectSpec[projectSpecKey];
141141
if (existingResources.find((r) => r.name === resourceConfig.name))
142142
throw new InputValidationError(
143-
`a ${projectSpecKey} with name '${resourceConfig.name}' already exists`,
143+
`a ${resourceType} with name '${resourceConfig.name}' already exists`,
144144
);
145145

146146
const newResources = [...existingResources];
@@ -152,7 +152,7 @@ export class FsProjectManager implements ProjectManager {
152152
newResources.push({ name: input.resourceConfig.name, path: harnessPath });
153153
break;
154154
}
155-
// TODO: add a default case to push the resource config. Only runtime/harness and other resources that require non-spec changes should need special casing.
155+
// TODO: add limited special casing for runtime and default for other resources that proxy directly to spec changes.
156156
}
157157

158158
yield { message: `Updating project config file from '${agentCoreSpecPath}'` };
@@ -172,7 +172,7 @@ export class FsProjectManager implements ProjectManager {
172172
harnessSpec: z.input<typeof HarnessSpecSchema>,
173173
): Promise<string> {
174174
const outputPath = join(projectRoot, "app", harnessSpec.name);
175-
const harness = await createHarnessTreeFromSpec(harnessSpec as HarnessSpec);
175+
const harness = await createHarnessTreeFromSpec(harnessSpec);
176176

177177
await harness.write(outputPath);
178178
return outputPath;
@@ -223,6 +223,9 @@ export class FsProjectManager implements ProjectManager {
223223
}
224224
}
225225

226+
/** Map {@link ProjectResource} to keys in the project spec.
227+
* Note: we let TS infer the return type to avoid pulling in keys that do not correspond to resources (ex. name, managedBy, etc.)
228+
*/
226229
function toProjectSpecKey(resourceType: ProjectResource) {
227230
switch (resourceType) {
228231
case "harness":

src/core/project/templates.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1+
import type z from "zod";
12
import { PROJECT_TEMPLATES, type ProjectTemplate } from "../../handlers/project/types";
2-
import { HarnessSpecSchema, type HarnessSpec } from "../../projectSchemas/harness";
3+
import { HarnessSpecSchema } from "../../projectSchemas/harness";
34
import { FsTreeNode } from "./fsTree";
45
import type { AssetSource } from "./source";
56

@@ -94,7 +95,9 @@ export async function createProjectTreeFromTemplate(
9495

9596
const DEFAULT_HARNESS_SYSTEM_PROMPT = "You are a helpful assistant";
9697

97-
export async function createHarnessTreeFromSpec(spec: HarnessSpec): Promise<FsTreeNode> {
98+
export async function createHarnessTreeFromSpec(
99+
spec: z.input<typeof HarnessSpecSchema>,
100+
): Promise<FsTreeNode> {
98101
return FsTreeNode.createDirectory(".", [
99102
FsTreeNode.createFile("harness.json", async () => json(HarnessSpecSchema.parse(spec))),
100103
FsTreeNode.createFile(

0 commit comments

Comments
 (0)