Skip to content

Commit cde2190

Browse files
author
StackMemory Bot (CLI)
committed
chore: handoff checkpoint on main
1 parent 99b8da1 commit cde2190

30 files changed

Lines changed: 582 additions & 179 deletions

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ Use these JSON snippets with Claude Code’s MCP “tools/call”. Responses are
103103

104104
- Plan only (no code):
105105
```json
106-
{"method":"tools/call","params":{"name":"plan_only","arguments":{"task":"Refactor config loader","plannerModel":"claude-3-5-sonnet-latest"}}}
106+
{"method":"tools/call","params":{"name":"plan_only","arguments":{"task":"Refactor config loader","plannerModel":"claude-sonnet-4-20250514"}}}
107107
```
108108

109109
- Approval‑gated plan (phase 1):
@@ -124,7 +124,7 @@ Use these JSON snippets with Claude Code’s MCP “tools/call”. Responses are
124124
```
125125

126126
Env defaults (optional):
127-
- `STACKMEMORY_MM_PLANNER_MODEL` (e.g., `claude-3-5-sonnet-latest` or `claude-3-opus-latest`)
127+
- `STACKMEMORY_MM_PLANNER_MODEL` (e.g., `claude-sonnet-4-20250514`)
128128
- `STACKMEMORY_MM_REVIEWER_MODEL` (defaults to planner if unset)
129129
- `STACKMEMORY_MM_IMPLEMENTER` (`codex` or `claude`)
130130
- `STACKMEMORY_MM_MAX_ITERS` (e.g., `2`)
@@ -414,7 +414,7 @@ See https://github.com/stackmemoryai/stackmemory/blob/main/docs/roadmap.md for o
414414
- [Agent Instructions](./AGENTS.md) - Specific guidance for AI agents working with ML systems
415415

416416
### Documentation
417-
417+
- [Vision](./vision.md) - Product vision, principles, roadmap, metrics
418418
- [Product Requirements](./PRD.md) - Detailed product specifications
419419
- [Technical Architecture](./TECHNICAL_ARCHITECTURE.md) - System design and database schemas
420420
- [Beads Integration](./BEADS_INTEGRATION.md) - Git-native memory patterns from Beads ecosystem

docs/AGENTIC_PATTERNS_IMPLEMENTATION.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ oracle: {
3232
}
3333

3434
workers: [{
35-
model: 'claude-3-haiku-20240307',
35+
model: 'claude-3-5-haiku-20241022',
3636
costPerToken: 0.00025, // $0.25/1M tokens
3737
capabilities: ['code_implementation', 'testing']
3838
}]
@@ -244,4 +244,4 @@ npx stackmemory ralph oracle-worker "Build REST API for user management" \
244244

245245
These agentic patterns transform StackMemory from a traditional development tool into a self-improving, cost-effective, and highly capable software development platform. The combination of cost optimization, systematic learning, and extended capabilities enables production-ready AI-assisted development at scale.
246246

247-
The patterns are production-proven concepts adapted for StackMemory's unique architecture, providing immediate benefits while establishing a foundation for future AI-assisted development workflows.
247+
The patterns are production-proven concepts adapted for StackMemory's unique architecture, providing immediate benefits while establishing a foundation for future AI-assisted development workflows.

docs/mcp.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ The `plan_and_code` MCP tool lets Claude Code trigger StackMemory’s multi‑ag
2020

2121
## Environment defaults
2222
If not specified in arguments, the MCP handler reads these env vars:
23-
- `STACKMEMORY_MM_PLANNER_MODEL` (e.g., `claude-3-5-sonnet-latest`)
23+
- `STACKMEMORY_MM_PLANNER_MODEL` (e.g., `claude-sonnet-4-20250514`)
2424
- `STACKMEMORY_MM_REVIEWER_MODEL` (defaults to planner model if unset)
2525
- `STACKMEMORY_MM_IMPLEMENTER` (`codex` or `claude`)
2626
- `STACKMEMORY_MM_MAX_ITERS` (e.g., `3`)
@@ -98,7 +98,7 @@ Request (tools/call):
9898
"name": "plan_gate",
9999
"arguments": {
100100
"task": "Refactor config loader into provider pattern",
101-
"plannerModel": "claude-3-5-sonnet-latest"
101+
"plannerModel": "claude-sonnet-4-20250514"
102102
}
103103
}
104104
}

docs/status.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,17 @@
77
- Two-tier storage: Complete
88
- Test Suite: 480 tests passing
99

10+
## Test Mode
11+
12+
To run tests in constrained environments or avoid native module initialization during CLI/harness execution, enable test mode. When enabled, the CLI skips opening the local SQLite DB and avoids writing frames/anchors in helper commands.
13+
14+
- Env flags:
15+
- `VITEST=true`: Detected automatically by the CLI; disables DB work in commands like `init`, `status`, and `context:test`.
16+
- `NODE_ENV=test`: Also triggers DB‑skip behavior.
17+
- `STACKMEMORY_TEST_SKIP_DB=1`: Explicit override to skip DB, independent of test runner.
18+
19+
- Typical usage:
20+
- `VITEST=true npm run test:run`
21+
- `STACKMEMORY_TEST_SKIP_DB=1 npm run test:run`
22+
23+
This keeps unit tests fast and stable across sandboxes. Regular usage (without these flags) fully initializes and uses the local `.stackmemory/context.db`.

package-lock.json

Lines changed: 21 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@
118118
"inquirer": "^9.3.8",
119119
"msgpackr": "^1.10.1",
120120
"ngrok": "^5.0.0-beta.2",
121+
"node-pty": "^1.1.0",
121122
"open": "^11.0.0",
122123
"ora": "^9.0.0",
123124
"pg": "^8.17.1",

scripts/install-claude-hooks.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ MAX_FILE_SIZE=100000 # Max size per file (100KB)
9999
MAX_TOTAL_SIZE=500000 # Max total size (500KB)
100100
101101
# Claude CLI settings
102-
CLAUDE_MODEL=claude-3-opus # Model to use
102+
CLAUDE_MODEL=claude-sonnet-4-20250514 # Model to use
103103
CLAUDE_MAX_TOKENS=4000 # Max tokens per request
104104
105105
# File patterns to check (regex)
@@ -130,4 +130,4 @@ echo ""
130130
echo "Environment variables you can set:"
131131
echo " CLAUDE_AUTO_FIX=true # Auto-apply suggested fixes"
132132
echo " CLAUDE_REVIEW_ENABLED=false # Skip code review"
133-
echo " CLAUDE_TEST_ENABLED=false # Skip test generation"
133+
echo " CLAUDE_TEST_ENABLED=false # Skip test generation"

src/__tests__/integration/cli-integration.test.ts

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,71 @@ import { execSync } from 'child_process';
88
import * as fs from 'fs';
99
import * as path from 'path';
1010
import * as os from 'os';
11+
import Database from 'better-sqlite3';
1112

1213
// Use the built CLI
1314
const projectRoot = path.join(__dirname, '..', '..', '..');
1415
const cliPath = path.join(projectRoot, 'dist', 'src', 'cli', 'index.js');
1516

17+
// Helper to create test database (since init skips DB in test mode)
18+
function createTestDb(testDir: string): void {
19+
const dbDir = path.join(testDir, '.stackmemory');
20+
if (!fs.existsSync(dbDir)) {
21+
fs.mkdirSync(dbDir, { recursive: true });
22+
}
23+
const db = new Database(path.join(dbDir, 'context.db'));
24+
// Create full schema matching FrameDatabase
25+
db.exec(`
26+
CREATE TABLE IF NOT EXISTS frames (
27+
frame_id TEXT PRIMARY KEY,
28+
run_id TEXT NOT NULL DEFAULT 'test-run',
29+
project_id TEXT NOT NULL DEFAULT 'test-project',
30+
parent_frame_id TEXT,
31+
depth INTEGER NOT NULL DEFAULT 0,
32+
type TEXT NOT NULL DEFAULT 'task',
33+
name TEXT NOT NULL DEFAULT 'test',
34+
state TEXT NOT NULL DEFAULT 'active',
35+
inputs TEXT DEFAULT '{}',
36+
outputs TEXT DEFAULT '{}',
37+
digest_text TEXT,
38+
digest_json TEXT DEFAULT '{}',
39+
created_at INTEGER NOT NULL DEFAULT (unixepoch()),
40+
closed_at INTEGER,
41+
FOREIGN KEY (parent_frame_id) REFERENCES frames(frame_id)
42+
);
43+
CREATE TABLE IF NOT EXISTS events (
44+
event_id TEXT PRIMARY KEY,
45+
frame_id TEXT NOT NULL,
46+
run_id TEXT NOT NULL DEFAULT 'test-run',
47+
seq INTEGER NOT NULL DEFAULT 0,
48+
event_type TEXT NOT NULL DEFAULT 'test',
49+
payload TEXT NOT NULL DEFAULT '{}',
50+
ts INTEGER NOT NULL DEFAULT (unixepoch() * 1000),
51+
FOREIGN KEY (frame_id) REFERENCES frames(frame_id) ON DELETE CASCADE
52+
);
53+
CREATE TABLE IF NOT EXISTS anchors (
54+
anchor_id TEXT PRIMARY KEY,
55+
frame_id TEXT NOT NULL,
56+
type TEXT NOT NULL DEFAULT 'FACT',
57+
text TEXT NOT NULL DEFAULT '',
58+
priority INTEGER NOT NULL DEFAULT 5,
59+
metadata TEXT DEFAULT '{}',
60+
created_at INTEGER NOT NULL DEFAULT (unixepoch()),
61+
FOREIGN KEY (frame_id) REFERENCES frames(frame_id) ON DELETE CASCADE
62+
);
63+
CREATE TABLE IF NOT EXISTS sessions (
64+
id TEXT PRIMARY KEY,
65+
project_id TEXT,
66+
created_at INTEGER DEFAULT (unixepoch())
67+
);
68+
CREATE INDEX IF NOT EXISTS idx_frames_project_state ON frames(project_id, state);
69+
CREATE INDEX IF NOT EXISTS idx_frames_parent ON frames(parent_frame_id);
70+
CREATE INDEX IF NOT EXISTS idx_events_frame_seq ON events(frame_id, seq);
71+
CREATE INDEX IF NOT EXISTS idx_anchors_frame_priority ON anchors(frame_id, priority DESC);
72+
`);
73+
db.close();
74+
}
75+
1676
describe('CLI Integration', () => {
1777
let testDir: string;
1878

@@ -78,6 +138,8 @@ describe('CLI Integration', () => {
78138
it('should show clear status', { timeout: 15000 }, () => {
79139
// Initialize first
80140
execSync(`node ${cliPath} init`, { cwd: testDir });
141+
// Create DB since init skips it in test mode
142+
createTestDb(testDir);
81143

82144
const result = execSync(`node ${cliPath} clear --status`, {
83145
cwd: testDir,

src/cli/__tests__/index.test.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,21 @@ describe('CLI Commands', () => {
344344
});
345345
});
346346

347+
describe('ping command', () => {
348+
it('should respond with pong and timestamp', async () => {
349+
const { program } = await import('../index.js');
350+
351+
process.argv = ['node', 'stackmemory', 'ping'];
352+
await program.parseAsync(process.argv);
353+
354+
expect(consoleSpy.log).toHaveBeenCalledWith(
355+
expect.stringMatching(
356+
/^pong \d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/
357+
)
358+
);
359+
});
360+
});
361+
347362
describe('mcp-server command', () => {
348363
it('should start MCP server with default options', async () => {
349364
const { program } = await import('../index.js');

src/cli/claude-sm.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1056,10 +1056,17 @@ class ClaudeSM {
10561056
claudeArgs,
10571057
});
10581058
} catch (error) {
1059-
console.error(chalk.red((error as Error).message));
1060-
process.exit(1);
1059+
// If PTY wrapper fails (e.g., node-pty missing), fall back to direct launch
1060+
const msg = (error as Error).message || 'Unknown PTY error';
1061+
console.error(chalk.yellow(`[Sweep disabled] ${msg}`));
1062+
console.log(
1063+
chalk.gray(
1064+
'Falling back to direct Claude launch (no prediction bar)...'
1065+
)
1066+
);
1067+
// Disable Sweep for this session and continue below
1068+
this.config.useSweep = false;
10611069
}
1062-
return;
10631070
}
10641071

10651072
console.log(chalk.gray('Starting Claude...'));

0 commit comments

Comments
 (0)