@atheory-ai/ce-plugin-sandbox 0.1.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/LICENSE +201 -0
- package/README.md +27 -0
- package/dist/index.js +574 -0
- package/dist/index.js.map +7 -0
- package/package.json +53 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# @atheory-ai/ce-plugin-sandbox
|
|
2
|
+
|
|
3
|
+
Local validation and fixture analysis for Context Engine plugin WASM artifacts.
|
|
4
|
+
The sandbox delegates loading and extraction to the `ce` binary, exercising the
|
|
5
|
+
same runtime contract used by Context Engine.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
pnpm add -D @atheory-ai/ce-plugin-sandbox
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Commands
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
ce-sandbox validate dist/my-plugin.wasm
|
|
17
|
+
ce-sandbox run dist/my-plugin.wasm tests/fixtures/example.php
|
|
18
|
+
ce-sandbox coverage dist/my-plugin.wasm --fixtures tests/fixtures
|
|
19
|
+
ce-sandbox diff dist/previous.wasm dist/current.wasm --fixtures tests/fixtures
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Use `--ce /path/to/ce` to select a binary and `--json` for machine-readable
|
|
23
|
+
output.
|
|
24
|
+
|
|
25
|
+
## License
|
|
26
|
+
|
|
27
|
+
Apache-2.0
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,574 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// src/runner/loader.ts
|
|
4
|
+
import { spawnSync } from "child_process";
|
|
5
|
+
import { writeFileSync, unlinkSync } from "fs";
|
|
6
|
+
import { tmpdir } from "os";
|
|
7
|
+
import { join } from "path";
|
|
8
|
+
var PluginLoader = class {
|
|
9
|
+
constructor(ceBinary = "ce") {
|
|
10
|
+
this.ceBinary = ceBinary;
|
|
11
|
+
this.validateBinary();
|
|
12
|
+
}
|
|
13
|
+
validateBinary() {
|
|
14
|
+
const result = spawnSync(this.ceBinary, ["version"], { stdio: "pipe" });
|
|
15
|
+
if (result.error || result.status !== 0) {
|
|
16
|
+
throw new Error(
|
|
17
|
+
`CE binary not found: ${this.ceBinary}
|
|
18
|
+
Install it or specify path with --ce flag.`
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
validate(wasmPath) {
|
|
23
|
+
const result = spawnSync(this.ceBinary, ["plugin", "validate", wasmPath, "--json"], {
|
|
24
|
+
encoding: "utf8"
|
|
25
|
+
});
|
|
26
|
+
if (result.status !== 0) {
|
|
27
|
+
return { passed: false, errors: [result.stderr || "validation failed"], output: result.stdout };
|
|
28
|
+
}
|
|
29
|
+
try {
|
|
30
|
+
const parsed = JSON.parse(result.stdout);
|
|
31
|
+
return { passed: true, errors: [], output: result.stdout, ...parsed };
|
|
32
|
+
} catch {
|
|
33
|
+
return { passed: true, errors: [], output: result.stdout };
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
extract(wasmPath, fixturePath, content) {
|
|
37
|
+
const tmpInput = join(tmpdir(), `ce-sandbox-${Date.now()}.json`);
|
|
38
|
+
writeFileSync(tmpInput, JSON.stringify({ filePath: fixturePath, content }), "utf8");
|
|
39
|
+
const result = spawnSync(
|
|
40
|
+
this.ceBinary,
|
|
41
|
+
["plugin", "extract", wasmPath, "--input", tmpInput, "--json"],
|
|
42
|
+
{ encoding: "utf8" }
|
|
43
|
+
);
|
|
44
|
+
try {
|
|
45
|
+
unlinkSync(tmpInput);
|
|
46
|
+
} catch {
|
|
47
|
+
}
|
|
48
|
+
if (result.status !== 0) {
|
|
49
|
+
throw new Error(`Extraction failed: ${result.stderr}`);
|
|
50
|
+
}
|
|
51
|
+
return JSON.parse(result.stdout);
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
// src/output/render.ts
|
|
56
|
+
import chalk from "chalk";
|
|
57
|
+
function renderReport(report) {
|
|
58
|
+
console.log();
|
|
59
|
+
console.log(chalk.bold(`${report.pluginName} v${report.pluginVersion}`));
|
|
60
|
+
console.log(chalk.dim(`wasm: ${report.wasmHash.slice(0, 12)}...`));
|
|
61
|
+
console.log();
|
|
62
|
+
if (report.fixtureResults.length > 0) {
|
|
63
|
+
console.log(chalk.bold("Coverage"));
|
|
64
|
+
console.log();
|
|
65
|
+
for (const f of report.fixtureResults) {
|
|
66
|
+
const pct = f.coveragePct === -1 ? "N/A" : `${f.coveragePct.toFixed(0)}%`;
|
|
67
|
+
const color = f.coveragePct >= 80 ? chalk.green : f.coveragePct >= 50 ? chalk.yellow : chalk.red;
|
|
68
|
+
const bar = coverageBar(f.coveragePct);
|
|
69
|
+
console.log(` ${f.fixturePath}`);
|
|
70
|
+
console.log(` ${color(pct.padStart(4))} ${bar} ${f.extractedNodes} nodes, ${f.extractedEdges} edges`);
|
|
71
|
+
if (f.missingSymbols.length > 0 && f.missingSymbols.length <= 5) {
|
|
72
|
+
console.log(chalk.dim(` missing: ${f.missingSymbols.join(", ")}`));
|
|
73
|
+
} else if (f.missingSymbols.length > 5) {
|
|
74
|
+
console.log(chalk.dim(
|
|
75
|
+
` missing: ${f.missingSymbols.slice(0, 5).join(", ")} +${f.missingSymbols.length - 5} more`
|
|
76
|
+
));
|
|
77
|
+
}
|
|
78
|
+
console.log();
|
|
79
|
+
}
|
|
80
|
+
const aggPct = report.aggregate.coveragePct;
|
|
81
|
+
const aggColor = aggPct >= 80 ? chalk.green : aggPct >= 50 ? chalk.yellow : chalk.red;
|
|
82
|
+
const aggStr = aggPct < 0 ? "N/A" : `${aggPct.toFixed(1)}%`;
|
|
83
|
+
console.log(
|
|
84
|
+
` ${chalk.bold("Total")} ${aggColor(aggStr)} (${report.aggregate.totalExtractedNodes}/${report.aggregate.totalExpectedSymbols} symbols)`
|
|
85
|
+
);
|
|
86
|
+
console.log();
|
|
87
|
+
}
|
|
88
|
+
if (report.diff) {
|
|
89
|
+
const delta = report.diff.coverageDelta;
|
|
90
|
+
const sign = delta > 0 ? "+" : "";
|
|
91
|
+
const color = delta > 0 ? chalk.green : delta < 0 ? chalk.red : chalk.dim;
|
|
92
|
+
console.log(chalk.bold("Changes from previous build"));
|
|
93
|
+
console.log(` Coverage: ${color(`${sign}${delta.toFixed(1)}%`)}`);
|
|
94
|
+
for (const f of report.diff.fixtures) {
|
|
95
|
+
if (f.addedNodes.length > 0 || f.removedNodes.length > 0) {
|
|
96
|
+
console.log(` ${f.fixture}`);
|
|
97
|
+
if (f.addedNodes.length > 0) {
|
|
98
|
+
console.log(chalk.green(` + ${f.addedNodes.length} nodes: ${f.addedNodes.slice(0, 3).join(", ")}`));
|
|
99
|
+
}
|
|
100
|
+
if (f.removedNodes.length > 0) {
|
|
101
|
+
console.log(chalk.red(` - ${f.removedNodes.length} nodes: ${f.removedNodes.slice(0, 3).join(", ")}`));
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
console.log();
|
|
106
|
+
}
|
|
107
|
+
if (report.validation.errors.length > 0) {
|
|
108
|
+
for (const err of report.validation.errors) {
|
|
109
|
+
console.log(chalk.red(` \u2717 ${err}`));
|
|
110
|
+
}
|
|
111
|
+
console.log();
|
|
112
|
+
}
|
|
113
|
+
if (report.validation.warnings.length > 0) {
|
|
114
|
+
for (const warn of report.validation.warnings) {
|
|
115
|
+
console.log(chalk.yellow(` \u26A0 ${warn}`));
|
|
116
|
+
}
|
|
117
|
+
console.log();
|
|
118
|
+
}
|
|
119
|
+
if (report.validation.passed && report.validation.warnings.length === 0) {
|
|
120
|
+
console.log(chalk.green(" \u2713 All checks passed"));
|
|
121
|
+
console.log();
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
function coverageBar(pct) {
|
|
125
|
+
if (pct < 0)
|
|
126
|
+
return chalk.dim("\u2591".repeat(10) + " N/A");
|
|
127
|
+
const filled = Math.round(pct / 10);
|
|
128
|
+
const empty = 10 - filled;
|
|
129
|
+
const color = pct >= 80 ? chalk.green : pct >= 50 ? chalk.yellow : chalk.red;
|
|
130
|
+
return color("\u2588".repeat(filled)) + chalk.dim("\u2591".repeat(empty));
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// src/output/report.ts
|
|
134
|
+
function addValidationInsights(report) {
|
|
135
|
+
const { aggregate, validation } = report;
|
|
136
|
+
if (aggregate.coveragePct >= 0 && aggregate.coveragePct < 80) {
|
|
137
|
+
validation.warnings.push(
|
|
138
|
+
`Coverage is ${aggregate.coveragePct.toFixed(1)}% \u2014 below the 80% recommended threshold. Review missing symbols and add extraction patterns for them.`
|
|
139
|
+
);
|
|
140
|
+
}
|
|
141
|
+
for (const f of report.fixtureResults) {
|
|
142
|
+
if (f.extractedNodes === 0 && f.astSymbols > 0) {
|
|
143
|
+
validation.errors.push(
|
|
144
|
+
`Fixture ${f.fixturePath}: plugin extracted 0 nodes from a file with ${f.astSymbols} expected symbols. Check that language.match() returns true for this file extension.`
|
|
145
|
+
);
|
|
146
|
+
validation.passed = false;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
if (report.fixtureResults.length === 0) {
|
|
150
|
+
validation.warnings.push(
|
|
151
|
+
`No fixture files found. Add sample files to tests/fixtures/ to enable coverage analysis.`
|
|
152
|
+
);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
function buildReport(params) {
|
|
156
|
+
const { pluginName, pluginVersion, wasmHash, fixtureResults, validationErrors } = params;
|
|
157
|
+
const totalExpected = fixtureResults.reduce((s, f) => s + f.astSymbols, 0);
|
|
158
|
+
const totalExtracted = fixtureResults.reduce((s, f) => s + f.extractedNodes, 0);
|
|
159
|
+
const totalEdges = fixtureResults.reduce((s, f) => s + f.extractedEdges, 0);
|
|
160
|
+
const knownFixtures = fixtureResults.filter((f) => f.coveragePct >= 0);
|
|
161
|
+
const coveragePct = knownFixtures.length > 0 ? knownFixtures.reduce((s, f) => s + f.coveragePct, 0) / knownFixtures.length : -1;
|
|
162
|
+
const report = {
|
|
163
|
+
schemaVersion: 1,
|
|
164
|
+
pluginName,
|
|
165
|
+
pluginVersion,
|
|
166
|
+
wasmHash,
|
|
167
|
+
builtAt: Date.now(),
|
|
168
|
+
fixtureResults,
|
|
169
|
+
aggregate: {
|
|
170
|
+
totalExpectedSymbols: totalExpected,
|
|
171
|
+
totalExtractedNodes: totalExtracted,
|
|
172
|
+
coveragePct,
|
|
173
|
+
totalEdges
|
|
174
|
+
},
|
|
175
|
+
validation: {
|
|
176
|
+
passed: validationErrors.length === 0,
|
|
177
|
+
errors: [...validationErrors],
|
|
178
|
+
warnings: []
|
|
179
|
+
}
|
|
180
|
+
};
|
|
181
|
+
addValidationInsights(report);
|
|
182
|
+
return report;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
// src/commands/validate.ts
|
|
186
|
+
import { createHash } from "crypto";
|
|
187
|
+
import { readFileSync } from "fs";
|
|
188
|
+
async function runValidate(wasmPath, opts) {
|
|
189
|
+
const loader = new PluginLoader(opts.ce);
|
|
190
|
+
const wasmBytes = readFileSync(wasmPath);
|
|
191
|
+
const wasmHash = createHash("sha256").update(wasmBytes).digest("hex");
|
|
192
|
+
const result = loader.validate(wasmPath);
|
|
193
|
+
const report = buildReport({
|
|
194
|
+
pluginName: wasmPath,
|
|
195
|
+
pluginVersion: "unknown",
|
|
196
|
+
wasmHash,
|
|
197
|
+
fixtureResults: [],
|
|
198
|
+
validationErrors: result.errors
|
|
199
|
+
});
|
|
200
|
+
if (opts.json) {
|
|
201
|
+
console.log(JSON.stringify(report, null, 2));
|
|
202
|
+
} else {
|
|
203
|
+
renderReport(report);
|
|
204
|
+
}
|
|
205
|
+
if (!result.passed)
|
|
206
|
+
process.exit(1);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
// src/runner/fixtures.ts
|
|
210
|
+
import { readdirSync, readFileSync as readFileSync2, statSync } from "fs";
|
|
211
|
+
import { join as join2 } from "path";
|
|
212
|
+
function loadFixtures(fixturesDir) {
|
|
213
|
+
const fixtures2 = [];
|
|
214
|
+
try {
|
|
215
|
+
const entries = readdirSync(fixturesDir);
|
|
216
|
+
for (const entry of entries) {
|
|
217
|
+
const fullPath = join2(fixturesDir, entry);
|
|
218
|
+
const stat = statSync(fullPath);
|
|
219
|
+
if (stat.isFile()) {
|
|
220
|
+
const content = readFileSync2(fullPath, "utf8");
|
|
221
|
+
fixtures2.push({ path: entry, content });
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
} catch (err) {
|
|
225
|
+
const e = err;
|
|
226
|
+
if (e.code !== "ENOENT")
|
|
227
|
+
throw err;
|
|
228
|
+
}
|
|
229
|
+
return fixtures2;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
// src/analysis/ast.ts
|
|
233
|
+
var ENUMERATORS = {
|
|
234
|
+
".go": (content) => {
|
|
235
|
+
const symbols = [];
|
|
236
|
+
const lines = content.split("\n");
|
|
237
|
+
lines.forEach((line, i) => {
|
|
238
|
+
const lineNum = i + 1;
|
|
239
|
+
const fnMatch = line.match(/^func\s+(?:\([^)]+\)\s+)?(\w+)\s*\(/);
|
|
240
|
+
if (fnMatch)
|
|
241
|
+
symbols.push({ name: fnMatch[1], type: "function", line: lineNum });
|
|
242
|
+
const typeMatch = line.match(/^type\s+(\w+)\s+(?:struct|interface|func|\w)/);
|
|
243
|
+
if (typeMatch)
|
|
244
|
+
symbols.push({ name: typeMatch[1], type: "type", line: lineNum });
|
|
245
|
+
const constMatch = line.match(/^\s{0,1}(\w+)\s*=/);
|
|
246
|
+
if (constMatch && line.includes("const")) {
|
|
247
|
+
symbols.push({ name: constMatch[1], type: "const", line: lineNum });
|
|
248
|
+
}
|
|
249
|
+
});
|
|
250
|
+
return symbols;
|
|
251
|
+
},
|
|
252
|
+
".ts": (content) => {
|
|
253
|
+
const symbols = [];
|
|
254
|
+
const lines = content.split("\n");
|
|
255
|
+
lines.forEach((line, i) => {
|
|
256
|
+
const lineNum = i + 1;
|
|
257
|
+
const fnMatch = line.match(/^(?:export\s+)?(?:async\s+)?function\s+(\w+)/);
|
|
258
|
+
if (fnMatch)
|
|
259
|
+
symbols.push({ name: fnMatch[1], type: "function", line: lineNum });
|
|
260
|
+
const classMatch = line.match(/^(?:export\s+)?class\s+(\w+)/);
|
|
261
|
+
if (classMatch)
|
|
262
|
+
symbols.push({ name: classMatch[1], type: "class", line: lineNum });
|
|
263
|
+
const ifaceMatch = line.match(/^(?:export\s+)?interface\s+(\w+)/);
|
|
264
|
+
if (ifaceMatch)
|
|
265
|
+
symbols.push({ name: ifaceMatch[1], type: "interface", line: lineNum });
|
|
266
|
+
const typeMatch = line.match(/^(?:export\s+)?type\s+(\w+)\s*=/);
|
|
267
|
+
if (typeMatch)
|
|
268
|
+
symbols.push({ name: typeMatch[1], type: "type", line: lineNum });
|
|
269
|
+
});
|
|
270
|
+
return symbols;
|
|
271
|
+
},
|
|
272
|
+
".py": (content) => {
|
|
273
|
+
const symbols = [];
|
|
274
|
+
const lines = content.split("\n");
|
|
275
|
+
lines.forEach((line, i) => {
|
|
276
|
+
const lineNum = i + 1;
|
|
277
|
+
const fnMatch = line.match(/^(?:async\s+)?def\s+(\w+)\s*\(/);
|
|
278
|
+
if (fnMatch)
|
|
279
|
+
symbols.push({ name: fnMatch[1], type: "function", line: lineNum });
|
|
280
|
+
const classMatch = line.match(/^class\s+(\w+)/);
|
|
281
|
+
if (classMatch)
|
|
282
|
+
symbols.push({ name: classMatch[1], type: "class", line: lineNum });
|
|
283
|
+
});
|
|
284
|
+
return symbols;
|
|
285
|
+
}
|
|
286
|
+
};
|
|
287
|
+
function enumerateExpectedSymbols(filePath, content) {
|
|
288
|
+
const ext = filePath.substring(filePath.lastIndexOf("."));
|
|
289
|
+
const enumerator = ENUMERATORS[ext];
|
|
290
|
+
if (!enumerator)
|
|
291
|
+
return null;
|
|
292
|
+
return enumerator(content);
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
// src/analysis/coverage.ts
|
|
296
|
+
function computeCoverage(fixturePath, content, extraction) {
|
|
297
|
+
const expected = enumerateExpectedSymbols(fixturePath, content);
|
|
298
|
+
if (expected === null) {
|
|
299
|
+
return {
|
|
300
|
+
fixturePath,
|
|
301
|
+
expectedSymbols: [],
|
|
302
|
+
extractedNodes: extraction.nodes,
|
|
303
|
+
matchedSymbols: [],
|
|
304
|
+
missingSymbols: [],
|
|
305
|
+
extraNodes: extraction.nodes,
|
|
306
|
+
coveragePct: -1
|
|
307
|
+
};
|
|
308
|
+
}
|
|
309
|
+
if (expected.length === 0) {
|
|
310
|
+
return {
|
|
311
|
+
fixturePath,
|
|
312
|
+
expectedSymbols: [],
|
|
313
|
+
extractedNodes: extraction.nodes,
|
|
314
|
+
matchedSymbols: [],
|
|
315
|
+
missingSymbols: [],
|
|
316
|
+
extraNodes: extraction.nodes,
|
|
317
|
+
coveragePct: 0
|
|
318
|
+
};
|
|
319
|
+
}
|
|
320
|
+
const matched = [];
|
|
321
|
+
const missing = [];
|
|
322
|
+
for (const sym of expected) {
|
|
323
|
+
const covered = extraction.nodes.some(
|
|
324
|
+
(node) => node.label === sym.name || node.canonicalID.endsWith(`:${sym.name}`) || node.canonicalID.endsWith(`/${sym.name}`)
|
|
325
|
+
);
|
|
326
|
+
if (covered) {
|
|
327
|
+
matched.push(sym.name);
|
|
328
|
+
} else {
|
|
329
|
+
missing.push(sym.name);
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
const extra = extraction.nodes.filter(
|
|
333
|
+
(node) => !expected.some(
|
|
334
|
+
(sym) => node.label === sym.name || node.canonicalID.endsWith(`:${sym.name}`) || node.canonicalID.endsWith(`/${sym.name}`)
|
|
335
|
+
)
|
|
336
|
+
);
|
|
337
|
+
const coveragePct = expected.length > 0 ? matched.length / expected.length * 100 : 0;
|
|
338
|
+
return {
|
|
339
|
+
fixturePath,
|
|
340
|
+
expectedSymbols: expected,
|
|
341
|
+
extractedNodes: extraction.nodes,
|
|
342
|
+
matchedSymbols: matched,
|
|
343
|
+
missingSymbols: missing,
|
|
344
|
+
extraNodes: extra,
|
|
345
|
+
coveragePct
|
|
346
|
+
};
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
// src/commands/coverage.ts
|
|
350
|
+
import { createHash as createHash2 } from "crypto";
|
|
351
|
+
import { readFileSync as readFileSync3 } from "fs";
|
|
352
|
+
async function runCoverage(wasmPath, opts) {
|
|
353
|
+
const loader = new PluginLoader(opts.ce);
|
|
354
|
+
const fixtures2 = loadFixtures(opts.fixtures);
|
|
355
|
+
const wasmBytes = readFileSync3(wasmPath);
|
|
356
|
+
const wasmHash = createHash2("sha256").update(wasmBytes).digest("hex");
|
|
357
|
+
const validation = loader.validate(wasmPath);
|
|
358
|
+
const fixtureResults = [];
|
|
359
|
+
for (const fixture of fixtures2) {
|
|
360
|
+
let extraction = { nodes: [], edges: [] };
|
|
361
|
+
if (validation.passed) {
|
|
362
|
+
try {
|
|
363
|
+
extraction = loader.extract(wasmPath, fixture.path, fixture.content);
|
|
364
|
+
} catch (err) {
|
|
365
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
366
|
+
validation.errors.push(`Extraction failed for ${fixture.path}: ${msg}`);
|
|
367
|
+
validation.passed = false;
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
const cov = computeCoverage(fixture.path, fixture.content, extraction);
|
|
371
|
+
fixtureResults.push({
|
|
372
|
+
fixturePath: cov.fixturePath,
|
|
373
|
+
astSymbols: cov.expectedSymbols.length,
|
|
374
|
+
extractedNodes: cov.extractedNodes.length,
|
|
375
|
+
extractedEdges: extraction.edges.length,
|
|
376
|
+
coveragePct: cov.coveragePct,
|
|
377
|
+
missingSymbols: cov.missingSymbols,
|
|
378
|
+
extraNodes: cov.extraNodes.map((n) => n.canonicalID)
|
|
379
|
+
});
|
|
380
|
+
}
|
|
381
|
+
const report = buildReport({
|
|
382
|
+
pluginName: wasmPath,
|
|
383
|
+
pluginVersion: "unknown",
|
|
384
|
+
wasmHash,
|
|
385
|
+
fixtureResults,
|
|
386
|
+
validationErrors: validation.errors
|
|
387
|
+
});
|
|
388
|
+
if (opts.json) {
|
|
389
|
+
console.log(JSON.stringify(report, null, 2));
|
|
390
|
+
} else {
|
|
391
|
+
renderReport(report);
|
|
392
|
+
}
|
|
393
|
+
if (!report.validation.passed)
|
|
394
|
+
process.exit(1);
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
// src/analysis/diff.ts
|
|
398
|
+
function diffExtractions(fixture, oldResult, newResult, oldCoverage, newCoverage) {
|
|
399
|
+
const oldNodeIDs = new Set(oldResult.nodes.map((n) => n.canonicalID));
|
|
400
|
+
const newNodeIDs = new Set(newResult.nodes.map((n) => n.canonicalID));
|
|
401
|
+
const oldEdgeIDs = new Set(oldResult.edges.map((e) => e.id));
|
|
402
|
+
const newEdgeIDs = new Set(newResult.edges.map((e) => e.id));
|
|
403
|
+
return {
|
|
404
|
+
fixture,
|
|
405
|
+
addedNodes: [...newNodeIDs].filter((id) => !oldNodeIDs.has(id)),
|
|
406
|
+
removedNodes: [...oldNodeIDs].filter((id) => !newNodeIDs.has(id)),
|
|
407
|
+
addedEdges: [...newEdgeIDs].filter((id) => !oldEdgeIDs.has(id)),
|
|
408
|
+
removedEdges: [...oldEdgeIDs].filter((id) => !newEdgeIDs.has(id)),
|
|
409
|
+
coverageDelta: newCoverage - oldCoverage
|
|
410
|
+
};
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
// src/commands/diff.ts
|
|
414
|
+
import { createHash as createHash3 } from "crypto";
|
|
415
|
+
import { readFileSync as readFileSync4 } from "fs";
|
|
416
|
+
async function runDiff(oldWasmPath, newWasmPath, opts) {
|
|
417
|
+
const loader = new PluginLoader(opts.ce);
|
|
418
|
+
const fixtures2 = loadFixtures(opts.fixtures);
|
|
419
|
+
const oldBytes = readFileSync4(oldWasmPath);
|
|
420
|
+
const newBytes = readFileSync4(newWasmPath);
|
|
421
|
+
const oldHash = createHash3("sha256").update(oldBytes).digest("hex");
|
|
422
|
+
const newHash = createHash3("sha256").update(newBytes).digest("hex");
|
|
423
|
+
const fixtureResults = [];
|
|
424
|
+
const diffs = [];
|
|
425
|
+
let oldTotalCoverage = 0;
|
|
426
|
+
let newTotalCoverage = 0;
|
|
427
|
+
let knownCount = 0;
|
|
428
|
+
for (const fixture of fixtures2) {
|
|
429
|
+
const oldExtraction = loader.extract(oldWasmPath, fixture.path, fixture.content);
|
|
430
|
+
const newExtraction = loader.extract(newWasmPath, fixture.path, fixture.content);
|
|
431
|
+
const oldCov = computeCoverage(fixture.path, fixture.content, oldExtraction);
|
|
432
|
+
const newCov = computeCoverage(fixture.path, fixture.content, newExtraction);
|
|
433
|
+
if (oldCov.coveragePct >= 0 && newCov.coveragePct >= 0) {
|
|
434
|
+
oldTotalCoverage += oldCov.coveragePct;
|
|
435
|
+
newTotalCoverage += newCov.coveragePct;
|
|
436
|
+
knownCount++;
|
|
437
|
+
}
|
|
438
|
+
const diff = diffExtractions(
|
|
439
|
+
fixture.path,
|
|
440
|
+
oldExtraction,
|
|
441
|
+
newExtraction,
|
|
442
|
+
oldCov.coveragePct,
|
|
443
|
+
newCov.coveragePct
|
|
444
|
+
);
|
|
445
|
+
diffs.push(diff);
|
|
446
|
+
fixtureResults.push({
|
|
447
|
+
fixturePath: newCov.fixturePath,
|
|
448
|
+
astSymbols: newCov.expectedSymbols.length,
|
|
449
|
+
extractedNodes: newCov.extractedNodes.length,
|
|
450
|
+
extractedEdges: newExtraction.edges.length,
|
|
451
|
+
coveragePct: newCov.coveragePct,
|
|
452
|
+
missingSymbols: newCov.missingSymbols,
|
|
453
|
+
extraNodes: newCov.extraNodes.map((n) => n.canonicalID)
|
|
454
|
+
});
|
|
455
|
+
}
|
|
456
|
+
const coverageDelta = knownCount > 0 ? (newTotalCoverage - oldTotalCoverage) / knownCount : 0;
|
|
457
|
+
const report = buildReport({
|
|
458
|
+
pluginName: newWasmPath,
|
|
459
|
+
pluginVersion: "unknown",
|
|
460
|
+
wasmHash: newHash,
|
|
461
|
+
fixtureResults,
|
|
462
|
+
validationErrors: []
|
|
463
|
+
});
|
|
464
|
+
report.diff = {
|
|
465
|
+
previousWasmHash: oldHash,
|
|
466
|
+
fixtures: diffs,
|
|
467
|
+
coverageDelta
|
|
468
|
+
};
|
|
469
|
+
if (opts.json) {
|
|
470
|
+
console.log(JSON.stringify(report, null, 2));
|
|
471
|
+
} else {
|
|
472
|
+
renderReport(report);
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
// src/commands/run.ts
|
|
477
|
+
import { readFileSync as readFileSync5 } from "fs";
|
|
478
|
+
import chalk2 from "chalk";
|
|
479
|
+
async function runExtract(wasmPath, fixturePath, opts) {
|
|
480
|
+
const loader = new PluginLoader(opts.ce);
|
|
481
|
+
const content = readFileSync5(fixturePath, "utf8");
|
|
482
|
+
const result = loader.extract(wasmPath, fixturePath, content);
|
|
483
|
+
if (opts.json) {
|
|
484
|
+
console.log(JSON.stringify(result, null, 2));
|
|
485
|
+
return;
|
|
486
|
+
}
|
|
487
|
+
console.log();
|
|
488
|
+
console.log(chalk2.bold(`Extraction: ${fixturePath}`));
|
|
489
|
+
console.log();
|
|
490
|
+
console.log(chalk2.bold(`Nodes (${result.nodes.length})`));
|
|
491
|
+
for (const node of result.nodes) {
|
|
492
|
+
console.log(` ${chalk2.cyan(node.type.padEnd(12))} ${node.label}`);
|
|
493
|
+
console.log(chalk2.dim(` ${node.canonicalID}`));
|
|
494
|
+
}
|
|
495
|
+
console.log();
|
|
496
|
+
console.log(chalk2.bold(`Edges (${result.edges.length})`));
|
|
497
|
+
for (const edge of result.edges) {
|
|
498
|
+
console.log(` ${chalk2.yellow(edge.type.padEnd(12))} ${edge.sourceID} \u2192 ${edge.targetID}`);
|
|
499
|
+
}
|
|
500
|
+
console.log();
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
// src/index.ts
|
|
504
|
+
var args = process.argv.slice(2);
|
|
505
|
+
function flag(name) {
|
|
506
|
+
return args.includes(`--${name}`);
|
|
507
|
+
}
|
|
508
|
+
function option(name, defaultVal) {
|
|
509
|
+
const idx = args.indexOf(`--${name}`);
|
|
510
|
+
return idx !== -1 && args[idx + 1] ? args[idx + 1] : defaultVal;
|
|
511
|
+
}
|
|
512
|
+
var json = flag("json");
|
|
513
|
+
var fixtures = option("fixtures", "./tests/fixtures");
|
|
514
|
+
var ce = option("ce", "ce");
|
|
515
|
+
var [command, ...rest] = args.filter((a) => !a.startsWith("--"));
|
|
516
|
+
switch (command) {
|
|
517
|
+
case "validate": {
|
|
518
|
+
const [wasmPath] = rest;
|
|
519
|
+
if (!wasmPath) {
|
|
520
|
+
console.error("Usage: ce-sandbox validate <file.wasm>");
|
|
521
|
+
process.exit(1);
|
|
522
|
+
}
|
|
523
|
+
runValidate(wasmPath, { json, ce }).catch(die);
|
|
524
|
+
break;
|
|
525
|
+
}
|
|
526
|
+
case "coverage": {
|
|
527
|
+
const [wasmPath] = rest;
|
|
528
|
+
if (!wasmPath) {
|
|
529
|
+
console.error("Usage: ce-sandbox coverage <file.wasm>");
|
|
530
|
+
process.exit(1);
|
|
531
|
+
}
|
|
532
|
+
runCoverage(wasmPath, { json, fixtures, ce }).catch(die);
|
|
533
|
+
break;
|
|
534
|
+
}
|
|
535
|
+
case "diff": {
|
|
536
|
+
const [oldWasm, newWasm] = rest;
|
|
537
|
+
if (!oldWasm || !newWasm) {
|
|
538
|
+
console.error("Usage: ce-sandbox diff <old.wasm> <new.wasm>");
|
|
539
|
+
process.exit(1);
|
|
540
|
+
}
|
|
541
|
+
runDiff(oldWasm, newWasm, { json, fixtures, ce }).catch(die);
|
|
542
|
+
break;
|
|
543
|
+
}
|
|
544
|
+
case "run": {
|
|
545
|
+
const [wasmPath, fixturePath] = rest;
|
|
546
|
+
if (!wasmPath || !fixturePath) {
|
|
547
|
+
console.error("Usage: ce-sandbox run <file.wasm> <fixture>");
|
|
548
|
+
process.exit(1);
|
|
549
|
+
}
|
|
550
|
+
runExtract(wasmPath, fixturePath, { json, ce }).catch(die);
|
|
551
|
+
break;
|
|
552
|
+
}
|
|
553
|
+
default:
|
|
554
|
+
console.log(`
|
|
555
|
+
ce-sandbox \u2014 Context Engine Plugin Sandbox
|
|
556
|
+
|
|
557
|
+
Commands:
|
|
558
|
+
validate <file.wasm> Validate a plugin file
|
|
559
|
+
coverage <file.wasm> Run coverage analysis against fixtures
|
|
560
|
+
diff <old.wasm> <new.wasm> Show extraction changes between builds
|
|
561
|
+
run <file.wasm> <fixture> Run extraction on a single file
|
|
562
|
+
|
|
563
|
+
Flags:
|
|
564
|
+
--json Output machine-readable JSON
|
|
565
|
+
--fixtures Path to fixtures directory (default: ./tests/fixtures)
|
|
566
|
+
--ce Path to ce binary (default: looks in PATH)
|
|
567
|
+
`);
|
|
568
|
+
process.exit(0);
|
|
569
|
+
}
|
|
570
|
+
function die(err) {
|
|
571
|
+
console.error(err instanceof Error ? err.message : String(err));
|
|
572
|
+
process.exit(1);
|
|
573
|
+
}
|
|
574
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/runner/loader.ts", "../src/output/render.ts", "../src/output/report.ts", "../src/commands/validate.ts", "../src/runner/fixtures.ts", "../src/analysis/ast.ts", "../src/analysis/coverage.ts", "../src/commands/coverage.ts", "../src/analysis/diff.ts", "../src/commands/diff.ts", "../src/commands/run.ts", "../src/index.ts"],
|
|
4
|
+
"sourcesContent": ["import { spawnSync } from \"child_process\"\nimport { writeFileSync, unlinkSync } from \"fs\"\nimport { tmpdir } from \"os\"\nimport { join } from \"path\"\nimport type { ExtractionResult } from \"@atheory-ai/ce-plugin-sdk\"\n\nexport class PluginLoader {\n private ceBinary: string\n\n constructor(ceBinary = \"ce\") {\n this.ceBinary = ceBinary\n this.validateBinary()\n }\n\n private validateBinary(): void {\n // No shell: run the binary directly with an argv array so a ceBinary value\n // like \"foo; rm -rf ~\" can't be interpreted as a shell command.\n const result = spawnSync(this.ceBinary, [\"version\"], { stdio: \"pipe\" })\n if (result.error || result.status !== 0) {\n throw new Error(\n `CE binary not found: ${this.ceBinary}\\n` +\n `Install it or specify path with --ce flag.`\n )\n }\n }\n\n validate(wasmPath: string): { passed: boolean; errors: string[]; output: string } {\n const result = spawnSync(this.ceBinary, [\"plugin\", \"validate\", wasmPath, \"--json\"], {\n encoding: \"utf8\",\n })\n\n if (result.status !== 0) {\n return { passed: false, errors: [result.stderr || \"validation failed\"], output: result.stdout }\n }\n\n try {\n const parsed = JSON.parse(result.stdout) as Record<string, unknown>\n return { passed: true, errors: [], output: result.stdout, ...parsed }\n } catch {\n return { passed: true, errors: [], output: result.stdout }\n }\n }\n\n extract(wasmPath: string, fixturePath: string, content: string): ExtractionResult {\n const tmpInput = join(tmpdir(), `ce-sandbox-${Date.now()}.json`)\n writeFileSync(tmpInput, JSON.stringify({ filePath: fixturePath, content }), \"utf8\")\n\n const result = spawnSync(\n this.ceBinary,\n [\"plugin\", \"extract\", wasmPath, \"--input\", tmpInput, \"--json\"],\n { encoding: \"utf8\" }\n )\n\n try { unlinkSync(tmpInput) } catch { /* ignore */ }\n\n if (result.status !== 0) {\n throw new Error(`Extraction failed: ${result.stderr}`)\n }\n\n return JSON.parse(result.stdout) as ExtractionResult\n }\n}\n", "import chalk from \"chalk\"\nimport type { SandboxReport } from \"./schema.js\"\n\nexport function renderReport(report: SandboxReport): void {\n console.log()\n console.log(chalk.bold(`${report.pluginName} v${report.pluginVersion}`))\n console.log(chalk.dim(`wasm: ${report.wasmHash.slice(0, 12)}...`))\n console.log()\n\n if (report.fixtureResults.length > 0) {\n console.log(chalk.bold(\"Coverage\"))\n console.log()\n\n for (const f of report.fixtureResults) {\n const pct = f.coveragePct === -1 ? \"N/A\" : `${f.coveragePct.toFixed(0)}%`\n const color = f.coveragePct >= 80 ? chalk.green\n : f.coveragePct >= 50 ? chalk.yellow\n : chalk.red\n const bar = coverageBar(f.coveragePct)\n\n console.log(` ${f.fixturePath}`)\n console.log(` ${color(pct.padStart(4))} ${bar} ${f.extractedNodes} nodes, ${f.extractedEdges} edges`)\n\n if (f.missingSymbols.length > 0 && f.missingSymbols.length <= 5) {\n console.log(chalk.dim(` missing: ${f.missingSymbols.join(\", \")}`))\n } else if (f.missingSymbols.length > 5) {\n console.log(chalk.dim(\n ` missing: ${f.missingSymbols.slice(0, 5).join(\", \")} +${f.missingSymbols.length - 5} more`\n ))\n }\n console.log()\n }\n\n const aggPct = report.aggregate.coveragePct\n const aggColor = aggPct >= 80 ? chalk.green : aggPct >= 50 ? chalk.yellow : chalk.red\n const aggStr = aggPct < 0 ? \"N/A\" : `${aggPct.toFixed(1)}%`\n console.log(\n ` ${chalk.bold(\"Total\")} ${aggColor(aggStr)} ` +\n `(${report.aggregate.totalExtractedNodes}/${report.aggregate.totalExpectedSymbols} symbols)`\n )\n console.log()\n }\n\n if (report.diff) {\n const delta = report.diff.coverageDelta\n const sign = delta > 0 ? \"+\" : \"\"\n const color = delta > 0 ? chalk.green : delta < 0 ? chalk.red : chalk.dim\n console.log(chalk.bold(\"Changes from previous build\"))\n console.log(` Coverage: ${color(`${sign}${delta.toFixed(1)}%`)}`)\n\n for (const f of report.diff.fixtures) {\n if (f.addedNodes.length > 0 || f.removedNodes.length > 0) {\n console.log(` ${f.fixture}`)\n if (f.addedNodes.length > 0) {\n console.log(chalk.green(` + ${f.addedNodes.length} nodes: ${f.addedNodes.slice(0, 3).join(\", \")}`))\n }\n if (f.removedNodes.length > 0) {\n console.log(chalk.red(` - ${f.removedNodes.length} nodes: ${f.removedNodes.slice(0, 3).join(\", \")}`))\n }\n }\n }\n console.log()\n }\n\n if (report.validation.errors.length > 0) {\n for (const err of report.validation.errors) {\n console.log(chalk.red(` \\u2717 ${err}`))\n }\n console.log()\n }\n\n if (report.validation.warnings.length > 0) {\n for (const warn of report.validation.warnings) {\n console.log(chalk.yellow(` \\u26A0 ${warn}`))\n }\n console.log()\n }\n\n if (report.validation.passed && report.validation.warnings.length === 0) {\n console.log(chalk.green(\" \\u2713 All checks passed\"))\n console.log()\n }\n}\n\nfunction coverageBar(pct: number): string {\n if (pct < 0) return chalk.dim(\"\\u2591\".repeat(10) + \" N/A\")\n const filled = Math.round(pct / 10)\n const empty = 10 - filled\n const color = pct >= 80 ? chalk.green : pct >= 50 ? chalk.yellow : chalk.red\n return color(\"\\u2588\".repeat(filled)) + chalk.dim(\"\\u2591\".repeat(empty))\n}\n", "import type { SandboxReport } from \"./schema.js\"\n\nexport function addValidationInsights(report: SandboxReport): void {\n const { aggregate, validation } = report\n\n if (aggregate.coveragePct >= 0 && aggregate.coveragePct < 80) {\n validation.warnings.push(\n `Coverage is ${aggregate.coveragePct.toFixed(1)}% \u2014 below the 80% recommended threshold. ` +\n `Review missing symbols and add extraction patterns for them.`\n )\n }\n\n for (const f of report.fixtureResults) {\n if (f.extractedNodes === 0 && f.astSymbols > 0) {\n validation.errors.push(\n `Fixture ${f.fixturePath}: plugin extracted 0 nodes from a file ` +\n `with ${f.astSymbols} expected symbols. ` +\n `Check that language.match() returns true for this file extension.`\n )\n validation.passed = false\n }\n }\n\n if (report.fixtureResults.length === 0) {\n validation.warnings.push(\n `No fixture files found. Add sample files to tests/fixtures/ to enable coverage analysis.`\n )\n }\n}\n\nexport function buildReport(params: {\n pluginName: string\n pluginVersion: string\n wasmHash: string\n fixtureResults: SandboxReport[\"fixtureResults\"]\n validationErrors: string[]\n}): SandboxReport {\n const { pluginName, pluginVersion, wasmHash, fixtureResults, validationErrors } = params\n\n const totalExpected = fixtureResults.reduce((s, f) => s + f.astSymbols, 0)\n const totalExtracted = fixtureResults.reduce((s, f) => s + f.extractedNodes, 0)\n const totalEdges = fixtureResults.reduce((s, f) => s + f.extractedEdges, 0)\n\n const knownFixtures = fixtureResults.filter(f => f.coveragePct >= 0)\n const coveragePct = knownFixtures.length > 0\n ? knownFixtures.reduce((s, f) => s + f.coveragePct, 0) / knownFixtures.length\n : -1\n\n const report: SandboxReport = {\n schemaVersion: 1,\n pluginName,\n pluginVersion,\n wasmHash,\n builtAt: Date.now(),\n fixtureResults,\n aggregate: {\n totalExpectedSymbols: totalExpected,\n totalExtractedNodes: totalExtracted,\n coveragePct,\n totalEdges,\n },\n validation: {\n passed: validationErrors.length === 0,\n errors: [...validationErrors],\n warnings: [],\n },\n }\n\n addValidationInsights(report)\n return report\n}\n", "import { PluginLoader } from \"../runner/loader.js\"\nimport { renderReport } from \"../output/render.js\"\nimport { buildReport } from \"../output/report.js\"\nimport { createHash } from \"crypto\"\nimport { readFileSync } from \"fs\"\n\nexport interface ValidateOptions {\n json: boolean\n ce: string\n}\n\nexport async function runValidate(wasmPath: string, opts: ValidateOptions): Promise<void> {\n const loader = new PluginLoader(opts.ce)\n\n const wasmBytes = readFileSync(wasmPath)\n const wasmHash = createHash(\"sha256\").update(wasmBytes).digest(\"hex\")\n\n const result = loader.validate(wasmPath)\n\n const report = buildReport({\n pluginName: wasmPath,\n pluginVersion: \"unknown\",\n wasmHash,\n fixtureResults: [],\n validationErrors: result.errors,\n })\n\n if (opts.json) {\n console.log(JSON.stringify(report, null, 2))\n } else {\n renderReport(report)\n }\n\n if (!result.passed) process.exit(1)\n}\n", "import { readdirSync, readFileSync, statSync } from \"fs\"\nimport { join } from \"path\"\n\nexport interface Fixture {\n path: string\n content: string\n}\n\nexport function loadFixtures(fixturesDir: string): Fixture[] {\n const fixtures: Fixture[] = []\n\n try {\n const entries = readdirSync(fixturesDir)\n for (const entry of entries) {\n const fullPath = join(fixturesDir, entry)\n const stat = statSync(fullPath)\n if (stat.isFile()) {\n const content = readFileSync(fullPath, \"utf8\")\n fixtures.push({ path: entry, content })\n }\n }\n } catch (err) {\n const e = err as NodeJS.ErrnoException\n if (e.code !== \"ENOENT\") throw err\n // fixtures dir doesn't exist \u2014 return empty\n }\n\n return fixtures\n}\n", "export interface ExpectedSymbol {\n name: string\n type: \"function\" | \"type\" | \"interface\" | \"method\" | \"const\" | \"var\" | \"class\" | \"other\"\n line: number\n}\n\nconst ENUMERATORS: Record<string, (content: string) => ExpectedSymbol[]> = {\n\n \".go\": (content: string): ExpectedSymbol[] => {\n const symbols: ExpectedSymbol[] = []\n const lines = content.split(\"\\n\")\n\n lines.forEach((line, i) => {\n const lineNum = i + 1\n const fnMatch = line.match(/^func\\s+(?:\\([^)]+\\)\\s+)?(\\w+)\\s*\\(/)\n if (fnMatch) symbols.push({ name: fnMatch[1], type: \"function\", line: lineNum })\n\n const typeMatch = line.match(/^type\\s+(\\w+)\\s+(?:struct|interface|func|\\w)/)\n if (typeMatch) symbols.push({ name: typeMatch[1], type: \"type\", line: lineNum })\n\n const constMatch = line.match(/^\\s{0,1}(\\w+)\\s*=/)\n if (constMatch && line.includes(\"const\")) {\n symbols.push({ name: constMatch[1], type: \"const\", line: lineNum })\n }\n })\n\n return symbols\n },\n\n \".ts\": (content: string): ExpectedSymbol[] => {\n const symbols: ExpectedSymbol[] = []\n const lines = content.split(\"\\n\")\n\n lines.forEach((line, i) => {\n const lineNum = i + 1\n const fnMatch = line.match(/^(?:export\\s+)?(?:async\\s+)?function\\s+(\\w+)/)\n if (fnMatch) symbols.push({ name: fnMatch[1], type: \"function\", line: lineNum })\n\n const classMatch = line.match(/^(?:export\\s+)?class\\s+(\\w+)/)\n if (classMatch) symbols.push({ name: classMatch[1], type: \"class\", line: lineNum })\n\n const ifaceMatch = line.match(/^(?:export\\s+)?interface\\s+(\\w+)/)\n if (ifaceMatch) symbols.push({ name: ifaceMatch[1], type: \"interface\", line: lineNum })\n\n const typeMatch = line.match(/^(?:export\\s+)?type\\s+(\\w+)\\s*=/)\n if (typeMatch) symbols.push({ name: typeMatch[1], type: \"type\", line: lineNum })\n })\n\n return symbols\n },\n\n \".py\": (content: string): ExpectedSymbol[] => {\n const symbols: ExpectedSymbol[] = []\n const lines = content.split(\"\\n\")\n\n lines.forEach((line, i) => {\n const lineNum = i + 1\n const fnMatch = line.match(/^(?:async\\s+)?def\\s+(\\w+)\\s*\\(/)\n if (fnMatch) symbols.push({ name: fnMatch[1], type: \"function\", line: lineNum })\n\n const classMatch = line.match(/^class\\s+(\\w+)/)\n if (classMatch) symbols.push({ name: classMatch[1], type: \"class\", line: lineNum })\n })\n\n return symbols\n },\n}\n\nexport function enumerateExpectedSymbols(\n filePath: string,\n content: string,\n): ExpectedSymbol[] | null {\n const ext = filePath.substring(filePath.lastIndexOf(\".\"))\n const enumerator = ENUMERATORS[ext]\n if (!enumerator) return null\n return enumerator(content)\n}\n", "import type { ExtractionResult, Node } from \"@atheory-ai/ce-plugin-sdk\"\nimport { enumerateExpectedSymbols, type ExpectedSymbol } from \"./ast.js\"\n\nexport interface FileCoverageResult {\n fixturePath: string\n expectedSymbols: ExpectedSymbol[]\n extractedNodes: Node[]\n matchedSymbols: string[]\n missingSymbols: string[]\n extraNodes: Node[]\n coveragePct: number\n}\n\nexport function computeCoverage(\n fixturePath: string,\n content: string,\n extraction: ExtractionResult,\n): FileCoverageResult {\n const expected = enumerateExpectedSymbols(fixturePath, content)\n\n // null means unsupported file type \u2014 coverage is not applicable\n if (expected === null) {\n return {\n fixturePath,\n expectedSymbols: [],\n extractedNodes: extraction.nodes,\n matchedSymbols: [],\n missingSymbols: [],\n extraNodes: extraction.nodes,\n coveragePct: -1,\n }\n }\n\n // known file type but no expected symbols (e.g. empty file)\n if (expected.length === 0) {\n return {\n fixturePath,\n expectedSymbols: [],\n extractedNodes: extraction.nodes,\n matchedSymbols: [],\n missingSymbols: [],\n extraNodes: extraction.nodes,\n coveragePct: 0,\n }\n }\n\n const matched: string[] = []\n const missing: string[] = []\n\n for (const sym of expected) {\n const covered = extraction.nodes.some(\n node =>\n node.label === sym.name ||\n node.canonicalID.endsWith(`:${sym.name}`) ||\n node.canonicalID.endsWith(`/${sym.name}`)\n )\n if (covered) {\n matched.push(sym.name)\n } else {\n missing.push(sym.name)\n }\n }\n\n const extra = extraction.nodes.filter(\n node => !expected.some(\n sym =>\n node.label === sym.name ||\n node.canonicalID.endsWith(`:${sym.name}`) ||\n node.canonicalID.endsWith(`/${sym.name}`)\n )\n )\n\n const coveragePct = expected.length > 0\n ? (matched.length / expected.length) * 100\n : 0\n\n return {\n fixturePath,\n expectedSymbols: expected,\n extractedNodes: extraction.nodes,\n matchedSymbols: matched,\n missingSymbols: missing,\n extraNodes: extra,\n coveragePct,\n }\n}\n", "import { PluginLoader } from \"../runner/loader.js\"\nimport { loadFixtures } from \"../runner/fixtures.js\"\nimport { computeCoverage } from \"../analysis/coverage.js\"\nimport { buildReport } from \"../output/report.js\"\nimport { renderReport } from \"../output/render.js\"\nimport { createHash } from \"crypto\"\nimport { readFileSync } from \"fs\"\nimport type { FixtureResult } from \"../output/schema.js\"\n\nexport interface CoverageOptions {\n json: boolean\n fixtures: string\n ce: string\n}\n\nexport async function runCoverage(wasmPath: string, opts: CoverageOptions): Promise<void> {\n const loader = new PluginLoader(opts.ce)\n const fixtures = loadFixtures(opts.fixtures)\n\n const wasmBytes = readFileSync(wasmPath)\n const wasmHash = createHash(\"sha256\").update(wasmBytes).digest(\"hex\")\n\n // Validate first\n const validation = loader.validate(wasmPath)\n\n const fixtureResults: FixtureResult[] = []\n\n for (const fixture of fixtures) {\n let extraction = { nodes: [], edges: [] }\n\n if (validation.passed) {\n try {\n extraction = loader.extract(wasmPath, fixture.path, fixture.content)\n } catch (err) {\n const msg = err instanceof Error ? err.message : String(err)\n validation.errors.push(`Extraction failed for ${fixture.path}: ${msg}`)\n validation.passed = false\n }\n }\n\n const cov = computeCoverage(fixture.path, fixture.content, extraction)\n\n fixtureResults.push({\n fixturePath: cov.fixturePath,\n astSymbols: cov.expectedSymbols.length,\n extractedNodes: cov.extractedNodes.length,\n extractedEdges: extraction.edges.length,\n coveragePct: cov.coveragePct,\n missingSymbols: cov.missingSymbols,\n extraNodes: cov.extraNodes.map(n => n.canonicalID),\n })\n }\n\n const report = buildReport({\n pluginName: wasmPath,\n pluginVersion: \"unknown\",\n wasmHash,\n fixtureResults,\n validationErrors: validation.errors,\n })\n\n if (opts.json) {\n console.log(JSON.stringify(report, null, 2))\n } else {\n renderReport(report)\n }\n\n if (!report.validation.passed) process.exit(1)\n}\n", "import type { ExtractionResult } from \"@atheory-ai/ce-plugin-sdk\"\n\nexport interface ExtractionDiff {\n fixture: string\n addedNodes: string[]\n removedNodes: string[]\n addedEdges: string[]\n removedEdges: string[]\n coverageDelta: number\n}\n\nexport function diffExtractions(\n fixture: string,\n oldResult: ExtractionResult,\n newResult: ExtractionResult,\n oldCoverage: number,\n newCoverage: number,\n): ExtractionDiff {\n const oldNodeIDs = new Set(oldResult.nodes.map(n => n.canonicalID))\n const newNodeIDs = new Set(newResult.nodes.map(n => n.canonicalID))\n\n const oldEdgeIDs = new Set(oldResult.edges.map(e => e.id))\n const newEdgeIDs = new Set(newResult.edges.map(e => e.id))\n\n return {\n fixture,\n addedNodes: [...newNodeIDs].filter(id => !oldNodeIDs.has(id)),\n removedNodes: [...oldNodeIDs].filter(id => !newNodeIDs.has(id)),\n addedEdges: [...newEdgeIDs].filter(id => !oldEdgeIDs.has(id)),\n removedEdges: [...oldEdgeIDs].filter(id => !newEdgeIDs.has(id)),\n coverageDelta: newCoverage - oldCoverage,\n }\n}\n", "import { PluginLoader } from \"../runner/loader.js\"\nimport { loadFixtures } from \"../runner/fixtures.js\"\nimport { computeCoverage } from \"../analysis/coverage.js\"\nimport { diffExtractions } from \"../analysis/diff.js\"\nimport { renderReport } from \"../output/render.js\"\nimport { buildReport } from \"../output/report.js\"\nimport { createHash } from \"crypto\"\nimport { readFileSync } from \"fs\"\nimport type { ExtractionDiff } from \"../analysis/diff.js\"\nimport type { FixtureResult } from \"../output/schema.js\"\n\nexport interface DiffOptions {\n json: boolean\n fixtures: string\n ce: string\n}\n\nexport async function runDiff(\n oldWasmPath: string,\n newWasmPath: string,\n opts: DiffOptions,\n): Promise<void> {\n const loader = new PluginLoader(opts.ce)\n const fixtures = loadFixtures(opts.fixtures)\n\n const oldBytes = readFileSync(oldWasmPath)\n const newBytes = readFileSync(newWasmPath)\n const oldHash = createHash(\"sha256\").update(oldBytes).digest(\"hex\")\n const newHash = createHash(\"sha256\").update(newBytes).digest(\"hex\")\n\n const fixtureResults: FixtureResult[] = []\n const diffs: ExtractionDiff[] = []\n let oldTotalCoverage = 0\n let newTotalCoverage = 0\n let knownCount = 0\n\n for (const fixture of fixtures) {\n const oldExtraction = loader.extract(oldWasmPath, fixture.path, fixture.content)\n const newExtraction = loader.extract(newWasmPath, fixture.path, fixture.content)\n\n const oldCov = computeCoverage(fixture.path, fixture.content, oldExtraction)\n const newCov = computeCoverage(fixture.path, fixture.content, newExtraction)\n\n if (oldCov.coveragePct >= 0 && newCov.coveragePct >= 0) {\n oldTotalCoverage += oldCov.coveragePct\n newTotalCoverage += newCov.coveragePct\n knownCount++\n }\n\n const diff = diffExtractions(\n fixture.path,\n oldExtraction,\n newExtraction,\n oldCov.coveragePct,\n newCov.coveragePct,\n )\n diffs.push(diff)\n\n fixtureResults.push({\n fixturePath: newCov.fixturePath,\n astSymbols: newCov.expectedSymbols.length,\n extractedNodes: newCov.extractedNodes.length,\n extractedEdges: newExtraction.edges.length,\n coveragePct: newCov.coveragePct,\n missingSymbols: newCov.missingSymbols,\n extraNodes: newCov.extraNodes.map(n => n.canonicalID),\n })\n }\n\n const coverageDelta = knownCount > 0\n ? (newTotalCoverage - oldTotalCoverage) / knownCount\n : 0\n\n const report = buildReport({\n pluginName: newWasmPath,\n pluginVersion: \"unknown\",\n wasmHash: newHash,\n fixtureResults,\n validationErrors: [],\n })\n\n report.diff = {\n previousWasmHash: oldHash,\n fixtures: diffs,\n coverageDelta,\n }\n\n if (opts.json) {\n console.log(JSON.stringify(report, null, 2))\n } else {\n renderReport(report)\n }\n}\n", "import { PluginLoader } from \"../runner/loader.js\"\nimport { readFileSync } from \"fs\"\nimport chalk from \"chalk\"\n\nexport interface RunOptions {\n json: boolean\n ce: string\n}\n\nexport async function runExtract(\n wasmPath: string,\n fixturePath: string,\n opts: RunOptions,\n): Promise<void> {\n const loader = new PluginLoader(opts.ce)\n const content = readFileSync(fixturePath, \"utf8\")\n\n const result = loader.extract(wasmPath, fixturePath, content)\n\n if (opts.json) {\n console.log(JSON.stringify(result, null, 2))\n return\n }\n\n console.log()\n console.log(chalk.bold(`Extraction: ${fixturePath}`))\n console.log()\n console.log(chalk.bold(`Nodes (${result.nodes.length})`))\n for (const node of result.nodes) {\n console.log(` ${chalk.cyan(node.type.padEnd(12))} ${node.label}`)\n console.log(chalk.dim(` ${node.canonicalID}`))\n }\n\n console.log()\n console.log(chalk.bold(`Edges (${result.edges.length})`))\n for (const edge of result.edges) {\n console.log(` ${chalk.yellow(edge.type.padEnd(12))} ${edge.sourceID} \u2192 ${edge.targetID}`)\n }\n console.log()\n}\n", "import { runValidate } from \"./commands/validate.js\"\nimport { runCoverage } from \"./commands/coverage.js\"\nimport { runDiff } from \"./commands/diff.js\"\nimport { runExtract } from \"./commands/run.js\"\n\nconst args = process.argv.slice(2)\n\nfunction flag(name: string): boolean {\n return args.includes(`--${name}`)\n}\n\nfunction option(name: string, defaultVal: string): string {\n const idx = args.indexOf(`--${name}`)\n return idx !== -1 && args[idx + 1] ? args[idx + 1] : defaultVal\n}\n\nconst json = flag(\"json\")\nconst fixtures = option(\"fixtures\", \"./tests/fixtures\")\nconst ce = option(\"ce\", \"ce\")\n\nconst [command, ...rest] = args.filter(a => !a.startsWith(\"--\"))\n\nswitch (command) {\n case \"validate\": {\n const [wasmPath] = rest\n if (!wasmPath) { console.error(\"Usage: ce-sandbox validate <file.wasm>\"); process.exit(1) }\n runValidate(wasmPath, { json, ce }).catch(die)\n break\n }\n case \"coverage\": {\n const [wasmPath] = rest\n if (!wasmPath) { console.error(\"Usage: ce-sandbox coverage <file.wasm>\"); process.exit(1) }\n runCoverage(wasmPath, { json, fixtures, ce }).catch(die)\n break\n }\n case \"diff\": {\n const [oldWasm, newWasm] = rest\n if (!oldWasm || !newWasm) {\n console.error(\"Usage: ce-sandbox diff <old.wasm> <new.wasm>\")\n process.exit(1)\n }\n runDiff(oldWasm, newWasm, { json, fixtures, ce }).catch(die)\n break\n }\n case \"run\": {\n const [wasmPath, fixturePath] = rest\n if (!wasmPath || !fixturePath) {\n console.error(\"Usage: ce-sandbox run <file.wasm> <fixture>\")\n process.exit(1)\n }\n runExtract(wasmPath, fixturePath, { json, ce }).catch(die)\n break\n }\n default:\n console.log(`\nce-sandbox \u2014 Context Engine Plugin Sandbox\n\nCommands:\n validate <file.wasm> Validate a plugin file\n coverage <file.wasm> Run coverage analysis against fixtures\n diff <old.wasm> <new.wasm> Show extraction changes between builds\n run <file.wasm> <fixture> Run extraction on a single file\n\nFlags:\n --json Output machine-readable JSON\n --fixtures Path to fixtures directory (default: ./tests/fixtures)\n --ce Path to ce binary (default: looks in PATH)\n`)\n process.exit(0)\n}\n\nfunction die(err: unknown): never {\n console.error(err instanceof Error ? err.message : String(err))\n process.exit(1)\n}\n"],
|
|
5
|
+
"mappings": ";;;AAAA,SAAS,iBAAiB;AAC1B,SAAS,eAAe,kBAAkB;AAC1C,SAAS,cAAc;AACvB,SAAS,YAAY;AAGd,IAAM,eAAN,MAAmB;AAAA,EAGxB,YAAY,WAAW,MAAM;AAC3B,SAAK,WAAW;AAChB,SAAK,eAAe;AAAA,EACtB;AAAA,EAEQ,iBAAuB;AAG7B,UAAM,SAAS,UAAU,KAAK,UAAU,CAAC,SAAS,GAAG,EAAE,OAAO,OAAO,CAAC;AACtE,QAAI,OAAO,SAAS,OA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D,cAAQ,KAAK,CAAC;AAAA,IAChB;AACA,YAAQ,SAAS,SAAS,EAAE,MAAM,UAAU,GAAG,CAAC,EAAE,MAAM,GAAG;AAC3D;AAAA,EACF;AAAA,EACA,KAAK,OAAO;AACV,UAAM,CAAC,UAAU,WAAW,IAAI;AAChC,QAAI,CAAC,YAAY,CAAC,aAAa;AAC7B,cAAQ,MAAM,6CAA6C;AAC3D,cAAQ,KAAK,CAAC;AAAA,IAChB;AACA,eAAW,UAAU,aAAa,EAAE,MAAM,GAAG,CAAC,EAAE,MAAM,GAAG;AACzD;AAAA,EACF;AAAA,EACA;AACE,YAAQ,IAAI;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAaf;AACG,YAAQ,KAAK,CAAC;AAClB;AAEA,SAAS,IAAI,KAAqB;AAChC,UAAQ,MAAM,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG,CAAC;AAC9D,UAAQ,KAAK,CAAC;AAChB;",
|
|
6
|
+
"names": ["readFileSync", "join", "fixtures", "createHash", "readFileSync", "fixtures", "createHash", "readFileSync", "fixtures", "readFileSync", "chalk"]
|
|
7
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@atheory-ai/ce-plugin-sandbox",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Local sandbox CLI for validating Context Engine plugins.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"ce-sandbox": "./dist/index.js"
|
|
8
|
+
},
|
|
9
|
+
"dependencies": {
|
|
10
|
+
"chalk": "^5.x",
|
|
11
|
+
"@atheory-ai/ce-plugin-sdk": "^0.1.0"
|
|
12
|
+
},
|
|
13
|
+
"devDependencies": {
|
|
14
|
+
"typescript": "*",
|
|
15
|
+
"esbuild": "*",
|
|
16
|
+
"vitest": "*",
|
|
17
|
+
"@types/node": "^20.x"
|
|
18
|
+
},
|
|
19
|
+
"license": "Apache-2.0",
|
|
20
|
+
"engines": {
|
|
21
|
+
"node": ">=20"
|
|
22
|
+
},
|
|
23
|
+
"homepage": "https://github.com/atheory-ai/context-engine/tree/main/sdk#readme",
|
|
24
|
+
"bugs": {
|
|
25
|
+
"url": "https://github.com/atheory-ai/context-engine/issues"
|
|
26
|
+
},
|
|
27
|
+
"repository": {
|
|
28
|
+
"type": "git",
|
|
29
|
+
"url": "git+https://github.com/atheory-ai/context-engine.git",
|
|
30
|
+
"directory": "sdk/packages/plugin-sandbox"
|
|
31
|
+
},
|
|
32
|
+
"publishConfig": {
|
|
33
|
+
"access": "public"
|
|
34
|
+
},
|
|
35
|
+
"files": [
|
|
36
|
+
"dist",
|
|
37
|
+
"README.md",
|
|
38
|
+
"LICENSE"
|
|
39
|
+
],
|
|
40
|
+
"keywords": [
|
|
41
|
+
"context-engine",
|
|
42
|
+
"plugin",
|
|
43
|
+
"wasm",
|
|
44
|
+
"validation",
|
|
45
|
+
"cli"
|
|
46
|
+
],
|
|
47
|
+
"scripts": {
|
|
48
|
+
"build": "node build.mjs && chmod +x dist/index.js",
|
|
49
|
+
"test": "vitest run",
|
|
50
|
+
"lint": "eslint src tests build.mjs --ext .ts,.js,.mjs",
|
|
51
|
+
"clean": "rm -rf dist"
|
|
52
|
+
}
|
|
53
|
+
}
|