@stackmemoryai/stackmemory 1.2.0 → 1.2.1

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.
@@ -1,124 +1,159 @@
1
- # StackMemory - Project Configuration
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
- Test coverage:
75
- - New features require tests in `src/**/__tests__/`
76
- - Maintain or improve coverage (no untested code paths)
77
- - Critical paths: context management, handoff, Linear sync
78
-
79
- Never: Assume success | Skip testing | Use mock data as fallback
80
-
81
- ## Git Rules (CRITICAL)
82
-
83
- - NEVER use `--no-verify` on git push or commit
84
- - ALWAYS fix lint/test errors before pushing
85
- - If pre-push hooks fail, fix the underlying issue
86
- - Run `npm run lint && npm run test:run` before pushing
87
- - Commit message format: `type(scope): message`
88
- - Branch naming: `feature/STA-XXX-description` | `fix/STA-XXX-description` | `chore/description`
89
-
90
- ## Task Management
91
-
92
- - Use TodoWrite for 3+ steps or multiple requests
93
- - Keep one task in_progress at a time
94
- - Update task status immediately on completion
95
-
96
- ## Security
97
-
98
- NEVER hardcode secrets - use process.env with dotenv/config
99
-
100
- ```javascript
101
- import 'dotenv/config';
102
- const API_KEY = process.env.LINEAR_API_KEY;
103
- if (!API_KEY) {
104
- console.error('LINEAR_API_KEY not set');
105
- process.exit(1);
106
- }
107
- ```
108
-
109
- Environment sources (check in order):
110
- 1. .env file
111
- 2. .env.local
112
- 3. ~/.zshrc
113
- 4. Process environment
114
-
115
- Secret patterns to block: lin_api_* | lin_oauth_* | sk-* | npm_*
116
-
117
- ## Workflow
118
-
119
- - Check .env for API keys before asking
120
- - Run npm run linear:sync after task completion
121
- - Use browser MCP for visual testing
122
- - Review recent commits and stackmemory.json on session start
123
- - Use subagents for multi-step tasks
124
- - Ask 1-3 clarifying questions for complex commands (one at a time)
1
+ AGENTS.md
2
+
3
+ Purpose
4
+ - A minimal, agent-friendly reference so code-generation agents (Codex, Claude Code, etc.) can work effectively in this repository.
5
+ - Explains key docs, the /designs/ folder, agent responsibilities, and quick operational notes (how to run tests, what to update, and commit expectations).
6
+
7
+ Repo doc descriptions
8
+ - prompt_plan.md
9
+ - The agent-driven plan that sequences work into small, testable prompts and steps.
10
+ - Contains per-step prompts, expected artifacts, tests, rollback/idempotency notes, and a TODO checklist using Markdown checkboxes.
11
+ - This is the canonical agent workflow driver — update it as you make progress (see Agent responsibility rules below).
12
+
13
+ - spec.md
14
+ - The minimal functional & technical specification that defines APIs, data models, and acceptance criteria.
15
+ - Includes the concise Definition of Done that must be satisfied for each plan step before marking it complete.
16
+
17
+ - idea.md
18
+ - Free-form brainstorming, assumptions, notes, research links, and open questions.
19
+ - Useful for context but not authoritative — always follow spec.md and prompt_plan.md for implementation decisions.
20
+
21
+ - idea_one_pager.md
22
+ - A short summary / one‑pager capturing Problem, Audience, Platform, Core Flow, and MVP Features (and optional Non‑Goals).
23
+ - Good for quick alignment and to confirm that work stays within scope.
24
+
25
+ What lives in /designs/
26
+ - UI/UX artifacts and visual assets that inform implementation:
27
+ - wireframes (PNG/SVG), Figma exports (.fig, .pdf), sequence diagrams, architecture diagrams (PNG/PDF/SVG), and annotated screenshots.
28
+ - Naming conventions: keep filenames short, include version/date and owner, e.g., dashboard_v1_2025-11-01.png or seq_query_flow_v2.pdf.
29
+ - Large source Figma files may live externally; include an export + a small README describing where the canonical design is stored and any viewing permissions required.
30
+
31
+ How agents should interact (summary)
32
+ - Treat prompt_plan.md as the authoritative workflow: follow the listed prompts in order and mark checklist items as you finish them.
33
+ - Always follow TDD: write tests first, make the minimal change to pass tests, then refactor while keeping tests green.
34
+ - After any code/test change, update the matching TODO checkbox in prompt_plan.md using the same Markdown checkbox format ('- [x]') and commit the change alongside code and tests.
35
+ - Make the smallest change that passes tests and improves code. Do not introduce new public APIs without updating spec.md and tests.
36
+ - Don't duplicate templates/files to work around errors — fix the original.
37
+ - Suggest a clear manual test path for every change (even when tests cover it).
38
+ - If you cannot open a file or content is missing, say so explicitly and stop. Do not guess.
39
+
40
+ Quick operational commands (expect these to exist; if not, ask)
41
+ - npm run dev — start local dev server
42
+ - npm test run unit + integration test suite
43
+ - npm run lint — run linting
44
+ - npm run build — build TypeScript
45
+ - npm run migrate:up / migrate:down — database migrations
46
+
47
+ Commit & PR expectations
48
+ - Each prompt/plan step should result in a single, focused commit/PR with:
49
+ - Code + tests + prompt_plan.md checklist update.
50
+ - A short, copy-pasteable commit summary in the prompt_plan.md step completion entry.
51
+ - Clear CHANGELOG or Release notes entry if user-facing behavior changed (or explicitly state "No user-facing changes").
52
+ - Use atomic commits. Include test run results in PR description.
53
+
54
+ Include this governance / workflow block verbatim (do not modify)
55
+ ## Repository docs
56
+ - 'ONE_PAGER.md' - Captures Problem, Audience, Platform, Core Flow, MVP Features; Non-Goals optional.
57
+ - 'DEV_SPEC.md' - Minimal functional and technical specification consistent with prior docs, including a concise **Definition of Done**.
58
+ - 'PROMPT_PLAN.md' - Agent-Ready Planner with per-step prompts, expected artifacts, tests, rollback notes, idempotency notes, and a TODO checklist using Markdown checkboxes. This file drives the agent workflow.
59
+ - 'docs/STYLE.md' - Unified design system reference. Typography, layout, color tokens, component patterns. Inspired by Hatchet (structural layout, inset panels) and Outliner (clean hierarchy, whitespace). **All dashboard UI changes must follow this guide.**
60
+ - 'AGENTS.md' - This file.
61
+
62
+ ### Agent responsibility
63
+ - After completing any coding, refactor, or test step, **immediately update the corresponding TODO checklist item in 'prompt_plan.md'**.
64
+ - Use the same Markdown checkbox format ('- [x]') to mark completion.
65
+ - When creating new tasks or subtasks, add them directly under the appropriate section anchor in 'prompt_plan.md'.
66
+ - Always commit changes to 'prompt_plan.md' alongside the code and tests that fulfill them.
67
+ - Do not consider work "done" until the matching checklist item is checked and all related tests are green.
68
+ - When a stage (plan step) is complete with green tests, update the README "Release notes" section with any user-facing impact (or explicitly state "No user-facing changes" if applicable).
69
+ - Even when automated coverage exists, always suggest a feasible manual test path so the human can exercise the feature end-to-end.
70
+ - After a plan step is finished, document its completion state with a short checklist. Include: step name & number, test results, 'prompt_plan.md' status, manual checks performed (mark as complete only after the human confirms they ran to their satisfaction), release notes status, and an inline commit summary string the human can copy & paste.
71
+
72
+ #### Guardrails for agents
73
+ - Make the smallest change that passes tests and improves the code.
74
+ - Do not introduce new public APIs without updating 'spec.md' and relevant tests.
75
+ - Do not duplicate templates or files to work around issues. Fix the original.
76
+ - If a file cannot be opened or content is missing, say so explicitly and stop. Do not guess.
77
+ - Respect privacy and logging policy: do not log secrets, prompts, completions, or PII.
78
+
79
+ #### Deferred-work notation
80
+ - When a task is intentionally paused, keep its checkbox unchecked and prepend '(Deferred)' to the TODO label in 'prompt_plan.md', followed by a short reason.
81
+ - Apply the same '(Deferred)' tag to every downstream checklist item that depends on the paused work.
82
+ - Remove the tag only after the work resumes; this keeps the outstanding scope visible without implying completion.
83
+
84
+
85
+
86
+ #### When the prompt plan is fully satisfied
87
+ - Once every Definition of Done task in 'prompt_plan.md' is either checked off or explicitly marked '(Deferred)', the plan is considered **complete**.
88
+ - After that point, you no longer need to update prompt-plan TODOs or reference 'prompt_plan.md', 'spec.md', 'idea_one_pager.md', or other upstream docs to justify changes.
89
+ - All other guardrails, testing requirements, and agent responsibilities in this file continue to apply unchanged.
90
+
91
+
92
+ ---
93
+
94
+ ## Testing policy (non-negotiable)
95
+ - Tests **MUST** cover the functionality being implemented.
96
+ - **NEVER** ignore the output of the system or the tests - logs and messages often contain **CRITICAL** information.
97
+ - **TEST OUTPUT MUST BE PRISTINE TO PASS.**
98
+ - If logs are **supposed** to contain errors, capture and test it.
99
+ - **NO EXCEPTIONS POLICY:** Under no circumstances should you mark any test type as "not applicable". Every project, regardless of size or complexity, **MUST** have unit tests, integration tests, **AND** end-to-end tests. If you believe a test type doesn't apply, you need the human to say exactly **"I AUTHORIZE YOU TO SKIP WRITING TESTS THIS TIME"**.
100
+
101
+ ### TDD (how we work)
102
+ - Write tests **before** implementation.
103
+ - Only write enough code to make the failing test pass.
104
+ - Refactor continuously while keeping tests green.
105
+
106
+ **TDD cycle**
107
+ 1. Write a failing test that defines a desired function or improvement.
108
+ 2. Run the test to confirm it fails as expected.
109
+ 3. Write minimal code to make the test pass.
110
+ 4. Run the test to confirm success.
111
+ 5. Refactor while keeping tests green.
112
+ 6. Repeat for each new feature or bugfix.
113
+
114
+ ---
115
+
116
+ ## Important checks
117
+ - **NEVER** disable functionality to hide a failure. Fix root cause.
118
+ - **NEVER** create duplicate templates or files. Fix the original.
119
+ - **NEVER** claim something is "working" when any functionality is disabled or broken.
120
+ - If you can't open a file or access something requested, say so. Do not assume contents.
121
+ - **ALWAYS** identify and fix the root cause of template or compilation errors.
122
+ - If git is initialized, ensure a '.gitignore' exists and contains at least:
123
+
124
+ .env
125
+ .env.local
126
+ .env.*
127
+
128
+ Ask the human whether additional patterns should be added, and suggest any that you think are important given the project.
129
+
130
+ ## When to ask for human input
131
+ Ask the human if any of the following is true:
132
+ - A test type appears "not applicable". Use the exact phrase request: **"I AUTHORIZE YOU TO SKIP WRITING TESTS THIS TIME"**.
133
+ - Required anchors conflict or are missing from upstream docs.
134
+ - You need new environment variables or secrets.
135
+ - An external dependency or major architectural change is required.
136
+ - Design files are missing, unsupported or oversized
137
+
138
+ (End of verbatim block)
139
+
140
+ Minimal examples for checklist updates (copy/pasteable)
141
+ - After completing a prompt step, add an entry under that step in prompt_plan.md similar to:
142
+ - [x] Step 5 — Implement POST /api/v1/query — tests green — manual checks: cURL example tested — README Release Notes updated — commit: "query: add /api/v1/query route, adapter integration, tests"
143
+ - If pausing work:
144
+ - - [ ] (Deferred) Step 7.3 — Implement real Pinecone adapter — blocked on PINECONE_API_KEY (reason: waiting for dev key from infra)
145
+
146
+ If anything is missing
147
+ - If you cannot open prompt_plan.md, spec.md, idea.md, idea_one_pager.md, or any design file, stop and report exactly which file and why (permission/absent/parse error).
148
+ - Ask for required secrets or permissions rather than guessing. Use the "When to ask for human input" rules above.
149
+
150
+ Contact & escalation
151
+ - When blocked on infra/secrets/design files, create a short note in prompt_plan.md under the current step and ping the human with:
152
+ - What I need: (e.g., PINECONE_API_KEY, AWS dev creds)
153
+ - Why I need it: (which step/blocker)
154
+ - Recommended minimal next action & fallback
155
+
156
+ Notes
157
+ - Keep AGENTS.md and the rest of the repo docs in sync. Update this file if workflow expectations change.
158
+
159
+ End.
@@ -0,0 +1,159 @@
1
+ AGENTS.md
2
+
3
+ Purpose
4
+ - A minimal, agent-friendly reference so code-generation agents (Codex, Claude Code, etc.) can work effectively in this repository.
5
+ - Explains key docs, the /designs/ folder, agent responsibilities, and quick operational notes (how to run tests, what to update, and commit expectations).
6
+
7
+ Repo doc descriptions
8
+ - prompt_plan.md
9
+ - The agent-driven plan that sequences work into small, testable prompts and steps.
10
+ - Contains per-step prompts, expected artifacts, tests, rollback/idempotency notes, and a TODO checklist using Markdown checkboxes.
11
+ - This is the canonical agent workflow driver — update it as you make progress (see Agent responsibility rules below).
12
+
13
+ - spec.md
14
+ - The minimal functional & technical specification that defines APIs, data models, and acceptance criteria.
15
+ - Includes the concise Definition of Done that must be satisfied for each plan step before marking it complete.
16
+
17
+ - idea.md
18
+ - Free-form brainstorming, assumptions, notes, research links, and open questions.
19
+ - Useful for context but not authoritative — always follow spec.md and prompt_plan.md for implementation decisions.
20
+
21
+ - idea_one_pager.md
22
+ - A short summary / one‑pager capturing Problem, Audience, Platform, Core Flow, and MVP Features (and optional Non‑Goals).
23
+ - Good for quick alignment and to confirm that work stays within scope.
24
+
25
+ What lives in /designs/
26
+ - UI/UX artifacts and visual assets that inform implementation:
27
+ - wireframes (PNG/SVG), Figma exports (.fig, .pdf), sequence diagrams, architecture diagrams (PNG/PDF/SVG), and annotated screenshots.
28
+ - Naming conventions: keep filenames short, include version/date and owner, e.g., dashboard_v1_2025-11-01.png or seq_query_flow_v2.pdf.
29
+ - Large source Figma files may live externally; include an export + a small README describing where the canonical design is stored and any viewing permissions required.
30
+
31
+ How agents should interact (summary)
32
+ - Treat prompt_plan.md as the authoritative workflow: follow the listed prompts in order and mark checklist items as you finish them.
33
+ - Always follow TDD: write tests first, make the minimal change to pass tests, then refactor while keeping tests green.
34
+ - After any code/test change, update the matching TODO checkbox in prompt_plan.md using the same Markdown checkbox format ('- [x]') and commit the change alongside code and tests.
35
+ - Make the smallest change that passes tests and improves code. Do not introduce new public APIs without updating spec.md and tests.
36
+ - Don't duplicate templates/files to work around errors — fix the original.
37
+ - Suggest a clear manual test path for every change (even when tests cover it).
38
+ - If you cannot open a file or content is missing, say so explicitly and stop. Do not guess.
39
+
40
+ Quick operational commands (expect these to exist; if not, ask)
41
+ - npm run dev — start local dev server
42
+ - npm test — run unit + integration test suite
43
+ - npm run lint — run linting
44
+ - npm run build — build TypeScript
45
+ - npm run migrate:up / migrate:down — database migrations
46
+
47
+ Commit & PR expectations
48
+ - Each prompt/plan step should result in a single, focused commit/PR with:
49
+ - Code + tests + prompt_plan.md checklist update.
50
+ - A short, copy-pasteable commit summary in the prompt_plan.md step completion entry.
51
+ - Clear CHANGELOG or Release notes entry if user-facing behavior changed (or explicitly state "No user-facing changes").
52
+ - Use atomic commits. Include test run results in PR description.
53
+
54
+ Include this governance / workflow block verbatim (do not modify)
55
+ ## Repository docs
56
+ - 'ONE_PAGER.md' - Captures Problem, Audience, Platform, Core Flow, MVP Features; Non-Goals optional.
57
+ - 'DEV_SPEC.md' - Minimal functional and technical specification consistent with prior docs, including a concise **Definition of Done**.
58
+ - 'PROMPT_PLAN.md' - Agent-Ready Planner with per-step prompts, expected artifacts, tests, rollback notes, idempotency notes, and a TODO checklist using Markdown checkboxes. This file drives the agent workflow.
59
+ - 'docs/STYLE.md' - Unified design system reference. Typography, layout, color tokens, component patterns. Inspired by Hatchet (structural layout, inset panels) and Outliner (clean hierarchy, whitespace). **All dashboard UI changes must follow this guide.**
60
+ - 'AGENTS.md' - This file.
61
+
62
+ ### Agent responsibility
63
+ - After completing any coding, refactor, or test step, **immediately update the corresponding TODO checklist item in 'prompt_plan.md'**.
64
+ - Use the same Markdown checkbox format ('- [x]') to mark completion.
65
+ - When creating new tasks or subtasks, add them directly under the appropriate section anchor in 'prompt_plan.md'.
66
+ - Always commit changes to 'prompt_plan.md' alongside the code and tests that fulfill them.
67
+ - Do not consider work "done" until the matching checklist item is checked and all related tests are green.
68
+ - When a stage (plan step) is complete with green tests, update the README "Release notes" section with any user-facing impact (or explicitly state "No user-facing changes" if applicable).
69
+ - Even when automated coverage exists, always suggest a feasible manual test path so the human can exercise the feature end-to-end.
70
+ - After a plan step is finished, document its completion state with a short checklist. Include: step name & number, test results, 'prompt_plan.md' status, manual checks performed (mark as complete only after the human confirms they ran to their satisfaction), release notes status, and an inline commit summary string the human can copy & paste.
71
+
72
+ #### Guardrails for agents
73
+ - Make the smallest change that passes tests and improves the code.
74
+ - Do not introduce new public APIs without updating 'spec.md' and relevant tests.
75
+ - Do not duplicate templates or files to work around issues. Fix the original.
76
+ - If a file cannot be opened or content is missing, say so explicitly and stop. Do not guess.
77
+ - Respect privacy and logging policy: do not log secrets, prompts, completions, or PII.
78
+
79
+ #### Deferred-work notation
80
+ - When a task is intentionally paused, keep its checkbox unchecked and prepend '(Deferred)' to the TODO label in 'prompt_plan.md', followed by a short reason.
81
+ - Apply the same '(Deferred)' tag to every downstream checklist item that depends on the paused work.
82
+ - Remove the tag only after the work resumes; this keeps the outstanding scope visible without implying completion.
83
+
84
+
85
+
86
+ #### When the prompt plan is fully satisfied
87
+ - Once every Definition of Done task in 'prompt_plan.md' is either checked off or explicitly marked '(Deferred)', the plan is considered **complete**.
88
+ - After that point, you no longer need to update prompt-plan TODOs or reference 'prompt_plan.md', 'spec.md', 'idea_one_pager.md', or other upstream docs to justify changes.
89
+ - All other guardrails, testing requirements, and agent responsibilities in this file continue to apply unchanged.
90
+
91
+
92
+ ---
93
+
94
+ ## Testing policy (non-negotiable)
95
+ - Tests **MUST** cover the functionality being implemented.
96
+ - **NEVER** ignore the output of the system or the tests - logs and messages often contain **CRITICAL** information.
97
+ - **TEST OUTPUT MUST BE PRISTINE TO PASS.**
98
+ - If logs are **supposed** to contain errors, capture and test it.
99
+ - **NO EXCEPTIONS POLICY:** Under no circumstances should you mark any test type as "not applicable". Every project, regardless of size or complexity, **MUST** have unit tests, integration tests, **AND** end-to-end tests. If you believe a test type doesn't apply, you need the human to say exactly **"I AUTHORIZE YOU TO SKIP WRITING TESTS THIS TIME"**.
100
+
101
+ ### TDD (how we work)
102
+ - Write tests **before** implementation.
103
+ - Only write enough code to make the failing test pass.
104
+ - Refactor continuously while keeping tests green.
105
+
106
+ **TDD cycle**
107
+ 1. Write a failing test that defines a desired function or improvement.
108
+ 2. Run the test to confirm it fails as expected.
109
+ 3. Write minimal code to make the test pass.
110
+ 4. Run the test to confirm success.
111
+ 5. Refactor while keeping tests green.
112
+ 6. Repeat for each new feature or bugfix.
113
+
114
+ ---
115
+
116
+ ## Important checks
117
+ - **NEVER** disable functionality to hide a failure. Fix root cause.
118
+ - **NEVER** create duplicate templates or files. Fix the original.
119
+ - **NEVER** claim something is "working" when any functionality is disabled or broken.
120
+ - If you can't open a file or access something requested, say so. Do not assume contents.
121
+ - **ALWAYS** identify and fix the root cause of template or compilation errors.
122
+ - If git is initialized, ensure a '.gitignore' exists and contains at least:
123
+
124
+ .env
125
+ .env.local
126
+ .env.*
127
+
128
+ Ask the human whether additional patterns should be added, and suggest any that you think are important given the project.
129
+
130
+ ## When to ask for human input
131
+ Ask the human if any of the following is true:
132
+ - A test type appears "not applicable". Use the exact phrase request: **"I AUTHORIZE YOU TO SKIP WRITING TESTS THIS TIME"**.
133
+ - Required anchors conflict or are missing from upstream docs.
134
+ - You need new environment variables or secrets.
135
+ - An external dependency or major architectural change is required.
136
+ - Design files are missing, unsupported or oversized
137
+
138
+ (End of verbatim block)
139
+
140
+ Minimal examples for checklist updates (copy/pasteable)
141
+ - After completing a prompt step, add an entry under that step in prompt_plan.md similar to:
142
+ - [x] Step 5 — Implement POST /api/v1/query — tests green — manual checks: cURL example tested — README Release Notes updated — commit: "query: add /api/v1/query route, adapter integration, tests"
143
+ - If pausing work:
144
+ - - [ ] (Deferred) Step 7.3 — Implement real Pinecone adapter — blocked on PINECONE_API_KEY (reason: waiting for dev key from infra)
145
+
146
+ If anything is missing
147
+ - If you cannot open prompt_plan.md, spec.md, idea.md, idea_one_pager.md, or any design file, stop and report exactly which file and why (permission/absent/parse error).
148
+ - Ask for required secrets or permissions rather than guessing. Use the "When to ask for human input" rules above.
149
+
150
+ Contact & escalation
151
+ - When blocked on infra/secrets/design files, create a short note in prompt_plan.md under the current step and ping the human with:
152
+ - What I need: (e.g., PINECONE_API_KEY, AWS dev creds)
153
+ - Why I need it: (which step/blocker)
154
+ - Recommended minimal next action & fallback
155
+
156
+ Notes
157
+ - Keep AGENTS.md and the rest of the repo docs in sync. Update this file if workflow expectations change.
158
+
159
+ End.
@@ -0,0 +1,166 @@
1
+ # ProvenantAI
2
+
3
+ ## Reference Docs
4
+ ```
5
+ AGENTS.md # TDD workflow, checklists, guardrails
6
+ PROMPT_PLAN.md # 20 implementation prompts
7
+ docs/STYLE.md # Design system (Hatchet + Outliner)
8
+ docs/business/ONE_PAGER.md # Executive summary
9
+ DEV_SPEC.md # Developer spec
10
+ docs/reference/PROJECT.md # Quick reference
11
+ docs/business/VISION.md # Product vision + self-learning + model router
12
+ docs/architecture/SYSTEM_INTEGRATION.md # System connections (events, flows)
13
+ docs/architecture/HEARTBEAT_DESIGN.md # Task health + recovery
14
+ docs/nudge-engine-design.md # Proactive scanner alerts
15
+ docs/architecture/WEBHOOK_SYSTEM_DESIGN.md # External event publishing
16
+ docs/VALUES.md # Company values
17
+ ```
18
+
19
+ ## Commands
20
+ ```bash
21
+ npm run dev|test|lint|migrate # Development tasks
22
+ docker-compose up -d # Start local DBs
23
+ railway up # Deploy to Railway
24
+ ```
25
+
26
+ ## Stack
27
+ Node.js + Express + PostgreSQL + Redis | Railway | Stripe + Salesforce + QuickBooks
28
+
29
+ ## Core Services (src/core/)
30
+ monitoring-service | cache-service | queue-service | master-agent | api-validation
31
+
32
+ ## Directory Structure
33
+ ```
34
+ src/
35
+ api/ core/ features/ shared/ integrations/
36
+ docs/ scripts/ docker/
37
+ ```
38
+
39
+ ## Git Workflow
40
+ - **NEVER add Co-Authored-By lines** to commits
41
+ - Pre-commit: runs lint + test suite
42
+ - Commit format: `type(scope): message`
43
+ - Deploy: `railway up --detach`
44
+
45
+ ## Architecture
46
+ - **Provenance tracking**: every data point includes source + timestamp + lineage
47
+ - **Multi-tenant**: container isolation per org
48
+ - **Investigation replays**: stored in `data/investigation-replays/`
49
+ - **StackMemory**: session/entity context layer (repurpose when KG lands)
50
+
51
+ ## Key Implementation Files
52
+ ```
53
+ src/graph/client.ts # MCP client for Graphiti
54
+ src/graph/service.ts # Graph ingest + enrich + search
55
+ src/llm/adapter.js # LLM streaming + SYSTEM_PROMPT
56
+ src/routes/query.js # Query endpoint + KG enrichment
57
+ src/auth/auth.middleware.js # Clerk + API key + test mode
58
+ src/nudge/rule-engine.js # 13 default rules + CRUD + eval
59
+ src/nudge/nudge-engine.js # Lifecycle + state machine + events
60
+ src/nudge/delivery.js # Slack Block Kit + delivery
61
+ src/integrations/slack/app.js # OAuth v2 + token management
62
+ scripts/create-stripe-products.js # Stripe product creation
63
+ scripts/seed-demo-data.js # Demo nudge data
64
+ dashboard-app/src/pages/pricing/ # 4-tier pricing UI
65
+ ```
66
+
67
+ ## Current State
68
+ - **20 prompts complete** (PROMPT_PLAN.md)
69
+ - **80 test suites, 1547 tests** - all passing (37 unit, 30 core, 13 integrations)
70
+ - **KG integrated** - commit 917f31e (FalkorDB + Graphiti MCP)
71
+ - **Published**: @provenantai/cli@1.0.0
72
+ - **Deployed**: Railway (health OK, DB connected)
73
+ - **Bundle**: 236KB main + 346KB vendor (lazy routes)
74
+ - **Pricing**: Free | Growth $999-1499 | Scale $2999-4499 | Enterprise custom
75
+ - **Slack**: wired in index.js (conditional on SLACK_CLIENT_ID)
76
+ - **Dashboard**: SlackSettings + Nudges page + E2E smoke tests
77
+
78
+ ## Knowledge Graph
79
+ - **FalkorDB**: `falkordb/falkordb:latest` port 6380 (Redis-compatible)
80
+ - **Graphiti**: `zepai/knowledge-graph-mcp:standalone` port 8100
81
+ - **Protocol**: MCP Streamable HTTP (JSON-RPC + SSE) - NOT REST
82
+ - **Ingestion**: fire-and-forget via `add_memory`, extraction runs in background
83
+ - **Config**: `config/graphiti-falkordb.yaml` - Claude Haiku for LLM
84
+ - **Performance**: 34ms avg, $0.00056/event
85
+ - **Query integration**: GraphService.enrichRetrieval() when GRAPHITI_URL set
86
+ - **Graph context**: prepended as first context_document, graceful fallback
87
+
88
+ ## Stripe Products (LIVE)
89
+ ```
90
+ Growth: prod_TyNYCJmlKbMdlz
91
+ Monthly $1,499: price_1T0Qn8BjaxUVbh5VjC7BP0cS
92
+ Quarterly $2,997: price_1T0Qn9BjaxUVbh5VYmugdPrF
93
+ Scale: prod_TyNY5SGKvVlbpo
94
+ Monthly $4,499: price_1T0Qn9BjaxUVbh5ViK6vRmgn
95
+ Quarterly $8,997: price_1T0Qn9BjaxUVbh5V1mBcTAJ0
96
+ ```
97
+ Price IDs in `.env` + `dashboard-app/.env` (VITE_STRIPE_PRICE_*)
98
+
99
+ ## Clerk Auth
100
+ - **Current**: test keys (pk_test_*, sk_test_*)
101
+ - **Production setup**: `bash scripts/setup-clerk-production.sh`
102
+ - **Webhook**: /api/webhooks/clerk (Svix verification required in prod)
103
+ - **Status**: code production-ready, test mode blocked in production
104
+
105
+ ## Dashboard
106
+ - **Chat**: `/api/v1/query` with SSE streaming
107
+ - **Sidebar**: toggleable, time-grouped, backend persistence
108
+ - **localStorage**: `provenantai:conversationId`, `sidebarOpen`, `onboarded`
109
+ - **Vite**: `base: '/app/'` + BrowserRouter `basename="/app"`
110
+ - **Dev auth**: `X-Test-Mode: true` bypasses Clerk
111
+ - **Express**: `node src/index.js` on PORT=8080 (3000 = Rails)
112
+ - **Build**: `bash -c 'cd dashboard-app && npx vite build'`
113
+
114
+ ## Slack Integration
115
+ - **OAuth flow**: GET /api/integrations/slack/install → consent → callback
116
+ - **DB**: `slack_installations` table (migration 030) - per-org bot tokens
117
+ - **Service**: `src/integrations/slack/app.js` - createSlackAppService
118
+ - **Delivery**: `src/nudge/delivery.js` - nudge:created listener, Block Kit formatter
119
+ - **Routes**: install, callback, status, channel config, revoke
120
+ - **Env**: SLACK_CLIENT_ID, SLACK_CLIENT_SECRET, SLACK_REDIRECT_URI
121
+ - **Demo data**: `node scripts/seed-demo-data.js` (10 nudges)
122
+
123
+ ## Architecture Patterns
124
+ - **DI**: all route factories accept `deps` objects
125
+ - **Mocks**: MockPineconeAdapter, MockGmailConnectorClient, stub embeddings
126
+ - **Queues**: Bull (not BullMQ)
127
+ - **KMS**: AES-256-GCM shim via LOCAL_KMS_KEY
128
+ - **Streaming**: adapter.streamLLM() → query/stream → ReadableStream
129
+ - **Graph**: optional graphService dep, null when GRAPHITI_URL unset
130
+
131
+ ## Testing
132
+ - **Framework**: Jest + SWC (`@swc/jest`), `@jest/globals` imports
133
+ - **Mocks**: `mockDb = { query: jest.fn() }` via DI
134
+ - **Fetch**: `global.fetch = mockFetch` + `jsonResponse()` helper
135
+ - **Pre-commit**: lint + parallel test suite via concurrently
136
+ - **Timeout guard**: Promise.race + .unref() timer in test/setup.js
137
+ - **Supertest**: pass Express app directly (NOT server) - avoids port contention
138
+ - **Redis**: skip eager connect in NODE_ENV=test; disconnect in afterAll
139
+
140
+ ### Parallel Test Execution
141
+ ```bash
142
+ npm test # 3 parallel processes (~9s vs 18s)
143
+ test:unit (37 suites, 615 tests) # test/ dir
144
+ test:core (30 suites, 643 tests) # src/(api|auth|billing|core|...)
145
+ test:integrations (13 suites, 289 tests) # src/integrations/
146
+ test:all (single-process, 4 workers) # fallback
147
+ ```
148
+ **After code changes**: run targeted sub-suite in background via Bash `run_in_background`
149
+
150
+ ## GTM Content
151
+ ```
152
+ docs/content/linkedin-pillar1-drafts.md # 5 problem posts (ready)
153
+ docs/content/gtm-launch-materials.md # Schedule + Loom + outreach
154
+ docs/business/CONTENT_INBOUND_STRATEGY.md # Content/inbound playbook
155
+ docs/business/FRACTIONAL_CMO_AGENT.md # CMO Agent product brief
156
+ ```
157
+
158
+ ## Next Actions
159
+ 1. Commit: SlackSettings, Nudges polish, smoke tests
160
+ 2. Clerk: swap to production keys (requires Clerk dashboard action)
161
+ 3. Slack: create app at api.slack.com, run migration 030
162
+ 4. Content: schedule posts in Typefully, record Loom demo
163
+ 5. Design partners: outreach to 3-5 ICP companies
164
+ 6. Attribution: add Google Ads + Meta connectors
165
+
166
+ <!-- Sync docs/reference/PROJECT.md when verbose docs change -->