pi-gortex 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,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for describing the origin of the Work and
141
+ reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2026 Andrey Kumanyaev <me@zzet.org>
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,102 @@
1
+ # pi-gortex
2
+
3
+ A [Pi](https://github.com/earendil-works/pi) extension that gives the agent
4
+ [Gortex](https://github.com/zzet/gortex)'s code-graph tools, and applies
5
+ Gortex's read-discipline decisions to Pi's own tools.
6
+
7
+ ### What is Gortex?
8
+
9
+ A code-intelligence engine that indexes your repositories into a queryable
10
+ knowledge graph of functions, classes, call chains, routes and cross-service
11
+ contracts, and serves it over MCP. Agents look up exactly the symbol they
12
+ need instead of reading whole files around it, which is where the token
13
+ savings come from. It is a single static binary with no dependency chain,
14
+ and it covers 257 languages through tree-sitter.
15
+
16
+ Pi has no MCP support by design, so this extension is the bridge.
17
+
18
+ ## What it does
19
+
20
+ - **Registers Gortex's graph tools as native Pi tools**, over a persistent
21
+ `gortex mcp` child per session. The deferred catalogue is reached through the
22
+ daemon's own `tools_search`, and promoted tools appear in Pi's registry.
23
+ - **Applies read discipline.** Pi's tool calls are forwarded to
24
+ `gortex hook --agent=pi`, which answers block / soft guidance / nothing
25
+ according to the posture you configured. Gortex owns that logic, so the
26
+ behaviour matches every other agent it integrates with.
27
+ - **Briefs the model once per session** with Gortex's orientation for the
28
+ current repository.
29
+
30
+ See [docs/architecture.md](docs/architecture.md) for how it works.
31
+
32
+ ## Requirements
33
+
34
+ - **Node 24+**, **Pi 0.85+**
35
+ - **The `gortex` binary** on `PATH`, **v0.61.2 or newer**. See
36
+ [Gortex installation](https://github.com/zzet/gortex/blob/main/docs/installation.md).
37
+ The extension starts the shared daemon itself and never blocks Pi's startup
38
+ on it, and warns you at session start when the binary is older than that.
39
+ Run `gortex upgrade` to fix it.
40
+
41
+ ## Install
42
+
43
+ Add it to Pi's settings, `~/.pi/agent/settings.json` for every project or
44
+ `<project>/.pi/settings.json` for one:
45
+
46
+ ```json
47
+ {
48
+ "packages": ["npm:pi-gortex"]
49
+ }
50
+ ```
51
+
52
+ Leave the spec unpinned: Pi skips pinned specs during `pi update`.
53
+
54
+ For local development, point Pi at a checkout instead: a `packages` entry with
55
+ the absolute path, or a single run with `pi -e /path/to/pi-gortex`.
56
+
57
+ ## Configure
58
+
59
+ Zero configuration required. Every value resolves at runtime, first hit wins:
60
+ environment -> `<cwd>/.pi/gortex.json` -> `<agent dir>/extensions/gortex.json`
61
+ (agent dir is `$PI_CODING_AGENT_DIR`, else `~/.pi/agent`) -> defaults.
62
+
63
+ | Sidecar key | Environment | Default | Meaning |
64
+ |----------------|--------------------|--------------------|---------|
65
+ | `bin` | `GORTEX_BIN` | `gortex` on `PATH` | Binary used for `daemon start`, `mcp` and `hook`. |
66
+ | `hook_mode` | `GORTEX_HOOK_MODE` | `deny` | Posture: `deny`, `enrich`, `consult-unlock`, `nudge`. |
67
+ | `enforce` | `GORTEX_ENFORCE` | `true` | `false` keeps the graph tools and the briefing, and wires no enforcement. |
68
+ | `tools_preset` | `GORTEX_TOOLS` | `core` | Eager MCP surface. `core`/`full` use the daemon's default; `edit`/`nav`/`readonly` narrow it. |
69
+
70
+ ```json
71
+ {
72
+ "bin": "/usr/local/bin/gortex",
73
+ "hook_mode": "enrich",
74
+ "enforce": true
75
+ }
76
+ ```
77
+
78
+ **If the graph tools go missing**, the first turn of the session says so and
79
+ names `/reload` as the retry. The bridge fails open, always: an absent binary or
80
+ a daemon that is down costs the session its graph tools, never the session.
81
+
82
+ ## Develop
83
+
84
+ ```sh
85
+ npm install
86
+ npm test # node --test
87
+ npm run typecheck
88
+ npm run check # both
89
+ ```
90
+
91
+ Zero runtime dependencies. Pi's types are imported as types only and erased, so
92
+ the package also loads as a bare directory extension with no `node_modules`
93
+ beside it.
94
+
95
+ The suites drive the extension through Pi's own `ExtensionRunner`;
96
+ [docs/tests.md](docs/tests.md) explains the approach and the rules a suite
97
+ follows.
98
+
99
+ ## License
100
+
101
+ Apache License 2.0, the same license as
102
+ [gortex](https://github.com/zzet/gortex) itself.
@@ -0,0 +1,126 @@
1
+ # Architecture
2
+
3
+ How the bridge is built, and why each piece is shaped the way it is.
4
+
5
+ ## The problem
6
+
7
+ Pi has no MCP support, by design; its extension API covers the ground MCP would.
8
+ Gortex speaks MCP and owns a hook protocol that every agent it integrates with
9
+ shares. This extension is the adapter between the two, and it does two separate
10
+ jobs over two separate channels.
11
+
12
+ ## Channel 1: graph tools over an MCP stdio bridge
13
+
14
+ One Gortex MCP child process per session, spoken to over newline-delimited
15
+ JSON-RPC on stdio. Every tool the daemon offers becomes a native Pi tool whose
16
+ implementation forwards the call down that channel.
17
+
18
+ - **Handshake.** The client identifies itself as Pi and advertises which compact
19
+ wire formats it can decode, so list-shaped results arrive compact without the
20
+ daemon needing a per-client allowlist entry. One retry after a short backoff
21
+ absorbs a daemon that is still warming up.
22
+ - **Version skew.** The handshake reply carries `serverInfo.version` and the
23
+ protocol the daemon settled on. A daemon below the supported floor, or one
24
+ answering a protocol this client does not speak, warns the user through Pi's
25
+ warning channel and tells the model a tool may misbehave. Advisory only: the
26
+ session keeps every tool it registered.
27
+ - **Registration.** The daemon's eager tool surface is registered up front, each
28
+ MCP input schema passed through verbatim as the Pi tool's parameters, so the
29
+ model reads the daemon's own parameter documentation.
30
+ - **Promotion.** The rest of the catalogue stays deferred, and the model reaches
31
+ it through the daemon's own search tool. The daemon announces each promotion
32
+ and the extension re-syncs the tool list into Pi's registry. Announcements
33
+ arrive in bursts, so the re-sync is debounced; a search call awaits its own
34
+ re-sync directly, so every tool its reply names is callable by the time the
35
+ model reads it.
36
+ - **Framing.** Reads are incremental. The scan for a frame boundary resumes
37
+ where the previous chunk ended, so one large frame split across many chunks
38
+ does not re-scan a growing buffer each time. A frame past a generous size cap
39
+ kills the child, because a stream cannot be resynced mid-frame, and the next
40
+ call respawns it.
41
+ - **Timeouts.** Every request is bounded: a short cap for ordinary requests, a
42
+ longer one for the handshake, the longest for tool calls. The last is generous
43
+ enough for analyzers that legitimately run for minutes, and finite so a wedged
44
+ daemon cannot hang an agent turn forever.
45
+
46
+ ### Tool-name aliasing
47
+
48
+ Some Gortex tools share a name with a Pi built-in. Pi lets an extension silently
49
+ replace a built-in by reusing its name, which would break Pi's own rendering and
50
+ anything hooked to that built-in, so a colliding tool registers under a prefixed
51
+ alias. Every name in Pi's built-in vocabulary is guarded this way, which covers
52
+ built-ins Pi may grow later as well as today's collisions. Each aliased tool
53
+ front-loads the rename into its own description, because Gortex's guidance and
54
+ denial messages name the bare tool and the model has to map it.
55
+
56
+ ## Channel 2: read discipline over the hook bridge
57
+
58
+ Every tool call Pi is about to run is forwarded to Gortex's hook with a
59
+ normalized event envelope, and the decision that comes back is applied: block
60
+ the call with a reason, attach non-blocking soft guidance, or do nothing.
61
+
62
+ Pi names its tools in its own lowercase vocabulary and shapes their inputs its
63
+ own way, while Gortex's classifier switches on canonical tool names and input
64
+ keys. That translation lives on this side of the bridge, so the Go side keeps
65
+ one vocabulary for every agent it serves.
66
+
67
+ Postures are resolved by Gortex. Keeping that decision there is what keeps the
68
+ behaviour identical across hosts.
69
+
70
+ ## Orientation injection
71
+
72
+ The session briefing rides a tail user message appended during context assembly.
73
+ Carrying it in the system prompt would place it at the head of the conversation,
74
+ where a change invalidates prefix prompt caching on every turn. The text is
75
+ computed once per session and cleared only once it has been appended, so a
76
+ context shape the extension cannot append to does not silently drop it.
77
+
78
+ ## The readiness barrier
79
+
80
+ Pi arms the prompt's submit handler well before the session hook that registers
81
+ tools has run: at startup, and again on the reload and new-session paths, which
82
+ do their own work first. A fast prompt can therefore reach the agent loop while
83
+ tool registration is still pending, or before it has begun at all.
84
+
85
+ The turn waits on a promise that settles when the current session hook
86
+ finishes, under a cap. The hold works at all because Pi awaits each lifecycle
87
+ handler in turn before moving on, a property its documentation leaves unstated
88
+ for this event and the suites verify against the real host. Two details
89
+ matter:
90
+
91
+ - The promise is armed when the extension instance is constructed, because every
92
+ session builds a fresh instance before its session hook fires. An instance can
93
+ be asked for a turn before its own hook has run.
94
+ - Each session hook invocation captures its own resolver. Overlapping
95
+ invocations (a rapid reload, or an embedder sharing one resource loader) would
96
+ otherwise let a stale invocation release a turn parked on a newer one.
97
+
98
+ If the cap expires first, that turn is told the tools may not be callable yet
99
+ and pointed at a reload. Exactly one turn reports it.
100
+
101
+ ## Session state
102
+
103
+ The live bridge, the last bridge error and the registered tool names live at
104
+ module scope, and that is load bearing. A reload re-imports the module, so the
105
+ state resets with it. A new session, a resume and a fork re-invoke the extension
106
+ factory against the cached module, and the new invocation stops the previous
107
+ invocation's child, which works only while both invocations see the same bridge.
108
+ Each invocation claims the shared slot before its first suspension point, so an
109
+ invocation that overlaps it stops that bridge instead of leaving the child
110
+ behind. State held per instance would leak a Gortex child on every new
111
+ session.
112
+
113
+ ## Failure posture
114
+
115
+ Fail open, everywhere. A missing binary, a daemon that is down, a handshake that
116
+ times out, a malformed configuration file, a hook that errors: each costs the
117
+ session some capability and never takes the session down. When the bridge is
118
+ down the first turn says so and names the reload command; a hook error yields an
119
+ empty decision, so a hiccup never blocks a tool call the user asked for.
120
+
121
+ ## Configuration
122
+
123
+ Every value resolves at runtime, layered from the environment down through a
124
+ project file and a global one to defaults. See the table in the
125
+ [README](../README.md#configure). Runtime resolution is what lets one artifact
126
+ serve both the npm package and a directory install.
package/docs/tests.md ADDED
@@ -0,0 +1,108 @@
1
+ # Tests
2
+
3
+ ```sh
4
+ npm test # node --test
5
+ npm run typecheck
6
+ npm run check # both
7
+ ```
8
+
9
+ Node 24+. The suites import the TypeScript sources directly under type
10
+ stripping, so there is no build step.
11
+
12
+ This file holds the rules a suite here follows. What a suite covers, and why it
13
+ earns its place, is stated in that suite's own header.
14
+
15
+ ## Pi is real, Gortex is doubled
16
+
17
+ Pi runs for real. Every behavioural suite drives the extension through Pi's own
18
+ extension runner, loaded through Pi's own resource loader. Gortex is doubled: a
19
+ stand-in for the process seam answers the handshake, the tool list and the tool
20
+ calls, so no binary is spawned and no daemon is required.
21
+
22
+ The split follows from what each side is. Pi is the contract this extension must
23
+ not get wrong, and its lifecycle ordering is the property the readiness barrier
24
+ rests on (see [the architecture](architecture.md#the-readiness-barrier)). A
25
+ hand-written stub of that ordering would assert our own belief about Pi back to
26
+ ourselves, and would keep passing on the day Pi changed. Gortex is our own
27
+ dependency, whose timing has to be controllable to the millisecond for a barrier
28
+ to be testable at all.
29
+
30
+ So: make Pi the oracle, and keep the daemon out of the run.
31
+
32
+ ## The factory seam
33
+
34
+ Pi calls an extension factory with one argument, which would normally cost the
35
+ suite every injection point. The way through is the inline-factory closure Pi's
36
+ loader accepts:
37
+
38
+ ```ts
39
+ new DefaultResourceLoader({
40
+ cwd, agentDir,
41
+ extensionFactories: [{ name: "gortex", factory: (pi) => gortexExtension(pi, options) }],
42
+ noExtensions: true, /* ...and the other no* flags */
43
+ });
44
+ ```
45
+
46
+ The config and the process double ride that closure, while Pi owns the
47
+ lifecycle, the tool registry and the event payload shapes.
48
+
49
+ ## Hermetic by construction
50
+
51
+ Each harness gets a temp `cwd`, a temp `agentDir` and an in-memory session
52
+ manager. The loader's `no*` flags keep the developer's own installed extensions
53
+ out. A run touches no network, no real `~/.pi`, and writes no session files.
54
+ Never resolve the real agent directory from a test, which would load whatever
55
+ the developer happens to have installed.
56
+
57
+ ## Assert structure, never wall-clock
58
+
59
+ A suite that needs registration to still be in flight gates the double and
60
+ releases it deliberately, so the state under test holds for as long as the
61
+ machine takes, rather than flaking on a loaded CI runner. Where a bound is
62
+ asserted, it is a bound the extension itself sets, driven by a cap the suite
63
+ passes in.
64
+
65
+ ## Fence what cannot be asserted
66
+
67
+ Some setups rest on a property no assertion reaches, such as a child being
68
+ spawned before the handler's first suspension point. A suite that relies on one
69
+ checks it and throws when it stops holding. A gate that silently targets nothing
70
+ leaves the suite green while testing nothing.
71
+
72
+ ## Two properties of the real runner
73
+
74
+ - The runner swallows a handler throw into its error listener rather than
75
+ rejecting, so a broken handler would leave the assertions around it passing.
76
+ Every suite asserts the errors the runner collected are empty.
77
+ - The runner accepts partial action objects, so only the members this extension
78
+ touches need implementing, which is what pi-mono's own runner tests do.
79
+
80
+ ## Cover the published path once
81
+
82
+ A suite that imports the factory itself says nothing about whether the package
83
+ manifest points anywhere real, or whether Pi's loader can load the import graph.
84
+ One suite has to come in through Pi's own discovery instead, and assert the file
85
+ it loaded against the manifest, because Pi falls back to discovering an entry
86
+ point in the directory when the manifest resolves to nothing.
87
+
88
+ ## Where the double stops
89
+
90
+ The double models what the suites need and no more. Behaviour past that edge,
91
+ such as promotion re-sync under real notification traffic, frame splitting, the
92
+ frame size cap, a real model turn or a live daemon, is unverified here. A change
93
+ in that territory is verified by hand against a running Gortex, and the suite
94
+ says as much rather than implying coverage it does not have.
95
+
96
+ ## Pinning
97
+
98
+ The Pi devDependency is pinned tight on purpose. Pi is pre-1.0 and its runner's
99
+ method surface has been renamed without a changelog entry before, so a tight pin
100
+ turns that into a red build rather than a silently skipped suite. The runtime
101
+ peer dependency stays wide.
102
+
103
+ ## Layout
104
+
105
+ Shared machinery (the harness, the subject loader, the process double, the
106
+ shared fixtures) lives in `test/support`. Per-suite choreography stays in the
107
+ suite: for the barrier, when each event fires relative to the others is the
108
+ thing under test.
package/index.ts ADDED
@@ -0,0 +1,3 @@
1
+ // Package entry point: `main` and `pi.extensions` both resolve here.
2
+ export { default } from "./src/index.ts";
3
+ export * from "./src/index.ts";
package/package.json ADDED
@@ -0,0 +1,63 @@
1
+ {
2
+ "name": "pi-gortex",
3
+ "version": "0.1.0",
4
+ "description": "Gortex for Pi: high-performance code-intelligence engine for AI agents, based on graph. Exposes only the information the agent needs, cutting token usage up to 50x. 100% local.",
5
+ "keywords": [
6
+ "pi-package",
7
+ "pi-extension",
8
+ "gortex",
9
+ "mcp",
10
+ "code-graph"
11
+ ],
12
+ "homepage": "https://github.com/gortexhq/pi#readme",
13
+ "bugs": {
14
+ "url": "https://github.com/gortexhq/pi/issues"
15
+ },
16
+ "repository": {
17
+ "type": "git",
18
+ "url": "git+https://github.com/gortexhq/pi.git"
19
+ },
20
+ "license": "Apache-2.0",
21
+ "files": [
22
+ "index.ts",
23
+ "src/",
24
+ "docs/",
25
+ "README.md",
26
+ "LICENSE"
27
+ ],
28
+ "type": "module",
29
+ "main": "./index.ts",
30
+ "scripts": {
31
+ "test": "node --test \"test/*.test.ts\"",
32
+ "test:watch": "node --test --watch \"test/*.test.ts\"",
33
+ "typecheck": "tsc --noEmit",
34
+ "check": "npm run typecheck && npm test",
35
+ "prepublishOnly": "npm run check"
36
+ },
37
+ "devDependencies": {
38
+ "@earendil-works/pi-coding-agent": "~0.85.1",
39
+ "@types/node": "^26.6.2",
40
+ "typescript": "^7.0.2"
41
+ },
42
+ "peerDependencies": {
43
+ "@earendil-works/pi-coding-agent": "*",
44
+ "@earendil-works/pi-tui": "*"
45
+ },
46
+ "peerDependenciesMeta": {
47
+ "@earendil-works/pi-coding-agent": {
48
+ "optional": true
49
+ },
50
+ "@earendil-works/pi-tui": {
51
+ "optional": true
52
+ }
53
+ },
54
+ "engines": {
55
+ "node": ">=24.0.0"
56
+ },
57
+ "pi": {
58
+ "extensions": [
59
+ "./index.ts"
60
+ ],
61
+ "image": "https://raw.githubusercontent.com/zzet/gortex/main/assets/wall.png"
62
+ }
63
+ }