@rengler33/prov 0.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.
Files changed (146) hide show
  1. package/README.md +314 -0
  2. package/dist/cli.d.ts +26 -0
  3. package/dist/cli.d.ts.map +1 -0
  4. package/dist/cli.js +381 -0
  5. package/dist/cli.js.map +1 -0
  6. package/dist/commands/agent.d.ts +107 -0
  7. package/dist/commands/agent.d.ts.map +1 -0
  8. package/dist/commands/agent.js +197 -0
  9. package/dist/commands/agent.js.map +1 -0
  10. package/dist/commands/agent.test.d.ts +5 -0
  11. package/dist/commands/agent.test.d.ts.map +1 -0
  12. package/dist/commands/agent.test.js +199 -0
  13. package/dist/commands/agent.test.js.map +1 -0
  14. package/dist/commands/constraint.d.ts +100 -0
  15. package/dist/commands/constraint.d.ts.map +1 -0
  16. package/dist/commands/constraint.js +763 -0
  17. package/dist/commands/constraint.js.map +1 -0
  18. package/dist/commands/constraint.test.d.ts +9 -0
  19. package/dist/commands/constraint.test.d.ts.map +1 -0
  20. package/dist/commands/constraint.test.js +470 -0
  21. package/dist/commands/constraint.test.js.map +1 -0
  22. package/dist/commands/graph.d.ts +99 -0
  23. package/dist/commands/graph.d.ts.map +1 -0
  24. package/dist/commands/graph.js +552 -0
  25. package/dist/commands/graph.js.map +1 -0
  26. package/dist/commands/graph.test.d.ts +2 -0
  27. package/dist/commands/graph.test.d.ts.map +1 -0
  28. package/dist/commands/graph.test.js +258 -0
  29. package/dist/commands/graph.test.js.map +1 -0
  30. package/dist/commands/impact.d.ts +83 -0
  31. package/dist/commands/impact.d.ts.map +1 -0
  32. package/dist/commands/impact.js +319 -0
  33. package/dist/commands/impact.js.map +1 -0
  34. package/dist/commands/impact.test.d.ts +2 -0
  35. package/dist/commands/impact.test.d.ts.map +1 -0
  36. package/dist/commands/impact.test.js +234 -0
  37. package/dist/commands/impact.test.js.map +1 -0
  38. package/dist/commands/init.d.ts +45 -0
  39. package/dist/commands/init.d.ts.map +1 -0
  40. package/dist/commands/init.js +94 -0
  41. package/dist/commands/init.js.map +1 -0
  42. package/dist/commands/init.test.d.ts +7 -0
  43. package/dist/commands/init.test.d.ts.map +1 -0
  44. package/dist/commands/init.test.js +174 -0
  45. package/dist/commands/init.test.js.map +1 -0
  46. package/dist/commands/integration.test.d.ts +10 -0
  47. package/dist/commands/integration.test.d.ts.map +1 -0
  48. package/dist/commands/integration.test.js +456 -0
  49. package/dist/commands/integration.test.js.map +1 -0
  50. package/dist/commands/mcp.d.ts +21 -0
  51. package/dist/commands/mcp.d.ts.map +1 -0
  52. package/dist/commands/mcp.js +616 -0
  53. package/dist/commands/mcp.js.map +1 -0
  54. package/dist/commands/mcp.test.d.ts +7 -0
  55. package/dist/commands/mcp.test.d.ts.map +1 -0
  56. package/dist/commands/mcp.test.js +132 -0
  57. package/dist/commands/mcp.test.js.map +1 -0
  58. package/dist/commands/plan.d.ts +218 -0
  59. package/dist/commands/plan.d.ts.map +1 -0
  60. package/dist/commands/plan.js +1307 -0
  61. package/dist/commands/plan.js.map +1 -0
  62. package/dist/commands/plan.test.d.ts +9 -0
  63. package/dist/commands/plan.test.d.ts.map +1 -0
  64. package/dist/commands/plan.test.js +569 -0
  65. package/dist/commands/plan.test.js.map +1 -0
  66. package/dist/commands/spec.d.ts +94 -0
  67. package/dist/commands/spec.d.ts.map +1 -0
  68. package/dist/commands/spec.js +635 -0
  69. package/dist/commands/spec.js.map +1 -0
  70. package/dist/commands/spec.test.d.ts +9 -0
  71. package/dist/commands/spec.test.d.ts.map +1 -0
  72. package/dist/commands/spec.test.js +407 -0
  73. package/dist/commands/spec.test.js.map +1 -0
  74. package/dist/commands/trace.d.ts +157 -0
  75. package/dist/commands/trace.d.ts.map +1 -0
  76. package/dist/commands/trace.js +847 -0
  77. package/dist/commands/trace.js.map +1 -0
  78. package/dist/commands/trace.test.d.ts +9 -0
  79. package/dist/commands/trace.test.d.ts.map +1 -0
  80. package/dist/commands/trace.test.js +524 -0
  81. package/dist/commands/trace.test.js.map +1 -0
  82. package/dist/graph.d.ts +204 -0
  83. package/dist/graph.d.ts.map +1 -0
  84. package/dist/graph.js +496 -0
  85. package/dist/graph.js.map +1 -0
  86. package/dist/graph.test.d.ts +2 -0
  87. package/dist/graph.test.d.ts.map +1 -0
  88. package/dist/graph.test.js +382 -0
  89. package/dist/graph.test.js.map +1 -0
  90. package/dist/hash.d.ts +72 -0
  91. package/dist/hash.d.ts.map +1 -0
  92. package/dist/hash.js +137 -0
  93. package/dist/hash.js.map +1 -0
  94. package/dist/hash.test.d.ts +2 -0
  95. package/dist/hash.test.d.ts.map +1 -0
  96. package/dist/hash.test.js +227 -0
  97. package/dist/hash.test.js.map +1 -0
  98. package/dist/index.d.ts +18 -0
  99. package/dist/index.d.ts.map +1 -0
  100. package/dist/index.js +64 -0
  101. package/dist/index.js.map +1 -0
  102. package/dist/index.test.d.ts +2 -0
  103. package/dist/index.test.d.ts.map +1 -0
  104. package/dist/index.test.js +11 -0
  105. package/dist/index.test.js.map +1 -0
  106. package/dist/output.d.ts +84 -0
  107. package/dist/output.d.ts.map +1 -0
  108. package/dist/output.js +175 -0
  109. package/dist/output.js.map +1 -0
  110. package/dist/output.test.d.ts +7 -0
  111. package/dist/output.test.d.ts.map +1 -0
  112. package/dist/output.test.js +146 -0
  113. package/dist/output.test.js.map +1 -0
  114. package/dist/staleness.d.ts +162 -0
  115. package/dist/staleness.d.ts.map +1 -0
  116. package/dist/staleness.js +309 -0
  117. package/dist/staleness.js.map +1 -0
  118. package/dist/staleness.test.d.ts +2 -0
  119. package/dist/staleness.test.d.ts.map +1 -0
  120. package/dist/staleness.test.js +448 -0
  121. package/dist/staleness.test.js.map +1 -0
  122. package/dist/storage.d.ts +267 -0
  123. package/dist/storage.d.ts.map +1 -0
  124. package/dist/storage.js +623 -0
  125. package/dist/storage.js.map +1 -0
  126. package/dist/storage.test.d.ts +5 -0
  127. package/dist/storage.test.d.ts.map +1 -0
  128. package/dist/storage.test.js +434 -0
  129. package/dist/storage.test.js.map +1 -0
  130. package/dist/types.d.ts +270 -0
  131. package/dist/types.d.ts.map +1 -0
  132. package/dist/types.js +12 -0
  133. package/dist/types.js.map +1 -0
  134. package/dist/types.test.d.ts +2 -0
  135. package/dist/types.test.d.ts.map +1 -0
  136. package/dist/types.test.js +232 -0
  137. package/dist/types.test.js.map +1 -0
  138. package/dist/watcher.d.ts +139 -0
  139. package/dist/watcher.d.ts.map +1 -0
  140. package/dist/watcher.js +406 -0
  141. package/dist/watcher.js.map +1 -0
  142. package/dist/watcher.test.d.ts +5 -0
  143. package/dist/watcher.test.d.ts.map +1 -0
  144. package/dist/watcher.test.js +327 -0
  145. package/dist/watcher.test.js.map +1 -0
  146. package/package.json +53 -0
package/README.md ADDED
@@ -0,0 +1,314 @@
1
+ # prov
2
+
3
+ **Provenance-first planning CLI for AI agent workflows**
4
+
5
+ Prov creates and maintains an *intent graph* that tracks the complete provenance chain from high-level specifications through implementation decisions, plans, and code artifacts. When code becomes cheap to generate, the economics of software shift dramatically. Prov captures what matters most: the intent behind your system.
6
+
7
+ ## Philosophy
8
+
9
+ This project is inspired by [The Phoenix Architecture](https://aicoding.leaflet.pub/3mcbiyal7jc2y), which argues that in an era of generative AI, code is no longer scarce—it's abundant, fast, and increasingly disposable. The true assets become specifications, evaluations, and decision records, not the implementation itself.
10
+
11
+ **Core principles:**
12
+
13
+ - **Regenerable Systems**: Components can be deleted and recreated from stored intent while maintaining behavior guarantees
14
+ - **Provenance Over Code**: Specifications, constraints, and decisions are the durable artifacts; code is derived
15
+ - **Intent Graphs**: Meaning is encoded in content-addressed graphs capturing requirements, constraints, plans, and decisions
16
+ - **Evaluation-First**: Behavior is specified through durable evaluations (property tests, invariants, contracts) that survive implementation changes
17
+
18
+ ## Installation
19
+
20
+ ### From npm
21
+
22
+ ```bash
23
+ npm install -g prov
24
+ ```
25
+
26
+ ### From source
27
+
28
+ ```bash
29
+ git clone https://github.com/your-org/prov.git
30
+ cd prov
31
+ npm install
32
+ npm run build
33
+ ```
34
+
35
+ ### Single executable (Bun)
36
+
37
+ ```bash
38
+ npm run build:bun
39
+ # Creates ./bin/prov - a standalone executable
40
+ ```
41
+
42
+ **Requirements:** Node.js 18+
43
+
44
+ ## Quick Start
45
+
46
+ ```bash
47
+ # Initialize provenance tracking in your project
48
+ prov init
49
+
50
+ # Add a specification
51
+ prov spec add --file spec/authentication.spec.yaml
52
+
53
+ # Add constraints that must always hold
54
+ prov constraint add --file constraints/security.constraints.yaml
55
+
56
+ # Create a plan derived from specs
57
+ prov plan create --from spec:authentication --title "Implement OAuth2 flow"
58
+
59
+ # Execute plan steps and trace artifacts back to their origins
60
+ prov trace add --file src/auth/oauth.ts --step plan:abc123:step-1
61
+ ```
62
+
63
+ ## Core Concepts
64
+
65
+ ### Specifications
66
+ Declarative descriptions of *what* your system should do. Specs contain requirements that drive implementation.
67
+
68
+ ```yaml
69
+ # spec/authentication.spec.yaml
70
+ id: spec:authentication:v1
71
+ title: User Authentication
72
+ requirements:
73
+ - id: req:auth:1
74
+ description: Users must authenticate via OAuth2 or password
75
+ - id: req:auth:2
76
+ description: Sessions expire after 24 hours of inactivity
77
+ ```
78
+
79
+ ### Constraints
80
+ Invariants that must *always* hold, regardless of which requirements are being implemented.
81
+
82
+ ```yaml
83
+ # constraints/security.constraints.yaml
84
+ id: constraint:security:v1
85
+ invariants:
86
+ - id: inv:sec:1
87
+ description: Passwords must never be logged or stored in plaintext
88
+ - id: inv:sec:2
89
+ description: All API endpoints must require authentication
90
+ ```
91
+
92
+ ### Plans
93
+ Implementation roadmaps derived from specifications. Plans contain steps that can be executed and tracked.
94
+
95
+ ```bash
96
+ prov plan create --from spec:authentication --title "Implement OAuth2"
97
+ prov plan show plan:abc123
98
+ prov plan next plan:abc123 # Get the next step to work on
99
+ ```
100
+
101
+ ### Traces
102
+ Links between code artifacts and the plan steps (and ultimately specs/constraints) they implement.
103
+
104
+ ```bash
105
+ # Trace a file to a plan step
106
+ prov trace add --file src/auth/oauth.ts --step plan:abc123:step-1
107
+
108
+ # See why an artifact exists
109
+ prov trace why src/auth/oauth.ts
110
+
111
+ # Scan for untraced files
112
+ prov trace scan
113
+ ```
114
+
115
+ ### The Intent Graph
116
+ All entities form a directed acyclic graph (DAG) with cryptographic content addressing:
117
+
118
+ ```
119
+ Specifications ──→ Requirements
120
+ │ │
121
+ ↓ ↓
122
+ Constraints ───→ Plans ──→ Steps ──→ Traces ──→ Artifacts
123
+ │ │
124
+ ↓ ↓
125
+ Invariants Decisions
126
+ ```
127
+
128
+ ## Commands
129
+
130
+ For the complete CLI reference with all options and examples, see [docs/CLI.md](docs/CLI.md).
131
+
132
+ ### Initialization
133
+
134
+ | Command | Description |
135
+ |---------|-------------|
136
+ | `prov init` | Initialize provenance tracking in current directory |
137
+ | `prov init --force` | Reinitialize (recreates `.prov/` directory) |
138
+
139
+ ### Specifications
140
+
141
+ | Command | Description |
142
+ |---------|-------------|
143
+ | `prov spec add --file <path>` | Add a specification from YAML file |
144
+ | `prov spec list` | List all specifications |
145
+ | `prov spec validate` | Validate all specs against schema |
146
+
147
+ ### Constraints
148
+
149
+ | Command | Description |
150
+ |---------|-------------|
151
+ | `prov constraint add --file <path>` | Add constraints from YAML file |
152
+ | `prov constraint list` | List all constraints and invariants |
153
+ | `prov constraint check` | Check constraint compliance |
154
+
155
+ ### Plans
156
+
157
+ | Command | Description |
158
+ |---------|-------------|
159
+ | `prov plan create --from <spec-id> --title <title>` | Create a new plan |
160
+ | `prov plan show <plan-id>` | Show plan details and steps |
161
+ | `prov plan validate <plan-id>` | Validate plan structure |
162
+ | `prov plan next <plan-id>` | Get next incomplete step |
163
+ | `prov plan remaining <plan-id>` | List remaining steps |
164
+ | `prov plan progress <plan-id>` | Show completion progress |
165
+
166
+ ### Traces
167
+
168
+ | Command | Description |
169
+ |---------|-------------|
170
+ | `prov trace add --file <path> --step <step-id>` | Trace artifact to plan step |
171
+ | `prov trace show <file>` | Show trace information for a file |
172
+ | `prov trace why <file>` | Explain why an artifact exists |
173
+ | `prov trace scan` | Find untraced files in project |
174
+
175
+ ### Graph
176
+
177
+ | Command | Description |
178
+ |---------|-------------|
179
+ | `prov graph show` | Display the intent graph |
180
+ | `prov graph export --format <dot\|json>` | Export graph for visualization |
181
+ | `prov graph orphans` | Find disconnected nodes |
182
+
183
+ ### Analysis
184
+
185
+ | Command | Description |
186
+ |---------|-------------|
187
+ | `prov impact <entity-id>` | Analyze impact of changes to an entity |
188
+ | `prov stale` | Find artifacts that may be stale |
189
+
190
+ ### AI Agent Integration
191
+
192
+ | Command | Description |
193
+ |---------|-------------|
194
+ | `prov agent context` | Get context for AI agent consumption |
195
+ | `prov mcp` | Start Model Context Protocol server |
196
+
197
+ ## Output Formats
198
+
199
+ All commands support multiple output formats:
200
+
201
+ ```bash
202
+ prov spec list # Auto-detect (table for TTY, YAML for pipe)
203
+ prov spec list --format table # Human-readable table
204
+ prov spec list --format yaml # YAML for processing
205
+ prov spec list --format json # JSON for programmatic use
206
+ ```
207
+
208
+ ## MCP Server Integration
209
+
210
+ Prov includes a [Model Context Protocol](https://modelcontextprotocol.io) server for AI agent integration:
211
+
212
+ ```bash
213
+ prov mcp
214
+ ```
215
+
216
+ This exposes tools that allow AI agents to:
217
+ - Query the intent graph for context
218
+ - Create and manage plans
219
+ - Trace artifacts to their origins
220
+ - Check constraint compliance
221
+ - Identify stale or orphaned artifacts
222
+
223
+ ### MCP Configuration
224
+
225
+ Add to your MCP client configuration:
226
+
227
+ ```json
228
+ {
229
+ "mcpServers": {
230
+ "prov": {
231
+ "command": "prov",
232
+ "args": ["mcp"]
233
+ }
234
+ }
235
+ }
236
+ ```
237
+
238
+ ## Architecture
239
+
240
+ ```
241
+ ┌─────────────────────────────────────┐
242
+ │ CLI Commands (commands/) │
243
+ │ spec, constraint, plan, trace, etc │
244
+ └────────────┬────────────────────────┘
245
+
246
+ ┌────────────▼────────────────────────┐
247
+ │ Intent Graph (graph.ts) │
248
+ │ DAG of specs, plans, traces, etc │
249
+ └────────────┬────────────────────────┘
250
+
251
+ ┌────────────▼────────────────────────┐
252
+ │ Storage Layer (storage.ts) │
253
+ │ File I/O, locking, persistence │
254
+ └────────────┬────────────────────────┘
255
+
256
+ ┌────────────▼────────────────────────┐
257
+ │ Core Types & Utilities │
258
+ │ types.ts, hash.ts, output.ts │
259
+ └─────────────────────────────────────┘
260
+ ```
261
+
262
+ **Key design decisions:**
263
+ - **Content addressing**: All entities use SHA-256 hashes for change detection
264
+ - **File-based storage**: Graph persisted to `.prov/graph.json` for simplicity and git compatibility
265
+ - **Strict typing**: Full TypeScript with comprehensive type definitions
266
+ - **Schema validation**: Zod schemas ensure data integrity
267
+
268
+ ## Project Structure
269
+
270
+ ```
271
+ .prov/ # Provenance data directory (git-tracked)
272
+ ├── graph.json # The intent graph
273
+ └── mappings/ # File-to-trace mappings
274
+
275
+ spec/ # Your specifications (YAML)
276
+ constraints/ # Your constraints (YAML)
277
+ plans/ # Generated/managed plans
278
+ ```
279
+
280
+ ## Development
281
+
282
+ ```bash
283
+ npm run dev # Watch mode compilation
284
+ npm run test # Run tests in watch mode
285
+ npm run test:run # Run tests once
286
+ npm run lint # Lint code
287
+ npm run typecheck # Type check without emitting
288
+ npm run docs # Generate API documentation
289
+ npm run docs:watch # Generate docs in watch mode
290
+ ```
291
+
292
+ ### API Documentation
293
+
294
+ Generate API documentation from TypeScript source:
295
+
296
+ ```bash
297
+ npm run docs
298
+ ```
299
+
300
+ Documentation is output to `docs/api/`. Open `docs/api/index.html` in a browser to view.
301
+
302
+ ## Why Provenance?
303
+
304
+ When AI generates code, you need to know:
305
+ - **What** specification drove this implementation?
306
+ - **Why** was this decision made?
307
+ - **What** constraints must this code respect?
308
+ - **What** breaks if this spec changes?
309
+
310
+ Prov answers these questions by maintaining the complete derivation chain from intent to artifact. When your specs change, you know exactly which code needs regeneration.
311
+
312
+ ## License
313
+
314
+ MIT
package/dist/cli.d.ts ADDED
@@ -0,0 +1,26 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * prov CLI entry point
4
+ *
5
+ * A provenance-first planning CLI for AI agent workflows.
6
+ * This CLI serves two audiences: human developers managing specs
7
+ * and AI agents creating/executing plans.
8
+ *
9
+ * @see spec:cli-interface:v1
10
+ * @see dec:cli-framework (Commander.js)
11
+ */
12
+ import { type OutputFormat } from './output.js';
13
+ /**
14
+ * Global CLI options that apply to all commands.
15
+ */
16
+ export interface GlobalOptions {
17
+ /** Output format: table, yaml, or json */
18
+ format?: OutputFormat;
19
+ /** Enable verbose output */
20
+ verbose?: boolean;
21
+ /** Suppress non-essential output */
22
+ quiet?: boolean;
23
+ /** Project directory (defaults to cwd) */
24
+ dir?: string;
25
+ }
26
+ //# sourceMappingURL=cli.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA;;;;;;;;;GASG;AAIH,OAAO,EAAE,KAAK,YAAY,EAAgC,MAAM,aAAa,CAAC;AAkB9E;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,0CAA0C;IAC1C,MAAM,CAAC,EAAE,YAAY,CAAC;IACtB,4BAA4B;IAC5B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,oCAAoC;IACpC,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,0CAA0C;IAC1C,GAAG,CAAC,EAAE,MAAM,CAAC;CACd"}