mrvn-cli 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.
package/README.md ADDED
@@ -0,0 +1,439 @@
1
+ # Marvin CLI
2
+
3
+ AI-powered product development assistant. Marvin provides three expert personas — **Product Owner**, **Delivery Manager**, and **Technical Lead** — that help teams manage features, epics, decisions, actions, questions, and meetings through an interactive CLI backed by Claude.
4
+
5
+ ## Quick Start
6
+
7
+ ```bash
8
+ # Install dependencies
9
+ npm install
10
+
11
+ # Initialize a project
12
+ npx tsx bin/marvin.ts init
13
+
14
+ # Check project status
15
+ npx tsx bin/marvin.ts status
16
+
17
+ # Start a chat session
18
+ npx tsx bin/marvin.ts chat --as po # Product Owner
19
+ npx tsx bin/marvin.ts chat --as dm # Delivery Manager
20
+ npx tsx bin/marvin.ts chat --as tl # Technical Lead
21
+ ```
22
+
23
+ ## How It Works
24
+
25
+ Marvin stores all project governance data as **Markdown files with YAML frontmatter** inside a `.marvin/` directory. Each artifact gets its own file with an auto-incrementing ID (`F-001`, `E-001`, `D-001`, `A-002`, `Q-003`). This makes everything human-readable, Git-friendly, and Obsidian-compatible.
26
+
27
+ When you start a chat session, Marvin:
28
+
29
+ 1. Loads a persona-specific system prompt (Product Owner focuses on value and stakeholders; Delivery Manager on risks and status; Tech Lead on architecture and quality)
30
+ 2. Exposes your project's governance data as **MCP tools** that Claude can call
31
+ 3. Starts an interactive conversation where the agent can read, create, and update project artifacts
32
+
33
+ ```
34
+ .marvin/
35
+ ├── config.yaml # Project configuration
36
+ ├── sessions.yaml # Saved chat sessions
37
+ ├── templates/ # Document templates
38
+ ├── sources/ # Source documents for ingestion
39
+ │ ├── .manifest.yaml # Tracks processing state
40
+ │ ├── Requirements.pdf # Source document
41
+ │ └── Architecture Notes.md # Source document
42
+ └── docs/
43
+ ├── features/ # F-001.md, F-002.md, ...
44
+ ├── epics/ # E-001.md, E-002.md, ...
45
+ ├── decisions/ # D-001.md, D-002.md, ...
46
+ ├── actions/ # A-001.md, A-002.md, ...
47
+ ├── questions/ # Q-001.md, Q-002.md, ...
48
+ ├── meetings/ # 2026-02-08-kickoff.md, ...
49
+ ├── reports/ # R-001.md, R-002.md, ...
50
+ ├── use-cases/ # UC-001.md, UC-002.md, ... (SAP AEM)
51
+ ├── tech-assessments/ # TA-001.md, TA-002.md, ... (SAP AEM)
52
+ └── extension-designs/ # XD-001.md, XD-002.md, ... (SAP AEM)
53
+ ```
54
+
55
+ ## Methodologies
56
+
57
+ Marvin supports pluggable methodologies. Choose one during `marvin init`:
58
+
59
+ ### Generic Agile (default)
60
+
61
+ Standard agile governance with features, epics, decisions, actions, questions, meetings, and reports.
62
+
63
+ ### SAP Application Extension Methodology (SAP AEM)
64
+
65
+ A 3-phase methodology for building extensions on SAP BTP:
66
+
67
+ | Phase | Name | Focus | Artifacts |
68
+ |-------|------|-------|-----------|
69
+ | 1 | **Assess Extension Use Case** | Define and justify business scenarios | Use Cases (UC-xxx) |
70
+ | 2 | **Assess Extension Technology** | Evaluate BTP technologies and extension points | Tech Assessments (TA-xxx) |
71
+ | 3 | **Define Extension Target Solution** | Design the extension architecture | Extension Designs (XD-xxx) |
72
+
73
+ **How it layers with core capabilities:**
74
+
75
+ ```
76
+ Layer 1 — Core: decisions, actions, questions (always available)
77
+ Layer 2 — Common: meetings, reports, features, epics (shared across methodologies)
78
+ Layer 3 — Methodology: use-cases, tech-assessments, (sap-aem specific)
79
+ extension-designs, phase management
80
+ ```
81
+
82
+ **Persona roles in AEM:**
83
+
84
+ | Persona | AEM Role | Owns | Phase Focus |
85
+ |---------|----------|------|-------------|
86
+ | Product Owner | Business Process Owner | Use Cases (UC-xxx) | Phase 1: define business need, classify extension type |
87
+ | Tech Lead | Solution Architect | Tech Assessments (TA-xxx), Extension Designs (XD-xxx) | Phase 2-3: evaluate BTP services, design solution |
88
+ | Delivery Manager | Project Manager | Phase gates, reports | All phases: track progression, gate readiness |
89
+
90
+ **Artifact chain with hard validation:**
91
+
92
+ ```
93
+ Use Case (PO) Tech Assessment (TL) Extension Design (TL)
94
+ ┌──────────┐ ┌──────────────────┐ ┌──────────────────────┐
95
+ │ UC-001 │───▶│ TA-001 │───▶│ XD-001 │
96
+ │ assessed │ │ linked: UC-001 │ │ linked: TA-001 │
97
+ └──────────┘ │ recommended │ │ architecture: │
98
+ └──────────────────┘ │ event-driven │
99
+ └──────────────────────┘
100
+ ```
101
+
102
+ - Tech assessments require an **assessed or approved** use case
103
+ - Extension designs require a **recommended** tech assessment
104
+ - Phase advancement has **soft gates** — warnings, not blocks
105
+
106
+ **Switching methodologies:** Change `methodology` in `.marvin/config.yaml`. Existing files stay on disk. Common tools (meetings, features, epics, reports) remain available. Only methodology-specific CRUD tools are gained/lost.
107
+
108
+ ## Commands
109
+
110
+ | Command | Description |
111
+ |---------|-------------|
112
+ | `marvin init` | Create a `.marvin/` project (includes methodology picker) |
113
+ | `marvin chat --as <persona>` | Start an interactive session (`po`, `dm`, `tl`) |
114
+ | `marvin status` | Show document counts and open items |
115
+ | `marvin config [key] [value]` | View or set configuration |
116
+ | `marvin import <path>` | Import documents or sources from external paths |
117
+ | `marvin import <path> --dry-run` | Preview import plan without writing files |
118
+ | `marvin ingest [file]` | Process source documents into governance artifacts |
119
+ | `marvin ingest --all` | Process all unprocessed source files |
120
+ | `marvin config api-key` | Securely set your Anthropic API key |
121
+ | `marvin sync` | Stage, commit, pull, and push governance data |
122
+ | `marvin sync init [--remote <url>]` | Initialize a git repo inside `.marvin/` |
123
+ | `marvin sync status` | Show branch, remote, and changed files |
124
+ | `marvin sync remote <url>` | Set or update the remote repository URL |
125
+ | `marvin clone <url> [dir]` | Clone governance data from a remote repo |
126
+ | `marvin chat --resume` | Resume a past session (interactive picker) |
127
+ | `marvin chat --resume <name>` | Resume a specific session by name |
128
+ | `marvin sessions` | List all saved chat sessions |
129
+ | `marvin sessions delete <name>` | Delete a saved session |
130
+ | `marvin serve` | Start standalone MCP server for Claude Desktop/Code |
131
+
132
+ ## Personas
133
+
134
+ | Short Name | Full Name | Focus |
135
+ |------------|-----------|-------|
136
+ | `po` | Product Owner | Product vision, feature definition and prioritization, stakeholder needs, acceptance criteria |
137
+ | `dm` | Delivery Manager | Project delivery, epic scheduling and tracking, risk management, governance, meeting facilitation |
138
+ | `tl` | Technical Lead | Architecture, epic creation and scoping, code quality, technical decisions, implementation guidance |
139
+
140
+ Each persona has a tuned system prompt that shapes how Claude approaches your project. The agent has access to governance tools for managing features, epics, decisions, actions, questions, meetings, and reports — plus methodology-specific tools when a plugin is active.
141
+
142
+ ## Feature → Epic Workflow
143
+
144
+ Marvin enforces a structured product development workflow:
145
+
146
+ 1. **Product Owner** defines features (`F-xxx`) as `draft`, then approves them when requirements are clear
147
+ 2. **Tech Lead** breaks approved features into implementation epics (`E-xxx`) — the system **enforces** that epics can only be created against approved features
148
+ 3. **Delivery Manager** sets target dates on epics and tracks progress across features and epics
149
+
150
+ ```
151
+ Feature (PO) Epic (TL) Work Items
152
+ ┌──────────┐ ┌──────────────┐ ┌──────────────────────┐
153
+ │ F-001 │───▶│ E-001 │───▶│ A-001 (epic:E-001) │
154
+ │ approved │ │ linked: F-001│ │ D-003 (epic:E-001) │
155
+ └──────────┘ ├──────────────┤ └──────────────────────┘
156
+ │ E-002 │
157
+ │ linked: F-001│
158
+ └──────────────┘
159
+ ```
160
+
161
+ This provides **hard enforcement** (epics must link to approved features) combined with **soft guidance** (persona prompts steer each role toward their responsibilities).
162
+
163
+ ## Configuration
164
+
165
+ Marvin uses two configuration layers:
166
+
167
+ - **User config** (`~/.config/marvin/config.yaml`) — API key, default model, default persona
168
+ - **Project config** (`.marvin/config.yaml`) — Project name, methodology, persona overrides
169
+
170
+ The API key resolves in order: user config > `ANTHROPIC_API_KEY` environment variable.
171
+
172
+ **Example project config (SAP AEM):**
173
+
174
+ ```yaml
175
+ name: my-btp-project
176
+ methodology: sap-aem
177
+ aem:
178
+ currentPhase: assess-use-case
179
+ personas:
180
+ product-owner:
181
+ enabled: true
182
+ delivery-manager:
183
+ enabled: true
184
+ tech-lead:
185
+ enabled: true
186
+ ```
187
+
188
+ ## Import
189
+
190
+ `marvin import` brings external data into your project. It auto-detects what you're pointing at and does the right thing:
191
+
192
+ | Input | What happens |
193
+ |-------|-------------|
194
+ | Another `.marvin/` project (or dir with `config.yaml`) | Imports all governance documents from its `docs/` subdirectories |
195
+ | Directory with `decisions/`, `actions/`, etc. | Imports markdown documents directly |
196
+ | A `.md` file with valid Marvin frontmatter (`id` + `type`) | Imports as a single governance artifact |
197
+ | Directory with PDFs, text files, or unstructured markdown | Copies to `.marvin/sources/` |
198
+ | A single PDF or TXT file | Copies to `.marvin/sources/` |
199
+
200
+ ### Basic usage
201
+
202
+ ```bash
203
+ # Preview what will happen (no files written)
204
+ marvin import ./proto-governance --dry-run
205
+
206
+ # Import governance documents from another directory
207
+ marvin import ./proto-governance
208
+
209
+ # Import a single Marvin-format document
210
+ marvin import ./exported/D-001.md
211
+
212
+ # Import from another Marvin project
213
+ marvin import ../other-project/.marvin
214
+
215
+ # Import raw source files (PDFs, text) into sources/
216
+ marvin import ./reference-docs
217
+ ```
218
+
219
+ ### Handling ID conflicts
220
+
221
+ When an imported document has the same ID as an existing one, the `--conflict` option controls behavior:
222
+
223
+ ```bash
224
+ # Renumber conflicting IDs (default) — D-001 becomes D-004, etc.
225
+ marvin import ./docs --conflict renumber
226
+
227
+ # Skip documents that conflict
228
+ marvin import ./docs --conflict skip
229
+
230
+ # Overwrite existing documents
231
+ marvin import ./docs --conflict overwrite
232
+ ```
233
+
234
+ When renumbering, cross-references within document content are updated automatically (e.g. "See D-001" becomes "See D-004").
235
+
236
+ ### Tagging imports
237
+
238
+ Add a tag to all imported documents for traceability:
239
+
240
+ ```bash
241
+ marvin import ./proto-governance --tag imported:proto
242
+ ```
243
+
244
+ ### Importing and ingesting in one step
245
+
246
+ When importing raw source files (PDFs, text), use `--ingest` to immediately process them with AI analysis:
247
+
248
+ ```bash
249
+ # Copy files to sources/ and then run ingest on each
250
+ marvin import ./reference-docs --ingest
251
+
252
+ # Use a specific persona and create artifacts directly
253
+ marvin import ./reference-docs --ingest --as tl --no-draft
254
+ ```
255
+
256
+ ### Options reference
257
+
258
+ | Option | Description | Default |
259
+ |--------|-------------|---------|
260
+ | `--dry-run` | Preview the import plan without writing files | off |
261
+ | `--conflict <strategy>` | How to handle ID conflicts: `renumber`, `skip`, `overwrite` | `renumber` |
262
+ | `--tag <tag>` | Tag added to all imported documents | none |
263
+ | `--ingest` / `--no-ingest` | Trigger AI ingest after copying raw sources | off |
264
+ | `--as <persona>` | Persona for ingest (`po`, `dm`, `tl`) | `product-owner` |
265
+ | `--draft` / `--no-draft` | Draft mode for ingest (propose vs. create) | `--draft` |
266
+
267
+ ## Sources & Ingest
268
+
269
+ Marvin supports a **source document intake** workflow. Drop reference documents (PDFs, Markdown, text files) into `.marvin/sources/` and use the `ingest` command to extract governance artifacts.
270
+
271
+ ```bash
272
+ # Check what source files are available
273
+ marvin ingest
274
+
275
+ # Process a specific file (draft mode — proposes without creating)
276
+ marvin ingest Requirements.pdf
277
+
278
+ # Process and create artifacts directly
279
+ marvin ingest Requirements.pdf --no-draft
280
+
281
+ # Process all unprocessed files
282
+ marvin ingest --all
283
+
284
+ # Use a specific persona for analysis
285
+ marvin ingest --all --as tl
286
+ ```
287
+
288
+ **Draft mode** (default): Claude analyzes the document and presents a structured proposal of decisions, actions, and questions — nothing is created. Review the proposal, then use `--no-draft` or `marvin chat` to refine and create.
289
+
290
+ **Direct mode** (`--no-draft`): Claude creates artifacts directly using MCP tools. Each artifact gets a `source` frontmatter field for traceability.
291
+
292
+ The `.manifest.yaml` file in `sources/` tracks processing state — which files have been processed, which artifacts were created, and any errors.
293
+
294
+ ## Git Sync
295
+
296
+ Marvin's governance data lives in `.marvin/`, which can be its own **standalone git repository** — independent from your outer project's git. This lets teams share decisions, features, epics, and other artifacts across members.
297
+
298
+ ```bash
299
+ # Initialize git tracking in .marvin/
300
+ marvin sync init
301
+
302
+ # Optionally set a remote
303
+ marvin sync init --remote git@github.com:team/governance.git
304
+
305
+ # Check what's changed
306
+ marvin sync status
307
+
308
+ # Sync everything (stage → commit → pull --rebase → push)
309
+ marvin sync
310
+
311
+ # On another machine, clone the governance data
312
+ marvin clone git@github.com:team/governance.git
313
+ ```
314
+
315
+ Commit messages are auto-generated based on what changed (e.g. `Update 2 decisions, 1 action, 1 feature`). If a rebase encounters conflicts, Marvin reports the conflicted files and asks you to resolve them manually before re-running `marvin sync`.
316
+
317
+ > **Tip:** Add `.marvin/` to your outer project's `.gitignore` to avoid tracking it twice.
318
+
319
+ ## MCP Server Mode
320
+
321
+ Marvin can run as a standalone **MCP server** so Claude Desktop and Claude Code can use governance tools directly — without going through `marvin chat`.
322
+
323
+ ```bash
324
+ # Via the serve command (from within a Marvin project)
325
+ marvin serve
326
+
327
+ # Via the standalone binary (specify project dir)
328
+ marvin-serve --project-dir /path/to/project
329
+ ```
330
+
331
+ **Claude Code** — add to `.mcp.json` in your project root:
332
+
333
+ ```json
334
+ {
335
+ "mcpServers": {
336
+ "marvin": {
337
+ "command": "npx",
338
+ "args": ["marvin", "serve"]
339
+ }
340
+ }
341
+ }
342
+ ```
343
+
344
+ **Claude Desktop** — add to `~/Library/Application Support/Claude/claude_desktop_config.json`:
345
+
346
+ ```json
347
+ {
348
+ "mcpServers": {
349
+ "marvin": {
350
+ "command": "npx",
351
+ "args": ["marvin-serve", "--project-dir", "/path/to/project"]
352
+ }
353
+ }
354
+ }
355
+ ```
356
+
357
+ ## Session Persistence
358
+
359
+ Every chat session is **automatically saved** when you exit. Marvin uses the Claude Agent SDK's built-in session persistence and generates an AI-powered name for each session (e.g. `jwt-auth-decision`, `sprint-3-planning`).
360
+
361
+ ```bash
362
+ # Start a new session — auto-saved on exit
363
+ marvin chat --as po
364
+
365
+ # → On exit: Session saved as "graphql-vs-rest-decision"
366
+
367
+ # List saved sessions
368
+ marvin sessions
369
+
370
+ # Resume via interactive picker
371
+ marvin chat --resume
372
+
373
+ # Resume a specific session by name
374
+ marvin chat --resume graphql-vs-rest-decision
375
+
376
+ # Delete a session
377
+ marvin sessions delete graphql-vs-rest-decision
378
+ ```
379
+
380
+ Session metadata (name, persona, timestamps, turn count) is stored in `.marvin/sessions.yaml`. The agent also has read-only MCP access to session history — it can reference what was discussed in previous sessions for continuity.
381
+
382
+ ## Architecture
383
+
384
+ ```
385
+ bin/marvin.ts → CLI entry point
386
+ bin/marvin-serve.ts → Standalone MCP server entry point
387
+ src/cli/program.ts → Commander command definitions
388
+ src/core/ → Project discovery, config, errors
389
+ src/storage/ → Extensible document store (Markdown + YAML frontmatter)
390
+ src/personas/ → Persona definitions, registry, prompt builder
391
+ src/agent/ → Claude Agent SDK integration, MCP tools
392
+ src/mcp/ → Standalone MCP stdio server adapter
393
+ src/plugins/ → Plugin system (methodology plugins)
394
+ ├── types.ts → MarvinPlugin interface
395
+ ├── common.ts → Shared registrations + tool factory (meetings, reports, features, epics)
396
+ ├── registry.ts → Plugin resolution
397
+ └── builtin/
398
+ ├── generic-agile.ts → Default methodology
399
+ ├── sap-aem.ts → SAP AEM methodology
400
+ └── tools/ → Tool implementations per artifact type
401
+ src/import/ → Import engine (classifier, resolver, plan/execute)
402
+ src/skills/ → Custom skill definitions
403
+ src/git/ → Git sync (simple-git wrapper for .marvin/)
404
+ ```
405
+
406
+ Key design decisions:
407
+
408
+ - **One file per artifact** — Better for Git merges and human readability than a single register file
409
+ - **System prompt composition** — Personas are behavioral modes (different system prompts), not separate agents
410
+ - **MCP tools for data access** — The agent calls tools to read/write governance data, keeping AI reasoning separate from data operations
411
+ - **Extensible storage** — `DocumentStore` accepts plugin-registered types at construction time; `DocumentType` is `string`, not a fixed union
412
+ - **Layered capabilities** — Core governance is always available, common tools are shared across methodologies, methodology-specific tools layer on top
413
+
414
+ ## Development
415
+
416
+ ```bash
417
+ npm run build # Build with tsup
418
+ npm run dev # Run via tsx (no build needed)
419
+ npm test # Run tests with vitest
420
+ npm run test:watch # Watch mode
421
+ npm run typecheck # TypeScript check without emitting
422
+ ```
423
+
424
+ ## Tech Stack
425
+
426
+ | Component | Choice |
427
+ |-----------|--------|
428
+ | Language | TypeScript (ESM, Node 20+) |
429
+ | Agent SDK | `@anthropic-ai/claude-agent-sdk` |
430
+ | CLI | Commander.js v14 |
431
+ | Storage | Markdown + YAML frontmatter (`gray-matter`) |
432
+ | Config | YAML (`yaml` package) |
433
+ | Git sync | `simple-git` |
434
+ | Testing | Vitest |
435
+ | Build | tsup |
436
+
437
+ ## License
438
+
439
+ MIT