@helloleo/plugins 0.2.23 → 0.2.25
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/dist/index.js
CHANGED
|
@@ -14,6 +14,108 @@ var __export = (target, all) => {
|
|
|
14
14
|
});
|
|
15
15
|
};
|
|
16
16
|
|
|
17
|
+
// src/hooks/syntax-check.ts
|
|
18
|
+
import { readFileSync, statSync } from "fs";
|
|
19
|
+
import { relative } from "path";
|
|
20
|
+
var WRITE_TOOLS = new Set(["write", "edit", "apply_patch"]);
|
|
21
|
+
var CHECKED = /\.(?:[cm]?tsx?|[cm]?jsx?)$/;
|
|
22
|
+
var SKIPPED = /(?:^|[/\\])(?:node_modules|dist|build|\.wrangler|\.output)[/\\]/;
|
|
23
|
+
var MAX_LINES = 6;
|
|
24
|
+
var MAX_BYTES = 2000000;
|
|
25
|
+
function loaderFor(file) {
|
|
26
|
+
const tsx = file.endsWith("x");
|
|
27
|
+
return file.includes(".ts") ? tsx ? "tsx" : "ts" : tsx ? "jsx" : "js";
|
|
28
|
+
}
|
|
29
|
+
function parse(file) {
|
|
30
|
+
const stat = statSync(file, { throwIfNoEntry: false });
|
|
31
|
+
if (!stat?.isFile() || stat.size > MAX_BYTES)
|
|
32
|
+
return [];
|
|
33
|
+
const text = readFileSync(file, "utf8");
|
|
34
|
+
let raised;
|
|
35
|
+
try {
|
|
36
|
+
new Bun.Transpiler({ loader: loaderFor(file) }).transformSync(text);
|
|
37
|
+
return [];
|
|
38
|
+
} catch (err) {
|
|
39
|
+
raised = err;
|
|
40
|
+
}
|
|
41
|
+
const errors = raised.errors;
|
|
42
|
+
const messages = Array.isArray(errors) && errors.length > 0 ? errors : [raised];
|
|
43
|
+
const lines = text.split(`
|
|
44
|
+
`);
|
|
45
|
+
const seen = new Set;
|
|
46
|
+
const findings = [];
|
|
47
|
+
for (const item of messages) {
|
|
48
|
+
if (item?.level !== undefined && item.level !== "error")
|
|
49
|
+
continue;
|
|
50
|
+
const line = item?.position?.line ?? 0;
|
|
51
|
+
if (seen.has(line))
|
|
52
|
+
continue;
|
|
53
|
+
seen.add(line);
|
|
54
|
+
findings.push({
|
|
55
|
+
line,
|
|
56
|
+
col: item?.position?.column ?? 0,
|
|
57
|
+
message: item?.message ?? "Syntax error.",
|
|
58
|
+
source: item?.position?.lineText ?? lines[line - 1] ?? ""
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
return findings;
|
|
62
|
+
}
|
|
63
|
+
function report(label, findings) {
|
|
64
|
+
const shown = findings.slice(0, MAX_LINES);
|
|
65
|
+
const lines = shown.map((f) => `ERROR [${f.line}:${f.col}] ${f.message}`);
|
|
66
|
+
const more = findings.length - shown.length;
|
|
67
|
+
if (more > 0)
|
|
68
|
+
lines.push(`... and ${more} more`);
|
|
69
|
+
const body = [
|
|
70
|
+
"",
|
|
71
|
+
"",
|
|
72
|
+
"Syntax errors detected in this file, please fix:",
|
|
73
|
+
`<diagnostics file="${label}">`,
|
|
74
|
+
...lines
|
|
75
|
+
];
|
|
76
|
+
const first = shown[0];
|
|
77
|
+
if (first.source) {
|
|
78
|
+
const gutter = `${first.line} | `;
|
|
79
|
+
body.push("", `${gutter}${first.source}`, `${" ".repeat(gutter.length + Math.max(first.col - 1, 0))}^`);
|
|
80
|
+
}
|
|
81
|
+
body.push("</diagnostics>");
|
|
82
|
+
return body.join(`
|
|
83
|
+
`);
|
|
84
|
+
}
|
|
85
|
+
function targets(tool, args, metadata) {
|
|
86
|
+
if (tool === "apply_patch") {
|
|
87
|
+
const files = Array.isArray(metadata.files) ? metadata.files : [];
|
|
88
|
+
return files.map((f) => f.movePath ?? f.filePath).filter((p) => typeof p === "string");
|
|
89
|
+
}
|
|
90
|
+
return typeof args.filePath === "string" ? [args.filePath] : [];
|
|
91
|
+
}
|
|
92
|
+
var SyntaxCheckPlugin = async ({ worktree, directory }) => {
|
|
93
|
+
const base = worktree || directory;
|
|
94
|
+
if (typeof Bun === "undefined") {
|
|
95
|
+
console.error("[helloleo] syntax-check disabled: Bun.Transpiler unavailable on this runtime");
|
|
96
|
+
return {};
|
|
97
|
+
}
|
|
98
|
+
return {
|
|
99
|
+
"tool.execute.after": async (input, output) => {
|
|
100
|
+
try {
|
|
101
|
+
if (!WRITE_TOOLS.has(input.tool))
|
|
102
|
+
return;
|
|
103
|
+
const metadata = output.metadata ?? {};
|
|
104
|
+
for (const file of targets(input.tool, input.args ?? {}, metadata)) {
|
|
105
|
+
if (!CHECKED.test(file) || SKIPPED.test(file))
|
|
106
|
+
continue;
|
|
107
|
+
const label = base ? relative(base, file) || file : file;
|
|
108
|
+
const reported = output.output ?? "";
|
|
109
|
+
if (reported.includes(`<diagnostics file="${file}"`) || reported.includes(`<diagnostics file="${label}"`))
|
|
110
|
+
continue;
|
|
111
|
+
const findings = parse(file);
|
|
112
|
+
if (findings.length > 0)
|
|
113
|
+
output.output = `${reported}${report(label, findings)}`;
|
|
114
|
+
}
|
|
115
|
+
} catch {}
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
};
|
|
17
119
|
// node_modules/@opencode-ai/plugin/node_modules/zod/v4/classic/external.js
|
|
18
120
|
var exports_external = {};
|
|
19
121
|
__export(exports_external, {
|
|
@@ -72,7 +174,7 @@ __export(exports_external, {
|
|
|
72
174
|
pipe: () => pipe,
|
|
73
175
|
partialRecord: () => partialRecord,
|
|
74
176
|
parseAsync: () => parseAsync2,
|
|
75
|
-
parse: () =>
|
|
177
|
+
parse: () => parse4,
|
|
76
178
|
overwrite: () => _overwrite,
|
|
77
179
|
optional: () => optional,
|
|
78
180
|
object: () => object,
|
|
@@ -262,7 +364,7 @@ __export(exports_core2, {
|
|
|
262
364
|
regexes: () => exports_regexes,
|
|
263
365
|
prettifyError: () => prettifyError,
|
|
264
366
|
parseAsync: () => parseAsync,
|
|
265
|
-
parse: () =>
|
|
367
|
+
parse: () => parse2,
|
|
266
368
|
locales: () => exports_locales,
|
|
267
369
|
isValidJWT: () => isValidJWT,
|
|
268
370
|
isValidBase64URL: () => isValidBase64URL,
|
|
@@ -1361,7 +1463,7 @@ var _parse = (_Err) => (schema, value, _ctx, _params) => {
|
|
|
1361
1463
|
}
|
|
1362
1464
|
return result.value;
|
|
1363
1465
|
};
|
|
1364
|
-
var
|
|
1466
|
+
var parse2 = /* @__PURE__ */ _parse($ZodRealError);
|
|
1365
1467
|
var _parseAsync = (_Err) => async (schema, value, _ctx, params) => {
|
|
1366
1468
|
const ctx = _ctx ? Object.assign(_ctx, { async: true }) : { async: true };
|
|
1367
1469
|
let result = schema._zod.run({ value, issues: [] }, ctx);
|
|
@@ -3879,10 +3981,10 @@ var $ZodFunction = /* @__PURE__ */ $constructor("$ZodFunction", (inst, def) => {
|
|
|
3879
3981
|
throw new Error("implement() must be called with a function");
|
|
3880
3982
|
}
|
|
3881
3983
|
return function(...args) {
|
|
3882
|
-
const parsedArgs = inst._def.input ?
|
|
3984
|
+
const parsedArgs = inst._def.input ? parse2(inst._def.input, args) : args;
|
|
3883
3985
|
const result = Reflect.apply(func, this, parsedArgs);
|
|
3884
3986
|
if (inst._def.output) {
|
|
3885
|
-
return
|
|
3987
|
+
return parse2(inst._def.output, result);
|
|
3886
3988
|
}
|
|
3887
3989
|
return result;
|
|
3888
3990
|
};
|
|
@@ -11290,7 +11392,7 @@ var ZodRealError = $constructor("ZodError", initializer2, {
|
|
|
11290
11392
|
});
|
|
11291
11393
|
|
|
11292
11394
|
// node_modules/@opencode-ai/plugin/node_modules/zod/v4/classic/parse.js
|
|
11293
|
-
var
|
|
11395
|
+
var parse4 = /* @__PURE__ */ _parse(ZodRealError);
|
|
11294
11396
|
var parseAsync2 = /* @__PURE__ */ _parseAsync(ZodRealError);
|
|
11295
11397
|
var safeParse2 = /* @__PURE__ */ _safeParse(ZodRealError);
|
|
11296
11398
|
var safeParseAsync2 = /* @__PURE__ */ _safeParseAsync(ZodRealError);
|
|
@@ -11324,7 +11426,7 @@ var ZodType = /* @__PURE__ */ $constructor("ZodType", (inst, def) => {
|
|
|
11324
11426
|
reg.add(inst, meta);
|
|
11325
11427
|
return inst;
|
|
11326
11428
|
};
|
|
11327
|
-
inst.parse = (data, params) =>
|
|
11429
|
+
inst.parse = (data, params) => parse4(inst, data, params, { callee: inst.parse });
|
|
11328
11430
|
inst.safeParse = (data, params) => safeParse2(inst, data, params);
|
|
11329
11431
|
inst.parseAsync = async (data, params) => parseAsync2(inst, data, params, { callee: inst.parseAsync });
|
|
11330
11432
|
inst.safeParseAsync = async (data, params) => safeParseAsync2(inst, data, params);
|
|
@@ -12539,15 +12641,15 @@ var remove = tool({
|
|
|
12539
12641
|
if (!await file2.exists()) {
|
|
12540
12642
|
throw new Error(`File not found: ${args.filePath}`);
|
|
12541
12643
|
}
|
|
12542
|
-
const
|
|
12644
|
+
const relative2 = path.relative(context.directory, resolved);
|
|
12543
12645
|
await context.ask({
|
|
12544
12646
|
permission: "remove",
|
|
12545
12647
|
patterns: [resolved],
|
|
12546
12648
|
always: [resolved],
|
|
12547
|
-
metadata: { filePath:
|
|
12649
|
+
metadata: { filePath: relative2 }
|
|
12548
12650
|
});
|
|
12549
12651
|
await unlink(resolved);
|
|
12550
|
-
return `Removed ${
|
|
12652
|
+
return `Removed ${relative2}`;
|
|
12551
12653
|
}
|
|
12552
12654
|
});
|
|
12553
12655
|
var RemovePlugin = async () => {
|
|
@@ -12617,7 +12719,7 @@ __export(exports_external2, {
|
|
|
12617
12719
|
pipe: () => pipe2,
|
|
12618
12720
|
partialRecord: () => partialRecord2,
|
|
12619
12721
|
parseAsync: () => parseAsync4,
|
|
12620
|
-
parse: () =>
|
|
12722
|
+
parse: () => parse8,
|
|
12621
12723
|
overwrite: () => _overwrite2,
|
|
12622
12724
|
optional: () => optional2,
|
|
12623
12725
|
object: () => object2,
|
|
@@ -12807,7 +12909,7 @@ __export(exports_core4, {
|
|
|
12807
12909
|
regexes: () => exports_regexes2,
|
|
12808
12910
|
prettifyError: () => prettifyError2,
|
|
12809
12911
|
parseAsync: () => parseAsync3,
|
|
12810
|
-
parse: () =>
|
|
12912
|
+
parse: () => parse6,
|
|
12811
12913
|
locales: () => exports_locales2,
|
|
12812
12914
|
isValidJWT: () => isValidJWT2,
|
|
12813
12915
|
isValidBase64URL: () => isValidBase64URL2,
|
|
@@ -13906,7 +14008,7 @@ var _parse2 = (_Err) => (schema, value, _ctx, _params) => {
|
|
|
13906
14008
|
}
|
|
13907
14009
|
return result.value;
|
|
13908
14010
|
};
|
|
13909
|
-
var
|
|
14011
|
+
var parse6 = /* @__PURE__ */ _parse2($ZodRealError2);
|
|
13910
14012
|
var _parseAsync2 = (_Err) => async (schema, value, _ctx, params) => {
|
|
13911
14013
|
const ctx = _ctx ? Object.assign(_ctx, { async: true }) : { async: true };
|
|
13912
14014
|
let result = schema._zod.run({ value, issues: [] }, ctx);
|
|
@@ -16424,10 +16526,10 @@ var $ZodFunction2 = /* @__PURE__ */ $constructor2("$ZodFunction", (inst, def) =>
|
|
|
16424
16526
|
throw new Error("implement() must be called with a function");
|
|
16425
16527
|
}
|
|
16426
16528
|
return function(...args) {
|
|
16427
|
-
const parsedArgs = inst._def.input ?
|
|
16529
|
+
const parsedArgs = inst._def.input ? parse6(inst._def.input, args) : args;
|
|
16428
16530
|
const result = Reflect.apply(func, this, parsedArgs);
|
|
16429
16531
|
if (inst._def.output) {
|
|
16430
|
-
return
|
|
16532
|
+
return parse6(inst._def.output, result);
|
|
16431
16533
|
}
|
|
16432
16534
|
return result;
|
|
16433
16535
|
};
|
|
@@ -23835,7 +23937,7 @@ var ZodRealError2 = $constructor2("ZodError", initializer4, {
|
|
|
23835
23937
|
});
|
|
23836
23938
|
|
|
23837
23939
|
// node_modules/zod/v4/classic/parse.js
|
|
23838
|
-
var
|
|
23940
|
+
var parse8 = /* @__PURE__ */ _parse2(ZodRealError2);
|
|
23839
23941
|
var parseAsync4 = /* @__PURE__ */ _parseAsync2(ZodRealError2);
|
|
23840
23942
|
var safeParse4 = /* @__PURE__ */ _safeParse2(ZodRealError2);
|
|
23841
23943
|
var safeParseAsync4 = /* @__PURE__ */ _safeParseAsync2(ZodRealError2);
|
|
@@ -23869,7 +23971,7 @@ var ZodType2 = /* @__PURE__ */ $constructor2("ZodType", (inst, def) => {
|
|
|
23869
23971
|
reg.add(inst, meta);
|
|
23870
23972
|
return inst;
|
|
23871
23973
|
};
|
|
23872
|
-
inst.parse = (data, params) =>
|
|
23974
|
+
inst.parse = (data, params) => parse8(inst, data, params, { callee: inst.parse });
|
|
23873
23975
|
inst.safeParse = (data, params) => safeParse4(inst, data, params);
|
|
23874
23976
|
inst.parseAsync = async (data, params) => parseAsync4(inst, data, params, { callee: inst.parseAsync });
|
|
23875
23977
|
inst.safeParseAsync = async (data, params) => safeParseAsync4(inst, data, params);
|
|
@@ -26878,6 +26980,7 @@ var SetupNetsuitePlugin = async () => {
|
|
|
26878
26980
|
};
|
|
26879
26981
|
};
|
|
26880
26982
|
export {
|
|
26983
|
+
SyntaxCheckPlugin,
|
|
26881
26984
|
SetupNetsuitePlugin,
|
|
26882
26985
|
SetupAuthenticationPlugin,
|
|
26883
26986
|
ScaffoldPlugin,
|
|
@@ -12,8 +12,7 @@
|
|
|
12
12
|
"db:generate": "drizzle-kit generate",
|
|
13
13
|
"generate-routes": "tsr generate",
|
|
14
14
|
"typecheck": "tsc --noEmit",
|
|
15
|
-
"lint": "oxlint --fix"
|
|
16
|
-
"test": "vitest run"
|
|
15
|
+
"lint": "oxlint --fix"
|
|
17
16
|
},
|
|
18
17
|
"dependencies": {
|
|
19
18
|
"@helloleo/runtime": "^0.1.4",
|
|
@@ -79,25 +78,15 @@
|
|
|
79
78
|
"drizzle-kit": "^0.31.10",
|
|
80
79
|
"@tanstack/router-cli": "^1.167.18",
|
|
81
80
|
"@tanstack/router-plugin": "^1.168.19",
|
|
82
|
-
"@testing-library/dom": "^10.4.1",
|
|
83
|
-
"@testing-library/react": "^16.3.2",
|
|
84
81
|
"@types/node": "^26.1.0",
|
|
85
82
|
"@types/react": "^19.2.17",
|
|
86
83
|
"@types/react-dom": "^19.2.3",
|
|
87
84
|
"@vitejs/plugin-react": "^6.0.3",
|
|
88
|
-
"jsdom": "^29.1.1",
|
|
89
85
|
"oxfmt": "^0.57.0",
|
|
90
86
|
"oxlint": "^1.72.0",
|
|
91
87
|
"typescript": "^6.0.3",
|
|
92
88
|
"vite": "^8.1.3",
|
|
93
89
|
"vite-tsconfig-paths": "^6.1.1",
|
|
94
|
-
"vitest": "^4.1.9",
|
|
95
90
|
"wrangler": "^4.107.0"
|
|
96
|
-
},
|
|
97
|
-
"pnpm": {
|
|
98
|
-
"onlyBuiltDependencies": [
|
|
99
|
-
"esbuild",
|
|
100
|
-
"lightningcss"
|
|
101
|
-
]
|
|
102
91
|
}
|
|
103
92
|
}
|