Skip to content
This repository was archived by the owner on Apr 14, 2025. It is now read-only.

Commit bcbf73c

Browse files
jpadamsshykes
authored andcommitted
toy programmer in typescript using go workspace
Signed-off-by: Jeremy Adams <jeremy@dagger.io>
1 parent 462fd9c commit bcbf73c

File tree

8 files changed

+1300
-0
lines changed

8 files changed

+1300
-0
lines changed

toy-programmer-ts/.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/sdk/** linguist-generated

toy-programmer-ts/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/sdk
2+
/**/node_modules/**
3+
/**/.pnpm-store/**

toy-programmer-ts/dagger.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"name": "toy-programmer-ts",
3+
"engineVersion": "v0.17.0-llm.2",
4+
"sdk": {
5+
"source": "typescript"
6+
},
7+
"dependencies": [
8+
{
9+
"name": "toy-workspace",
10+
"source": "../toy-workspace"
11+
}
12+
]
13+
}

toy-programmer-ts/package.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"type": "module",
3+
"dependencies": {
4+
"@dagger.io/dagger": "./sdk",
5+
"typescript": "^5.5.4"
6+
},
7+
"packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
8+
}

toy-programmer-ts/prompt.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
You are an expert go programmer.
2+
You have access to a workspace.
3+
Use the read, write, build tools to complete the following assignment:
4+
5+
<assignment>
6+
$assignment
7+
</assignment>
8+
9+
Don't stop until your code builds.

toy-programmer-ts/src/index.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { dag, Container, func, object } from "@dagger.io/dagger";
2+
3+
@object()
4+
export class ToyProgrammerTs {
5+
/**
6+
* Write a Go program based on the provided assignment.
7+
*/
8+
@func()
9+
GoProgram(assignment: string): Container {
10+
// Create a new workspace using the third-party module
11+
let before = dag.toyWorkspace();
12+
13+
// Run the agent loop in the workspace
14+
let after = dag
15+
.llm()
16+
.withToyWorkspace(before)
17+
.withPromptVar("assignment", assignment)
18+
.withPromptFile(dag.currentModule().source().file("prompt.txt"))
19+
.ToyWorkspace();
20+
21+
// Return the modified workspace's container
22+
return after.container();
23+
}
24+
}

toy-programmer-ts/tsconfig.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"compilerOptions": {
3+
"target": "ES2022",
4+
"moduleResolution": "Node",
5+
"experimentalDecorators": true,
6+
"paths": {
7+
"@dagger.io/dagger": ["./sdk/src"],
8+
"@dagger.io/dagger/telemetry": ["./sdk/src/telemetry"]
9+
}
10+
}
11+
}

toy-programmer-ts/yarn.lock

Lines changed: 1231 additions & 0 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)