Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

DevinSkillDispatch.test.ts

89 lines3.4 KB

1import { describe, expect, it } from "vite-plus/test";
2​
3import { planDevinSkillDispatch } from "./DevinSkillDispatch.ts";
4​
5const SKILLS = new Set(["2spec", "deploy", "implement", "review", "re-release-version"]);
6​
7describe("planDevinSkillDispatch", () => {
8 it("leaves a prompt without a known skill untouched", () => {
9 expect(planDevinSkillDispatch("fix the build", SKILLS)).toBeUndefined();
10 // Not a discovered skill, so it stays prose rather than becoming an invocation.
11 expect(planDevinSkillDispatch("echo $HOME then $unknown", SKILLS)).toBeUndefined();
12 });
13​
14 it("rewrites a known token into Devin's native mention", () => {
15 expect(planDevinSkillDispatch("$deploy", SKILLS)).toEqual({
16 prompt: "@skills:deploy",
17 skillName: "deploy",
18 });
19 });
20​
21 it("preserves trailing arguments after the token", () => {
22 expect(planDevinSkillDispatch("$deploy staging", SKILLS)).toEqual({
23 prompt: "@skills:deploy staging",
24 skillName: "deploy",
25 });
26 });
27​
28 it("preserves surrounding text around a mid-prompt mention", () => {
29 expect(planDevinSkillDispatch("ok, now $deploy all the tickets", SKILLS)).toEqual({
30 prompt: "ok, now @skills:deploy all the tickets",
31 skillName: "deploy",
32 });
33 });
34​
35 it("preserves a mention that opens the prompt", () => {
36 expect(planDevinSkillDispatch("$review\nfocus on auth", SKILLS)).toEqual({
37 prompt: "@skills:review\nfocus on auth",
38 skillName: "review",
39 });
40 });
41​
42 it("rewrites multiple mentions and keeps the last name for diagnostics", () => {
43 expect(planDevinSkillDispatch("$review the diff, then $deploy the fixes", SKILLS)).toEqual({
44 prompt: "@skills:review the diff, then @skills:deploy the fixes",
45 skillName: "deploy",
46 });
47 });
48​
49 it("preserves unknown tokens and $HOME", () => {
50 expect(planDevinSkillDispatch("echo $HOME then $deploy", SKILLS)).toEqual({
51 prompt: "echo $HOME then @skills:deploy",
52 skillName: "deploy",
53 });
54 expect(planDevinSkillDispatch("echo $HOME", SKILLS)).toBeUndefined();
55 expect(planDevinSkillDispatch("echo $unknown then $deploy", SKILLS)).toEqual({
56 prompt: "echo $unknown then @skills:deploy",
57 skillName: "deploy",
58 });
59 });
60​
61 it("does not infer a skill from a path-like token", () => {
62 // A filesystem path is never a skill mention, even when a segment matches.
63 expect(planDevinSkillDispatch("check src/$deploy/config.ts", SKILLS)).toBeUndefined();
64 });
65​
66 it("ignores a dollar token glued to other text", () => {
67 expect(planDevinSkillDispatch("cost is 5$deploy", SKILLS)).toBeUndefined();
68 });
69​
70 it("ignores currency amounts and compact monetary expressions", () => {
71 const skillsWithCurrency = new Set([...SKILLS, "20", "20k", "100M"]);
72 expect(planDevinSkillDispatch("pay $20 tomorrow", skillsWithCurrency)).toBeUndefined();
73 expect(planDevinSkillDispatch("budget is $20k tomorrow", skillsWithCurrency)).toBeUndefined();
74 });
75​
76 it("dispatches a known skill whose name begins with a digit", () => {
77 expect(planDevinSkillDispatch("use $2spec for this", SKILLS)).toEqual({
78 prompt: "use @skills:2spec for this",
79 skillName: "2spec",
80 });
81 });
82​
83 it("dispatches a hyphenated skill name", () => {
84 expect(planDevinSkillDispatch("run $re-release-version now", SKILLS)).toEqual({
85 prompt: "run @skills:re-release-version now",
86 skillName: "re-release-version",
87 });
88 });
89});