@awebai/oats-pi 0.69.3 → 0.69.5
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 +20 -0
- package/extension/core-loader.mjs +36 -18
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -45,6 +45,26 @@ OATS
|
|
|
45
45
|
publishes both packages from the same version tag. Reload pi after an adapter
|
|
46
46
|
install or upgrade.
|
|
47
47
|
|
|
48
|
+
**Which kernel the bridge loads.** The bridge imports the kernel's
|
|
49
|
+
`lib/core.mjs`, from the first of:
|
|
50
|
+
|
|
51
|
+
1. `OATS_PKG_ROOT`, the kernel's package directory (a checkout of
|
|
52
|
+
awebai/oats, say), when it is one;
|
|
53
|
+
2. inside an OATS instance, the kernel that launched it: the home's own
|
|
54
|
+
`oats` (`$OATS_INSTANCE_HOME/.oats/bin/oats`), a link the kernel writes at
|
|
55
|
+
every launch. A home therefore needs no global install, whatever PATH pi
|
|
56
|
+
runs with, when its kernel runs from a checkout or a local install;
|
|
57
|
+
3. the `oats` on PATH, when its real path lies in the kernel's package: the
|
|
58
|
+
global install's, or a checkout's after `npm link`. An `oats` that is a
|
|
59
|
+
script running the kernel from elsewhere names no package and is passed
|
|
60
|
+
over;
|
|
61
|
+
4. `@awebai/oats` in npm's global folder (`npm root -g`).
|
|
62
|
+
|
|
63
|
+
Outside an instance with none of these, pi reports the extension as failing
|
|
64
|
+
to load, with "OATS kernel not found" and the three ways out:
|
|
65
|
+
`npm install -g @awebai/oats`, an `oats` on PATH that links to the kernel, or
|
|
66
|
+
`OATS_PKG_ROOT`.
|
|
67
|
+
|
|
48
68
|
All lifecycle/config/package operations use the shell-visible CLI: `oats
|
|
49
69
|
status`, `oats spawn`, `oats doctor`, `oats install`, `oats trust`, `oats use`, and
|
|
50
70
|
`oats retire`.
|
|
@@ -1,17 +1,22 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* core-loader.mjs — locate the
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* future Claude plugin shares.
|
|
2
|
+
* core-loader.mjs — locate the @awebai/oats kernel and re-export its
|
|
3
|
+
* lib/core.mjs. The pi package is a thin adapter: it never ships the kernel,
|
|
4
|
+
* skills, injects, or capabilities — those live in the kernel package, the
|
|
5
|
+
* single source of truth that the future Claude plugin shares.
|
|
7
6
|
*
|
|
8
7
|
* Resolution order:
|
|
9
8
|
* 1. $OATS_PKG_ROOT (explicit override, e.g. a dev clone)
|
|
10
|
-
* 2.
|
|
11
|
-
*
|
|
9
|
+
* 2. inside an instance, the home's kernel shim ($OATS_INSTANCE_HOME/.oats/bin/oats,
|
|
10
|
+
* a link to the kernel that launched it) → realpath → its package root, whatever
|
|
11
|
+
* PATH pi has
|
|
12
|
+
* 3. the `oats` binary on PATH → realpath → its package root
|
|
13
|
+
* 4. `npm root -g`/@awebai/oats (binary not linked but package present)
|
|
14
|
+
* Steps 2 and 3 find the package from the binary's real path: an `oats` that is
|
|
15
|
+
* a script running the kernel from elsewhere names no package, and is passed
|
|
16
|
+
* over. Step 2 takes only a link, and falls through silently without one.
|
|
12
17
|
*/
|
|
13
18
|
import { execSync } from "node:child_process";
|
|
14
|
-
import { existsSync, readFileSync, realpathSync } from "node:fs";
|
|
19
|
+
import { existsSync, lstatSync, readFileSync, realpathSync } from "node:fs";
|
|
15
20
|
import { dirname, join } from "node:path";
|
|
16
21
|
import { pathToFileURL } from "node:url";
|
|
17
22
|
|
|
@@ -23,17 +28,29 @@ function isKernelRoot(dir) {
|
|
|
23
28
|
try { return JSON.parse(readFileSync(pj, "utf8")).name === PKG_NAME; } catch { return false; }
|
|
24
29
|
}
|
|
25
30
|
|
|
31
|
+
/** The kernel package a binary's real path lies in (<pkg>/bin/oats.mjs → <pkg>), or undefined. */
|
|
32
|
+
function kernelRootOf(bin) {
|
|
33
|
+
let d = dirname(realpathSync(bin));
|
|
34
|
+
while (d !== dirname(d)) {
|
|
35
|
+
if (isKernelRoot(d)) return d;
|
|
36
|
+
d = dirname(d);
|
|
37
|
+
}
|
|
38
|
+
return undefined;
|
|
39
|
+
}
|
|
40
|
+
|
|
26
41
|
function findKernelRoot() {
|
|
27
42
|
if (process.env.OATS_PKG_ROOT && isKernelRoot(process.env.OATS_PKG_ROOT)) return process.env.OATS_PKG_ROOT;
|
|
43
|
+
if (process.env.OATS_INSTANCE_HOME) {
|
|
44
|
+
try {
|
|
45
|
+
const shim = join(process.env.OATS_INSTANCE_HOME, ".oats", "bin", "oats");
|
|
46
|
+
const root = lstatSync(shim).isSymbolicLink() ? kernelRootOf(shim) : undefined;
|
|
47
|
+
if (root) return root;
|
|
48
|
+
} catch { /* no shim: the PATH lookup below */ }
|
|
49
|
+
}
|
|
28
50
|
try {
|
|
29
51
|
const bin = execSync("command -v oats", { encoding: "utf8", stdio: ["ignore", "pipe", "pipe"] }).trim();
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
while (d !== dirname(d)) {
|
|
33
|
-
if (isKernelRoot(d)) return d;
|
|
34
|
-
d = dirname(d);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
52
|
+
const root = bin ? kernelRootOf(bin) : undefined;
|
|
53
|
+
if (root) return root;
|
|
37
54
|
} catch { /* not on PATH */ }
|
|
38
55
|
try {
|
|
39
56
|
const g = execSync("npm root -g", { encoding: "utf8", stdio: ["ignore", "pipe", "pipe"] }).trim();
|
|
@@ -46,9 +63,10 @@ function findKernelRoot() {
|
|
|
46
63
|
export const OATS_PKG_ROOT = findKernelRoot();
|
|
47
64
|
if (!OATS_PKG_ROOT) {
|
|
48
65
|
throw new Error(
|
|
49
|
-
"OATS kernel not found
|
|
50
|
-
"
|
|
51
|
-
"
|
|
66
|
+
"OATS kernel not found. In an OATS instance the bridge uses the kernel that launched it; elsewhere it needs one of:\n" +
|
|
67
|
+
" npm install -g @awebai/oats\n" +
|
|
68
|
+
" an `oats` on PATH that links to the kernel's bin/oats.mjs (npm link, in a checkout); a script that runs it is not followed\n" +
|
|
69
|
+
" OATS_PKG_ROOT=<the kernel's package directory, such as a checkout of awebai/oats>",
|
|
52
70
|
);
|
|
53
71
|
}
|
|
54
72
|
|
package/package.json
CHANGED