@vimhead.dev/pi-norn 0.1.0-tip.35725822562.1 → 0.1.0-tip.35976246970.1

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.
Files changed (3) hide show
  1. package/README.md +5 -2
  2. package/dist/index.js +28 -14
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  # Norn for Pi
2
2
 
3
- Deliver the selected Norn runtime's documentation introduction to outer Pi sessions.
3
+ Deliver the selected Norn runtime's documentation and
4
+ [workflow introductions](https://github.com/vimhead/norn/blob/main/docs/cli.md#workflow-introduction)
5
+ to outer Pi sessions.
4
6
  Install the Norn CLI separately, then:
5
7
 
6
8
  ```bash
@@ -10,6 +12,7 @@ pi
10
12
 
11
13
  The adapter selects `norn` from `PATH`, or `pi --norn-executable /absolute/path/to/norn`.
12
14
  It does not carry another Norn runtime or SDK and does not inject authoring context
13
- into Norn-managed agent sessions.
15
+ into Norn-managed agent sessions. Workflow discovery is skipped in untrusted
16
+ projects. Both introductions refresh at session start or `/reload`.
14
17
 
15
18
  [Runtime installation](https://github.com/vimhead/norn#installation).
package/dist/index.js CHANGED
@@ -8,7 +8,7 @@ function nornPiAdapter(pi) {
8
8
  let cachedIntro;
9
9
  pi.registerFlag("norn-executable", {
10
10
  type: "string",
11
- description: "Norn executable for docs intro (defaults to norn on PATH). Accepts an executable path, not a shell command."
11
+ description: "Norn executable for docs intro and workflows intro (defaults to norn on PATH). Accepts an executable path, not a shell command."
12
12
  });
13
13
  pi.on("session_start", async (_event, ctx) => {
14
14
  cachedIntro = void 0;
@@ -19,20 +19,19 @@ function nornPiAdapter(pi) {
19
19
  if (configuredExecutable !== void 0 && typeof configuredExecutable !== "string")
20
20
  throw new Error("Invalid Norn executable flag");
21
21
  const executable = configuredExecutable ?? "norn";
22
- const result = await pi.exec(executable, ["docs", "intro"], {
23
- cwd: ctx.cwd,
24
- timeout: 1e4
25
- });
26
- if (result.killed || result.code !== 0)
27
- throw new Error("Norn docs intro did not complete successfully");
28
- const response = JSON.parse(result.stdout);
29
- if (!response || typeof response !== "object" || !("intro" in response) || typeof response.intro !== "string" || response.intro.trim().length === 0 || Buffer.byteLength(response.intro, "utf8") > 16384) {
30
- throw new Error("Invalid Norn introduction response");
31
- }
32
- cachedIntro = { executable, intro: response.intro };
22
+ const [intro, workflowsIntro] = await Promise.all([
23
+ loadIntroduction({ pi, executable, cwd: ctx.cwd, group: "docs" }),
24
+ ctx.isProjectTrusted() ? loadIntroduction({
25
+ pi,
26
+ executable,
27
+ cwd: ctx.cwd,
28
+ group: "workflows"
29
+ }) : Promise.resolve("")
30
+ ]);
31
+ cachedIntro = { executable, intro, workflowsIntro };
33
32
  } catch {
34
33
  ctx.ui.notify(
35
- "Norn introduction unavailable. Check --norn-executable and run that executable with 'docs intro' to diagnose, then /reload to retry.",
34
+ "Norn introduction unavailable. Check --norn-executable and run that executable with 'docs intro' and 'workflows intro' in the project directory to diagnose, then /reload to retry.",
36
35
  "warning"
37
36
  );
38
37
  }
@@ -55,10 +54,25 @@ function nornPiAdapter(pi) {
55
54
 
56
55
  ${INTRO_START}
57
56
  ${cachedIntro.intro}
58
- ${INTRO_END}`
57
+ ${INTRO_END}${cachedIntro.workflowsIntro ? `
58
+
59
+ ${cachedIntro.workflowsIntro}` : ""}`
59
60
  };
60
61
  });
61
62
  }
63
+ async function loadIntroduction(input) {
64
+ const result = await input.pi.exec(input.executable, [input.group, "intro"], {
65
+ cwd: input.cwd,
66
+ timeout: 1e4
67
+ });
68
+ if (result.killed || result.code !== 0)
69
+ throw new Error(`Norn ${input.group} intro did not complete successfully`);
70
+ const response = JSON.parse(result.stdout);
71
+ if (!response || typeof response !== "object" || !("intro" in response) || typeof response.intro !== "string" || input.group === "docs" && response.intro.trim().length === 0 || Buffer.byteLength(response.intro, "utf8") > 16384) {
72
+ throw new Error("Invalid Norn introduction response");
73
+ }
74
+ return response.intro;
75
+ }
62
76
  export {
63
77
  nornPiAdapter as default
64
78
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vimhead.dev/pi-norn",
3
- "version": "0.1.0-tip.35725822562.1",
3
+ "version": "0.1.0-tip.35976246970.1",
4
4
  "description": "Deliver installed Norn runtime documentation to outer Pi agent sessions.",
5
5
  "type": "module",
6
6
  "license": "MIT",