@a16njs/engine 0.4.0 → 0.6.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/dist/index.d.ts +45 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +84 -19
- package/dist/index.js.map +1 -1
- package/dist/path-rewriter.d.ts +68 -0
- package/dist/path-rewriter.d.ts.map +1 -0
- package/dist/path-rewriter.js +144 -0
- package/dist/path-rewriter.js.map +1 -0
- package/dist/plugin-discovery.d.ts +64 -0
- package/dist/plugin-discovery.d.ts.map +1 -0
- package/dist/plugin-discovery.js +161 -0
- package/dist/plugin-discovery.js.map +1 -0
- package/dist/plugin-loader.d.ts +96 -0
- package/dist/plugin-loader.d.ts.map +1 -0
- package/dist/plugin-loader.js +112 -0
- package/dist/plugin-loader.js.map +1 -0
- package/dist/plugin-registry.d.ts +94 -0
- package/dist/plugin-registry.d.ts.map +1 -0
- package/dist/plugin-registry.js +89 -0
- package/dist/plugin-registry.js.map +1 -0
- package/dist/transformation.d.ts +93 -0
- package/dist/transformation.d.ts.map +1 -0
- package/dist/transformation.js +56 -0
- package/dist/transformation.js.map +1 -0
- package/dist/workspace.d.ts +73 -0
- package/dist/workspace.d.ts.map +1 -0
- package/dist/workspace.js +178 -0
- package/dist/workspace.js.map +1 -0
- package/package.json +4 -4
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transformation.d.ts","sourceRoot":"","sources":["../src/transformation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,UAAU,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAG1F;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,6BAA6B;IAC7B,KAAK,EAAE,kBAAkB,EAAE,CAAC;IAC5B,wBAAwB;IACxB,YAAY,EAAE,UAAU,CAAC;IACzB,wBAAwB;IACxB,YAAY,EAAE,UAAU,CAAC;IACzB,4CAA4C;IAC5C,UAAU,EAAE,MAAM,CAAC;IACnB,2CAA2C;IAC3C,UAAU,EAAE,MAAM,CAAC;IACnB;;;;;OAKG;IACH,SAAS,EAAE,CAAC,KAAK,EAAE,kBAAkB,EAAE,KAAK,OAAO,CAAC,UAAU,CAAC,CAAC;CACjE;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,4BAA4B;IAC5B,KAAK,EAAE,kBAAkB,EAAE,CAAC;IAC5B,+CAA+C;IAC/C,QAAQ,EAAE,OAAO,EAAE,CAAC;CACrB;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,WAAW,qBAAqB;IACpC,gDAAgD;IAChD,EAAE,EAAE,MAAM,CAAC;IACX,0BAA0B;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb;;;;OAIG;IACH,SAAS,CAAC,OAAO,EAAE,qBAAqB,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;CAC1E;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,qBAAa,2BAA4B,YAAW,qBAAqB;IACvE,QAAQ,CAAC,EAAE,oBAAoB;IAC/B,QAAQ,CAAC,IAAI,8BAA8B;IAErC,SAAS,CAAC,OAAO,EAAE,qBAAqB,GAAG,OAAO,CAAC,oBAAoB,CAAC;CA0C/E"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { buildMapping, rewriteContent, detectOrphans } from './path-rewriter.js';
|
|
2
|
+
/**
|
|
3
|
+
* Path rewriting transformation.
|
|
4
|
+
*
|
|
5
|
+
* Rewrites file path references in content during format conversion.
|
|
6
|
+
* Uses a trial emission to discover the source-to-target path mapping,
|
|
7
|
+
* then rewrites all path references in content. Also detects orphan
|
|
8
|
+
* references (paths that weren't converted) using plugin-provided
|
|
9
|
+
* path patterns.
|
|
10
|
+
*
|
|
11
|
+
* This replaces the hardcoded path rewriting logic that was previously
|
|
12
|
+
* embedded in the engine's convert() method, eliminating the need for
|
|
13
|
+
* double emission and removing hardcoded plugin knowledge.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```typescript
|
|
17
|
+
* const transform = new PathRewritingTransformation();
|
|
18
|
+
* engine.convert({
|
|
19
|
+
* source: 'cursor',
|
|
20
|
+
* target: 'claude',
|
|
21
|
+
* root: '/project',
|
|
22
|
+
* transformations: [transform],
|
|
23
|
+
* });
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export class PathRewritingTransformation {
|
|
27
|
+
id = 'path-rewriting';
|
|
28
|
+
name = 'Path Reference Rewriting';
|
|
29
|
+
async transform(context) {
|
|
30
|
+
const warnings = [];
|
|
31
|
+
// Trial emit to discover the path mapping
|
|
32
|
+
const trialResult = await context.trialEmit(context.items);
|
|
33
|
+
if (trialResult.written.length === 0) {
|
|
34
|
+
// No files would be written → no mapping → return cloned items
|
|
35
|
+
return {
|
|
36
|
+
items: context.items.map((item) => ({ ...item })),
|
|
37
|
+
warnings,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
// Build mapping from source paths to target paths
|
|
41
|
+
const mapping = buildMapping(context.items, trialResult.written, context.sourceRoot, context.targetRoot);
|
|
42
|
+
// Rewrite path references in content
|
|
43
|
+
const rewriteResult = rewriteContent(context.items, mapping);
|
|
44
|
+
// Detect orphan references using plugin-provided path patterns
|
|
45
|
+
const patterns = context.sourcePlugin.pathPatterns;
|
|
46
|
+
if (patterns && patterns.prefixes.length > 0 && patterns.extensions.length > 0) {
|
|
47
|
+
const orphanWarnings = detectOrphans(rewriteResult.items, mapping, patterns.prefixes, patterns.extensions);
|
|
48
|
+
warnings.push(...orphanWarnings);
|
|
49
|
+
}
|
|
50
|
+
return {
|
|
51
|
+
items: rewriteResult.items,
|
|
52
|
+
warnings,
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=transformation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transformation.js","sourceRoot":"","sources":["../src/transformation.ts"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pB,CAAC;YACF,QAAQ,CAAC,IAAI,CAAC,GAAG,cAAc,CAAC,CAAC;QACnC,CAAC;QAED,OAAO;YACL,KAAK,EAAE,aAAa,CAAC,KAAK;YAC1B,QAAQ;SACT,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import type { Workspace, WorkspaceEntry } from '@a16njs/models';
|
|
2
|
+
export type { Workspace, WorkspaceEntry } from '@a16njs/models';
|
|
3
|
+
export { LocalWorkspace, toWorkspace } from '@a16njs/models';
|
|
4
|
+
/**
|
|
5
|
+
* Read-only wrapper around another workspace.
|
|
6
|
+
* Allows read operations but throws on any write operation.
|
|
7
|
+
* Useful for dry-run scenarios.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* const ws = new LocalWorkspace('source', '/project');
|
|
12
|
+
* const readOnly = new ReadOnlyWorkspace(ws);
|
|
13
|
+
* await readOnly.read('file.md'); // works
|
|
14
|
+
* await readOnly.write('file.md', 'content'); // throws!
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
export declare class ReadOnlyWorkspace implements Workspace {
|
|
18
|
+
private readonly underlying;
|
|
19
|
+
/**
|
|
20
|
+
* Create a new ReadOnlyWorkspace wrapping another workspace.
|
|
21
|
+
* @param underlying - The workspace to wrap
|
|
22
|
+
*/
|
|
23
|
+
constructor(underlying: Workspace);
|
|
24
|
+
get id(): string;
|
|
25
|
+
get root(): string;
|
|
26
|
+
resolve(relativePath: string): string;
|
|
27
|
+
exists(relativePath: string): Promise<boolean>;
|
|
28
|
+
read(relativePath: string): Promise<string>;
|
|
29
|
+
write(_relativePath: string, _content: string): Promise<void>;
|
|
30
|
+
readdir(relativePath: string): Promise<WorkspaceEntry[]>;
|
|
31
|
+
mkdir(_relativePath: string): Promise<void>;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* In-memory workspace for testing.
|
|
35
|
+
* Stores files in a Map, no filesystem access.
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```typescript
|
|
39
|
+
* const ws = new MemoryWorkspace('test');
|
|
40
|
+
* await ws.write('rules/my-rule.md', '# Rule');
|
|
41
|
+
* const content = await ws.read('rules/my-rule.md');
|
|
42
|
+
* const entries = await ws.readdir('rules');
|
|
43
|
+
* // entries: [{ name: 'my-rule.md', isFile: true, isDirectory: false }]
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
export declare class MemoryWorkspace implements Workspace {
|
|
47
|
+
readonly id: string;
|
|
48
|
+
readonly root: string;
|
|
49
|
+
private files;
|
|
50
|
+
private directories;
|
|
51
|
+
/**
|
|
52
|
+
* Create a new MemoryWorkspace.
|
|
53
|
+
* @param id - Unique identifier for this workspace
|
|
54
|
+
* @param initialFiles - Optional map of relative paths to file contents
|
|
55
|
+
*/
|
|
56
|
+
constructor(id: string, initialFiles?: Record<string, string>);
|
|
57
|
+
resolve(relativePath: string): string;
|
|
58
|
+
exists(relativePath: string): Promise<boolean>;
|
|
59
|
+
read(relativePath: string): Promise<string>;
|
|
60
|
+
write(relativePath: string, content: string): Promise<void>;
|
|
61
|
+
readdir(relativePath: string): Promise<WorkspaceEntry[]>;
|
|
62
|
+
mkdir(relativePath: string): Promise<void>;
|
|
63
|
+
/**
|
|
64
|
+
* Get all file paths stored in this workspace (for test assertions).
|
|
65
|
+
* @returns Array of normalized file paths
|
|
66
|
+
*/
|
|
67
|
+
getAllPaths(): string[];
|
|
68
|
+
/**
|
|
69
|
+
* Normalize a path to use forward slashes and strip leading slash.
|
|
70
|
+
*/
|
|
71
|
+
private normalizePath;
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=workspace.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workspace.d.ts","sourceRoot":"","sources":["../src/workspace.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC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S3C,KAAK,CAAC,YAAY,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAK3D,OAAO,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC;IA4CxD,KAAK,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAOhD;;;OAGG;IACH,WAAW,IAAI,MAAM,EAAE;IAIvB;;OAEG;IACH,OAAO,CAAC,aAAa;CAGtB"}
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import * as path from 'path';
|
|
2
|
+
export { LocalWorkspace, toWorkspace } from '@a16njs/models';
|
|
3
|
+
/**
|
|
4
|
+
* Read-only wrapper around another workspace.
|
|
5
|
+
* Allows read operations but throws on any write operation.
|
|
6
|
+
* Useful for dry-run scenarios.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* const ws = new LocalWorkspace('source', '/project');
|
|
11
|
+
* const readOnly = new ReadOnlyWorkspace(ws);
|
|
12
|
+
* await readOnly.read('file.md'); // works
|
|
13
|
+
* await readOnly.write('file.md', 'content'); // throws!
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
export class ReadOnlyWorkspace {
|
|
17
|
+
underlying;
|
|
18
|
+
/**
|
|
19
|
+
* Create a new ReadOnlyWorkspace wrapping another workspace.
|
|
20
|
+
* @param underlying - The workspace to wrap
|
|
21
|
+
*/
|
|
22
|
+
constructor(underlying) {
|
|
23
|
+
this.underlying = underlying;
|
|
24
|
+
}
|
|
25
|
+
get id() {
|
|
26
|
+
return this.underlying.id;
|
|
27
|
+
}
|
|
28
|
+
get root() {
|
|
29
|
+
return this.underlying.root;
|
|
30
|
+
}
|
|
31
|
+
resolve(relativePath) {
|
|
32
|
+
return this.underlying.resolve(relativePath);
|
|
33
|
+
}
|
|
34
|
+
exists(relativePath) {
|
|
35
|
+
return this.underlying.exists(relativePath);
|
|
36
|
+
}
|
|
37
|
+
read(relativePath) {
|
|
38
|
+
return this.underlying.read(relativePath);
|
|
39
|
+
}
|
|
40
|
+
async write(_relativePath, _content) {
|
|
41
|
+
throw new Error('Cannot write to read-only workspace');
|
|
42
|
+
}
|
|
43
|
+
readdir(relativePath) {
|
|
44
|
+
return this.underlying.readdir(relativePath);
|
|
45
|
+
}
|
|
46
|
+
async mkdir(_relativePath) {
|
|
47
|
+
throw new Error('Cannot mkdir in read-only workspace');
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* In-memory workspace for testing.
|
|
52
|
+
* Stores files in a Map, no filesystem access.
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* ```typescript
|
|
56
|
+
* const ws = new MemoryWorkspace('test');
|
|
57
|
+
* await ws.write('rules/my-rule.md', '# Rule');
|
|
58
|
+
* const content = await ws.read('rules/my-rule.md');
|
|
59
|
+
* const entries = await ws.readdir('rules');
|
|
60
|
+
* // entries: [{ name: 'my-rule.md', isFile: true, isDirectory: false }]
|
|
61
|
+
* ```
|
|
62
|
+
*/
|
|
63
|
+
export class MemoryWorkspace {
|
|
64
|
+
id;
|
|
65
|
+
root = '/memory';
|
|
66
|
+
files = new Map();
|
|
67
|
+
directories = new Set();
|
|
68
|
+
/**
|
|
69
|
+
* Create a new MemoryWorkspace.
|
|
70
|
+
* @param id - Unique identifier for this workspace
|
|
71
|
+
* @param initialFiles - Optional map of relative paths to file contents
|
|
72
|
+
*/
|
|
73
|
+
constructor(id, initialFiles) {
|
|
74
|
+
this.id = id;
|
|
75
|
+
if (initialFiles) {
|
|
76
|
+
for (const [filePath, content] of Object.entries(initialFiles)) {
|
|
77
|
+
this.files.set(this.normalizePath(filePath), content);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
resolve(relativePath) {
|
|
82
|
+
const normalized = this.normalizePath(relativePath);
|
|
83
|
+
if (normalized === '')
|
|
84
|
+
return this.root;
|
|
85
|
+
return this.root + '/' + normalized;
|
|
86
|
+
}
|
|
87
|
+
async exists(relativePath) {
|
|
88
|
+
const normalized = this.normalizePath(relativePath);
|
|
89
|
+
// Check if it's a file
|
|
90
|
+
if (this.files.has(normalized))
|
|
91
|
+
return true;
|
|
92
|
+
// Check if it's an explicit directory
|
|
93
|
+
if (this.directories.has(normalized))
|
|
94
|
+
return true;
|
|
95
|
+
// Check if it's an implicit directory (some file has this as a prefix)
|
|
96
|
+
if (normalized === '')
|
|
97
|
+
return true;
|
|
98
|
+
const prefix = normalized + '/';
|
|
99
|
+
for (const key of this.files.keys()) {
|
|
100
|
+
if (key.startsWith(prefix))
|
|
101
|
+
return true;
|
|
102
|
+
}
|
|
103
|
+
return false;
|
|
104
|
+
}
|
|
105
|
+
async read(relativePath) {
|
|
106
|
+
const normalized = this.normalizePath(relativePath);
|
|
107
|
+
const content = this.files.get(normalized);
|
|
108
|
+
if (content === undefined) {
|
|
109
|
+
throw new Error(`File not found: ${relativePath} in workspace ${this.id}`);
|
|
110
|
+
}
|
|
111
|
+
return content;
|
|
112
|
+
}
|
|
113
|
+
async write(relativePath, content) {
|
|
114
|
+
const normalized = this.normalizePath(relativePath);
|
|
115
|
+
this.files.set(normalized, content);
|
|
116
|
+
}
|
|
117
|
+
async readdir(relativePath) {
|
|
118
|
+
const normalized = this.normalizePath(relativePath);
|
|
119
|
+
// Check directory exists
|
|
120
|
+
if (!(await this.exists(normalized))) {
|
|
121
|
+
throw new Error(`Directory not found: ${relativePath} in workspace ${this.id}`);
|
|
122
|
+
}
|
|
123
|
+
const prefix = normalized === '' ? '' : normalized + '/';
|
|
124
|
+
const entries = new Map();
|
|
125
|
+
// Scan files for entries under this directory
|
|
126
|
+
for (const key of this.files.keys()) {
|
|
127
|
+
if (!key.startsWith(prefix))
|
|
128
|
+
continue;
|
|
129
|
+
const rest = key.slice(prefix.length);
|
|
130
|
+
const slashIndex = rest.indexOf('/');
|
|
131
|
+
if (slashIndex === -1) {
|
|
132
|
+
// Direct child file
|
|
133
|
+
entries.set(rest, { name: rest, isFile: true, isDirectory: false });
|
|
134
|
+
}
|
|
135
|
+
else {
|
|
136
|
+
// Subdirectory (from file path)
|
|
137
|
+
const dirName = rest.slice(0, slashIndex);
|
|
138
|
+
if (!entries.has(dirName)) {
|
|
139
|
+
entries.set(dirName, { name: dirName, isFile: false, isDirectory: true });
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
// Also scan explicit directories
|
|
144
|
+
for (const dir of this.directories) {
|
|
145
|
+
if (!dir.startsWith(prefix))
|
|
146
|
+
continue;
|
|
147
|
+
const rest = dir.slice(prefix.length);
|
|
148
|
+
if (rest === '')
|
|
149
|
+
continue;
|
|
150
|
+
const slashIndex = rest.indexOf('/');
|
|
151
|
+
const dirName = slashIndex === -1 ? rest : rest.slice(0, slashIndex);
|
|
152
|
+
if (!entries.has(dirName)) {
|
|
153
|
+
entries.set(dirName, { name: dirName, isFile: false, isDirectory: true });
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
return Array.from(entries.values());
|
|
157
|
+
}
|
|
158
|
+
async mkdir(relativePath) {
|
|
159
|
+
const normalized = this.normalizePath(relativePath);
|
|
160
|
+
if (normalized !== '') {
|
|
161
|
+
this.directories.add(normalized);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Get all file paths stored in this workspace (for test assertions).
|
|
166
|
+
* @returns Array of normalized file paths
|
|
167
|
+
*/
|
|
168
|
+
getAllPaths() {
|
|
169
|
+
return Array.from(this.files.keys());
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Normalize a path to use forward slashes and strip leading slash.
|
|
173
|
+
*/
|
|
174
|
+
normalizePath(p) {
|
|
175
|
+
return p.split(path.sep).join('/').replace(/^\//, '');
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
//# sourceMappingURL=workspace.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version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,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC,CAAC;YAC5E,CAAC;QACH,CAAC;QAED,OAAO,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;IACtC,CAAC;IAED,KAAK,CAAC,KAAK,CAAC,YAAoB;QAC9B,MAAM,UAAU,GAAG,IAAI,CAAC,aAAa,CAAC,YAAY,CAAC,CAAC;QACpD,IAAI,UAAU,KAAK,EAAE,EAAE,CAAC;YACtB,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;QACnC,CAAC;IACH,CAAC;IAED;;;OAGG;IACH,WAAW;QACT,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC;IACvC,CAAC;IAED;;OAEG;IACK,aAAa,CAAC,CAAS;QAC7B,OAAO,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;IACxD,CAAC;CACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@a16njs/engine",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "Conversion engine for a16n",
|
|
5
5
|
"license": "AGPL-3.0",
|
|
6
6
|
"author": "Texarkanine",
|
|
@@ -31,14 +31,14 @@
|
|
|
31
31
|
"dist"
|
|
32
32
|
],
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@a16njs/models": "0.
|
|
34
|
+
"@a16njs/models": "0.10.0"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@types/node": "^20.0.0",
|
|
38
38
|
"typescript": "^5.4.0",
|
|
39
39
|
"vitest": "^2.0.0",
|
|
40
|
-
"@a16njs/plugin-cursor": "0.
|
|
41
|
-
"@a16njs/plugin-claude": "0.
|
|
40
|
+
"@a16njs/plugin-cursor": "0.10.0",
|
|
41
|
+
"@a16njs/plugin-claude": "0.10.0"
|
|
42
42
|
},
|
|
43
43
|
"scripts": {
|
|
44
44
|
"build": "tsc",
|