gnosion 0.2.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.
- gnosion-0.2.0/LICENSE +21 -0
- gnosion-0.2.0/MANIFEST.in +7 -0
- gnosion-0.2.0/PKG-INFO +444 -0
- gnosion-0.2.0/README.md +420 -0
- gnosion-0.2.0/USAGE.md +228 -0
- gnosion-0.2.0/gnosion/__init__.py +14 -0
- gnosion-0.2.0/gnosion/agent.py +190 -0
- gnosion-0.2.0/gnosion/artifact.py +64 -0
- gnosion-0.2.0/gnosion/cli.py +167 -0
- gnosion-0.2.0/gnosion/core.py +223 -0
- gnosion-0.2.0/gnosion/embed.py +167 -0
- gnosion-0.2.0/gnosion/feed.py +201 -0
- gnosion-0.2.0/gnosion/handoff.py +121 -0
- gnosion-0.2.0/gnosion/heads.py +176 -0
- gnosion-0.2.0/gnosion/linalg.py +69 -0
- gnosion-0.2.0/gnosion/mapping.py +411 -0
- gnosion-0.2.0/gnosion/mcp_server.py +157 -0
- gnosion-0.2.0/gnosion/ml.py +66 -0
- gnosion-0.2.0/gnosion/registry.py +57 -0
- gnosion-0.2.0/gnosion/ui.py +562 -0
- gnosion-0.2.0/gnosion.egg-info/PKG-INFO +444 -0
- gnosion-0.2.0/gnosion.egg-info/SOURCES.txt +26 -0
- gnosion-0.2.0/gnosion.egg-info/dependency_links.txt +1 -0
- gnosion-0.2.0/gnosion.egg-info/entry_points.txt +2 -0
- gnosion-0.2.0/gnosion.egg-info/requires.txt +15 -0
- gnosion-0.2.0/gnosion.egg-info/top_level.txt +1 -0
- gnosion-0.2.0/pyproject.toml +34 -0
- gnosion-0.2.0/setup.cfg +4 -0
gnosion-0.2.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Crave Asia / IPG
|
|
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.
|
gnosion-0.2.0/PKG-INFO
ADDED
|
@@ -0,0 +1,444 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: gnosion
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: Gnosion β a portable, self-improving cognitive engine: pluggable cognition heads (vision/text/design/tabular/memory) that learn from every input, exportable as a single .gnosion file and importable into any project.
|
|
5
|
+
Author: Crave Asia / IPG
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/craveasia/gnosion
|
|
8
|
+
Keywords: machine-learning,embeddings,self-learning,memory,portable-model,brain
|
|
9
|
+
Requires-Python: >=3.9
|
|
10
|
+
Description-Content-Type: text/markdown
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Provides-Extra: embed
|
|
13
|
+
Requires-Dist: fastembed>=0.4; extra == "embed"
|
|
14
|
+
Provides-Extra: ml
|
|
15
|
+
Requires-Dist: numpy>=1.23; extra == "ml"
|
|
16
|
+
Requires-Dist: scikit-learn>=1.2; extra == "ml"
|
|
17
|
+
Provides-Extra: all
|
|
18
|
+
Requires-Dist: fastembed>=0.4; extra == "all"
|
|
19
|
+
Requires-Dist: numpy>=1.23; extra == "all"
|
|
20
|
+
Requires-Dist: scikit-learn>=1.2; extra == "all"
|
|
21
|
+
Provides-Extra: dev
|
|
22
|
+
Requires-Dist: pytest>=7; extra == "dev"
|
|
23
|
+
Dynamic: license-file
|
|
24
|
+
|
|
25
|
+
<div align="center">
|
|
26
|
+
|
|
27
|
+
# π§ Gnosion
|
|
28
|
+
|
|
29
|
+
**A portable, self-improving cognitive engine β and a universal memory for any coding agent.**
|
|
30
|
+
|
|
31
|
+
*Learns from every input Β· exports to one file Β· imports anywhere Β· zero required dependencies.*
|
|
32
|
+
|
|
33
|
+
`pip install gnosion` Β· `npm i -g gnosion` Β· MIT
|
|
34
|
+
|
|
35
|
+
</div>
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
Gnosion is a small, honest brain you can drop into anything: a product, a data
|
|
40
|
+
pipeline, or your coding workflow. It holds several **cognition domains** (vision,
|
|
41
|
+
text, design, tabular, memory) that each learn their own way, guards them so they
|
|
42
|
+
never regress or memorise junk, and packs the whole thing into a single portable
|
|
43
|
+
`.gnosion` file you can move between projects and machines.
|
|
44
|
+
|
|
45
|
+
It also doubles as a **shared project memory for coding agents** β Claude Code,
|
|
46
|
+
Cursor, Windsurf, Cline, Aider, Zed, or your own scripts β via a CLI and an MCP
|
|
47
|
+
server, so agents stop re-deriving your decisions, drifting from your structure, or
|
|
48
|
+
repeating fixed bugs.
|
|
49
|
+
|
|
50
|
+
- πͺΆ **Zero required dependencies.** Pure-Python core β installs and runs anywhere,
|
|
51
|
+
no PyTorch, no build step.
|
|
52
|
+
- π **Gets smarter on every input.** Each `learn()` improves the right domain;
|
|
53
|
+
memory recalls from a *single* example.
|
|
54
|
+
- π¦ **Portable.** `export()` β one `.gnosion`. `load()` it anywhere. Ship it in git.
|
|
55
|
+
- π **Fully flexible.** Add your own domains and swap in your own embedder in a line.
|
|
56
|
+
- π€ **Universal agent memory.** One CLI + one MCP server, shared across every agent.
|
|
57
|
+
- π«± **Honest.** Lightweight ML (nearest-centroid + k-NN over embeddings) β no magic,
|
|
58
|
+
no black box. Optional extras add real semantic quality.
|
|
59
|
+
- πΈοΈ **Visual & interactive.** `gns ui` opens a drag/zoom/spin **neuro-graph** of
|
|
60
|
+
everything the brain knows, with views for knowledge, projects, and chat β feed it,
|
|
61
|
+
map a project, and export a handoff right from the browser. See [the dashboard](#the-interactive-dashboard-gns-ui).
|
|
62
|
+
- π½οΈ **Feeds on anything.** `gns feed` learns from `.md` files, folders, or web pages
|
|
63
|
+
(with optional crawl) into named knowledge domains (marketing, SEO, DevOpsβ¦).
|
|
64
|
+
|
|
65
|
+
## How it works (one glance)
|
|
66
|
+
|
|
67
|
+
Every input is embedded to a vector, routed to the domain's head, and folded into one
|
|
68
|
+
portable file. Nothing else to run.
|
|
69
|
+
|
|
70
|
+
```mermaid
|
|
71
|
+
flowchart LR
|
|
72
|
+
IN["input<br/>text Β· image Β· numbers"] --> EMB["embedder<br/>hashing (0-dep) or fastembed (semantic)"]
|
|
73
|
+
EMB --> H{"domain head"}
|
|
74
|
+
H -->|classifier| C["nearest-centroid + optional logreg<br/>champion / challenger β never regresses"]
|
|
75
|
+
H -->|memory| M["k-NN cosine recall<br/>learns from ONE example Β· reinforces on hit"]
|
|
76
|
+
C --> F[("one .gnosion file<br/>portable Β· git-committable")]
|
|
77
|
+
M --> F
|
|
78
|
+
F -.load anywhere.-> IN
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## Install
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
pip install gnosion # Python, zero deps
|
|
85
|
+
pip install "gnosion[embed]" # + fastembed (ONNX MiniLM/CLIP) β semantic quality
|
|
86
|
+
pip install "gnosion[ml]" # + numpy / scikit-learn acceleration
|
|
87
|
+
|
|
88
|
+
npm i -g gnosion # Node wrapper (bundles the Python core; needs Python 3.9+)
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
**Automatic quality upgrades β zero code changes.** Install an extra and Gnosion just
|
|
92
|
+
gets better on its own:
|
|
93
|
+
- `gnosion[ml]` β classifiers automatically use a **calibrated logistic regression**
|
|
94
|
+
(falls back to nearest-centroid otherwise). The `.gnosion` stays plain JSON β the
|
|
95
|
+
model is re-fit from the stored samples, never pickled.
|
|
96
|
+
- `gnosion[embed]` β embeddings become **semantic** (fastembed ONNX MiniLM/CLIP, no
|
|
97
|
+
torch) so paraphrases and visually-similar images match. Opt out with
|
|
98
|
+
`GNOSION_NO_FASTEMBED=1`. A brain records which embedder it used, so it reloads
|
|
99
|
+
consistently.
|
|
100
|
+
|
|
101
|
+
## Quickstart (Python)
|
|
102
|
+
|
|
103
|
+
```python
|
|
104
|
+
from gnosion import Gnosion
|
|
105
|
+
|
|
106
|
+
bx = Gnosion() # 5 default cognition domains
|
|
107
|
+
|
|
108
|
+
# classify β teach with labels, then predict
|
|
109
|
+
bx.learn("text", "how do I reset my password", label="account")
|
|
110
|
+
bx.learn("text", "what are your opening hours", label="hours")
|
|
111
|
+
bx.train("text")
|
|
112
|
+
bx.predict("text", "i forgot my password") # {'label': 'account', 'confidence': 0.83}
|
|
113
|
+
|
|
114
|
+
# remember facts / conventions β memory learns from ONE example
|
|
115
|
+
bx.remember("design", "auth pattern",
|
|
116
|
+
"Use a JWT in an httpOnly cookie; the refresh token rotates.")
|
|
117
|
+
bx.recall("design", "auth pattern") # {'value': '...', 'similarity': 1.0}
|
|
118
|
+
|
|
119
|
+
# vision (image bytes) and tabular (feature vectors) work the same way
|
|
120
|
+
bx.learn("vision", open("leak.jpg", "rb").read(), label="plumbing")
|
|
121
|
+
bx.learn("tabular", [500000, 0.1, 4.0, 30], label="affordable")
|
|
122
|
+
|
|
123
|
+
# one portable file β import anywhere
|
|
124
|
+
bx.export("company.gnosion")
|
|
125
|
+
same_brain = Gnosion.load("company.gnosion")
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
## The 5 default cognition domains ("neurons")
|
|
129
|
+
|
|
130
|
+
| Domain | Head | Input | What it does |
|
|
131
|
+
|-----------|-------------|-----------------|--------------|
|
|
132
|
+
| `vision` | classifier | image bytes | what kind of thing is in the picture |
|
|
133
|
+
| `text` | classifier | text | intent / category of a message |
|
|
134
|
+
| `design` | memory | text | system-design & structure conventions (recall) |
|
|
135
|
+
| `tabular` | classifier | list of numbers | outcome from numeric features |
|
|
136
|
+
| `memory` | memory | text | general knowledge recall (from 1 example) |
|
|
137
|
+
|
|
138
|
+
```mermaid
|
|
139
|
+
flowchart TB
|
|
140
|
+
G(("π§ Gnosion")) --> V["vision<br/><i>classifier Β· image</i>"]
|
|
141
|
+
G --> T["text<br/><i>classifier Β· text</i>"]
|
|
142
|
+
G --> D["design<br/><i>memory Β· text</i>"]
|
|
143
|
+
G --> B["tabular<br/><i>classifier Β· numbers</i>"]
|
|
144
|
+
G --> M["memory<br/><i>memory Β· text</i>"]
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
Add your own: `bx.add_domain("sentiment", head="classifier", modality="text")`.
|
|
148
|
+
|
|
149
|
+
## Universal coding-agent memory π€
|
|
150
|
+
|
|
151
|
+
A full **agent-memory model** any agent can read and write β persisted to
|
|
152
|
+
`./.gnosion/project.gnosion` in the repo. It covers the standard agent-memory types:
|
|
153
|
+
|
|
154
|
+
| Type | Holds |
|
|
155
|
+
|---|---|
|
|
156
|
+
| `fact` | world / semantic facts |
|
|
157
|
+
| `entity` | facts **about** the user / project / environment / team / domain |
|
|
158
|
+
| `experience` | **episodic** β "did X β got Y" events (experience tracking) |
|
|
159
|
+
| `observation` | raw things noticed in the environment |
|
|
160
|
+
| `skill` | **procedural**, user-addable how-to procedures the agent recalls & follows |
|
|
161
|
+
| `decision Β· convention Β· structure Β· bug Β· preference` | how / why you work |
|
|
162
|
+
|
|
163
|
+
**CLI** (any agent can shell out to this):
|
|
164
|
+
```bash
|
|
165
|
+
gns note "The user prefers concise plain-text replies" --kind entity --subject user
|
|
166
|
+
gns note "We use JWT in an httpOnly cookie; refresh rotates" --kind decision
|
|
167
|
+
gns experience "used dedup reuse for repeat photos" --outcome "served stale label; now re-runs"
|
|
168
|
+
gns observe "the vision model classifies category only, not sub-category"
|
|
169
|
+
gns skill "deploy" --when "shipping a change" --how "git pull; docker compose up -d --build"
|
|
170
|
+
gns ask "how do we do auth" # recall relevant memories (any type)
|
|
171
|
+
gns skills # list learned skills
|
|
172
|
+
gns brief # session-start briefing (facts, decisions, skills)
|
|
173
|
+
gns mem # counts by type
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
**MCP** β one config, works across MCP-capable agents (Claude Code, Cursor, Windsurf,
|
|
177
|
+
Cline, Zed, β¦). They all share the same repo `.gnosion`, so memory carries across
|
|
178
|
+
agents *and* sessions:
|
|
179
|
+
```jsonc
|
|
180
|
+
{ "mcpServers": { "gnosion": { "command": "gns", "args": ["mcp"] } } }
|
|
181
|
+
```
|
|
182
|
+
Tools exposed: **remember Β· recall Β· record_experience Β· observe Β· add_skill Β·
|
|
183
|
+
recall_skill Β· briefing Β· stats**. (Pure stdlib JSON-RPC over stdio β no SDK needed.)
|
|
184
|
+
|
|
185
|
+
**Python:**
|
|
186
|
+
```python
|
|
187
|
+
from gnosion.agent import AgentMemory
|
|
188
|
+
mem = AgentMemory(root=".")
|
|
189
|
+
mem.about("user", "prefers concise plain-text answers") # entity fact
|
|
190
|
+
mem.experience("tried X", outcome="failed because Y") # episodic
|
|
191
|
+
mem.observe("CI is flaky on the payments module") # observation
|
|
192
|
+
mem.add_skill("deploy", when_to_use="shipping a change",
|
|
193
|
+
how="git pull; docker compose up -d --build") # user-added skill
|
|
194
|
+
mem.recall_skill("how do I ship this") # -> the deploy skill
|
|
195
|
+
mem.recall("how do we do auth") # across all types
|
|
196
|
+
print(mem.briefing())
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
> Recall matches shared **words** out of the box (zero-dep). For **semantic**
|
|
200
|
+
> paraphrase recall, `pip install "gnosion[embed]"` and set `GNOSION_SEMANTIC=1`
|
|
201
|
+
> (or `AgentMemory(semantic=True)`) β then it uses fastembed (ONNX MiniLM, no torch).
|
|
202
|
+
|
|
203
|
+
## The walking brain πΆ
|
|
204
|
+
|
|
205
|
+
Gnosion is *portable*, so it goes with you. Every time an `AgentMemory` saves, it
|
|
206
|
+
records the project into a global registry at `~/.gnosion/registry.json` β so one brain
|
|
207
|
+
remembers **every project it has entered** and what it learned in each. `gns ui` reads
|
|
208
|
+
that registry to show the whole picture.
|
|
209
|
+
|
|
210
|
+
```mermaid
|
|
211
|
+
flowchart LR
|
|
212
|
+
PA["project A<br/>.gnosion"] --> R
|
|
213
|
+
PB["project B<br/>.gnosion"] --> R
|
|
214
|
+
PC["project C<br/>.gnosion"] --> R
|
|
215
|
+
R["~/.gnosion registry<br/><i>what learned where</i>"] --> UI["gns ui<br/>πΈοΈ neuro-graph"]
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
## The interactive dashboard (`gns ui`)
|
|
219
|
+
|
|
220
|
+
```bash
|
|
221
|
+
gns ui # dashboard for THIS repo's ./.gnosion/project.gnosion
|
|
222
|
+
gns ui company.gnosion # dashboard for any explicit .gnosion file
|
|
223
|
+
gns ui --port 9000 # pick a port (auto-finds a free one otherwise)
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
Opens a **local, self-contained, interactive dashboard** (pure stdlib server β no deps,
|
|
227
|
+
no CDN, no internet). The main canvas is a **live force-directed neuro-graph** you can
|
|
228
|
+
**drag, zoom (scroll), pan (drag background), and spin** (orbit toggle); double-click any
|
|
229
|
+
neuron for details. The left rail switches **views**:
|
|
230
|
+
|
|
231
|
+
| View | Shows |
|
|
232
|
+
|---|---|
|
|
233
|
+
| **Neuro** | *every* neuron the brain has learned β the whole mind, clustered by similarity (dot = neuron, edge = similarity, size = how often recalled) |
|
|
234
|
+
| **Coding Agent** | the project **knowledge graph** β files, functions, classes & concepts as typed nodes; imports/calls/references as edges; detected stack β with one-click **handoff.md** export |
|
|
235
|
+
| **Chat / Training** | the conversational brain (`text` Β· `design` Β· `memory`) + its clusters |
|
|
236
|
+
| ***\<domain>*** | one nav **per fed knowledge domain** (marketing, seo, devopsβ¦) β **appears automatically** as the brain learns |
|
|
237
|
+
|
|
238
|
+
Long lists are collapsed to the first 5 with a **"see all N β"** modal (searchable), so a
|
|
239
|
+
big brain stays readable. The sidebar also lists every **project** the walking brain has
|
|
240
|
+
entered (click to switch), and live stats. You can **feed knowledge** (paste text / a URL,
|
|
241
|
+
optional crawl) and **re-scan / export a handoff** right from the toolbar.
|
|
242
|
+
|
|
243
|
+
```mermaid
|
|
244
|
+
flowchart LR
|
|
245
|
+
subgraph UI["gns ui Β· one canvas, many views"]
|
|
246
|
+
N["π§ Neuro<br/>all knowledge"]
|
|
247
|
+
C["π» Coding Agent<br/>files + imports + stack"]
|
|
248
|
+
T["π¬ Chat / Training<br/>text Β· design Β· memory"]
|
|
249
|
+
K["π marketing / seo / devopsβ¦<br/>auto-appear per fed domain"]
|
|
250
|
+
end
|
|
251
|
+
BRAIN[(".gnosion")] --> UI
|
|
252
|
+
UI -->|"+ Feed"| BRAIN
|
|
253
|
+
C -->|"β¬ handoff.md"| AGENT["Claude Β· Codex Β· Cursor"]
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
> Run `gns ui` locally to see it β the graph animates and is fully interactive. (The repo
|
|
257
|
+
> ships no PNGs; the diagram above is the layout.)
|
|
258
|
+
|
|
259
|
+
## Feed it knowledge (`gns feed`)
|
|
260
|
+
|
|
261
|
+
Gnosion learns anything you point it at, into a **named knowledge domain** (which then
|
|
262
|
+
becomes its own nav + cluster in the UI, and is searchable via `gns ask`). Pure stdlib.
|
|
263
|
+
|
|
264
|
+
```bash
|
|
265
|
+
gns feed notes.md --domain marketing # a markdown/text file β chunked
|
|
266
|
+
gns feed ./kb --domain seo # a whole folder (.md/.txt/.rst)
|
|
267
|
+
gns feed https://site.com/post --domain dev # one web page (HTML β text)
|
|
268
|
+
gns feed https://docs.x.io --crawl --depth 1 --max 20 --domain dev # a small doc site
|
|
269
|
+
gns feed --text "SEO: titles drive CTR" --domain seo # a raw paste
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
**Which source should I use?**
|
|
273
|
+
|
|
274
|
+
| Source | Best for | Notes |
|
|
275
|
+
|---|---|---|
|
|
276
|
+
| **`.md` / `.txt` files** β
| curated knowledge you control | highest signal β chunked by heading/paragraph. Feed a whole folder at once. |
|
|
277
|
+
| **A single URL** | one research page / article | static HTML only (no JS rendering); tags stripped to text. |
|
|
278
|
+
| **`--crawl`** | a small doc site | follows **same-host** links up to `--depth`/`--max`, one request at a time. |
|
|
279
|
+
| **`--text`** | a quick paste | no file needed. |
|
|
280
|
+
|
|
281
|
+
> Chunks are matched by shared **words** by default. Install `gnosion[embed]` +
|
|
282
|
+
> `GNOSION_SEMANTIC=1` for **semantic** recall (paraphrases match). This is how a domain
|
|
283
|
+
> like *marketing*, *SEO*, *DevOps*, or *PyTorch recipes* becomes a first-class part of
|
|
284
|
+
> the brain.
|
|
285
|
+
|
|
286
|
+
## Map anything into a knowledge graph (`gns mapping`)
|
|
287
|
+
|
|
288
|
+
`gns mapping` turns a directory β a codebase, a docs folder, *any* tree of files β into a
|
|
289
|
+
real **knowledge graph the brain stores and traverses**, so you can ask *"what connects X
|
|
290
|
+
to Y?"* instead of grepping. (Inspired by [Graphify](https://github.com/Graphify-Labs/graphify),
|
|
291
|
+
kept pure-Python, zero-dep, and general.)
|
|
292
|
+
|
|
293
|
+
```bash
|
|
294
|
+
gns mapping . # build / refresh the map for a directory
|
|
295
|
+
gns mapping query "auth database" # a scoped subgraph around matching nodes
|
|
296
|
+
gns mapping path "login" "DatabasePool" # shortest path between two things
|
|
297
|
+
gns mapping explain "UserService" # a node + everything it connects to
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
**The model β a graph you traverse, not embeddings:**
|
|
301
|
+
|
|
302
|
+
| | Kinds |
|
|
303
|
+
|---|---|
|
|
304
|
+
| **Nodes** | `dir` Β· `file` Β· `function` Β· `class` Β· `module` Β· `route` Β· `concept` (doc headings) |
|
|
305
|
+
| **Edges** | `contains` Β· `defines` Β· `imports` Β· `inherits` Β· `calls` Β· `references` |
|
|
306
|
+
|
|
307
|
+
Each edge is tagged `EXTRACTED` (explicit in source) or `INFERRED` (resolved by analysis).
|
|
308
|
+
Python is parsed with `ast` (functions, classes, methods, imports, calls, inheritance,
|
|
309
|
+
routes); JS/TS via light regex; Markdown headings become `concept` nodes and `[[wikilinks]]`
|
|
310
|
+
become `references`. The graph persists to `.gnosion/graph.json` (reusable, no re-parsing),
|
|
311
|
+
and file/symbol notes also land in the brain's `structure` memory so `gns ask` still works.
|
|
312
|
+
|
|
313
|
+
```text
|
|
314
|
+
$ gns mapping path "login" "DatabasePool"
|
|
315
|
+
{ "from": "login_route", "to": "DatabasePool",
|
|
316
|
+
"path": ["login_route", "UserService.login", "DatabasePool"], "hops": 2 }
|
|
317
|
+
```
|
|
318
|
+
|
|
319
|
+
Because it's general, the *same* command maps a docs vault or a mixed folder β you get a
|
|
320
|
+
graph of concepts and references, not just code.
|
|
321
|
+
|
|
322
|
+
## Hand a project to a coding agent (`gns handoff`)
|
|
323
|
+
|
|
324
|
+
```bash
|
|
325
|
+
gns handoff -o PROJECT.md # ONE markdown: stack + file tree + per-file defs/routes/imports + memory briefing
|
|
326
|
+
gns handoff --as-claude # write it as ./CLAUDE.md
|
|
327
|
+
gns handoff --as-agents # write it as ./AGENTS.md
|
|
328
|
+
```
|
|
329
|
+
|
|
330
|
+
`handoff` turns the map β plus what the brain has learned about the project β into **one
|
|
331
|
+
file a coding agent reads instead of crawling every source file**, saving tokens.
|
|
332
|
+
|
|
333
|
+
Two ways to plug it into an agent:
|
|
334
|
+
|
|
335
|
+
```mermaid
|
|
336
|
+
flowchart LR
|
|
337
|
+
P["your project"] -->|gns mapping| B[(".gnosion<br/>graph.json")]
|
|
338
|
+
B -->|gns handoff| MD["PROJECT.md / CLAUDE.md<br/><i>one-shot cheap context</i>"]
|
|
339
|
+
B -->|gns mcp| MCP["MCP server<br/><i>live recall + traversal</i>"]
|
|
340
|
+
MD --> A["Claude Β· Codex Β· Cursor"]
|
|
341
|
+
MCP --> A
|
|
342
|
+
```
|
|
343
|
+
|
|
344
|
+
- **Static** β `gns handoff` β a single `.md` the agent loads once (cheap, offline).
|
|
345
|
+
- **Live** β the MCP server *is* the pluggable install: `claude mcp add gnosion -- gns mcp`;
|
|
346
|
+
the agent then calls `recall` / `briefing` on demand across every session.
|
|
347
|
+
|
|
348
|
+
## Use cases
|
|
349
|
+
|
|
350
|
+
One brain, many jobs β it is deliberately **universal**:
|
|
351
|
+
|
|
352
|
+
- **Give a product its own brain** β classify images/text on-device ($0, offline),
|
|
353
|
+
learning from user confirmations; ship the trained brain as one file.
|
|
354
|
+
- **A domain-expert brain** β `gns feed` marketing, SEO, DevOps, legal, or product docs
|
|
355
|
+
into named domains; the brain becomes a queryable expert you can commit and share.
|
|
356
|
+
- **Coding-agent context** β `mapping` + `handoff` hand any agent a whole project in one
|
|
357
|
+
file (or a traversable graph); MCP gives it live recall. Less token burn, less drift.
|
|
358
|
+
- **Agent memory across sessions & tools** β capture decisions/conventions/bug-fixes
|
|
359
|
+
once; every future agent session recalls them.
|
|
360
|
+
- **An ML side-brain / pipeline component** β use it inside a PyTorch or vision pipeline
|
|
361
|
+
as a fast nearest-centroid classifier or a k-NN memory cache: log good predictions,
|
|
362
|
+
recall them next time, or bootstrap labels before a heavy model is trained. Swap in
|
|
363
|
+
your own embedder (`.embed(x) -> vector`) and it rides on your existing features.
|
|
364
|
+
- **A learning layer over LLMs** β remember the good answers an LLM gave; serve them
|
|
365
|
+
locally next time (faster, cheaper, consistent).
|
|
366
|
+
- **Edge / CPU classification** β vision/text/tabular classifiers, no GPU, no framework.
|
|
367
|
+
|
|
368
|
+
## Flexibility
|
|
369
|
+
|
|
370
|
+
- **Custom domains:** `bx.add_domain(name, head="classifier"|"memory", modality="text"|"image"|"vector")`.
|
|
371
|
+
- **Custom embedder:** any object with `.embed(x) -> list[float]` and a stable `.dim`
|
|
372
|
+
β plug in your own model, or `pip install "gnosion[embed]"` for fastembed.
|
|
373
|
+
- **Custom heads:** `ClassifierHead` / `MemoryHead` are plain classes with
|
|
374
|
+
`to_dict()`/`from_dict()`; extend them and register in `HEAD_TYPES`.
|
|
375
|
+
- **Portable format:** the `.gnosion` is a zip (`manifest.json` + gzipped brain) β you
|
|
376
|
+
can inspect, diff, or generate it yourself.
|
|
377
|
+
|
|
378
|
+
## How it learns (and won't get worse)
|
|
379
|
+
|
|
380
|
+
- **Classifier heads** keep every labelled example and fit a per-label centroid over
|
|
381
|
+
embeddings. `train()` carves a **stable golden holdout**, scores a challenger, and
|
|
382
|
+
**only promotes it if it doesn't regress** β champion/challenger.
|
|
383
|
+
- **Memory heads** store `(embedding β value)` and answer by nearest-neighbour cosine
|
|
384
|
+
above a confidence threshold β so paraphrases recall the right value and unrelated
|
|
385
|
+
queries recall *nothing* (no confident-but-wrong answers).
|
|
386
|
+
|
|
387
|
+
## API at a glance
|
|
388
|
+
|
|
389
|
+
```python
|
|
390
|
+
Gnosion(dim=256, prefer_fastembed=False, domains=None)
|
|
391
|
+
.learn(domain, x, label=None, value=None) .remember(domain, cue, value) .absorb(domain, q, a)
|
|
392
|
+
.train(domain=None) .predict(domain, x) .recall(domain, q, min_sim=None) .search(domain, q, k=5)
|
|
393
|
+
.add_domain(name, head, modality) .stats() .export(path) Gnosion.load(path)
|
|
394
|
+
```
|
|
395
|
+
|
|
396
|
+
## CLI reference
|
|
397
|
+
|
|
398
|
+
```bash
|
|
399
|
+
gns note|ask|brief|mem # universal repo memory (./.gnosion/project.gnosion)
|
|
400
|
+
gns observe|experience|skill|skills # episodic / procedural memory
|
|
401
|
+
gns feed <file|dir|url> --domain X # teach new knowledge (--text, --crawl, --depth, --max)
|
|
402
|
+
gns mapping [path] # build a knowledge graph of a directory
|
|
403
|
+
gns mapping query|path|explain ... # traverse it instead of grepping
|
|
404
|
+
gns handoff [--as-claude|--as-agents|-o F.md] # export a single project map for coding agents
|
|
405
|
+
gns ui [file.gnosion] [--port N] # πΈοΈ interactive dashboard (local, 0-dep)
|
|
406
|
+
gns mcp # run the MCP server (stdio) for agents
|
|
407
|
+
gns learn|train|predict|recall <file.gnosion> <domain> <text> [--label/--value]
|
|
408
|
+
gns inspect|stats <file.gnosion> # peek / full stats
|
|
409
|
+
```
|
|
410
|
+
|
|
411
|
+
## Expand & scale it bigger
|
|
412
|
+
|
|
413
|
+
Gnosion is small on purpose, so growth is just composition:
|
|
414
|
+
|
|
415
|
+
- **More brainpower per domain** β install `gnosion[embed]` for semantic embeddings and
|
|
416
|
+
`gnosion[ml]` for calibrated logistic-regression classifiers. Zero code changes; the
|
|
417
|
+
`.gnosion` stays plain JSON (models are re-fit from stored samples, never pickled).
|
|
418
|
+
- **More domains** β `bx.add_domain(name, head, modality)` or just `gns feed --domain new`.
|
|
419
|
+
Every domain is independent, so the brain scales sideways without retraining others.
|
|
420
|
+
- **Bigger embedder** β point a domain at any model exposing `.embed(x) -> list[float]`
|
|
421
|
+
and a stable `.dim` (OpenAI embeddings, your own CLIP, a fine-tuned encoder). The graph,
|
|
422
|
+
recall, and champion/challenger guard all keep working.
|
|
423
|
+
- **Many brains, one mind** β keep a per-repo `.gnosion` (committed) and let the
|
|
424
|
+
`~/.gnosion` registry aggregate them; `gns ui` shows all projects and lets you switch.
|
|
425
|
+
- **Custom heads** β subclass `ClassifierHead` / `MemoryHead` (they're plain
|
|
426
|
+
`to_dict()`/`from_dict()` classes) and register in `HEAD_TYPES` for new learning rules.
|
|
427
|
+
- **Sharding** β split by domain into separate `.gnosion` files and load the one you need;
|
|
428
|
+
each file is a self-contained zip you can diff, cache, or generate.
|
|
429
|
+
|
|
430
|
+
## What Gnosion is β and isn't
|
|
431
|
+
|
|
432
|
+
It **is** a practical, portable, always-improving memory + classifier you can embed
|
|
433
|
+
anywhere. It **is not** a replacement for a large language model, and importing a
|
|
434
|
+
`.gnosion` will not magically make an LLM bug-free β it *augments* by remembering what
|
|
435
|
+
worked and classifying what it has seen, so systems drift less and repeat fewer
|
|
436
|
+
mistakes.
|
|
437
|
+
|
|
438
|
+
## Learn more
|
|
439
|
+
|
|
440
|
+
- **[`USAGE.md`](USAGE.md)** β a full how-to: install β app brain β project memory β
|
|
441
|
+
coding agents (MCP) β AI agents β embedding in a system β Node/JS β sharing a brain.
|
|
442
|
+
- **[`PUBLISHING.md`](PUBLISHING.md)** β the exact GitHub / PyPI / npm steps.
|
|
443
|
+
|
|
444
|
+
MIT Β© Crave Asia / IPG
|