@draig/lexis-two 1.0.5 → 1.0.7
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.
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
// lexis-two — OpenCode TUI plugin (no-op)
|
|
2
2
|
//
|
|
3
|
-
//
|
|
4
|
-
// and prevent installation/runtime load failures in the TUI interface.
|
|
3
|
+
// Satisfies OpenCode's TUI target loader. No TUI UI is needed for lexis-two.
|
|
5
4
|
|
|
6
|
-
export default
|
|
7
|
-
|
|
5
|
+
export default {
|
|
6
|
+
async tui() {
|
|
7
|
+
return {};
|
|
8
|
+
},
|
|
8
9
|
};
|
|
@@ -14,11 +14,23 @@ import path from "path";
|
|
|
14
14
|
|
|
15
15
|
// The shared instruction builder is CommonJS; bridge to it from this ES module.
|
|
16
16
|
const require = createRequire(import.meta.url);
|
|
17
|
+
|
|
18
|
+
let lexisInstructionsModule;
|
|
19
|
+
try {
|
|
20
|
+
lexisInstructionsModule = require("../../hooks/lexis-two-instructions");
|
|
21
|
+
} catch (e) {
|
|
22
|
+
try {
|
|
23
|
+
lexisInstructionsModule = require("@draig/lexis-two/hooks/lexis-two-instructions");
|
|
24
|
+
} catch (err) {
|
|
25
|
+
throw new Error("Failed to load lexis-two-instructions: " + err.message);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
17
29
|
const {
|
|
18
30
|
getLexisInstructions,
|
|
19
31
|
getDefaultMode,
|
|
20
32
|
normalizePersistedMode,
|
|
21
|
-
} =
|
|
33
|
+
} = lexisInstructionsModule;
|
|
22
34
|
|
|
23
35
|
// OpenCode has no flag-file convention of its own; keep mode beside its config.
|
|
24
36
|
const statePath = path.join(
|
|
@@ -43,7 +55,7 @@ function writeMode(mode) {
|
|
|
43
55
|
fs.writeFileSync(statePath, mode);
|
|
44
56
|
}
|
|
45
57
|
|
|
46
|
-
|
|
58
|
+
function createServerHooks({ client } = {}) {
|
|
47
59
|
const log = (level, message) => {
|
|
48
60
|
try {
|
|
49
61
|
client &&
|
|
@@ -71,4 +83,11 @@ export default async ({ client } = {}) => {
|
|
|
71
83
|
log("info", "lexis-two " + mode);
|
|
72
84
|
},
|
|
73
85
|
};
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// OpenCode v1 plugin shape: default export is { server(), tui() }.
|
|
89
|
+
export default {
|
|
90
|
+
async server(input) {
|
|
91
|
+
return createServerHooks(input);
|
|
92
|
+
},
|
|
74
93
|
};
|
package/package.json
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@draig/lexis-two",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.7",
|
|
4
4
|
"description": "The simple way to obtain the best code. Portable rules, skills, and slash commands for AI agents with lowest tokens usage.",
|
|
5
5
|
"main": "./.opencode/plugins/lexis-two.mjs",
|
|
6
6
|
"exports": {
|
|
7
|
+
".": "./.opencode/plugins/lexis-two.mjs",
|
|
7
8
|
"./server": "./.opencode/plugins/lexis-two.mjs",
|
|
8
9
|
"./tui": "./.opencode/plugins/lexis-two-tui.mjs"
|
|
9
10
|
},
|
|
@@ -16,7 +17,8 @@
|
|
|
16
17
|
".opencode/plugins/lexis-two-tui.mjs",
|
|
17
18
|
".opencode/command/",
|
|
18
19
|
"hooks/",
|
|
19
|
-
"skills/"
|
|
20
|
+
"skills/",
|
|
21
|
+
"scripts/opencode-wrapper-postinstall.mjs"
|
|
20
22
|
],
|
|
21
23
|
"keywords": [
|
|
22
24
|
"pi-package",
|
|
@@ -26,6 +28,7 @@
|
|
|
26
28
|
],
|
|
27
29
|
"license": "MIT",
|
|
28
30
|
"scripts": {
|
|
31
|
+
"postinstall": "node scripts/opencode-wrapper-postinstall.mjs",
|
|
29
32
|
"test": "node --test tests/*.test.js && npm test --prefix pi-extension",
|
|
30
33
|
"benchmark:opencode-go": "node benchmarks/benchmark-opencode-go.js --repeat 3 --write-md",
|
|
31
34
|
"benchmark:report": "node benchmarks/render-opencode-go-report.js",
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Patch OpenCode's npm cache wrapper package.json after install.
|
|
3
|
+
//
|
|
4
|
+
// OpenCode installs scoped plugins into ~/.cache/opencode/packages/@scope/pkg@latest/
|
|
5
|
+
// with a wrapper package.json that only lists dependencies. At runtime the loader
|
|
6
|
+
// reads that wrapper (not node_modules/@scope/pkg/package.json), so exports/main
|
|
7
|
+
// are missing and the plugin fails with "runtime load failed".
|
|
8
|
+
|
|
9
|
+
import fs from "fs";
|
|
10
|
+
import path from "path";
|
|
11
|
+
import { fileURLToPath } from "url";
|
|
12
|
+
|
|
13
|
+
const pkgRoot = path.dirname(path.join(fileURLToPath(import.meta.url), ".."));
|
|
14
|
+
const pkgJsonPath = path.join(pkgRoot, "package.json");
|
|
15
|
+
|
|
16
|
+
function isOpenCodeWrapperDir(dir) {
|
|
17
|
+
const normalized = dir.replace(/\\/g, "/");
|
|
18
|
+
return normalized.includes("/packages/") && normalized.endsWith("@latest");
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function patchWrapperPackageJson(wrapperDir, packageName) {
|
|
22
|
+
const wrapperPkgPath = path.join(wrapperDir, "package.json");
|
|
23
|
+
if (!fs.existsSync(wrapperPkgPath)) return false;
|
|
24
|
+
|
|
25
|
+
const wrapper = JSON.parse(fs.readFileSync(wrapperPkgPath, "utf8"));
|
|
26
|
+
const pluginBase = `./node_modules/${packageName}/.opencode/plugins`;
|
|
27
|
+
const next = {
|
|
28
|
+
...wrapper,
|
|
29
|
+
main: `${pluginBase}/lexis-two.mjs`,
|
|
30
|
+
exports: {
|
|
31
|
+
".": `${pluginBase}/lexis-two.mjs`,
|
|
32
|
+
"./server": `${pluginBase}/lexis-two.mjs`,
|
|
33
|
+
"./tui": `${pluginBase}/lexis-two-tui.mjs`,
|
|
34
|
+
},
|
|
35
|
+
"oc-plugin": ["server", "tui"],
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
fs.writeFileSync(wrapperPkgPath, `${JSON.stringify(next, null, 2)}\n`);
|
|
39
|
+
return true;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
try {
|
|
43
|
+
const pkg = JSON.parse(fs.readFileSync(pkgJsonPath, "utf8"));
|
|
44
|
+
const wrapperDir = path.resolve(pkgRoot, "../..");
|
|
45
|
+
if (!isOpenCodeWrapperDir(wrapperDir)) process.exit(0);
|
|
46
|
+
patchWrapperPackageJson(wrapperDir, pkg.name);
|
|
47
|
+
} catch {
|
|
48
|
+
// lexis: postinstall is best-effort — normal npm installs must not fail
|
|
49
|
+
process.exit(0);
|
|
50
|
+
}
|