flywire-coding-cortex 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.
Files changed (29) hide show
  1. flywire_coding_cortex-0.1.0/LICENSE +21 -0
  2. flywire_coding_cortex-0.1.0/PKG-INFO +447 -0
  3. flywire_coding_cortex-0.1.0/README.md +423 -0
  4. flywire_coding_cortex-0.1.0/pyproject.toml +38 -0
  5. flywire_coding_cortex-0.1.0/setup.cfg +4 -0
  6. flywire_coding_cortex-0.1.0/src/flywire_coding_cortex/__init__.py +3 -0
  7. flywire_coding_cortex-0.1.0/src/flywire_coding_cortex/assets/circuit.seed.json +1 -0
  8. flywire_coding_cortex-0.1.0/src/flywire_coding_cortex/assets/manifest.json +54 -0
  9. flywire_coding_cortex-0.1.0/src/flywire_coding_cortex/assets/seed-graph.json +18 -0
  10. flywire_coding_cortex-0.1.0/src/flywire_coding_cortex/assets/skill/SKILL.md +55 -0
  11. flywire_coding_cortex-0.1.0/src/flywire_coding_cortex/assets/skill/practices.md +14 -0
  12. flywire_coding_cortex-0.1.0/src/flywire_coding_cortex/assets/skill/roles.md +17 -0
  13. flywire_coding_cortex-0.1.0/src/flywire_coding_cortex/bridge.py +85 -0
  14. flywire_coding_cortex-0.1.0/src/flywire_coding_cortex/cli.py +304 -0
  15. flywire_coding_cortex-0.1.0/src/flywire_coding_cortex/etl/__init__.py +1 -0
  16. flywire_coding_cortex-0.1.0/src/flywire_coding_cortex/etl/build_circuit.py +210 -0
  17. flywire_coding_cortex-0.1.0/src/flywire_coding_cortex/etl/download.py +128 -0
  18. flywire_coding_cortex-0.1.0/src/flywire_coding_cortex/install_skills.py +74 -0
  19. flywire_coding_cortex-0.1.0/src/flywire_coding_cortex/lif.py +335 -0
  20. flywire_coding_cortex-0.1.0/src/flywire_coding_cortex/mcp_server.py +208 -0
  21. flywire_coding_cortex-0.1.0/src/flywire_coding_cortex/memory.py +106 -0
  22. flywire_coding_cortex-0.1.0/src/flywire_coding_cortex/paths.py +112 -0
  23. flywire_coding_cortex-0.1.0/src/flywire_coding_cortex/sense.py +62 -0
  24. flywire_coding_cortex-0.1.0/src/flywire_coding_cortex.egg-info/PKG-INFO +447 -0
  25. flywire_coding_cortex-0.1.0/src/flywire_coding_cortex.egg-info/SOURCES.txt +27 -0
  26. flywire_coding_cortex-0.1.0/src/flywire_coding_cortex.egg-info/dependency_links.txt +1 -0
  27. flywire_coding_cortex-0.1.0/src/flywire_coding_cortex.egg-info/entry_points.txt +2 -0
  28. flywire_coding_cortex-0.1.0/src/flywire_coding_cortex.egg-info/requires.txt +9 -0
  29. flywire_coding_cortex-0.1.0/src/flywire_coding_cortex.egg-info/top_level.txt +1 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 FlyWire Coding Cortex contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,447 @@
1
+ Metadata-Version: 2.4
2
+ Name: flywire-coding-cortex
3
+ Version: 0.1.0
4
+ Summary: Run FlyWire-derived LIF neurons and map rates to coding-agent drives
5
+ Author: FlyWire Coding Cortex contributors
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/imrizwan/flywire-cortex
8
+ Project-URL: Codex, https://codex.flywire.ai/
9
+ Keywords: flywire,connectome,LIF,agent,openclaw,cursor,mcp
10
+ Classifier: License :: OSI Approved :: MIT License
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
13
+ Requires-Python: >=3.10
14
+ Description-Content-Type: text/markdown
15
+ License-File: LICENSE
16
+ Requires-Dist: numpy>=1.24
17
+ Provides-Extra: full
18
+ Requires-Dist: pandas>=2.0; extra == "full"
19
+ Requires-Dist: pyarrow>=14; extra == "full"
20
+ Provides-Extra: dev
21
+ Requires-Dist: build; extra == "dev"
22
+ Requires-Dist: wheel; extra == "dev"
23
+ Dynamic: license-file
24
+
25
+ # FlyWire Coding Cortex
26
+
27
+ **Pip-installable connector** for AI coding agents: install once, then every
28
+ Cursor / OpenClaw / Claude session can **run FlyWire-derived neurons** (leaky
29
+ integrate-and-fire on real synapse edges) and map population rates into
30
+ **coding drives** (implement, stop, reverse, steer, groom).
31
+
32
+ | | |
33
+ |---|---|
34
+ | **Code license** | MIT |
35
+ | **Circuit data** | FlyWire-derived, [CC BY-NC 4.0](data/DATA_LICENSE.md) |
36
+ | **Anatomy browser** | [FlyWire Codex](https://codex.flywire.ai/) |
37
+ | **Default seed** | 668 neurons · ~19k signed edges (FAFB v783 escape/steering subgraph) |
38
+
39
+ > **Honesty bar:** Wiring and contact counts come from public FlyWire data.
40
+ > Membrane dynamics, task→current encoding, and the rate→coding map are
41
+ > **models**. This does not claim biologically calibrated coding skill or that
42
+ > a fruit fly “understands” your codebase.
43
+
44
+ ---
45
+
46
+ ## Why this exists
47
+
48
+ Most agent “skills” are markdown instructions. This package is a
49
+ **pip-installable tool** plus an ambient skill/MCP connector so agents can
50
+ call a real runtime every session—without cloning a folder into every project.
51
+
52
+ ```text
53
+ coding task
54
+
55
+
56
+ sense (risk / tests / urgency → currents)
57
+
58
+
59
+ LIF on FlyWire-derived circuit.json
60
+
61
+
62
+ population rates (gf, dnp09, mdn, loom, …)
63
+
64
+
65
+ CodingSignals (primary drive + clamps)
66
+
67
+
68
+ agent acts ──verify──► Hebbian coding memory
69
+ ```
70
+
71
+ ---
72
+
73
+ ## Quick start
74
+
75
+ ```bash
76
+ # From this repository
77
+ pip install -e .
78
+ # Optional (needed for --profile full):
79
+ # pip install -e ".[full]"
80
+
81
+ flywire-cortex fetch --profile seed
82
+ flywire-cortex install
83
+ flywire-cortex status
84
+ ```
85
+
86
+ Smoke test:
87
+
88
+ ```bash
89
+ flywire-cortex reset
90
+ flywire-cortex sense --text "urgent failing auth bug"
91
+ flywire-cortex step --ms 50
92
+ flywire-cortex signals
93
+ ```
94
+
95
+ Example: giant-fiber stop drive
96
+
97
+ ```bash
98
+ flywire-cortex reset
99
+ flywire-cortex stimulate gf --strength 0.5 --ms 80
100
+ flywire-cortex step --ms 10
101
+ flywire-cortex signals
102
+ # → primary: "gf", escape: true, stop: true
103
+ ```
104
+
105
+ If `pip install` fails (SSL / corporate proxy), you can still run from source:
106
+
107
+ ```powershell
108
+ $env:PYTHONPATH = "C:\path\to\flywire-coding-cortex\src"
109
+ python -m flywire_coding_cortex.cli status
110
+ ```
111
+
112
+ ---
113
+
114
+ ## Install
115
+
116
+ ### 1. Package
117
+
118
+ ```bash
119
+ pip install flywire-coding-cortex # when published to PyPI
120
+ # or
121
+ pip install -e . # from a clone
122
+ # or
123
+ uv tool install .
124
+ ```
125
+
126
+ `pip install` **does not download** connectome dumps. Data is opt-in via `fetch`.
127
+
128
+ ### 2. Circuit profile
129
+
130
+ ```bash
131
+ flywire-cortex fetch --list-profiles
132
+ flywire-cortex fetch --profile seed # default, offline after copy
133
+ ```
134
+
135
+ ### 3. Wire agents
136
+
137
+ ```bash
138
+ flywire-cortex install
139
+ # or subset:
140
+ flywire-cortex install --targets cursor openclaw
141
+ ```
142
+
143
+ Copies `skill/` into:
144
+
145
+ | Target | Path |
146
+ |---|---|
147
+ | Cursor | `~/.cursor/skills/flywire-coding-cortex/` |
148
+ | OpenClaw | `~/.openclaw/workspace/skills/flywire-coding-cortex/` (and `~/.openclaw/skills/` when present) |
149
+ | Claude | `~/.claude/skills/flywire-coding-cortex/` |
150
+
151
+ Also writes `~/.flywire-coding-cortex/mcp.snippet.json`.
152
+
153
+ ### 4. Optional MCP connector (Cursor)
154
+
155
+ Add to your Cursor MCP config:
156
+
157
+ ```json
158
+ {
159
+ "mcpServers": {
160
+ "flywire-coding-cortex": {
161
+ "command": "flywire-cortex",
162
+ "args": ["mcp"]
163
+ }
164
+ }
165
+ }
166
+ ```
167
+
168
+ Then restart the agent session. Tools exposed:
169
+
170
+ | Tool | Purpose |
171
+ |---|---|
172
+ | `cortex_status` | Active profile + neuron/edge counts |
173
+ | `cortex_sense` | Task text → sensory currents |
174
+ | `cortex_step` | Advance LIF (`ms`, optional `text`) |
175
+ | `cortex_stimulate` | Stim a role group (`gf`, `dnp09`, …) |
176
+ | `cortex_signals` | Clamped coding drives JSON |
177
+ | `cortex_remember` | Query / strengthen / weaken memory |
178
+
179
+ ---
180
+
181
+ ## Download profiles
182
+
183
+ Choose (and later change) how much FlyWire data to pull. Profiles are cached
184
+ side-by-side under `~/.flywire-coding-cortex/profiles/<name>/`. `status` /
185
+ `step` always use the **active** profile.
186
+
187
+ | Profile | Approx size | Command | What you get |
188
+ |---|---|---|---|
189
+ | `seed` | ~0.3–5 MB | `flywire-cortex fetch` | Bundled curated subgraph (668 cells by default) |
190
+ | `codex` | ~60–300 MB | `flywire-cortex fetch --profile codex` | Public Codex gzipped CSVs + ETL rebuild |
191
+ | `full` | ~10.6 GB | `flywire-cortex fetch --profile full --yes` | Zenodo Feathers + ETL (explicit confirm) |
192
+
193
+ ```bash
194
+ flywire-cortex fetch --list-profiles
195
+ flywire-cortex fetch --profile seed --force # re-copy / switch back
196
+ flywire-cortex fetch --profile full --yes
197
+ flywire-cortex fetch --profile full --yes --include-synapses # also ~9.5 GB synapse table
198
+ flywire-cortex status
199
+ ```
200
+
201
+ **Rules:**
202
+
203
+ - Agents must **never** auto-run `full`. Ask the human first.
204
+ - `full` requires `--yes` and `pip install 'flywire-coding-cortex[full]'` (pandas + pyarrow).
205
+ - URLs live in [`data/manifest.json`](data/manifest.json) so mirrors can be edited without code changes.
206
+
207
+ Codex dump base (FAFB v783):
208
+
209
+ `https://storage.googleapis.com/flywire-data/codex/data/fafb/783`
210
+
211
+ ---
212
+
213
+ ## Every coding turn (agent loop)
214
+
215
+ The bundled skill instructs agents to run this loop (CLI or MCP):
216
+
217
+ 1. **`status`** — ensure a circuit exists (`fetch --profile seed` if missing)
218
+ 2. **`sense --text "…"`** — encode the task into currents (risk, test-red, urgency, ambiguity)
219
+ 3. **`step --ms 50`** — run LIF on real edges
220
+ 4. **`signals`** — read `primary` drive and clamps
221
+ 5. **Act only under that primary drive** (see [Roles](#roles--coding-drives))
222
+ 6. Apply [practices](#thinking-practices)
223
+ 7. After verify: **`remember strengthen|weaken`**
224
+
225
+ LIF voltage/rates persist across separate CLI invocations in
226
+ `~/.flywire-coding-cortex/state/lif_state.json`. Use `flywire-cortex reset` to
227
+ clear between unrelated tasks.
228
+
229
+ ---
230
+
231
+ ## CLI reference
232
+
233
+ ```text
234
+ flywire-cortex <command> …
235
+ ```
236
+
237
+ | Command | Description |
238
+ |---|---|
239
+ | `fetch` | Download / activate a profile (`--profile`, `--list-profiles`, `--force`, `--yes`, `--include-synapses`) |
240
+ | `status` | Home path, active profile, neuron/edge/role counts |
241
+ | `sense` | Encode task text (or `--risk` / `--test-red` / `--urgency` / `--ambiguity`) |
242
+ | `step` | Advance simulation (`--ms`, optional `--text`) |
243
+ | `stimulate` | Stim a group: `gf`, `dnp09`, `mdn`, `lc4`, `lplc2`, `dng11`, `escw`, `dna01`, `dna02`, … |
244
+ | `signals` | Emit coding drives JSON (`--ms` to step first) |
245
+ | `reset` | Clear persisted LIF state |
246
+ | `remember` | `query` \| `strengthen` \| `weaken` \| `add-node` \| `add-edge` |
247
+ | `install` | Copy skills + print MCP snippet (`--targets`) |
248
+ | `mcp` | Run MCP stdio server |
249
+
250
+ ### `remember` examples
251
+
252
+ ```bash
253
+ flywire-cortex remember query --text "auth middleware"
254
+ flywire-cortex remember strengthen --pre concept:tests --post role:dnp09 --why "ci green"
255
+ flywire-cortex remember weaken --pre concept:migration --post role:dnp09 --why "broke prod"
256
+ flywire-cortex remember add-node --pre concept:oauth --label "OAuth flow"
257
+ flywire-cortex remember add-edge --pre concept:oauth --post role:lc4 --why "auth is high risk"
258
+ ```
259
+
260
+ ---
261
+
262
+ ## Roles → coding drives
263
+
264
+ FlyWire-style role names are **coding lenses**. Rates come from the live sim;
265
+ the bridge picks a **winner-take-most** primary.
266
+
267
+ | Role | Drive | Agent should |
268
+ |---|---|---|
269
+ | `lc4` / `lplc2` | Risk / loom | Scan blast radius, security, regressions |
270
+ | `gf` | Escape / stop | Do not ship; halt feature work; unblocker |
271
+ | `dnp09` | Forward | Implement the requested change |
272
+ | `mdn` | Reverse | Revert / undo a bad direction |
273
+ | `dna01` / `dna02` | Steer | Write L vs R tradeoff, then choose |
274
+ | `dng11` | Groom | Cleanup, rename, lint-only |
275
+ | `escw` | Effort under pressure | Polish without scope creep |
276
+ | `ascending` | Proprioception | Read local conventions before inventing |
277
+ | `sensory` | External constraint | Honor ticket / failing test / user text |
278
+
279
+ Example `signals` payload:
280
+
281
+ ```json
282
+ {
283
+ "primary": "dnp09",
284
+ "escape": false,
285
+ "stop": false,
286
+ "reverse": false,
287
+ "walk_drive": 0.42,
288
+ "nervous": 0.12,
289
+ "support": ["lc4"],
290
+ "rationale": "primary=dnp09 walk=0.42 nervous=0.12 mdn=0.0 gf=False"
291
+ }
292
+ ```
293
+
294
+ ---
295
+
296
+ ## Thinking practices
297
+
298
+ Applied **on top of** rates (see `skill/practices.md`):
299
+
300
+ 1. **Winner-take-most** — one primary drive per turn
301
+ 2. **Inhibition delay** — high risk → list blast radius before edits
302
+ 3. **Recurrent working set** — ≤5 active files/APIs
303
+ 4. **Hebbian writeback** — strengthen only after verify; weaken on failure
304
+ 5. **Sparse coding** — smallest change that satisfies the drive
305
+ 6. **Bilateral steer** — design forks get an explicit L/R paragraph
306
+ 7. **Proprioception first** — read neighbors before new patterns
307
+ 8. **Refractory** — after `gf` / `mdn`, no new feature drive that turn
308
+ 9. **Population scores** — prefer CLI sense scores over vibes
309
+ 10. **Consolidate** — end of session: 3 new + 1 weakened memory edges
310
+
311
+ ---
312
+
313
+ ## Architecture
314
+
315
+ ```text
316
+ flywire-coding-cortex/
317
+ pyproject.toml
318
+ README.md ← you are here
319
+ INSTALL.md
320
+ LICENSE ← MIT (code)
321
+ data/
322
+ circuit.seed.json ← curated FlyWire subgraph (CC BY-NC)
323
+ manifest.json ← profile URLs / sizes
324
+ DATA_LICENSE.md
325
+ memory/
326
+ seed-graph.json ← starter coding-memory ontology
327
+ skill/
328
+ SKILL.md ← Cursor / OpenClaw / Claude skill
329
+ roles.md
330
+ practices.md
331
+ src/flywire_coding_cortex/
332
+ cli.py ← entrypoint
333
+ lif.py ← LIF on CSR adjacency
334
+ sense.py ← task → currents
335
+ bridge.py ← rates → CodingSignals
336
+ memory.py ← Hebbian graph
337
+ paths.py ← FLYWIRE_CORTEX_HOME helpers
338
+ mcp_server.py
339
+ install_skills.py
340
+ assets/ ← copies shipped in the wheel
341
+ etl/
342
+ download.py ← fetch profiles
343
+ build_circuit.py ← Codex / Feather → circuit.json
344
+ ```
345
+
346
+ ### Runtime home (`FLYWIRE_CORTEX_HOME`)
347
+
348
+ Default: `~/.flywire-coding-cortex/`
349
+
350
+ | Path | Contents |
351
+ |---|---|
352
+ | `config.json` | Active profile name |
353
+ | `profiles/<name>/circuit.json` | Active wiring |
354
+ | `profiles/<name>/raw/` | Downloaded dumps (gitignored) |
355
+ | `state/lif_state.json` | Persisted voltages / rates / stims |
356
+ | `memory/graph.json` | Coding synapses (not FlyWire edges) |
357
+ | `mcp.snippet.json` | MCP config helper |
358
+
359
+ Override:
360
+
361
+ ```bash
362
+ # bash
363
+ export FLYWIRE_CORTEX_HOME=/path/to/cortex-home
364
+
365
+ # PowerShell
366
+ $env:FLYWIRE_CORTEX_HOME = "D:\cortex-home"
367
+ ```
368
+
369
+ ### What is real vs modeled
370
+
371
+ | Real (measured / extracted) | Modeled |
372
+ |---|---|
373
+ | Neuron IDs, sides, types, roles in the subgraph | LIF τ, threshold, noise, weight scale |
374
+ | Signed synapse counts from Codex NT types | Task text → current injection |
375
+ | Graph adjacency used for spike propagation | Rate → coding-drive clamps |
376
+ | | Hebbian coding-memory edges |
377
+
378
+ ---
379
+
380
+ ## Environment & dependencies
381
+
382
+ - Python **≥ 3.10** (3.10+ recommended; annotations use modern syntax)
383
+ - Required: `numpy`
384
+ - Optional `[full]`: `pandas`, `pyarrow` (Zenodo Feather profile)
385
+
386
+ ```bash
387
+ pip install -e ".[full]"
388
+ ```
389
+
390
+ ---
391
+
392
+ ## Limitations (v1)
393
+
394
+ - Does **not** simulate the full ~139k-neuron brain every turn
395
+ - Does **not** call live Codex apps (sign-in wall); uses static public files
396
+ - Does **not** depend on DesktopFly or any overlay app
397
+ - `full` downloads are large; confirm disk and network before `--yes`
398
+ - MCP server is a minimal JSON-RPC subset (`initialize`, `tools/list`, `tools/call`)
399
+
400
+ ---
401
+
402
+ ## Troubleshooting
403
+
404
+ | Symptom | Fix |
405
+ |---|---|
406
+ | `flywire-cortex` not found | `pip install -e .` or set `PYTHONPATH=…/src` and run `python -m flywire_coding_cortex.cli` |
407
+ | `circuit.seed.json missing` | Run `fetch --profile codex` once to rebuild, or ensure `data/circuit.seed.json` exists in the repo |
408
+ | Rates always zero across commands | Call `sense`/`stimulate` then `step`; state persists—use `reset` between unrelated tasks |
409
+ | `full` refuses to run | Pass `--yes`; install `[full]` extras |
410
+ | Skill not picked up | Re-run `flywire-cortex install`; start a **new** agent session |
411
+ | SSL errors on `pip install` | Fix certs / use a venv; interim: `PYTHONPATH` + `python -m …` |
412
+
413
+ ---
414
+
415
+ ## Citation & attribution
416
+
417
+ Please cite FlyWire when using or redistributing circuit extracts:
418
+
419
+ - Dorkenwald, S. et al. *Neuronal wiring diagram of an adult brain.* Nature 634, 124–138 (2024). https://doi.org/10.1038/s41586-024-07558-y
420
+ - Schlegel, P. et al. *Whole-brain annotation and multi-connectome cell typing of Drosophila.* Nature 634, 139–152 (2024). https://doi.org/10.1038/s41586-024-07686-5
421
+
422
+ Project sites: [flywire.ai](https://flywire.ai) · [codex.flywire.ai](https://codex.flywire.ai/)
423
+
424
+ Code in this repository is MIT. Derived JSON and downloaded dumps remain under
425
+ FlyWire’s **CC BY-NC 4.0** terms — see [data/DATA_LICENSE.md](data/DATA_LICENSE.md).
426
+
427
+ ---
428
+
429
+ ## Contributing / publishing
430
+
431
+ ```bash
432
+ git clone <this-repo>
433
+ cd flywire-coding-cortex
434
+ pip install -e ".[full]"
435
+ flywire-cortex fetch --profile seed
436
+ flywire-cortex install
437
+ ```
438
+
439
+ To rebuild the shipped seed from Codex dumps:
440
+
441
+ ```bash
442
+ flywire-cortex fetch --profile codex --force
443
+ # copies rebuilt circuit into data/circuit.seed.json and package assets
444
+ ```
445
+
446
+ When ready for GitHub/PyPI: tag a release, ensure `circuit.seed.json` is
447
+ committed, and document the CC BY-NC split in the release notes.