@stackmemoryai/stackmemory 1.5.4 → 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 +97 -0
- package/dist/src/cli/commands/orchestrator.js +291 -5
- package/package.json +2 -1
- package/scripts/gepa/.before-optimize.md +110 -142
- package/scripts/gepa/generations/gen-000/baseline.md +111 -147
- package/scripts/gepa/generations/gen-001/baseline.md +111 -147
- package/scripts/gepa/generations/gen-001/variant-a.md +1 -176
- package/scripts/gepa/generations/gen-001/variant-b.md +1 -280
- package/scripts/gepa/generations/gen-001/variant-c.md +1 -122
- package/scripts/gepa/generations/gen-001/variant-d.md +1 -138
- package/scripts/gepa/results/eval-1-baseline.json +80 -80
- package/scripts/gepa/results/eval-1-variant-a.json +65 -65
- package/scripts/gepa/results/eval-1-variant-b.json +78 -78
- package/scripts/gepa/results/eval-1-variant-c.json +69 -69
- package/scripts/gepa/results/eval-1-variant-d.json +71 -71
- package/scripts/gepa/state.json +6 -22
|
@@ -1,280 +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
|
-
- Snapshot: src/core/worktree/capture.ts
|
|
29
|
-
- Preflight: src/core/worktree/preflight.ts
|
|
30
|
-
- Conductor: src/cli/commands/orchestrator.ts
|
|
31
|
-
- Shared Utils: src/core/utils/{git,text,fs}.ts
|
|
32
|
-
|
|
33
|
-
## Detailed Guides
|
|
34
|
-
|
|
35
|
-
Quick reference (agent_docs/):
|
|
36
|
-
- linear_integration.md - Linear sync
|
|
37
|
-
- mcp_server.md - MCP tools
|
|
38
|
-
- database_storage.md - Storage
|
|
39
|
-
- claude_hooks.md - Hooks
|
|
40
|
-
|
|
41
|
-
Full documentation (docs/):
|
|
42
|
-
- principles.md - Agent programming paradigm
|
|
43
|
-
- architecture.md - Extension model and browser sandbox
|
|
44
|
-
- SPEC.md - Technical specification
|
|
45
|
-
- API_REFERENCE.md - API docs
|
|
46
|
-
- DEVELOPMENT.md - Dev guide
|
|
47
|
-
- SETUP.md - Installation
|
|
48
|
-
|
|
49
|
-
## Commands
|
|
50
|
-
|
|
51
|
-
```bash
|
|
52
|
-
npm run build # Compile TypeScript (esbuild)
|
|
53
|
-
npm run lint # ESLint check
|
|
54
|
-
npm run lint:fix # Auto-fix lint issues
|
|
55
|
-
npm test # Run Vitest (watch)
|
|
56
|
-
npm run test:run # Run tests once
|
|
57
|
-
npm run linear:sync # Sync with Linear
|
|
58
|
-
|
|
59
|
-
# StackMemory CLI
|
|
60
|
-
stackmemory capture # Save session state for handoff
|
|
61
|
-
stackmemory restore # Restore from captured state
|
|
62
|
-
stackmemory snapshot save # Post-run context snapshot (alias: snap)
|
|
63
|
-
stackmemory snapshot list # List recent snapshots
|
|
64
|
-
stackmemory preflight # File overlap check for parallel tasks (alias: pf)
|
|
65
|
-
stackmemory conductor start # Autonomous Linear→worktree→agent orchestrator
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
## Working Directory
|
|
69
|
-
|
|
70
|
-
- PRIMARY: /Users/jwu/Dev/stackmemory
|
|
71
|
-
- ALLOWED: All subdirectories
|
|
72
|
-
- TEMP: /tmp for temporary operations
|
|
73
|
-
|
|
74
|
-
## Validation (MUST DO)
|
|
75
|
-
|
|
76
|
-
After code changes:
|
|
77
|
-
1. `npm run lint` - fix any errors AND warnings
|
|
78
|
-
2. `npm run test:run` - verify no regressions
|
|
79
|
-
3. `npm run build` - ensure compilation
|
|
80
|
-
4. Run code to verify it works
|
|
81
|
-
|
|
82
|
-
<example>
|
|
83
|
-
# Correct validation sequence after editing src/core/context/frame-manager.ts:
|
|
84
|
-
$ npm run lint # → 0 errors, 0 warnings
|
|
85
|
-
$ npm run test:run # → all tests pass (including search-benchmark smoke)
|
|
86
|
-
$ npm run build # → dist/ updated, no TS errors
|
|
87
|
-
$ stackmemory snapshot save # → verify feature works end-to-end
|
|
88
|
-
</example>
|
|
89
|
-
|
|
90
|
-
Test coverage:
|
|
91
|
-
- New features require tests in `src/**/__tests__/`
|
|
92
|
-
- Maintain or improve coverage (no untested code paths)
|
|
93
|
-
- Critical paths: context management, handoff, Linear sync
|
|
94
|
-
|
|
95
|
-
<example>
|
|
96
|
-
# New feature: adding a getFrameCount() method to FrameManager
|
|
97
|
-
# → requires test in src/core/context/__tests__/frame-manager.test.ts
|
|
98
|
-
it('getFrameCount returns correct count after adding frames', () => {
|
|
99
|
-
const mgr = new FrameManager(db);
|
|
100
|
-
mgr.addFrame({ content: 'a' });
|
|
101
|
-
mgr.addFrame({ content: 'b' });
|
|
102
|
-
expect(mgr.getFrameCount()).toBe(2);
|
|
103
|
-
});
|
|
104
|
-
</example>
|
|
105
|
-
|
|
106
|
-
Never: Assume success | Skip testing | Use mock data as fallback
|
|
107
|
-
|
|
108
|
-
## Git Rules (CRITICAL)
|
|
109
|
-
|
|
110
|
-
- NEVER use `--no-verify` on git push or commit
|
|
111
|
-
- ALWAYS fix lint/test errors before pushing
|
|
112
|
-
- If pre-push hooks fail, fix the underlying issue
|
|
113
|
-
- Run `npm run lint && npm run test:run` before pushing
|
|
114
|
-
- Commit message format: `type(scope): message`
|
|
115
|
-
- Branch naming: `feature/STA-XXX-description` | `fix/STA-XXX-description` | `chore/description`
|
|
116
|
-
|
|
117
|
-
<example>
|
|
118
|
-
# Good commit messages:
|
|
119
|
-
feat(mcp): add get_frame_count tool to server
|
|
120
|
-
fix(sqlite): correct BM25 score negation in hybrid search
|
|
121
|
-
chore(deps): bump better-sqlite3 to 9.4.3
|
|
122
|
-
refactor(context): extract frame deduplication to utils
|
|
123
|
-
|
|
124
|
-
# Good branch names:
|
|
125
|
-
feature/STA-123-fts5-hybrid-search
|
|
126
|
-
fix/STA-456-timer-leak-promise-race
|
|
127
|
-
chore/update-vitest-config
|
|
128
|
-
|
|
129
|
-
# Bad — never do these:
|
|
130
|
-
git commit --no-verify -m "wip"
|
|
131
|
-
git push --force origin main
|
|
132
|
-
</example>
|
|
133
|
-
|
|
134
|
-
## Task Management
|
|
135
|
-
|
|
136
|
-
- Use TodoWrite for 3+ steps or multiple requests
|
|
137
|
-
- Keep one task in_progress at a time
|
|
138
|
-
- Update task status immediately on completion
|
|
139
|
-
|
|
140
|
-
<example>
|
|
141
|
-
# User asks: "Add FTS5 search, wire it to MCP, and write tests"
|
|
142
|
-
# → 3+ steps: use TodoWrite
|
|
143
|
-
TodoWrite([
|
|
144
|
-
{ id: '1', content: 'Add FTS5 search method to sqlite-adapter', status: 'pending' },
|
|
145
|
-
{ id: '2', content: 'Wire search to MCP tool handler in server.ts', status: 'pending' },
|
|
146
|
-
{ id: '3', content: 'Write tests in __tests__/sqlite-adapter.test.ts', status: 'pending' },
|
|
147
|
-
])
|
|
148
|
-
# Complete step 1 → update status to 'completed' before starting step 2
|
|
149
|
-
</example>
|
|
150
|
-
|
|
151
|
-
## Security
|
|
152
|
-
|
|
153
|
-
NEVER hardcode secrets - use process.env with dotenv/config
|
|
154
|
-
|
|
155
|
-
```javascript
|
|
156
|
-
import 'dotenv/config';
|
|
157
|
-
const API_KEY = process.env.LINEAR_API_KEY;
|
|
158
|
-
if (!API_KEY) {
|
|
159
|
-
console.error('LINEAR_API_KEY not set');
|
|
160
|
-
process.exit(1);
|
|
161
|
-
}
|
|
162
|
-
```
|
|
163
|
-
|
|
164
|
-
<example>
|
|
165
|
-
// BAD — never do this:
|
|
166
|
-
const client = new LinearClient({ apiKey: 'lin_api_abc123xyz' });
|
|
167
|
-
|
|
168
|
-
// GOOD:
|
|
169
|
-
const apiKey = process.env.LINEAR_API_KEY;
|
|
170
|
-
if (!apiKey) throw new Error('LINEAR_API_KEY not set');
|
|
171
|
-
const client = new LinearClient({ apiKey });
|
|
172
|
-
</example>
|
|
173
|
-
|
|
174
|
-
Environment sources (check in order):
|
|
175
|
-
1. .env file
|
|
176
|
-
2. .env.local
|
|
177
|
-
3. ~/.zshrc
|
|
178
|
-
4. Process environment
|
|
179
|
-
|
|
180
|
-
Secret patterns to block: lin_api_* | lin_oauth_* | sk-* | npm_*
|
|
181
|
-
|
|
182
|
-
## Deploy
|
|
183
|
-
|
|
184
|
-
```bash
|
|
185
|
-
# npm publish (uses NPM_TOKEN from .env, no OTP needed)
|
|
186
|
-
git stash -- scripts/gepa/ # stash GEPA state (dirties working tree)
|
|
187
|
-
NPM_TOKEN=$(grep '^NPM_TOKEN=' .env | cut -d= -f2) \
|
|
188
|
-
npm publish --registry https://registry.npmjs.org/ \
|
|
189
|
-
--//registry.npmjs.org/:_authToken="$NPM_TOKEN"
|
|
190
|
-
git stash pop # restore GEPA state
|
|
191
|
-
|
|
192
|
-
# Railway
|
|
193
|
-
railway up
|
|
194
|
-
|
|
195
|
-
# Pre-publish checks require clean git status — stash GEPA files first
|
|
196
|
-
```
|
|
197
|
-
|
|
198
|
-
## Task Delegation Model
|
|
199
|
-
|
|
200
|
-
Route effort by task complexity — not all code changes deserve equal scrutiny:
|
|
201
|
-
|
|
202
|
-
**AUTOMATE** — Execute immediately, lint+test is sufficient:
|
|
203
|
-
- CRUD operations, boilerplate, formatting, simple transforms
|
|
204
|
-
- Adding a tool handler following existing switch/case pattern
|
|
205
|
-
- Config additions (new env var, feature flag)
|
|
206
|
-
|
|
207
|
-
<example>
|
|
208
|
-
# AUTOMATE: adding a new MCP tool that follows the existing switch/case pattern
|
|
209
|
-
case 'get_frame_by_id':
|
|
210
|
-
return { frame: await frameManager.getById(args.id) };
|
|
211
|
-
# → just add the case, lint, test. No design review needed.
|
|
212
|
-
</example>
|
|
213
|
-
|
|
214
|
-
**STANDARD** — Normal workflow, lint+test+build:
|
|
215
|
-
- Feature implementation, bug fixes, refactoring
|
|
216
|
-
- New test coverage, documentation updates
|
|
217
|
-
- Integration wiring (adding handler to server.ts dispatch)
|
|
218
|
-
|
|
219
|
-
<example>
|
|
220
|
-
# STANDARD: fixing a bug where snapshot list shows stale entries
|
|
221
|
-
# → read the relevant files, understand root cause, fix, lint+test+build
|
|
222
|
-
</example>
|
|
223
|
-
|
|
224
|
-
**CAREFUL** — Review approach before implementation:
|
|
225
|
-
- API/schema changes, database migrations, auth flows
|
|
226
|
-
- New integration patterns (MCP tools, webhook handlers)
|
|
227
|
-
- Changes to frame-manager, sqlite-adapter, or daemon lifecycle
|
|
228
|
-
- Anything touching error handling chains
|
|
229
|
-
|
|
230
|
-
<example>
|
|
231
|
-
# CAREFUL: adding a new column to the frames table
|
|
232
|
-
# → read sqlite-adapter.ts and schema_version migration pattern first
|
|
233
|
-
# → plan the migration (increment schema_version, ALTER TABLE or recreate)
|
|
234
|
-
# → confirm approach with user if destructive
|
|
235
|
-
</example>
|
|
236
|
-
|
|
237
|
-
**ARCHITECT** — Plan mode required, explore existing patterns first:
|
|
238
|
-
- New service boundaries, system integrations
|
|
239
|
-
- Performance-critical paths (FTS5 queries, search scoring)
|
|
240
|
-
- Breaking changes to MCP protocol or CLI interface
|
|
241
|
-
|
|
242
|
-
<example>
|
|
243
|
-
# ARCHITECT: replacing LIKE-based search with hybrid FTS5+BM25
|
|
244
|
-
# → enter plan mode, read sqlite-adapter.ts + search-benchmark.test.ts
|
|
245
|
-
# → understand current scoring thresholds, BM25 sign conventions
|
|
246
|
-
# → design schema migration, write plan, get approval before coding
|
|
247
|
-
</example>
|
|
248
|
-
|
|
249
|
-
**HUMAN** — Explicit user approval before any changes:
|
|
250
|
-
- Security-critical decisions, secret handling
|
|
251
|
-
- Irreversible operations (data migrations, schema drops)
|
|
252
|
-
- Publishing (npm publish, Railway deploy)
|
|
253
|
-
|
|
254
|
-
<example>
|
|
255
|
-
# HUMAN: "drop the old digest_cache table and run npm publish"
|
|
256
|
-
# → STOP. Confirm with user: "This will permanently delete digest_cache
|
|
257
|
-
# and publish to npm. Proceed?" — wait for explicit yes.
|
|
258
|
-
</example>
|
|
259
|
-
|
|
260
|
-
Quality gates scale with tier — don't over-engineer AUTOMATE tasks, don't under-review CAREFUL ones.
|
|
261
|
-
|
|
262
|
-
## Workflow
|
|
263
|
-
|
|
264
|
-
- Check .env for API keys before asking
|
|
265
|
-
- Run npm run linear:sync after task completion
|
|
266
|
-
- Use browser MCP for visual testing
|
|
267
|
-
- Review recent commits and stackmemory.json on session start
|
|
268
|
-
- Use subagents for multi-step tasks
|
|
269
|
-
- Ask 1-3 clarifying questions for complex commands (one at a time)
|
|
270
|
-
|
|
271
|
-
<example>
|
|
272
|
-
# Session start checklist:
|
|
273
|
-
$ git log --oneline -10 # understand recent context
|
|
274
|
-
$ cat stackmemory.json # check current config/state
|
|
275
|
-
$ cat .env | grep -v '^#' # verify which API keys are present
|
|
276
|
-
|
|
277
|
-
# After completing a Linear task:
|
|
278
|
-
$ npm run linear:sync # update issue status in Linear
|
|
279
|
-
$ stackmemory snapshot save # capture context for next session
|
|
280
|
-
</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,122 +1 @@
|
|
|
1
|
-
|
|
2
|
-
# StackMemory - Project Configuration
|
|
3
|
-
|
|
4
|
-
## Project Structure
|
|
5
|
-
|
|
6
|
-
```
|
|
7
|
-
src/
|
|
8
|
-
cli/ # CLI commands and entry point
|
|
9
|
-
core/
|
|
10
|
-
context/ # Frame and context management
|
|
11
|
-
database/ # Database adapters (SQLite, ParadeDB)
|
|
12
|
-
digest/ # Digest generation
|
|
13
|
-
query/ # Query parsing and routing
|
|
14
|
-
integrations/ # External integrations (Linear, MCP)
|
|
15
|
-
services/ # Business services
|
|
16
|
-
skills/ # Claude Code skills
|
|
17
|
-
utils/ # Shared utilities
|
|
18
|
-
scripts/ # Build and utility scripts
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
## Key Files
|
|
22
|
-
|
|
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`
|
|
31
|
-
|
|
32
|
-
## Docs
|
|
33
|
-
|
|
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
|
|
36
|
-
|
|
37
|
-
## Commands
|
|
38
|
-
|
|
39
|
-
```bash
|
|
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
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
## Validation (MUST DO)
|
|
55
|
-
|
|
56
|
-
After code changes: `npm run lint && npm run test:run && npm run build`
|
|
57
|
-
|
|
58
|
-
- New features require tests in `src/**/__tests__/`
|
|
59
|
-
- Maintain or improve coverage — no untested code paths
|
|
60
|
-
- Critical paths: context management, handoff, Linear sync
|
|
61
|
-
- Never assume success | skip testing | use mock data as fallback
|
|
62
|
-
|
|
63
|
-
## Git Rules (CRITICAL)
|
|
64
|
-
|
|
65
|
-
- NEVER `--no-verify` on push or commit — fix the underlying issue
|
|
66
|
-
- Commit: `type(scope): message` | Branch: `feature/STA-XXX-description` | `fix/` | `chore/`
|
|
67
|
-
|
|
68
|
-
## Security
|
|
69
|
-
|
|
70
|
-
NEVER hardcode secrets — use `process.env` with dotenv/config.
|
|
71
|
-
|
|
72
|
-
```javascript
|
|
73
|
-
import 'dotenv/config';
|
|
74
|
-
const API_KEY = process.env.LINEAR_API_KEY;
|
|
75
|
-
if (!API_KEY) { console.error('LINEAR_API_KEY not set'); process.exit(1); }
|
|
76
|
-
```
|
|
77
|
-
|
|
78
|
-
Env sources (order): `.env` → `.env.local` → `~/.zshrc` → process env
|
|
79
|
-
Block patterns: `lin_api_*` | `lin_oauth_*` | `sk-*` | `npm_*`
|
|
80
|
-
|
|
81
|
-
## Deploy
|
|
82
|
-
|
|
83
|
-
```bash
|
|
84
|
-
# npm publish
|
|
85
|
-
git stash -- scripts/gepa/
|
|
86
|
-
NPM_TOKEN=$(grep '^NPM_TOKEN=' .env | cut -d= -f2) \
|
|
87
|
-
npm publish --registry https://registry.npmjs.org/ \
|
|
88
|
-
--//registry.npmjs.org/:_authToken="$NPM_TOKEN"
|
|
89
|
-
git stash pop
|
|
90
|
-
|
|
91
|
-
# Railway
|
|
92
|
-
railway up
|
|
93
|
-
```
|
|
94
|
-
|
|
95
|
-
Pre-publish requires clean git status — stash GEPA files first.
|
|
96
|
-
|
|
97
|
-
## Task Delegation Model
|
|
98
|
-
|
|
99
|
-
**AUTOMATE** — lint+test sufficient:
|
|
100
|
-
- CRUD, boilerplate, config additions, simple switch/case handlers
|
|
101
|
-
|
|
102
|
-
**STANDARD** — lint+test+build:
|
|
103
|
-
- Feature impl, bug fixes, refactoring, new tests, integration wiring
|
|
104
|
-
|
|
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
|
|
108
|
-
|
|
109
|
-
**ARCHITECT** — plan mode required:
|
|
110
|
-
- New service boundaries, FTS5/search performance, breaking MCP/CLI changes
|
|
111
|
-
|
|
112
|
-
**HUMAN** — explicit approval required:
|
|
113
|
-
- Secret handling, data migrations/schema drops, npm publish, Railway deploy
|
|
114
|
-
|
|
115
|
-
## Workflow
|
|
116
|
-
|
|
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
|
+
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,138 +1 @@
|
|
|
1
|
-
|
|
2
|
-
# StackMemory - Project Configuration
|
|
3
|
-
|
|
4
|
-
## Quick Reference
|
|
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`
|
|
8
|
-
|
|
9
|
-
**Docs:** `agent_docs/` (quick ref) · `docs/` (full: principles, architecture, SPEC, API_REFERENCE, DEVELOPMENT, SETUP)
|
|
10
|
-
|
|
11
|
-
---
|
|
12
|
-
|
|
13
|
-
## Project Structure
|
|
14
|
-
|
|
15
|
-
```
|
|
16
|
-
src/
|
|
17
|
-
cli/ # CLI commands and entry point
|
|
18
|
-
core/
|
|
19
|
-
context/ # Frame and context management
|
|
20
|
-
database/ # Database adapters (SQLite, ParadeDB)
|
|
21
|
-
digest/ # Digest generation
|
|
22
|
-
query/ # Query parsing and routing
|
|
23
|
-
integrations/ # External integrations (Linear, MCP)
|
|
24
|
-
services/ # Business services
|
|
25
|
-
skills/ # Claude Code skills
|
|
26
|
-
utils/ # Shared utilities
|
|
27
|
-
scripts/ # Build and utility scripts
|
|
28
|
-
config/ # Configuration files
|
|
29
|
-
docs/ # Documentation
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
---
|
|
33
|
-
|
|
34
|
-
## Commands
|
|
35
|
-
|
|
36
|
-
```bash
|
|
37
|
-
# Build & Quality
|
|
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
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
---
|
|
55
|
-
|
|
56
|
-
## Validation (MUST DO)
|
|
57
|
-
|
|
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
|
|
63
|
-
|
|
64
|
-
**Test coverage:** New features require tests in `src/**/__tests__/`. Maintain or improve coverage. Critical paths: context management, handoff, Linear sync.
|
|
65
|
-
|
|
66
|
-
Never: assume success · skip testing · use mock data as fallback
|
|
67
|
-
|
|
68
|
-
---
|
|
69
|
-
|
|
70
|
-
## Git Rules (CRITICAL)
|
|
71
|
-
|
|
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
|
|
74
|
-
- Run `npm run lint && npm run test:run` before pushing
|
|
75
|
-
- Commit: `type(scope): message`
|
|
76
|
-
- Branch: `feature/STA-XXX-description` · `fix/STA-XXX-description` · `chore/description`
|
|
77
|
-
|
|
78
|
-
---
|
|
79
|
-
|
|
80
|
-
## Task Delegation Model
|
|
81
|
-
|
|
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
|
-
---
|
|
91
|
-
|
|
92
|
-
## Security
|
|
93
|
-
|
|
94
|
-
NEVER hardcode secrets — use `process.env` with dotenv/config:
|
|
95
|
-
|
|
96
|
-
```javascript
|
|
97
|
-
import 'dotenv/config';
|
|
98
|
-
const API_KEY = process.env.LINEAR_API_KEY;
|
|
99
|
-
if (!API_KEY) { console.error('LINEAR_API_KEY not set'); process.exit(1); }
|
|
100
|
-
```
|
|
101
|
-
|
|
102
|
-
Env lookup order: `.env` → `.env.local` → `~/.zshrc` → process env
|
|
103
|
-
|
|
104
|
-
Block patterns: `lin_api_*` · `lin_oauth_*` · `sk-*` · `npm_*`
|
|
105
|
-
|
|
106
|
-
---
|
|
107
|
-
|
|
108
|
-
## Deploy
|
|
109
|
-
|
|
110
|
-
```bash
|
|
111
|
-
# npm publish (uses NPM_TOKEN from .env, no OTP needed)
|
|
112
|
-
git stash -- scripts/gepa/ # stash GEPA state (dirties working tree)
|
|
113
|
-
NPM_TOKEN=$(grep '^NPM_TOKEN=' .env | cut -d= -f2) \
|
|
114
|
-
npm publish --registry https://registry.npmjs.org/ \
|
|
115
|
-
--//registry.npmjs.org/:_authToken="$NPM_TOKEN"
|
|
116
|
-
git stash pop # restore GEPA state
|
|
117
|
-
|
|
118
|
-
# Railway
|
|
119
|
-
railway up
|
|
120
|
-
```
|
|
121
|
-
|
|
122
|
-
Pre-publish checks require clean git status — stash GEPA files first.
|
|
123
|
-
|
|
124
|
-
---
|
|
125
|
-
|
|
126
|
-
## Workflow
|
|
127
|
-
|
|
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
|
|
131
|
-
- Run `npm run linear:sync` after task completion
|
|
132
|
-
- Use browser MCP for visual testing
|
|
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
|
-
```
|
|
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"}
|