@a16njs/engine 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +79 -0
- package/dist/index.d.ts +78 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +90 -0
- package/dist/index.js.map +1 -0
- package/package.json +48 -0
package/README.md
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
# @a16njs/engine
|
|
2
|
+
|
|
3
|
+
Conversion engine for a16n. Orchestrates plugins to convert between tools.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @a16njs/engine
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
import { A16nEngine } from '@a16njs/engine';
|
|
15
|
+
import cursorPlugin from '@a16njs/plugin-cursor';
|
|
16
|
+
import claudePlugin from '@a16njs/plugin-claude';
|
|
17
|
+
|
|
18
|
+
// Create engine with plugins
|
|
19
|
+
const engine = new A16nEngine([cursorPlugin, claudePlugin]);
|
|
20
|
+
|
|
21
|
+
// Convert from Cursor to Claude
|
|
22
|
+
const result = await engine.convert({
|
|
23
|
+
source: 'cursor',
|
|
24
|
+
target: 'claude',
|
|
25
|
+
root: './my-project',
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
console.log(`Discovered: ${result.discovered.length} items`);
|
|
29
|
+
console.log(`Written: ${result.written.length} files`);
|
|
30
|
+
console.log(`Warnings: ${result.warnings.length}`);
|
|
31
|
+
|
|
32
|
+
// Dry run (no writes)
|
|
33
|
+
const dryResult = await engine.convert({
|
|
34
|
+
source: 'cursor',
|
|
35
|
+
target: 'claude',
|
|
36
|
+
root: './my-project',
|
|
37
|
+
dryRun: true,
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
// Discover only
|
|
41
|
+
const discovery = await engine.discover('cursor', './my-project');
|
|
42
|
+
console.log(`Found: ${discovery.items.length} customizations`);
|
|
43
|
+
|
|
44
|
+
// List plugins
|
|
45
|
+
const plugins = engine.listPlugins();
|
|
46
|
+
plugins.forEach(p => console.log(`${p.id}: ${p.name}`));
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## API
|
|
50
|
+
|
|
51
|
+
### `new A16nEngine(plugins)`
|
|
52
|
+
|
|
53
|
+
Create an engine with the given plugins.
|
|
54
|
+
|
|
55
|
+
### `engine.convert(options)`
|
|
56
|
+
|
|
57
|
+
Convert customizations from source to target format.
|
|
58
|
+
|
|
59
|
+
Options:
|
|
60
|
+
- `source` - Source plugin ID
|
|
61
|
+
- `target` - Target plugin ID
|
|
62
|
+
- `root` - Project root directory
|
|
63
|
+
- `dryRun` - If true, only discover without writing
|
|
64
|
+
|
|
65
|
+
### `engine.discover(pluginId, root)`
|
|
66
|
+
|
|
67
|
+
Discover customizations using a specific plugin.
|
|
68
|
+
|
|
69
|
+
### `engine.listPlugins()`
|
|
70
|
+
|
|
71
|
+
List all registered plugins.
|
|
72
|
+
|
|
73
|
+
### `engine.getPlugin(id)`
|
|
74
|
+
|
|
75
|
+
Get a plugin by ID.
|
|
76
|
+
|
|
77
|
+
## License
|
|
78
|
+
|
|
79
|
+
MIT
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import type { A16nPlugin, AgentCustomization, DiscoveryResult, Warning, WrittenFile, CustomizationType } from '@a16njs/models';
|
|
2
|
+
/**
|
|
3
|
+
* Options for a conversion operation.
|
|
4
|
+
*/
|
|
5
|
+
export interface ConversionOptions {
|
|
6
|
+
/** Source plugin ID */
|
|
7
|
+
source: string;
|
|
8
|
+
/** Target plugin ID */
|
|
9
|
+
target: string;
|
|
10
|
+
/** Project root directory */
|
|
11
|
+
root: string;
|
|
12
|
+
/** If true, only discover without writing */
|
|
13
|
+
dryRun?: boolean;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Result of a conversion operation.
|
|
17
|
+
*/
|
|
18
|
+
export interface ConversionResult {
|
|
19
|
+
/** Items discovered from source */
|
|
20
|
+
discovered: AgentCustomization[];
|
|
21
|
+
/** Files written to target */
|
|
22
|
+
written: WrittenFile[];
|
|
23
|
+
/** Warnings from discovery and emission */
|
|
24
|
+
warnings: Warning[];
|
|
25
|
+
/** Items that couldn't be represented by target */
|
|
26
|
+
unsupported: AgentCustomization[];
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Information about a registered plugin.
|
|
30
|
+
*/
|
|
31
|
+
export interface PluginInfo {
|
|
32
|
+
id: string;
|
|
33
|
+
name: string;
|
|
34
|
+
supports: CustomizationType[];
|
|
35
|
+
source: 'bundled' | 'installed';
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* The a16n conversion engine.
|
|
39
|
+
* Orchestrates plugins to discover and emit agent customizations.
|
|
40
|
+
*/
|
|
41
|
+
export declare class A16nEngine {
|
|
42
|
+
private plugins;
|
|
43
|
+
/**
|
|
44
|
+
* Create a new engine with the given plugins.
|
|
45
|
+
* @param plugins - Plugins to register
|
|
46
|
+
*/
|
|
47
|
+
constructor(plugins?: A16nPlugin[]);
|
|
48
|
+
/**
|
|
49
|
+
* Register a plugin with the engine.
|
|
50
|
+
* @param plugin - The plugin to register
|
|
51
|
+
*/
|
|
52
|
+
registerPlugin(plugin: A16nPlugin): void;
|
|
53
|
+
/**
|
|
54
|
+
* List all registered plugins.
|
|
55
|
+
* @returns Array of plugin info
|
|
56
|
+
*/
|
|
57
|
+
listPlugins(): PluginInfo[];
|
|
58
|
+
/**
|
|
59
|
+
* Get a plugin by its ID.
|
|
60
|
+
* @param id - The plugin ID
|
|
61
|
+
* @returns The plugin or undefined if not found
|
|
62
|
+
*/
|
|
63
|
+
getPlugin(id: string): A16nPlugin | undefined;
|
|
64
|
+
/**
|
|
65
|
+
* Discover customizations using a specific plugin.
|
|
66
|
+
* @param pluginId - The plugin to use for discovery
|
|
67
|
+
* @param root - The project root to scan
|
|
68
|
+
* @returns Discovery result with items and warnings
|
|
69
|
+
*/
|
|
70
|
+
discover(pluginId: string, root: string): Promise<DiscoveryResult>;
|
|
71
|
+
/**
|
|
72
|
+
* Convert customizations from one format to another.
|
|
73
|
+
* @param options - Conversion options
|
|
74
|
+
* @returns Conversion result with discovered items, written files, and warnings
|
|
75
|
+
*/
|
|
76
|
+
convert(options: ConversionOptions): Promise<ConversionResult>;
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,UAAU,EACV,kBAAkB,EAClB,eAAe,EACf,OAAO,EACP,WAAW,EACX,iBAAiB,EAClB,MAAM,gBAAgB,CAAC;AAExB;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,uBAAuB;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,uBAAuB;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,6BAA6B;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,6CAA6C;IAC7C,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,mCAAmC;IACnC,UAAU,EAAE,kBAAkB,EAAE,CAAC;IACjC,8BAA8B;IAC9B,OAAO,EAAE,WAAW,EAAE,CAAC;IACvB,2CAA2C;IAC3C,QAAQ,EAAE,OAAO,EAAE,CAAC;IACpB,mDAAmD;IACnD,WAAW,EAAE,kBAAkB,EAAE,CAAC;CACnC;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,iBAAiB,EAAE,CAAC;IAC9B,MAAM,EAAE,SAAS,GAAG,WAAW,CAAC;CACjC;AAED;;;GAGG;AACH,qBAAa,UAAU;IACrB,OAAO,CAAC,OAAO,CAAsC;IAErD;;;OAGG;gBACS,OAAO,GAAE,UAAU,EAAO;IAMtC;;;OAGG;IACH,cAAc,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI;IAIxC;;;OAGG;IACH,WAAW,IAAI,UAAU,EAAE;IAS3B;;;;OAIG;IACH,SAAS,CAAC,EAAE,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS;IAI7C;;;;;OAKG;IACG,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC;IAQxE;;;;OAIG;IACG,OAAO,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,gBAAgB,CAAC;CAiCrE"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The a16n conversion engine.
|
|
3
|
+
* Orchestrates plugins to discover and emit agent customizations.
|
|
4
|
+
*/
|
|
5
|
+
export class A16nEngine {
|
|
6
|
+
plugins = new Map();
|
|
7
|
+
/**
|
|
8
|
+
* Create a new engine with the given plugins.
|
|
9
|
+
* @param plugins - Plugins to register
|
|
10
|
+
*/
|
|
11
|
+
constructor(plugins = []) {
|
|
12
|
+
for (const plugin of plugins) {
|
|
13
|
+
this.registerPlugin(plugin);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Register a plugin with the engine.
|
|
18
|
+
* @param plugin - The plugin to register
|
|
19
|
+
*/
|
|
20
|
+
registerPlugin(plugin) {
|
|
21
|
+
this.plugins.set(plugin.id, plugin);
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* List all registered plugins.
|
|
25
|
+
* @returns Array of plugin info
|
|
26
|
+
*/
|
|
27
|
+
listPlugins() {
|
|
28
|
+
return Array.from(this.plugins.values()).map((p) => ({
|
|
29
|
+
id: p.id,
|
|
30
|
+
name: p.name,
|
|
31
|
+
supports: p.supports,
|
|
32
|
+
source: 'bundled',
|
|
33
|
+
}));
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Get a plugin by its ID.
|
|
37
|
+
* @param id - The plugin ID
|
|
38
|
+
* @returns The plugin or undefined if not found
|
|
39
|
+
*/
|
|
40
|
+
getPlugin(id) {
|
|
41
|
+
return this.plugins.get(id);
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Discover customizations using a specific plugin.
|
|
45
|
+
* @param pluginId - The plugin to use for discovery
|
|
46
|
+
* @param root - The project root to scan
|
|
47
|
+
* @returns Discovery result with items and warnings
|
|
48
|
+
*/
|
|
49
|
+
async discover(pluginId, root) {
|
|
50
|
+
const plugin = this.getPlugin(pluginId);
|
|
51
|
+
if (!plugin) {
|
|
52
|
+
throw new Error(`Unknown plugin: ${pluginId}`);
|
|
53
|
+
}
|
|
54
|
+
return plugin.discover(root);
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Convert customizations from one format to another.
|
|
58
|
+
* @param options - Conversion options
|
|
59
|
+
* @returns Conversion result with discovered items, written files, and warnings
|
|
60
|
+
*/
|
|
61
|
+
async convert(options) {
|
|
62
|
+
const sourcePlugin = this.getPlugin(options.source);
|
|
63
|
+
const targetPlugin = this.getPlugin(options.target);
|
|
64
|
+
if (!sourcePlugin) {
|
|
65
|
+
throw new Error(`Unknown source: ${options.source}`);
|
|
66
|
+
}
|
|
67
|
+
if (!targetPlugin) {
|
|
68
|
+
throw new Error(`Unknown target: ${options.target}`);
|
|
69
|
+
}
|
|
70
|
+
// Discover from source
|
|
71
|
+
const discovery = await sourcePlugin.discover(options.root);
|
|
72
|
+
if (options.dryRun) {
|
|
73
|
+
return {
|
|
74
|
+
discovered: discovery.items,
|
|
75
|
+
written: [],
|
|
76
|
+
warnings: discovery.warnings,
|
|
77
|
+
unsupported: [],
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
// Emit to target
|
|
81
|
+
const emission = await targetPlugin.emit(discovery.items, options.root);
|
|
82
|
+
return {
|
|
83
|
+
discovered: discovery.items,
|
|
84
|
+
written: emission.written,
|
|
85
|
+
warnings: [...discovery.warnings, ...emission.warnings],
|
|
86
|
+
unsupported: emission.unsupported,
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AA+CA;;;GAGG;AACH,MAAM,OAAO,UAAU;IACb,OAAO,GAA4B,IAAI,GAAG,EAAE,CAAC;IAErD;;;OAGG;IACH,YAAY,UAAwB,EAAE;QACpC,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;YAC7B,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;QAC9B,CAAC;IACH,CAAC;IAED;;;OAGG;IACH,cAAc,CAAC,MAAkB;QAC/B,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC;IACtC,CAAC;IAED;;;OAGG;IACH,WAAW;QACT,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;YACnD,EAAE,EAAE,CAAC,CAAC,EAAE;YACR,IAAI,EAAE,CAAC,CAAC,IAAI;YACZ,QAAQ,EAAE,CAAC,CAAC,QAAQ;YACpB,MAAM,EAAE,SAAkB;SAC3B,CAAC,CAAC,CAAC;IACN,CAAC;IAED;;;;OAIG;IACH,SAAS,CAAC,EAAU;QAClB,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAC9B,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,QAAQ,CAAC,QAAgB,EAAE,IAAY;QAC3C,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CA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CAAC;YACvD,WAAW,EAAE,QAAQ,CAAC,WAAW;SAClC,CAAC;IACJ,CAAC;CACF"}
|
package/package.json
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@a16njs/engine",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Conversion engine for a16n",
|
|
5
|
+
"license": "AGPL-3.0",
|
|
6
|
+
"author": "Texarkanine",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/Texarkanine/a16n.git",
|
|
10
|
+
"directory": "packages/engine"
|
|
11
|
+
},
|
|
12
|
+
"homepage": "https://github.com/Texarkanine/a16n#readme",
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/Texarkanine/a16n/issues"
|
|
15
|
+
},
|
|
16
|
+
"keywords": [
|
|
17
|
+
"a16n",
|
|
18
|
+
"engine",
|
|
19
|
+
"conversion"
|
|
20
|
+
],
|
|
21
|
+
"type": "module",
|
|
22
|
+
"main": "./dist/index.js",
|
|
23
|
+
"types": "./dist/index.d.ts",
|
|
24
|
+
"exports": {
|
|
25
|
+
".": {
|
|
26
|
+
"types": "./dist/index.d.ts",
|
|
27
|
+
"import": "./dist/index.js"
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
"files": ["dist"],
|
|
31
|
+
"scripts": {
|
|
32
|
+
"build": "tsc",
|
|
33
|
+
"clean": "rimraf dist *.tsbuildinfo",
|
|
34
|
+
"typecheck": "tsc --noEmit",
|
|
35
|
+
"test": "vitest run",
|
|
36
|
+
"test:watch": "vitest"
|
|
37
|
+
},
|
|
38
|
+
"dependencies": {
|
|
39
|
+
"@a16njs/models": "workspace:*"
|
|
40
|
+
},
|
|
41
|
+
"devDependencies": {
|
|
42
|
+
"@a16njs/plugin-cursor": "workspace:*",
|
|
43
|
+
"@a16njs/plugin-claude": "workspace:*",
|
|
44
|
+
"@types/node": "^20.0.0",
|
|
45
|
+
"typescript": "^5.4.0",
|
|
46
|
+
"vitest": "^2.0.0"
|
|
47
|
+
}
|
|
48
|
+
}
|