notex-companion 0.1.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Bhirawa Mbani
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 ADDED
@@ -0,0 +1,82 @@
1
+ # notex-companion
2
+
3
+ A local retrieval companion for [Notex](https://github.com/bhirmbani/notex). It reads a checkout's
4
+ `graphify-out/graph.json` and serves deterministic search/query/path/node lookups over it — to the
5
+ Notex browser page over loopback HTTP, and (once [TBR-69](https://linear.app/bmbn/issue/TBR-69)
6
+ lands) to an MCP host over stdio.
7
+
8
+ ## What it reads
9
+
10
+ Exactly one file: `graphify-out/graph.json` in the checkout it's run from. That file is produced by
11
+ [graphify](https://github.com/bhirmbani/notex) elsewhere — the companion never generates, rebuilds,
12
+ or shells out to graphify itself. It also reads (and writes) `.notex/companion.json`, a per-checkout
13
+ pairing-token sidecar (see [Pairing](#pairing)). Both `graphify-out/` and `.notex/` should be
14
+ gitignored in the checkout you run this in.
15
+
16
+ ## What it does not do
17
+
18
+ - **No LLM.** It holds no model and does no vocabulary expansion or prose synthesis — retrieval is
19
+ literal token matching plus graph traversal. An MCP host agent (or a human) expands vocabulary
20
+ before asking; the companion tells you honestly when it hasn't (`degraded: { expansion: "none" }`).
21
+ - **No graph building.** It only reads an existing `graphify-out/graph.json`; it never invokes
22
+ graphify or writes to `graphify-out/`.
23
+ - **No network beyond loopback.** The HTTP server binds `127.0.0.1` only, never `0.0.0.0` — it is
24
+ never reachable from your LAN, let alone the internet.
25
+
26
+ Full contract: [`docs/specs/companion-api.md`](https://github.com/bhirmbani/notex/blob/main/docs/specs/companion-api.md).
27
+
28
+ ## Install & run
29
+
30
+ ```bash
31
+ npx notex-companion@latest
32
+ ```
33
+
34
+ Run this from inside a checkout that already has a `graphify-out/graph.json`. It prints which
35
+ checkout it's serving, the graph's node/edge/community counts, and one pairing line — paste that
36
+ line into Notex's "Connect companion" flow to pair your browser.
37
+
38
+ If `graphify-out/graph.json` is missing, it prints an actionable message and exits (code 1) instead
39
+ of starting a broken server.
40
+
41
+ ### Commands
42
+
43
+ ```bash
44
+ notex-companion [serve] [options] # start the loopback HTTP server — the default command
45
+ notex-companion mcp # start the stdio MCP server (stub until TBR-69 — the bin
46
+ # wiring ships here, the tool surface does not yet)
47
+ ```
48
+
49
+ ### `serve` options
50
+
51
+ | Flag | Default | Meaning |
52
+ |---|---|---|
53
+ | `--port <n>` | `7717` | Port to bind on `127.0.0.1`. There is no port scanning — pass this explicitly if `7717` is taken. |
54
+ | `--origin <url>` | — | An additional allowed CORS origin, beyond the production Notex origin (and `http://localhost:3000` outside `NODE_ENV=production`). Repeatable. |
55
+ | `--rotate-token` | off | Generate a new pairing token, invalidating the previous one. |
56
+
57
+ ## Pairing
58
+
59
+ On first run the companion generates a 32-byte token, persists it to `.notex/companion.json`
60
+ (mode `0600`), and reuses it across restarts. Every op except `/v1/ping` requires it as
61
+ `Authorization: Bearer <token>`. The token never leaves your machine — Notex stores it only in your
62
+ browser's `localStorage`, keyed by Repository, and it is never sent to the Notex server or database.
63
+
64
+ ## `apiVersion`
65
+
66
+ `ping` and every op response report `apiVersion` (currently `0.1.0`). Compatibility rule — see
67
+ [`companion-api.md` §1.1](https://github.com/bhirmbani/notex/blob/main/docs/specs/companion-api.md#11-apiversion-compatibility-rule-decided-by-tbr-66)
68
+ for the full rationale:
69
+
70
+ - **Pre-`1.0.0`:** the *minor* version is the breaking boundary. `0.1.x` and `0.2.0` are not
71
+ assumed compatible.
72
+ - **`1.0.0` and after:** ordinary semver — only a *major* bump may break compatibility.
73
+
74
+ ## Requirements
75
+
76
+ Node.js `>= 18`. No Python, no native build toolchain, no Bun — plain `npx` is enough. (If you
77
+ happen to run it under [Bun](https://bun.sh), it uses `Bun.serve` directly; otherwise it falls back
78
+ to a small `node:http`-based server that serves the same HTTP surface.)
79
+
80
+ ## License
81
+
82
+ MIT
package/dist/cli.d.ts ADDED
@@ -0,0 +1,10 @@
1
+ /** Thrown by argument parsing on bad input — `main()` turns it into a stderr message + exit 1. */
2
+ export declare class CliUsageError extends Error {
3
+ }
4
+ export type ServeArgs = {
5
+ port: number | undefined;
6
+ origins: string[];
7
+ rotateToken: boolean;
8
+ };
9
+ export declare function parseServeArgs(args: string[]): ServeArgs;
10
+ export declare function main(argv?: string[]): void;