@pmelab/gtd 64.0.0 → 64.1.1

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.
@@ -16,6 +16,8 @@ import {
16
16
  import { Effect } from "effect"
17
17
  import { ScriptSurface } from "../emit/index.js"
18
18
  import { GitService } from "../platform/index.js"
19
+ import { listFormat } from "../steering/index.js"
20
+ import { declaredValidateCommand } from "../workflow/index.js"
19
21
  import { gitTiers, type GitTier, type ScriptedCommand } from "./index.js"
20
22
 
21
23
  // Every case runs through real `sh` — with this build's `gtd` on PATH — and
@@ -158,6 +160,23 @@ for (const makeTier of gitTiers) {
158
160
  ),
159
161
  )
160
162
  })
163
+
164
+ it("checks a declared format from the spec on its command line", () => {
165
+ const ids = listFormat({
166
+ name: "ids",
167
+ item: { id: /^A-\d+$/, separator: ":", example: "A-1" },
168
+ ids: { unique: true },
169
+ })
170
+ const check = declaredValidateCommand("ids", ids.spec).replace('"$GTD_FILE"', `'${FILE}'`)
171
+ t.seed.writeFile(FILE, "- A-1: it's\n")
172
+ expect(run(script(check))).toEqual({ ok: true, status: 0, output: "" })
173
+ t.seed.writeFile(FILE, "- A-1: a\n- A-1: b\n")
174
+ const result = run(script(check))
175
+ expect(result).toMatchObject({ ok: false, status: 1 })
176
+ expect(result.output).toBe(
177
+ `gtd check: ${FILE} is not valid under mode "ids" (1 finding(s)):\n${FILE}:2: duplicate ID A-1 — first on line 1\n`,
178
+ )
179
+ })
161
180
  })
162
181
 
163
182
  it("gtd uncheck clears a review file's ticks", () => {
@@ -4,3 +4,7 @@ export const seededValidateCommand = (mode: string): string => `gtd check ${mode
4
4
  /** True when `command` is exactly `mode`'s seeded template (compared literally, not rendered) — distinguishes gtd's own seeding from a user override. */
5
5
  export const isSeededValidateCommand = (mode: string, command: string): boolean =>
6
6
  command === seededValidateCommand(mode)
7
+
8
+ /** The `validate:` command for a declared format: its spec travels on the command line, so `gtd check` loads no workflow to find it. */
9
+ export const declaredValidateCommand = (mode: string, spec: string): string =>
10
+ `gtd check ${mode} "$GTD_FILE" --spec '${spec.replace(/'/g, "'\\''")}'`
@@ -32,6 +32,8 @@ export interface StepDef {
32
32
  readonly label?: string
33
33
  readonly file?: string
34
34
  readonly mode?: StateMode
35
+ /** A declared format's spec, when `mode` names one rather than a built-in or `modes:` entry. */
36
+ readonly modeSpec?: string
35
37
  readonly model?: string
36
38
  readonly system?: string
37
39
  readonly judge?: string
@@ -23,7 +23,11 @@ export {
23
23
  SETTING_NAME_RULE,
24
24
  } from "./vars.js"
25
25
  export { resolveScopeAccess, resolveScopeSkills } from "./skills.js"
26
- export { seededValidateCommand, isSeededValidateCommand } from "./SteeringFormats.js"
26
+ export {
27
+ declaredValidateCommand,
28
+ seededValidateCommand,
29
+ isSeededValidateCommand,
30
+ } from "./SteeringFormats.js"
27
31
  export {
28
32
  type ChangeStatus,
29
33
  type PendingChange,