@stackmemoryai/stackmemory 0.5.64 → 0.5.66

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 CHANGED
@@ -1,6 +1,11 @@
1
1
  # StackMemory
2
2
 
3
- **Lossless, project-scoped memory for AI tools** • v0.5.59
3
+ [![Test Shared Context](https://github.com/stackmemoryai/stackmemory/actions/workflows/test-shared-context.yml/badge.svg?branch=main)](https://github.com/stackmemoryai/stackmemory/actions/workflows/test-shared-context.yml)
4
+ [![Publish to NPM](https://github.com/stackmemoryai/stackmemory/actions/workflows/npm-publish.yml/badge.svg?branch=main)](https://github.com/stackmemoryai/stackmemory/actions/workflows/npm-publish.yml)
5
+ [![Coverage](https://codecov.io/gh/stackmemoryai/stackmemory/branch/main/graph/badge.svg)](https://codecov.io/gh/stackmemoryai/stackmemory)
6
+ [![npm version](https://img.shields.io/npm/v/@stackmemoryai/stackmemory)](https://www.npmjs.com/package/@stackmemoryai/stackmemory)
7
+
8
+ Lossless, project-scoped memory for AI tools
4
9
 
5
10
  StackMemory is a **production-ready memory runtime** for AI coding tools that preserves full project context across sessions:
6
11
 
@@ -19,124 +24,46 @@ Instead of a linear chat log, StackMemory organizes memory as a **call stack** o
19
24
 
20
25
  ## Why StackMemory exists
21
26
 
22
- Development tools lose context between sessions:
23
-
24
- - Previous decisions aren't tracked
25
- - Constraints get forgotten
26
- - Changes lack history
27
- - Tool execution isn't recorded
27
+ Tools forget decisions and constraints between sessions. StackMemory makes context durable and actionable.
28
28
 
29
- StackMemory solves this by:
30
-
31
- - Storing all events, tool calls, and decisions
32
- - Smart retrieval of relevant context
33
- - Call stack organization for nested context
34
- - Configurable importance scoring
35
- - Team collaboration through shared stacks
29
+ - Records: events, tool calls, decisions, and anchors
30
+ - Retrieves: high-signal context tailored to the current task
31
+ - Organizes: nested frames with importance scoring and shared stacks
36
32
 
37
33
  ---
38
34
 
39
- ## Features
40
-
41
- StackMemory includes powerful features to enhance your AI coding workflow. Enable/disable with `claude-sm config setup`.
42
-
43
- ### Predictive Edit
44
-
45
- Anticipates your next edit and displays suggestions as a status bar overlay. Powered by llama-server and Claude Code's PostToolUse hooks.
46
-
47
- ```bash
48
- claude-sm --sweep # Enable (default: on)
49
- claude-sm --no-sweep # Disable
50
- ```
51
-
52
- - **How it works**: Analyzes tool outputs and predicts likely follow-up edits
53
- - **Interface**: Tab to accept, Esc to dismiss
54
- - **Requirement**: Installs `node-pty` on first use
55
-
56
- ### Code Review
57
-
58
- AI-powered code review using Greptile's codebase-aware analysis. Automatically registers the Greptile MCP server for deep repository understanding.
59
-
60
- ```bash
61
- claude-sm --greptile # Enable (default: on)
62
- claude-sm --no-greptile # Disable
63
- ```
64
-
65
- - **Tools provided**: `index_repository`, `query_repository`, `get_repository_info`
66
- - **Requirement**: `GREPTILE_API_KEY` in `.env`
67
-
68
- ### Prompt Forge
69
-
70
- Genetic Eval-driven Prompt Algorithm (GEPA) for automatic system prompt optimization. Evolves your `CLAUDE.md` through mutation, evaluation, and selection.
71
-
72
- ```bash
73
- claude-sm --gepa # Enable
74
- claude-sm --no-gepa # Disable (default)
75
- ```
76
-
77
- - **Auto-optimize**: Watches `CLAUDE.md` and runs optimization on changes
78
- - **Strategies**: rephrase, add_examples, remove_redundancy, restructure, add_constraints, simplify
79
- - **Output**: Before/after comparison with metrics (lines, tokens, rules)
80
-
81
- ### Model Switcher
82
-
83
- Dynamic model routing based on task complexity. Automatically selects the optimal model (Haiku/Sonnet/Opus) for each request.
84
-
85
- ```bash
86
- claude-sm --model-routing # Enable
87
- claude-sm --no-model-routing # Disable (default)
88
- ```
89
-
90
- - **Cost optimization**: Uses cheaper models for simple tasks
91
- - **Quality preservation**: Routes complex tasks to more capable models
92
-
93
- ### Safe Branch
94
-
95
- Git worktree isolation for experimental changes. Each session operates in an isolated branch, preventing accidental commits to main.
96
-
97
- ```bash
98
- claude-sm --worktree # Enable
99
- claude-sm --no-worktree # Disable (default)
100
- ```
101
-
102
- - **Isolation**: Changes happen in a separate worktree
103
- - **Safety**: Main branch remains untouched until explicit merge
35
+ ## Features (at a glance)
104
36
 
105
- ### Mobile Sync
37
+ - MCP tools for Claude Code: 26+ tools; context on every request
38
+ - Safe branches: worktree isolation with `--worktree` or `-w`
39
+ - Persistent context: frames, anchors, decisions, retrieval
40
+ - Optional boosts: model routing, prompt optimization (GEPA)
41
+ - Integrations: Linear, Greptile, DiffMem, Browser MCP
106
42
 
107
- WhatsApp notifications for session updates and task completion. Stay informed even when away from your terminal.
43
+ See the docs directory for deeper feature guides.
108
44
 
109
- ```bash
110
- claude-sm --whatsapp # Enable
111
- claude-sm --no-whatsapp # Disable (default)
112
- ```
113
-
114
- - **Notifications**: Session start, task completion, errors
115
- - **Interactive**: Reply to trigger actions remotely
45
+ ---
116
46
 
117
- ### Session Insights
47
+ ## Quick Start
118
48
 
119
- Detailed tracing of session activity for debugging and optimization. Tracks tool calls, timing, and decision paths.
49
+ Requirements: Node >= 20
120
50
 
121
51
  ```bash
122
- claude-sm --tracing # Enable
123
- claude-sm --no-tracing # Disable (default)
124
- ```
125
-
126
- - **Visibility**: Full execution trace
127
- - **Analytics**: Performance metrics and patterns
52
+ # Install globally
53
+ npm install -g @stackmemoryai/stackmemory
128
54
 
129
- ### Task Alert
55
+ # Initialize in your project (zero-config, just works)
56
+ cd your-project
57
+ stackmemory init
130
58
 
131
- Desktop/terminal notifications when long-running tasks complete. Never miss a completed build or test run.
59
+ # Configure Claude Code integration
60
+ stackmemory setup-mcp
132
61
 
133
- ```bash
134
- claude-sm --notify-on-done # Enable (default: on)
135
- claude-sm --no-notify-on-done # Disable
62
+ # Minimal usage
63
+ stackmemory init && stackmemory setup-mcp && stackmemory doctor
136
64
  ```
137
65
 
138
- - **Platforms**: macOS notifications, terminal bell
139
- - **Smart**: Only notifies for tasks taking >10 seconds
66
+ Restart Claude Code and StackMemory MCP tools will be available.
140
67
 
141
68
  ---
142
69
 
@@ -161,72 +88,52 @@ Frames can span:
161
88
 
162
89
  ## Hosted vs Open Source
163
90
 
164
- ### Hosted (default)
165
-
166
- - Cloud-backed memory runtime
167
- - Fast indexing + retrieval
168
- - Durable storage
169
- - Per-project pricing
170
- - Works out-of-the-box
171
-
172
- ### Open-source local mirror
173
-
174
- - SQLite-based
175
- - Fully inspectable
176
- - Offline / air-gapped
177
- - Intentionally **N versions behind**
178
- - No sync, no org features
179
-
180
- > OSS is for trust and inspection.
181
- > Hosted is for scale, performance, and teams.
91
+ - Hosted: cloud-backed, fast retrieval, durable, team features — works out of the box.
92
+ - OSS local: SQLite, offline, inspectable — intentionally behind; no sync/org features.
182
93
 
183
94
  ---
184
95
 
185
96
  ## How it integrates
186
97
 
187
- StackMemory integrates as an **MCP tool** and is invoked on **every interaction** in:
98
+ Runs as an MCP server. Editors (e.g., Claude Code) call StackMemory on each interaction to fetch a compiled context bundle; editors don’t store memory themselves.
188
99
 
189
- - Claude Code
190
- - compatible editors
191
- - future MCP-enabled tools
100
+ ### MCP Quick Usage
192
101
 
193
- The editor never manages memory directly; it asks StackMemory for the **context bundle**.
102
+ Use these JSON snippets with Claude Code’s MCP “tools/call”. Responses are returned as a single text item containing JSON.
194
103
 
195
- ---
104
+ - Plan only (no code):
105
+ ```json
106
+ {"method":"tools/call","params":{"name":"plan_only","arguments":{"task":"Refactor config loader","plannerModel":"claude-3-5-sonnet-latest"}}}
107
+ ```
196
108
 
197
- ## Product Health Metrics
109
+ - Approval‑gated plan (phase 1):
110
+ ```json
111
+ {"method":"tools/call","params":{"name":"plan_gate","arguments":{"task":"Refactor config loader","compact":true}}}
112
+ ```
198
113
 
199
- ### Current Status (v0.5.47)
114
+ - Approve + execute (phase 2):
115
+ ```json
116
+ {"method":"tools/call","params":{"name":"approve_plan","arguments":{"approvalId":"<copy from plan_gate>","implementer":"codex","execute":true,"recordFrame":true,"compact":true}}}
117
+ ```
200
118
 
201
- | Metric | Current | Target | Status |
202
- |--------|---------|--------|--------|
203
- | **Test Coverage** | 85% | 90% | In Progress |
204
- | **Tests Passing** | 490 | 500+ | On Track |
205
- | **Documentation** | 80% | 100% | In Progress |
206
- | **Active Issues** | 3 high | 0 high | In Progress |
119
+ - Manage approvals:
120
+ ```json
121
+ {"method":"tools/call","params":{"name":"pending_list","arguments":{}}}
122
+ {"method":"tools/call","params":{"name":"pending_show","arguments":{"approvalId":"<id>","compact":true}}}
123
+ {"method":"tools/call","params":{"name":"pending_clear","arguments":{"approvalId":"<id>"}}}
124
+ ```
207
125
 
208
- ---
209
-
210
- # QuickStart
126
+ Env defaults (optional):
127
+ - `STACKMEMORY_MM_PLANNER_MODEL` (e.g., `claude-3-5-sonnet-latest` or `claude-3-opus-latest`)
128
+ - `STACKMEMORY_MM_REVIEWER_MODEL` (defaults to planner if unset)
129
+ - `STACKMEMORY_MM_IMPLEMENTER` (`codex` or `claude`)
130
+ - `STACKMEMORY_MM_MAX_ITERS` (e.g., `2`)
211
131
 
212
- ## 1. Install & Initialize (30 seconds)
213
-
214
- ```bash
215
- # Install globally
216
- npm install -g @stackmemoryai/stackmemory
132
+ ---
217
133
 
218
- # Initialize in your project (zero-config, just works)
219
- cd your-project
220
- stackmemory init
134
+ ## Quick Start
221
135
 
222
- # Configure Claude Code integration
223
- stackmemory setup-mcp
224
-
225
- # Verify everything works
226
- stackmemory doctor
227
- ```
228
-
229
- That's it! Restart Claude Code and StackMemory MCP tools are available.
136
+ See above for install and minimal usage. For advanced options, see Setup.
230
137
 
231
138
  ---
232
139
 
@@ -277,77 +184,7 @@ Checks project initialization, database integrity, MCP config, and suggests fixe
277
184
 
278
185
  ## 3. Advanced Setup
279
186
 
280
- <details>
281
- <summary>Manual MCP configuration</summary>
282
-
283
- Create MCP configuration:
284
-
285
- ```bash
286
- mkdir -p ~/.claude
287
- cat > ~/.claude/stackmemory-mcp.json << 'EOF'
288
- {
289
- "mcpServers": {
290
- "stackmemory": {
291
- "command": "stackmemory",
292
- "args": ["mcp-server"],
293
- "env": { "NODE_ENV": "production" }
294
- }
295
- }
296
- }
297
- EOF
298
- ```
299
-
300
- Update Claude config.json:
301
-
302
- ```json
303
- {
304
- "mcp": {
305
- "configFiles": ["~/.claude/stackmemory-mcp.json"]
306
- }
307
- }
308
- ```
309
-
310
- </details>
311
-
312
- <details>
313
- <summary>Hosted mode (cloud storage)</summary>
314
-
315
- ```bash
316
- stackmemory onboard
317
- # Select "Hosted" when prompted
318
- # Or set DATABASE_URL environment variable
319
- ```
320
-
321
- </details>
322
-
323
- <details>
324
- <summary>ChromaDB for semantic search</summary>
325
-
326
- ```bash
327
- stackmemory init --chromadb
328
- # Prompts for ChromaDB API key
329
- ```
330
-
331
- </details>
332
-
333
- Claude Code sessions automatically capture tool calls, maintain context across sessions, and sync with Linear when configured.
334
-
335
- Available MCP tools in Claude Code:
336
-
337
- | Tool | Description |
338
- | -------------------- | ------------------------------------------ |
339
- | `get_context` | Retrieve relevant context for current work |
340
- | `add_decision` | Record a decision with rationale |
341
- | `start_frame` | Begin a new context frame |
342
- | `close_frame` | Close current frame with summary |
343
- | `create_task` | Create a new task |
344
- | `update_task_status` | Update task status |
345
- | `get_active_tasks` | List active tasks (with filters) |
346
- | `get_task_metrics` | Get task analytics |
347
- | `linear_sync` | Sync with Linear |
348
- | `linear_update_task` | Update Linear issue |
349
- | `linear_get_tasks` | Get tasks from Linear |
350
-
187
+ See https://github.com/stackmemoryai/stackmemory/blob/main/docs/setup.md for advanced options (hosted mode, ChromaDB, manual MCP config, and available tools).
351
188
 
352
189
  ---
353
190
 
@@ -379,7 +216,7 @@ This creates `.stackmemory/` with SQLite storage.
379
216
  "mcpServers": {
380
217
  "stackmemory": {
381
218
  "command": "node",
382
- "args": ["dist/integrations/mcp/server.js"]
219
+ "args": ["dist/src/integrations/mcp/server.js"]
383
220
  }
384
221
  }
385
222
  }
@@ -540,140 +377,25 @@ stackmemory skills rlm "Build, test, and publish version 2.0.0"
540
377
 
541
378
  ## CLI Commands
542
379
 
543
- ```bash
544
- # Setup & Diagnostics
545
- stackmemory init # Initialize project (zero-config)
546
- stackmemory init --interactive # Interactive setup with options
547
- stackmemory setup-mcp # Configure Claude Code MCP
548
- stackmemory doctor # Diagnose issues and suggest fixes
549
-
550
- # Status
551
- stackmemory status # Current status
552
- stackmemory progress # Recent activity
553
-
554
- # Tasks
555
- stackmemory tasks list [--status pending] # List tasks
556
- stackmemory task add "title" --priority high
557
- stackmemory task done <id>
558
-
559
- # Search & Logs
560
- stackmemory search "query" [--tasks|--context]
561
- stackmemory log [--follow] [--type task]
562
- ```
563
-
564
- ```bash
565
- # Context
566
- stackmemory context show [--verbose]
567
- stackmemory context push "name" --type task
568
- stackmemory context add decision "text"
569
- stackmemory context pop [--all]
570
-
571
- # Linear Integration
572
- stackmemory linear setup # OAuth setup
573
- stackmemory linear sync [--direction from_linear]
574
- stackmemory linear auto-sync --start
575
- stackmemory linear update ENG-123 --status done
576
-
577
- # Storage Management
578
- stackmemory storage status # Show tier distribution
579
- stackmemory storage migrate [--tier young] # Trigger migration
580
- stackmemory storage cleanup --force # Clean old data
581
- stackmemory storage config --show # Show configuration
582
-
583
- # Analytics & Server
584
- stackmemory analytics [--view|--port 3000]
585
- stackmemory mcp-server [--port 3001]
586
- ```
380
+ See https://github.com/stackmemoryai/stackmemory/blob/main/docs/cli.md for the full command reference and examples.
587
381
 
588
382
  ---
589
383
 
590
384
  ## Status
591
385
 
592
- - Hosted: **Private beta**
593
- - OSS mirror: **Production ready**
594
- - MCP integration: **Stable**
595
- - CLI: **v0.5.51** - Zero-config setup, diagnostics, full task/context/Linear management
596
- - Two-tier storage: **Complete**
597
- - Test Suite: **480 tests passing**
386
+ See https://github.com/stackmemoryai/stackmemory/blob/main/docs/status.md for current status.
598
387
 
599
388
  ---
600
389
 
601
390
  ## Changelog
602
391
 
603
- ### v0.5.51 (2026-01-28)
604
- - **Interactive feature setup**: `claude-sm config setup` wizard to toggle features and install deps on demand
605
- - Checkbox prompt for all features (Sweep, Greptile, Model Routing, Worktree, WhatsApp, Tracing)
606
- - Auto-installs `node-pty` when Sweep is enabled
607
- - Prompts for `GREPTILE_API_KEY` and registers MCP server when Greptile is enabled
608
- - **Sweep next-edit predictions**: PTY wrapper displays predicted edits as a status bar in Claude Code sessions. Tab to accept, Esc to dismiss. Powered by llama-server via PostToolUse hooks.
609
- - `claude-sm --sweep` (default: on) or `stackmemory sweep wrap`
610
- - `node-pty` installed on demand via setup (no longer in optionalDependencies)
611
- - **Greptile AI code review**: Auto-registers Greptile MCP server for codebase-aware code review.
612
- - `claude-sm --greptile` (default: on)
613
- - Requires `GREPTILE_API_KEY` in `.env`
614
- - Tools: `index_repository`, `query_repository`, `get_repository_info`
615
- - **Feature flags**: Added `greptile` feature flag to `feature-flags.ts`
616
-
617
- ### v0.5.47 (2026-01-27)
618
- - **Graceful database failures**: Handles native module version mismatches
619
- - **Suppress dotenv logs**: Cleaner terminal output
620
- - **TTY preservation**: Fixes interactive mode for claude-sm/claude-smd
621
- - **Silent Linear auth**: No spam when API key not configured
622
-
623
- ### v0.5.40 (2026-01-27)
624
- - **Zero-config onboarding**: `stackmemory init` now works without any prompts
625
- - **New `setup-mcp` command**: Auto-configures Claude Code MCP integration
626
- - **New `doctor` command**: Diagnoses issues and suggests fixes
627
- - **Interactive postinstall**: Asks for consent before modifying ~/.claude
628
- - **Better error messages**: Shows reason + fix + next step
629
-
630
- ### v0.5.39 (2026-01-27)
631
- - **AsyncMutex**: Thread-safe Linear sync with stale lock detection
632
- - **Action timeout**: 60s timeout for SMS action execution
633
- - **Persistent rate limiting**: Survives server restarts
634
- - **Atomic file writes**: Prevents corruption on crash
635
-
636
- ### v0.5.30 (2026-01-26)
637
- - Standardized error handling with `IntegrationError`, `DatabaseError`, `ValidationError`
638
- - Adopted error classes across Linear integration (12 files)
639
- - Adopted error classes across database layer (6 files)
640
- - WhatsApp notifications with session ID and interactive options
641
-
642
- ### v0.5.28 (2026-01-25)
643
- - WhatsApp flag for claude-sm automatic notifications
644
- - Incoming request queue for WhatsApp triggers
645
- - SMS webhook /send endpoint for outgoing notifications
646
-
647
- ### v0.5.26 (2026-01-24)
648
- - OpenCode wrapper (opencode-sm) with context integration
649
- - Discovery CLI and MCP tools
650
- - Real LLM provider and retrieval audit system
651
- - Linear issue management and task picker
652
-
653
- ### v0.5.21 (2026-01-23)
654
- - Claude-sm remote mode and configurable defaults
655
- - Context loading command improvements
656
- - Session summary features
657
-
658
- ### v0.3.16 (2026-01-15)
659
- - Fixed critical error handling - getFrame() returns undefined instead of throwing
660
- - Improved test coverage and fixed StackMemoryError constructor usage
661
- - Removed dangerous secret-cleaning scripts from repository
662
- - All tests passing, lint clean, build successful
663
-
664
- ### v0.3.15 (2026-01-14)
665
- - Two-tier storage system implementation complete
666
- - Smart compression with LZ4/ZSTD support
667
- - Background migration with configurable triggers
668
- - Improved Linear integration with bidirectional sync
392
+ See https://github.com/stackmemoryai/stackmemory/blob/main/docs/changelog.md for detailed release notes.
669
393
 
670
394
  ---
671
395
 
672
396
  ## Roadmap
673
397
 
674
- **Phase 4 (Completed):** Two-tier storage system with local tiers and infinite remote storage
675
- **Phase 5 (Current):** PostgreSQL production adapter, enhanced team collaboration, advanced analytics
676
- **Phase 6 (Next):** Enterprise features, multi-org support, cost optimization
398
+ See https://github.com/stackmemoryai/stackmemory/blob/main/docs/roadmap.md for our current roadmap.
677
399
 
678
400
  ---
679
401
 
@@ -696,5 +418,6 @@ stackmemory mcp-server [--port 3001]
696
418
  - [Product Requirements](./PRD.md) - Detailed product specifications
697
419
  - [Technical Architecture](./TECHNICAL_ARCHITECTURE.md) - System design and database schemas
698
420
  - [Beads Integration](./BEADS_INTEGRATION.md) - Git-native memory patterns from Beads ecosystem
421
+ - [MCP: plan_and_code](https://github.com/stackmemoryai/stackmemory/blob/main/docs/mcp.md) - Trigger planning + coding via MCP with JSON results
699
422
 
700
423
  ---
package/bin/claude-sm CHANGED
@@ -3,4 +3,4 @@
3
3
  * Claude-SM CLI Launcher (ESM)
4
4
  * Delegates to built CLI in dist without requiring tsx.
5
5
  */
6
- import('../dist/cli/claude-sm.js');
6
+ import('../dist/src/cli/claude-sm.js');
package/bin/claude-smd CHANGED
@@ -3,4 +3,4 @@
3
3
  * Claude-SM-Danger CLI Launcher (ESM)
4
4
  * Delegates to built CLI in dist without requiring tsx.
5
5
  */
6
- import('../dist/cli/claude-sm-danger.js');
6
+ import('../dist/src/cli/claude-sm-danger.js');
package/bin/codex-smd CHANGED
@@ -3,4 +3,4 @@
3
3
  * Codex-SM-Danger CLI Launcher (ESM)
4
4
  * Delegates to built CLI in dist without requiring tsx.
5
5
  */
6
- import('../dist/cli/codex-sm-danger.js');
6
+ import('../dist/src/cli/codex-sm-danger.js');
@@ -23,6 +23,7 @@ import {
23
23
  DatabaseError,
24
24
  ErrorCode
25
25
  } from "../../core/errors/index.js";
26
+ import { version as VERSION } from "../../version.js";
26
27
  function getEnv(key, defaultValue) {
27
28
  const value = process.env[key];
28
29
  if (value === void 0) {
@@ -270,6 +271,109 @@ function createSkillsCommand() {
270
271
  process.exit(1);
271
272
  }
272
273
  });
274
+ skillsCmd.command("spike").description(
275
+ "Run multi-agent spike (planner: Claude, implementer: Codex/Claude, critic: Claude)"
276
+ ).option("-t, --task <desc>", "Task description", "Spike harness").option(
277
+ "--planner-model <name>",
278
+ "Claude model for planning",
279
+ "claude-3-5-sonnet-latest"
280
+ ).option(
281
+ "--reviewer-model <name>",
282
+ "Claude model for review",
283
+ "claude-3-5-sonnet-latest"
284
+ ).option("--implementer <name>", "codex|claude", "codex").option("--max-iters <n>", "Retry loop iterations", "2").option(
285
+ "--execute",
286
+ "Execute implementer (codex-sm) instead of dry-run",
287
+ false
288
+ ).option("--audit-dir <path>", "Persist spike results to directory").option("--record-frame", "Record as real frame with anchors", false).option(
289
+ "--record",
290
+ "Record plan & critique into StackMemory context",
291
+ false
292
+ ).option("--json", "Emit single JSON result (UI-friendly)", false).option("--quiet", "Minimal output (default)", true).option("--verbose", "Verbose sectioned output", false).action(async (options) => {
293
+ const spinner = ora("Planning with Claude...").start();
294
+ try {
295
+ const { runSpike } = await import("../../orchestrators/multimodal/harness.js");
296
+ const result = await runSpike(
297
+ {
298
+ task: options.task,
299
+ repoPath: process.cwd()
300
+ },
301
+ {
302
+ plannerModel: options.plannerModel,
303
+ reviewerModel: options.reviewerModel,
304
+ implementer: options.implementer,
305
+ maxIters: parseInt(options.maxIters),
306
+ dryRun: !options.execute,
307
+ auditDir: options.auditDir,
308
+ recordFrame: Boolean(options.recordFrame),
309
+ record: Boolean(options.record)
310
+ }
311
+ );
312
+ spinner.stop();
313
+ if (options.json) {
314
+ console.log(JSON.stringify(result));
315
+ } else if (options.verbose) {
316
+ console.log(chalk.gray(`StackMemory v${VERSION}`));
317
+ console.log(chalk.cyan("\n=== Plan ==="));
318
+ console.log(JSON.stringify(result.plan, null, 2));
319
+ console.log(chalk.cyan("\n=== Iterations ==="));
320
+ (result.iterations || []).forEach((it, idx) => {
321
+ console.log(chalk.gray(`
322
+ -- Attempt ${idx + 1} --`));
323
+ console.log(`Command: ${it.command}`);
324
+ console.log(`OK: ${it.ok}`);
325
+ console.log("Critique:", JSON.stringify(it.critique));
326
+ });
327
+ console.log(chalk.cyan("\n=== Final ==="));
328
+ console.log(JSON.stringify(result.implementation, null, 2));
329
+ console.log(chalk.cyan("\n=== Critique ==="));
330
+ console.log(JSON.stringify(result.critique, null, 2));
331
+ } else if (!options.quiet) {
332
+ console.log(
333
+ `Plan steps: ${result.plan.steps.length}, Approved: ${result.critique.approved}`
334
+ );
335
+ }
336
+ if (!result.implementation.success) process.exitCode = 1;
337
+ } catch (error) {
338
+ spinner.stop();
339
+ console.error(chalk.red("Spike failed:"), error?.message || error);
340
+ process.exit(1);
341
+ }
342
+ });
343
+ skillsCmd.command("plan <task>").description("Generate an implementation plan (no code execution)").option(
344
+ "--planner-model <name>",
345
+ "Claude model for planning",
346
+ "claude-3-5-sonnet-latest"
347
+ ).option("--json", "Emit JSON (default)", true).option("--pretty", "Pretty-print JSON", false).option(
348
+ "--compact",
349
+ "Compact output (summary + step titles + criteria)",
350
+ false
351
+ ).action(async (task, options) => {
352
+ const spinner = ora("Planning with Claude...").start();
353
+ try {
354
+ const { runPlanOnly } = await import("../../orchestrators/multimodal/harness.js");
355
+ const plan = await runPlanOnly(
356
+ { task, repoPath: process.cwd() },
357
+ { plannerModel: options.plannerModel }
358
+ );
359
+ spinner.stop();
360
+ const compacted = options.compact ? {
361
+ summary: plan?.summary,
362
+ steps: Array.isArray(plan?.steps) ? plan.steps.map((s) => ({
363
+ id: s.id,
364
+ title: s.title,
365
+ acceptanceCriteria: s.acceptanceCriteria
366
+ })) : [],
367
+ risks: plan?.risks
368
+ } : plan;
369
+ const payload = JSON.stringify(compacted, null, options.pretty ? 2 : 0);
370
+ console.log(payload);
371
+ } catch (error) {
372
+ spinner.stop();
373
+ console.error(chalk.red("Plan failed:"), error?.message || error);
374
+ process.exit(1);
375
+ }
376
+ });
273
377
  skillsCmd.command("dig <query>").description("Deep historical context retrieval").option(
274
378
  "-d, --depth <depth>",
275
379
  "Search depth (e.g., 30days, 6months, all)",