forgium 0.1.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 (36) hide show
  1. package/README.md +300 -0
  2. package/dist/cli/index.d.ts +2 -0
  3. package/dist/cli/index.js +404 -0
  4. package/dist/core/domain/types.d.ts +190 -0
  5. package/dist/core/domain/types.js +1 -0
  6. package/dist/core/errors/forgium-errors.d.ts +53 -0
  7. package/dist/core/errors/forgium-errors.js +58 -0
  8. package/dist/core/execution/execution-adapter.d.ts +35 -0
  9. package/dist/core/execution/execution-adapter.js +25 -0
  10. package/dist/core/execution/pi-rpc-execution-adapter.d.ts +13 -0
  11. package/dist/core/execution/pi-rpc-execution-adapter.js +119 -0
  12. package/dist/core/execution/spec-flow-execution-adapter.d.ts +14 -0
  13. package/dist/core/execution/spec-flow-execution-adapter.js +233 -0
  14. package/dist/core/index.d.ts +11 -0
  15. package/dist/core/index.js +11 -0
  16. package/dist/core/repository/filesystem-forgium-repository.d.ts +68 -0
  17. package/dist/core/repository/filesystem-forgium-repository.js +656 -0
  18. package/dist/core/repository/paths.d.ts +10 -0
  19. package/dist/core/repository/paths.js +14 -0
  20. package/dist/core/repository/repo-discovery.d.ts +1 -0
  21. package/dist/core/repository/repo-discovery.js +17 -0
  22. package/dist/core/schemas/draft.schema.d.ts +44 -0
  23. package/dist/core/schemas/draft.schema.js +11 -0
  24. package/dist/core/schemas/inbox.schema.d.ts +23 -0
  25. package/dist/core/schemas/inbox.schema.js +9 -0
  26. package/dist/core/schemas/manifest.schema.d.ts +116 -0
  27. package/dist/core/schemas/manifest.schema.js +20 -0
  28. package/dist/core/schemas/receipt.schema.d.ts +355 -0
  29. package/dist/core/schemas/receipt.schema.js +54 -0
  30. package/dist/core/services/id.d.ts +4 -0
  31. package/dist/core/services/id.js +9 -0
  32. package/dist/core/services/spec-flow-commands.d.ts +6 -0
  33. package/dist/core/services/spec-flow-commands.js +7 -0
  34. package/dist/core/transitions/transition-rules.d.ts +3 -0
  35. package/dist/core/transitions/transition-rules.js +10 -0
  36. package/package.json +34 -0
package/README.md ADDED
@@ -0,0 +1,300 @@
1
+ # Forgium
2
+
3
+ Forgium is a repository-native workflow engine for software-development agents. It keeps a durable, reviewable queue of work in your repository: raw requests go to an Inbox, approved work becomes a Feature, and a Feature moves through execution, review, completion, or a blocker.
4
+
5
+ The repository is the source of truth. Forgium does not require a database or a hosted service.
6
+
7
+ Technical decisions and the staged implementation plan live in [docs/](docs/README.md).
8
+
9
+ ## Requirements
10
+
11
+ - Node.js 20 or later
12
+ - Git (optional; when present, Forgium uses it to discover the project root automatically)
13
+
14
+ ## Install
15
+
16
+ If Forgium has been published to your npm registry:
17
+
18
+ ```bash
19
+ npm install --global forgium
20
+ ```
21
+
22
+ To use this checkout during development:
23
+
24
+ ```bash
25
+ npm install
26
+ npm run build
27
+ npm link
28
+ ```
29
+
30
+ Confirm that the CLI is available:
31
+
32
+ ```bash
33
+ forgium --help
34
+ ```
35
+
36
+ ## Quick start
37
+
38
+ Run these commands from the root of the project you want Forgium to manage:
39
+
40
+ ```bash
41
+ # 1. Create the workflow directories.
42
+ forgium init
43
+
44
+ # 2. Capture an unprocessed request.
45
+ forgium capture "Add a WhatsApp contact button to the storefront"
46
+
47
+ # 3. Turn approved work into an executable Feature.
48
+ forgium feature create \
49
+ --title "Add WhatsApp contact button" \
50
+ --goal "Let storefront visitors contact the business on WhatsApp" \
51
+ --acceptance "A WhatsApp button is visible on the storefront" \
52
+ "The button opens the configured WhatsApp conversation"
53
+
54
+ # 4. Start the next ready Feature.
55
+ forgium work
56
+
57
+ # 5. After implementation, submit it for review and complete it.
58
+ forgium feature submit feature-add-whatsapp-contact-button
59
+ forgium review feature-add-whatsapp-contact-button
60
+ ```
61
+
62
+ Use `forgium status` at any time to see the number of Inbox items and Features in each state.
63
+
64
+ ## What Forgium creates
65
+
66
+ `forgium init` creates the following structure:
67
+
68
+ ```text
69
+ product/
70
+ └── inbox/ # Raw, untriaged requests
71
+
72
+ features/
73
+ ├── draft/ # Propuestas incompletas o pendientes de aprobación
74
+ ├── ready/ # Approved work waiting to start
75
+ ├── doing/ # Work in progress
76
+ ├── review/ # Work awaiting review
77
+ ├── blocked/ # Work that cannot proceed
78
+ └── done/ # Completed work
79
+ ```
80
+
81
+ It also adds `.forgium/runtime/` to `.gitignore`. Runtime leases created when work starts are local process metadata; the Inbox and Feature directories are intended to be committed to Git. The runtime directory is created only when it is needed.
82
+
83
+ Each Feature is a directory containing at least a `manifest.yaml`. You can add supporting artifacts to that directory, such as `spec.md`, `tickets/`, `notes.md`, or `research.md`.
84
+
85
+ ## Typical workflow
86
+
87
+ ### 1. Capture incoming work
88
+
89
+ Capture a short request directly:
90
+
91
+ ```bash
92
+ forgium capture "Add dark mode"
93
+ ```
94
+
95
+ For a multi-line request, pipe text to Forgium. The first line becomes the title and the remaining text becomes the body:
96
+
97
+ ```bash
98
+ printf '%s\n%s\n' \
99
+ 'Add dark mode' \
100
+ 'Respect the system preference and provide a manual toggle.' \
101
+ | forgium capture --source feedback
102
+ ```
103
+
104
+ `--source` identifies where the request came from; its default is `cli`.
105
+
106
+ List captured requests with:
107
+
108
+ ```bash
109
+ forgium inbox
110
+ ```
111
+
112
+ > In this version, Inbox triage and promotion are deliberate human/agent steps. `forgium capture` records raw intent; use `forgium feature create` when that intent has been approved and defined well enough to execute.
113
+
114
+ ### 2. Create a Feature
115
+
116
+ A Feature must have a title, a goal, and at least one acceptance criterion:
117
+
118
+ ```bash
119
+ forgium feature create \
120
+ --title "Export invoices as CSV" \
121
+ --goal "Allow finance users to download invoice data for reconciliation" \
122
+ --acceptance "Users can export filtered invoices as a CSV file" \
123
+ "The export includes invoice number, date, customer, and amount" \
124
+ --constraint "Do not change the existing invoice API"
125
+ ```
126
+
127
+ Forgium creates the Feature in `features/ready/`. Its ID is derived from the title (for example, `feature-export-invoices-as-csv`). Supply `--slug <slug>` when you need a different directory name and ID suffix:
128
+
129
+ ```bash
130
+ forgium feature create \
131
+ --slug invoice-csv-export \
132
+ --title "Export invoices as CSV" \
133
+ --goal "Enable invoice exports" \
134
+ --acceptance "A CSV export can be downloaded"
135
+ ```
136
+
137
+ List all Features or only one state:
138
+
139
+ ```bash
140
+ forgium feature list
141
+ forgium feature list --state ready
142
+ ```
143
+
144
+ ### 3. Execute work
145
+
146
+ Start the oldest ready Feature explicitly:
147
+
148
+ ```bash
149
+ forgium feature start feature-export-invoices-as-csv
150
+ ```
151
+
152
+ Or let Forgium select and start the next ready Feature:
153
+
154
+ ```bash
155
+ forgium work
156
+ ```
157
+
158
+ Starting a Feature moves it from `ready` to `doing` and creates a local runtime lease. `forgium work` also prints the execution profile:
159
+
160
+ - **direct** — implement the Feature directly with your agent or normal development workflow.
161
+ - **spec-needs-plan** — a `spec.md` exists but no `tickets/` directory exists. Forgium prints the `pi-spec-flow` command to plan tickets.
162
+ - **spec-flow** — both `spec.md` and `tickets/` exist. Forgium prints the command to continue implementation with `pi-spec-flow`.
163
+
164
+ You can inspect this profile without starting work:
165
+
166
+ ```bash
167
+ forgium feature profile feature-export-invoices-as-csv
168
+ ```
169
+
170
+ For a Feature containing `spec.md`, the suggested Pi commands are:
171
+
172
+ ```text
173
+ /spec-flow-init <path-to-spec.md>
174
+ /spec-flow-implement <path-to-spec.md>
175
+ /spec-flow-next <path-to-spec.md>
176
+ ```
177
+
178
+ ### Ejecución automatizada opt-in
179
+
180
+ `forgium run` puede delegar la implementación a Pi. Elige el engine de forma
181
+ explícita; Forgium conserva los receipts, la verificación y la transición a
182
+ `review`.
183
+
184
+ ```bash
185
+ # Features directas.
186
+ forgium run --engine pi
187
+
188
+ # Features con spec.md y tickets/.
189
+ # Requiere que Pi tenga pi-spec-flow >= 0.4.8 instalado.
190
+ forgium run --engine pi-spec-flow
191
+ ```
192
+
193
+ El adapter de Spec Flow responde la confirmación del ticket ya seleccionado,
194
+ pero no aprueba el trabajo: una Feature completada sigue necesitando la review
195
+ explícita de Forgium para llegar a `done`.
196
+
197
+ El smoke test real es opt-in y usa el modelo configurado por defecto en Pi, por
198
+ lo que puede consumir tokens:
199
+
200
+ ```bash
201
+ npm run test:e2e:pi
202
+ ```
203
+
204
+ ### 4. Review, complete, or unblock
205
+
206
+ When implementation is ready, send the Feature to review:
207
+
208
+ ```bash
209
+ forgium feature submit feature-export-invoices-as-csv
210
+ ```
211
+
212
+ After review, use one of the following:
213
+
214
+ ```bash
215
+ # Approve and move review → done.
216
+ forgium review feature-export-invoices-as-csv
217
+
218
+ # Send review → doing for another implementation pass.
219
+ forgium review feature-export-invoices-as-csv --fail
220
+
221
+ # Record a blocker and move doing/review → blocked.
222
+ forgium feature block feature-export-invoices-as-csv \
223
+ --reason "Awaiting approval from the finance team"
224
+
225
+ # Equivalent review-time blocker command.
226
+ forgium review feature-export-invoices-as-csv \
227
+ --block "Awaiting approval from the finance team"
228
+
229
+ # Once resolved, move blocked → ready.
230
+ forgium feature unblock feature-export-invoices-as-csv
231
+ ```
232
+
233
+ Blocking appends the reason and timestamp to the Feature's `notes.md`.
234
+
235
+ ## Feature lifecycle
236
+
237
+ Forgium enforces these transitions:
238
+
239
+ ```text
240
+ ready → doing → review → done
241
+ ↘ ↙
242
+ blocked → ready
243
+
244
+ review → doing (review needs more work)
245
+ ```
246
+
247
+ A completed Feature cannot be moved to another state through the CLI. Use Feature IDs or directory slugs with lifecycle commands; both are accepted.
248
+
249
+ ## Command reference
250
+
251
+ | Command | Purpose |
252
+ | --- | --- |
253
+ | `forgium init` | Initialize the Inbox, Draft, and Feature state directories. |
254
+ | `forgium capture [text...]` | Save a raw Inbox item. Reads piped standard input when no text is supplied. |
255
+ | `forgium inbox` | List Inbox items. |
256
+ | `forgium triage [--non-interactive] [--edit] [--dry-run]` | Resolve Drafts and triage captured Inbox items. |
257
+ | `forgium run [--max-features <n> | --until-empty] [--engine pi|pi-spec-flow]` | Run the bounded repository loop. Agent execution is opt-in. |
258
+ | `npm run test:e2e:pi` | Run the opt-in real Pi + `pi-spec-flow` smoke test using Pi's configured default model. |
259
+ | `forgium status` | Show counts by Inbox, Draft, and Feature state. |
260
+ | `forgium validate` | Validate required directories and Inbox/Draft/Feature file schemas. Returns exit code `2` when invalid. |
261
+ | `forgium feature create ...` | Create a ready Feature. |
262
+ | `forgium feature list [--state <state>]` | List Features, optionally filtering by `ready`, `doing`, `review`, `blocked`, or `done`. |
263
+ | `forgium feature start <id>` | Move `ready` → `doing`. |
264
+ | `forgium feature submit <id>` | Move `doing` → `review`. |
265
+ | `forgium feature complete <id>` | Move `review` → `done`. |
266
+ | `forgium feature block <id> --reason <reason>` | Move `doing` or `review` → `blocked` and record the reason. |
267
+ | `forgium feature unblock <id>` | Move `blocked` → `ready`. |
268
+ | `forgium feature profile <id>` | Show whether a Feature is direct or `pi-spec-flow` work. |
269
+ | `forgium feature verify <id>` | Run configured checks and record a verification receipt. |
270
+ | `forgium work` | Start the next ready Feature and show its execution profile. |
271
+ | `forgium review <id> [--fail \| --block <reason>]` | Complete a Feature in review, return it to `doing`, or block it. |
272
+
273
+ Run `forgium <command> --help` for the CLI's current argument and option details.
274
+
275
+ ## Global options and automation
276
+
277
+ Pass `--root <path>` to operate on a specific project rather than the current Git repository:
278
+
279
+ ```bash
280
+ forgium --root /path/to/project status
281
+ ```
282
+
283
+ Pass `--json` to emit machine-readable results, which is useful for scripts and agents:
284
+
285
+ ```bash
286
+ forgium --json status
287
+ forgium --json feature list --state ready
288
+ ```
289
+
290
+ When Forgium reports an error in JSON mode, it writes an object with an error code and message to standard error.
291
+
292
+ ## Validate before committing
293
+
294
+ Run validation after manually editing Inbox items, Feature manifests, or Feature artifacts:
295
+
296
+ ```bash
297
+ forgium validate
298
+ ```
299
+
300
+ Commit the resulting `product/` and `features/` changes with the work they describe, so the queue and lifecycle remain portable and auditable.
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};