@laurindustries/mnemos 0.0.0-stage → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +21 -0
- package/LICENSE +21 -0
- package/README.md +78 -2
- package/docs/README.md +33 -0
- package/docs/assets/mnemos-readme.svg +13 -0
- package/docs/assets/mnemos-social-preview.png +0 -0
- package/docs/branding.md +19 -0
- package/docs/cli.md +144 -0
- package/docs/development.md +29 -0
- package/docs/getting-started.md +127 -0
- package/docs/mcp.md +105 -0
- package/docs/ontology.md +233 -0
- package/docs/operations.md +130 -0
- package/docs/refresh.md +79 -0
- package/docs/release.md +68 -0
- package/docs/relocation.md +22 -0
- package/examples/ontology.extended.yaml +64 -0
- package/package.json +91 -4
- package/scripts/check-docs.mjs +23 -0
- package/scripts/cli.mjs +9 -0
- package/scripts/mcp.mjs +3 -0
- package/scripts/package-smoke-worker.mjs +63 -0
- package/scripts/package-smoke.mjs +49 -0
- package/scripts/refresh.config.example.json +8 -0
- package/scripts/refresh.mjs +10 -0
- package/src/api.ts +39 -0
- package/src/cli.ts +111 -0
- package/src/config.ts +124 -0
- package/src/core-bootstrap.mjs +3 -0
- package/src/explorer.ts +106 -0
- package/src/index.ts +88 -0
- package/src/legacy-v5.json +22 -0
- package/src/mcp.ts +31 -0
- package/src/ontology-editor.ts +115 -0
- package/src/ontology.ts +50 -0
- package/src/ontology.yaml +60 -0
- package/src/opencode-bootstrap.mjs +2 -0
- package/src/opencode.ts +28 -0
- package/src/paths.ts +8 -0
- package/src/refresh/cli.ts +121 -0
- package/src/refresh/inventory.ts +259 -0
- package/src/refresh/refresh.ts +112 -0
- package/src/service-bootstrap.mjs +11 -0
- package/src/service-protocol.ts +94 -0
- package/src/service.ts +138 -0
- package/src/shared-store.ts +125 -0
- package/src/store.ts +385 -0
- package/src/tool-contract.ts +45 -0
- package/src/web/app.js +241 -0
- package/src/web/index.html +56 -0
- package/src/web/mnemos-icon-32.png +0 -0
- package/src/web/mnemos-icon.svg +9 -0
- package/src/web/mnemos-logo.svg +10 -0
- package/src/web/style.css +57 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## [0.2.0]
|
|
4
|
+
|
|
5
|
+
- Mnemos branding, packaged explorer icons, and the `@laurindustries/mnemos`
|
|
6
|
+
npm name. CLI commands, `/kg`, tool names, and database locations are unchanged.
|
|
7
|
+
- Standalone shared LadybugDB package with CLI, native Pi and OpenCode 2 adapters,
|
|
8
|
+
and stdio MCP, sharing validation and one Node daemon per database.
|
|
9
|
+
- YAML ontology, custom scalar attributes, directed endpoint constraints,
|
|
10
|
+
additive compatibility checks, and conditional refresh ownership/pruning.
|
|
11
|
+
- Shared ontology edit tool for Pi, OpenCode, and MCP. Its prompt restricts it
|
|
12
|
+
to explicit user requests; it validates replacement YAML before writing and
|
|
13
|
+
does not activate the change automatically.
|
|
14
|
+
- Read-only local graph explorer with packaged assets; disabled unless
|
|
15
|
+
`PI_KNOWLEDGE_GRAPH_EXPLORER=1`. Stop and restart any older owner on upgrade.
|
|
16
|
+
- Install-first portable README and organized CLI, ontology, operations, refresh,
|
|
17
|
+
development, relocation and release documentation.
|
|
18
|
+
- MIT license, package metadata cleanup, and repeatable production-tarball smoke
|
|
19
|
+
validation without Pi or development dependencies.
|
|
20
|
+
|
|
21
|
+
See the [maintainer release checklist](docs/release.md) for packaging and compatibility checks.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Mnemos 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.
|
package/README.md
CHANGED
|
@@ -1,3 +1,79 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Mnemos
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+

|
|
4
|
+
|
|
5
|
+
**Shared memory for coding agents.** Give a fresh Pi, OpenCode, or MCP session
|
|
6
|
+
access to the durable facts another session recorded, without replaying the old
|
|
7
|
+
chat or pasting the same context again.
|
|
8
|
+
|
|
9
|
+
Mnemos stores named things, the relationships between them, and references to
|
|
10
|
+
their sources in a local knowledge graph. Start with projects, repositories,
|
|
11
|
+
and environments. Add your own types in YAML when your work needs them.
|
|
12
|
+
|
|
13
|
+
[Get started](docs/getting-started.md) · [Read the docs](docs/README.md) · [Report an issue](https://github.com/LaurIndustries/mnemos/issues)
|
|
14
|
+
|
|
15
|
+
## Try a handoff
|
|
16
|
+
|
|
17
|
+
In one connected agent session, ask:
|
|
18
|
+
|
|
19
|
+
> In Mnemos, record that the Payments project includes the `payments-api`
|
|
20
|
+
> repository. Use `project:payments` and `repo:payments/api` as IDs and
|
|
21
|
+
> record `README.md` as the source for the relationship.
|
|
22
|
+
|
|
23
|
+
Open another session with the **same Mnemos database**, then ask:
|
|
24
|
+
|
|
25
|
+
> Which repositories belong to `project:payments`? Include the source of each
|
|
26
|
+
> relationship you find in Mnemos.
|
|
27
|
+
|
|
28
|
+
The new session can read the saved relationship and its source reference. It
|
|
29
|
+
still needs to check that reference before relying on a stale or high-impact
|
|
30
|
+
claim. No model or agent required for the [terminal walkthrough](docs/getting-started.md#try-it-from-the-terminal).
|
|
31
|
+
|
|
32
|
+
## What you can do
|
|
33
|
+
|
|
34
|
+
| Need | Use Mnemos to… |
|
|
35
|
+
| --- | --- |
|
|
36
|
+
| Pick up where another session stopped | Save and retrieve durable project context across compatible clients. |
|
|
37
|
+
| Explain how things connect | Follow directed relationships, such as a Terragrunt repo calling a module or a repo targeting an environment. |
|
|
38
|
+
| Check where a fact came from | Attach a file path, URL, or other source reference to an entity or relationship. |
|
|
39
|
+
| Fit the graph to your work | Define your own types, attributes, and allowed relationships in [YAML](docs/ontology.md). |
|
|
40
|
+
| See the bigger picture | Open the optional [read-only explorer](docs/operations.md#graph-explorer) to follow links and inspect evidence. |
|
|
41
|
+
|
|
42
|
+
## Get started
|
|
43
|
+
|
|
44
|
+
Use **Node 22.19.0+** and keep optional npm dependencies enabled; they supply
|
|
45
|
+
the native database binary. Linux x64 is the automated release target.
|
|
46
|
+
|
|
47
|
+
For the terminal commands, install from npm:
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
npm install -g @laurindustries/mnemos@0.2.0
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Pi, OpenCode, and [MCP clients](docs/mcp.md) can launch Mnemos without a global
|
|
54
|
+
npm install.
|
|
55
|
+
|
|
56
|
+
| Using | Start here |
|
|
57
|
+
| --- | --- |
|
|
58
|
+
| Pi | [Install the Pi extension](docs/getting-started.md#connect-pi) |
|
|
59
|
+
| OpenCode 2 | [Load the native plugin](docs/getting-started.md#connect-opencode-2) |
|
|
60
|
+
| An MCP client | [Install the local MCP server](docs/mcp.md) |
|
|
61
|
+
| A terminal | [Create and query a scratch graph](docs/getting-started.md#try-it-from-the-terminal) |
|
|
62
|
+
|
|
63
|
+
## Know what you’re storing
|
|
64
|
+
|
|
65
|
+
- **Facts, not transcripts.** Mnemos does not automatically index chats or code.
|
|
66
|
+
A stored source reference is not independently verified. Search matches text
|
|
67
|
+
and filters; it isn’t semantic or vector search.
|
|
68
|
+
- **Local, not cloud-synced.** Clients on the same machine share a graph when
|
|
69
|
+
pointed at the same database. No external database server is required.
|
|
70
|
+
- **Persistent by design.** Reloading or forking a chat does not undo graph
|
|
71
|
+
writes. Deletion is permanent; keep [backups](docs/operations.md#back-up-and-restore)
|
|
72
|
+
and don’t store secrets. When enabled, the explorer is readable by other local
|
|
73
|
+
users.
|
|
74
|
+
- **Schema edits are separate from fact writes.** `mnemos_edit_ontology` is for
|
|
75
|
+
[explicitly requested edits](docs/ontology.md#edit-on-explicit-request).
|
|
76
|
+
This is a tool instruction, not access control: a valid edit writes without
|
|
77
|
+
a confirmation dialog.
|
|
78
|
+
|
|
79
|
+
[CLI and tools](docs/cli.md) · [Refresh infrastructure facts](docs/refresh.md) · [Release checks](docs/release.md) · [Changelog](CHANGELOG.md) · [MIT license](LICENSE)
|
package/docs/README.md
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# Mnemos documentation
|
|
2
|
+
|
|
3
|
+
Mnemos gives coding agents a shared, local place to keep facts worth remembering.
|
|
4
|
+
A graph answer can tell you how things connect and where the claim came from;
|
|
5
|
+
it is not proof that the claim is still true.
|
|
6
|
+
|
|
7
|
+
## Start using Mnemos
|
|
8
|
+
|
|
9
|
+
| I want to… | Go to |
|
|
10
|
+
| --- | --- |
|
|
11
|
+
| Try the graph without a model or agent | [Create and query a demo graph](getting-started.md#try-it-from-the-terminal) |
|
|
12
|
+
| Connect a coding agent | [Pi](getting-started.md#connect-pi) · [OpenCode 2](getting-started.md#connect-opencode-2) · [MCP setup](mcp.md) |
|
|
13
|
+
| Find the arguments for a command or tool | [CLI and tool reference](cli.md) |
|
|
14
|
+
| See the graph in a browser | [Enable the local explorer](operations.md#graph-explorer) |
|
|
15
|
+
|
|
16
|
+
## Make it yours
|
|
17
|
+
|
|
18
|
+
| I want to… | Go to |
|
|
19
|
+
| --- | --- |
|
|
20
|
+
| Understand what the graph can store | [The ontology and built-in types](ontology.md) |
|
|
21
|
+
| Ask an agent to extend the schema | [Edit the ontology on explicit request](ontology.md#edit-on-explicit-request) |
|
|
22
|
+
| Preview import from local infrastructure configuration | [Refresh infrastructure facts](refresh.md) |
|
|
23
|
+
| Give two projects separate memory | [Choose a database path](operations.md#storage) |
|
|
24
|
+
| Protect my graph or move it safely | [Back up and restore](operations.md#back-up-and-restore) |
|
|
25
|
+
|
|
26
|
+
## Build and maintain Mnemos
|
|
27
|
+
|
|
28
|
+
- [Development](development.md): source layout, checks, and browser tests.
|
|
29
|
+
- [Release checks](release.md): packaging, compatibility, and host verification.
|
|
30
|
+
- [Switch Pi loaders](relocation.md): migrate an earlier installation without loading twice.
|
|
31
|
+
- [Brand assets](branding.md): use the wordmark, app icon, and GitHub preview.
|
|
32
|
+
|
|
33
|
+
[Back to Mnemos](../README.md) · [Changelog](../CHANGELOG.md)
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1540 480" role="img" aria-label="Mnemos">
|
|
2
|
+
<rect x="2" y="2" width="1536" height="476" rx="52" fill="#111720" stroke="#465164" stroke-width="4"/>
|
|
3
|
+
<svg x="60" y="65" width="1420" height="350" viewBox="0 0 1420 350" aria-hidden="true">
|
|
4
|
+
<defs><linearGradient id="metal" x2="0.8" y2="1"><stop stop-color="#faf9f5"/><stop offset="1" stop-color="#c6c7c8"/></linearGradient><linearGradient id="dark" x2="1" y2="1"><stop stop-color="#202327"/><stop offset="1" stop-color="#0c0e10"/></linearGradient></defs>
|
|
5
|
+
<path d="M80 20H268L322 74V268L268 322H58L10 274V86Z" fill="url(#dark)" stroke="url(#metal)" stroke-width="15" stroke-linejoin="miter"/>
|
|
6
|
+
<path d="M88 46H192L35 205V100Z" fill="#fff" opacity=".045"/>
|
|
7
|
+
<path d="M211 314L282 244H311L241 314Z" fill="#00cce9"/>
|
|
8
|
+
<g stroke="#f5f4ef" stroke-width="10" fill="none"><path d="M179 175L82 155M179 175L238 84M179 175L264 207M179 175L90 261"/></g>
|
|
9
|
+
<g fill="#101215" stroke="#f5f4ef" stroke-width="11"><circle cx="82" cy="155" r="21"/><circle cx="238" cy="84" r="22"/><circle cx="264" cy="207" r="21"/><circle cx="90" cy="261" r="21"/><circle cx="179" cy="175" r="30"/></g>
|
|
10
|
+
<g fill="#00cce9"><circle cx="82" cy="155" r="9"/><circle cx="238" cy="84" r="9"/><circle cx="264" cy="207" r="9"/><circle cx="90" cy="261" r="9"/><circle cx="179" cy="175" r="16"/></g>
|
|
11
|
+
<g fill="#f5f4ef" transform="translate(385 105)"><path d="M0 0H20L80 72L140 0H160V126H135V43L80 108L25 43V126H0Z"/><path d="M184 0H205L298 87V0H323V126H301L209 39V126H184Z"/><path d="M350 0H473V24H375V50H462V74H375V102H473V126H350Z"/><path d="M496 0H516L576 72L636 0H656V126H631V43L576 108L521 43V126H496Z"/><path fill-rule="evenodd" d="M718 0H790Q823 0 823 33V93Q823 126 790 126H718Q680 126 680 93V33Q680 0 718 0ZM718 24Q705 24 705 38V88Q705 102 718 102H785Q798 102 798 88V38Q798 24 785 24Z"/><path d="M967 0H881Q843 0 843 37Q843 74 881 74H929Q944 74 944 88Q944 102 929 102H845V126H930Q969 126 969 88Q969 50 930 50H881Q868 50 868 37Q868 24 881 24H943Z"/><path d="M943 0H997L973 24H919Z" fill="#00cce9"/></g>
|
|
12
|
+
</svg>
|
|
13
|
+
</svg>
|
|
Binary file
|
package/docs/branding.md
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Mnemos brand assets
|
|
2
|
+
|
|
3
|
+
Use **Mnemos** in prose and `@laurindustries/mnemos` as the npm package name.
|
|
4
|
+
The supplied wordmark spells **MNEMOS**; keep its original geometry and proportions.
|
|
5
|
+
|
|
6
|
+
| Asset | Use |
|
|
7
|
+
| --- | --- |
|
|
8
|
+
| [Color wordmark](../src/web/mnemos-logo.svg) | Explorer header or other dark backgrounds |
|
|
9
|
+
| [SVG app mark](../src/web/mnemos-icon.svg) | Scalable favicon or compact brand placement |
|
|
10
|
+
| [32 px PNG app mark](../src/web/mnemos-icon-32.png) | Favicon fallback when SVG is unavailable |
|
|
11
|
+
| [README banner](assets/mnemos-readme.svg) | Wordmark on a fixed dark panel for both GitHub themes |
|
|
12
|
+
| [GitHub social preview](assets/mnemos-social-preview.png) | 1280 × 640 PNG for repository link previews |
|
|
13
|
+
|
|
14
|
+
To set the link preview on GitHub, open **Settings → Social preview → Edit**
|
|
15
|
+
and upload the PNG. GitHub does not provide a separate repository avatar.
|
|
16
|
+
|
|
17
|
+
The explorer serves its icons locally with the rest of its assets. The desktop
|
|
18
|
+
ICO and ICNS variants and extra raster sizes from the supplied archive are not
|
|
19
|
+
needed by the CLI, adapters, or browser UI and are not shipped.
|
package/docs/cli.md
ADDED
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
# CLI and tool reference
|
|
2
|
+
|
|
3
|
+
Use `knowledge_graph` in agent sessions or `knowledge-graph` in a terminal to
|
|
4
|
+
query and change graph facts. Use `mnemos_edit_ontology` only when the user
|
|
5
|
+
asks to change the YAML schema itself. Facts and schema are separate. To
|
|
6
|
+
connect either tool over stdio, see the [MCP install guide](mcp.md).
|
|
7
|
+
|
|
8
|
+
## Command-line usage
|
|
9
|
+
|
|
10
|
+
Use `knowledge-graph` after installing the package. In a checkout, replace it
|
|
11
|
+
with `node scripts/cli.mjs` or run `npm run cli -- <arguments>`. To try these
|
|
12
|
+
operations without touching your default database, use the
|
|
13
|
+
[scratch graph walkthrough](getting-started.md#try-it-from-the-terminal).
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
knowledge-graph --help
|
|
17
|
+
knowledge-graph schema --human
|
|
18
|
+
knowledge-graph upsert-entity project:demo --entity-type Project --name Demo
|
|
19
|
+
knowledge-graph upsert-entity repo:demo --entity-type Repo --name Demo --kind generic
|
|
20
|
+
knowledge-graph upsert-edge --from project:demo --to repo:demo --edge-type HAS_REPO
|
|
21
|
+
knowledge-graph neighbors project:demo --direction out
|
|
22
|
+
knowledge-graph search --filters '{"kind":"generic"}' --limit 20
|
|
23
|
+
knowledge-graph request --input '{"action":"get","id":"project:demo"}'
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
With the exception of `schema`, the data commands above use or start the shared
|
|
27
|
+
owner. Use `--db FILE` and `--ontology FILE` to override the corresponding
|
|
28
|
+
[environment settings](operations.md#shared-configuration-and-coexistence)
|
|
29
|
+
before the CLI loads the ontology. `--help` works without valid settings or an
|
|
30
|
+
ontology; `schema` validates the configured ontology without opening storage.
|
|
31
|
+
|
|
32
|
+
### Flags and JSON input
|
|
33
|
+
|
|
34
|
+
- Command names and field flags use hyphens. JSON uses the action and field
|
|
35
|
+
names in the table below. For example, `--entity-type` maps to `entity_type`,
|
|
36
|
+
`--edge-type` to `edge_type`, `--local-path` to `localPath`, and `--gitlab-url`
|
|
37
|
+
to `gitlabUrl`. `--flag=value` is supported.
|
|
38
|
+
- `get`, `neighbors`, `upsert-entity`, and `delete-entity` accept one positional
|
|
39
|
+
ID or `--id`. Other fields include `--name`, `--from`, `--to`, `--query`,
|
|
40
|
+
`--limit`, `--direction`, `--kind`, `--stage`, `--description`, and `--source`.
|
|
41
|
+
Pass custom values via `--attributes '{"replicas":3,"enabled":true}'` or
|
|
42
|
+
query them with `--filters JSON`, based on the configured ontology.
|
|
43
|
+
- `request` with no input flag, `request --input -`, and `--input -` read one
|
|
44
|
+
JSON request from stdin. `--input JSON` also works without a command. If you
|
|
45
|
+
also name a command, its action must match the JSON. Don't mix raw JSON with
|
|
46
|
+
positional IDs or field flags.
|
|
47
|
+
|
|
48
|
+
### Output and exit status
|
|
49
|
+
|
|
50
|
+
Successful results are JSON on stdout (`--json` is optional). `schema --human`
|
|
51
|
+
prints readable text instead. Errors are JSON of the form `{"error":"…"}` on
|
|
52
|
+
stderr with empty stdout. CLI JSON is not subject to the agent tool's output cap.
|
|
53
|
+
|
|
54
|
+
| Exit | Meaning |
|
|
55
|
+
| --- | --- |
|
|
56
|
+
| `0` | Success |
|
|
57
|
+
| `2` | Usage or input error |
|
|
58
|
+
| `1` | Configuration or store error, including graph constraints |
|
|
59
|
+
| `130` / `143` | Interrupted by `SIGINT` / `SIGTERM` |
|
|
60
|
+
|
|
61
|
+
Commands do not ask for confirmation or retry mutations. Closing the CLI does
|
|
62
|
+
not stop the detached graph owner. Cancellation does not undo a committed write.
|
|
63
|
+
|
|
64
|
+
## Tool: `knowledge_graph`
|
|
65
|
+
|
|
66
|
+
Read and write facts using the selected [ontology](ontology.md). The table uses
|
|
67
|
+
the built-in model; call `schema` to see the actual per-type rules. Configured
|
|
68
|
+
custom scalar values go in `attributes` for writes and `filters` for exact
|
|
69
|
+
search matches.
|
|
70
|
+
|
|
71
|
+
| Action | Required fields | Common optional fields |
|
|
72
|
+
| --- | --- | --- |
|
|
73
|
+
| `schema` | — | — |
|
|
74
|
+
| `get` | `id` | — |
|
|
75
|
+
| `search` | — | `query`, `entity_type`, `kind`, `stage`, `filters`, `limit` |
|
|
76
|
+
| `neighbors` | `id` | `direction` (`in`, `out`, `both`), `edge_type`, `limit` |
|
|
77
|
+
| `upsert_entity` | `id`, `entity_type`, `name`; `kind` for a new Repo | `description`, `source`, `attributes`; Repo: `localPath`, `gitlabUrl`; Environment: `stage` |
|
|
78
|
+
| `upsert_edge` | `from`, `to`, `edge_type` | `description`, `source`, `attributes` |
|
|
79
|
+
| `delete_edge` | `from`, `to`, `edge_type` | — |
|
|
80
|
+
| `delete_entity` | `id` | — |
|
|
81
|
+
|
|
82
|
+
### Record a relationship with evidence
|
|
83
|
+
|
|
84
|
+
Create both endpoints before linking them. For example, a Terragrunt repo can
|
|
85
|
+
point to a Terraform module repo using `CALLS`:
|
|
86
|
+
|
|
87
|
+
```json
|
|
88
|
+
{"action":"upsert_entity","id":"repo:payments/live","entity_type":"Repo","name":"Payments live","kind":"terragrunt"}
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
```json
|
|
92
|
+
{"action":"upsert_entity","id":"repo:modules/api","entity_type":"Repo","name":"API module","kind":"terraform-module"}
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
```json
|
|
96
|
+
{"action":"upsert_edge","from":"repo:payments/live","to":"repo:modules/api","edge_type":"CALLS","source":"terragrunt.hcl:12"}
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
Reuse stable IDs to update rather than duplicate facts. Omitted `description`
|
|
100
|
+
and `source` are preserved; an empty string clears them. A source is a reference
|
|
101
|
+
for the reader to check, not an independently verified claim.
|
|
102
|
+
|
|
103
|
+
### Query a relationship in the right direction
|
|
104
|
+
|
|
105
|
+
This asks which repositories target a known environment. Use `direction: "in"`
|
|
106
|
+
because a `TARGETS` edge points *from* a repository *to* an environment:
|
|
107
|
+
|
|
108
|
+
```json
|
|
109
|
+
{"action":"neighbors","id":"environment:payments:prod","edge_type":"TARGETS","direction":"in"}
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
Use the same pattern with `IN_ENVIRONMENT` to find associated Kubernetes
|
|
113
|
+
contexts and Azure subscriptions. The `stage` filter only matches environments;
|
|
114
|
+
it does not find the repositories that point to them. `schema` returns named
|
|
115
|
+
`entities`, `relationships` with explicit endpoints, and `shared_attributes`.
|
|
116
|
+
For `IN_ENVIRONMENT`, the source endpoint lists both allowed types in an array.
|
|
117
|
+
|
|
118
|
+
### Limits and destructive operations
|
|
119
|
+
|
|
120
|
+
Search is case-insensitive substring matching on string attributes such as ID,
|
|
121
|
+
name, description, checkout path, and GitLab URL. It is not vector search or
|
|
122
|
+
full-text ranking. Omit `query` to list matching entities. Search and neighbors
|
|
123
|
+
default to 20 results and cap at 100, with no pagination cursor. Agent graph
|
|
124
|
+
results are capped at 40 KiB/1,500 lines and marked when clipped. Narrow the
|
|
125
|
+
query or use CLI JSON for complete results within the action's limit.
|
|
126
|
+
|
|
127
|
+
Deletes are permanent. Deleting an entity also deletes incident edges. Missing
|
|
128
|
+
entity IDs are errors; deleting an absent edge between existing compatible
|
|
129
|
+
endpoints returns `deleted: 0`.
|
|
130
|
+
|
|
131
|
+
## Tool: `mnemos_edit_ontology`
|
|
132
|
+
|
|
133
|
+
Available in Pi, OpenCode, and MCP. The tool instructs agents to use it only
|
|
134
|
+
when the user explicitly asks to edit ontology YAML, not to add a graph fact.
|
|
135
|
+
This is a prompt rule, not access control: valid edits apply without a dialog.
|
|
136
|
+
|
|
137
|
+
| Action | Input | Result |
|
|
138
|
+
| --- | --- | --- |
|
|
139
|
+
| `inspect` | `{"action":"inspect"}` | Configured path, current YAML, and `base_sha256` |
|
|
140
|
+
| `apply` | `action: "apply"`, the `base_sha256` from `inspect`, and complete replacement `yaml` | Whether the file was replaced; leaves the database and owner unchanged |
|
|
141
|
+
|
|
142
|
+
The target is the configured, user-owned YAML file. The tool rejects stale or
|
|
143
|
+
incompatible edits and cannot edit the packaged default. Follow the
|
|
144
|
+
[ontology editing and activation guide](ontology.md#edit-on-explicit-request).
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# Development
|
|
2
|
+
|
|
3
|
+
Runtime bootstraps use shipped jiti to resolve TypeScript and `.js` source imports.
|
|
4
|
+
`npm run build` and `npm run typecheck` both run `tsc --noEmit`; there is no dist
|
|
5
|
+
artifact. Validate those runtime exports with `npm run test:package`, not just
|
|
6
|
+
successful typechecking. `npm run validate:release` runs types, unit/integration,
|
|
7
|
+
docs and packaged smoke, without requiring browsers. Run browser tests separately.
|
|
8
|
+
See [release checklist](release.md) for external host/platform gates.
|
|
9
|
+
|
|
10
|
+
## Local checks
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
# Node 22.19.0 or later, with platform-native optional dependencies
|
|
14
|
+
npm ci --include=optional
|
|
15
|
+
npm run typecheck
|
|
16
|
+
npm test
|
|
17
|
+
|
|
18
|
+
# Optional real-browser tests (install Chromium once):
|
|
19
|
+
npx playwright install chromium
|
|
20
|
+
npm run test:browser
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
To use an existing compatible Chromium binary, set `PLAYWRIGHT_CHROMIUM_EXECUTABLE_PATH`. Browser tests check search, filtering, directed relationship navigation and evidence, schema, refresh, narrow layouts, safe data rendering, and absence of external network requests.
|
|
24
|
+
|
|
25
|
+
Ontology editor tests cover shared registration and execution in Pi, OpenCode
|
|
26
|
+
and MCP, the explicit-request instruction, stale or concurrent edits, invalid
|
|
27
|
+
YAML, protected files, and writes that leave the database and daemon untouched.
|
|
28
|
+
|
|
29
|
+
Integration tests include replacement ontologies without default labels, custom scalar attributes/enums/constraints, entity/edge CAS, additive compatibility, invalid YAML, daemon mismatches, and physical-schema rejection. Browser tests also cover custom labels, attributes, search and constraints. All graph tests use temporary databases. Integration tests cover persistence, all allowed edge pairs, invalid types, missing endpoints, directionality, idempotency, field preservation, deletion, parameter safety, concurrency, and cancellation. Shared-service tests race independent Node.js processes, verify a single owner and cross-session visibility, user-wide defaults, client-only shutdown, symlink identity, private API access, stale/crashed owner recovery, external-writer lock rejection, and explicitly configured test-only idle shutdown (production has no idle timeout). The ontology lives in `src/ontology.yaml`, validation/compatibility in `src/config.ts`, and derived schema helpers in `src/ontology.ts`; the Pi entry point is `src/index.ts`; native storage is in `src/store.ts`; the shared client and service are in `src/shared-store.ts` and `src/service.ts`.
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
# Get started with Mnemos
|
|
2
|
+
|
|
3
|
+
Save one fact, read it in another process, then connect the agent you already use.
|
|
4
|
+
|
|
5
|
+
## Install from npm
|
|
6
|
+
|
|
7
|
+
Mnemos needs **Node 22.19.0 or later**. Keep optional npm dependencies enabled;
|
|
8
|
+
they supply LadybugDB's native binaries. Automated release checks target Linux
|
|
9
|
+
x64. LadybugDB 0.22.3 also provides binaries for Linux arm64, macOS x64/arm64,
|
|
10
|
+
and Windows x64; full host support there has not been verified. End users don't
|
|
11
|
+
need to download a browser binary.
|
|
12
|
+
|
|
13
|
+
Install the CLI, refresh command, and stdio MCP server on your `PATH`:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm install -g @laurindustries/mnemos@0.2.0
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
For a project-local install, omit `-g` and run the CLI using
|
|
20
|
+
`npx --no-install knowledge-graph`. If you use only Pi or OpenCode, follow the
|
|
21
|
+
host instructions below instead of installing the command-line package globally.
|
|
22
|
+
|
|
23
|
+
## Try it from the terminal
|
|
24
|
+
|
|
25
|
+
This example uses the built-in ontology and creates a separate database. It
|
|
26
|
+
writes only fictional demo facts. Start in a fresh shell. The shell block
|
|
27
|
+
exports the database path so an agent launched from this terminal can find the
|
|
28
|
+
same facts.
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
demo=$(mktemp -d)
|
|
32
|
+
export PI_KNOWLEDGE_GRAPH_DB="$demo/graph.lbug"
|
|
33
|
+
unset PI_KNOWLEDGE_GRAPH_ONTOLOGY
|
|
34
|
+
export PI_KNOWLEDGE_GRAPH_PORT=0
|
|
35
|
+
export PI_KNOWLEDGE_GRAPH_EXPLORER=0
|
|
36
|
+
|
|
37
|
+
knowledge-graph schema --human
|
|
38
|
+
knowledge-graph upsert-entity project:payments --entity-type Project --name Payments
|
|
39
|
+
knowledge-graph upsert-entity repo:payments/api --entity-type Repo --name payments-api --kind generic
|
|
40
|
+
knowledge-graph upsert-edge --from project:payments --to repo:payments/api \
|
|
41
|
+
--edge-type HAS_REPO --source 'demo: project repository list'
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Now start a separate CLI process to read what the previous commands saved:
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
knowledge-graph neighbors project:payments --direction out --edge-type HAS_REPO
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
The response includes `repo:payments/api`, the `HAS_REPO` relationship, and its
|
|
51
|
+
source. A connected agent can query the same graph using `knowledge_graph`.
|
|
52
|
+
The first command that needs storage starts a database owner; exiting each CLI
|
|
53
|
+
command leaves that owner running. For cleanup, [stop the scratch database owner](operations.md#shared-service-lifecycle-and-safety)
|
|
54
|
+
before removing `$demo`. Use a fresh shell or unset the demo variables before
|
|
55
|
+
using your normal graph.
|
|
56
|
+
|
|
57
|
+
## Connect Pi
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
pi install npm:@laurindustries/mnemos@0.2.0
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
Use one active installation. `--local` puts the installation in a trusted
|
|
64
|
+
project's settings. If you already use an archived compatibility wrapper, see
|
|
65
|
+
[switching to the package loader](relocation.md) before installing again.
|
|
66
|
+
|
|
67
|
+
Start Pi with the database settings you want. `/kg schema` shows which schema
|
|
68
|
+
and database you selected without a model call. If you opt into the browser UI,
|
|
69
|
+
`/kg` opens it and `/kg url` prints its address without launching a browser.
|
|
70
|
+
|
|
71
|
+
## Connect OpenCode 2
|
|
72
|
+
|
|
73
|
+
Add Mnemos to the native `plugins` array in your OpenCode 2 configuration:
|
|
74
|
+
|
|
75
|
+
```json
|
|
76
|
+
{ "plugins": ["@laurindustries/mnemos@0.2.0"] }
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
Do not also declare an auto-discovered wrapper. OpenCode 1 is not supported.
|
|
80
|
+
The database owner uses Node even when OpenCode runs on Bun. Put Node on `PATH`
|
|
81
|
+
or set `PI_KNOWLEDGE_GRAPH_NODE` to its absolute executable path. See
|
|
82
|
+
[host verification notes](release.md#local-release-evidence) for what has been tested in
|
|
83
|
+
real hosts.
|
|
84
|
+
|
|
85
|
+
## Connect an MCP client
|
|
86
|
+
|
|
87
|
+
Follow [the MCP install guide](mcp.md) for Pi, OpenCode 2, or any client that
|
|
88
|
+
accepts a local stdio server. A global npm install is optional.
|
|
89
|
+
|
|
90
|
+
To join the terminal demo, set `PI_KNOWLEDGE_GRAPH_DB` in the client's server
|
|
91
|
+
environment to the absolute path shown by `printf '%s\n' "$demo/graph.lbug"`.
|
|
92
|
+
Set `PI_KNOWLEDGE_GRAPH_PORT` to `0` and keep the explorer off for that demo.
|
|
93
|
+
|
|
94
|
+
## Share memory across sessions
|
|
95
|
+
|
|
96
|
+
Point each host at the **same absolute database path**, with matching ontology,
|
|
97
|
+
port, and explorer settings. Without an override, the data lives at
|
|
98
|
+
`~/.pi/agent/knowledge-graph/graph.lbug` even if you don't use Pi. Choose separate
|
|
99
|
+
paths when you want separate graphs. See [configuration](operations.md#shared-configuration-and-coexistence)
|
|
100
|
+
for the full list of settings.
|
|
101
|
+
|
|
102
|
+
To check the handoff, ask one session to record a specific fact and its source,
|
|
103
|
+
then open another session and ask for that fact. Mnemos does not sync across
|
|
104
|
+
machines or automatically save conversation history.
|
|
105
|
+
|
|
106
|
+
## Install from source or a tarball
|
|
107
|
+
|
|
108
|
+
Use a checkout if you want to contribute or try changes before they ship:
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
git clone https://github.com/LaurIndustries/mnemos.git
|
|
112
|
+
cd mnemos
|
|
113
|
+
npm ci --include=optional
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
Run `node scripts/cli.mjs` in place of `knowledge-graph`, or use the absolute
|
|
117
|
+
checkout path as a local package in Pi or in OpenCode's `plugins` array.
|
|
118
|
+
For MCP, use the [source launcher](mcp.md#choose-how-to-launch-the-server).
|
|
119
|
+
|
|
120
|
+
To test a package archive instead, run `npm pack` in the checkout, then install
|
|
121
|
+
the resulting archive in a separate project:
|
|
122
|
+
|
|
123
|
+
```bash
|
|
124
|
+
npm install /absolute/path/to/mnemos/laurindustries-mnemos-0.2.0.tgz
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
Next: [learn how the graph works](ontology.md) or [see the tool and CLI reference](cli.md).
|
package/docs/mcp.md
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
# Install Mnemos as an MCP server
|
|
2
|
+
|
|
3
|
+
Mnemos is a **local stdio MCP server**. Your MCP client launches it as a process;
|
|
4
|
+
there is no MCP URL to paste and no sign-in required. Use **Node 22.19.0+** and
|
|
5
|
+
keep optional npm dependencies enabled for the native database binary.
|
|
6
|
+
|
|
7
|
+
## Choose how to launch the server
|
|
8
|
+
|
|
9
|
+
**From npm:** no global install is needed. Use `npx` as the executable and pass
|
|
10
|
+
these arguments separately:
|
|
11
|
+
|
|
12
|
+
```text
|
|
13
|
+
--yes --package=@laurindustries/mnemos@0.2.0 knowledge-graph-mcp
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
If npm returns `404`, use the source setup instead. If you already installed
|
|
17
|
+
Mnemos globally, `knowledge-graph-mcp` on `PATH` works without arguments.
|
|
18
|
+
|
|
19
|
+
**From source:** clone the repository and install its dependencies:
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
git clone https://github.com/LaurIndustries/mnemos.git
|
|
23
|
+
cd mnemos
|
|
24
|
+
npm ci --include=optional
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Configure your client to run `node` with one argument: the **absolute** path to
|
|
28
|
+
`mnemos/scripts/mcp.mjs` in that checkout. For a project-local npm or tarball
|
|
29
|
+
install, that script lives at
|
|
30
|
+
`node_modules/@laurindustries/mnemos/scripts/mcp.mjs` instead.
|
|
31
|
+
|
|
32
|
+
## Pi
|
|
33
|
+
|
|
34
|
+
Add Mnemos from a shell, then check the connection:
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
pi mcp add mnemos -- npx --yes --package=@laurindustries/mnemos@0.2.0 knowledge-graph-mcp
|
|
38
|
+
pi mcp list
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
For source, replace everything after `--` with
|
|
42
|
+
`node /absolute/path/to/mnemos/scripts/mcp.mjs`. Use `/reload` if Pi is already
|
|
43
|
+
running and `/mcp` to inspect the connected tools. If you already installed the
|
|
44
|
+
native Pi extension, choose that **or** MCP rather than exposing Mnemos twice.
|
|
45
|
+
|
|
46
|
+
## OpenCode 2
|
|
47
|
+
|
|
48
|
+
Merge this entry into `opencode.json` or `opencode.jsonc`. In OpenCode 2, local
|
|
49
|
+
servers go under **`mcp.servers`**, and `command` is an array:
|
|
50
|
+
|
|
51
|
+
```json
|
|
52
|
+
{
|
|
53
|
+
"mcp": {
|
|
54
|
+
"servers": {
|
|
55
|
+
"mnemos": {
|
|
56
|
+
"type": "local",
|
|
57
|
+
"command": ["npx", "--yes", "--package=@laurindustries/mnemos@0.2.0", "knowledge-graph-mcp"]
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
For source, use `["node", "/absolute/path/to/mnemos/scripts/mcp.mjs"]` as the
|
|
65
|
+
`command`. Run `opencode mcp list` to check the connection. Use either MCP or
|
|
66
|
+
[the native plugin](getting-started.md#connect-opencode-2) in a given client.
|
|
67
|
+
|
|
68
|
+
## Other clients using `mcpServers`
|
|
69
|
+
|
|
70
|
+
Merge this entry into the client's MCP configuration:
|
|
71
|
+
|
|
72
|
+
```json
|
|
73
|
+
{
|
|
74
|
+
"mcpServers": {
|
|
75
|
+
"mnemos": {
|
|
76
|
+
"command": "npx",
|
|
77
|
+
"args": ["--yes", "--package=@laurindustries/mnemos@0.2.0", "knowledge-graph-mcp"]
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
For source, set `"command": "node"` and
|
|
84
|
+
`"args": ["/absolute/path/to/mnemos/scripts/mcp.mjs"]`. If a desktop client can't
|
|
85
|
+
find `node` or `npx`, use the executable's absolute path. The `npx` launcher
|
|
86
|
+
also needs Node on its `PATH`; the source launcher can use an absolute Node path
|
|
87
|
+
without relying on `npx`. Restart the client after editing its configuration.
|
|
88
|
+
|
|
89
|
+
## Pick a database and verify the connection
|
|
90
|
+
|
|
91
|
+
With no override, Mnemos uses `~/.pi/agent/knowledge-graph/graph.lbug`. To join
|
|
92
|
+
an existing graph or isolate a project, set `PI_KNOWLEDGE_GRAPH_DB` to the full
|
|
93
|
+
path of the intended database. Pass variables in `env` for `mcpServers`, or
|
|
94
|
+
`environment` for OpenCode 2. Sharing a graph also requires the same ontology,
|
|
95
|
+
port, and explorer settings. See [shared configuration](operations.md#shared-configuration-and-coexistence).
|
|
96
|
+
|
|
97
|
+
A connected client should discover `knowledge_graph` and `mnemos_edit_ontology`.
|
|
98
|
+
Some clients add the server name as a prefix. Call `knowledge_graph` with
|
|
99
|
+
`{"action":"schema"}` to check the connection without opening the database.
|
|
100
|
+
Running the server alone in a terminal normally waits for MCP input and prints
|
|
101
|
+
no ready message: stdout is reserved for the protocol; diagnostics go to stderr.
|
|
102
|
+
|
|
103
|
+
The graph tool can change facts. The ontology tool can change the configured
|
|
104
|
+
user-owned YAML without a confirmation dialog. Only enable it in clients you
|
|
105
|
+
trust to follow the [explicit-request instruction](ontology.md#edit-on-explicit-request).
|