@stackmemoryai/stackmemory 1.2.1 → 1.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.
- package/dist/src/cli/commands/skills.js +123 -1
- package/dist/src/hooks/graphiti-hooks.js +149 -0
- package/dist/src/hooks/session-summary.js +30 -0
- package/dist/src/integrations/graphiti/linear-graphiti-bridge.js +115 -0
- package/dist/src/integrations/greptile/client.js +101 -0
- package/dist/src/integrations/greptile/config.js +14 -0
- package/dist/src/integrations/greptile/index.js +11 -0
- package/dist/src/integrations/greptile/types.js +4 -0
- package/dist/src/integrations/linear/webhook.js +16 -0
- package/dist/src/integrations/mcp/handlers/greptile-handlers.js +456 -0
- package/dist/src/integrations/mcp/server.js +27 -0
- package/dist/src/skills/claude-skills.js +46 -1
- package/dist/src/skills/parallel-agent-skill.js +514 -0
- package/package.json +1 -1
- package/scripts/gepa/.before-optimize.md +140 -159
- package/scripts/gepa/config.json +7 -1
- package/scripts/gepa/evals/fixtures/api-endpoint.ts +31 -0
- package/scripts/gepa/evals/fixtures/brittle-integration.ts +38 -0
- package/scripts/gepa/evals/fixtures/fts5-triggers.sql +23 -0
- package/scripts/gepa/evals/fixtures/leaky-service.ts +70 -0
- package/scripts/gepa/evals/fixtures/mcp-dispatch-stub.ts +39 -0
- package/scripts/gepa/evals/fixtures/pr-diff.txt +24 -0
- package/scripts/gepa/evals/fixtures/unsafe-webhook.ts +34 -0
- package/scripts/gepa/evals/fixtures/unwrapped-db-op.ts +42 -0
- package/scripts/gepa/evals/stackmemory-tasks.jsonl +8 -0
- package/scripts/gepa/generations/gen-000/baseline.md +172 -159
- package/scripts/gepa/generations/gen-001/baseline.md +172 -159
- package/scripts/gepa/generations/gen-001/variant-a.md +156 -146
- package/scripts/gepa/generations/gen-001/variant-b.md +199 -170
- package/scripts/gepa/generations/gen-001/variant-c.md +127 -46
- package/scripts/gepa/generations/gen-001/variant-d.md +160 -107
- package/scripts/gepa/hooks/reflect.js +44 -5
- package/scripts/gepa/optimize.js +281 -39
- package/scripts/gepa/results/eval-1-baseline.json +187 -10
- package/scripts/gepa/results/eval-1-variant-a.json +188 -11
- package/scripts/gepa/results/eval-1-variant-b.json +188 -11
- package/scripts/gepa/results/eval-1-variant-c.json +168 -11
- package/scripts/gepa/results/eval-1-variant-d.json +169 -12
- package/scripts/gepa/state.json +18 -18
|
@@ -1,237 +1,266 @@
|
|
|
1
|
-
#
|
|
1
|
+
# StackMemory - Project Configuration
|
|
2
|
+
|
|
3
|
+
## Project Structure
|
|
2
4
|
|
|
3
|
-
## Refs
|
|
4
5
|
```
|
|
5
|
-
|
|
6
|
-
|
|
6
|
+
src/
|
|
7
|
+
cli/ # CLI commands and entry point
|
|
8
|
+
core/ # Core business logic
|
|
9
|
+
context/ # Frame and context management
|
|
10
|
+
database/ # Database adapters (SQLite, ParadeDB)
|
|
11
|
+
digest/ # Digest generation
|
|
12
|
+
query/ # Query parsing and routing
|
|
13
|
+
integrations/ # External integrations (Linear, MCP)
|
|
14
|
+
services/ # Business services
|
|
15
|
+
skills/ # Claude Code skills
|
|
16
|
+
utils/ # Shared utilities
|
|
17
|
+
scripts/ # Build and utility scripts
|
|
18
|
+
config/ # Configuration files
|
|
19
|
+
docs/ # Documentation
|
|
7
20
|
```
|
|
8
21
|
|
|
22
|
+
## Key Files
|
|
23
|
+
|
|
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
|
|
28
|
+
|
|
29
|
+
## Detailed Guides
|
|
30
|
+
|
|
31
|
+
Quick reference (agent_docs/):
|
|
32
|
+
- linear_integration.md - Linear sync
|
|
33
|
+
- mcp_server.md - MCP tools
|
|
34
|
+
- database_storage.md - Storage
|
|
35
|
+
- claude_hooks.md - Hooks
|
|
36
|
+
|
|
37
|
+
Full documentation (docs/):
|
|
38
|
+
- principles.md - Agent programming paradigm
|
|
39
|
+
- architecture.md - Extension model and browser sandbox
|
|
40
|
+
- SPEC.md - Technical specification
|
|
41
|
+
- API_REFERENCE.md - API docs
|
|
42
|
+
- DEVELOPMENT.md - Dev guide
|
|
43
|
+
- SETUP.md - Installation
|
|
44
|
+
|
|
9
45
|
## Commands
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
npm run build # Compile TypeScript (esbuild)
|
|
49
|
+
npm run lint # ESLint check
|
|
50
|
+
npm run lint:fix # Auto-fix lint issues
|
|
51
|
+
npm test # Run Vitest (watch)
|
|
52
|
+
npm run test:run # Run tests once
|
|
53
|
+
npm run linear:sync # Sync with Linear
|
|
54
|
+
|
|
55
|
+
# StackMemory CLI
|
|
56
|
+
stackmemory capture # Save session state for handoff
|
|
57
|
+
stackmemory restore # Restore from captured state
|
|
14
58
|
```
|
|
15
59
|
|
|
16
|
-
##
|
|
17
|
-
[PRINCIPLE]code>docs|simple→complex|security first|evidence-based
|
|
18
|
-
[COMM]concise|symbols>prose|bullets>paragraphs|<4 lines
|
|
19
|
-
[WORKFLOW]TodoWrite(3+)→execute→update
|
|
20
|
-
[GIT]clean commits|type(scope): message|feature/|fix/|chore/ prefix
|
|
21
|
-
[STACK]React/TS/Vite|Node/Express/PG|Git/ESLint/Jest
|
|
22
|
-
|
|
23
|
-
## Think
|
|
24
|
-
[NONE]single file,<10 lines
|
|
25
|
-
[THINK]multi-file,standard|~4K
|
|
26
|
-
[HARD]architecture,complex|~10K
|
|
27
|
-
[ULTRA]critical redesign|~32K
|
|
28
|
-
|
|
29
|
-
## Critical [C:10]
|
|
30
|
-
[SECURITY]
|
|
31
|
-
NEVER:commit secrets|exec untrusted|expose PII|force push
|
|
32
|
-
ALWAYS:validate input|parameterized queries|hash passwords
|
|
33
|
-
BLOCK:~/.ssh|~/.aws|/api[_-]?key|token|secret/i
|
|
60
|
+
## Working Directory
|
|
34
61
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
✅ GOOD:
|
|
41
|
-
```js
|
|
42
|
-
db.query('SELECT * FROM users WHERE id = $1', [userId])
|
|
43
|
-
```
|
|
44
|
-
</example>
|
|
62
|
+
- PRIMARY: /Users/jwu/Dev/stackmemory
|
|
63
|
+
- ALLOWED: All subdirectories
|
|
64
|
+
- TEMP: /tmp for temporary operations
|
|
65
|
+
|
|
66
|
+
## Validation (MUST DO)
|
|
45
67
|
|
|
46
|
-
|
|
68
|
+
After code changes:
|
|
69
|
+
1. `npm run lint` - fix any errors AND warnings
|
|
70
|
+
2. `npm run test:run` - verify no regressions
|
|
71
|
+
3. `npm run build` - ensure compilation
|
|
72
|
+
4. Run code to verify it works
|
|
47
73
|
|
|
48
74
|
<example>
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
✅ GOOD:
|
|
54
|
-
```ts
|
|
55
|
-
import { foo } from './bar.js'
|
|
56
|
-
```
|
|
75
|
+
# After adding a new MCP tool handler
|
|
76
|
+
npm run lint && npm run test:run && npm run build
|
|
77
|
+
# Then test the tool:
|
|
78
|
+
echo '{"method":"tools/call","params":{"name":"your_tool"}}' | node dist/integrations/mcp/server.js
|
|
57
79
|
</example>
|
|
58
80
|
|
|
59
|
-
|
|
81
|
+
Test coverage:
|
|
82
|
+
- New features require tests in `src/**/__tests__/`
|
|
83
|
+
- Maintain or improve coverage (no untested code paths)
|
|
84
|
+
- Critical paths: context management, handoff, Linear sync
|
|
60
85
|
|
|
61
86
|
<example>
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
if (!id) throw new Error('No ID')
|
|
66
|
-
return users.find(u => u.id === id)
|
|
67
|
-
}
|
|
68
|
-
```
|
|
69
|
-
✅ GOOD:
|
|
70
|
-
```js
|
|
71
|
-
function getUser(id) {
|
|
72
|
-
if (!id) return undefined
|
|
73
|
-
return users.find(u => u.id === id)
|
|
74
|
-
}
|
|
75
|
-
```
|
|
87
|
+
# New feature: src/core/context/frame-deduplicator.ts
|
|
88
|
+
# Required: src/core/context/__tests__/frame-deduplicator.test.ts
|
|
89
|
+
# Test both happy path and edge cases (empty input, duplicates, conflicts)
|
|
76
90
|
</example>
|
|
77
91
|
|
|
78
|
-
|
|
92
|
+
Never: Assume success | Skip testing | Use mock data as fallback
|
|
79
93
|
|
|
80
|
-
|
|
81
|
-
❌ BAD:
|
|
82
|
-
```js
|
|
83
|
-
// This function gets the user from the database
|
|
84
|
-
function getUserFromDatabase(userId) { ... }
|
|
85
|
-
```
|
|
86
|
-
✅ GOOD:
|
|
87
|
-
```js
|
|
88
|
-
function getUser(id) { ... }
|
|
89
|
-
// Only comment complex parts:
|
|
90
|
-
const hash = await bcrypt.hash(pwd, 10) // 10 rounds for security/perf balance
|
|
91
|
-
```
|
|
92
|
-
</example>
|
|
94
|
+
## Git Rules (CRITICAL)
|
|
93
95
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
+
- NEVER use `--no-verify` on git push or commit
|
|
97
|
+
- ALWAYS fix lint/test errors before pushing
|
|
98
|
+
- If pre-push hooks fail, fix the underlying issue
|
|
99
|
+
- Run `npm run lint && npm run test:run` before pushing
|
|
100
|
+
- Commit message format: `type(scope): message`
|
|
101
|
+
- Branch naming: `feature/STA-XXX-description` | `fix/STA-XXX-description` | `chore/description`
|
|
96
102
|
|
|
97
103
|
<example>
|
|
98
|
-
|
|
99
|
-
|
|
104
|
+
# Good commits:
|
|
105
|
+
feat(mcp): add search_frames tool for context retrieval
|
|
106
|
+
fix(linear): handle null assignee in webhook handler
|
|
107
|
+
chore(deps): upgrade better-sqlite3 to 11.8.0
|
|
108
|
+
|
|
109
|
+
# Good branches:
|
|
110
|
+
feature/STA-123-add-digest-export
|
|
111
|
+
fix/STA-456-frame-timestamp-parsing
|
|
112
|
+
chore/upgrade-typescript-5.3
|
|
100
113
|
</example>
|
|
101
114
|
|
|
102
|
-
|
|
115
|
+
## Task Management
|
|
116
|
+
|
|
117
|
+
- Use TodoWrite for 3+ steps or multiple requests
|
|
118
|
+
- Keep one task in_progress at a time
|
|
119
|
+
- Update task status immediately on completion
|
|
103
120
|
|
|
104
121
|
<example>
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
-
|
|
122
|
+
# Multi-step task requires TodoWrite:
|
|
123
|
+
User: "Add Graphiti integration with Linear bridge"
|
|
124
|
+
1. Create TodoWrite with 4 tasks:
|
|
125
|
+
- Research Graphiti API patterns
|
|
126
|
+
- Implement LinearGraphitiBridge class
|
|
127
|
+
- Add webhook handler for Linear events
|
|
128
|
+
- Write integration tests
|
|
129
|
+
2. Mark task 1 in_progress, complete it
|
|
130
|
+
3. Mark task 2 in_progress, etc.
|
|
109
131
|
</example>
|
|
110
132
|
|
|
111
|
-
|
|
133
|
+
## Security
|
|
134
|
+
|
|
135
|
+
NEVER hardcode secrets - use process.env with dotenv/config
|
|
112
136
|
|
|
113
137
|
<example>
|
|
114
|
-
|
|
115
|
-
|
|
138
|
+
// ✓ CORRECT
|
|
139
|
+
import 'dotenv/config';
|
|
140
|
+
const API_KEY = process.env.LINEAR_API_KEY;
|
|
141
|
+
if (!API_KEY) {
|
|
142
|
+
console.error('LINEAR_API_KEY not set');
|
|
143
|
+
process.exit(1);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
// ✗ WRONG
|
|
147
|
+
const API_KEY = 'lin_api_abc123def456';
|
|
116
148
|
</example>
|
|
117
149
|
|
|
118
|
-
|
|
150
|
+
Environment sources (check in order):
|
|
151
|
+
1. .env file
|
|
152
|
+
2. .env.local
|
|
153
|
+
3. ~/.zshrc
|
|
154
|
+
4. Process environment
|
|
119
155
|
|
|
120
|
-
|
|
121
|
-
[TASK]TodoWrite 3+|one in_progress|update immediate
|
|
156
|
+
Secret patterns to block: lin_api_* | lin_oauth_* | sk-* | npm_*
|
|
122
157
|
|
|
123
158
|
<example>
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
4. Complete work
|
|
129
|
-
5. TaskUpdate task1 → completed
|
|
130
|
-
6. TaskUpdate task2 → in_progress
|
|
159
|
+
# If you see this pattern, STOP and use env vars:
|
|
160
|
+
const token = 'lin_api_...';
|
|
161
|
+
const apiKey = 'sk-...';
|
|
162
|
+
const npmToken = 'npm_...';
|
|
131
163
|
</example>
|
|
132
164
|
|
|
133
|
-
|
|
165
|
+
## Deploy
|
|
134
166
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
const valid = validateUser(user)
|
|
148
|
-
return valid ? transformUser(user) : null
|
|
149
|
-
}
|
|
167
|
+
```bash
|
|
168
|
+
# npm publish (uses NPM_TOKEN from .env, no OTP needed)
|
|
169
|
+
git stash -- scripts/gepa/ # stash GEPA state (dirties working tree)
|
|
170
|
+
NPM_TOKEN=$(grep '^NPM_TOKEN=' .env | cut -d= -f2) \
|
|
171
|
+
npm publish --registry https://registry.npmjs.org/ \
|
|
172
|
+
--//registry.npmjs.org/:_authToken="$NPM_TOKEN"
|
|
173
|
+
git stash pop # restore GEPA state
|
|
174
|
+
|
|
175
|
+
# Railway
|
|
176
|
+
railway up
|
|
177
|
+
|
|
178
|
+
# Pre-publish checks require clean git status — stash GEPA files first
|
|
150
179
|
```
|
|
151
|
-
</example>
|
|
152
180
|
|
|
153
|
-
|
|
181
|
+
## Task Delegation Model
|
|
154
182
|
|
|
155
|
-
|
|
156
|
-
❌ BAD: User asks to update function → Write entire new file
|
|
157
|
-
✅ GOOD: User asks to update function → Read file → Edit specific function
|
|
158
|
-
</example>
|
|
183
|
+
Route effort by task complexity — not all code changes deserve equal scrutiny:
|
|
159
184
|
|
|
160
|
-
|
|
185
|
+
**AUTOMATE** — Execute immediately, lint+test is sufficient:
|
|
186
|
+
- CRUD operations, boilerplate, formatting, simple transforms
|
|
187
|
+
- Adding a tool handler following existing switch/case pattern
|
|
188
|
+
- Config additions (new env var, feature flag)
|
|
161
189
|
|
|
162
190
|
<example>
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
3. `npm test` → verify passing
|
|
167
|
-
4. `npm run build` → ensure clean build
|
|
168
|
-
5. Only then mark task complete
|
|
191
|
+
# AUTOMATE tier example:
|
|
192
|
+
User: "Add a new MCP tool for listing frames by tag"
|
|
193
|
+
Action: Add case to server.ts switch, follow existing pattern, lint+test
|
|
169
194
|
</example>
|
|
170
195
|
|
|
171
|
-
|
|
196
|
+
**STANDARD** — Normal workflow, lint+test+build:
|
|
197
|
+
- Feature implementation, bug fixes, refactoring
|
|
198
|
+
- New test coverage, documentation updates
|
|
199
|
+
- Integration wiring (adding handler to server.ts dispatch)
|
|
172
200
|
|
|
173
201
|
<example>
|
|
174
|
-
|
|
175
|
-
|
|
202
|
+
# STANDARD tier example:
|
|
203
|
+
User: "Fix the digest generation to include frame metadata"
|
|
204
|
+
Action: Modify digest-generator.ts, add tests, lint+test+build, verify output
|
|
176
205
|
</example>
|
|
177
206
|
|
|
178
|
-
|
|
179
|
-
|
|
207
|
+
**CAREFUL** — Review approach before implementation:
|
|
208
|
+
- API/schema changes, database migrations, auth flows
|
|
209
|
+
- New integration patterns (MCP tools, webhook handlers)
|
|
210
|
+
- Changes to frame-manager, sqlite-adapter, or daemon lifecycle
|
|
211
|
+
- Anything touching error handling chains
|
|
180
212
|
|
|
181
213
|
<example>
|
|
182
|
-
|
|
183
|
-
|
|
214
|
+
# CAREFUL tier example:
|
|
215
|
+
User: "Add a new column to frames table for priority scoring"
|
|
216
|
+
Action: Read schema, check migrations, discuss ALTER TABLE vs rebuild, plan rollback
|
|
184
217
|
</example>
|
|
185
218
|
|
|
186
|
-
|
|
219
|
+
**ARCHITECT** — Plan mode required, explore existing patterns first:
|
|
220
|
+
- New service boundaries, system integrations
|
|
221
|
+
- Performance-critical paths (FTS5 queries, search scoring)
|
|
222
|
+
- Breaking changes to MCP protocol or CLI interface
|
|
187
223
|
|
|
188
224
|
<example>
|
|
189
|
-
|
|
190
|
-
|
|
225
|
+
# ARCHITECT tier example:
|
|
226
|
+
User: "Integrate Graphiti knowledge graph with existing frame storage"
|
|
227
|
+
Action: EnterPlanMode, explore frame-manager.ts, research Graphiti API, design bridge layer
|
|
191
228
|
</example>
|
|
192
229
|
|
|
193
|
-
|
|
230
|
+
**HUMAN** — Explicit user approval before any changes:
|
|
231
|
+
- Security-critical decisions, secret handling
|
|
232
|
+
- Irreversible operations (data migrations, schema drops)
|
|
233
|
+
- Publishing (npm publish, Railway deploy)
|
|
194
234
|
|
|
195
235
|
<example>
|
|
196
|
-
|
|
197
|
-
|
|
236
|
+
# HUMAN tier example:
|
|
237
|
+
User: "Publish v1.3.0 to npm"
|
|
238
|
+
Action: Ask "Ready to publish? This will run npm publish with NPM_TOKEN." Wait for approval.
|
|
198
239
|
</example>
|
|
199
240
|
|
|
200
|
-
|
|
201
|
-
```
|
|
202
|
-
Session: actual vs estimated|variance %
|
|
203
|
-
Completed: N/M tasks|files modified|commits
|
|
204
|
-
Outcomes: deliverables|blockers|next actions
|
|
205
|
-
```
|
|
241
|
+
Quality gates scale with tier — don't over-engineer AUTOMATE tasks, don't under-review CAREFUL ones.
|
|
206
242
|
|
|
207
|
-
|
|
208
|
-
✅ GOOD summary:
|
|
209
|
-
```
|
|
210
|
-
Completed: 3/4 tasks | 7 files | 2 commits
|
|
211
|
-
Outcomes: Auth refresh implemented, tests passing
|
|
212
|
-
Blockers: Redis connection requires env var
|
|
213
|
-
Next: Add REDIS_URL to .env, deploy to staging
|
|
214
|
-
```
|
|
215
|
-
</example>
|
|
243
|
+
## Workflow
|
|
216
244
|
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
245
|
+
- Check .env for API keys before asking
|
|
246
|
+
- Run npm run linear:sync after task completion
|
|
247
|
+
- Use browser MCP for visual testing
|
|
248
|
+
- Review recent commits and stackmemory.json on session start
|
|
249
|
+
- Use subagents for multi-step tasks
|
|
250
|
+
- Ask 1-3 clarifying questions for complex commands (one at a time)
|
|
220
251
|
|
|
221
252
|
<example>
|
|
222
|
-
|
|
223
|
-
|
|
253
|
+
# Session start workflow:
|
|
254
|
+
1. Read stackmemory.json for project state
|
|
255
|
+
2. Run: git log --oneline -5
|
|
256
|
+
3. Check git status for uncommitted work
|
|
257
|
+
4. If user mentions Linear task, run: npm run linear:sync
|
|
258
|
+
5. Proceed with user request
|
|
224
259
|
</example>
|
|
225
260
|
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
[BUILD]npm build|esbuild|tsc→building_the_project.md
|
|
233
|
-
[CODE]conventions|naming|imports→code_conventions.md
|
|
234
|
-
[TEST]vitest|jest|test:run→running_tests.md
|
|
235
|
-
[OVERVIEW]agent docs|guides→OVERVIEW.md
|
|
236
|
-
|
|
237
|
-
~150t|v4.4.0-compact
|
|
261
|
+
<example>
|
|
262
|
+
# Complex command clarification:
|
|
263
|
+
User: "Optimize the search performance"
|
|
264
|
+
Response: "Which search path should I focus on? (1) FTS5 queries, (2) Hybrid search scoring, or (3) Database indexes?"
|
|
265
|
+
# Wait for answer before proceeding
|
|
266
|
+
</example>
|
|
@@ -1,61 +1,142 @@
|
|
|
1
|
-
#
|
|
1
|
+
# StackMemory - Project Configuration
|
|
2
|
+
|
|
3
|
+
## Project Structure
|
|
2
4
|
|
|
3
|
-
## Refs
|
|
4
5
|
```
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
6
|
+
src/
|
|
7
|
+
cli/ # CLI commands and entry point
|
|
8
|
+
core/ # Core business logic
|
|
9
|
+
context/ # Frame and context management
|
|
10
|
+
database/ # Database adapters (SQLite, ParadeDB)
|
|
11
|
+
digest/ # Digest generation
|
|
12
|
+
query/ # Query parsing and routing
|
|
13
|
+
integrations/ # External integrations (Linear, MCP)
|
|
14
|
+
services/ # Business services
|
|
15
|
+
skills/ # Claude Code skills
|
|
16
|
+
utils/ # Shared utilities
|
|
17
|
+
scripts/ # Build and utility scripts
|
|
18
|
+
config/ # Configuration files
|
|
19
|
+
docs/ # Documentation
|
|
15
20
|
```
|
|
16
21
|
|
|
22
|
+
## Key Files
|
|
23
|
+
|
|
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
|
|
28
|
+
|
|
29
|
+
## Documentation
|
|
30
|
+
|
|
31
|
+
Quick reference (agent_docs/): linear_integration.md | mcp_server.md | database_storage.md | claude_hooks.md
|
|
32
|
+
|
|
33
|
+
Full docs (docs/): principles.md | architecture.md | SPEC.md | API_REFERENCE.md | DEVELOPMENT.md | SETUP.md
|
|
34
|
+
|
|
17
35
|
## Commands
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
npm run build|lint|lint:fix|test|test:run|linear:sync
|
|
39
|
+
stackmemory capture|restore # Session state handoff
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Working Directory
|
|
43
|
+
|
|
44
|
+
PRIMARY: /Users/jwu/Dev/stackmemory | ALLOWED: All subdirectories | TEMP: /tmp
|
|
45
|
+
|
|
46
|
+
## Validation (MUST DO)
|
|
47
|
+
|
|
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
|
|
53
|
+
|
|
54
|
+
Test coverage:
|
|
55
|
+
- New features require tests in `src/**/__tests__/`
|
|
56
|
+
- Maintain or improve coverage (no untested code paths)
|
|
57
|
+
- Critical paths: context management, handoff, Linear sync
|
|
58
|
+
|
|
59
|
+
Never: Assume success | Skip testing | Use mock data as fallback
|
|
60
|
+
|
|
61
|
+
## Git Rules (CRITICAL)
|
|
62
|
+
|
|
63
|
+
- NEVER use `--no-verify` on commit/push
|
|
64
|
+
- ALWAYS fix lint/test errors before pushing
|
|
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`
|
|
68
|
+
|
|
69
|
+
## Security
|
|
70
|
+
|
|
71
|
+
NEVER hardcode secrets - use process.env with dotenv/config
|
|
72
|
+
|
|
73
|
+
```javascript
|
|
74
|
+
import 'dotenv/config';
|
|
75
|
+
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
|
+
}
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
Environment sources (check in order): .env | .env.local | ~/.zshrc | process.env
|
|
83
|
+
|
|
84
|
+
Secret patterns to block: lin_api_* | lin_oauth_* | sk-* | npm_*
|
|
85
|
+
|
|
86
|
+
## Deploy
|
|
87
|
+
|
|
18
88
|
```bash
|
|
19
|
-
npm
|
|
20
|
-
|
|
89
|
+
# npm publish (uses NPM_TOKEN from .env)
|
|
90
|
+
git stash -- scripts/gepa/
|
|
91
|
+
NPM_TOKEN=$(grep '^NPM_TOKEN=' .env | cut -d= -f2) \
|
|
92
|
+
npm publish --registry https://registry.npmjs.org/ \
|
|
93
|
+
--//registry.npmjs.org/:_authToken="$NPM_TOKEN"
|
|
94
|
+
git stash pop
|
|
95
|
+
|
|
96
|
+
# Railway
|
|
97
|
+
railway up
|
|
98
|
+
|
|
99
|
+
# Pre-publish requires clean git — stash GEPA files first
|
|
21
100
|
```
|
|
22
101
|
|
|
23
|
-
##
|
|
24
|
-
Node/Express/PostgreSQL/Redis | Railway | Stripe/Salesforce/QuickBooks
|
|
102
|
+
## Task Delegation Model
|
|
25
103
|
|
|
26
|
-
|
|
27
|
-
src/api|core|features|shared|integrations | docs/ | scripts/ | docker/
|
|
104
|
+
Route effort by complexity:
|
|
28
105
|
|
|
29
|
-
|
|
30
|
-
-
|
|
31
|
-
-
|
|
32
|
-
-
|
|
33
|
-
- StackMemory: security layer (future session/entity context bridge on KG)
|
|
106
|
+
**AUTOMATE** — Execute immediately, lint+test sufficient:
|
|
107
|
+
- CRUD, boilerplate, formatting, simple transforms
|
|
108
|
+
- Tool handler following existing pattern
|
|
109
|
+
- Config additions (env var, feature flag)
|
|
34
110
|
|
|
35
|
-
|
|
36
|
-
-
|
|
37
|
-
-
|
|
38
|
-
- Commit format: type(scope): message
|
|
111
|
+
**STANDARD** — Normal workflow, lint+test+build:
|
|
112
|
+
- Features, bug fixes, refactoring
|
|
113
|
+
- Tests, docs, integration wiring
|
|
39
114
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
115
|
+
**CAREFUL** — Review approach before implementation:
|
|
116
|
+
- API/schema changes, migrations, auth flows
|
|
117
|
+
- New integration patterns (MCP, webhooks)
|
|
118
|
+
- Changes to frame-manager, sqlite-adapter, daemon lifecycle
|
|
119
|
+
- Error handling chains
|
|
45
120
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
121
|
+
**ARCHITECT** — Plan mode required, explore patterns first:
|
|
122
|
+
- New service boundaries, system integrations
|
|
123
|
+
- Performance-critical paths (FTS5, search scoring)
|
|
124
|
+
- Breaking changes to MCP protocol or CLI
|
|
125
|
+
|
|
126
|
+
**HUMAN** — Explicit approval required:
|
|
127
|
+
- Security decisions, secret handling
|
|
128
|
+
- Irreversible operations (migrations, schema drops)
|
|
129
|
+
- Publishing (npm, Railway)
|
|
130
|
+
|
|
131
|
+
Quality gates scale with tier — don't over-engineer AUTOMATE, don't under-review CAREFUL.
|
|
49
132
|
|
|
50
133
|
## Workflow
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
[PUSHBACK] "Simpler: X" | "Risk: Y" | "Consider: Z"
|
|
61
|
-
[QUESTIONS] 1-3 clarifying | one at a time | no time estimates
|
|
134
|
+
|
|
135
|
+
- Check .env for API keys before asking
|
|
136
|
+
- Run npm run linear:sync after task completion
|
|
137
|
+
- Use browser MCP for visual testing
|
|
138
|
+
- Review recent commits and stackmemory.json on session start
|
|
139
|
+
- Use TodoWrite for 3+ steps or multiple requests
|
|
140
|
+
- Keep one task in_progress at a time
|
|
141
|
+
- Update task status immediately on completion
|
|
142
|
+
- Ask 1-3 clarifying questions for complex commands (one at a time)
|