@vimhead.dev/pi-norn 0.1.0-tip.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/README.md ADDED
@@ -0,0 +1,15 @@
1
+ # Norn for Pi
2
+
3
+ Deliver the selected Norn runtime's documentation introduction to outer Pi sessions.
4
+ Install the Norn CLI separately, then:
5
+
6
+ ```bash
7
+ pi install npm:@vimhead.dev/pi-norn@tip
8
+ pi
9
+ ```
10
+
11
+ The adapter selects `norn` from `PATH`, or `pi --norn-executable /absolute/path/to/norn`.
12
+ It does not carry another Norn runtime or SDK and does not inject authoring context
13
+ into Norn-managed agent sessions.
14
+
15
+ [Runtime installation](https://github.com/vimhead/norn#installation).
@@ -0,0 +1,2 @@
1
+ import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
2
+ export default function nornPiAdapter(pi: ExtensionAPI): void;
package/dist/index.js ADDED
@@ -0,0 +1,49 @@
1
+ // ../core/src/agent-protocol.ts
2
+ var AGENT_RESPONSE_TOOL_NAME = "pi_workflows_agent_response";
3
+
4
+ // src/index.ts
5
+ var INTRO_START = "<norn-docs-intro>";
6
+ var INTRO_END = "</norn-docs-intro>";
7
+ function nornPiAdapter(pi) {
8
+ let cachedIntro;
9
+ pi.registerFlag("norn-executable", {
10
+ type: "string",
11
+ description: "Norn executable for docs intro (defaults to norn on PATH). Accepts an executable path, not a shell command."
12
+ });
13
+ pi.on("session_start", async (_event, ctx) => {
14
+ cachedIntro = void 0;
15
+ if (pi.getAllTools().some((tool) => tool.name === AGENT_RESPONSE_TOOL_NAME)) return;
16
+ try {
17
+ const configuredExecutable = pi.getFlag("norn-executable");
18
+ if (configuredExecutable !== void 0 && typeof configuredExecutable !== "string") throw new Error("Invalid Norn executable flag");
19
+ const executable = configuredExecutable ?? "norn";
20
+ const result = await pi.exec(executable, ["docs", "intro"], { cwd: ctx.cwd, timeout: 1e4 });
21
+ if (result.killed || result.code !== 0) throw new Error("Norn docs intro did not complete successfully");
22
+ const response = JSON.parse(result.stdout);
23
+ if (!response || typeof response !== "object" || !("intro" in response) || typeof response.intro !== "string" || response.intro.trim().length === 0 || Buffer.byteLength(response.intro, "utf8") > 16384) {
24
+ throw new Error("Invalid Norn introduction response");
25
+ }
26
+ cachedIntro = { executable, intro: response.intro };
27
+ } catch {
28
+ ctx.ui.notify("Norn introduction unavailable. Check --norn-executable and run that executable with 'docs intro' to diagnose, then /reload to retry.", "warning");
29
+ }
30
+ });
31
+ pi.on("before_agent_start", (event, ctx) => {
32
+ if (!cachedIntro) return;
33
+ if (pi.getAllTools().some((tool) => tool.name === AGENT_RESPONSE_TOOL_NAME)) return;
34
+ if (event.systemPrompt.includes(INTRO_START)) return;
35
+ if (cachedIntro.executable !== (pi.getFlag("norn-executable") ?? "norn")) {
36
+ cachedIntro = void 0;
37
+ ctx.ui.notify("Norn executable changed. Run /reload to refresh its introduction.", "warning");
38
+ return;
39
+ }
40
+ return { systemPrompt: `${event.systemPrompt}
41
+
42
+ ${INTRO_START}
43
+ ${cachedIntro.intro}
44
+ ${INTRO_END}` };
45
+ });
46
+ }
47
+ export {
48
+ nornPiAdapter as default
49
+ };
package/package.json ADDED
@@ -0,0 +1,47 @@
1
+ {
2
+ "name": "@vimhead.dev/pi-norn",
3
+ "version": "0.1.0-tip.0",
4
+ "description": "Deliver installed Norn runtime documentation to outer Pi agent sessions.",
5
+ "type": "module",
6
+ "license": "MIT",
7
+ "keywords": [
8
+ "pi-package"
9
+ ],
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "git+https://github.com/vimhead/norn.git",
13
+ "directory": "packages/pi-norn"
14
+ },
15
+ "homepage": "https://github.com/vimhead/norn#readme",
16
+ "engines": {
17
+ "node": ">=22.19.0"
18
+ },
19
+ "publishConfig": {
20
+ "access": "public",
21
+ "tag": "tip"
22
+ },
23
+ "files": [
24
+ "dist",
25
+ "README.md"
26
+ ],
27
+ "pi": {
28
+ "extensions": [
29
+ "./dist/index.js"
30
+ ]
31
+ },
32
+ "peerDependencies": {
33
+ "@earendil-works/pi-coding-agent": "*"
34
+ },
35
+ "peerDependenciesMeta": {
36
+ "@earendil-works/pi-coding-agent": {
37
+ "optional": true
38
+ }
39
+ },
40
+ "devDependencies": {
41
+ "@earendil-works/pi-coding-agent": "0.85.1",
42
+ "@vimhead.dev/norn-core": "0.0.0"
43
+ },
44
+ "scripts": {
45
+ "build": "node ../../scripts/build-package.ts"
46
+ }
47
+ }