@mod-computer/cli 0.1.1 → 0.2.2

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 (55) hide show
  1. package/README.md +98 -76
  2. package/dist/cli.bundle.js +23750 -12931
  3. package/dist/cli.bundle.js.map +4 -4
  4. package/dist/cli.js +23 -12
  5. package/dist/commands/add.js +245 -0
  6. package/dist/commands/auth.js +129 -21
  7. package/dist/commands/comment.js +568 -0
  8. package/dist/commands/diff.js +182 -0
  9. package/dist/commands/index.js +33 -3
  10. package/dist/commands/init.js +475 -221
  11. package/dist/commands/ls.js +135 -0
  12. package/dist/commands/members.js +687 -0
  13. package/dist/commands/mv.js +282 -0
  14. package/dist/commands/rm.js +257 -0
  15. package/dist/commands/status.js +273 -306
  16. package/dist/commands/sync.js +99 -75
  17. package/dist/commands/trace.js +1752 -0
  18. package/dist/commands/workspace.js +354 -330
  19. package/dist/config/features.js +18 -7
  20. package/dist/config/release-profiles/development.json +4 -1
  21. package/dist/config/release-profiles/mvp.json +4 -2
  22. package/dist/daemon/conflict-resolution.js +172 -0
  23. package/dist/daemon/content-hash.js +31 -0
  24. package/dist/daemon/file-sync.js +985 -0
  25. package/dist/daemon/index.js +203 -0
  26. package/dist/daemon/mime-types.js +166 -0
  27. package/dist/daemon/offline-queue.js +211 -0
  28. package/dist/daemon/path-utils.js +64 -0
  29. package/dist/daemon/share-policy.js +83 -0
  30. package/dist/daemon/wasm-errors.js +189 -0
  31. package/dist/daemon/worker.js +557 -0
  32. package/dist/daemon-worker.js +3 -2
  33. package/dist/errors/workspace-errors.js +48 -0
  34. package/dist/lib/auth-server.js +89 -26
  35. package/dist/lib/browser.js +1 -1
  36. package/dist/lib/diff.js +284 -0
  37. package/dist/lib/formatters.js +204 -0
  38. package/dist/lib/git.js +137 -0
  39. package/dist/lib/local-fs.js +201 -0
  40. package/dist/lib/prompts.js +23 -83
  41. package/dist/lib/storage.js +11 -1
  42. package/dist/lib/trace-formatters.js +314 -0
  43. package/dist/services/add-service.js +554 -0
  44. package/dist/services/add-validation.js +124 -0
  45. package/dist/services/mod-config.js +8 -2
  46. package/dist/services/modignore-service.js +2 -0
  47. package/dist/stores/use-workspaces-store.js +36 -14
  48. package/dist/types/add-types.js +99 -0
  49. package/dist/types/config.js +1 -1
  50. package/dist/types/workspace-connection.js +53 -2
  51. package/package.json +7 -5
  52. package/commands/execute.md +0 -156
  53. package/commands/overview.md +0 -233
  54. package/commands/review.md +0 -151
  55. package/commands/spec.md +0 -169
package/README.md CHANGED
@@ -1,106 +1,142 @@
1
1
  # mod-cli
2
2
 
3
- ## Intro
3
+ Spec-driven development with traceability. Connect your specs, code, and tests so reviews show the full picture.
4
4
 
5
- mod-cli is the local sync agent for Mod, a collaboration layer for teams working with coding agents.
5
+ ## Quick Start
6
6
 
7
- Coding agents operate on local filesystems. They read specs, write code, and generate metadata (traces, reasoning, todos). But collaboration happens elsewhere: in GitHub PRs, Notion docs, Slack threads. The result: context lives in silos. Agents can't access specs being discussed in the browser. Teammates can't see agent reasoning. Reviews happen without the full picture.
8
-
9
- mod-cli bridges local and collaborative workflows. It syncs the local filesystem to Mod workspaces in real-time, making local changes visible to collaborators and remote edits available to agents. The CLI turns a directory into a distributed, collaborative filesystem.
10
-
11
- ## Conceptual Overview
12
-
13
- **Workspaces**: A workspace is a container for files, branches, and metadata. Create workspaces with `mod workspace create`, list them with `mod workspace list`, switch with `mod workspace switch`. Each workspace has its own history, collaborators, and sync state. A directory connects to one workspace at a time.
14
-
15
- **Local-First Sync**: `mod sync start` launches a daemon that watches the local directory and syncs to the connected workspace. File edits, new files, deletions propagate automatically. Remote changes from collaborators sync back to local files. The daemon runs in the background; coding agents work locally as normal. Multiple collaborators can sync to the same workspace from different machines.
16
-
17
- **Branching**: Mod branches are lightweight isolation scopes for work-in-progress. Unlike git branches, they don't require commits or staging. Create a branch, start working, and all changes are tracked automatically. When integrated with git, Mod branches map to git branches. Without git, Mod branches provide standalone isolation.
18
-
19
- **Changelog**: Every file change on a branch is recorded automatically with timestamp, diff, and context. No manual commits required. The changelog captures what changed, when, and alongside what other activity (agent conversations, spec edits, collaborator comments). View at branch level or filter to a specific file.
20
-
21
- **Reversion**: Restore to any point in the changelog. Revert an entire branch to a previous state, or revert a single file while keeping other files at their current state. Fine-grained reversion without needing explicit commits as restore points.
7
+ ```bash
8
+ # Install
9
+ npm install -g @mod-computer/cli
22
10
 
23
- **Merge**: Combine branches by merging their changes. Mod detects conflicts at the file level and surfaces them for resolution. Metadata (comments, traces) merges automatically. After merge, the target branch contains changes from both branches with full history preserved.
11
+ # Initialize workspace (installs /mod skill for Claude Code)
12
+ mod init
13
+ mod auth login
24
14
 
25
- **Git Integration**: In git repositories, sync respects git branch scope. Changes on a git branch sync to the corresponding Mod branch. Switching git branches switches sync context automatically. For non-git directories, Mod branches work independently. The CLI integrates with git workflows but doesn't require git.
15
+ # Start working
16
+ git checkout -b feat/user-auth
17
+ ```
26
18
 
27
- **Metadata Layer**: Workspaces and files carry metadata: comments, notes, and traces. The CLI provides commands to read and write metadata locally. Agents can query file context before making changes and write traces linking code to requirements. Teams see the same metadata in the web app. This shared context layer makes agent reasoning visible and lets teams annotate code without changing source files.
19
+ ## The Idea
28
20
 
29
- **File Import**: For existing projects, `mod sync import` brings current files into the workspace. In git repos, import can pull from git history. Preview first with `--preview` to see what will sync. After import, changes sync automatically.
21
+ You write specs. Agents implement them. But at review time, how do you know what requirement each function addresses? What's tested? What changed but isn't connected to anything?
30
22
 
31
- ## Example
23
+ mod-cli builds a trace graph as you work:
32
24
 
33
- A developer is implementing an authentication feature using Claude Code.
25
+ ```
26
+ Spec requirement → Implementation → Tests
27
+ ```
34
28
 
35
- **1. Initialize**: The developer runs `mod init` in their project directory. They sign in (or are prompted to create an account), then select an existing workspace or create a new one. The directory is now connected to the workspace.
29
+ At review, `mod trace report` shows what's connected. `mod trace diff` catches what isn't.
36
30
 
37
- **2. Start sync**: They run `mod sync start`. The daemon launches in the background, watching for file changes and syncing to the workspace.
31
+ ## Usage
38
32
 
39
- **3. Create branch**: They run `mod branch create add-auth`. A new branch is created. The spec file `specs/auth.md` was collaboratively edited in the web app and is already synced locally.
33
+ ### With Claude Code (Recommended)
40
34
 
41
- **4. Work with agent**: They prompt Claude Code to implement the spec. Claude reads `specs/auth.md` from the filesystem, checks existing comments with `mod comment list`, implements the requirements, and adds traces with `mod trace add src/auth.ts REQ-AUTH-1`. Every file change and metadata update syncs automatically.
35
+ `mod init` installs the `/mod` skill automatically. Use it to implement specs:
42
36
 
43
- **5. Review changelog**: Running `mod changelog` shows all file changes with timestamps and diffs. The developer sees implementation progress alongside agent conversation context.
37
+ ```bash
38
+ # Write a spec
39
+ claude "Write a spec for user authentication in specs/auth.md"
44
40
 
45
- **6. Collaborate**: A teammate edits the spec in the web app, adding a section on rate limiting. The edit syncs to the local file. The developer prompts Claude again, and new changes sync back.
41
+ # Implement from spec - agent handles traces
42
+ claude "/mod implement specs/auth.md"
46
43
 
47
- **7. Ready for review**: Running `mod branch status` shows all changed files. The developer opens the web app to the review view, where teammates see file changes alongside traces and agent reasoning.
44
+ # Add tests - agent traces them to implementations
45
+ claude "/mod test specs/auth.md"
48
46
 
49
- ## How It Works
47
+ # Review coverage
48
+ mod trace report specs/auth.md
49
+ ```
50
50
 
51
- **Sync Daemon**: `mod sync start` launches a background daemon that watches the directory. File system events trigger sync operations. The daemon maintains a WebSocket connection to the sync server for real-time updates.
51
+ ### Manual Workflow
52
52
 
53
- **Automerge Storage**: Local workspace state uses Automerge, a CRDT library for conflict-free replication. Changes merge automatically without coordination. The CLI stores Automerge documents in `~/.mod/` at the device root, shared across all connected repos.
53
+ ```bash
54
+ # Add traces as you work
55
+ mod trace add specs/auth.md:15 --type=requirement
56
+ mod trace add src/auth/login.ts:42 --type=implementation --link=req-login--a1b2
54
57
 
55
- **Bidirectional Sync**: Local file changes update Automerge documents and propagate to the server. Server changes (from collaborators or the web app) update local Automerge state and write back to files. The sync is continuous and automatic.
58
+ # Link existing traces
59
+ mod trace link impl-login--a1b2 spec-login--c3d4
56
60
 
57
- **Branch State**: Each branch maintains independent file states in Automerge. Switching branches updates local files to match. Branch metadata and change history sync alongside file content.
61
+ # View connections
62
+ mod trace report specs/auth.md
63
+ mod trace coverage
58
64
 
59
- **Changelog**: The CLI records every file change with timestamp, diff, and surrounding context. The changelog is queryable and connects code changes to concurrent activity like agent conversations and collaborator edits.
65
+ # Find gaps before merge
66
+ mod trace diff # Untraced files on branch
67
+ mod trace unmet # Requirements without implementations
68
+ ```
60
69
 
61
- ## Commands Reference
70
+ ## Commands
62
71
 
63
- ### Core Commands
72
+ ### Setup
64
73
 
65
74
  ```bash
66
- mod init # Initialize workspace and install Claude commands
67
- mod sync start # Start background sync daemon
68
- mod sync stop # Stop sync daemon
69
- mod sync status # Show sync health and connection status
70
- mod sync import # Import existing files to workspace
75
+ mod init # Initialize workspace, install /mod skill
76
+ mod auth login # Authenticate
77
+ mod auth logout # Sign out
78
+ mod auth status # Show auth state
71
79
  ```
72
80
 
73
- ### Branch Management
81
+ ### Traces
74
82
 
75
83
  ```bash
76
- mod branch create <name> # Create new branch
77
- mod branch switch <name> # Switch to branch
78
- mod branch list # List all branches
79
- mod branch status # Show current branch and changes
80
- mod branch changelog # Show automatic changelog
81
- mod branch tree # Display directory tree
84
+ # Add traces
85
+ mod trace add <file>:<line> --type=<type> ["description"]
86
+ mod trace add <file>:<line> --type=<type> --link=<trace-id>
87
+
88
+ # Link traces
89
+ mod trace link <source-id> <target-id>
90
+
91
+ # View traces
92
+ mod trace list # All traces
93
+ mod trace list --type=requirement # Filter by type
94
+ mod trace list --file=<path> # Filter by file
95
+ mod trace get <trace-id> # Get trace details
96
+
97
+ # Reports
98
+ mod trace report <file> # Per-document coverage
99
+ mod trace coverage # Workspace-wide stats
100
+
101
+ # Find gaps
102
+ mod trace diff # Untraced files on branch
103
+ mod trace diff main..HEAD # Explicit git range
104
+ mod trace unmet # Requirements without implementations
82
105
  ```
83
106
 
84
- ### Workspace Management
107
+ ### Comments
85
108
 
86
109
  ```bash
87
- mod workspace create <name> # Create new workspace
88
- mod workspace list # List workspaces
89
- mod workspace switch <name> # Switch active workspace
90
- mod workspace info # Show workspace details
110
+ mod comment add <file>:<line> "text"
111
+ mod comment list [file]
91
112
  ```
92
113
 
93
- ### Metadata
114
+ ## Trace Types
115
+
116
+ | Type | Use For |
117
+ |------|---------|
118
+ | `requirement` | Specs, user stories, acceptance criteria |
119
+ | `specification` | Detailed technical specs |
120
+ | `implementation` | Code that builds something |
121
+ | `test` | Code that verifies something |
122
+ | `design` | Design docs, architecture notes |
123
+ | `decision` | ADRs, decision records |
124
+ | `utility` | Helpers that don't need tracing |
125
+
126
+ ## CI Integration
127
+
128
+ Commands exit non-zero when issues exist:
94
129
 
95
130
  ```bash
96
- mod comment add <file> <text> # Add comment to file
97
- mod comment list [file] # List comments (all or per file)
98
- mod note set <file> <text> # Set note on file
99
- mod note get <file> # Get note for file
100
- mod trace add <file> <req-id> # Add trace linking file to requirement
101
- mod trace list [file] # List traces (all or per file)
131
+ # Pre-merge validation
132
+ mod trace diff && mod trace unmet && git push
102
133
  ```
103
134
 
135
+ | Command | Exit 0 | Exit 1 |
136
+ |---------|--------|--------|
137
+ | `mod trace diff` | All changed files traced | Untraced files exist |
138
+ | `mod trace unmet` | All requirements implemented | Unmet requirements |
139
+
104
140
  ## Development
105
141
 
106
142
  ```bash
@@ -109,17 +145,3 @@ pnpm build # Build CLI
109
145
  pnpm dev # Watch mode
110
146
  pnpm test # Run tests
111
147
  ```
112
-
113
- ## Thoughts
114
-
115
- **Daemon architecture**: The sync daemon runs as a background process rather than requiring an active terminal. This lets developers work normally while sync happens invisibly. The daemon writes logs to `~/.mod/logs/sync.log` for debugging.
116
-
117
- **CRDT trade-offs**: Automerge handles conflicts automatically, but the resulting merges aren't always what users expect for text files. Currently optimizing for metadata sync; file content sync may need smarter merge strategies.
118
-
119
- **Git integration**: In git repos, sync is branch-aware: git branch switches trigger Mod branch switches. Mod adds real-time collaboration and agent context on top of git. In non-git directories, Mod provides standalone change tracking and sync.
120
-
121
- **Device-level storage**: All state lives in `~/.mod/` at the device root rather than per-repo. Sign in once, use across all repos. Single daemon can sync multiple connected directories. No per-repo config to gitignore.
122
-
123
- **Metadata commands**: Specific commands for comments, notes, and traces rather than a generic `mod meta` interface. Agents benefit from semantic clarity. Each metadata type has different workflows: comments are threaded, notes are single per file, traces link to requirement IDs. Keeping them separate makes intent clear for both agents and humans.
124
-
125
- **Offline handling**: The daemon queues changes when offline and syncs when reconnected. Local edits always work; sync catches up when possible. Conflict resolution happens through Automerge's CRDT properties.