@stackmemoryai/stackmemory 1.5.3 → 1.5.5
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 +104 -2
- package/dist/src/cli/commands/orchestrator.js +478 -7
- package/package.json +2 -1
- package/scripts/gepa/.before-optimize.md +111 -107
- package/scripts/gepa/generations/gen-000/baseline.md +111 -139
- package/scripts/gepa/generations/gen-001/baseline.md +111 -139
- package/scripts/gepa/generations/gen-001/variant-a.md +1 -176
- package/scripts/gepa/generations/gen-001/variant-b.md +1 -266
- package/scripts/gepa/generations/gen-001/variant-c.md +1 -142
- package/scripts/gepa/generations/gen-001/variant-d.md +1 -172
- package/scripts/gepa/results/eval-1-baseline.json +66 -66
- package/scripts/gepa/results/eval-1-variant-a.json +64 -64
- package/scripts/gepa/results/eval-1-variant-b.json +73 -73
- package/scripts/gepa/results/eval-1-variant-c.json +82 -62
- package/scripts/gepa/results/eval-1-variant-d.json +95 -75
- package/scripts/gepa/state.json +8 -24
|
@@ -1,266 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
## Project Structure
|
|
4
|
-
|
|
5
|
-
```
|
|
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
|
|
20
|
-
```
|
|
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
|
-
|
|
45
|
-
## Commands
|
|
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
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
## Working Directory
|
|
61
|
-
|
|
62
|
-
- PRIMARY: /Users/jwu/Dev/stackmemory
|
|
63
|
-
- ALLOWED: All subdirectories
|
|
64
|
-
- TEMP: /tmp for temporary operations
|
|
65
|
-
|
|
66
|
-
## Validation (MUST DO)
|
|
67
|
-
|
|
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
|
|
73
|
-
|
|
74
|
-
<example>
|
|
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
|
|
79
|
-
</example>
|
|
80
|
-
|
|
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
|
|
85
|
-
|
|
86
|
-
<example>
|
|
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)
|
|
90
|
-
</example>
|
|
91
|
-
|
|
92
|
-
Never: Assume success | Skip testing | Use mock data as fallback
|
|
93
|
-
|
|
94
|
-
## Git Rules (CRITICAL)
|
|
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`
|
|
102
|
-
|
|
103
|
-
<example>
|
|
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
|
|
113
|
-
</example>
|
|
114
|
-
|
|
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
|
|
120
|
-
|
|
121
|
-
<example>
|
|
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.
|
|
131
|
-
</example>
|
|
132
|
-
|
|
133
|
-
## Security
|
|
134
|
-
|
|
135
|
-
NEVER hardcode secrets - use process.env with dotenv/config
|
|
136
|
-
|
|
137
|
-
<example>
|
|
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';
|
|
148
|
-
</example>
|
|
149
|
-
|
|
150
|
-
Environment sources (check in order):
|
|
151
|
-
1. .env file
|
|
152
|
-
2. .env.local
|
|
153
|
-
3. ~/.zshrc
|
|
154
|
-
4. Process environment
|
|
155
|
-
|
|
156
|
-
Secret patterns to block: lin_api_* | lin_oauth_* | sk-* | npm_*
|
|
157
|
-
|
|
158
|
-
<example>
|
|
159
|
-
# If you see this pattern, STOP and use env vars:
|
|
160
|
-
const token = 'lin_api_...';
|
|
161
|
-
const apiKey = 'sk-...';
|
|
162
|
-
const npmToken = 'npm_...';
|
|
163
|
-
</example>
|
|
164
|
-
|
|
165
|
-
## Deploy
|
|
166
|
-
|
|
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
|
|
179
|
-
```
|
|
180
|
-
|
|
181
|
-
## Task Delegation Model
|
|
182
|
-
|
|
183
|
-
Route effort by task complexity — not all code changes deserve equal scrutiny:
|
|
184
|
-
|
|
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)
|
|
189
|
-
|
|
190
|
-
<example>
|
|
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
|
|
194
|
-
</example>
|
|
195
|
-
|
|
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)
|
|
200
|
-
|
|
201
|
-
<example>
|
|
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
|
|
205
|
-
</example>
|
|
206
|
-
|
|
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
|
|
212
|
-
|
|
213
|
-
<example>
|
|
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
|
|
217
|
-
</example>
|
|
218
|
-
|
|
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
|
|
223
|
-
|
|
224
|
-
<example>
|
|
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
|
|
228
|
-
</example>
|
|
229
|
-
|
|
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)
|
|
234
|
-
|
|
235
|
-
<example>
|
|
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.
|
|
239
|
-
</example>
|
|
240
|
-
|
|
241
|
-
Quality gates scale with tier — don't over-engineer AUTOMATE tasks, don't under-review CAREFUL ones.
|
|
242
|
-
|
|
243
|
-
## Workflow
|
|
244
|
-
|
|
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)
|
|
251
|
-
|
|
252
|
-
<example>
|
|
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
|
|
259
|
-
</example>
|
|
260
|
-
|
|
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
|
+
API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"You have reached your specified API usage limits. You will regain access on 2026-04-01 at 00:00 UTC."},"request_id":"req_011CYrHDkMg9shHV1yKLKZod"}
|
|
@@ -1,142 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
## Project Structure
|
|
4
|
-
|
|
5
|
-
```
|
|
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
|
|
20
|
-
```
|
|
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
|
-
|
|
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
|
-
|
|
88
|
-
```bash
|
|
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
|
|
100
|
-
```
|
|
101
|
-
|
|
102
|
-
## Task Delegation Model
|
|
103
|
-
|
|
104
|
-
Route effort by complexity:
|
|
105
|
-
|
|
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)
|
|
110
|
-
|
|
111
|
-
**STANDARD** — Normal workflow, lint+test+build:
|
|
112
|
-
- Features, bug fixes, refactoring
|
|
113
|
-
- Tests, docs, integration wiring
|
|
114
|
-
|
|
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
|
|
120
|
-
|
|
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.
|
|
132
|
-
|
|
133
|
-
## Workflow
|
|
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)
|
|
1
|
+
API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"You have reached your specified API usage limits. You will regain access on 2026-04-01 at 00:00 UTC."},"request_id":"req_011CYrHEfNKPYQGLekuXZCrz"}
|
|
@@ -1,172 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
## Overview
|
|
4
|
-
|
|
5
|
-
StackMemory is an agent programming platform with CLI, MCP server, and Linear integration.
|
|
6
|
-
|
|
7
|
-
**Primary**: /Users/jwu/Dev/stackmemory
|
|
8
|
-
**Tech**: TypeScript, Node.js, SQLite, Vitest, ESLint, esbuild
|
|
9
|
-
|
|
10
|
-
## Architecture
|
|
11
|
-
|
|
12
|
-
```
|
|
13
|
-
src/
|
|
14
|
-
cli/ # CLI entry (index.ts)
|
|
15
|
-
core/ # Business logic
|
|
16
|
-
context/ # Frame management (frame-manager.ts)
|
|
17
|
-
database/ # Storage adapters (sqlite-adapter.ts)
|
|
18
|
-
digest/ # Digest generation
|
|
19
|
-
query/ # Query routing
|
|
20
|
-
integrations/ # Linear, MCP (mcp/server.ts)
|
|
21
|
-
services/ # Business services
|
|
22
|
-
skills/ # Claude Code skills
|
|
23
|
-
utils/ # Shared utilities
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
## Documentation
|
|
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
|
|
41
|
-
|
|
42
|
-
## Commands
|
|
43
|
-
|
|
44
|
-
```bash
|
|
45
|
-
# Build & Quality
|
|
46
|
-
npm run build # Compile (esbuild)
|
|
47
|
-
npm run lint # Check
|
|
48
|
-
npm run lint:fix # Auto-fix
|
|
49
|
-
npm test # Watch mode
|
|
50
|
-
npm run test:run # Run once
|
|
51
|
-
|
|
52
|
-
# Integration
|
|
53
|
-
npm run linear:sync # Sync Linear
|
|
54
|
-
|
|
55
|
-
# CLI
|
|
56
|
-
stackmemory capture # Save session state
|
|
57
|
-
stackmemory restore # Restore session
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
## Validation Checklist
|
|
61
|
-
|
|
62
|
-
After EVERY code change:
|
|
63
|
-
|
|
64
|
-
1. **Lint**: `npm run lint` - fix ALL errors AND warnings
|
|
65
|
-
2. **Test**: `npm run test:run` - verify no regressions
|
|
66
|
-
3. **Build**: `npm run build` - ensure compilation
|
|
67
|
-
4. **Run**: Execute code to verify functionality
|
|
68
|
-
|
|
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
|
|
73
|
-
|
|
74
|
-
**Never**: Assume success | Skip testing | Use mock fallbacks
|
|
75
|
-
|
|
76
|
-
## Git Workflow
|
|
77
|
-
|
|
78
|
-
**Commit format**: `type(scope): message`
|
|
79
|
-
**Branch naming**: `feature/STA-XXX-desc` | `fix/STA-XXX-desc` | `chore/desc`
|
|
80
|
-
|
|
81
|
-
**Critical rules**:
|
|
82
|
-
- NEVER use `--no-verify` on commit/push
|
|
83
|
-
- ALWAYS fix lint/test errors before pushing
|
|
84
|
-
- Run `npm run lint && npm run test:run` before pushing
|
|
85
|
-
- If pre-push hooks fail, fix the underlying issue
|
|
86
|
-
|
|
87
|
-
## Task Delegation Model
|
|
88
|
-
|
|
89
|
-
Route effort by complexity:
|
|
90
|
-
|
|
91
|
-
### AUTOMATE
|
|
92
|
-
Execute immediately, lint+test is sufficient:
|
|
93
|
-
- CRUD, boilerplate, formatting, simple transforms
|
|
94
|
-
- Tool handler following existing switch/case
|
|
95
|
-
- Config additions (env var, feature flag)
|
|
96
|
-
|
|
97
|
-
### STANDARD
|
|
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)
|
|
121
|
-
|
|
122
|
-
## Security
|
|
123
|
-
|
|
124
|
-
**NEVER hardcode secrets** - use process.env with dotenv/config:
|
|
125
|
-
|
|
126
|
-
```javascript
|
|
127
|
-
import 'dotenv/config';
|
|
128
|
-
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
|
-
}
|
|
133
|
-
```
|
|
134
|
-
|
|
135
|
-
**Env sources** (check in order):
|
|
136
|
-
1. .env file
|
|
137
|
-
2. .env.local
|
|
138
|
-
3. ~/.zshrc
|
|
139
|
-
4. Process environment
|
|
140
|
-
|
|
141
|
-
**Block patterns**: lin_api_* | lin_oauth_* | sk-* | npm_*
|
|
142
|
-
|
|
143
|
-
## Deployment
|
|
144
|
-
|
|
145
|
-
```bash
|
|
146
|
-
# npm publish (uses NPM_TOKEN from .env, no OTP)
|
|
147
|
-
git stash -- scripts/gepa/ # stash GEPA state
|
|
148
|
-
NPM_TOKEN=$(grep '^NPM_TOKEN=' .env | cut -d= -f2) \
|
|
149
|
-
npm publish --registry https://registry.npmjs.org/ \
|
|
150
|
-
--//registry.npmjs.org/:_authToken="$NPM_TOKEN"
|
|
151
|
-
git stash pop # restore GEPA state
|
|
152
|
-
|
|
153
|
-
# Railway
|
|
154
|
-
railway up
|
|
155
|
-
|
|
156
|
-
# Note: Pre-publish checks require clean git status
|
|
157
|
-
```
|
|
158
|
-
|
|
159
|
-
## Task Management
|
|
160
|
-
|
|
161
|
-
- Use TodoWrite for 3+ steps or multiple requests
|
|
162
|
-
- Keep one task in_progress at a time
|
|
163
|
-
- Update status immediately on completion
|
|
164
|
-
|
|
165
|
-
## Workflow Tips
|
|
166
|
-
|
|
167
|
-
- Check .env for API keys before asking
|
|
168
|
-
- Run `npm run linear:sync` after task completion
|
|
169
|
-
- Use browser MCP for visual testing
|
|
170
|
-
- Review recent commits and stackmemory.json on session start
|
|
171
|
-
- Use subagents for multi-step tasks
|
|
172
|
-
- Ask 1-3 clarifying questions for complex commands (one at a time)
|
|
1
|
+
API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"You have reached your specified API usage limits. You will regain access on 2026-04-01 at 00:00 UTC."},"request_id":"req_011CYrHFtqie98MEfrzJptbx"}
|