7434047aae
- workflow-utils, workflow-meta: import workflow types from @uncaged/workflow - adapter-cursor, adapter-hermes: same - cli: same - core: remove workflow re-exports, no longer depends on @uncaged/workflow Phase 5+6 of #320, Testing: #323
60 lines
2.1 KiB
TypeScript
60 lines
2.1 KiB
TypeScript
import type { AgentFn, Role, ThreadContext } from "@uncaged/workflow";
|
|
import type { LlmExtractorConfig } from "@uncaged/nerve-workflow-utils";
|
|
import { createRole } from "@uncaged/nerve-workflow-utils";
|
|
import { z } from "zod";
|
|
|
|
export const testerMetaSchema = z.object({
|
|
passed: z.boolean().describe("true if all e2e checks passed"),
|
|
});
|
|
export type TesterMeta = z.infer<typeof testerMetaSchema>;
|
|
|
|
export function testerPrompt({
|
|
threadId,
|
|
nerveRoot,
|
|
}: { threadId: string; nerveRoot: string }): string {
|
|
return `You are testing a newly created Nerve sense end-to-end.
|
|
|
|
**IMPORTANT: The Nerve workspace is at \`${nerveRoot}\`. All paths below are relative to this directory. Always \`cd ${nerveRoot}\` first.**
|
|
|
|
Read the workflow thread for context: \`nerve thread ${threadId}\`
|
|
Read \`cat ${nerveRoot}/AGENT.md\`, then \`${nerveRoot}/CONVENTIONS.md\` and \`${nerveRoot}/.knowledge/sense.md\` if they exist.
|
|
|
|
Verify the full lifecycle in this order:
|
|
|
|
1. **File check** — all required sense files exist (no per-sense \`package.json\`):
|
|
- \`senses/<name>/src/index.ts\`
|
|
- \`senses/<name>/src/schema.ts\`
|
|
- \`senses/<name>/migrations/\`
|
|
|
|
2. **Build** — from the workspace root:
|
|
\`\`\`
|
|
cd ${nerveRoot} && pnpm run build
|
|
\`\`\`
|
|
(or \`npm run build\` per root \`package.json\`.) Must produce \`${nerveRoot}/dist/senses/<name>/index.js\` without errors.
|
|
|
|
3. **Config check** — \`nerve validate\` passes, confirming nerve.yaml is valid.
|
|
|
|
4. **Sense list** — \`nerve sense list\` shows the sense.
|
|
|
|
5. **Trigger** — \`nerve sense trigger <name>\` completes without error.
|
|
|
|
6. **Query** — \`nerve sense query <name>\` — retry up to 20s until rows appear.
|
|
|
|
If any step fails, include the relevant error output.
|
|
|
|
Output a clear summary: what you checked, what passed, what failed, and why.`;
|
|
}
|
|
|
|
export function createTesterRole(
|
|
adapter: AgentFn,
|
|
extract: LlmExtractorConfig,
|
|
nerveRoot: string,
|
|
): Role<TesterMeta> {
|
|
return createRole(
|
|
adapter,
|
|
async (ctx: ThreadContext) => testerPrompt({ threadId: ctx.threadId, nerveRoot }),
|
|
testerMetaSchema,
|
|
extract,
|
|
);
|
|
}
|