@atheory-ai/ce-plugin-sdk 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 +86 -0
- package/dist/abi.d.ts +33 -0
- package/dist/abi.d.ts.map +1 -0
- package/dist/abi.js +162 -0
- package/dist/abi.js.map +7 -0
- package/dist/build/ce-abi.d.ts +7 -0
- package/dist/build/ce-abi.d.ts.map +1 -0
- package/dist/build/ce-abi.js +65 -0
- package/dist/build/ce-abi.js.map +7 -0
- package/dist/define.d.ts +18 -0
- package/dist/define.d.ts.map +1 -0
- package/dist/effects.d.ts +21 -0
- package/dist/effects.d.ts.map +1 -0
- package/dist/eslint/index.d.ts +29 -0
- package/dist/eslint/index.d.ts.map +1 -0
- package/dist/eslint/index.js +309 -0
- package/dist/eslint/index.js.map +7 -0
- package/dist/eslint/rules/concept-term-format.d.ts +4 -0
- package/dist/eslint/rules/concept-term-format.d.ts.map +1 -0
- package/dist/eslint/rules/extract-return-type.d.ts +4 -0
- package/dist/eslint/rules/extract-return-type.d.ts.map +1 -0
- package/dist/eslint/rules/id-helpers-required.d.ts +4 -0
- package/dist/eslint/rules/id-helpers-required.d.ts.map +1 -0
- package/dist/eslint/rules/no-node-apis.d.ts +4 -0
- package/dist/eslint/rules/no-node-apis.d.ts.map +1 -0
- package/dist/eslint/rules/pure-activate.d.ts +4 -0
- package/dist/eslint/rules/pure-activate.d.ts.map +1 -0
- package/dist/eslint/rules/tool-description-length.d.ts +4 -0
- package/dist/eslint/rules/tool-description-length.d.ts.map +1 -0
- package/dist/host.d.ts +13 -0
- package/dist/host.d.ts.map +1 -0
- package/dist/iir.d.ts +83 -0
- package/dist/iir.d.ts.map +1 -0
- package/dist/index.cjs +267 -0
- package/dist/index.cjs.map +7 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +244 -0
- package/dist/index.js.map +7 -0
- package/dist/tree.d.ts +27 -0
- package/dist/tree.d.ts.map +1 -0
- package/dist/types.d.ts +175 -0
- package/dist/types.d.ts.map +1 -0
- package/package.json +84 -0
- package/tsconfig.plugin.json +7 -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,86 @@
|
|
|
1
|
+
# @atheory-ai/ce-plugin-sdk
|
|
2
|
+
|
|
3
|
+
TypeScript SDK for authoring Context Engine plugins.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pnpm add @atheory-ai/ce-plugin-sdk
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
import { definePlugin, nodeID, edgeID } from "@atheory-ai/ce-plugin-sdk"
|
|
15
|
+
|
|
16
|
+
export default definePlugin({
|
|
17
|
+
id: "com.example.my-plugin",
|
|
18
|
+
name: "My Plugin",
|
|
19
|
+
version: "1.0.0",
|
|
20
|
+
|
|
21
|
+
language: {
|
|
22
|
+
match: (filePath) => filePath.endsWith(".myext"),
|
|
23
|
+
extract: (filePath, content, tree) => ({
|
|
24
|
+
nodes: [/* ... */],
|
|
25
|
+
edges: [/* ... */],
|
|
26
|
+
}),
|
|
27
|
+
},
|
|
28
|
+
})
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
`extract` receives `tree` — the host's tree-sitter CST for the file. Walk it
|
|
32
|
+
instead of matching raw text; the host already parsed the file.
|
|
33
|
+
|
|
34
|
+
## What a plugin can provide
|
|
35
|
+
|
|
36
|
+
- **`language`** — `match` + `extract` for a file type. To support a language
|
|
37
|
+
the engine doesn't bundle (go, python, javascript, typescript, tsx), ship a
|
|
38
|
+
tree-sitter grammar WASM and declare it — the host loads it at runtime, no
|
|
39
|
+
engine rebuild:
|
|
40
|
+
|
|
41
|
+
```typescript
|
|
42
|
+
language: {
|
|
43
|
+
match: (p) => p.endsWith(".ex"),
|
|
44
|
+
extensions: [".ex", ".exs"],
|
|
45
|
+
grammar: "elixir.wasm", // bundled next to the plugin .wasm
|
|
46
|
+
extract: (filePath, content, tree) => ({ nodes: [], edges: [] }),
|
|
47
|
+
}
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
- **IIR lift** — `extract` may return `iir` alongside `nodes`/`edges`: a
|
|
51
|
+
`FunctionIntent` per function, attached to its symbol node. This is how the
|
|
52
|
+
engine gets [intent representation](https://github.com/atheory-ai/context-engine/blob/main/docs/iir.md)
|
|
53
|
+
for a language.
|
|
54
|
+
|
|
55
|
+
- **`iirRules`** — a conformance rule pack the host merges over its defaults
|
|
56
|
+
(e.g. forbid `== null` conditions). Declarative; no runtime call.
|
|
57
|
+
|
|
58
|
+
- **`analyzers`**, **`tools`**, **`role`**, **`concepts`** — graph analyzers,
|
|
59
|
+
cognitive tools, an agent role, and domain concept seeds.
|
|
60
|
+
|
|
61
|
+
## Key Constraints
|
|
62
|
+
|
|
63
|
+
- No Node.js APIs (`fs`, `path`, `process`) — plugins run in a WASM sandbox
|
|
64
|
+
- Always use `nodeID()` and `edgeID()` — never construct IDs manually
|
|
65
|
+
- Tool `description` must be ≤ 100 characters
|
|
66
|
+
- Concept `term` must be `lowercase-hyphenated`
|
|
67
|
+
- `activate()` must be a pure function
|
|
68
|
+
|
|
69
|
+
## ESLint Plugin
|
|
70
|
+
|
|
71
|
+
The SDK ships a flat-config ESLint plugin that enforces these constraints at lint time:
|
|
72
|
+
|
|
73
|
+
```js
|
|
74
|
+
import cePlugin from "@atheory-ai/ce-plugin-sdk/eslint-plugin-ce"
|
|
75
|
+
|
|
76
|
+
export default [cePlugin.configs.recommended]
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## Documentation
|
|
80
|
+
|
|
81
|
+
See the [SDK workspace in Context Engine](https://github.com/atheory-ai/context-engine/tree/main/sdk)
|
|
82
|
+
for examples, release compatibility, and contributor guidance.
|
|
83
|
+
|
|
84
|
+
## License
|
|
85
|
+
|
|
86
|
+
Apache-2.0
|
package/dist/abi.d.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { IIRRulePack, PluginDefinition } from "./types.js";
|
|
2
|
+
export interface PluginManifest {
|
|
3
|
+
id: string;
|
|
4
|
+
name: string;
|
|
5
|
+
version: string;
|
|
6
|
+
abi: {
|
|
7
|
+
name: string;
|
|
8
|
+
version: number;
|
|
9
|
+
callConvention: string;
|
|
10
|
+
};
|
|
11
|
+
capabilities: {
|
|
12
|
+
language: boolean;
|
|
13
|
+
role: boolean;
|
|
14
|
+
analyzers: string[];
|
|
15
|
+
tools: string[];
|
|
16
|
+
};
|
|
17
|
+
language?: {
|
|
18
|
+
extensions: string[];
|
|
19
|
+
grammar?: string;
|
|
20
|
+
};
|
|
21
|
+
iirRules?: IIRRulePack;
|
|
22
|
+
}
|
|
23
|
+
export declare function buildPluginManifest(plugin: PluginDefinition): PluginManifest;
|
|
24
|
+
export declare function cePluginManifest(): void;
|
|
25
|
+
export declare function ceLanguageMatch(): void;
|
|
26
|
+
export declare function ceLanguageExtract(): void;
|
|
27
|
+
export declare function ceLanguageConcepts(): void;
|
|
28
|
+
export declare function ceAnalyzersList(): void;
|
|
29
|
+
export declare function ceAnalyzerRun(): void;
|
|
30
|
+
export declare function ceToolsList(): void;
|
|
31
|
+
export declare function ceToolActivate(): void;
|
|
32
|
+
export declare function ceToolExecute(): void;
|
|
33
|
+
//# sourceMappingURL=abi.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"abi.d.ts","sourceRoot":"","sources":["../src/abi.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAsB,WAAW,EAAQ,gBAAgB,EAA8C,MAAM,YAAY,CAAA;AAgCrI,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAQ,MAAM,CAAA;IAChB,IAAI,EAAM,MAAM,CAAA;IAChB,OAAO,EAAG,MAAM,CAAA;IAChB,GAAG,EAAO;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,cAAc,EAAE,MAAM,CAAA;KAAE,CAAA;IACnE,YAAY,EAAE;QACZ,QAAQ,EAAG,OAAO,CAAA;QAClB,IAAI,EAAO,OAAO,CAAA;QAClB,SAAS,EAAE,MAAM,EAAE,CAAA;QACnB,KAAK,EAAM,MAAM,EAAE,CAAA;KACpB,CAAA;IACD,QAAQ,CAAC,EAAE;QAAE,UAAU,EAAE,MAAM,EAAE,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,CAAA;IACrD,QAAQ,CAAC,EAAE,WAAW,CAAA;CACvB;AAID,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,gBAAgB,GAAG,cAAc,CAsB5E;AAED,wBAAgB,gBAAgB,IAAI,IAAI,CAEvC;AAED,wBAAgB,eAAe,IAAI,IAAI,CAUtC;AAED,wBAAgB,iBAAiB,IAAI,IAAI,CAmBxC;AAED,wBAAgB,kBAAkB,IAAI,IAAI,CAEzC;AAED,wBAAgB,eAAe,IAAI,IAAI,CAEtC;AAED,wBAAgB,aAAa,IAAI,IAAI,CAIpC;AAED,wBAAgB,WAAW,IAAI,IAAI,CAElC;AAED,wBAAgB,cAAc,IAAI,IAAI,CAIrC;AAED,wBAAgB,aAAa,IAAI,IAAI,CAapC"}
|
package/dist/abi.js
ADDED
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
// src/abi.ts
|
|
2
|
+
var g = globalThis;
|
|
3
|
+
installHostFallbacks();
|
|
4
|
+
function buildPluginManifest(plugin) {
|
|
5
|
+
return {
|
|
6
|
+
id: plugin.id,
|
|
7
|
+
name: plugin.name,
|
|
8
|
+
version: plugin.version,
|
|
9
|
+
abi: {
|
|
10
|
+
name: "ce-plugin",
|
|
11
|
+
version: 1,
|
|
12
|
+
callConvention: "javy-stream-io"
|
|
13
|
+
},
|
|
14
|
+
capabilities: {
|
|
15
|
+
language: Boolean(plugin.language),
|
|
16
|
+
role: Boolean(plugin.role),
|
|
17
|
+
analyzers: plugin.analyzers?.map((analyzer) => analyzer.name) ?? [],
|
|
18
|
+
tools: plugin.tools?.map((tool) => tool.name) ?? []
|
|
19
|
+
},
|
|
20
|
+
language: plugin.language ? { extensions: plugin.language.extensions ?? [], grammar: plugin.language.grammar } : void 0,
|
|
21
|
+
// Contributed IIR conformance rules; the host merges them over its defaults.
|
|
22
|
+
iirRules: plugin.iirRules
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
function cePluginManifest() {
|
|
26
|
+
writeJSON(buildPluginManifest(getPlugin()));
|
|
27
|
+
}
|
|
28
|
+
function ceLanguageMatch() {
|
|
29
|
+
const plugin = getPlugin();
|
|
30
|
+
if (!plugin.language) {
|
|
31
|
+
write("\0");
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
write(plugin.language.match(read()) ? "" : "\0");
|
|
35
|
+
}
|
|
36
|
+
function ceLanguageExtract() {
|
|
37
|
+
const plugin = getPlugin();
|
|
38
|
+
if (!plugin.language) {
|
|
39
|
+
writeJSON({ nodes: [], edges: [] });
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
const input = parseInput();
|
|
43
|
+
writeJSON(plugin.language.extract(
|
|
44
|
+
input.file_path ?? input.filePath ?? "",
|
|
45
|
+
input.content ?? "",
|
|
46
|
+
input.tree?.root ?? null
|
|
47
|
+
));
|
|
48
|
+
}
|
|
49
|
+
function ceLanguageConcepts() {
|
|
50
|
+
writeJSON(getPlugin().language?.concepts ?? []);
|
|
51
|
+
}
|
|
52
|
+
function ceAnalyzersList() {
|
|
53
|
+
writeJSON((getPlugin().analyzers ?? []).map((analyzer) => descriptor(analyzer)));
|
|
54
|
+
}
|
|
55
|
+
function ceAnalyzerRun() {
|
|
56
|
+
const analyzers = getPlugin().analyzers ?? [];
|
|
57
|
+
const nodes = parseInput();
|
|
58
|
+
writeJSON(analyzers.flatMap((analyzer) => analyzer.analyze(nodes)));
|
|
59
|
+
}
|
|
60
|
+
function ceToolsList() {
|
|
61
|
+
writeJSON((getPlugin().tools ?? []).map((tool) => descriptor(tool)));
|
|
62
|
+
}
|
|
63
|
+
function ceToolActivate() {
|
|
64
|
+
const input = parseInput();
|
|
65
|
+
const tool = findTool(input.tool_name ?? input.toolName ?? "");
|
|
66
|
+
write(tool?.activate(input.ir) ? "" : "\0");
|
|
67
|
+
}
|
|
68
|
+
function ceToolExecute() {
|
|
69
|
+
const input = parseInput();
|
|
70
|
+
const tool = findTool(input.tool_name ?? input.toolName ?? "");
|
|
71
|
+
if (!tool) {
|
|
72
|
+
writeJSON({ emissions: [], proposedNodes: [], proposedEdges: [] });
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
writeJSON(tool.execute(input.request, {
|
|
76
|
+
query(q) {
|
|
77
|
+
const result = g.__ce_substrate_query?.(JSON.stringify(q)) ?? "[]";
|
|
78
|
+
return JSON.parse(result);
|
|
79
|
+
}
|
|
80
|
+
}));
|
|
81
|
+
}
|
|
82
|
+
function getPlugin() {
|
|
83
|
+
if (!g.__ce_plugin_definition) {
|
|
84
|
+
throw new Error("CE plugin definition was not registered");
|
|
85
|
+
}
|
|
86
|
+
return g.__ce_plugin_definition;
|
|
87
|
+
}
|
|
88
|
+
function findTool(name) {
|
|
89
|
+
return getPlugin().tools?.find((tool) => tool.name === name);
|
|
90
|
+
}
|
|
91
|
+
function descriptor(item) {
|
|
92
|
+
return { name: item.name, description: item.description ?? "" };
|
|
93
|
+
}
|
|
94
|
+
function parseInput() {
|
|
95
|
+
const raw = read();
|
|
96
|
+
return raw ? JSON.parse(raw) : {};
|
|
97
|
+
}
|
|
98
|
+
function read() {
|
|
99
|
+
const chunks = [];
|
|
100
|
+
const buffer = new Uint8Array(4096);
|
|
101
|
+
for (; ; ) {
|
|
102
|
+
const n = Javy.IO.readSync(0, buffer);
|
|
103
|
+
if (n <= 0)
|
|
104
|
+
break;
|
|
105
|
+
chunks.push(buffer.slice(0, n));
|
|
106
|
+
}
|
|
107
|
+
const total = chunks.reduce((sum, chunk) => sum + chunk.length, 0);
|
|
108
|
+
const all = new Uint8Array(total);
|
|
109
|
+
let offset = 0;
|
|
110
|
+
for (const chunk of chunks) {
|
|
111
|
+
all.set(chunk, offset);
|
|
112
|
+
offset += chunk.length;
|
|
113
|
+
}
|
|
114
|
+
return new TextDecoder().decode(all);
|
|
115
|
+
}
|
|
116
|
+
function writeJSON(value) {
|
|
117
|
+
write(JSON.stringify(value));
|
|
118
|
+
}
|
|
119
|
+
function write(value) {
|
|
120
|
+
const buffer = new TextEncoder().encode(value);
|
|
121
|
+
let offset = 0;
|
|
122
|
+
while (offset < buffer.length) {
|
|
123
|
+
const written = Javy.IO.writeSync(1, buffer.subarray(offset));
|
|
124
|
+
if (written <= 0) {
|
|
125
|
+
throw new Error("failed to write CE plugin output");
|
|
126
|
+
}
|
|
127
|
+
offset += written;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
function installHostFallbacks() {
|
|
131
|
+
g.__ce_log ?? (g.__ce_log = () => void 0);
|
|
132
|
+
g.__ce_emit ?? (g.__ce_emit = () => void 0);
|
|
133
|
+
g.__ce_substrate_query ?? (g.__ce_substrate_query = () => "[]");
|
|
134
|
+
g.__ce_get_config ?? (g.__ce_get_config = () => "");
|
|
135
|
+
g.__ce_node_id ?? (g.__ce_node_id = (projectID, type, canonicalID) => stableID(`${projectID}:${type}:${canonicalID}`));
|
|
136
|
+
g.__ce_edge_id ?? (g.__ce_edge_id = (sourceID, type, targetID) => stableID(`${sourceID}:${type}:${targetID}`));
|
|
137
|
+
}
|
|
138
|
+
function stableID(input) {
|
|
139
|
+
let h1 = 3735928559;
|
|
140
|
+
let h2 = 1103547991;
|
|
141
|
+
for (let i = 0; i < input.length; i++) {
|
|
142
|
+
const ch = input.charCodeAt(i);
|
|
143
|
+
h1 = Math.imul(h1 ^ ch, 2654435761);
|
|
144
|
+
h2 = Math.imul(h2 ^ ch, 1597334677);
|
|
145
|
+
}
|
|
146
|
+
h1 = Math.imul(h1 ^ h1 >>> 16, 2246822507) ^ Math.imul(h2 ^ h2 >>> 13, 3266489909);
|
|
147
|
+
h2 = Math.imul(h2 ^ h2 >>> 16, 2246822507) ^ Math.imul(h1 ^ h1 >>> 13, 3266489909);
|
|
148
|
+
return `${(h2 >>> 0).toString(16).padStart(8, "0")}${(h1 >>> 0).toString(16).padStart(8, "0")}`;
|
|
149
|
+
}
|
|
150
|
+
export {
|
|
151
|
+
buildPluginManifest,
|
|
152
|
+
ceAnalyzerRun,
|
|
153
|
+
ceAnalyzersList,
|
|
154
|
+
ceLanguageConcepts,
|
|
155
|
+
ceLanguageExtract,
|
|
156
|
+
ceLanguageMatch,
|
|
157
|
+
cePluginManifest,
|
|
158
|
+
ceToolActivate,
|
|
159
|
+
ceToolExecute,
|
|
160
|
+
ceToolsList
|
|
161
|
+
};
|
|
162
|
+
//# sourceMappingURL=abi.js.map
|
package/dist/abi.js.map
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/abi.ts"],
|
|
4
|
+
"sourcesContent": ["import type { AnalyzerDefinition, IIRRulePack, Node, PluginDefinition, SubstrateQuery, SyntaxNode, ToolDefinition } from \"./types.js\"\n\ndeclare const Javy: {\n IO: {\n readSync(fd: number, buffer: Uint8Array): number\n writeSync(fd: number, buffer: Uint8Array): number\n }\n}\ndeclare const TextEncoder: {\n new(): { encode(value: string): Uint8Array }\n}\ndeclare const TextDecoder: {\n new(): { decode(value: Uint8Array): string }\n}\n\ntype GlobalWithPlugin = typeof globalThis & {\n __ce_plugin_definition?: PluginDefinition\n __ce_node_id?: (projectID: string, type: string, canonicalID: string) => string\n __ce_edge_id?: (sourceID: string, type: string, targetID: string) => string\n __ce_log?: (level: string, message: string) => void\n __ce_emit?: (channel: string, content: string) => void\n __ce_substrate_query?: (queryJSON: string) => string\n __ce_get_config?: (key: string) => string\n}\n\nconst g = globalThis as GlobalWithPlugin\n\ninstallHostFallbacks()\n\n// PluginManifest is the JSON shape emitted by ce_plugin_manifest, mirroring the\n// host's runtime.PluginManifest. Optional fields are omitted by JSON.stringify\n// when undefined, matching the host's omitempty decoding.\nexport interface PluginManifest {\n id: string\n name: string\n version: string\n abi: { name: string; version: number; callConvention: string }\n capabilities: {\n language: boolean\n role: boolean\n analyzers: string[]\n tools: string[]\n }\n language?: { extensions: string[]; grammar?: string }\n iirRules?: IIRRulePack\n}\n\n// buildPluginManifest is the pure manifest builder, kept separate from the IO so\n// it can be unit-tested.\nexport function buildPluginManifest(plugin: PluginDefinition): PluginManifest {\n return {\n id: plugin.id,\n name: plugin.name,\n version: plugin.version,\n abi: {\n name: \"ce-plugin\",\n version: 1,\n callConvention: \"javy-stream-io\",\n },\n capabilities: {\n language: Boolean(plugin.language),\n role: Boolean(plugin.role),\n analyzers: plugin.analyzers?.map((analyzer) => analyzer.name) ?? [],\n tools: plugin.tools?.map((tool) => tool.name) ?? [],\n },\n language: plugin.language\n ? { extensions: plugin.language.extensions ?? [], grammar: plugin.language.grammar }\n : undefined,\n // Contributed IIR conformance rules; the host merges them over its defaults.\n iirRules: plugin.iirRules,\n }\n}\n\nexport function cePluginManifest(): void {\n writeJSON(buildPluginManifest(getPlugin()))\n}\n\nexport function ceLanguageMatch(): void {\n const plugin = getPlugin()\n // The host reads a single byte: 0x01 = match, 0x00 = no match (see\n // ceToolActivate, which uses the same convention). Writing \"true\"/\"false\" as\n // text would be read as byte 't'/'f' and never match.\n if (!plugin.language) {\n write(\"\\x00\")\n return\n }\n write(plugin.language.match(read()) ? \"\\x01\" : \"\\x00\")\n}\n\nexport function ceLanguageExtract(): void {\n const plugin = getPlugin()\n if (!plugin.language) {\n writeJSON({ nodes: [], edges: [] })\n return\n }\n // The host sends the serialized tree as a { root, source, language } wrapper;\n // hand the extractor the root SyntaxNode directly.\n const input = parseInput<{\n file_path?: string\n filePath?: string\n content?: string\n tree?: { root?: SyntaxNode | null } | null\n }>()\n writeJSON(plugin.language.extract(\n input.file_path ?? input.filePath ?? \"\",\n input.content ?? \"\",\n input.tree?.root ?? null,\n ))\n}\n\nexport function ceLanguageConcepts(): void {\n writeJSON(getPlugin().language?.concepts ?? [])\n}\n\nexport function ceAnalyzersList(): void {\n writeJSON((getPlugin().analyzers ?? []).map((analyzer) => descriptor(analyzer)))\n}\n\nexport function ceAnalyzerRun(): void {\n const analyzers = getPlugin().analyzers ?? []\n const nodes = parseInput<Parameters<AnalyzerDefinition[\"analyze\"]>[0]>()\n writeJSON(analyzers.flatMap((analyzer) => analyzer.analyze(nodes)))\n}\n\nexport function ceToolsList(): void {\n writeJSON((getPlugin().tools ?? []).map((tool) => descriptor(tool)))\n}\n\nexport function ceToolActivate(): void {\n const input = parseInput<{ tool_name?: string; toolName?: string; ir: Parameters<ToolDefinition[\"activate\"]>[0] }>()\n const tool = findTool(input.tool_name ?? input.toolName ?? \"\")\n write(tool?.activate(input.ir) ? \"\\x01\" : \"\\x00\")\n}\n\nexport function ceToolExecute(): void {\n const input = parseInput<{ tool_name?: string; toolName?: string; request: Parameters<ToolDefinition[\"execute\"]>[0] }>()\n const tool = findTool(input.tool_name ?? input.toolName ?? \"\")\n if (!tool) {\n writeJSON({ emissions: [], proposedNodes: [], proposedEdges: [] })\n return\n }\n writeJSON(tool.execute(input.request, {\n query(q: SubstrateQuery): Node[] {\n const result = g.__ce_substrate_query?.(JSON.stringify(q)) ?? \"[]\"\n return JSON.parse(result) as Node[]\n },\n }))\n}\n\nfunction getPlugin(): PluginDefinition {\n if (!g.__ce_plugin_definition) {\n throw new Error(\"CE plugin definition was not registered\")\n }\n return g.__ce_plugin_definition\n}\n\nfunction findTool(name: string): ToolDefinition | undefined {\n return getPlugin().tools?.find((tool) => tool.name === name)\n}\n\nfunction descriptor(item: { name: string; description?: string }): { name: string; description: string } {\n return { name: item.name, description: item.description ?? \"\" }\n}\n\nfunction parseInput<T>(): T {\n const raw = read()\n return raw ? JSON.parse(raw) as T : {} as T\n}\n\nfunction read(): string {\n const chunks: Uint8Array[] = []\n const buffer = new Uint8Array(4096)\n for (;;) {\n const n = Javy.IO.readSync(0, buffer)\n if (n <= 0) break\n chunks.push(buffer.slice(0, n))\n }\n const total = chunks.reduce((sum, chunk) => sum + chunk.length, 0)\n const all = new Uint8Array(total)\n let offset = 0\n for (const chunk of chunks) {\n all.set(chunk, offset)\n offset += chunk.length\n }\n return new TextDecoder().decode(all)\n}\n\nfunction writeJSON(value: unknown): void {\n write(JSON.stringify(value))\n}\n\nfunction write(value: string): void {\n const buffer = new TextEncoder().encode(value)\n let offset = 0\n while (offset < buffer.length) {\n const written = Javy.IO.writeSync(1, buffer.subarray(offset))\n if (written <= 0) {\n throw new Error(\"failed to write CE plugin output\")\n }\n offset += written\n }\n}\n\nfunction installHostFallbacks(): void {\n g.__ce_log ??= () => undefined\n g.__ce_emit ??= () => undefined\n g.__ce_substrate_query ??= () => \"[]\"\n g.__ce_get_config ??= () => \"\"\n g.__ce_node_id ??= (projectID, type, canonicalID) => stableID(`${projectID}:${type}:${canonicalID}`)\n g.__ce_edge_id ??= (sourceID, type, targetID) => stableID(`${sourceID}:${type}:${targetID}`)\n}\n\nfunction stableID(input: string): string {\n let h1 = 0xdeadbeef\n let h2 = 0x41c6ce57\n for (let i = 0; i < input.length; i++) {\n const ch = input.charCodeAt(i)\n h1 = Math.imul(h1 ^ ch, 2654435761)\n h2 = Math.imul(h2 ^ ch, 1597334677)\n }\n h1 = Math.imul(h1 ^ (h1 >>> 16), 2246822507) ^ Math.imul(h2 ^ (h2 >>> 13), 3266489909)\n h2 = Math.imul(h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AACrB,IAAE,cAAF,EAAE,YAAc,MAAM;AACtB,IAAE,yBAAF,EAAE,uBAAyB,MAAM;AACjC,IAAE,oBAAF,EAAE,kBAAoB,MAAM;AAC5B,IAAE,iBAAF,EAAE,eAAiB,CAAC,WAAW,MAAM,gBAAgB,SAAS,GAAG,SAAS,IAAI,IAAI,IAAI,WAAW,EAAE;AACnG,IAAE,iBAAF,EAAE,eAAiB,CAAC,UAAU,MAAM,aAAa,SAAS,GAAG,QAAQ,IAAI,IAAI,IAAI,QAAQ,EAAE;AAC7F;AAEA,SAAS,SAAS,OAAuB;AACvC,MAAI,KAAK;AACT,MAAI,KAAK;AACT,WAAS,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK;AACrC,UAAM,KAAK,MAAM,WAAW,CAAC;AAC7B,SAAK,KAAK,KAAK,KAAK,IAAI,UAAU;AAClC,SAAK,KAAK,KAAK,KAAK,IAAI,UAAU;AAAA,EACpC;AACA,OAAK,KAAK,KAAK,KAAM,OAAO,IAAK,UAAU,IAAI,KAAK,KAAK,KAAM,OAAO,IAAK,UAAU;AACrF,OAAK,KAAK,KAAK,KAAM,OAAO,IAAK,UAAU,IAAI,KAAK,KAAK,KAAM,OAAO,IAAK,UAAU;AACrF,SAAO,IAAI,OAAO,GAAG,SAAS,EAAE,EAAE,SAAS,GAAG,GAAG,CAAC,IAAI,OAAO,GAAG,SAAS,EAAE,EAAE,SAAS,GAAG,GAAG,CAAC;AAC/F;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { AbiModule } from "@atheory-ai/wasm-plugin-toolkit";
|
|
2
|
+
type CEAbiModule = AbiModule & {
|
|
3
|
+
readonly callConvention: "javy-stream-io";
|
|
4
|
+
};
|
|
5
|
+
export declare const CE_PLUGIN_ABI: CEAbiModule;
|
|
6
|
+
export default CE_PLUGIN_ABI;
|
|
7
|
+
//# sourceMappingURL=ce-abi.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ce-abi.d.ts","sourceRoot":"","sources":["../../src/build/ce-abi.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAA;AAEhE,KAAK,WAAW,GAAG,SAAS,GAAG;IAC7B,QAAQ,CAAC,cAAc,EAAE,gBAAgB,CAAA;CAC1C,CAAA;AAED,eAAO,MAAM,aAAa,EAAE,WAyD3B,CAAA;AAED,eAAe,aAAa,CAAA"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
// src/build/ce-abi.ts
|
|
2
|
+
var CE_PLUGIN_ABI = {
|
|
3
|
+
name: "ce-plugin",
|
|
4
|
+
abiVersion: 1,
|
|
5
|
+
callConvention: "javy-stream-io",
|
|
6
|
+
wit: `package atheory:ce;
|
|
7
|
+
world plugin {
|
|
8
|
+
export ce-plugin-manifest: func();
|
|
9
|
+
export ce-language-match: func();
|
|
10
|
+
export ce-language-extract: func();
|
|
11
|
+
export ce-language-concepts: func();
|
|
12
|
+
export ce-analyzers-list: func();
|
|
13
|
+
export ce-analyzer-run: func();
|
|
14
|
+
export ce-tools-list: func();
|
|
15
|
+
export ce-tool-activate: func();
|
|
16
|
+
export ce-tool-execute: func();
|
|
17
|
+
}
|
|
18
|
+
`,
|
|
19
|
+
entryWrapper: ({ userEntryRelative }) => `
|
|
20
|
+
import plugin from "${userEntryRelative}"
|
|
21
|
+
import { definePlugin } from "@atheory-ai/ce-plugin-sdk"
|
|
22
|
+
import {
|
|
23
|
+
cePluginManifest,
|
|
24
|
+
ceLanguageMatch,
|
|
25
|
+
ceLanguageExtract,
|
|
26
|
+
ceLanguageConcepts,
|
|
27
|
+
ceAnalyzersList,
|
|
28
|
+
ceAnalyzerRun,
|
|
29
|
+
ceToolsList,
|
|
30
|
+
ceToolActivate,
|
|
31
|
+
ceToolExecute,
|
|
32
|
+
} from "@atheory-ai/ce-plugin-sdk/abi"
|
|
33
|
+
|
|
34
|
+
definePlugin(plugin)
|
|
35
|
+
|
|
36
|
+
export {
|
|
37
|
+
cePluginManifest,
|
|
38
|
+
ceLanguageMatch,
|
|
39
|
+
ceLanguageExtract,
|
|
40
|
+
ceLanguageConcepts,
|
|
41
|
+
ceAnalyzersList,
|
|
42
|
+
ceAnalyzerRun,
|
|
43
|
+
ceToolsList,
|
|
44
|
+
ceToolActivate,
|
|
45
|
+
ceToolExecute,
|
|
46
|
+
}
|
|
47
|
+
`,
|
|
48
|
+
requiredExports: [
|
|
49
|
+
"ce-plugin-manifest",
|
|
50
|
+
"ce-language-match",
|
|
51
|
+
"ce-language-extract",
|
|
52
|
+
"ce-language-concepts",
|
|
53
|
+
"ce-analyzers-list",
|
|
54
|
+
"ce-analyzer-run",
|
|
55
|
+
"ce-tools-list",
|
|
56
|
+
"ce-tool-activate",
|
|
57
|
+
"ce-tool-execute"
|
|
58
|
+
]
|
|
59
|
+
};
|
|
60
|
+
var ce_abi_default = CE_PLUGIN_ABI;
|
|
61
|
+
export {
|
|
62
|
+
CE_PLUGIN_ABI,
|
|
63
|
+
ce_abi_default as default
|
|
64
|
+
};
|
|
65
|
+
//# sourceMappingURL=ce-abi.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/build/ce-abi.ts"],
|
|
4
|
+
"sourcesContent": ["// CE plugin AbiModule for @atheory-ai/wasm-plugin-toolkit.\n//\n// Re-exported as `@atheory-ai/ce-plugin-sdk/build/abi` via package.json\n// exports so plugins can `import abi from \"@atheory-ai/ce-plugin-sdk/build/abi\"`\n// in their `wasm-toolkit.config.mjs`.\n\nimport type { AbiModule } from \"@atheory-ai/wasm-plugin-toolkit\"\n\ntype CEAbiModule = AbiModule & {\n readonly callConvention: \"javy-stream-io\"\n}\n\nexport const CE_PLUGIN_ABI: CEAbiModule = {\n name: \"ce-plugin\",\n abiVersion: 1,\n callConvention: \"javy-stream-io\",\n wit: `package atheory:ce;\nworld plugin {\n export ce-plugin-manifest: func();\n export ce-language-match: func();\n export ce-language-extract: func();\n export ce-language-concepts: func();\n export ce-analyzers-list: func();\n export ce-analyzer-run: func();\n export ce-tools-list: func();\n export ce-tool-activate: func();\n export ce-tool-execute: func();\n}\n`,\n entryWrapper: ({ userEntryRelative }) => `\nimport plugin from \"${userEntryRelative}\"\nimport { definePlugin } from \"@atheory-ai/ce-plugin-sdk\"\nimport {\n cePluginManifest,\n ceLanguageMatch,\n ceLanguageExtract,\n ceLanguageConcepts,\n ceAnalyzersList,\n ceAnalyzerRun,\n ceToolsList,\n ceToolActivate,\n ceToolExecute,\n} from \"@atheory-ai/ce-plugin-sdk/abi\"\n\ndefinePlugin(plugin)\n\nexport {\n cePluginManifest,\n ceLanguageMatch,\n ceLanguageExtract,\n ceLanguageConcepts,\n ceAnalyzersList,\n ceAnalyzerRun,\n ceToolsList,\n ceToolActivate,\n ceToolExecute,\n}\n`,\n requiredExports: [\n \"ce-plugin-manifest\",\n \"ce-language-match\",\n \"ce-language-extract\",\n \"ce-language-concepts\",\n \"ce-analyzers-list\",\n \"ce-analyzer-run\",\n \"ce-tools-list\",\n \"ce-tool-activate\",\n \"ce-tool-execute\",\n ],\n}\n\nexport default CE_PLUGIN_ABI\n"],
|
|
5
|
+
"mappings": ";AAYO,IAAM,gBAA6B;AAAA,EACxC,MAAM;AAAA,EACN,YAAY;AAAA,EACZ,gBAAgB;AAAA,EAChB,KAAK;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAaL,cAAc,CAAC,EAAE,kBAAkB,MAAM;AAAA,sBACrB,iBAAiB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EA4BrC,iBAAiB;AAAA,IACf;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;AAEA,IAAO,iBAAQ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/dist/define.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { PluginDefinition } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* definePlugin is the single entry point for all plugin authors.
|
|
4
|
+
*
|
|
5
|
+
* Usage:
|
|
6
|
+
* import { definePlugin } from "@atheory-ai/ce-plugin-sdk"
|
|
7
|
+
*
|
|
8
|
+
* export default definePlugin({
|
|
9
|
+
* id: "com.example.my-plugin",
|
|
10
|
+
* name: "My Plugin",
|
|
11
|
+
* version: "1.0.0",
|
|
12
|
+
* language: { match, extract, concepts },
|
|
13
|
+
* tools: [{ name, description, activate, execute }],
|
|
14
|
+
* })
|
|
15
|
+
*/
|
|
16
|
+
export declare function definePlugin(definition: PluginDefinition): PluginDefinition;
|
|
17
|
+
export declare function setPluginDefinition(definition: PluginDefinition): void;
|
|
18
|
+
//# sourceMappingURL=define.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"define.d.ts","sourceRoot":"","sources":["../src/define.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAElD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,YAAY,CAAC,UAAU,EAAE,gBAAgB,GAAG,gBAAgB,CA2F3E;AAED,wBAAgB,mBAAmB,CAAC,UAAU,EAAE,gBAAgB,GAAG,IAAI,CAKtE"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export type EffectKind = "network" | "db" | "io" | "log" | "mutation" | "unclassified";
|
|
2
|
+
export type EffectBasis = "resolved" | "heuristic";
|
|
3
|
+
export interface EffectClassifierInput {
|
|
4
|
+
/** The called method / function name, e.g. "Get", "track". */
|
|
5
|
+
method?: string;
|
|
6
|
+
/** The receiver root, e.g. "http", "analytics". */
|
|
7
|
+
root?: string;
|
|
8
|
+
/** Full import path of the root when it is an imported package, e.g. "net/http". */
|
|
9
|
+
importPath?: string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* classifyEffect returns the (kind, basis) for a detected effectful call. A call
|
|
13
|
+
* matched against a known effectful API — by import path or a recognized client
|
|
14
|
+
* root — is "resolved" (deterministic). A call categorized only from a
|
|
15
|
+
* method-name verb, or left uncategorized, is "heuristic" (a guess).
|
|
16
|
+
*/
|
|
17
|
+
export declare function classifyEffect(input: EffectClassifierInput): {
|
|
18
|
+
kind: EffectKind;
|
|
19
|
+
basis: EffectBasis;
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=effects.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"effects.d.ts","sourceRoot":"","sources":["../src/effects.ts"],"names":[],"mappings":"AAUA,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG,IAAI,GAAG,IAAI,GAAG,KAAK,GAAG,UAAU,GAAG,cAAc,CAAA;AAOtF,MAAM,MAAM,WAAW,GAAG,UAAU,GAAG,WAAW,CAAA;AAElD,MAAM,WAAW,qBAAqB;IACpC,8DAA8D;IAC9D,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,mDAAmD;IACnD,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,oFAAoF;IACpF,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB;AAwBD;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,qBAAqB,GAAG;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,KAAK,EAAE,WAAW,CAAA;CAAE,CAarG"}
|