create-actuate 0.2.0 → 0.4.0
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 +2 -0
- package/dist/bin.js +9 -4
- package/dist/{chunk-24GQNKSL.js → chunk-QVLVAHZC.js} +60 -4
- package/dist/index.d.ts +5 -1
- package/dist/index.js +5 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -13,6 +13,8 @@ Templates come from [actuate-run/templates](https://github.com/actuate-run/templ
|
|
|
13
13
|
cd my-tool && npm install && npx actuate dev
|
|
14
14
|
```
|
|
15
15
|
|
|
16
|
+
The hello starter comes with `actuator.test.ts` (run it with `npx actuate test`; it uses `node:test` and `@actuate/cli/testing`, nothing else to install) and an `AGENTS.md` that tells coding agents how to check an actuator before it's deployed. A template that ships its own `actuator.test.ts` gets it too.
|
|
17
|
+
|
|
16
18
|
[Quickstart](https://actuate.run/docs/getting-started/quickstart/)
|
|
17
19
|
|
|
18
20
|
---
|
package/dist/bin.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
scaffold
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-QVLVAHZC.js";
|
|
5
5
|
|
|
6
6
|
// src/bin.ts
|
|
7
7
|
import { relative } from "path";
|
|
@@ -20,11 +20,16 @@ try {
|
|
|
20
20
|
...values.template ? { template: values.template } : {},
|
|
21
21
|
...values.ref ? { ref: values.ref } : {}
|
|
22
22
|
});
|
|
23
|
+
const cd = relative(process.cwd(), dir);
|
|
23
24
|
console.log(`
|
|
24
25
|
Next:
|
|
25
|
-
cd ${
|
|
26
|
-
npm install
|
|
27
|
-
npx actuate dev
|
|
26
|
+
${cd ? ` cd ${cd}
|
|
27
|
+
` : ""} npm install
|
|
28
|
+
npx actuate dev run it locally, with the platform's guards
|
|
29
|
+
npx actuate test run its tests
|
|
30
|
+
npx actuate doctor check Node, providers and login
|
|
31
|
+
|
|
32
|
+
Docs: https://actuate.run/docs/getting-started/quickstart/
|
|
28
33
|
`);
|
|
29
34
|
} catch (err) {
|
|
30
35
|
console.error(err instanceof Error ? err.message : err);
|
|
@@ -42,14 +42,67 @@ export default defineActuator({
|
|
|
42
42
|
},
|
|
43
43
|
});
|
|
44
44
|
`;
|
|
45
|
+
var HELLO_TEST = `import { test } from "node:test";
|
|
46
|
+
import assert from "node:assert/strict";
|
|
47
|
+
import { testActuator } from "@actuate/cli/testing";
|
|
48
|
+
import actuator from "./actuator.js";
|
|
49
|
+
|
|
50
|
+
test("greets, sleeps, then follows up", async () => {
|
|
51
|
+
const t = testActuator(actuator);
|
|
52
|
+
const run = await t.start({ name: "Aina" });
|
|
53
|
+
assert.equal(run.status, "WAITING"); // asleep until the follow-up
|
|
54
|
+
|
|
55
|
+
await t.advance("10 seconds"); // the test clock: no real waiting
|
|
56
|
+
assert.equal(t.run(run.runId).status, "COMPLETED");
|
|
57
|
+
assert.deepEqual(t.rows("greetings").map((r) => r.name), ["Aina"]);
|
|
58
|
+
assert.deepEqual(t.logs(run.runId).map((l) => l.message), ["Hello, Aina!", "Still there, Aina?"]);
|
|
59
|
+
// A budget: fails if a change makes this run cost more passes or rows.
|
|
60
|
+
assert.deepEqual(t.usage(run.runId).passes, 2);
|
|
61
|
+
assert.ok(t.usage(run.runId).rowsWritten <= 20);
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
test("refuses an empty name before any code runs", async () => {
|
|
65
|
+
const t = testActuator(actuator);
|
|
66
|
+
await assert.rejects(t.start({ name: "" }), /name/);
|
|
67
|
+
});
|
|
68
|
+
`;
|
|
69
|
+
var AGENTS_MD = `# Working on this actuator
|
|
70
|
+
|
|
71
|
+
This is an [Actuate](https://actuate.run) actuator: \`actuator.ts\` exports \`defineActuator({ ... })\`.
|
|
72
|
+
\`run\` is replayed from the top after every sleep, wait and retry, so every side effect
|
|
73
|
+
(provider calls, fetch, database writes, Date.now(), Math.random()) goes inside \`ctx.step.do\`.
|
|
74
|
+
|
|
75
|
+
Before you call a change done:
|
|
76
|
+
|
|
77
|
+
1. \`npx actuate check --platform\`: replay safety, plus the hosted platform's deploy checks.
|
|
78
|
+
2. \`npx actuate test\`: the tests (\`*.test.ts\`, written with \`@actuate/cli/testing\`). Add one
|
|
79
|
+
for each behaviour you change; pin passes and rows written with \`t.usage(runId)\`.
|
|
80
|
+
3. \`npx actuate dev\`, then \`npx actuate run '{...}' --local\` and \`npx actuate logs <runId> --local\`
|
|
81
|
+
to try it by hand. Local runs get the platform's guards and show rows read and written.
|
|
82
|
+
4. \`npx actuate deploy --dry-run\`, and only then \`npx actuate deploy\`: every deploy attempt
|
|
83
|
+
counts against the monthly deploy budget, failed ones included.
|
|
84
|
+
|
|
85
|
+
Mark API keys and tokens in the config schema with \`secret(z.string())\` and set their values in the
|
|
86
|
+
dashboard (Config tab), not in \`actuate.config.json\`, which is committed. For \`actuate dev\`, put them
|
|
87
|
+
in \`.dev.vars\` (git-ignored) as \`ACTUATE_CONFIG={"apiKey":"..."}\`; it is merged over the file.
|
|
88
|
+
|
|
89
|
+
\`npx actuate <command> --help\` explains each command; \`--json\` gives machine-readable output.
|
|
90
|
+
Guide: https://actuate.run/docs/guides/best-practices/
|
|
91
|
+
`;
|
|
45
92
|
function scaffoldFiles(name, actuatorSource, extra = {}) {
|
|
46
93
|
const pkg = {
|
|
47
94
|
name,
|
|
48
95
|
private: true,
|
|
49
96
|
type: "module",
|
|
50
|
-
scripts: {
|
|
97
|
+
scripts: {
|
|
98
|
+
dev: "actuate dev",
|
|
99
|
+
test: "actuate test",
|
|
100
|
+
check: "actuate check --platform",
|
|
101
|
+
deploy: "actuate deploy",
|
|
102
|
+
typecheck: "tsc --noEmit"
|
|
103
|
+
},
|
|
51
104
|
dependencies: { "@actuate/sdk": SDK_VERSION },
|
|
52
|
-
devDependencies: { "@actuate/cli": SDK_VERSION, typescript: "^5.9.3" }
|
|
105
|
+
devDependencies: { "@actuate/cli": SDK_VERSION, "@types/node": "^22.10.0", typescript: "^5.9.3" }
|
|
53
106
|
};
|
|
54
107
|
return {
|
|
55
108
|
"package.json": JSON.stringify(pkg, null, 2) + "\n",
|
|
@@ -71,6 +124,7 @@ function scaffoldFiles(name, actuatorSource, extra = {}) {
|
|
|
71
124
|
) + "\n",
|
|
72
125
|
".gitignore": "node_modules/\n.actuate/\n.dev.vars\n.env\n",
|
|
73
126
|
"actuate.config.json": "{}\n",
|
|
127
|
+
"AGENTS.md": AGENTS_MD,
|
|
74
128
|
"actuator.ts": actuatorSource,
|
|
75
129
|
...extra
|
|
76
130
|
};
|
|
@@ -86,7 +140,7 @@ async function fetchTemplate(template, ref, doFetch) {
|
|
|
86
140
|
throw new Error(`Template "${template}" not found in ${TEMPLATES_REPO}@${ref} (HTTP ${res.status}). Templates: https://github.com/${TEMPLATES_REPO}`);
|
|
87
141
|
}
|
|
88
142
|
const files = { "actuator.ts": await res.text() };
|
|
89
|
-
for (const optional of ["README.md", ".env.example", "actuate.config.json"]) {
|
|
143
|
+
for (const optional of ["README.md", ".env.example", "actuate.config.json", "actuator.test.ts"]) {
|
|
90
144
|
const r = await doFetch(raw(optional));
|
|
91
145
|
if (r.ok) files[optional] = await r.text();
|
|
92
146
|
}
|
|
@@ -101,7 +155,7 @@ async function scaffold(options) {
|
|
|
101
155
|
const template = options.template ?? "hello";
|
|
102
156
|
let files;
|
|
103
157
|
if (template === "hello") {
|
|
104
|
-
files = scaffoldFiles(basename(dir), HELLO_ACTUATOR);
|
|
158
|
+
files = scaffoldFiles(basename(dir), HELLO_ACTUATOR, { "actuator.test.ts": HELLO_TEST });
|
|
105
159
|
} else {
|
|
106
160
|
const fetched = await fetchTemplate(template, options.ref ?? "main", options.fetch ?? fetch);
|
|
107
161
|
const { "actuator.ts": source, ...rest } = fetched;
|
|
@@ -117,6 +171,8 @@ export {
|
|
|
117
171
|
TEMPLATES_REPO,
|
|
118
172
|
SDK_VERSION,
|
|
119
173
|
HELLO_ACTUATOR,
|
|
174
|
+
HELLO_TEST,
|
|
175
|
+
AGENTS_MD,
|
|
120
176
|
scaffoldFiles,
|
|
121
177
|
scaffold
|
|
122
178
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -14,8 +14,12 @@ interface ScaffoldOptions {
|
|
|
14
14
|
log?: (line: string) => void;
|
|
15
15
|
}
|
|
16
16
|
declare const HELLO_ACTUATOR = "import { defineActuator, z } from \"@actuate/sdk\";\n\nexport const ConfigSchema = z.object({\n greeting: z.string().default(\"Hello\"),\n followUpAfter: z.enum([\"10 seconds\", \"1 hour\", \"1 day\"]).default(\"10 seconds\"),\n});\n\nexport const InputSchema = z.object({\n name: z.string().min(1).describe(\"Who to greet\"),\n});\n\nexport default defineActuator({\n name: \"hello\",\n description: \"Greets someone, waits, then follows up. A starting point for your own actuator.\",\n config: ConfigSchema,\n input: InputSchema,\n // For MCP clients: this tool adds a row and sends nothing outside, so it isn't destructive.\n hints: { destructive: false, openWorld: false },\n async run(ctx, input, config) {\n await ctx.db.migrate([\n \"CREATE TABLE greetings (run_id TEXT PRIMARY KEY, name TEXT NOT NULL, greeted_at TEXT NOT NULL)\",\n ]);\n\n const greetedAt = await ctx.step.do(\"greet\", async () => {\n const at = new Date().toISOString();\n await ctx.db.sql`INSERT INTO greetings (run_id, name, greeted_at) VALUES (${ctx.runId}, ${input.name}, ${at})`;\n ctx.log.info(`${config.greeting}, ${input.name}!`);\n return at;\n });\n\n // The run hibernates here. Nothing runs, and nothing is billed, until it wakes.\n await ctx.step.sleep(config.followUpAfter);\n\n await ctx.step.do(\"follow-up\", () => ctx.log.info(`Still there, ${input.name}?`));\n return { greetedAt };\n },\n});\n";
|
|
17
|
+
/** The hello starter's test: `actuate test` runs it with node:test, no other dependency needed. */
|
|
18
|
+
declare const HELLO_TEST = "import { test } from \"node:test\";\nimport assert from \"node:assert/strict\";\nimport { testActuator } from \"@actuate/cli/testing\";\nimport actuator from \"./actuator.js\";\n\ntest(\"greets, sleeps, then follows up\", async () => {\n const t = testActuator(actuator);\n const run = await t.start({ name: \"Aina\" });\n assert.equal(run.status, \"WAITING\"); // asleep until the follow-up\n\n await t.advance(\"10 seconds\"); // the test clock: no real waiting\n assert.equal(t.run(run.runId).status, \"COMPLETED\");\n assert.deepEqual(t.rows(\"greetings\").map((r) => r.name), [\"Aina\"]);\n assert.deepEqual(t.logs(run.runId).map((l) => l.message), [\"Hello, Aina!\", \"Still there, Aina?\"]);\n // A budget: fails if a change makes this run cost more passes or rows.\n assert.deepEqual(t.usage(run.runId).passes, 2);\n assert.ok(t.usage(run.runId).rowsWritten <= 20);\n});\n\ntest(\"refuses an empty name before any code runs\", async () => {\n const t = testActuator(actuator);\n await assert.rejects(t.start({ name: \"\" }), /name/);\n});\n";
|
|
19
|
+
/** For coding agents (and people): the commands that check an actuator before it is deployed. */
|
|
20
|
+
declare const AGENTS_MD = "# Working on this actuator\n\nThis is an [Actuate](https://actuate.run) actuator: `actuator.ts` exports `defineActuator({ ... })`.\n`run` is replayed from the top after every sleep, wait and retry, so every side effect\n(provider calls, fetch, database writes, Date.now(), Math.random()) goes inside `ctx.step.do`.\n\nBefore you call a change done:\n\n1. `npx actuate check --platform`: replay safety, plus the hosted platform's deploy checks.\n2. `npx actuate test`: the tests (`*.test.ts`, written with `@actuate/cli/testing`). Add one\n for each behaviour you change; pin passes and rows written with `t.usage(runId)`.\n3. `npx actuate dev`, then `npx actuate run '{...}' --local` and `npx actuate logs <runId> --local`\n to try it by hand. Local runs get the platform's guards and show rows read and written.\n4. `npx actuate deploy --dry-run`, and only then `npx actuate deploy`: every deploy attempt\n counts against the monthly deploy budget, failed ones included.\n\nMark API keys and tokens in the config schema with `secret(z.string())` and set their values in the\ndashboard (Config tab), not in `actuate.config.json`, which is committed. For `actuate dev`, put them\nin `.dev.vars` (git-ignored) as `ACTUATE_CONFIG={\"apiKey\":\"...\"}`; it is merged over the file.\n\n`npx actuate <command> --help` explains each command; `--json` gives machine-readable output.\nGuide: https://actuate.run/docs/guides/best-practices/\n";
|
|
17
21
|
declare function scaffoldFiles(name: string, actuatorSource: string, extra?: Record<string, string>): Record<string, string>;
|
|
18
22
|
/** Create a new actuator project. Returns the absolute directory. */
|
|
19
23
|
declare function scaffold(options: ScaffoldOptions): Promise<string>;
|
|
20
24
|
|
|
21
|
-
export { HELLO_ACTUATOR, SDK_VERSION, type ScaffoldOptions, TEMPLATES_REPO, scaffold, scaffoldFiles };
|
|
25
|
+
export { AGENTS_MD, HELLO_ACTUATOR, HELLO_TEST, SDK_VERSION, type ScaffoldOptions, TEMPLATES_REPO, scaffold, scaffoldFiles };
|
package/dist/index.js
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
import {
|
|
2
|
+
AGENTS_MD,
|
|
2
3
|
HELLO_ACTUATOR,
|
|
4
|
+
HELLO_TEST,
|
|
3
5
|
SDK_VERSION,
|
|
4
6
|
TEMPLATES_REPO,
|
|
5
7
|
scaffold,
|
|
6
8
|
scaffoldFiles
|
|
7
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-QVLVAHZC.js";
|
|
8
10
|
export {
|
|
11
|
+
AGENTS_MD,
|
|
9
12
|
HELLO_ACTUATOR,
|
|
13
|
+
HELLO_TEST,
|
|
10
14
|
SDK_VERSION,
|
|
11
15
|
TEMPLATES_REPO,
|
|
12
16
|
scaffold,
|