@stackmemoryai/stackmemory 1.5.3 → 1.5.4
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/dist/src/cli/commands/orchestrate.js +7 -2
- package/dist/src/cli/commands/orchestrator.js +189 -4
- package/package.json +1 -1
- package/scripts/gepa/.before-optimize.md +89 -53
- package/scripts/gepa/generations/gen-000/baseline.md +8 -0
- package/scripts/gepa/generations/gen-001/baseline.md +8 -0
- package/scripts/gepa/generations/gen-001/variant-a.md +81 -81
- package/scripts/gepa/generations/gen-001/variant-b.md +78 -64
- package/scripts/gepa/generations/gen-001/variant-c.md +54 -74
- package/scripts/gepa/generations/gen-001/variant-d.md +79 -113
- package/scripts/gepa/results/eval-1-baseline.json +74 -74
- package/scripts/gepa/results/eval-1-variant-a.json +64 -64
- package/scripts/gepa/results/eval-1-variant-b.json +65 -65
- package/scripts/gepa/results/eval-1-variant-c.json +78 -58
- package/scripts/gepa/results/eval-1-variant-d.json +77 -57
- package/scripts/gepa/state.json +14 -14
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
```markdown
|
|
1
2
|
# StackMemory - Project Configuration
|
|
2
3
|
|
|
3
4
|
## Project Structure
|
|
@@ -5,7 +6,7 @@
|
|
|
5
6
|
```
|
|
6
7
|
src/
|
|
7
8
|
cli/ # CLI commands and entry point
|
|
8
|
-
core/
|
|
9
|
+
core/
|
|
9
10
|
context/ # Frame and context management
|
|
10
11
|
database/ # Database adapters (SQLite, ParadeDB)
|
|
11
12
|
digest/ # Digest generation
|
|
@@ -15,78 +16,72 @@ src/
|
|
|
15
16
|
skills/ # Claude Code skills
|
|
16
17
|
utils/ # Shared utilities
|
|
17
18
|
scripts/ # Build and utility scripts
|
|
18
|
-
config/ # Configuration files
|
|
19
|
-
docs/ # Documentation
|
|
20
19
|
```
|
|
21
20
|
|
|
22
21
|
## Key Files
|
|
23
22
|
|
|
24
|
-
- Entry: src/cli/index.ts
|
|
25
|
-
- MCP Server: src/integrations/mcp/server.ts
|
|
26
|
-
- Frame Manager: src/core/context/frame-manager.ts
|
|
27
|
-
- Database: src/core/database/sqlite-adapter.ts
|
|
23
|
+
- Entry: `src/cli/index.ts`
|
|
24
|
+
- MCP Server: `src/integrations/mcp/server.ts`
|
|
25
|
+
- Frame Manager: `src/core/context/frame-manager.ts`
|
|
26
|
+
- Database: `src/core/database/sqlite-adapter.ts`
|
|
27
|
+
- Snapshot: `src/core/worktree/capture.ts`
|
|
28
|
+
- Preflight: `src/core/worktree/preflight.ts`
|
|
29
|
+
- Conductor: `src/cli/commands/orchestrator.ts`
|
|
30
|
+
- Shared Utils: `src/core/utils/{git,text,fs}.ts`
|
|
28
31
|
|
|
29
|
-
##
|
|
32
|
+
## Docs
|
|
30
33
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
Full docs (docs/): principles.md | architecture.md | SPEC.md | API_REFERENCE.md | DEVELOPMENT.md | SETUP.md
|
|
34
|
+
- `agent_docs/`: linear_integration.md | mcp_server.md | database_storage.md | claude_hooks.md
|
|
35
|
+
- `docs/`: principles.md | architecture.md | SPEC.md | API_REFERENCE.md | DEVELOPMENT.md
|
|
34
36
|
|
|
35
37
|
## Commands
|
|
36
38
|
|
|
37
39
|
```bash
|
|
38
|
-
npm run build
|
|
39
|
-
|
|
40
|
+
npm run build # Compile TypeScript (esbuild)
|
|
41
|
+
npm run lint # ESLint check
|
|
42
|
+
npm run lint:fix # Auto-fix lint issues
|
|
43
|
+
npm run test:run # Run tests once
|
|
44
|
+
npm run linear:sync # Sync with Linear
|
|
45
|
+
|
|
46
|
+
stackmemory capture # Save session state for handoff
|
|
47
|
+
stackmemory restore # Restore from captured state
|
|
48
|
+
stackmemory snapshot save # Post-run context snapshot (alias: snap)
|
|
49
|
+
stackmemory snapshot list # List recent snapshots
|
|
50
|
+
stackmemory preflight # File overlap check for parallel tasks (alias: pf)
|
|
51
|
+
stackmemory conductor start # Autonomous Linear→worktree→agent orchestrator
|
|
40
52
|
```
|
|
41
53
|
|
|
42
|
-
## Working Directory
|
|
43
|
-
|
|
44
|
-
PRIMARY: /Users/jwu/Dev/stackmemory | ALLOWED: All subdirectories | TEMP: /tmp
|
|
45
|
-
|
|
46
54
|
## Validation (MUST DO)
|
|
47
55
|
|
|
48
|
-
After code changes:
|
|
49
|
-
1. `npm run lint` - fix errors AND warnings
|
|
50
|
-
2. `npm run test:run` - verify no regressions
|
|
51
|
-
3. `npm run build` - ensure compilation
|
|
52
|
-
4. Run code to verify it works
|
|
56
|
+
After code changes: `npm run lint && npm run test:run && npm run build`
|
|
53
57
|
|
|
54
|
-
Test coverage:
|
|
55
58
|
- New features require tests in `src/**/__tests__/`
|
|
56
|
-
- Maintain or improve coverage
|
|
59
|
+
- Maintain or improve coverage — no untested code paths
|
|
57
60
|
- Critical paths: context management, handoff, Linear sync
|
|
58
|
-
|
|
59
|
-
Never: Assume success | Skip testing | Use mock data as fallback
|
|
61
|
+
- Never assume success | skip testing | use mock data as fallback
|
|
60
62
|
|
|
61
63
|
## Git Rules (CRITICAL)
|
|
62
64
|
|
|
63
|
-
- NEVER
|
|
64
|
-
-
|
|
65
|
-
- Run `npm run lint && npm run test:run` before pushing
|
|
66
|
-
- Commit format: `type(scope): message`
|
|
67
|
-
- Branch naming: `feature/STA-XXX-desc` | `fix/STA-XXX-desc` | `chore/desc`
|
|
65
|
+
- NEVER `--no-verify` on push or commit — fix the underlying issue
|
|
66
|
+
- Commit: `type(scope): message` | Branch: `feature/STA-XXX-description` | `fix/` | `chore/`
|
|
68
67
|
|
|
69
68
|
## Security
|
|
70
69
|
|
|
71
|
-
NEVER hardcode secrets
|
|
70
|
+
NEVER hardcode secrets — use `process.env` with dotenv/config.
|
|
72
71
|
|
|
73
72
|
```javascript
|
|
74
73
|
import 'dotenv/config';
|
|
75
74
|
const API_KEY = process.env.LINEAR_API_KEY;
|
|
76
|
-
if (!API_KEY) {
|
|
77
|
-
console.error('LINEAR_API_KEY not set');
|
|
78
|
-
process.exit(1);
|
|
79
|
-
}
|
|
75
|
+
if (!API_KEY) { console.error('LINEAR_API_KEY not set'); process.exit(1); }
|
|
80
76
|
```
|
|
81
77
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
Secret patterns to block: lin_api_* | lin_oauth_* | sk-* | npm_*
|
|
78
|
+
Env sources (order): `.env` → `.env.local` → `~/.zshrc` → process env
|
|
79
|
+
Block patterns: `lin_api_*` | `lin_oauth_*` | `sk-*` | `npm_*`
|
|
85
80
|
|
|
86
81
|
## Deploy
|
|
87
82
|
|
|
88
83
|
```bash
|
|
89
|
-
# npm publish
|
|
84
|
+
# npm publish
|
|
90
85
|
git stash -- scripts/gepa/
|
|
91
86
|
NPM_TOKEN=$(grep '^NPM_TOKEN=' .env | cut -d= -f2) \
|
|
92
87
|
npm publish --registry https://registry.npmjs.org/ \
|
|
@@ -95,48 +90,33 @@ git stash pop
|
|
|
95
90
|
|
|
96
91
|
# Railway
|
|
97
92
|
railway up
|
|
98
|
-
|
|
99
|
-
# Pre-publish requires clean git — stash GEPA files first
|
|
100
93
|
```
|
|
101
94
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
Route effort by complexity:
|
|
95
|
+
Pre-publish requires clean git status — stash GEPA files first.
|
|
105
96
|
|
|
106
|
-
|
|
107
|
-
- CRUD, boilerplate, formatting, simple transforms
|
|
108
|
-
- Tool handler following existing pattern
|
|
109
|
-
- Config additions (env var, feature flag)
|
|
97
|
+
## Task Delegation Model
|
|
110
98
|
|
|
111
|
-
**
|
|
112
|
-
-
|
|
113
|
-
- Tests, docs, integration wiring
|
|
99
|
+
**AUTOMATE** — lint+test sufficient:
|
|
100
|
+
- CRUD, boilerplate, config additions, simple switch/case handlers
|
|
114
101
|
|
|
115
|
-
**
|
|
116
|
-
-
|
|
117
|
-
- New integration patterns (MCP, webhooks)
|
|
118
|
-
- Changes to frame-manager, sqlite-adapter, daemon lifecycle
|
|
119
|
-
- Error handling chains
|
|
102
|
+
**STANDARD** — lint+test+build:
|
|
103
|
+
- Feature impl, bug fixes, refactoring, new tests, integration wiring
|
|
120
104
|
|
|
121
|
-
**
|
|
122
|
-
-
|
|
123
|
-
-
|
|
124
|
-
- Breaking changes to MCP protocol or CLI
|
|
105
|
+
**CAREFUL** — review approach first:
|
|
106
|
+
- API/schema changes, DB migrations, auth flows, MCP/webhook handlers
|
|
107
|
+
- Changes to frame-manager, sqlite-adapter, daemon lifecycle, error chains
|
|
125
108
|
|
|
126
|
-
**
|
|
127
|
-
-
|
|
128
|
-
- Irreversible operations (migrations, schema drops)
|
|
129
|
-
- Publishing (npm, Railway)
|
|
109
|
+
**ARCHITECT** — plan mode required:
|
|
110
|
+
- New service boundaries, FTS5/search performance, breaking MCP/CLI changes
|
|
130
111
|
|
|
131
|
-
|
|
112
|
+
**HUMAN** — explicit approval required:
|
|
113
|
+
- Secret handling, data migrations/schema drops, npm publish, Railway deploy
|
|
132
114
|
|
|
133
115
|
## Workflow
|
|
134
116
|
|
|
135
|
-
- Check
|
|
136
|
-
- Run npm run linear:sync after task completion
|
|
137
|
-
-
|
|
138
|
-
-
|
|
139
|
-
-
|
|
140
|
-
|
|
141
|
-
- Update task status immediately on completion
|
|
142
|
-
- Ask 1-3 clarifying questions for complex commands (one at a time)
|
|
117
|
+
- Check `.env` for API keys before asking
|
|
118
|
+
- Run `npm run linear:sync` after task completion
|
|
119
|
+
- Review recent commits on session start
|
|
120
|
+
- Use subagents for multi-step tasks
|
|
121
|
+
- Ask 1–3 clarifying questions for complex commands (one at a time)
|
|
122
|
+
```
|
|
@@ -1,150 +1,115 @@
|
|
|
1
|
+
```markdown
|
|
1
2
|
# StackMemory - Project Configuration
|
|
2
3
|
|
|
3
|
-
##
|
|
4
|
+
## Quick Reference
|
|
4
5
|
|
|
5
|
-
|
|
6
|
+
**Entry points:** `src/cli/index.ts` · `src/integrations/mcp/server.ts`
|
|
7
|
+
**Key files:** `src/core/context/frame-manager.ts` · `src/core/database/sqlite-adapter.ts` · `src/core/worktree/{capture,preflight}.ts` · `src/cli/commands/orchestrator.ts` · `src/core/utils/{git,text,fs}.ts`
|
|
6
8
|
|
|
7
|
-
**
|
|
8
|
-
**Tech**: TypeScript, Node.js, SQLite, Vitest, ESLint, esbuild
|
|
9
|
+
**Docs:** `agent_docs/` (quick ref) · `docs/` (full: principles, architecture, SPEC, API_REFERENCE, DEVELOPMENT, SETUP)
|
|
9
10
|
|
|
10
|
-
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## Project Structure
|
|
11
14
|
|
|
12
15
|
```
|
|
13
16
|
src/
|
|
14
|
-
cli/ # CLI entry
|
|
15
|
-
core/
|
|
16
|
-
context/ # Frame management
|
|
17
|
-
database/ #
|
|
17
|
+
cli/ # CLI commands and entry point
|
|
18
|
+
core/
|
|
19
|
+
context/ # Frame and context management
|
|
20
|
+
database/ # Database adapters (SQLite, ParadeDB)
|
|
18
21
|
digest/ # Digest generation
|
|
19
|
-
query/ # Query routing
|
|
20
|
-
integrations/ # Linear, MCP
|
|
22
|
+
query/ # Query parsing and routing
|
|
23
|
+
integrations/ # External integrations (Linear, MCP)
|
|
21
24
|
services/ # Business services
|
|
22
25
|
skills/ # Claude Code skills
|
|
23
26
|
utils/ # Shared utilities
|
|
27
|
+
scripts/ # Build and utility scripts
|
|
28
|
+
config/ # Configuration files
|
|
29
|
+
docs/ # Documentation
|
|
24
30
|
```
|
|
25
31
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
**Quick reference** (agent_docs/):
|
|
29
|
-
- linear_integration.md
|
|
30
|
-
- mcp_server.md
|
|
31
|
-
- database_storage.md
|
|
32
|
-
- claude_hooks.md
|
|
33
|
-
|
|
34
|
-
**Full docs** (docs/):
|
|
35
|
-
- principles.md - Agent paradigm
|
|
36
|
-
- architecture.md - Extension model
|
|
37
|
-
- SPEC.md - Technical spec
|
|
38
|
-
- API_REFERENCE.md
|
|
39
|
-
- DEVELOPMENT.md
|
|
40
|
-
- SETUP.md
|
|
32
|
+
---
|
|
41
33
|
|
|
42
34
|
## Commands
|
|
43
35
|
|
|
44
36
|
```bash
|
|
45
37
|
# Build & Quality
|
|
46
|
-
npm run build # Compile (esbuild)
|
|
47
|
-
npm run lint #
|
|
48
|
-
npm run lint:fix # Auto-fix
|
|
49
|
-
npm test #
|
|
50
|
-
npm run test:run # Run once
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
#
|
|
56
|
-
stackmemory
|
|
57
|
-
stackmemory
|
|
38
|
+
npm run build # Compile TypeScript (esbuild)
|
|
39
|
+
npm run lint # ESLint check
|
|
40
|
+
npm run lint:fix # Auto-fix lint issues
|
|
41
|
+
npm test # Run Vitest (watch)
|
|
42
|
+
npm run test:run # Run tests once
|
|
43
|
+
npm run linear:sync # Sync with Linear
|
|
44
|
+
|
|
45
|
+
# StackMemory CLI
|
|
46
|
+
stackmemory capture # Save session state for handoff
|
|
47
|
+
stackmemory restore # Restore from captured state
|
|
48
|
+
stackmemory snapshot save # Post-run context snapshot (alias: snap)
|
|
49
|
+
stackmemory snapshot list # List recent snapshots
|
|
50
|
+
stackmemory preflight # File overlap check for parallel tasks (alias: pf)
|
|
51
|
+
stackmemory conductor start # Autonomous Linear→worktree→agent orchestrator
|
|
58
52
|
```
|
|
59
53
|
|
|
60
|
-
|
|
54
|
+
---
|
|
61
55
|
|
|
62
|
-
|
|
56
|
+
## Validation (MUST DO)
|
|
63
57
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
58
|
+
After every code change:
|
|
59
|
+
1. `npm run lint` — fix all errors AND warnings
|
|
60
|
+
2. `npm run test:run` — verify no regressions
|
|
61
|
+
3. `npm run build` — ensure compilation
|
|
62
|
+
4. Run the code to verify it works
|
|
68
63
|
|
|
69
|
-
**Test coverage
|
|
70
|
-
- New features require tests in `src/**/__tests__/`
|
|
71
|
-
- Maintain or improve coverage (no untested paths)
|
|
72
|
-
- Critical: context management, handoff, Linear sync
|
|
64
|
+
**Test coverage:** New features require tests in `src/**/__tests__/`. Maintain or improve coverage. Critical paths: context management, handoff, Linear sync.
|
|
73
65
|
|
|
74
|
-
|
|
66
|
+
Never: assume success · skip testing · use mock data as fallback
|
|
75
67
|
|
|
76
|
-
|
|
68
|
+
---
|
|
77
69
|
|
|
78
|
-
|
|
79
|
-
**Branch naming**: `feature/STA-XXX-desc` | `fix/STA-XXX-desc` | `chore/desc`
|
|
70
|
+
## Git Rules (CRITICAL)
|
|
80
71
|
|
|
81
|
-
|
|
82
|
-
-
|
|
83
|
-
- ALWAYS fix lint/test errors before pushing
|
|
72
|
+
- NEVER use `--no-verify` on git push or commit
|
|
73
|
+
- ALWAYS fix lint/test errors before pushing; if pre-push hooks fail, fix the issue
|
|
84
74
|
- Run `npm run lint && npm run test:run` before pushing
|
|
85
|
-
-
|
|
75
|
+
- Commit: `type(scope): message`
|
|
76
|
+
- Branch: `feature/STA-XXX-description` · `fix/STA-XXX-description` · `chore/description`
|
|
77
|
+
|
|
78
|
+
---
|
|
86
79
|
|
|
87
80
|
## Task Delegation Model
|
|
88
81
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
Normal workflow, lint+test+build:
|
|
99
|
-
- Features, bug fixes, refactoring
|
|
100
|
-
- Test coverage, documentation
|
|
101
|
-
- Integration wiring (server.ts dispatch)
|
|
102
|
-
|
|
103
|
-
### CAREFUL
|
|
104
|
-
Review approach before implementation:
|
|
105
|
-
- API/schema changes, database migrations, auth
|
|
106
|
-
- New integration patterns (MCP tools, webhooks)
|
|
107
|
-
- Changes to frame-manager, sqlite-adapter, daemon lifecycle
|
|
108
|
-
- Error handling chains
|
|
109
|
-
|
|
110
|
-
### ARCHITECT
|
|
111
|
-
Plan mode required, explore patterns first:
|
|
112
|
-
- New service boundaries, system integrations
|
|
113
|
-
- Performance-critical (FTS5 queries, search scoring)
|
|
114
|
-
- Breaking changes (MCP protocol, CLI interface)
|
|
115
|
-
|
|
116
|
-
### HUMAN
|
|
117
|
-
Explicit approval before changes:
|
|
118
|
-
- Security decisions, secret handling
|
|
119
|
-
- Irreversible operations (migrations, schema drops)
|
|
120
|
-
- Publishing (npm, Railway)
|
|
82
|
+
| Tier | When | Gates |
|
|
83
|
+
|------|------|-------|
|
|
84
|
+
| **AUTOMATE** | CRUD, boilerplate, config additions, simple switch/case handlers | lint + test |
|
|
85
|
+
| **STANDARD** | Features, bug fixes, refactoring, new tests, integration wiring | lint + test + build |
|
|
86
|
+
| **CAREFUL** | API/schema changes, DB migrations, auth, MCP tools, frame-manager/sqlite-adapter/daemon lifecycle | Review approach first |
|
|
87
|
+
| **ARCHITECT** | New service boundaries, FTS5/search perf, breaking MCP/CLI changes | Plan mode required |
|
|
88
|
+
| **HUMAN** | Security decisions, secret handling, irreversible ops, publishing | Explicit approval |
|
|
89
|
+
|
|
90
|
+
---
|
|
121
91
|
|
|
122
92
|
## Security
|
|
123
93
|
|
|
124
|
-
|
|
94
|
+
NEVER hardcode secrets — use `process.env` with dotenv/config:
|
|
125
95
|
|
|
126
96
|
```javascript
|
|
127
97
|
import 'dotenv/config';
|
|
128
98
|
const API_KEY = process.env.LINEAR_API_KEY;
|
|
129
|
-
if (!API_KEY) {
|
|
130
|
-
console.error('LINEAR_API_KEY not set');
|
|
131
|
-
process.exit(1);
|
|
132
|
-
}
|
|
99
|
+
if (!API_KEY) { console.error('LINEAR_API_KEY not set'); process.exit(1); }
|
|
133
100
|
```
|
|
134
101
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
3. ~/.zshrc
|
|
139
|
-
4. Process environment
|
|
102
|
+
Env lookup order: `.env` → `.env.local` → `~/.zshrc` → process env
|
|
103
|
+
|
|
104
|
+
Block patterns: `lin_api_*` · `lin_oauth_*` · `sk-*` · `npm_*`
|
|
140
105
|
|
|
141
|
-
|
|
106
|
+
---
|
|
142
107
|
|
|
143
|
-
##
|
|
108
|
+
## Deploy
|
|
144
109
|
|
|
145
110
|
```bash
|
|
146
|
-
# npm publish (uses NPM_TOKEN from .env, no OTP)
|
|
147
|
-
git stash -- scripts/gepa/ # stash GEPA state
|
|
111
|
+
# npm publish (uses NPM_TOKEN from .env, no OTP needed)
|
|
112
|
+
git stash -- scripts/gepa/ # stash GEPA state (dirties working tree)
|
|
148
113
|
NPM_TOKEN=$(grep '^NPM_TOKEN=' .env | cut -d= -f2) \
|
|
149
114
|
npm publish --registry https://registry.npmjs.org/ \
|
|
150
115
|
--//registry.npmjs.org/:_authToken="$NPM_TOKEN"
|
|
@@ -152,21 +117,22 @@ git stash pop # restore GEPA state
|
|
|
152
117
|
|
|
153
118
|
# Railway
|
|
154
119
|
railway up
|
|
155
|
-
|
|
156
|
-
# Note: Pre-publish checks require clean git status
|
|
157
120
|
```
|
|
158
121
|
|
|
159
|
-
|
|
122
|
+
Pre-publish checks require clean git status — stash GEPA files first.
|
|
160
123
|
|
|
161
|
-
|
|
162
|
-
- Keep one task in_progress at a time
|
|
163
|
-
- Update status immediately on completion
|
|
124
|
+
---
|
|
164
125
|
|
|
165
|
-
## Workflow
|
|
126
|
+
## Workflow
|
|
166
127
|
|
|
167
|
-
- Check
|
|
128
|
+
- Check `.env` for API keys before asking
|
|
129
|
+
- Review recent commits and `stackmemory.json` on session start
|
|
130
|
+
- Use subagents for multi-step tasks
|
|
168
131
|
- Run `npm run linear:sync` after task completion
|
|
169
132
|
- Use browser MCP for visual testing
|
|
170
|
-
-
|
|
171
|
-
|
|
172
|
-
|
|
133
|
+
- Ask 1–3 clarifying questions for complex commands (one at a time)
|
|
134
|
+
|
|
135
|
+
**Task management:** Use TodoWrite for 3+ steps. Keep one task `in_progress`. Update status immediately on completion.
|
|
136
|
+
|
|
137
|
+
**Working directory:** PRIMARY `/Users/jwu/Dev/stackmemory` · TEMP `/tmp`
|
|
138
|
+
```
|