@pmelab/gtd 59.0.0 → 60.0.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/.claude-plugin/plugin.json +1 -1
- package/README.md +42 -38
- package/claude/hooks/doors.ts +8 -4
- package/dist/chunks/flows-DENt0uWV.mjs +707 -0
- package/dist/chunks/{steering-CCNvngSH.mjs → steering-DF_BMadH.mjs} +292 -289
- package/dist/chunks/{testkit-CMBAAyRK.mjs → testkit-BvecVjQ0.mjs} +937 -772
- package/dist/chunks/{wire-C12dahrH.mjs → wire-DZ8R1RU9.mjs} +9 -2
- package/dist/flows.mjs +2 -676
- package/dist/gtd.bundle.mjs +1101 -1025
- package/dist/steering.mjs +2 -2
- package/dist/testkit/gherkin.mjs +371 -82
- package/dist/testkit.mjs +3 -2
- package/dist/web/main.js +234 -232
- package/dist/wire.mjs +2 -2
- package/dist/workflow-kit.mjs +3 -3
- package/package.json +1 -1
- package/skills/authoring/SKILL.md +68 -61
- package/src/cli/Cli.test.ts +311 -229
- package/src/cli/Cli.ts +486 -585
- package/src/cli/Help.test.ts +47 -0
- package/src/cli/Help.ts +70 -0
- package/src/cli/History.ts +9 -4
- package/src/cli/Judges.ts +1 -1
- package/src/cli/Output.test.ts +35 -0
- package/src/cli/Output.ts +31 -1
- package/src/cli/Program.test.ts +131 -82
- package/src/cli/Program.ts +197 -111
- package/src/edge/Edge.test.ts +64 -56
- package/src/edge/Edge.ts +4 -4
- package/src/emit/Emit.test.ts +1 -1
- package/src/emit/Emit.ts +1 -1
- package/src/flows/factory.test.ts +14 -0
- package/src/flows/factory.ts +25 -6
- package/src/flows/helpers.test.ts +35 -0
- package/src/flows/helpers.ts +19 -10
- package/src/flows/index.test.ts +66 -0
- package/src/flows/index.ts +109 -5
- package/src/flows/internal.ts +7 -0
- package/src/flows/runtime.test.ts +192 -1
- package/src/flows/runtime.ts +188 -54
- package/src/gherkin/git-control.feature +6 -6
- package/src/gherkin/index.test.ts +127 -0
- package/src/gherkin/index.ts +481 -98
- package/src/gherkin/messages.test.ts +124 -0
- package/src/gherkin/messages.ts +101 -0
- package/src/gherkin/more-steps.feature +170 -0
- package/src/gherkin/scenario-end.feature +101 -0
- package/src/gherkin/testkit.feature +83 -7
- package/src/install/Install.test.ts +7 -7
- package/src/install/Install.ts +8 -8
- package/src/replay/Replay.test.ts +13 -2
- package/src/replay/Replay.ts +19 -30
- package/src/replay/judgeDiffShape.test.ts +1 -1
- package/src/steering/Footnotes.test.ts +1 -1
- package/src/steering/SteeringFormats.test.ts +1 -1
- package/src/steering/freeform.test.ts +1 -1
- package/src/steering/index.test.ts +27 -1
- package/src/steering/index.ts +6 -104
- package/src/steering/internal.ts +11 -0
- package/src/steering/qa.test.ts +7 -2
- package/src/steering/reads.test.ts +42 -0
- package/src/steering/reads.ts +43 -0
- package/src/steering/registry.ts +93 -0
- package/src/steering/review.test.ts +2 -2
- package/src/step/planStart.test.ts +18 -16
- package/src/step/planStart.ts +9 -9
- package/src/testkit/TestRepo.test.ts +289 -6
- package/src/testkit/TestRepo.ts +317 -41
- package/src/testkit/imports.test.ts +58 -0
- package/src/testkit/imports.ts +102 -0
- package/src/testkit/index.test.ts +28 -0
- package/src/testkit/index.ts +14 -2
- package/src/twins/EmittedScriptRecognizer.ts +7 -14
- package/src/twins/EmittedScripts.test.ts +4 -2
- package/src/twins/InMemRepo.ts +1 -0
- package/src/wire/Land.ts +1 -1
- package/src/wire/Script.ts +11 -0
- package/src/wire/WireSchema.test.ts +3 -0
- package/src/wire/golden/1/script.json +4 -0
- package/src/wire/index.ts +1 -0
- package/src/workflow/SteeringFormats.test.ts +1 -1
- package/src/workflow/compile.ts +2 -2
- package/src/workflow/discovery.test.ts +3 -3
- package/src/workflow/load.test.ts +256 -116
- package/src/workflow/load.ts +175 -152
- package/src/workflow/skills.test.ts +5 -5
- package/src/workflow/skills.ts +1 -1
- package/src/workflow-kit/index.test.ts +25 -0
- package/src/workflow-kit/index.ts +37 -4
- package/src/workflow-kit/review.ts +2 -2
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest"
|
|
2
|
+
import { agent, human, workflow } from "../flows/index.js"
|
|
3
|
+
import { testRepo } from "../testkit/index.js"
|
|
4
|
+
import {
|
|
5
|
+
assertContains,
|
|
6
|
+
assertLacks,
|
|
7
|
+
assertRestsAt,
|
|
8
|
+
refusedWith,
|
|
9
|
+
restDescription,
|
|
10
|
+
} from "./messages.js"
|
|
11
|
+
|
|
12
|
+
const flow = async (): Promise<void> => {
|
|
13
|
+
await agent("plan", "Write PLAN.md.\nKeep it short.\n3\n4\n5\n6\n7")
|
|
14
|
+
await human("sign-off")
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const thrown = async (fn: () => unknown): Promise<string> => {
|
|
18
|
+
try {
|
|
19
|
+
await fn()
|
|
20
|
+
} catch (error) {
|
|
21
|
+
return (error as Error).message
|
|
22
|
+
}
|
|
23
|
+
throw new Error("did not throw")
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
describe("restDescription", () => {
|
|
27
|
+
it("names the step, its kind and actor, the content's head, the last commits and the unused actors", async () => {
|
|
28
|
+
const repo = testRepo({ workflow: { default: flow } })
|
|
29
|
+
repo.write("go", "\n")
|
|
30
|
+
await repo.drive({ plan: (_, r) => r.write("PLAN.md", "p\n") })
|
|
31
|
+
expect(
|
|
32
|
+
await restDescription(
|
|
33
|
+
() => repo,
|
|
34
|
+
[
|
|
35
|
+
{ step: "repair", origin: "scenario" },
|
|
36
|
+
{ step: "ready", origin: "Background" },
|
|
37
|
+
],
|
|
38
|
+
),
|
|
39
|
+
).toBe(
|
|
40
|
+
[
|
|
41
|
+
"where the process rests:",
|
|
42
|
+
' step "sign-off" (message, human)',
|
|
43
|
+
" content:",
|
|
44
|
+
" | sign-off",
|
|
45
|
+
" last commits:",
|
|
46
|
+
" chore: initial commit",
|
|
47
|
+
" gtd(agent): plan → sign-off",
|
|
48
|
+
' actors never used: "repair" (scenario), "ready" (Background)',
|
|
49
|
+
].join("\n"),
|
|
50
|
+
)
|
|
51
|
+
})
|
|
52
|
+
|
|
53
|
+
it("cuts long content to its first lines", async () => {
|
|
54
|
+
const repo = testRepo({ workflow: { default: flow } })
|
|
55
|
+
repo.write("go", "\n")
|
|
56
|
+
const description = await restDescription(() => repo, [])
|
|
57
|
+
expect(description).toContain('step "plan" (prompt, agent)')
|
|
58
|
+
expect(description).toContain(" | 5\n | … 2 more lines")
|
|
59
|
+
expect(description).not.toContain("actors never used")
|
|
60
|
+
})
|
|
61
|
+
|
|
62
|
+
it("says why the rest is unknown instead of throwing", async () => {
|
|
63
|
+
const description = await restDescription(() => {
|
|
64
|
+
throw new Error("no gtd config")
|
|
65
|
+
}, [])
|
|
66
|
+
expect(description).toBe("where the process rests:\n unknown — no gtd config")
|
|
67
|
+
})
|
|
68
|
+
})
|
|
69
|
+
|
|
70
|
+
describe("refusedWith", () => {
|
|
71
|
+
it("says nothing was refused when the attempt succeeds", async () => {
|
|
72
|
+
expect(await thrown(() => refusedWith(Promise.resolve(), "nope"))).toBe(
|
|
73
|
+
'expected a refusal with "nope", but nothing was refused',
|
|
74
|
+
)
|
|
75
|
+
})
|
|
76
|
+
|
|
77
|
+
it("prints the refusal it got when the text is missing", async () => {
|
|
78
|
+
expect(await thrown(() => refusedWith(Promise.reject(new Error("other")), "nope"))).toBe(
|
|
79
|
+
'expected a refusal with "nope", but it was refused with:\nother',
|
|
80
|
+
)
|
|
81
|
+
})
|
|
82
|
+
|
|
83
|
+
it("passes on a refusal carrying the text", async () => {
|
|
84
|
+
await refusedWith(Promise.reject(new Error("a nope b")), "nope")
|
|
85
|
+
})
|
|
86
|
+
})
|
|
87
|
+
|
|
88
|
+
describe("contains", () => {
|
|
89
|
+
it("prints the text looked for and what was there", async () => {
|
|
90
|
+
expect(await thrown(() => assertContains('"a.md"', "x", "y\n"))).toBe(
|
|
91
|
+
'"a.md" does not contain "x"; it holds:\ny\n',
|
|
92
|
+
)
|
|
93
|
+
expect(await thrown(() => assertLacks('"a.md"', "y", "y\n"))).toBe(
|
|
94
|
+
'"a.md" contains "y"; it holds:\ny\n',
|
|
95
|
+
)
|
|
96
|
+
})
|
|
97
|
+
|
|
98
|
+
it("says a missing file does not exist", async () => {
|
|
99
|
+
expect(await thrown(() => assertContains('"a.md"', "x", undefined))).toBe(
|
|
100
|
+
'"a.md" does not exist, so it cannot contain "x"',
|
|
101
|
+
)
|
|
102
|
+
expect(await thrown(() => assertLacks('"a.md"', "x", undefined))).toBe('"a.md" does not exist')
|
|
103
|
+
})
|
|
104
|
+
})
|
|
105
|
+
|
|
106
|
+
describe("assertRestsAt", () => {
|
|
107
|
+
it("fails on a stall at the step, pointing to the stall assertion", async () => {
|
|
108
|
+
const repo = testRepo({ workflow: { default: flow, flow: workflow(flow) } })
|
|
109
|
+
await repo.start("flow")
|
|
110
|
+
const stall = await repo.drive({ plan: () => undefined })
|
|
111
|
+
expect(stall.kind).toBe("stalled")
|
|
112
|
+
expect(await thrown(() => assertRestsAt(stall, "plan"))).toBe(
|
|
113
|
+
'expected a rest at "plan", but the process stalls at "plan" — assert a stall with: the process stalls at "plan"',
|
|
114
|
+
)
|
|
115
|
+
})
|
|
116
|
+
|
|
117
|
+
it("passes at a rest at the step, and fails at another", async () => {
|
|
118
|
+
const repo = testRepo({ workflow: { default: flow } })
|
|
119
|
+
repo.write("go", "\n")
|
|
120
|
+
const rest = await repo.drive({ plan: (_, r) => r.write("PLAN.md", "p\n") })
|
|
121
|
+
assertRestsAt(rest, "sign-off")
|
|
122
|
+
expect(await thrown(() => assertRestsAt(rest, "plan"))).toContain("sign-off")
|
|
123
|
+
})
|
|
124
|
+
})
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import assert from "node:assert"
|
|
2
|
+
import type { BeatDocument, TestRepo } from "../testkit/index.js"
|
|
3
|
+
|
|
4
|
+
const CONTENT_LINES = 5
|
|
5
|
+
const SUBJECTS = 5
|
|
6
|
+
|
|
7
|
+
const reason = (error: unknown): string => (error instanceof Error ? error.message : String(error))
|
|
8
|
+
|
|
9
|
+
const beatLines = async (repo: TestRepo): Promise<string[]> => {
|
|
10
|
+
try {
|
|
11
|
+
const beat = await repo.next()
|
|
12
|
+
const content = beat.content.trimEnd().split("\n")
|
|
13
|
+
const more = content.length - CONTENT_LINES
|
|
14
|
+
return [
|
|
15
|
+
`step "${beat.state}" (${beat.kind}, ${beat.actor}${beat.idle ? ", idle" : ""})`,
|
|
16
|
+
"content:",
|
|
17
|
+
...content.slice(0, CONTENT_LINES).map((line) => ` | ${line}`),
|
|
18
|
+
...(more > 0 ? [` | … ${more} more lines`] : []),
|
|
19
|
+
]
|
|
20
|
+
} catch (error) {
|
|
21
|
+
return [`unknown — gtd next failed: ${reason(error)}`]
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/** A scripted step no drive reached, and whether a Background or the scenario scripted it. */
|
|
26
|
+
export interface Unreached {
|
|
27
|
+
readonly step: string
|
|
28
|
+
readonly origin: "Background" | "scenario"
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export const unreachedList = (steps: readonly Unreached[]): string =>
|
|
32
|
+
steps.map(({ step, origin }) => `"${step}" (${origin})`).join(", ")
|
|
33
|
+
|
|
34
|
+
/** Where the process rests, for a failed outcome to end with. Never throws: it describes a failure. */
|
|
35
|
+
export const restDescription = async (
|
|
36
|
+
repo: () => TestRepo,
|
|
37
|
+
neverUsed: readonly Unreached[],
|
|
38
|
+
): Promise<string> => {
|
|
39
|
+
let lines: string[]
|
|
40
|
+
try {
|
|
41
|
+
const r = repo()
|
|
42
|
+
lines = [
|
|
43
|
+
...(await beatLines(r)),
|
|
44
|
+
"last commits:",
|
|
45
|
+
...r
|
|
46
|
+
.subjects()
|
|
47
|
+
.slice(-SUBJECTS)
|
|
48
|
+
.map((subject) => ` ${subject}`),
|
|
49
|
+
]
|
|
50
|
+
} catch (error) {
|
|
51
|
+
lines = [`unknown — ${reason(error)}`]
|
|
52
|
+
}
|
|
53
|
+
if (neverUsed.length > 0) lines.push(`actors never used: ${unreachedList(neverUsed)}`)
|
|
54
|
+
return ["where the process rests:", ...lines.map((line) => ` ${line}`)].join("\n")
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/** Both sides of a failed `contains`: the text looked for, and what was there. */
|
|
58
|
+
const containsFailure = (
|
|
59
|
+
where: string,
|
|
60
|
+
text: string,
|
|
61
|
+
content: string | undefined,
|
|
62
|
+
expected: boolean,
|
|
63
|
+
): string =>
|
|
64
|
+
content === undefined
|
|
65
|
+
? `${where} does not exist${expected ? `, so it cannot contain "${text}"` : ""}`
|
|
66
|
+
: `${where} ${expected ? "does not contain" : "contains"} "${text}"; it holds:\n${content}`
|
|
67
|
+
|
|
68
|
+
/** What `attempt` was refused with; fails when it was not refused at all. */
|
|
69
|
+
export const refusal = async (attempt: Promise<unknown>, expectation: string): Promise<string> => {
|
|
70
|
+
try {
|
|
71
|
+
await attempt
|
|
72
|
+
} catch (error) {
|
|
73
|
+
return error instanceof Error ? error.message : String(error)
|
|
74
|
+
}
|
|
75
|
+
assert.fail(`expected a refusal ${expectation}, but nothing was refused`)
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export const refusedWith = async (attempt: Promise<unknown>, message: string): Promise<void> => {
|
|
79
|
+
const got = await refusal(attempt, `with "${message}"`)
|
|
80
|
+
if (!got.includes(message))
|
|
81
|
+
assert.fail(`expected a refusal with "${message}", but it was refused with:\n${got}`)
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export const assertContains = (where: string, text: string, content: string | undefined): void => {
|
|
85
|
+
if (content === undefined || !content.includes(text))
|
|
86
|
+
assert.fail(containsFailure(where, text, content, true))
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export const assertLacks = (where: string, text: string, content: string | undefined): void => {
|
|
90
|
+
if (content === undefined || content.includes(text))
|
|
91
|
+
assert.fail(containsFailure(where, text, content, false))
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/** A rest at `step`; a stall there is no rest, so it points to the step that asserts one. */
|
|
95
|
+
export const assertRestsAt = (beat: BeatDocument, step: string): void => {
|
|
96
|
+
if (beat.kind === "stalled")
|
|
97
|
+
assert.fail(
|
|
98
|
+
`expected a rest at "${step}", but the process stalls at "${beat.state}" — assert a stall with: the process stalls at "${beat.state}"`,
|
|
99
|
+
)
|
|
100
|
+
assert.strictEqual(beat.state, step)
|
|
101
|
+
}
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
@inmem
|
|
2
|
+
Feature: steps for checks, stalls, beat fields, commit bodies and the environment
|
|
3
|
+
|
|
4
|
+
Background:
|
|
5
|
+
Given a gtd config with:
|
|
6
|
+
"""
|
|
7
|
+
import { agent, check, envSettings, human, scope, settings, workflow } from "@pmelab/gtd/flows"
|
|
8
|
+
|
|
9
|
+
const defaults = { title: "untitled" }
|
|
10
|
+
const envDefaults = { greeting: "hi" }
|
|
11
|
+
|
|
12
|
+
export const tested = workflow(async () => {
|
|
13
|
+
await scope({ name: "build", skills: ["tdd", "review"] }, async () => {
|
|
14
|
+
await agent("plan", "Plan.", { model: "smart" })
|
|
15
|
+
})
|
|
16
|
+
const green = await check("test", "npm test", ".gtd/FEEDBACK.md")
|
|
17
|
+
await agent(green ? "ship" : "repair", `Say ${envSettings.greeting} to ${settings.title}.`)
|
|
18
|
+
await human("done")
|
|
19
|
+
}, { defaults, envDefaults })
|
|
20
|
+
|
|
21
|
+
export default tested
|
|
22
|
+
"""
|
|
23
|
+
|
|
24
|
+
Scenario: the resting step's fields are read by name
|
|
25
|
+
When gtd starts workflow "tested"
|
|
26
|
+
Then the process rests at "build.plan"
|
|
27
|
+
And the resting step's model is "smart"
|
|
28
|
+
And the resting step's idle is "false"
|
|
29
|
+
And the resting step's skills includes "review"
|
|
30
|
+
And the resting step's content includes "Plan"
|
|
31
|
+
|
|
32
|
+
Scenario: a quoted argument keeps its spaces
|
|
33
|
+
Given step "build.plan" writes "PLAN.md" with:
|
|
34
|
+
"""
|
|
35
|
+
add two numbers
|
|
36
|
+
"""
|
|
37
|
+
And check step "test" passes
|
|
38
|
+
When gtd starts workflow "tested" with "--var 'title=a calculator'"
|
|
39
|
+
And the process is driven
|
|
40
|
+
Then the resting step's content contains "Say hi to a calculator."
|
|
41
|
+
|
|
42
|
+
Scenario: an agent step that changes nothing stalls
|
|
43
|
+
Given step "build.plan" changes nothing
|
|
44
|
+
When gtd starts workflow "tested"
|
|
45
|
+
And the process is driven
|
|
46
|
+
Then the process stalls at "build.plan"
|
|
47
|
+
|
|
48
|
+
Scenario: a passing check step goes on, and a variable changed mid-process is seen from then on
|
|
49
|
+
Given step "build.plan" writes "PLAN.md" with:
|
|
50
|
+
"""
|
|
51
|
+
add two numbers
|
|
52
|
+
"""
|
|
53
|
+
And check step "test" passes
|
|
54
|
+
When gtd starts workflow "tested"
|
|
55
|
+
And the process is driven
|
|
56
|
+
Then the process rests at "ship"
|
|
57
|
+
And the resting step's content contains "Say hi to untitled."
|
|
58
|
+
Given from now on the environment variable "GTD_GREETING" is "hello"
|
|
59
|
+
Then the resting step's content contains "Say hello to untitled."
|
|
60
|
+
|
|
61
|
+
Scenario: a failing check step writes its report
|
|
62
|
+
Given the environment variable "GTD_GREETING" is "hey"
|
|
63
|
+
And step "build.plan" writes "PLAN.md" with:
|
|
64
|
+
"""
|
|
65
|
+
add two numbers
|
|
66
|
+
"""
|
|
67
|
+
And check step "test" fails with:
|
|
68
|
+
"""
|
|
69
|
+
1 test failing
|
|
70
|
+
"""
|
|
71
|
+
When gtd starts workflow "tested"
|
|
72
|
+
And the process is driven
|
|
73
|
+
Then the process rests at "repair"
|
|
74
|
+
And ".gtd/FEEDBACK.md" contains "1 test failing"
|
|
75
|
+
And the resting step's content contains "Say hey to untitled."
|
|
76
|
+
|
|
77
|
+
Scenario: a check step scripted at a step that is no check refuses the drive
|
|
78
|
+
Given check step "build.plan" passes
|
|
79
|
+
When gtd starts workflow "tested"
|
|
80
|
+
Then driving the process is refused with 'step "build.plan" is no check step; its actor is agent'
|
|
81
|
+
|
|
82
|
+
Scenario: commit bodies are read whole, every commit of a subject at once
|
|
83
|
+
Given the working tree is committed with the message:
|
|
84
|
+
"""
|
|
85
|
+
chore: seed
|
|
86
|
+
|
|
87
|
+
Seeded by hand.
|
|
88
|
+
|
|
89
|
+
Refs: #1
|
|
90
|
+
"""
|
|
91
|
+
And step "build.plan" writes "PLAN.md" with:
|
|
92
|
+
"""
|
|
93
|
+
add two numbers
|
|
94
|
+
"""
|
|
95
|
+
And check step "test" passes
|
|
96
|
+
When gtd starts workflow "tested"
|
|
97
|
+
And the process is driven
|
|
98
|
+
Then the last commit body contains "Gtd-Step: test#1"
|
|
99
|
+
And the commit "gtd(agent): build.plan → test" has a body containing "Gtd-Step: build.plan#1"
|
|
100
|
+
And the commit "chore: seed" has a body containing "Seeded by hand."
|
|
101
|
+
And no commit body contains "never written"
|
|
102
|
+
|
|
103
|
+
Scenario: a canned command matched by pattern, a branch at a ref, and a file as committed there
|
|
104
|
+
Given a file "a.txt" with:
|
|
105
|
+
"""
|
|
106
|
+
one
|
|
107
|
+
"""
|
|
108
|
+
And the working tree is committed as "chore: one"
|
|
109
|
+
And a file "a.txt" with:
|
|
110
|
+
"""
|
|
111
|
+
two
|
|
112
|
+
"""
|
|
113
|
+
And the working tree is committed as "chore: two"
|
|
114
|
+
And a branch "old" at "HEAD~1"
|
|
115
|
+
And the command matching "^npm (test|run)" exits 1 with:
|
|
116
|
+
"""
|
|
117
|
+
red
|
|
118
|
+
"""
|
|
119
|
+
And step "build.plan" writes "PLAN.md" with:
|
|
120
|
+
"""
|
|
121
|
+
add two numbers
|
|
122
|
+
"""
|
|
123
|
+
And step "test" runs its script
|
|
124
|
+
When gtd starts workflow "tested"
|
|
125
|
+
And the process is driven
|
|
126
|
+
Then the process rests at "repair"
|
|
127
|
+
And "a.txt" as committed at "old" contains "one"
|
|
128
|
+
And ".gtd/FEEDBACK.md" contains "red"
|
|
129
|
+
|
|
130
|
+
Scenario: text is appended to a file, and a step overwrites one only if it exists
|
|
131
|
+
Given a file "NOTES.md" with:
|
|
132
|
+
"""
|
|
133
|
+
first
|
|
134
|
+
"""
|
|
135
|
+
And text is appended to "NOTES.md":
|
|
136
|
+
"""
|
|
137
|
+
second
|
|
138
|
+
"""
|
|
139
|
+
And step "build.plan" overwrites "PLAN.md", if it exists, with:
|
|
140
|
+
"""
|
|
141
|
+
never written
|
|
142
|
+
"""
|
|
143
|
+
And step "build.plan" overwrites "NOTES.md", if it exists, with:
|
|
144
|
+
"""
|
|
145
|
+
rewritten
|
|
146
|
+
"""
|
|
147
|
+
And step "test" runs its script
|
|
148
|
+
And the command "npm test" exits 0
|
|
149
|
+
When gtd starts workflow "tested"
|
|
150
|
+
And the process is driven
|
|
151
|
+
Then the process rests at "ship"
|
|
152
|
+
And "NOTES.md" contains "rewritten"
|
|
153
|
+
And "PLAN.md" does not exist
|
|
154
|
+
|
|
155
|
+
Scenario: a config given as source imports a module the scenario names
|
|
156
|
+
Given the module "src/gherkin/tiny.fixture.ts" is importable as "#workflow"
|
|
157
|
+
And a gtd config with:
|
|
158
|
+
"""
|
|
159
|
+
export { tiny, tiny as default } from "#workflow"
|
|
160
|
+
"""
|
|
161
|
+
And a file "IDEA.md" with:
|
|
162
|
+
"""
|
|
163
|
+
a calculator
|
|
164
|
+
"""
|
|
165
|
+
And step "plan" writes "PLAN.md" with:
|
|
166
|
+
"""
|
|
167
|
+
add two numbers
|
|
168
|
+
"""
|
|
169
|
+
When the process is driven
|
|
170
|
+
Then the process rests at "sign-off"
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
@inmem
|
|
2
|
+
Feature: a scenario's scripted steps must be reached by its end, not by every drive
|
|
3
|
+
|
|
4
|
+
Background:
|
|
5
|
+
Given a gtd config with:
|
|
6
|
+
"""
|
|
7
|
+
import { agent, human, workflow } from "@pmelab/gtd/flows"
|
|
8
|
+
|
|
9
|
+
export const shipping = workflow(async () => {
|
|
10
|
+
await agent("plan", "Write PLAN.md.")
|
|
11
|
+
await human("sign-off")
|
|
12
|
+
await agent("ship", "Ship it.")
|
|
13
|
+
await human("done")
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
export default shipping
|
|
17
|
+
"""
|
|
18
|
+
And step "ship" writes "SHIPPED.md" with:
|
|
19
|
+
"""
|
|
20
|
+
shipped
|
|
21
|
+
"""
|
|
22
|
+
|
|
23
|
+
Scenario: an actor the Background scripts, reached only by the second drive, passes
|
|
24
|
+
Given step "plan" writes "PLAN.md" with:
|
|
25
|
+
"""
|
|
26
|
+
add two numbers
|
|
27
|
+
"""
|
|
28
|
+
When gtd starts workflow "shipping"
|
|
29
|
+
And the process is driven
|
|
30
|
+
Then the process rests at "sign-off"
|
|
31
|
+
Given step "sign-off" writes "SIGNED.md" with:
|
|
32
|
+
"""
|
|
33
|
+
signed
|
|
34
|
+
"""
|
|
35
|
+
When the process is driven
|
|
36
|
+
Then the process rests at "done"
|
|
37
|
+
And "SHIPPED.md" contains "shipped"
|
|
38
|
+
|
|
39
|
+
Scenario: an actor the Background scripts may go unreached in a scenario another scenario reaches it in
|
|
40
|
+
Given step "plan" writes "PLAN.md" with:
|
|
41
|
+
"""
|
|
42
|
+
add two numbers
|
|
43
|
+
"""
|
|
44
|
+
When gtd starts workflow "shipping"
|
|
45
|
+
And the process is driven
|
|
46
|
+
Then the process rests at "sign-off"
|
|
47
|
+
|
|
48
|
+
@fails
|
|
49
|
+
Scenario: an actor the scenario scripts that no drive reaches fails it at its end
|
|
50
|
+
Given step "plan" writes "PLAN.md" with:
|
|
51
|
+
"""
|
|
52
|
+
add two numbers
|
|
53
|
+
"""
|
|
54
|
+
And step "done" writes "DONE.md" with:
|
|
55
|
+
"""
|
|
56
|
+
done
|
|
57
|
+
"""
|
|
58
|
+
When gtd starts workflow "shipping"
|
|
59
|
+
And the process is driven
|
|
60
|
+
Then the process rests at "sign-off"
|
|
61
|
+
|
|
62
|
+
@fails
|
|
63
|
+
Scenario: a lenient drive leaves an actor no drive reaches to fail the scenario at its end
|
|
64
|
+
Given step "plan" writes "PLAN.md" with:
|
|
65
|
+
"""
|
|
66
|
+
add two numbers
|
|
67
|
+
"""
|
|
68
|
+
And step "done" writes "DONE.md" with:
|
|
69
|
+
"""
|
|
70
|
+
done
|
|
71
|
+
"""
|
|
72
|
+
When gtd starts workflow "shipping"
|
|
73
|
+
And the process is driven leniently
|
|
74
|
+
Then the process rests at "sign-off"
|
|
75
|
+
|
|
76
|
+
Scenario: a refused drive excuses the actors it was handed
|
|
77
|
+
Given step "plan" writes "PLAN.md" with:
|
|
78
|
+
"""
|
|
79
|
+
add two numbers
|
|
80
|
+
"""
|
|
81
|
+
And step "sign-off" changes nothing
|
|
82
|
+
And step "done" writes "DONE.md" with:
|
|
83
|
+
"""
|
|
84
|
+
done
|
|
85
|
+
"""
|
|
86
|
+
When gtd starts workflow "shipping"
|
|
87
|
+
Then driving the process is refused with 'the actor for human step "sign-off" changed nothing'
|
|
88
|
+
|
|
89
|
+
@fails
|
|
90
|
+
Scenario: an actor scripted after a refused drive, and reached by no later one, fails the scenario
|
|
91
|
+
Given step "plan" writes "PLAN.md" with:
|
|
92
|
+
"""
|
|
93
|
+
add two numbers
|
|
94
|
+
"""
|
|
95
|
+
And step "sign-off" changes nothing
|
|
96
|
+
When gtd starts workflow "shipping"
|
|
97
|
+
Then driving the process is refused with 'the actor for human step "sign-off" changed nothing'
|
|
98
|
+
Given step "done" writes "DONE.md" with:
|
|
99
|
+
"""
|
|
100
|
+
done
|
|
101
|
+
"""
|
|
@@ -7,9 +7,9 @@ Feature: testkit drives any workflow against the real engine
|
|
|
7
7
|
Background:
|
|
8
8
|
Given a gtd config with:
|
|
9
9
|
"""
|
|
10
|
-
import { agent, human, judge, read, refuse, run } from "@pmelab/gtd/flows"
|
|
10
|
+
import { agent, human, judge, read, refuse, run, workflow } from "@pmelab/gtd/flows"
|
|
11
11
|
|
|
12
|
-
export const tiny = async () => {
|
|
12
|
+
export const tiny = workflow(async () => {
|
|
13
13
|
await agent("plan", "Write PLAN.md.")
|
|
14
14
|
await run("check", "npm test > .gtd/FEEDBACK.md 2>&1 && rm .gtd/FEEDBACK.md")
|
|
15
15
|
if (read(".gtd/FEEDBACK.md") !== undefined) await agent("repair", "Make the suite pass.")
|
|
@@ -18,11 +18,11 @@ Feature: testkit drives any workflow against the real engine
|
|
|
18
18
|
evidence: { plan: read("PLAN.md") ?? "" },
|
|
19
19
|
})
|
|
20
20
|
await human(answers.ready?.answer === "yes" ? "ship" : "rework")
|
|
21
|
-
}
|
|
21
|
+
})
|
|
22
22
|
|
|
23
|
-
export const picky = async () => {
|
|
23
|
+
export const picky = workflow(async () => {
|
|
24
24
|
refuse("gtd: picky refuses every start")
|
|
25
|
-
}
|
|
25
|
+
})
|
|
26
26
|
|
|
27
27
|
export default tiny
|
|
28
28
|
"""
|
|
@@ -83,9 +83,12 @@ Feature: testkit drives any workflow against the real engine
|
|
|
83
83
|
And "PLAN.md" contains "add two numbers"
|
|
84
84
|
|
|
85
85
|
Scenario: a judge step with queued actions refuses the drive
|
|
86
|
-
Given step "plan"
|
|
86
|
+
Given step "plan" writes "PLAN.md" with:
|
|
87
|
+
"""
|
|
88
|
+
add two numbers
|
|
89
|
+
"""
|
|
87
90
|
And step "check" changes nothing
|
|
88
|
-
And step "ready"
|
|
91
|
+
And step "ready" changes nothing
|
|
89
92
|
And judge step "ready" answers:
|
|
90
93
|
"""
|
|
91
94
|
[{ "id": "ready", "answer": true, "p": 0.9 }]
|
|
@@ -98,6 +101,79 @@ Feature: testkit drives any workflow against the real engine
|
|
|
98
101
|
When gtd starts workflow "tiny"
|
|
99
102
|
Then driving the process is refused with 'was not prompted with "Write a poem"'
|
|
100
103
|
|
|
104
|
+
Scenario: a step only asserted to be prompted is where the drive rests, and nothing lands there
|
|
105
|
+
Given step "plan" is prompted with "Write PLAN.md."
|
|
106
|
+
When gtd starts workflow "tiny"
|
|
107
|
+
And the process is driven
|
|
108
|
+
Then the process rests at "plan"
|
|
109
|
+
And the last commit subject is "gtd(human): plan"
|
|
110
|
+
|
|
111
|
+
Scenario: a prompt asserted beside a script is checked at every visit, before the step acts
|
|
112
|
+
Given step "check" is prompted with "npm test"
|
|
113
|
+
And step "check" writes ".gtd/FEEDBACK.md" with:
|
|
114
|
+
"""
|
|
115
|
+
1 test failing
|
|
116
|
+
"""
|
|
117
|
+
And step "plan" writes "PLAN.md" with:
|
|
118
|
+
"""
|
|
119
|
+
add two numbers
|
|
120
|
+
"""
|
|
121
|
+
When gtd starts workflow "tiny"
|
|
122
|
+
And the process is driven
|
|
123
|
+
Then the process rests at "repair"
|
|
124
|
+
|
|
125
|
+
@fails
|
|
126
|
+
Scenario: a prompt asserted at a step no drive reaches fails the scenario at its end
|
|
127
|
+
Given step "plan" changes nothing
|
|
128
|
+
And step "repair" is prompted with "Make the suite pass."
|
|
129
|
+
When gtd starts workflow "tiny"
|
|
130
|
+
And the process is driven
|
|
131
|
+
Then the process stalls at "plan"
|
|
132
|
+
|
|
133
|
+
Scenario: a human step scripted to change nothing refuses the drive instead of repeating it
|
|
134
|
+
Given step "plan" writes "PLAN.md" with:
|
|
135
|
+
"""
|
|
136
|
+
add two numbers
|
|
137
|
+
"""
|
|
138
|
+
And step "check" changes nothing
|
|
139
|
+
And judge step "ready" answers:
|
|
140
|
+
"""
|
|
141
|
+
[{ "id": "ready", "answer": true, "p": 0.9 }]
|
|
142
|
+
"""
|
|
143
|
+
And step "ship" changes nothing
|
|
144
|
+
When gtd starts workflow "tiny"
|
|
145
|
+
Then driving the process is refused with 'the actor for human step "ship" changed nothing'
|
|
146
|
+
|
|
147
|
+
Scenario: a lenient drive rests at an unscripted check step
|
|
148
|
+
Given step "plan" writes "PLAN.md" with:
|
|
149
|
+
"""
|
|
150
|
+
add two numbers
|
|
151
|
+
"""
|
|
152
|
+
When gtd starts workflow "tiny"
|
|
153
|
+
And the process is driven leniently
|
|
154
|
+
Then the process rests at "check"
|
|
155
|
+
And the resting step's content contains "npm test"
|
|
156
|
+
|
|
157
|
+
Scenario: a step scripted for a later drive counts once any drive reached it
|
|
158
|
+
Given step "plan" writes "PLAN.md" with:
|
|
159
|
+
"""
|
|
160
|
+
add two numbers
|
|
161
|
+
"""
|
|
162
|
+
And step "check" writes ".gtd/FEEDBACK.md" with:
|
|
163
|
+
"""
|
|
164
|
+
1 test failing
|
|
165
|
+
"""
|
|
166
|
+
When gtd starts workflow "tiny"
|
|
167
|
+
And the process is driven
|
|
168
|
+
Then the process rests at "repair"
|
|
169
|
+
Given step "repair" deletes ".gtd/FEEDBACK.md"
|
|
170
|
+
And judge step "ready" answers:
|
|
171
|
+
"""
|
|
172
|
+
[{ "id": "ready", "answer": false, "p": 0.9 }]
|
|
173
|
+
"""
|
|
174
|
+
When the process is driven
|
|
175
|
+
Then the process rests at "rework"
|
|
176
|
+
|
|
101
177
|
Scenario: a start the workflow refuses is reported with its message
|
|
102
178
|
Then starting workflow "picky" with "--var mode=bad" is refused with "picky refuses every start"
|
|
103
179
|
|
|
@@ -164,8 +164,8 @@ describe("renderBriefing", () => {
|
|
|
164
164
|
|
|
165
165
|
it("contains the door invocation, exec'ing the loop", () => {
|
|
166
166
|
const briefing = renderBriefing()
|
|
167
|
-
expect(briefing).toContain('gtd
|
|
168
|
-
expect(briefing).
|
|
167
|
+
expect(briefing).toContain('gtd start "$@"')
|
|
168
|
+
expect(briefing).toMatch(/bare `gtd start` lists/i)
|
|
169
169
|
expect(briefing).toMatch(/exec.{0,20}GTD_BUILD/s)
|
|
170
170
|
})
|
|
171
171
|
|
|
@@ -418,19 +418,19 @@ describe("DOOR_COMMAND", () => {
|
|
|
418
418
|
|
|
419
419
|
it("cds to the repository root before any gtd call", () => {
|
|
420
420
|
const cdIndex = DOOR_COMMAND.indexOf('cd "$(git rev-parse --show-toplevel)"')
|
|
421
|
-
const gtdIndex = DOOR_COMMAND.indexOf("gtd
|
|
421
|
+
const gtdIndex = DOOR_COMMAND.indexOf("gtd start")
|
|
422
422
|
expect(cdIndex).toBeGreaterThan(-1)
|
|
423
423
|
expect(gtdIndex).toBeGreaterThan(cdIndex)
|
|
424
424
|
})
|
|
425
425
|
|
|
426
|
-
it("hands every argument to gtd
|
|
427
|
-
expect(DOOR_COMMAND).toContain('gtd
|
|
426
|
+
it("hands every argument to gtd start", () => {
|
|
427
|
+
expect(DOOR_COMMAND).toContain('gtd start "$@"')
|
|
428
428
|
})
|
|
429
429
|
|
|
430
430
|
it("captures the emitted script via command substitution, never a pipe into sh", () => {
|
|
431
|
-
expect(DOOR_COMMAND).toContain('script="$(gtd
|
|
431
|
+
expect(DOOR_COMMAND).toContain('script="$(gtd start "$@")"')
|
|
432
432
|
expect(DOOR_COMMAND).toContain('sh -c "$script"')
|
|
433
|
-
expect(DOOR_COMMAND).not.toMatch(/gtd
|
|
433
|
+
expect(DOOR_COMMAND).not.toMatch(/gtd start[^\n]*\|\s*sh/)
|
|
434
434
|
})
|
|
435
435
|
|
|
436
436
|
it("prints usage to stderr and exits 2 when no name is given", () => {
|