@pmelab/gtd 60.0.0 → 61.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.
Files changed (81) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/README.md +21 -2
  3. package/dist/chunks/testkit-C9sq0x07.mjs +30758 -0
  4. package/dist/chunks/{wire-DZ8R1RU9.mjs → wire-CPNSm_9N.mjs} +27 -12
  5. package/dist/gtd.bundle.mjs +12238 -20706
  6. package/dist/gtd.core.mjs +593 -0
  7. package/dist/testkit/gherkin.mjs +2 -2
  8. package/dist/testkit.mjs +1 -1
  9. package/dist/wire.mjs +2 -2
  10. package/package.json +7 -7
  11. package/src/cli/Cli.test.ts +2 -2
  12. package/src/cli/Cli.ts +68 -51
  13. package/src/cli/History.test.ts +10 -1
  14. package/src/cli/Metrics.test.ts +10 -1
  15. package/src/cli/Output.test.ts +1 -1
  16. package/src/cli/Output.ts +3 -2
  17. package/src/cli/Program.test.ts +44 -25
  18. package/src/cli/Program.ts +39 -11
  19. package/src/cli/Strays.ts +3 -2
  20. package/src/cli/ToolCommands.ts +2 -2
  21. package/src/edge/Edge.test.ts +86 -31
  22. package/src/edge/Edge.ts +164 -31
  23. package/src/emit/GitScript.ts +21 -3
  24. package/src/emit/index.ts +3 -0
  25. package/src/flows/runtime.ts +1 -1
  26. package/src/gherkin/messages.test.ts +1 -0
  27. package/src/gherkin/module-config.feature +1 -0
  28. package/src/gherkin/more-steps.feature +1 -0
  29. package/src/gherkin/testkit.feature +2 -1
  30. package/src/install/Install.ts +9 -2
  31. package/src/install/Version.ts +9 -3
  32. package/src/install/index.ts +1 -1
  33. package/src/platform/CommandRunner.ts +13 -11
  34. package/src/platform/Commentary.ts +2 -2
  35. package/src/platform/Git.test.ts +4 -5
  36. package/src/platform/Git.ts +42 -38
  37. package/src/platform/Host.ts +1 -1
  38. package/src/platform/NodeServices.ts +11 -0
  39. package/src/platform/Workspace.test.ts +4 -5
  40. package/src/platform/Workspace.ts +3 -3
  41. package/src/platform/WorktreeState.test.ts +2 -3
  42. package/src/platform/WorktreeState.ts +1 -1
  43. package/src/platform/index.ts +2 -1
  44. package/src/replay/Format.test.ts +35 -8
  45. package/src/replay/Format.ts +7 -4
  46. package/src/replay/Replay.test.ts +54 -0
  47. package/src/replay/Replay.ts +61 -17
  48. package/src/replay/Trailers.test.ts +12 -12
  49. package/src/replay/Trailers.ts +35 -20
  50. package/src/replay/Tree.ts +11 -0
  51. package/src/replay/index.ts +3 -0
  52. package/src/step/LandStep.ts +1 -0
  53. package/src/step/RepoSnapshot.ts +2 -0
  54. package/src/step/planStart.test.ts +2 -2
  55. package/src/step/planStart.ts +3 -3
  56. package/src/step/planStep.test.ts +4 -4
  57. package/src/step/planStep.ts +10 -8
  58. package/src/testkit/TestRepo.test.ts +4 -1
  59. package/src/testkit/TestRepo.ts +3 -1
  60. package/src/twins/EmittedScriptRecognizer.ts +32 -1
  61. package/src/twins/EmittedScripts.test.ts +1 -1
  62. package/src/twins/GitTiers.ts +29 -7
  63. package/src/twins/InMemRepo.ts +14 -0
  64. package/src/twins/Layers.test.ts +1 -1
  65. package/src/twins/Layers.ts +10 -3
  66. package/src/twins/PinBeats.ts +33 -0
  67. package/src/twins/cliIo.ts +9 -4
  68. package/src/twins/index.ts +1 -0
  69. package/src/wire/BeatDocument.ts +26 -5
  70. package/src/wire/Demand.ts +16 -6
  71. package/src/wire/constants.ts +3 -0
  72. package/src/wire/types.ts +4 -0
  73. package/src/workflow/discovery.test.ts +24 -7
  74. package/src/workflow/discovery.ts +5 -6
  75. package/src/workflow/index.ts +1 -0
  76. package/src/workflow/load.test.ts +60 -3
  77. package/src/workflow/load.ts +316 -166
  78. package/src/workflow/pin.test.ts +159 -0
  79. package/src/workflow/pin.ts +72 -0
  80. package/src/workflow/vars.ts +3 -3
  81. package/dist/chunks/testkit-BvecVjQ0.mjs +0 -32355
@@ -4,8 +4,7 @@ import { join } from "node:path"
4
4
  import { tmpdir } from "node:os"
5
5
  import { afterEach, beforeEach, describe, expect, it } from "vitest"
6
6
  import { Cause, Effect, Exit, Layer } from "effect"
7
- import { NodeContext } from "@effect/platform-node"
8
- import { Narrator, GitService, Host, Workspace } from "../platform/index.js"
7
+ import { Narrator, GitService, Host, Workspace, NodeServices } from "../platform/index.js"
9
8
  import {
10
9
  ConfigDiscovery,
11
10
  ConfigService,
@@ -23,7 +22,7 @@ type Env = Readonly<Record<string, string>>
23
22
 
24
23
  const baseLayer = (dir: string, env: Env = {}) => {
25
24
  const hostLayer = Host.layer({ root: dir, home: homeDir, env })
26
- const gitLayer = GitService.Live.pipe(Layer.provide(Layer.merge(hostLayer, NodeContext.layer)))
25
+ const gitLayer = GitService.Live.pipe(Layer.provide(Layer.merge(hostLayer, NodeServices.layer)))
27
26
  const workspaceLayer = Workspace.Live.pipe(Layer.provide(Layer.merge(hostLayer, gitLayer)))
28
27
  return Layer.mergeAll(hostLayer, gitLayer, workspaceLayer)
29
28
  }
@@ -442,6 +441,64 @@ describe("ConfigService", () => {
442
441
  expect(Object.keys(cfg.fingerprint).sort()).toEqual(["gtd.config.ts", "steps.ts"])
443
442
  })
444
443
 
444
+ it("an ES module package gets the shipped gtd, a CommonJS one stays Node's, each module keeps its location", async () => {
445
+ const vendor = join(projectDir, "vendor", "wf")
446
+ const pkg = (name: string, manifest: object, file: string, source: string) => {
447
+ const dir = join(vendor, "node_modules", name)
448
+ mkdirSync(dir, { recursive: true })
449
+ writeFileSync(join(dir, "package.json"), JSON.stringify({ name, ...manifest }))
450
+ writeFileSync(join(dir, file), source)
451
+ }
452
+ // No @pmelab/gtd installed: only the shipped copy can serve this import.
453
+ pkg(
454
+ "dep",
455
+ { type: "module", exports: { import: "./index.js" } },
456
+ "index.js",
457
+ `import { human } from "@pmelab/gtd/flows"\nexport const file = typeof human\n`,
458
+ )
459
+ pkg("ts-dep", { main: "index.ts" }, "index.ts", `export const suffix: string = "ts"\n`)
460
+ pkg("cjs-dep", {}, "index.js", `module.exports = require("node:path").basename(__dirname)\n`)
461
+ writeFileSync(
462
+ join(vendor, "index.ts"),
463
+ [
464
+ `import { basename, dirname } from "node:path"`,
465
+ `import { fileURLToPath } from "node:url"`,
466
+ `import { file as base } from "dep"`,
467
+ `import { suffix } from "ts-dep"`,
468
+ `import cjs from "cjs-dep"`,
469
+ `const where = basename(dirname(fileURLToPath(import.meta.url)))`,
470
+ `export const file = [base, suffix, cjs, where].join("-")`,
471
+ ``,
472
+ ].join("\n"),
473
+ )
474
+ writeFileSync(
475
+ join(projectDir, "gtd.config.ts"),
476
+ [
477
+ `import { file } from "./vendor/wf/index.js"`,
478
+ optionedWorkflow("first", "{ steering: { [`.gtd/${file}.md`]: 'qa' } }"),
479
+ ].join("\n"),
480
+ )
481
+
482
+ const cfg = await getConfig()
483
+
484
+ expect(cfg.workflow.steering[".gtd/function-ts-cjs-dep-wf.md"]).toBe("qa")
485
+ expect(Object.keys(cfg.fingerprint).sort()).toEqual(["gtd.config.ts", "vendor/wf/index.ts"])
486
+ })
487
+
488
+ it("a config may require and require.resolve a local module", async () => {
489
+ writeFileSync(join(projectDir, "steps.ts"), `export const file = "required"\n`)
490
+ writeFileSync(
491
+ join(projectDir, "gtd.config.ts"),
492
+ [
493
+ `const { file } = require("./steps.js")`,
494
+ `const found = require("node:path").basename(require.resolve("./steps.ts"))`,
495
+ optionedWorkflow("first", "{ steering: { [`.gtd/${file}-${found}.md`]: 'qa' } }"),
496
+ ].join("\n"),
497
+ )
498
+
499
+ expect((await getConfig()).workflow.steering[".gtd/required-steps.ts.md"]).toBe("qa")
500
+ })
501
+
445
502
  it("the fingerprint covers gtd.config.ts but no gtd module it imports", async () => {
446
503
  const cfg = await getConfig()
447
504