@punks/cli 2.6.1 → 3.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 (105) hide show
  1. package/AGENTS.md +1 -1
  2. package/README.md +44 -24
  3. package/dist/BASELINE_CHANGELOG.md +57 -0
  4. package/dist/CHANGELOG.md +83 -0
  5. package/dist/data/scripts/harness-projection/adapters/claude.d.mts +3 -0
  6. package/dist/data/scripts/harness-projection/adapters/claude.mjs +124 -0
  7. package/dist/data/scripts/harness-projection/adapters/codex.d.mts +3 -0
  8. package/dist/data/scripts/harness-projection/adapters/codex.mjs +137 -0
  9. package/dist/data/scripts/harness-projection/adapters/cursor.d.mts +5 -0
  10. package/dist/data/scripts/harness-projection/adapters/cursor.mjs +106 -0
  11. package/dist/data/scripts/harness-projection/adapters/opencode.d.mts +5 -0
  12. package/dist/data/scripts/harness-projection/adapters/opencode.mjs +100 -0
  13. package/dist/data/scripts/harness-projection/apply.d.mts +12 -0
  14. package/dist/data/scripts/harness-projection/apply.mjs +96 -0
  15. package/dist/data/scripts/harness-projection/core.d.mts +8 -0
  16. package/dist/data/scripts/harness-projection/core.mjs +239 -0
  17. package/dist/data/scripts/harness-projection/test-fixtures/application-context-plan.json +27 -0
  18. package/dist/data/scripts/harness-projection/test-fixtures/claude/actions.json +109 -0
  19. package/dist/data/scripts/harness-projection/test-fixtures/claude/context-plan.json +150 -0
  20. package/dist/data/scripts/harness-projection/test-fixtures/claude/matrix.json +23 -0
  21. package/dist/data/scripts/harness-projection/test-fixtures/claude/traces.json +15 -0
  22. package/dist/data/scripts/harness-projection/test-fixtures/codex/actions.json +124 -0
  23. package/dist/data/scripts/harness-projection/test-fixtures/codex/context-plan.json +150 -0
  24. package/dist/data/scripts/harness-projection/test-fixtures/codex/matrix.json +23 -0
  25. package/dist/data/scripts/harness-projection/test-fixtures/codex/traces.json +15 -0
  26. package/dist/data/scripts/harness-projection/test-fixtures/cursor/compiler-input.json +93 -0
  27. package/dist/data/scripts/harness-projection/test-fixtures/cursor/context-plan.json +108 -0
  28. package/dist/data/scripts/harness-projection/test-fixtures/cursor/matrix.json +19 -0
  29. package/dist/data/scripts/harness-projection/test-fixtures/cursor/projection.json +54 -0
  30. package/dist/data/scripts/harness-projection/test-fixtures/mixed-context-plan.json +35 -0
  31. package/dist/data/scripts/harness-projection/test-fixtures/opencode/compiler-input.json +93 -0
  32. package/dist/data/scripts/harness-projection/test-fixtures/opencode/context-plan.json +108 -0
  33. package/dist/data/scripts/harness-projection/test-fixtures/opencode/matrix.json +19 -0
  34. package/dist/data/scripts/harness-projection/test-fixtures/opencode/projection.json +51 -0
  35. package/dist/data/scripts/sync-subagents.mjs +1113 -33
  36. package/dist/data/subagents/manifest.mjs +5 -6
  37. package/dist/index.js +1373 -62672
  38. package/dist/skills/agnostic/cli/hi-cli/SKILL.md +17 -121
  39. package/dist/skills/agnostic/cli/hi-cli/references/commands.md +32 -47
  40. package/dist/skills/agnostic/cli/hi-cli/references/post-command-flow.md +73 -62
  41. package/dist/skills/agnostic/docs/docs-onboarding/SKILL.md +1 -1
  42. package/dist/skills/agnostic/docs/docs-onboarding/references/artifact-contract.md +2 -2
  43. package/dist/skills/agnostic/planning/create-plan/SKILL.md +11 -10
  44. package/dist/skills/agnostic/planning/create-plan/references/grill-ambiguity.md +10 -31
  45. package/dist/skills/agnostic/planning/create-plan/references/plan-schema.md +2 -2
  46. package/dist/skills/agnostic/planning/create-spec/SKILL.md +3 -5
  47. package/dist/skills/agnostic/planning/create-spec/assets/SPEC-TEMPLATE.md +1 -0
  48. package/dist/skills/agnostic/planning/create-spec/references/backlog-sync.md +2 -2
  49. package/dist/skills/agnostic/planning/create-spec/references/grill-phase.md +4 -9
  50. package/dist/skills/agnostic/planning/create-spec/references/spec-quality-bar.md +1 -0
  51. package/dist/skills/agnostic/planning/implement-spec/references/lifecycle.md +1 -1
  52. package/dist/skills/agnostic/requirements/grilling/LICENSE +21 -0
  53. package/dist/skills/agnostic/requirements/grilling/SKILL.md +6 -30
  54. package/dist/skills/agnostic/requirements/grilling/UPSTREAM.md +16 -0
  55. package/dist/skills/agnostic/requirements/requirements-grill/SKILL.md +3 -5
  56. package/dist/skills/agnostic/requirements/requirements-grill/references/artifact-output.md +40 -16
  57. package/dist/skills/agnostic/requirements/requirements-grill/references/grilling-flow.md +3 -16
  58. package/dist/skills/agnostic/requirements/write-backlog/REFERENCE.md +21 -15
  59. package/dist/skills/agnostic/requirements/write-backlog/SKILL.md +14 -14
  60. package/dist/skills/agnostic/requirements/write-backlog/assets/concepts/backlog-model.md +28 -9
  61. package/dist/skills/agnostic/requirements/write-backlog/assets/providers/azure-devops-create-payload.md +45 -5
  62. package/dist/skills/agnostic/requirements/write-backlog/assets/providers/github-projects-create-payload.md +48 -28
  63. package/dist/skills/agnostic/requirements/write-backlog/assets/providers/linear-create-payload.md +22 -6
  64. package/dist/skills/agnostic/requirements/write-backlog/assets/providers/monday-create-payload.md +47 -22
  65. package/dist/skills/frameworks/effect/effect/LICENSE +21 -0
  66. package/dist/skills/frameworks/effect/effect/SKILL.md +100 -0
  67. package/dist/skills/frameworks/effect/effect/UPSTREAM.md +11 -0
  68. package/dist/skills/frameworks/effect/effect/references/CACHING.md +76 -0
  69. package/dist/skills/frameworks/effect/effect/references/CONFIG.md +67 -0
  70. package/dist/skills/frameworks/effect/effect/references/HTTP_CLIENTS.md +101 -0
  71. package/dist/skills/frameworks/effect/{effect-authoring/references/otel-patterns.md → effect/references/OBSERVABILITY.md} +4 -29
  72. package/dist/skills/frameworks/effect/effect/references/SCHEDULING.md +135 -0
  73. package/dist/skills/frameworks/effect/effect/references/SCHEMA.md +130 -0
  74. package/dist/skills/frameworks/effect/effect/references/SERVICES_LAYERS.md +168 -0
  75. package/dist/skills/frameworks/effect/effect/references/STREAMS.md +135 -0
  76. package/dist/skills/frameworks/effect/effect/references/TESTING.md +118 -0
  77. package/dist/skills/frameworks/effect/effect-backend-structure/SKILL.md +7 -8
  78. package/dist/skills/frameworks/effect/effect-recoverable-actions/SKILL.md +1 -1
  79. package/dist/skills/frameworks/nestjs/nestjs-best-practices/.gitignore +29 -0
  80. package/dist/skills/misc/secrets-cli/SKILL.md +54 -0
  81. package/dist/skills/misc/secrets-cli/references/command-reference.md +107 -0
  82. package/dist/skills/misc/secrets-cli/references/safety-and-errors.md +54 -0
  83. package/dist/skills/misc/secrets-cli/references/workflows.md +106 -0
  84. package/dist/skills/phases/design-phase/phases/grill.md +1 -1
  85. package/dist/skills/phases/requirements-phase/SKILL.md +2 -4
  86. package/dist/skills/phases/review-phase/REFERENCE.md +13 -5
  87. package/dist/skills/phases/review-phase/SKILL.md +3 -2
  88. package/package.json +1 -1
  89. package/dist/skills/agnostic/planning/create-spec/references/handoff.md +0 -47
  90. package/dist/skills/frameworks/effect/effect-authoring/SKILL.md +0 -116
  91. package/dist/skills/frameworks/effect/effect-authoring/references/branded-types.md +0 -98
  92. package/dist/skills/frameworks/effect/effect-authoring/references/effect-primitives.md +0 -144
  93. package/dist/skills/frameworks/effect/effect-authoring/references/error-patterns.md +0 -156
  94. package/dist/skills/frameworks/effect/effect-authoring/references/test-patterns.md +0 -146
  95. package/dist/skills/frameworks/effect/effect-best-practices/SKILL.md +0 -517
  96. package/dist/skills/frameworks/effect/effect-best-practices/references/anti-patterns.md +0 -392
  97. package/dist/skills/frameworks/effect/effect-best-practices/references/effect-atom-patterns.md +0 -653
  98. package/dist/skills/frameworks/effect/effect-best-practices/references/error-patterns.md +0 -464
  99. package/dist/skills/frameworks/effect/effect-best-practices/references/language-server.md +0 -287
  100. package/dist/skills/frameworks/effect/effect-best-practices/references/layer-patterns.md +0 -495
  101. package/dist/skills/frameworks/effect/effect-best-practices/references/observability-patterns.md +0 -342
  102. package/dist/skills/frameworks/effect/effect-best-practices/references/rpc-cluster-patterns.md +0 -418
  103. package/dist/skills/frameworks/effect/effect-best-practices/references/schema-patterns.md +0 -353
  104. package/dist/skills/frameworks/effect/effect-best-practices/references/service-patterns.md +0 -299
  105. /package/dist/skills/frameworks/effect/{effect-authoring/references/effect-atom-patterns.md → effect/references/EFFECT_ATOM.md} +0 -0
@@ -0,0 +1,168 @@
1
+ # Services, Layers, And Modules
2
+
3
+ Use this when defining service tags, module surfaces, layer implementations, runtime wiring, typed errors, or `Effect.fn` operation boundaries.
4
+
5
+ ## Module Surface
6
+
7
+ One opinionated application-module style uses file-local role names and one canonical ES module namespace projection. Follow the existing codebase's module style when it has one; this convention is not required by Effect.
8
+
9
+ ```ts
10
+ export interface Interface {
11
+ readonly get: (id: UserId) => Effect.Effect<User, NotFound | PersistenceError>
12
+ }
13
+
14
+ export class Service extends Context.Service<Service, Interface>()(
15
+ "@app/UserRepo",
16
+ ) {}
17
+
18
+ export const layer = Layer.effect(
19
+ Service,
20
+ Effect.gen(function* () {
21
+ const sql = yield* SqlClient.SqlClient
22
+
23
+ const get = Effect.fn("UserRepo.get")(function* (id: UserId) {
24
+ // ...
25
+ })
26
+
27
+ return Service.of({ get })
28
+ }),
29
+ )
30
+
31
+ export class NotFound extends Schema.TaggedErrorClass<NotFound>()(
32
+ "UserRepo.NotFound",
33
+ { id: UserId },
34
+ ) {}
35
+
36
+ export * as UserRepo from "./user-repo.js"
37
+ ```
38
+
39
+ Consumers use the module namespace.
40
+
41
+ ```ts
42
+ import { UserRepo } from "./user-repo.js"
43
+
44
+ const program = Effect.gen(function* () {
45
+ const repo = yield* UserRepo.Service
46
+ return yield* repo.get(id)
47
+ })
48
+ ```
49
+
50
+ The self-export is deliberate. It lets the file remain the module while giving every consumer the same domain-first name, without a TypeScript `namespace`, wrapper object, or repeated consumer-side aliases.
51
+
52
+ ```ts
53
+ // Sibling module: import the owning leaf directly.
54
+ import { UserRepo } from "./user-repo.js"
55
+
56
+ // Folder or package barrel: relay the identity established by the leaf.
57
+ export { UserRepo } from "./user-repo.js"
58
+ ```
59
+
60
+ Guidance:
61
+
62
+ - Do not name the tag class `UserRepo` inside `user-repo.ts`; the module namespace is the domain name.
63
+ - In this module style, single-file modules self-export their canonical namespace at the bottom: `export * as UserRepo from "./user-repo.js"`.
64
+ - Sibling modules import that namespace from the owning leaf; they do not import through their own aggregate barrel.
65
+ - Folder and package barrels relay established leaf identities with `export { UserRepo } from "./user-repo.js"`.
66
+ - The resulting `UserRepo.UserRepo === UserRepo` self-reference is unusual. Use this pattern only where the runtime and toolchain support it; otherwise use named exports or a separate barrel.
67
+ - Export only intentional surface; keep local schemas, row codecs, helpers, and implementation details unexported.
68
+ - Do not introduce TypeScript `namespace` declarations for organization.
69
+ - Use a named service class such as `class UserRepo extends Context.Service...` when an external library or existing codebase does not use module namespace style.
70
+
71
+ ## Layer Constructors
72
+
73
+ Choose the layer constructor that matches the thing produced.
74
+
75
+ ```ts
76
+ Layer.succeed(Service, impl) // already-built service
77
+ Layer.sync(Service, () => impl) // lazy synchronous service
78
+ Layer.effect(Service, makeEffect) // effectful service acquisition
79
+ ```
80
+
81
+ Guidance:
82
+
83
+ - Default real implementations to `Layer.effect(Service, Effect.gen(...))`.
84
+ - Use `Layer.effectContext(...)` when one acquisition intentionally supplies multiple services, especially first-class test stubs or one client backing several service tags.
85
+ - Use `Layer.unwrap(...)` when config or runtime discovery chooses/builds the layer.
86
+ - Use `Layer.fresh(...)` or `Effect.provide(layer, { local: true })` only when a test or operation needs isolated acquisition.
87
+ - Use `Context.Reference` rarely, only for ambient/defaultable runtime references where a safe default is real.
88
+
89
+ ## Long-Lived Work
90
+
91
+ A layer that starts a stream, listener, worker, subscription, or forever loop must fork that work into the layer scope. Layer acquisition must complete.
92
+
93
+ ```ts
94
+ export const layer = Layer.effectDiscard(
95
+ Effect.gen(function* () {
96
+ const events = yield* Events.Service
97
+
98
+ yield* events.stream.pipe(
99
+ Stream.runForEach(handleEvent),
100
+ Effect.forkScoped,
101
+ )
102
+ }),
103
+ )
104
+ ```
105
+
106
+ Guidance:
107
+
108
+ - Use `Effect.forkScoped`, `FiberSet`, or `FiberMap` for scoped background work.
109
+ - Do not run forever work inline during layer acquisition.
110
+ - Do not expose public `start` methods unless the domain explicitly needs manual lifecycle control.
111
+
112
+ ## Runtime Wiring
113
+
114
+ - Use `Layer.provide(...)` to hide an implementation dependency.
115
+ - Use `Layer.provideMerge(...)` only when the dependency should remain exposed for downstream consumers.
116
+ - Use `Layer.mergeAll(...)` for independent exposed layers.
117
+ - Prefer flat, topologically sorted runtime layer values with named subgraphs.
118
+ - Avoid using `provideMerge` as a blind make-it-compile tool.
119
+ - Avoid hiding important authority or lifecycle dependencies behind broad invisible provisioning.
120
+
121
+ ## Effect.fn
122
+
123
+ Use extra `Effect.fn(...)` arguments for wrappers that apply to the whole function call. Each transform receives `(effect, ...originalArgs)`.
124
+
125
+ ```ts
126
+ const readAttachment = Effect.fn("Attachment.read")(
127
+ function* (ref: AttachmentRef) {
128
+ return yield* api.read(ref)
129
+ },
130
+ (effect, ref) =>
131
+ effect.pipe(
132
+ attachmentError("Attachment.read", { attachmentId: ref.id }),
133
+ ),
134
+ )
135
+ ```
136
+
137
+ Good whole-function transforms:
138
+
139
+ - error classification
140
+ - localized recovery
141
+ - logging annotations
142
+ - spans
143
+ - retry
144
+ - timeout
145
+ - ensuring cleanup
146
+ - small local provisioning
147
+ - result mapping
148
+
149
+ Guidance:
150
+
151
+ - Keep the generator body focused on the core workflow.
152
+ - Use transforms when the wrapper needs original arguments.
153
+ - Do not build long clever pipelines; one or two transforms is usually enough.
154
+ - Do not use this for local branch-level handling inside the workflow.
155
+
156
+ ## Operation Error Helpers
157
+
158
+ For boundary errors with operation labels, prefer a shared curried `mapError` helper over hand-writing wrappers in every module.
159
+
160
+ ```ts
161
+ const persistenceError = operationError(PersistenceError.make)
162
+
163
+ const row = yield* query.pipe(
164
+ persistenceError("UserRepository.findById"),
165
+ )
166
+ ```
167
+
168
+ Name the local helper after the error it produces, such as `persistenceError`, `projectionError`, or `processingError`. Use `Effect.fn(...)` and spans for observability in addition to payload labels, not instead of them.
@@ -0,0 +1,135 @@
1
+ # Streams
2
+
3
+ Use this when working with `Stream`, event sources, async iterables, queue/pubsub-backed streams, pagination, backpressure, throttling, debouncing, or long-lived stream consumers.
4
+
5
+ ## Mental Model
6
+
7
+ `Stream<A, E, R>` is an effectful source that can emit many `A` values over time, fail with `E`, and require services `R`. Streams are pull-based and backpressured; consumption controls demand.
8
+
9
+ Use streams for sources that are naturally many-valued and time-ordered:
10
+
11
+ - gateway events
12
+ - provider callbacks adapted through queues
13
+ - subscription/event logs
14
+ - paginated APIs
15
+ - file/stdin/platform streams
16
+ - scheduled ticks when values matter
17
+ - pipelines with filtering, mapping, buffering, throttling, or bounded concurrent processing
18
+
19
+ Do not use streams just to loop forever. For one repeated effect with no emitted values, use `Effect.repeat(...)` with `Schedule`; read `SCHEDULING.md`.
20
+
21
+ ## Source Chooser
22
+
23
+ - In-memory values: `Stream.make(...)` or `Stream.fromIterable(...)`.
24
+ - Test fixtures: `Stream.fromIterable(...)`, often with `Stream.concat(Stream.never)` for an open subscription.
25
+ - Queue-backed callback boundary: `Queue` plus `Stream.fromQueue(...)`.
26
+ - Broadcast events: `PubSub` plus `Stream.fromPubSub(...)`.
27
+ - Latest-value state plus updates: `SubscriptionRef`.
28
+ - Schedule-generated ticks/values: `Stream.fromSchedule(...)`.
29
+ - Paginated pull APIs: `Stream.paginate(...)`; its step function is already effectful, returning `Effect<[chunk, Option<nextState>]>`.
30
+ - Async iterable/platform source: `Stream.fromAsyncIterable(...)` when no native Effect source exists.
31
+ - Effect that produces a stream after reading services/config: `Stream.unwrap(...)`.
32
+
33
+ ## Transformation Chooser
34
+
35
+ - Pure transformation: `Stream.map(...)`.
36
+ - Effectful transformation: `Stream.mapEffect(...)`.
37
+ - Bounded concurrent effectful transformation: `Stream.mapEffect(fn, { concurrency })`.
38
+ - Drop ordering when order is irrelevant and latency matters: `Stream.mapEffect(fn, { concurrency, unordered: true })`.
39
+ - One input to zero/many outputs: `Stream.flatMap(...)`.
40
+ - Multiple inner streams concurrently: `Stream.flatMap(fn, { concurrency })`.
41
+ - Keep only matching values: `Stream.filter(...)` / `Stream.filterEffect(...)`.
42
+ - Stateful transformation: `Stream.mapAccum(...)` / `Stream.mapAccumEffect(...)`.
43
+ - Paginated pull-to-pages: prefer `Stream.paginate(...)` over hand-rolled loops. There is no separate `Stream.paginateEffect`.
44
+
45
+ ## Consumption Chooser
46
+
47
+ - Side-effecting consumer: `Stream.runForEach(...)`.
48
+ - Ignore elements but run the stream: `Stream.runDrain`.
49
+ - Tests/small finite streams: `Stream.runCollect`.
50
+ - First N values in tests: `Stream.take(n)` plus `Stream.runCollect`.
51
+ - Fold into a value: `Stream.runFold(...)`.
52
+ - Long-lived consumer in a layer: `stream.pipe(Stream.runForEach(...), Effect.forkScoped)`.
53
+
54
+ Avoid `Stream.runCollect` on unbounded or production event streams.
55
+
56
+ ## Long-Lived Consumers
57
+
58
+ Own long-lived stream consumers in layers and fork them into the layer scope.
59
+
60
+ ```ts
61
+ export const layer = Layer.effectDiscard(
62
+ Effect.gen(function* () {
63
+ const gateway = yield* Gateway.Service
64
+
65
+ yield* gateway.events.pipe(
66
+ Stream.filter(isMessageEvent),
67
+ Stream.runForEach(handleEvent),
68
+ Effect.forkScoped,
69
+ )
70
+ }),
71
+ )
72
+ ```
73
+
74
+ Guidance:
75
+
76
+ - Let the layer own the stream lifetime.
77
+ - Use `Effect.forkScoped` for the ordinary case.
78
+ - If methods need to fork work into the layer lifetime, capture `Scope.Scope` during layer acquisition and use `Effect.forkIn(scope)` internally. Do not expose the scope as public service API.
79
+ - Preserve stream failures unless the owning boundary has a truthful recovery policy.
80
+
81
+ ## Queues, PubSub, And SubscriptionRef
82
+
83
+ - Use `Queue` when each event/item should be consumed by one consumer or worker.
84
+ - Use `PubSub` when every subscriber should see every event.
85
+ - Use `SubscriptionRef` when consumers need the current value and a stream of changes.
86
+ - Expose a `Stream` from service interfaces when callers should consume events, not push into the queue.
87
+ - Keep producer queues/private refs inside the implementation or test service.
88
+
89
+ Good service shape:
90
+
91
+ ```ts
92
+ export interface Interface {
93
+ readonly events: Stream.Stream<ProviderEvent, ProviderError>
94
+ readonly status: Stream.Stream<ProviderStatus>
95
+ }
96
+ ```
97
+
98
+ Implementation can use private `Queue` / `SubscriptionRef`; consumers see streams.
99
+
100
+ ## Backpressure And Buffers
101
+
102
+ Prefer natural stream backpressure first.
103
+
104
+ Use `Stream.buffer(...)` only when producer and consumer should decouple.
105
+
106
+ - `strategy: "suspend"`: apply backpressure when full.
107
+ - `strategy: "dropping"`: drop new values when full.
108
+ - `strategy: "sliding"`: keep the latest values by dropping old ones.
109
+ - `capacity: "unbounded"`: rare; use only when growth is bounded elsewhere.
110
+
111
+ Use `Stream.debounce(...)` for quiet-period behavior and `Stream.throttle(...)` / `Stream.throttleEffect(...)` for rate-shaped streams.
112
+
113
+ ## Error Handling
114
+
115
+ - Prefer typed stream errors over defects.
116
+ - Use `Stream.mapError(...)` to translate errors at boundaries.
117
+ - Use `Stream.catchIf(...)`, `Stream.catchTag(...)`, or `Stream.catchFilter(...)` for typed recovery.
118
+ - Use `Stream.catchCause(...)` only at explicit supervision boundaries.
119
+ - Do not hide stream defects by default; let them reach the owning layer/runtime unless the stream is explicitly best-effort.
120
+
121
+ ## Keyed Concurrency
122
+
123
+ For streams of work keyed by session/channel/id, prefer a named helper over ad hoc maps of fibers.
124
+
125
+ If the codebase already has a keyed-run helper (for example a `runForEachKeyed` that runs different keys concurrently while serializing each key and coalescing pending values into one latest-value rerun), use it. Otherwise build one named helper with `FiberMap` rather than scattering fiber bookkeeping through consumers.
126
+
127
+ Use this for projection/reconciliation streams where each key needs ordered processing but different keys can run in parallel.
128
+
129
+ ## Tests
130
+
131
+ - Use `Stream.fromIterable(...)` for finite fixtures.
132
+ - Use `Stream.empty` for no events.
133
+ - Use `Stream.fromQueue(...)` with a test-owned `Queue` when the test needs to drive events interactively.
134
+ - Use `Stream.take(n)` plus `Stream.runCollect` for finite assertions.
135
+ - Avoid real sleeps; coordinate with `Deferred`, `Queue`, `Latch`, and `TestClock`.
@@ -0,0 +1,118 @@
1
+ # Testing
2
+
3
+ Use this when writing Effect tests, tests involving time, retry, schedules, concurrency, workers, services, fakes, or config.
4
+
5
+ ## Defaults
6
+
7
+ - Use `it.effect` by default.
8
+ - Use `it.live` only when real time or live runtime services are the behavior under test.
9
+ - Use test layers and `ConfigProvider` rather than global mutation.
10
+ - Use `TestClock.setTime` / `TestClock.adjust` for sleeps, schedules, retries, leases, and timeouts.
11
+ - Fork sleeping effects before advancing `TestClock`.
12
+ - Avoid arbitrary `Effect.sleep(...)` in tests; it usually makes tests slow and flaky.
13
+ - Assert typed failures, rollback, interruption, finalization, retry bounds, idempotency, concurrency laws, and malformed persistence where relevant.
14
+
15
+ ```ts
16
+ it.effect("finds a user", () =>
17
+ Effect.gen(function* () {
18
+ const users = yield* UserRepo.Service
19
+ const result = yield* users.find(UserId.make("u1"))
20
+ expect(Option.isSome(result)).toBe(true)
21
+ }).pipe(Effect.provide(UserRepo.testLayer)),
22
+ )
23
+ ```
24
+
25
+ ## Synchronization Instead Of Sleeps
26
+
27
+ - Use `Deferred` for one-shot readiness/completion signals.
28
+ - Use `Queue` for handing test-controlled work or observed events across fibers.
29
+ - Use `Latch` for reusable open/close coordination gates.
30
+ - Use `Ref` for shared test observation state.
31
+ - Use explicit test hooks when the production boundary can expose a deterministic synchronization point.
32
+
33
+ ```ts
34
+ it.effect("publishes exactly once", () =>
35
+ Effect.gen(function* () {
36
+ const published = yield* Queue.unbounded<Message>()
37
+ const ready = yield* Deferred.make<void>()
38
+
39
+ const runWorker = makeWorker({
40
+ onReady: () => Deferred.succeed(ready, undefined),
41
+ onPublish: (message) => Queue.offer(published, message),
42
+ })
43
+
44
+ yield* runWorker.pipe(
45
+ Effect.forkScoped,
46
+ )
47
+
48
+ yield* Deferred.await(ready)
49
+ const message = yield* Queue.take(published)
50
+
51
+ expect(message).toEqual(expectedMessage)
52
+ }),
53
+ )
54
+ ```
55
+
56
+ ## First-Class App Test Stubs
57
+
58
+ Use `TestInterface extends Interface`, `TestService`, and `testLayer` for reusable/stateful fakes.
59
+
60
+ ```ts
61
+ export interface Interface {
62
+ readonly send: (message: Message) => Effect.Effect<void, SendError>
63
+ }
64
+
65
+ export class Service extends Context.Service<Service, Interface>()(
66
+ "@app/Notifier",
67
+ ) {}
68
+
69
+ export interface TestInterface extends Interface {
70
+ readonly sentMessages: () => Effect.Effect<ReadonlyArray<Message>>
71
+ readonly failNextSend: (error: SendError) => Effect.Effect<void>
72
+ }
73
+
74
+ export class TestService extends Context.Service<TestService, TestInterface>()(
75
+ "@app/Notifier/Test",
76
+ ) {}
77
+
78
+ export const testLayer = Layer.effectContext(
79
+ Effect.gen(function* () {
80
+ const sent = yield* Ref.make<ReadonlyArray<Message>>([])
81
+ const nextFailure = yield* Ref.make<Option.Option<SendError>>(Option.none())
82
+
83
+ const service = TestService.of({
84
+ send: Effect.fn("Notifier.Test.send")(function* (message) {
85
+ const failure = yield* Ref.getAndSet(nextFailure, Option.none())
86
+ if (Option.isSome(failure)) return yield* Effect.fail(failure.value)
87
+ yield* Ref.update(sent, (messages) => [...messages, message])
88
+ }),
89
+ sentMessages: Effect.fn("Notifier.Test.sentMessages")(function* () {
90
+ return yield* Ref.get(sent)
91
+ }),
92
+ failNextSend: Effect.fn("Notifier.Test.failNextSend")(function* (error) {
93
+ yield* Ref.set(nextFailure, Option.some(error))
94
+ }),
95
+ })
96
+
97
+ return Context.empty().pipe(
98
+ Context.add(Service, service),
99
+ Context.add(TestService, service),
100
+ )
101
+ }),
102
+ )
103
+ ```
104
+
105
+ Guidance:
106
+
107
+ - The same object should back both the real `Service` tag and `TestService` tag.
108
+ - Production code depends only on the real service tag.
109
+ - Tests use `TestService` for control and inspection.
110
+ - Use function-valued service members, including zero-argument operations, so `Effect.fn` fits naturally.
111
+ - Use `Layer.succeed` for complete dead-simple static test implementations.
112
+ - Use `Layer.mock` only for tiny local partial mocks where omitted members should fail loudly if used.
113
+
114
+ ## Config In Tests
115
+
116
+ Use `ConfigProvider.layer(ConfigProvider.fromUnknown(...))` when the test should exercise Config decoding.
117
+
118
+ Use `Layer.succeed(AppConfiguration.Service, config)` when the app wraps decoded config in its own service and the test does not need to exercise env decoding.
@@ -7,11 +7,12 @@ description: |
7
7
  Effect backend root. Enforces visible Effect requirements, layer-provided
8
8
  implementations, effect-solutions plus opensrc source lookup, and @effect/vitest
9
9
  testing conventions.
10
+ compatibility: Requires Effect v4. Examples are reviewed against the version documented in this repository.
10
11
  ---
11
12
 
12
13
  # Effect Backend Structure
13
14
 
14
- Use this skill with `$backend-domain-structure` for Effect backend code.
15
+ Use this skill with `$backend-domain-structure` and `$effect` for Effect backend code. `$effect` owns Effect v4 API guidance.
15
16
 
16
17
  The agnostic skill owns the layer model:
17
18
 
@@ -26,7 +27,7 @@ This skill adds Effect-specific services, layers, dependency visibility, source
26
27
 
27
28
  1. Identify the backend root from the current repo; do not assume a monorepo path.
28
29
  2. Read the nearest relevant `AGENTS.md` files.
29
- 3. Read `$backend-domain-structure` and `references/layout.md`.
30
+ 3. Read `$backend-domain-structure`, `$effect`, and `references/layout.md`.
30
31
  4. Run the relevant `effect-solutions` guides before coding.
31
32
  5. Check local `opensrc` Effect sources when docs are vague or an API surface is unfamiliar.
32
33
  6. Place code using the agnostic backend layers plus the Effect rules below.
@@ -45,17 +46,15 @@ Always consult `effect-solutions` first. Use the smallest relevant set:
45
46
 
46
47
  Use `opensrc` next when the guide is not enough:
47
48
 
48
- - `opensrc/repos/github.com/Effect-TS/effect/packages/effect`
49
- - `opensrc/repos/github.com/Effect-TS/effect/packages/sql`
50
- - `opensrc/repos/github.com/Effect-TS/effect/packages/sql-drizzle`
49
+ - Run `opensrc path Effect-TS/effect`.
50
+ - Inspect `packages/effect`, `packages/sql`, or `packages/sql-drizzle` in that checkout.
51
51
 
52
52
  For non-Effect libraries, run `opensrc path <package>` or `opensrc path owner/repo`.
53
53
 
54
54
  ## Services and Layers
55
55
 
56
- - Use `Effect.Service` for business services, repositories, and reusable capability interfaces.
57
- - Use `Context.Tag` only for externally supplied runtime handles or third-party tags.
58
- - Declare construction dependencies in `dependencies: [Dep.Default]`.
56
+ - Define business services, repositories, and reusable capability interfaces with `Context.Service`.
57
+ - Build implementations with layers and return values through `Service.of(...)`.
59
58
  - Let actions consume services/repositories through Effect accessors or `yield* Service`.
60
59
  - Keep action requirements visible until a feature, app, runner, or test layer provides them.
61
60
  - Compose feature dependencies in `features/<domain>/layer.ts` or the local equivalent.
@@ -9,7 +9,7 @@ description: |
9
9
 
10
10
  # Effect Recoverable Actions
11
11
 
12
- Use this skill with `$backend-recoverable-actions`, `$effect-backend-structure`, and `$effect-best-practices`.
12
+ Use this skill with `$backend-recoverable-actions`, `$effect-backend-structure`, and `$effect`.
13
13
 
14
14
  The agnostic skill owns the recovery model:
15
15
 
@@ -0,0 +1,29 @@
1
+ # Dependencies
2
+ node_modules/
3
+
4
+ # Website (lives on docs branch)
5
+ website/
6
+
7
+ # Build outputs
8
+ dist/
9
+ *.js
10
+ *.d.ts
11
+ *.js.map
12
+
13
+ # IDE
14
+ .idea/
15
+ .vscode/
16
+ *.swp
17
+ *.swo
18
+
19
+ # OS
20
+ .DS_Store
21
+ Thumbs.db
22
+
23
+ # Logs
24
+ *.log
25
+ npm-debug.log*
26
+
27
+ # Environment
28
+ .env
29
+ .env.local
@@ -0,0 +1,54 @@
1
+ ---
2
+ name: secrets-cli
3
+ description: Operates the DP Secrets CLI (`secrets`) for installation, authentication, project membership, environments, dotenv files, pulls, and secret values. Use before any agent runs a `secrets` command or when the user mentions the Secrets CLI, `secrets login`, `secrets projects`, `secrets envs`, `secrets files`, `secrets values`, or the compatibility `secrets secrets` tree.
4
+ metadata: {"DP Secrets":{"entrypoint":true}}
5
+ ---
6
+
7
+ # secrets-cli
8
+
9
+ Operate the `secrets` executable without exposing secret material or guessing selectors.
10
+
11
+ ## 1. Activate Before Execution
12
+
13
+ Before running any `secrets` command, explicitly announce: `Activating secrets-cli before running secrets.`
14
+
15
+ If this skill is unavailable, stop. Install it, then activate it before continuing:
16
+
17
+ ```bash
18
+ npx skills add https://github.com/wearedevpunks/skills/tree/main/skills/misc/secrets-cli --skill secrets-cli --global --yes
19
+ ```
20
+
21
+ Never run `secrets`, including `secrets --help` or `secrets --version`, without this activation.
22
+
23
+ ## 2. Load the Needed Reference
24
+
25
+ - Read [references/command-reference.md](references/command-reference.md) before constructing or checking command syntax.
26
+ - Read [references/workflows.md](references/workflows.md) for install, auth, membership, setup, pull, value, and cleanup sequences.
27
+ - Read [references/safety-and-errors.md](references/safety-and-errors.md) before handling values, stdin, pulls, destructive work, failures, or exit codes.
28
+
29
+ ## 3. Establish Context
30
+
31
+ 1. Confirm the CLI is installed with `secrets --version`; install or update only when needed.
32
+ 2. Confirm identity with `secrets whoami`; use `secrets login` when unauthenticated or expired.
33
+ 3. Resolve the project, environment, file, and value scope before mutation. Prefer explicit selectors when inference is uncertain.
34
+ 4. List the target immediately before destructive or overwrite-capable work.
35
+
36
+ Context is established when identity and every selector needed by the chosen leaf command are known.
37
+
38
+ ## 4. Execute the Smallest Workflow
39
+
40
+ Use one leaf command at a time. Prefer `secrets values`; use `secrets secrets` only for compatibility with existing automation.
41
+
42
+ Send sensitive input through `--stdin`. Never place secret values in commentary, logs, summaries, command echoes, or verification output. For pulls, inspect the plan and target paths before approval.
43
+
44
+ ## 5. Verify Completion
45
+
46
+ Completion requires all applicable checks:
47
+
48
+ - the command exited `0`
49
+ - a follow-up list, identity check, or filesystem check confirms the intended state
50
+ - pulled files exist at the configured paths and overwrite impact was accepted
51
+ - output and handoff text contain key names only, never secret values
52
+ - destructive cleanup followed leaf-to-root order and no intended active resource remains
53
+
54
+ If any check fails, report the exact failing command, safe error text, exit code, and next action. Do not claim completion.
@@ -0,0 +1,107 @@
1
+ # Command Reference
2
+
3
+ Use `secrets <group> <leaf> --help` as the live authority when an installed version differs from this reference.
4
+
5
+ ## Install and Global Utilities
6
+
7
+ Node.js 22.14 or newer is required for the npm package.
8
+
9
+ ```bash
10
+ npm install --global @punks/secrets
11
+ npx @punks/secrets --help
12
+ secrets --version
13
+ secrets --help
14
+ secrets --completions bash|zsh|fish|sh
15
+ secrets --log-level all|trace|debug|info|warn|warning|error|fatal|none <command>
16
+ ```
17
+
18
+ The untagged package installs the current stable release. Use `@punks/secrets@next` only when an explicit prerelease-testing policy requires it. A release executable from GitHub is standalone; verify it against the release `SHA256SUMS` before use.
19
+
20
+ Global flags are `--help` (`-h`), `--version` (`-v`), `--completions`, and `--log-level`. Put a log-level flag before the command when debugging, for example `secrets --log-level debug files list production`.
21
+
22
+ ## Authentication
23
+
24
+ ```text
25
+ secrets login
26
+ secrets whoami
27
+ secrets logout
28
+ ```
29
+
30
+ `login` opens device authorization in a browser. `whoami` prints email and role. `logout` clears local CLI authentication.
31
+
32
+ ## Projects
33
+
34
+ ```text
35
+ secrets projects list
36
+ secrets projects create NAME [--slug SLUG]
37
+ secrets projects update [PROJECT] [--project PROJECT] [--name NAME] [--slug SLUG]
38
+ secrets projects delete [PROJECT] [--project PROJECT]
39
+ ```
40
+
41
+ For `update` and `delete`, use either positional `PROJECT` or `--project`, never both. `update` requires at least one of `--name` or `--slug`. Create derives a kebab-case slug from `NAME` when `--slug` is absent.
42
+
43
+ Project create, update, delete, and membership administration require an admin identity. Project members can operate environments, files, and values within their memberships.
44
+
45
+ ## Project Membership
46
+
47
+ ```text
48
+ secrets projects users list [PROJECT] [--project PROJECT]
49
+ secrets projects users add EMAIL [--project PROJECT]
50
+ secrets projects users remove USER_ID_OR_EMAIL [--project PROJECT]
51
+ ```
52
+
53
+ For `users list`, use either positional `PROJECT` or `--project`, never both. Add has no public role flag; membership is binary. The target email must have signed in once before it can be added. Remove accepts a user ID or exact email address.
54
+
55
+ ## Environments
56
+
57
+ ```text
58
+ secrets envs list [PROJECT] [--project PROJECT]
59
+ secrets envs create NAME [--slug SLUG] [--project PROJECT]
60
+ secrets envs update ENVIRONMENT [--name NAME] [--slug SLUG] [--project PROJECT]
61
+ secrets envs delete ENVIRONMENT [--project PROJECT]
62
+ secrets envs pull ENVIRONMENT [--project PROJECT]
63
+ ```
64
+
65
+ For `envs list`, use either positional `PROJECT` or `--project`, never both. `update` requires at least one of `--name` or `--slug`. Create derives a kebab-case slug from `NAME` when `--slug` is absent.
66
+
67
+ ## Files
68
+
69
+ ```text
70
+ secrets files list ENVIRONMENT [--project PROJECT]
71
+ secrets files create PATH --env ENVIRONMENT [--name NAME] [--project PROJECT]
72
+ secrets files update FILE [--env ENVIRONMENT] [--name NAME] [--path PATH] [--project PROJECT]
73
+ secrets files delete FILE [--env ENVIRONMENT] [--project PROJECT]
74
+ secrets files pull FILE [--env ENVIRONMENT] [--project PROJECT]
75
+ ```
76
+
77
+ Files are dotenv format. Create requires `--env`; its display name defaults to the basename of `PATH`. Update requires at least one of `--name` or `--path`.
78
+
79
+ ## Values
80
+
81
+ `values` is preferred:
82
+
83
+ ```text
84
+ secrets values list FILE [--env ENVIRONMENT] [--project PROJECT]
85
+ secrets values get FILE KEY [--env ENVIRONMENT] [--project PROJECT]
86
+ secrets values put FILE KEY [VALUE] [--stdin] [--env ENVIRONMENT] [--project PROJECT]
87
+ secrets values set FILE KEY [VALUE] [--stdin] [--env ENVIRONMENT] [--project PROJECT]
88
+ secrets values update FILE KEY [VALUE] [--stdin] [--env ENVIRONMENT] [--project PROJECT]
89
+ secrets values delete FILE KEY [--env ENVIRONMENT] [--project PROJECT]
90
+ secrets values bulk-read FILE KEY... [--env ENVIRONMENT] [--project PROJECT]
91
+ secrets values bulk-upsert FILE [KEY=value...] [--stdin] [--env ENVIRONMENT] [--project PROJECT]
92
+ secrets values bulk-delete FILE KEY... [--env ENVIRONMENT] [--project PROJECT]
93
+ ```
94
+
95
+ `put` and `set` perform the same set operation. `update` targets an existing value. Each single-value mutation requires exactly one source: positional `VALUE` or `--stdin`. Bulk upsert requires exactly one source: one or more `KEY=value` arguments or newline-delimited stdin. Values may contain `=` because only the first `=` separates key from value.
96
+
97
+ `bulk-read` returns only the keys found, not their values. `get` intentionally prints one raw value; redirect or capture it safely and never echo it into agent output.
98
+
99
+ ## Compatibility Tree
100
+
101
+ Every `values` leaf and option above is also available under `secrets secrets`:
102
+
103
+ ```text
104
+ secrets secrets list|get|put|set|update|delete|bulk-read|bulk-upsert|bulk-delete ...
105
+ ```
106
+
107
+ Do not use the compatibility tree for new examples or automation.