memory-neo 0.1.0__tar.gz

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.
@@ -0,0 +1,225 @@
1
+ Metadata-Version: 2.4
2
+ Name: memory-neo
3
+ Version: 0.1.0
4
+ Summary: Push your codebase to a graph DB and query it with natural language
5
+ Author: memory-neo
6
+ License: MIT
7
+ Requires-Python: >=3.9
8
+ Description-Content-Type: text/markdown
9
+ Requires-Dist: click>=8.1
10
+ Requires-Dist: httpx>=0.27
11
+ Requires-Dist: rich>=13.7
12
+ Requires-Dist: python-dotenv>=1.0
13
+
14
+ # memory-neo/docs/README.md
15
+ # Path: docs/README.md
16
+ # Purpose: User-facing documentation — install, usage, deployment
17
+
18
+ # 🧠 memory-neo
19
+
20
+ Push your codebase to a graph database. Query it with natural language.
21
+
22
+ ```bash
23
+ pip install memory-neo
24
+ cd your-project/
25
+ memory-neo push
26
+ memory-neo query "show all auth functions"
27
+ memory-neo context parse_directory
28
+ ```
29
+
30
+ ---
31
+
32
+ ## How it works
33
+
34
+ 1. **Push** — `memory-neo push` scans your project, extracts files and Python functions via AST, and sends the structure to a hosted Memgraph graph database.
35
+ 2. **Query** — `memory-neo query "..."` converts your question to Cypher via Claude, runs it against your graph, and prints results with code highlighting.
36
+ 3. **Context** — `memory-neo context <name>` fetches a function or file as prompt-ready code you can paste into any LLM.
37
+
38
+ ---
39
+
40
+ ## Install
41
+
42
+ ```bash
43
+ pip install memory-neo
44
+ ```
45
+
46
+ Python 3.9+ required.
47
+
48
+ ---
49
+
50
+ ## Authentication
51
+
52
+ Get an API key at [memory-neo.dev](https://memory-neo.dev), then:
53
+
54
+ ```bash
55
+ memory-neo login
56
+ # Paste your API key when prompted
57
+ # Saved to ~/.memoryneo/config.json
58
+ ```
59
+
60
+ ---
61
+
62
+ ## Commands
63
+
64
+ ### `memory-neo push`
65
+
66
+ Scan the current directory and push its structure to Memgraph.
67
+
68
+ ```bash
69
+ memory-neo push # use directory name as project name
70
+ memory-neo push my-project # explicit project name
71
+ memory-neo push --dir ./src # scan a subdirectory
72
+ memory-neo push --dry-run # scan only, don't push
73
+ ```
74
+
75
+ What gets indexed:
76
+ - Files: `.py` `.js` `.jsx` `.ts` `.tsx` `.html` `.md` `.txt`
77
+ - Python: full AST extraction — function names, line numbers, args, docstrings, code
78
+ - Other: file name, path, content, line count
79
+
80
+ Ignored by default (via `memIgnore`):
81
+ - `.venv/`, `node_modules/`, `__pycache__/`, `.git/`, `*.pyc`, `.env`, and more
82
+
83
+ Custom ignore: place a `memIgnore` file in your project root (same syntax as `.gitignore`).
84
+
85
+ ---
86
+
87
+ ### `memory-neo query`
88
+
89
+ Ask a natural language question about your indexed codebase.
90
+
91
+ ```bash
92
+ memory-neo query "show all auth functions"
93
+ memory-neo query "which files import httpx"
94
+ memory-neo query "list all Python files"
95
+ memory-neo query "how many functions are in each file"
96
+ memory-neo query "show the parse_directory function"
97
+ memory-neo query --project my-project "show all classes"
98
+ memory-neo query --raw "..." # print raw JSON
99
+ memory-neo query --context "..." # dump results as prompt-ready context block
100
+ memory-neo query # interactive mode
101
+ ```
102
+
103
+ ---
104
+
105
+ ### `memory-neo context`
106
+
107
+ Fetch the raw code of a function or file — ready to paste into a prompt.
108
+
109
+ ```bash
110
+ memory-neo context parse_directory # fetch function by name
111
+ memory-neo context memory_neo/main.py # fetch file by path
112
+ memory-neo context login --type function # force function lookup
113
+ memory-neo context main.py --copy # copy to clipboard
114
+ ```
115
+
116
+ ---
117
+
118
+ ## Ignore patterns (`memIgnore`)
119
+
120
+ Place a `memIgnore` file in your project root to control what gets scanned.
121
+ Uses the same syntax as `.gitignore`:
122
+
123
+ ```
124
+ # Folders
125
+ .venv/
126
+ node_modules/
127
+ dist/
128
+
129
+ # Wildcards
130
+ *.log
131
+ *.tmp
132
+ *.pyc
133
+
134
+ # Files
135
+ .env
136
+ secrets.json
137
+ ```
138
+
139
+ If no `memIgnore` is found in your project, the package default is used (covers most common cases).
140
+
141
+ ---
142
+
143
+ ## Self-hosting
144
+
145
+ You can run the entire backend yourself.
146
+
147
+ ### Requirements
148
+ - Fly.io account
149
+ - Supabase (or any PostgreSQL) account
150
+ - Anthropic API key
151
+
152
+ ### Deploy
153
+
154
+ ```bash
155
+ # 1. Deploy Memgraph
156
+ fly deploy --config deploy/fly.memgraph.toml
157
+
158
+ # 2. Create persistent volume
159
+ fly volumes create memgraph_data --size 20 --region cdg --app memory-neo-graph
160
+
161
+ # 3. Init Memgraph schema
162
+ fly ssh console --app memory-neo-graph
163
+ # Inside pod:
164
+ cat /init.cypher | mgconsole
165
+
166
+ # 4. Set API secrets
167
+ fly secrets set \
168
+ ANTHROPIC_API_KEY=sk-ant-... \
169
+ DATABASE_URL=postgresql://... \
170
+ API_SECRET_SALT=$(openssl rand -base64 32) \
171
+ --app memory-neo-api
172
+
173
+ # 5. Deploy API
174
+ fly deploy --config deploy/fly.api.toml
175
+
176
+ # 6. Run Prisma migrations
177
+ fly ssh console --app memory-neo-api
178
+ # Inside pod:
179
+ prisma migrate deploy --schema=schema.prisma
180
+ ```
181
+
182
+ ### Point CLI to your instance
183
+
184
+ ```bash
185
+ memory-neo login --api-url https://your-api.fly.dev
186
+ ```
187
+
188
+ ---
189
+
190
+ ## Project structure
191
+
192
+ ```
193
+ memory-neo/
194
+ ├── memory_neo/ ← Python package (pip install memory-neo)
195
+ │ ├── cli/ ← push, query, context, login commands
196
+ │ ├── core/ ← scanner, AST extractor, ignore patterns
197
+ │ ├── graph/ ← HTTP client to backend
198
+ │ ├── nlp/ ← result formatter
199
+ │ └── utils/ ← config, display helpers
200
+ ├── api/ ← FastAPI backend (Fly.io)
201
+ │ ├── routes/ ← push, query, context, auth endpoints
202
+ │ ├── services/ ← graph (Memgraph), nlp (Claude), auth
203
+ │ └── db/ ← schema.prisma (PostgreSQL)
204
+ ├── deploy/ ← Dockerfiles, fly.toml configs, init.cypher
205
+ └── docs/ ← this file
206
+ ```
207
+
208
+ ---
209
+
210
+ ## Tech stack
211
+
212
+ | Layer | Technology |
213
+ |---|---|
214
+ | CLI package | Python + Click + Rich |
215
+ | Backend | FastAPI on Fly.io |
216
+ | Graph DB | Memgraph on Fly.io (Bolt protocol) |
217
+ | Postgres | Supabase |
218
+ | NLP engine | Claude API (claude-sonnet) |
219
+ | Auth | API key (SHA-256 hashed) |
220
+
221
+ ---
222
+
223
+ ## License
224
+
225
+ MIT
@@ -0,0 +1,212 @@
1
+ # memory-neo/docs/README.md
2
+ # Path: docs/README.md
3
+ # Purpose: User-facing documentation — install, usage, deployment
4
+
5
+ # 🧠 memory-neo
6
+
7
+ Push your codebase to a graph database. Query it with natural language.
8
+
9
+ ```bash
10
+ pip install memory-neo
11
+ cd your-project/
12
+ memory-neo push
13
+ memory-neo query "show all auth functions"
14
+ memory-neo context parse_directory
15
+ ```
16
+
17
+ ---
18
+
19
+ ## How it works
20
+
21
+ 1. **Push** — `memory-neo push` scans your project, extracts files and Python functions via AST, and sends the structure to a hosted Memgraph graph database.
22
+ 2. **Query** — `memory-neo query "..."` converts your question to Cypher via Claude, runs it against your graph, and prints results with code highlighting.
23
+ 3. **Context** — `memory-neo context <name>` fetches a function or file as prompt-ready code you can paste into any LLM.
24
+
25
+ ---
26
+
27
+ ## Install
28
+
29
+ ```bash
30
+ pip install memory-neo
31
+ ```
32
+
33
+ Python 3.9+ required.
34
+
35
+ ---
36
+
37
+ ## Authentication
38
+
39
+ Get an API key at [memory-neo.dev](https://memory-neo.dev), then:
40
+
41
+ ```bash
42
+ memory-neo login
43
+ # Paste your API key when prompted
44
+ # Saved to ~/.memoryneo/config.json
45
+ ```
46
+
47
+ ---
48
+
49
+ ## Commands
50
+
51
+ ### `memory-neo push`
52
+
53
+ Scan the current directory and push its structure to Memgraph.
54
+
55
+ ```bash
56
+ memory-neo push # use directory name as project name
57
+ memory-neo push my-project # explicit project name
58
+ memory-neo push --dir ./src # scan a subdirectory
59
+ memory-neo push --dry-run # scan only, don't push
60
+ ```
61
+
62
+ What gets indexed:
63
+ - Files: `.py` `.js` `.jsx` `.ts` `.tsx` `.html` `.md` `.txt`
64
+ - Python: full AST extraction — function names, line numbers, args, docstrings, code
65
+ - Other: file name, path, content, line count
66
+
67
+ Ignored by default (via `memIgnore`):
68
+ - `.venv/`, `node_modules/`, `__pycache__/`, `.git/`, `*.pyc`, `.env`, and more
69
+
70
+ Custom ignore: place a `memIgnore` file in your project root (same syntax as `.gitignore`).
71
+
72
+ ---
73
+
74
+ ### `memory-neo query`
75
+
76
+ Ask a natural language question about your indexed codebase.
77
+
78
+ ```bash
79
+ memory-neo query "show all auth functions"
80
+ memory-neo query "which files import httpx"
81
+ memory-neo query "list all Python files"
82
+ memory-neo query "how many functions are in each file"
83
+ memory-neo query "show the parse_directory function"
84
+ memory-neo query --project my-project "show all classes"
85
+ memory-neo query --raw "..." # print raw JSON
86
+ memory-neo query --context "..." # dump results as prompt-ready context block
87
+ memory-neo query # interactive mode
88
+ ```
89
+
90
+ ---
91
+
92
+ ### `memory-neo context`
93
+
94
+ Fetch the raw code of a function or file — ready to paste into a prompt.
95
+
96
+ ```bash
97
+ memory-neo context parse_directory # fetch function by name
98
+ memory-neo context memory_neo/main.py # fetch file by path
99
+ memory-neo context login --type function # force function lookup
100
+ memory-neo context main.py --copy # copy to clipboard
101
+ ```
102
+
103
+ ---
104
+
105
+ ## Ignore patterns (`memIgnore`)
106
+
107
+ Place a `memIgnore` file in your project root to control what gets scanned.
108
+ Uses the same syntax as `.gitignore`:
109
+
110
+ ```
111
+ # Folders
112
+ .venv/
113
+ node_modules/
114
+ dist/
115
+
116
+ # Wildcards
117
+ *.log
118
+ *.tmp
119
+ *.pyc
120
+
121
+ # Files
122
+ .env
123
+ secrets.json
124
+ ```
125
+
126
+ If no `memIgnore` is found in your project, the package default is used (covers most common cases).
127
+
128
+ ---
129
+
130
+ ## Self-hosting
131
+
132
+ You can run the entire backend yourself.
133
+
134
+ ### Requirements
135
+ - Fly.io account
136
+ - Supabase (or any PostgreSQL) account
137
+ - Anthropic API key
138
+
139
+ ### Deploy
140
+
141
+ ```bash
142
+ # 1. Deploy Memgraph
143
+ fly deploy --config deploy/fly.memgraph.toml
144
+
145
+ # 2. Create persistent volume
146
+ fly volumes create memgraph_data --size 20 --region cdg --app memory-neo-graph
147
+
148
+ # 3. Init Memgraph schema
149
+ fly ssh console --app memory-neo-graph
150
+ # Inside pod:
151
+ cat /init.cypher | mgconsole
152
+
153
+ # 4. Set API secrets
154
+ fly secrets set \
155
+ ANTHROPIC_API_KEY=sk-ant-... \
156
+ DATABASE_URL=postgresql://... \
157
+ API_SECRET_SALT=$(openssl rand -base64 32) \
158
+ --app memory-neo-api
159
+
160
+ # 5. Deploy API
161
+ fly deploy --config deploy/fly.api.toml
162
+
163
+ # 6. Run Prisma migrations
164
+ fly ssh console --app memory-neo-api
165
+ # Inside pod:
166
+ prisma migrate deploy --schema=schema.prisma
167
+ ```
168
+
169
+ ### Point CLI to your instance
170
+
171
+ ```bash
172
+ memory-neo login --api-url https://your-api.fly.dev
173
+ ```
174
+
175
+ ---
176
+
177
+ ## Project structure
178
+
179
+ ```
180
+ memory-neo/
181
+ ├── memory_neo/ ← Python package (pip install memory-neo)
182
+ │ ├── cli/ ← push, query, context, login commands
183
+ │ ├── core/ ← scanner, AST extractor, ignore patterns
184
+ │ ├── graph/ ← HTTP client to backend
185
+ │ ├── nlp/ ← result formatter
186
+ │ └── utils/ ← config, display helpers
187
+ ├── api/ ← FastAPI backend (Fly.io)
188
+ │ ├── routes/ ← push, query, context, auth endpoints
189
+ │ ├── services/ ← graph (Memgraph), nlp (Claude), auth
190
+ │ └── db/ ← schema.prisma (PostgreSQL)
191
+ ├── deploy/ ← Dockerfiles, fly.toml configs, init.cypher
192
+ └── docs/ ← this file
193
+ ```
194
+
195
+ ---
196
+
197
+ ## Tech stack
198
+
199
+ | Layer | Technology |
200
+ |---|---|
201
+ | CLI package | Python + Click + Rich |
202
+ | Backend | FastAPI on Fly.io |
203
+ | Graph DB | Memgraph on Fly.io (Bolt protocol) |
204
+ | Postgres | Supabase |
205
+ | NLP engine | Claude API (claude-sonnet) |
206
+ | Auth | API key (SHA-256 hashed) |
207
+
208
+ ---
209
+
210
+ ## License
211
+
212
+ MIT
@@ -0,0 +1,5 @@
1
+ # memory-neo/memory_neo/__init__.py
2
+ # Path: memory_neo/__init__.py
3
+ # Purpose: Package init — exposes version
4
+
5
+ __version__ = "0.1.0"
@@ -0,0 +1,2 @@
1
+ # memory-neo/memory_neo/cli/__init__.py
2
+ # Path: memory_neo/cli/__init__.py
@@ -0,0 +1,86 @@
1
+ # memory-neo/memory_neo/cli/context.py
2
+ # Path: memory_neo/cli/context.py
3
+ # Purpose: `memory-neo context <fn_or_file>` — fetch code from Memgraph, print prompt-ready
4
+ # Flow: user names a function or file → GET /context → returns raw code block
5
+
6
+ import click
7
+ import httpx
8
+
9
+ from memory_neo.utils.config import require_auth
10
+ from memory_neo.utils.display import error, info, panel
11
+ from rich.syntax import Syntax
12
+ from rich.console import Console
13
+
14
+ console = Console()
15
+
16
+
17
+ @click.command()
18
+ @click.argument("target")
19
+ @click.option("--project", "-p", default=None, help="Project name (default: current dir name)")
20
+ @click.option("--type", "-t", "target_type", default="auto",
21
+ type=click.Choice(["auto", "function", "file"]),
22
+ help="Whether target is a function or file (default: auto-detect)")
23
+ @click.option("--copy", "-c", is_flag=True, help="Copy result to clipboard")
24
+ def context(target, project, target_type, copy):
25
+ """Fetch a function or file as prompt-ready context.
26
+
27
+ \b
28
+ Examples:
29
+ memory-neo context parse_directory
30
+ memory-neo context memory_neo/main.py
31
+ memory-neo context login --type function
32
+ memory-neo context --copy parse_directory
33
+ """
34
+ cfg = require_auth()
35
+
36
+ if not project:
37
+ import os
38
+ project = os.path.basename(os.path.abspath("."))
39
+
40
+ panel("memory-neo context", subtitle=f"Fetching: {target}")
41
+
42
+ try:
43
+ resp = httpx.get(
44
+ f"{cfg['api_url']}/context/{target}",
45
+ headers={"X-API-Key": cfg["api_key"]},
46
+ params={
47
+ "project_name": project,
48
+ "user_id": cfg["user_id"],
49
+ "target_type": target_type,
50
+ },
51
+ timeout=15,
52
+ )
53
+
54
+ if resp.status_code == 404:
55
+ error(f"Not found: [bold]{target}[/bold] in project [bold]{project}[/bold]")
56
+ info("Tip: run `memory-neo push` first to index your code.")
57
+ raise SystemExit(1)
58
+
59
+ if resp.status_code != 200:
60
+ error(f"Context fetch failed (HTTP {resp.status_code}): {resp.text}")
61
+ raise SystemExit(1)
62
+
63
+ data = resp.json()
64
+ code = data.get("code", "")
65
+ source = data.get("source", target)
66
+ lang = data.get("language", "python")
67
+
68
+ info(f" Source : [dim]{source}[/dim]")
69
+ info(f" Type : {data.get('type', '?')}")
70
+ if data.get("start_line"):
71
+ info(f" Lines : {data['start_line']}–{data['end_line']}")
72
+
73
+ console.print()
74
+ console.print(Syntax(code, lang, theme="monokai", line_numbers=True))
75
+
76
+ if copy:
77
+ try:
78
+ import subprocess
79
+ subprocess.run("pbcopy", input=code.encode(), check=True)
80
+ info("Copied to clipboard.")
81
+ except Exception:
82
+ error("Could not copy — install pbcopy (macOS) or xclip (Linux).")
83
+
84
+ except httpx.ConnectError:
85
+ error(f"Could not reach {cfg['api_url']}.")
86
+ raise SystemExit(1)
@@ -0,0 +1,49 @@
1
+ # memory-neo/memory_neo/cli/login.py
2
+ # Path: memory_neo/cli/login.py
3
+ # Purpose: `memory-neo login` — stores API key in ~/.memoryneo/config.json
4
+ # Flow: user pastes API key → validated against backend → saved locally
5
+
6
+ import click
7
+ import httpx
8
+ from memory_neo.utils.config import save_config, load_config
9
+ from memory_neo.utils.display import success, error, info, panel
10
+
11
+
12
+ @click.command()
13
+ @click.option("--key", "-k", default=None, help="API key (skip interactive prompt)")
14
+ @click.option("--api-url", default=None, help="Override API base URL (for self-hosting)")
15
+ def login(key, api_url):
16
+ """Authenticate with your memory-neo API key."""
17
+
18
+ panel("memory-neo login", subtitle="Authenticate to push and query your repos")
19
+
20
+ if not key:
21
+ info("Get your API key at https://memory-neo.dev or run your own backend.")
22
+ key = click.prompt(" Paste your API key", hide_input=True)
23
+
24
+ base_url = api_url or "https://api.memory-neo.dev"
25
+
26
+ info(f"Validating key against {base_url} ...")
27
+
28
+ try:
29
+ resp = httpx.post(
30
+ f"{base_url}/auth/validate",
31
+ headers={"X-API-Key": key},
32
+ timeout=10,
33
+ )
34
+ if resp.status_code == 200:
35
+ data = resp.json()
36
+ save_config({
37
+ "api_key": key,
38
+ "api_url": base_url,
39
+ "user_id": data.get("user_id"),
40
+ "email": data.get("email"),
41
+ })
42
+ success(f"Logged in as {data.get('email', 'unknown')}.")
43
+ success("Config saved to ~/.memoryneo/config.json")
44
+ else:
45
+ error(f"Invalid API key (HTTP {resp.status_code}).")
46
+ raise SystemExit(1)
47
+ except httpx.ConnectError:
48
+ error(f"Could not reach {base_url}. Check your internet or --api-url.")
49
+ raise SystemExit(1)
@@ -0,0 +1,35 @@
1
+ # memory-neo/memory_neo/cli/main.py
2
+ # Path: memory_neo/cli/main.py
3
+ # Purpose: CLI entrypoint — registers all commands under `memory-neo` binary
4
+ # Registered via pyproject.toml [project.scripts]: memory-neo = "memory_neo.cli.main:cli"
5
+
6
+
7
+ import click
8
+ from memory_neo import __version__
9
+ from memory_neo.cli.login import login
10
+ from memory_neo.cli.push import push
11
+ from memory_neo.cli.query import query
12
+ from memory_neo.cli.context import context
13
+
14
+
15
+ @click.group()
16
+ @click.version_option(__version__, prog_name="memory-neo")
17
+ def cli():
18
+ """
19
+ \b
20
+ memory-neo — push your codebase to a graph, query it with language.
21
+
22
+ \b
23
+ Commands:
24
+ login Authenticate with your API key
25
+ push Scan current directory and push to Memgraph
26
+ query Ask a natural language question about your code
27
+ context Fetch a file or function as prompt-ready context
28
+ """
29
+ pass
30
+
31
+
32
+ cli.add_command(login)
33
+ cli.add_command(push)
34
+ cli.add_command(query)
35
+ cli.add_command(context)