@replayio/app-building 1.0.2 → 1.0.3
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/README.md +99 -67
- package/package.json +6 -23
- /package/dist/{package/container-registry.d.ts → container-registry.d.ts} +0 -0
- /package/dist/{package/container-registry.js → container-registry.js} +0 -0
- /package/dist/{package/container-utils.d.ts → container-utils.d.ts} +0 -0
- /package/dist/{package/container-utils.js → container-utils.js} +0 -0
- /package/dist/{package/container.d.ts → container.d.ts} +0 -0
- /package/dist/{package/container.js → container.js} +0 -0
- /package/dist/{package/fly.d.ts → fly.d.ts} +0 -0
- /package/dist/{package/fly.js → fly.js} +0 -0
- /package/dist/{package/http-client.d.ts → http-client.d.ts} +0 -0
- /package/dist/{package/http-client.js → http-client.js} +0 -0
- /package/dist/{package/image-ref.d.ts → image-ref.d.ts} +0 -0
- /package/dist/{package/image-ref.js → image-ref.js} +0 -0
- /package/dist/{package/index.d.ts → index.d.ts} +0 -0
- /package/dist/{package/index.js → index.js} +0 -0
package/README.md
CHANGED
|
@@ -1,92 +1,124 @@
|
|
|
1
|
-
# app-building
|
|
1
|
+
# @replayio/app-building
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
according to a spec without human involvement along the way. Example use cases:
|
|
3
|
+
Library for managing agentic app-building containers. Start and stop containers locally (Docker) or remotely (Fly.io), communicate with the in-container HTTP server, and track container state via a local registry.
|
|
5
4
|
|
|
6
|
-
|
|
7
|
-
* `npm run agent -- -p "Continue maintaining app XYZ and fix these bugs: ..."`
|
|
8
|
-
* `npm run agent -- -i` for interactive access to the agent.
|
|
9
|
-
|
|
10
|
-
Core ideas:
|
|
11
|
-
|
|
12
|
-
* The agent runs within a docker container that clones the target repo and exposes an HTTP server for control.
|
|
13
|
-
* The host communicates with the container via HTTP — sending prompts, polling events/logs, and managing lifecycle.
|
|
14
|
-
* The agent builds by following a set of skill documents with guides
|
|
15
|
-
for breaking its work down into jobs and directives for performing those tasks.
|
|
16
|
-
* The agent commits logs for it to review later and improve its skills.
|
|
17
|
-
* All code changes are committed and pushed back to the remote from inside the container.
|
|
18
|
-
|
|
19
|
-
Containers can run locally or remotely.
|
|
20
|
-
|
|
21
|
-
## Setup
|
|
5
|
+
## Install
|
|
22
6
|
|
|
23
7
|
```bash
|
|
24
|
-
npm install
|
|
8
|
+
npm install @replayio/app-building
|
|
25
9
|
```
|
|
26
10
|
|
|
27
|
-
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
import {
|
|
15
|
+
loadDotEnv,
|
|
16
|
+
ContainerRegistry,
|
|
17
|
+
type ContainerConfig,
|
|
18
|
+
type RepoOptions,
|
|
19
|
+
startContainer,
|
|
20
|
+
startRemoteContainer,
|
|
21
|
+
stopRemoteContainer,
|
|
22
|
+
httpGet,
|
|
23
|
+
httpPost,
|
|
24
|
+
httpOptsFor,
|
|
25
|
+
} from "@replayio/app-building";
|
|
26
|
+
|
|
27
|
+
// Assemble config once at startup
|
|
28
|
+
const envVars = loadDotEnv("/path/to/project");
|
|
29
|
+
const config: ContainerConfig = {
|
|
30
|
+
projectRoot: "/path/to/project",
|
|
31
|
+
envVars,
|
|
32
|
+
registry: new ContainerRegistry("/path/to/.container-registry.jsonl"),
|
|
33
|
+
flyToken: envVars.FLY_API_TOKEN,
|
|
34
|
+
flyApp: envVars.FLY_APP_NAME,
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
// Start a remote container
|
|
38
|
+
const repo: RepoOptions = { repoUrl: "https://github.com/...", cloneBranch: "main", pushBranch: "main" };
|
|
39
|
+
const state = await startRemoteContainer(config, repo);
|
|
40
|
+
|
|
41
|
+
// Send a prompt and wait for completion
|
|
42
|
+
const httpOpts = httpOptsFor(state);
|
|
43
|
+
const { id } = await httpPost(`${state.baseUrl}/message`, { prompt: "Build the app" }, httpOpts);
|
|
44
|
+
|
|
45
|
+
// Check status
|
|
46
|
+
const status = await httpGet(`${state.baseUrl}/status`, httpOpts);
|
|
47
|
+
|
|
48
|
+
// Query the registry
|
|
49
|
+
const alive = await config.registry.findAlive();
|
|
50
|
+
|
|
51
|
+
// Clean up
|
|
52
|
+
await stopRemoteContainer(config, state);
|
|
53
|
+
```
|
|
28
54
|
|
|
29
|
-
##
|
|
55
|
+
## Exported API
|
|
30
56
|
|
|
31
|
-
|
|
57
|
+
### Domain objects
|
|
32
58
|
|
|
33
|
-
|
|
59
|
+
| Export | Description |
|
|
60
|
+
|---|---|
|
|
61
|
+
| `ContainerConfig` | Interface bundling all external state: `projectRoot`, `envVars`, `registry`, optional `flyToken`/`flyApp`/`imageRef`. |
|
|
62
|
+
| `RepoOptions` | Per-invocation git settings: `repoUrl`, `cloneBranch`, `pushBranch`. |
|
|
63
|
+
| `ContainerRegistry` | Class encapsulating `.container-registry.jsonl` persistence. Methods: `log`, `markStopped`, `clearStopped`, `getRecent`, `find`, `findAlive`. |
|
|
34
64
|
|
|
35
|
-
|
|
36
|
-
npm run agent
|
|
37
|
-
npm run agent -- -p "<prompt>"
|
|
38
|
-
npm run agent -- --branch dev --push-branch feature/xyz -p "<prompt>"
|
|
39
|
-
```
|
|
65
|
+
### Container lifecycle
|
|
40
66
|
|
|
41
|
-
|
|
67
|
+
| Export | Description |
|
|
68
|
+
|---|---|
|
|
69
|
+
| `startContainer(config, repo)` | Build the Docker image locally and start a container with `--network host`. Returns `AgentState`. |
|
|
70
|
+
| `startRemoteContainer(config, repo)` | Create a Fly.io machine using the GHCR image. Requires `config.flyToken` and `config.flyApp`. Returns `AgentState`. |
|
|
71
|
+
| `stopContainer(config, containerName)` | Stop a local Docker container by name. |
|
|
72
|
+
| `stopRemoteContainer(config, state)` | Destroy the Fly.io machine for a remote container. Requires `config.flyToken`. |
|
|
73
|
+
| `buildImage(config)` | Build the Docker image locally (called automatically by `startContainer`). |
|
|
74
|
+
| `spawnTestContainer(config)` | Start an interactive (`-it`) container with the repo mounted at `/repo`. |
|
|
75
|
+
| `loadDotEnv(projectRoot)` | Parse a `.env` file and return key-value pairs. |
|
|
42
76
|
|
|
43
|
-
|
|
77
|
+
**Types:** `AgentState`, `ContainerConfig`, `RepoOptions`
|
|
44
78
|
|
|
45
|
-
|
|
46
|
-
npm run agent -- -i
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
Chat with the agent inside a container. Output is streamed via event polling. Press ESC to interrupt the current message. On exit, the container is detached and finishes any remaining work.
|
|
79
|
+
### Container registry (`ContainerRegistry` class)
|
|
50
80
|
|
|
51
|
-
|
|
81
|
+
| Method | Description |
|
|
82
|
+
|---|---|
|
|
83
|
+
| `log(state)` | Append a new entry to the registry. |
|
|
84
|
+
| `markStopped(name?)` | Mark a container as stopped. |
|
|
85
|
+
| `clearStopped(name)` | Clear the stopped flag (container came back alive). |
|
|
86
|
+
| `getRecent(limit?)` | Read the most recent registry entries. |
|
|
87
|
+
| `find(name)` | Find a specific container by name. |
|
|
88
|
+
| `findAlive()` | Probe recent entries and return those that are alive. Reconciles stopped flags. |
|
|
52
89
|
|
|
53
|
-
|
|
54
|
-
npm run status
|
|
55
|
-
```
|
|
90
|
+
**Types:** `RegistryEntry`
|
|
56
91
|
|
|
57
|
-
|
|
92
|
+
### HTTP client
|
|
58
93
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
npm run stop -- <containerName>
|
|
64
|
-
```
|
|
94
|
+
| Export | Description |
|
|
95
|
+
|---|---|
|
|
96
|
+
| `httpGet(url, opts?)` | GET with retries and timeout. Returns parsed JSON. |
|
|
97
|
+
| `httpPost(url, body?, opts?)` | POST with retries and timeout. Returns parsed JSON. |
|
|
65
98
|
|
|
66
|
-
|
|
99
|
+
**Types:** `HttpOptions`
|
|
67
100
|
|
|
68
|
-
|
|
101
|
+
### Container utilities
|
|
69
102
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
103
|
+
| Export | Description |
|
|
104
|
+
|---|---|
|
|
105
|
+
| `httpOptsFor(state)` | Return `HttpOptions` for a container (adds `fly-force-instance-id` header for remote containers). |
|
|
106
|
+
| `probeAlive(entry)` | Check if a container is responding to `/status`. |
|
|
73
107
|
|
|
74
|
-
|
|
75
|
-
2. Builds the app and writes tests to match the spec.
|
|
76
|
-
3. Gets all the tests to pass, deploys to production, and does further testing.
|
|
108
|
+
### Fly.io machines
|
|
77
109
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
110
|
+
| Export | Description |
|
|
111
|
+
|---|---|
|
|
112
|
+
| `createApp(token, name, org?)` | Create a Fly app and allocate IPs. |
|
|
113
|
+
| `createMachine(app, token, image, env, name)` | Create a Fly machine. Returns machine ID. |
|
|
114
|
+
| `waitForMachine(app, token, machineId, timeout?)` | Wait for a machine to reach `started` state. |
|
|
115
|
+
| `destroyMachine(app, token, machineId)` | Force-destroy a machine. |
|
|
116
|
+
| `listMachines(app, token)` | List all machines for an app. |
|
|
82
117
|
|
|
83
|
-
|
|
84
|
-
do it but not always) the agent will converge on an app that follows the initial spec
|
|
85
|
-
and skill directives.
|
|
118
|
+
**Types:** `FlyMachineInfo`
|
|
86
119
|
|
|
87
|
-
|
|
120
|
+
### Image ref
|
|
88
121
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
and debug problems it encounters in tests or the deployed app.
|
|
122
|
+
| Export | Description |
|
|
123
|
+
|---|---|
|
|
124
|
+
| `getImageRef()` | Returns `CONTAINER_IMAGE_REF` env var, or `ghcr.io/replayio/app-building:latest` by default. Used by `startRemoteContainer`. |
|
package/package.json
CHANGED
|
@@ -1,35 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@replayio/app-building",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "1.0.3",
|
|
4
|
+
"description": "Library for managing agentic app-building containers",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
7
7
|
".": {
|
|
8
|
-
"import": "./dist/
|
|
9
|
-
"types": "./dist/
|
|
8
|
+
"import": "./dist/index.js",
|
|
9
|
+
"types": "./dist/index.d.ts"
|
|
10
10
|
}
|
|
11
11
|
},
|
|
12
12
|
"files": [
|
|
13
|
-
"dist
|
|
13
|
+
"dist"
|
|
14
14
|
],
|
|
15
|
-
"readme": "src/package/README.md",
|
|
16
15
|
"scripts": {
|
|
17
|
-
"
|
|
18
|
-
"status": "tsx src/status.ts",
|
|
19
|
-
"read-log": "tsx src/read-log.ts",
|
|
20
|
-
"reset-app": "tsx src/reset-app.ts",
|
|
21
|
-
"docker:build": "docker build --no-cache --network=host -t app-building .",
|
|
22
|
-
"test-container": "tsx src/test-container.ts",
|
|
23
|
-
"stop": "tsx src/stop.ts",
|
|
24
|
-
"fly-machines": "tsx src/fly-machines.ts",
|
|
25
|
-
"add-task": "tsx scripts/add-task.ts"
|
|
26
|
-
},
|
|
27
|
-
"devDependencies": {
|
|
28
|
-
"@types/node": "^25.3.0",
|
|
29
|
-
"tsx": "^4.19.0",
|
|
30
|
-
"typescript": "^5.5.0"
|
|
31
|
-
},
|
|
32
|
-
"dependencies": {
|
|
33
|
-
"commander": "^14.0.3"
|
|
16
|
+
"prepublishOnly": "tsc -p tsconfig.json"
|
|
34
17
|
}
|
|
35
18
|
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|