@a16njs/models 0.5.0 → 0.7.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/README.md +1 -0
- package/dist/agentskills-io.d.ts +127 -0
- package/dist/agentskills-io.d.ts.map +1 -0
- package/dist/agentskills-io.js +213 -0
- package/dist/agentskills-io.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +12 -3
- package/dist/types.d.ts.map +1 -1
- package/dist/version.d.ts +71 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +76 -0
- package/dist/version.js.map +1 -0
- package/dist/warnings.d.ts +3 -1
- package/dist/warnings.d.ts.map +1 -1
- package/dist/warnings.js +2 -0
- package/dist/warnings.js.map +1 -1
- package/package.json +8 -3
package/README.md
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# @a16njs/models
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.com/package/@a16njs/models)
|
|
4
|
+
[](https://codecov.io/gh/Texarkanine/a16n)
|
|
4
5
|
|
|
5
6
|
Type definitions and plugin interface for a16n.
|
|
6
7
|
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared utilities for parsing and writing AgentSkills.io format.
|
|
3
|
+
* This module handles the verbatim AgentSkills.io format WITHOUT IR frontmatter.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Parsed frontmatter from an AgentSkills.io SKILL.md file.
|
|
7
|
+
* This is the VERBATIM AgentSkills.io format, NOT the IR format.
|
|
8
|
+
*/
|
|
9
|
+
export interface ParsedSkillFrontmatter {
|
|
10
|
+
/** Skill name (required) */
|
|
11
|
+
name: string;
|
|
12
|
+
/** Skill description for activation matching (required) */
|
|
13
|
+
description: string;
|
|
14
|
+
/** Resource file paths relative to skill directory (optional) */
|
|
15
|
+
resources?: string[];
|
|
16
|
+
/** If true, only invoked via /name (optional) */
|
|
17
|
+
disableModelInvocation?: boolean;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* A parsed AgentSkills.io skill with content and frontmatter.
|
|
21
|
+
*/
|
|
22
|
+
export interface ParsedSkill {
|
|
23
|
+
/** Parsed frontmatter */
|
|
24
|
+
frontmatter: ParsedSkillFrontmatter;
|
|
25
|
+
/** Skill content after frontmatter */
|
|
26
|
+
content: string;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Parse the frontmatter from an AgentSkills.io SKILL.md file.
|
|
30
|
+
*
|
|
31
|
+
* This parses the VERBATIM AgentSkills.io format:
|
|
32
|
+
* - name (required)
|
|
33
|
+
* - description (required)
|
|
34
|
+
* - resources (optional)
|
|
35
|
+
* - disable-model-invocation (optional)
|
|
36
|
+
*
|
|
37
|
+
* It does NOT parse IR-specific fields (version, type, relativeDir).
|
|
38
|
+
*
|
|
39
|
+
* @param fileContent - The complete SKILL.md file content
|
|
40
|
+
* @returns Parsed skill or error message
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* const content = `---
|
|
44
|
+
* name: deploy
|
|
45
|
+
* description: Deploy the application
|
|
46
|
+
* resources:
|
|
47
|
+
* - checklist.md
|
|
48
|
+
* ---
|
|
49
|
+
*
|
|
50
|
+
* Deploy instructions...`;
|
|
51
|
+
*
|
|
52
|
+
* parseSkillFrontmatter(content)
|
|
53
|
+
* // { frontmatter: { name: 'deploy', description: '...', resources: ['checklist.md'] }, content: 'Deploy instructions...' }
|
|
54
|
+
*/
|
|
55
|
+
export declare function parseSkillFrontmatter(fileContent: string): {
|
|
56
|
+
success: true;
|
|
57
|
+
skill: ParsedSkill;
|
|
58
|
+
} | {
|
|
59
|
+
success: false;
|
|
60
|
+
error: string;
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* Read resource files from a skill directory.
|
|
64
|
+
*
|
|
65
|
+
* @param skillDir - Absolute path to the skill directory
|
|
66
|
+
* @param resources - Array of resource file paths (relative to skillDir)
|
|
67
|
+
* @returns Map of relative path to file content
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* readSkillFiles('/path/to/skill', ['checklist.md', 'config.json'])
|
|
71
|
+
* // { 'checklist.md': '...', 'config.json': '...' }
|
|
72
|
+
*/
|
|
73
|
+
export declare function readSkillFiles(skillDir: string, resources: string[]): Promise<Record<string, string>>;
|
|
74
|
+
/**
|
|
75
|
+
* Write an AgentSkillIO to disk in verbatim AgentSkills.io format.
|
|
76
|
+
*
|
|
77
|
+
* This writes the VERBATIM AgentSkills.io format:
|
|
78
|
+
* - SKILL.md with name, description, resources, disable-model-invocation
|
|
79
|
+
* - Resource files in the skill directory
|
|
80
|
+
*
|
|
81
|
+
* It does NOT write IR-specific fields (version, type, relativeDir).
|
|
82
|
+
*
|
|
83
|
+
* @param outputDir - Directory to write the skill (e.g., .a16n/agent-skill-io/<name>)
|
|
84
|
+
* @param frontmatter - Skill frontmatter (AgentSkills.io format)
|
|
85
|
+
* @param content - Skill content
|
|
86
|
+
* @param files - Resource files to write (key: relative path, value: content)
|
|
87
|
+
* @returns Array of written file paths
|
|
88
|
+
*
|
|
89
|
+
* @example
|
|
90
|
+
* await writeAgentSkillIO(
|
|
91
|
+
* '.a16n/agent-skill-io/deploy',
|
|
92
|
+
* { name: 'deploy', description: 'Deploy app', resources: ['checklist.md'] },
|
|
93
|
+
* 'Deploy instructions...',
|
|
94
|
+
* { 'checklist.md': 'Checklist content...' }
|
|
95
|
+
* )
|
|
96
|
+
*/
|
|
97
|
+
export declare function writeAgentSkillIO(outputDir: string, frontmatter: ParsedSkillFrontmatter, content: string, files: Record<string, string>): Promise<string[]>;
|
|
98
|
+
/**
|
|
99
|
+
* Read an AgentSkillIO from disk in verbatim AgentSkills.io format.
|
|
100
|
+
*
|
|
101
|
+
* This reads the VERBATIM AgentSkills.io format from:
|
|
102
|
+
* - SKILL.md with name, description, resources, disable-model-invocation
|
|
103
|
+
* - Resource files in the skill directory
|
|
104
|
+
*
|
|
105
|
+
* It does NOT expect IR-specific fields (version, type, relativeDir).
|
|
106
|
+
*
|
|
107
|
+
* @param skillDir - Directory containing the skill (e.g., .a16n/agent-skill-io/<name>)
|
|
108
|
+
* @returns Parsed skill with frontmatter, content, and resource files
|
|
109
|
+
*
|
|
110
|
+
* @example
|
|
111
|
+
* await readAgentSkillIO('.a16n/agent-skill-io/deploy')
|
|
112
|
+
* // {
|
|
113
|
+
* // frontmatter: { name: 'deploy', description: '...', resources: ['checklist.md'] },
|
|
114
|
+
* // content: 'Deploy instructions...',
|
|
115
|
+
* // files: { 'checklist.md': 'Checklist content...' }
|
|
116
|
+
* // }
|
|
117
|
+
*/
|
|
118
|
+
export declare function readAgentSkillIO(skillDir: string): Promise<{
|
|
119
|
+
success: true;
|
|
120
|
+
skill: ParsedSkill & {
|
|
121
|
+
files: Record<string, string>;
|
|
122
|
+
};
|
|
123
|
+
} | {
|
|
124
|
+
success: false;
|
|
125
|
+
error: string;
|
|
126
|
+
}>;
|
|
127
|
+
//# sourceMappingURL=agentskills-io.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agentskills-io.d.ts","sourceRoot":"","sources":["../src/agentskills-io.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH;;;GAGG;AACH,MAAM,WAAW,sBAAsB;IACrC,4BAA4B;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,2DAA2D;IAC3D,WAAW,EAAE,MAAM,CAAC;IACpB,iEAAiE;IACjE,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IACrB,iDAAiD;IACjD,sBAAsB,CAAC,EAAE,OAAO,CAAC;CAClC;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,yBAAyB;IACzB,WAAW,EAAE,sBAAsB,CAAC;IACpC,sCAAsC;IACtC,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,qBAAqB,CACnC,WAAW,EAAE,MAAM,GAClB;IAAE,OAAO,EAAE,IAAI,CAAC;IAAC,KAAK,EAAE,WAAW,CAAA;CAAE,GAAG;IAAE,OAAO,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAwC3E;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,cAAc,CAClC,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,EAAE,GAClB,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAuBjC;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAsB,iBAAiB,CACrC,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE,sBAAsB,EACnC,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC5B,OAAO,CAAC,MAAM,EAAE,CAAC,CA4CnB;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAsB,gBAAgB,CACpC,QAAQ,EAAE,MAAM,GACf,OAAO,CACN;IAAE,OAAO,EAAE,IAAI,CAAC;IAAC,KAAK,EAAE,WAAW,GAAG;QAAE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;KAAE,CAAA;CAAE,GACzE;IAAE,OAAO,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CACpC,CAgCA"}
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared utilities for parsing and writing AgentSkills.io format.
|
|
3
|
+
* This module handles the verbatim AgentSkills.io format WITHOUT IR frontmatter.
|
|
4
|
+
*/
|
|
5
|
+
import * as fs from 'node:fs/promises';
|
|
6
|
+
import * as path from 'node:path';
|
|
7
|
+
import matter from 'gray-matter';
|
|
8
|
+
/**
|
|
9
|
+
* Parse the frontmatter from an AgentSkills.io SKILL.md file.
|
|
10
|
+
*
|
|
11
|
+
* This parses the VERBATIM AgentSkills.io format:
|
|
12
|
+
* - name (required)
|
|
13
|
+
* - description (required)
|
|
14
|
+
* - resources (optional)
|
|
15
|
+
* - disable-model-invocation (optional)
|
|
16
|
+
*
|
|
17
|
+
* It does NOT parse IR-specific fields (version, type, relativeDir).
|
|
18
|
+
*
|
|
19
|
+
* @param fileContent - The complete SKILL.md file content
|
|
20
|
+
* @returns Parsed skill or error message
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* const content = `---
|
|
24
|
+
* name: deploy
|
|
25
|
+
* description: Deploy the application
|
|
26
|
+
* resources:
|
|
27
|
+
* - checklist.md
|
|
28
|
+
* ---
|
|
29
|
+
*
|
|
30
|
+
* Deploy instructions...`;
|
|
31
|
+
*
|
|
32
|
+
* parseSkillFrontmatter(content)
|
|
33
|
+
* // { frontmatter: { name: 'deploy', description: '...', resources: ['checklist.md'] }, content: 'Deploy instructions...' }
|
|
34
|
+
*/
|
|
35
|
+
export function parseSkillFrontmatter(fileContent) {
|
|
36
|
+
try {
|
|
37
|
+
const parsed = matter(fileContent);
|
|
38
|
+
const data = parsed.data;
|
|
39
|
+
// Validate required fields
|
|
40
|
+
if (typeof data.name !== 'string') {
|
|
41
|
+
return { success: false, error: 'Missing required field: name' };
|
|
42
|
+
}
|
|
43
|
+
if (typeof data.description !== 'string') {
|
|
44
|
+
return { success: false, error: 'Missing required field: description' };
|
|
45
|
+
}
|
|
46
|
+
// Parse optional fields
|
|
47
|
+
const frontmatter = {
|
|
48
|
+
name: data.name,
|
|
49
|
+
description: data.description,
|
|
50
|
+
};
|
|
51
|
+
if (Array.isArray(data.resources)) {
|
|
52
|
+
frontmatter.resources = data.resources;
|
|
53
|
+
}
|
|
54
|
+
if (typeof data['disable-model-invocation'] === 'boolean') {
|
|
55
|
+
frontmatter.disableModelInvocation = data['disable-model-invocation'];
|
|
56
|
+
}
|
|
57
|
+
return {
|
|
58
|
+
success: true,
|
|
59
|
+
skill: {
|
|
60
|
+
frontmatter,
|
|
61
|
+
content: parsed.content.trim(),
|
|
62
|
+
},
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
catch (error) {
|
|
66
|
+
return {
|
|
67
|
+
success: false,
|
|
68
|
+
error: error instanceof Error ? error.message : 'Failed to parse frontmatter',
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Read resource files from a skill directory.
|
|
74
|
+
*
|
|
75
|
+
* @param skillDir - Absolute path to the skill directory
|
|
76
|
+
* @param resources - Array of resource file paths (relative to skillDir)
|
|
77
|
+
* @returns Map of relative path to file content
|
|
78
|
+
*
|
|
79
|
+
* @example
|
|
80
|
+
* readSkillFiles('/path/to/skill', ['checklist.md', 'config.json'])
|
|
81
|
+
* // { 'checklist.md': '...', 'config.json': '...' }
|
|
82
|
+
*/
|
|
83
|
+
export async function readSkillFiles(skillDir, resources) {
|
|
84
|
+
const files = {};
|
|
85
|
+
const resolvedSkillDir = path.resolve(skillDir);
|
|
86
|
+
for (const resource of resources) {
|
|
87
|
+
const resourcePath = path.join(skillDir, resource);
|
|
88
|
+
const resolvedResource = path.resolve(resourcePath);
|
|
89
|
+
// Validate path stays within skillDir to prevent path traversal
|
|
90
|
+
if (!resolvedResource.startsWith(resolvedSkillDir + path.sep) && resolvedResource !== resolvedSkillDir) {
|
|
91
|
+
continue; // Skip paths that escape the skill directory
|
|
92
|
+
}
|
|
93
|
+
try {
|
|
94
|
+
const content = await fs.readFile(resourcePath, 'utf-8');
|
|
95
|
+
files[resource] = content;
|
|
96
|
+
}
|
|
97
|
+
catch (error) {
|
|
98
|
+
// Skip missing files gracefully
|
|
99
|
+
continue;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
return files;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Write an AgentSkillIO to disk in verbatim AgentSkills.io format.
|
|
106
|
+
*
|
|
107
|
+
* This writes the VERBATIM AgentSkills.io format:
|
|
108
|
+
* - SKILL.md with name, description, resources, disable-model-invocation
|
|
109
|
+
* - Resource files in the skill directory
|
|
110
|
+
*
|
|
111
|
+
* It does NOT write IR-specific fields (version, type, relativeDir).
|
|
112
|
+
*
|
|
113
|
+
* @param outputDir - Directory to write the skill (e.g., .a16n/agent-skill-io/<name>)
|
|
114
|
+
* @param frontmatter - Skill frontmatter (AgentSkills.io format)
|
|
115
|
+
* @param content - Skill content
|
|
116
|
+
* @param files - Resource files to write (key: relative path, value: content)
|
|
117
|
+
* @returns Array of written file paths
|
|
118
|
+
*
|
|
119
|
+
* @example
|
|
120
|
+
* await writeAgentSkillIO(
|
|
121
|
+
* '.a16n/agent-skill-io/deploy',
|
|
122
|
+
* { name: 'deploy', description: 'Deploy app', resources: ['checklist.md'] },
|
|
123
|
+
* 'Deploy instructions...',
|
|
124
|
+
* { 'checklist.md': 'Checklist content...' }
|
|
125
|
+
* )
|
|
126
|
+
*/
|
|
127
|
+
export async function writeAgentSkillIO(outputDir, frontmatter, content, files) {
|
|
128
|
+
const written = [];
|
|
129
|
+
// Create output directory
|
|
130
|
+
await fs.mkdir(outputDir, { recursive: true });
|
|
131
|
+
// Build YAML frontmatter (AgentSkills.io format, NO IR fields)
|
|
132
|
+
const yamlData = {
|
|
133
|
+
name: frontmatter.name,
|
|
134
|
+
description: frontmatter.description,
|
|
135
|
+
};
|
|
136
|
+
if (frontmatter.resources) {
|
|
137
|
+
yamlData.resources = frontmatter.resources;
|
|
138
|
+
}
|
|
139
|
+
if (frontmatter.disableModelInvocation) {
|
|
140
|
+
yamlData['disable-model-invocation'] = frontmatter.disableModelInvocation;
|
|
141
|
+
}
|
|
142
|
+
// Write SKILL.md with gray-matter
|
|
143
|
+
const skillContent = matter.stringify(content, yamlData);
|
|
144
|
+
const skillPath = path.join(outputDir, 'SKILL.md');
|
|
145
|
+
await fs.writeFile(skillPath, skillContent, 'utf-8');
|
|
146
|
+
written.push(skillPath);
|
|
147
|
+
// Write resource files
|
|
148
|
+
const resolvedOutputDir = path.resolve(outputDir);
|
|
149
|
+
for (const [relativePath, fileContent] of Object.entries(files)) {
|
|
150
|
+
const filePath = path.join(outputDir, relativePath);
|
|
151
|
+
const resolvedFilePath = path.resolve(filePath);
|
|
152
|
+
// Validate path stays within outputDir to prevent path traversal
|
|
153
|
+
if (!resolvedFilePath.startsWith(resolvedOutputDir + path.sep) && resolvedFilePath !== resolvedOutputDir) {
|
|
154
|
+
throw new Error(`Invalid resource path: ${relativePath} escapes output directory`);
|
|
155
|
+
}
|
|
156
|
+
const fileDir = path.dirname(filePath);
|
|
157
|
+
await fs.mkdir(fileDir, { recursive: true });
|
|
158
|
+
await fs.writeFile(filePath, fileContent, 'utf-8');
|
|
159
|
+
written.push(filePath);
|
|
160
|
+
}
|
|
161
|
+
return written;
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Read an AgentSkillIO from disk in verbatim AgentSkills.io format.
|
|
165
|
+
*
|
|
166
|
+
* This reads the VERBATIM AgentSkills.io format from:
|
|
167
|
+
* - SKILL.md with name, description, resources, disable-model-invocation
|
|
168
|
+
* - Resource files in the skill directory
|
|
169
|
+
*
|
|
170
|
+
* It does NOT expect IR-specific fields (version, type, relativeDir).
|
|
171
|
+
*
|
|
172
|
+
* @param skillDir - Directory containing the skill (e.g., .a16n/agent-skill-io/<name>)
|
|
173
|
+
* @returns Parsed skill with frontmatter, content, and resource files
|
|
174
|
+
*
|
|
175
|
+
* @example
|
|
176
|
+
* await readAgentSkillIO('.a16n/agent-skill-io/deploy')
|
|
177
|
+
* // {
|
|
178
|
+
* // frontmatter: { name: 'deploy', description: '...', resources: ['checklist.md'] },
|
|
179
|
+
* // content: 'Deploy instructions...',
|
|
180
|
+
* // files: { 'checklist.md': 'Checklist content...' }
|
|
181
|
+
* // }
|
|
182
|
+
*/
|
|
183
|
+
export async function readAgentSkillIO(skillDir) {
|
|
184
|
+
try {
|
|
185
|
+
// Read SKILL.md
|
|
186
|
+
const skillPath = path.join(skillDir, 'SKILL.md');
|
|
187
|
+
const skillContent = await fs.readFile(skillPath, 'utf-8');
|
|
188
|
+
// Parse frontmatter
|
|
189
|
+
const parseResult = parseSkillFrontmatter(skillContent);
|
|
190
|
+
if (!parseResult.success) {
|
|
191
|
+
return parseResult;
|
|
192
|
+
}
|
|
193
|
+
// Read resource files
|
|
194
|
+
const resources = parseResult.skill.frontmatter.resources || [];
|
|
195
|
+
const files = await readSkillFiles(skillDir, resources);
|
|
196
|
+
return {
|
|
197
|
+
success: true,
|
|
198
|
+
skill: {
|
|
199
|
+
...parseResult.skill,
|
|
200
|
+
files,
|
|
201
|
+
},
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
catch (error) {
|
|
205
|
+
return {
|
|
206
|
+
success: false,
|
|
207
|
+
error: error instanceof Error
|
|
208
|
+
? `Failed to read SKILL.md: ${error.message}`
|
|
209
|
+
: 'Failed to read SKILL.md',
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
//# sourceMappingURL=agentskills-io.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agentskills-io.js","sourceRoot":"","sources":["../src/agentskills-io.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACvC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,MAAM,MAAM,aAAa,CAAC;AA2BjC;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,UAAU,qBAAqB,CACnC,WAAmB;IAEnB,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,MAAM,CAAC,WAAW,CAAC,CAAC;QACnC,MAAM,IAAI,GAAG,MAAM,CAAC,IAA+B,CAAC;QAEpD,2BAA2B;QAC3B,IAAI,OAAO,IAAI,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;YAClC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,8BAA8B,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;QAChB,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;QAClD,MAAM,YAAY,GAAG,MAAM,EAAE,CAAC,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;QAE3D,oBAAoB;QACpB,MAAM,WAAW,GAAG,qBAAqB,CAAC,YAAY,CAAC,CAAC;QACxD,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,CAAC;YACzB,OAAO,WAAW,CAAC;QACrB,CAAC;QAED,sBAAsB;QACtB,MAAM,SAAS,GAAG,WAAW,CAAC,KAAK,CAAC,WAAW,CAAC,SAAS,IAAI,EAAE,CAAC;QAChE,MAAM,KAAK,GAAG,MAAM,cAAc,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;QAExD,OAAO;YACL,OAAO,EAAE,IAAI;YACb,KAAK,EAAE;gBACL,GAAG,WAAW,CAAC,KAAK;gBACpB,KAAK;aACN;SACF,CAAC;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO;YACL,OAAO,EAAE,KAAK;YACd,KAAK,EACH,KAAK,YAAY,KAAK;gBACpB,CAAC,CAAC,4BAA4B,KAAK,CAAC,OAAO,EAAE;gBAC7C,CAAC,CAAC,yBAAyB;SAChC,CAAC;IACJ,CAAC;AACH,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -4,4 +4,6 @@ export { type A16nPlugin, type DiscoveryResult, type EmitResult, type EmitOption
|
|
|
4
4
|
export { WarningCode, type Warning } from './warnings.js';
|
|
5
5
|
export { isGlobalPrompt, isSimpleAgentSkill, isAgentSkill, // Deprecated alias for isSimpleAgentSkill
|
|
6
6
|
isAgentSkillIO, isFileRule, isAgentIgnore, isManualPrompt, getUniqueFilename, createId, } from './helpers.js';
|
|
7
|
+
export { type IRVersion, type ParsedIRVersion, CURRENT_IR_VERSION, parseIRVersion, areVersionsCompatible, getCurrentVersion, } from './version.js';
|
|
8
|
+
export { type ParsedSkillFrontmatter, type ParsedSkill, parseSkillFrontmatter, readSkillFiles, writeAgentSkillIO, readAgentSkillIO, } from './agentskills-io.js';
|
|
7
9
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,iBAAiB,EACjB,KAAK,kBAAkB,EACvB,KAAK,YAAY,EACjB,KAAK,gBAAgB,EACrB,KAAK,UAAU,EAAE,wCAAwC;AACzD,KAAK,YAAY,EACjB,KAAK,QAAQ,EACb,KAAK,WAAW,EAChB,KAAK,YAAY,GAClB,MAAM,YAAY,CAAC;AAGpB,OAAO,EACL,KAAK,UAAU,EACf,KAAK,eAAe,EACpB,KAAK,UAAU,EACf,KAAK,WAAW,EAChB,KAAK,WAAW,GACjB,MAAM,aAAa,CAAC;AAGrB,OAAO,EAAE,WAAW,EAAE,KAAK,OAAO,EAAE,MAAM,eAAe,CAAC;AAG1D,OAAO,EACL,cAAc,EACd,kBAAkB,EAClB,YAAY,EAAE,0CAA0C;AACxD,cAAc,EACd,UAAU,EACV,aAAa,EACb,cAAc,EACd,iBAAiB,EACjB,QAAQ,GACT,MAAM,cAAc,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,iBAAiB,EACjB,KAAK,kBAAkB,EACvB,KAAK,YAAY,EACjB,KAAK,gBAAgB,EACrB,KAAK,UAAU,EAAE,wCAAwC;AACzD,KAAK,YAAY,EACjB,KAAK,QAAQ,EACb,KAAK,WAAW,EAChB,KAAK,YAAY,GAClB,MAAM,YAAY,CAAC;AAGpB,OAAO,EACL,KAAK,UAAU,EACf,KAAK,eAAe,EACpB,KAAK,UAAU,EACf,KAAK,WAAW,EAChB,KAAK,WAAW,GACjB,MAAM,aAAa,CAAC;AAGrB,OAAO,EAAE,WAAW,EAAE,KAAK,OAAO,EAAE,MAAM,eAAe,CAAC;AAG1D,OAAO,EACL,cAAc,EACd,kBAAkB,EAClB,YAAY,EAAE,0CAA0C;AACxD,cAAc,EACd,UAAU,EACV,aAAa,EACb,cAAc,EACd,iBAAiB,EACjB,QAAQ,GACT,MAAM,cAAc,CAAC;AAGtB,OAAO,EACL,KAAK,SAAS,EACd,KAAK,eAAe,EACpB,kBAAkB,EAClB,cAAc,EACd,qBAAqB,EACrB,iBAAiB,GAClB,MAAM,cAAc,CAAC;AAGtB,OAAO,EACL,KAAK,sBAAsB,EAC3B,KAAK,WAAW,EAChB,qBAAqB,EACrB,cAAc,EACd,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,qBAAqB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -6,4 +6,8 @@ export { WarningCode } from './warnings.js';
|
|
|
6
6
|
// Helpers
|
|
7
7
|
export { isGlobalPrompt, isSimpleAgentSkill, isAgentSkill, // Deprecated alias for isSimpleAgentSkill
|
|
8
8
|
isAgentSkillIO, isFileRule, isAgentIgnore, isManualPrompt, getUniqueFilename, createId, } from './helpers.js';
|
|
9
|
+
// Version utilities
|
|
10
|
+
export { CURRENT_IR_VERSION, parseIRVersion, areVersionsCompatible, getCurrentVersion, } from './version.js';
|
|
11
|
+
// AgentSkills.io utilities
|
|
12
|
+
export { parseSkillFrontmatter, readSkillFiles, writeAgentSkillIO, readAgentSkillIO, } from './agentskills-io.js';
|
|
9
13
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,kEAAkE;AAElE,QAAQ;AACR,OAAO,EACL,iBAAiB,GASlB,MAAM,YAAY,CAAC;AAWpB,WAAW;AACX,OAAO,EAAE,WAAW,EAAgB,MAAM,eAAe,CAAC;AAE1D,UAAU;AACV,OAAO,EACL,cAAc,EACd,kBAAkB,EAClB,YAAY,EAAE,0CAA0C;AACxD,cAAc,EACd,UAAU,EACV,aAAa,EACb,cAAc,EACd,iBAAiB,EACjB,QAAQ,GACT,MAAM,cAAc,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,kEAAkE;AAElE,QAAQ;AACR,OAAO,EACL,iBAAiB,GASlB,MAAM,YAAY,CAAC;AAWpB,WAAW;AACX,OAAO,EAAE,WAAW,EAAgB,MAAM,eAAe,CAAC;AAE1D,UAAU;AACV,OAAO,EACL,cAAc,EACd,kBAAkB,EAClB,YAAY,EAAE,0CAA0C;AACxD,cAAc,EACd,UAAU,EACV,aAAa,EACb,cAAc,EACd,iBAAiB,EACjB,QAAQ,GACT,MAAM,cAAc,CAAC;AAEtB,oBAAoB;AACpB,OAAO,EAGL,kBAAkB,EAClB,cAAc,EACd,qBAAqB,EACrB,iBAAiB,GAClB,MAAM,cAAc,CAAC;AAEtB,2BAA2B;AAC3B,OAAO,EAGL,qBAAqB,EACrB,cAAc,EACd,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,qBAAqB,CAAC"}
|
package/dist/types.d.ts
CHANGED
|
@@ -19,17 +19,26 @@ export declare enum CustomizationType {
|
|
|
19
19
|
/**
|
|
20
20
|
* Base interface for all agent customization items.
|
|
21
21
|
* Every customization discovered or emitted extends this interface.
|
|
22
|
+
*
|
|
23
|
+
* BREAKING CHANGES (Phase 9):
|
|
24
|
+
* - `version` is now required (was not present)
|
|
25
|
+
* - `sourcePath` is now optional (was required)
|
|
26
|
+
* - `relativeDir` added as optional field for directory structure preservation
|
|
22
27
|
*/
|
|
23
28
|
export interface AgentCustomization {
|
|
24
29
|
/** Unique identifier for this item */
|
|
25
30
|
id: string;
|
|
26
31
|
/** The type of customization */
|
|
27
32
|
type: CustomizationType;
|
|
28
|
-
/**
|
|
29
|
-
|
|
33
|
+
/** IR version (required, e.g., 'v1beta1') */
|
|
34
|
+
version: string;
|
|
35
|
+
/** Original file path where this was discovered (optional, omitted in IR format) */
|
|
36
|
+
sourcePath?: string;
|
|
37
|
+
/** Relative directory path for preserving directory structure (optional) */
|
|
38
|
+
relativeDir?: string;
|
|
30
39
|
/** The actual prompt/rule content */
|
|
31
40
|
content: string;
|
|
32
|
-
/** Tool-specific extras that don't fit the standard model */
|
|
41
|
+
/** Tool-specific extras that don't fit the standard model (transient, not serialized in IR) */
|
|
33
42
|
metadata: Record<string, unknown>;
|
|
34
43
|
}
|
|
35
44
|
/**
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,oBAAY,iBAAiB;IAC3B,4DAA4D;IAC5D,YAAY,kBAAkB;IAC9B,mFAAmF;IACnF,gBAAgB,uBAAuB;IACvC,sFAAsF;IACtF,YAAY,mBAAmB;IAC/B,sCAAsC;IACtC,QAAQ,cAAc;IACtB,mDAAmD;IACnD,WAAW,iBAAiB;IAC5B,wFAAwF;IACxF,YAAY,kBAAkB;CAC/B;AAED
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,oBAAY,iBAAiB;IAC3B,4DAA4D;IAC5D,YAAY,kBAAkB;IAC9B,mFAAmF;IACnF,gBAAgB,uBAAuB;IACvC,sFAAsF;IACtF,YAAY,mBAAmB;IAC/B,sCAAsC;IACtC,QAAQ,cAAc;IACtB,mDAAmD;IACnD,WAAW,iBAAiB;IAC5B,wFAAwF;IACxF,YAAY,kBAAkB;CAC/B;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,kBAAkB;IACjC,sCAAsC;IACtC,EAAE,EAAE,MAAM,CAAC;IACX,gCAAgC;IAChC,IAAI,EAAE,iBAAiB,CAAC;IACxB,6CAA6C;IAC7C,OAAO,EAAE,MAAM,CAAC;IAChB,oFAAoF;I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ED;;;;;GAKG;AACH,MAAM,WAAW,YAAa,SAAQ,kBAAkB;IACtD,IAAI,EAAE,iBAAiB,CAAC,YAAY,CAAC;IACrC,8DAA8D;IAC9D,UAAU,EAAE,MAAM,CAAC;CACpB"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Kubernetes-style IR version format.
|
|
3
|
+
* Format: v{major}{stability}{revision}
|
|
4
|
+
* Examples: v1beta1, v2alpha3, v1stable1, v11 (stable)
|
|
5
|
+
*
|
|
6
|
+
* Requirements:
|
|
7
|
+
* - Must start with 'v'
|
|
8
|
+
* - Must have a major version number
|
|
9
|
+
* - May have stability identifier (alpha, beta, stable, or empty for stable)
|
|
10
|
+
* - Must end with a revision number (trailing number required)
|
|
11
|
+
*
|
|
12
|
+
* Valid: v1beta1, v2alpha3, v10stable5, v11
|
|
13
|
+
* Invalid: v1, v2beta, vbeta1, 1beta1
|
|
14
|
+
*/
|
|
15
|
+
export type IRVersion = string & {
|
|
16
|
+
readonly __brand: 'IRVersion';
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Parsed components of an IR version.
|
|
20
|
+
*/
|
|
21
|
+
export interface ParsedIRVersion {
|
|
22
|
+
/** Major version number (e.g., 1, 2, 10) */
|
|
23
|
+
major: number;
|
|
24
|
+
/** Stability identifier (alpha, beta, stable, or empty string for stable) */
|
|
25
|
+
stability: string;
|
|
26
|
+
/** Revision number (e.g., 1, 2, 3) */
|
|
27
|
+
revision: number;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* The current IR version used by this version of a16n.
|
|
31
|
+
*/
|
|
32
|
+
export declare const CURRENT_IR_VERSION: IRVersion;
|
|
33
|
+
/**
|
|
34
|
+
* Parse an IR version string into its components.
|
|
35
|
+
*
|
|
36
|
+
* @param version - The version string to parse (e.g., 'v1beta1')
|
|
37
|
+
* @returns Parsed version components or null if invalid
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* parseIRVersion('v1beta1') // { major: 1, stability: 'beta', revision: 1 }
|
|
41
|
+
* parseIRVersion('v2alpha3') // { major: 2, stability: 'alpha', revision: 3 }
|
|
42
|
+
* parseIRVersion('v11') // { major: 1, stability: '', revision: 1 }
|
|
43
|
+
* parseIRVersion('v1') // null (missing trailing revision number)
|
|
44
|
+
*/
|
|
45
|
+
export declare function parseIRVersion(version: string): ParsedIRVersion | null;
|
|
46
|
+
/**
|
|
47
|
+
* Check if two IR versions are compatible.
|
|
48
|
+
*
|
|
49
|
+
* Compatibility rules (forward compatibility guarantee):
|
|
50
|
+
* 1. Major versions must match
|
|
51
|
+
* 2. Stability must match (alpha != beta != stable)
|
|
52
|
+
* 3. Reader revision >= file revision (newer reader can read older files)
|
|
53
|
+
*
|
|
54
|
+
* @param readerVersion - The version of the reader (current a16n version)
|
|
55
|
+
* @param fileVersion - The version found in the IR file
|
|
56
|
+
* @returns true if compatible, false otherwise
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* areVersionsCompatible('v1beta2', 'v1beta1') // true (reader newer)
|
|
60
|
+
* areVersionsCompatible('v1beta1', 'v1beta2') // false (file too new)
|
|
61
|
+
* areVersionsCompatible('v2beta1', 'v1beta1') // false (major mismatch)
|
|
62
|
+
* areVersionsCompatible('v1stable1', 'v1beta1') // false (stability mismatch)
|
|
63
|
+
*/
|
|
64
|
+
export declare function areVersionsCompatible(readerVersion: string, fileVersion: string): boolean;
|
|
65
|
+
/**
|
|
66
|
+
* Get the current IR version.
|
|
67
|
+
*
|
|
68
|
+
* @returns The current IR version constant
|
|
69
|
+
*/
|
|
70
|
+
export declare function getCurrentVersion(): IRVersion;
|
|
71
|
+
//# sourceMappingURL=version.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG;IAAE,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAA;CAAE,CAAC;AAEnE;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,4CAA4C;IAC5C,KAAK,EAAE,MAAM,CAAC;IACd,6EAA6E;IAC7E,SAAS,EAAE,MAAM,CAAC;IAClB,sCAAsC;IACtC,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,eAAO,MAAM,kBAAkB,EAAE,SAAkC,CAAC;AAEpE;;;;;;;;;;;GAWG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,eAAe,GAAG,IAAI,CAatE;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,qBAAqB,CACnC,aAAa,EAAE,MAAM,EACrB,WAAW,EAAE,MAAM,GAClB,OAAO,CAyBT;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,IAAI,SAAS,CAE7C"}
|
package/dist/version.js
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The current IR version used by this version of a16n.
|
|
3
|
+
*/
|
|
4
|
+
export const CURRENT_IR_VERSION = 'v1beta1';
|
|
5
|
+
/**
|
|
6
|
+
* Parse an IR version string into its components.
|
|
7
|
+
*
|
|
8
|
+
* @param version - The version string to parse (e.g., 'v1beta1')
|
|
9
|
+
* @returns Parsed version components or null if invalid
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* parseIRVersion('v1beta1') // { major: 1, stability: 'beta', revision: 1 }
|
|
13
|
+
* parseIRVersion('v2alpha3') // { major: 2, stability: 'alpha', revision: 3 }
|
|
14
|
+
* parseIRVersion('v11') // { major: 1, stability: '', revision: 1 }
|
|
15
|
+
* parseIRVersion('v1') // null (missing trailing revision number)
|
|
16
|
+
*/
|
|
17
|
+
export function parseIRVersion(version) {
|
|
18
|
+
const regex = /^v(\d+)([a-z]*)(\d+)$/;
|
|
19
|
+
const match = regex.exec(version);
|
|
20
|
+
if (!match) {
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
return {
|
|
24
|
+
major: parseInt(match[1], 10),
|
|
25
|
+
stability: match[2] || '',
|
|
26
|
+
revision: parseInt(match[3], 10),
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Check if two IR versions are compatible.
|
|
31
|
+
*
|
|
32
|
+
* Compatibility rules (forward compatibility guarantee):
|
|
33
|
+
* 1. Major versions must match
|
|
34
|
+
* 2. Stability must match (alpha != beta != stable)
|
|
35
|
+
* 3. Reader revision >= file revision (newer reader can read older files)
|
|
36
|
+
*
|
|
37
|
+
* @param readerVersion - The version of the reader (current a16n version)
|
|
38
|
+
* @param fileVersion - The version found in the IR file
|
|
39
|
+
* @returns true if compatible, false otherwise
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* areVersionsCompatible('v1beta2', 'v1beta1') // true (reader newer)
|
|
43
|
+
* areVersionsCompatible('v1beta1', 'v1beta2') // false (file too new)
|
|
44
|
+
* areVersionsCompatible('v2beta1', 'v1beta1') // false (major mismatch)
|
|
45
|
+
* areVersionsCompatible('v1stable1', 'v1beta1') // false (stability mismatch)
|
|
46
|
+
*/
|
|
47
|
+
export function areVersionsCompatible(readerVersion, fileVersion) {
|
|
48
|
+
const reader = parseIRVersion(readerVersion);
|
|
49
|
+
const file = parseIRVersion(fileVersion);
|
|
50
|
+
// Invalid versions are incompatible
|
|
51
|
+
if (!reader || !file) {
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
// Normalize empty stability to 'stable'
|
|
55
|
+
const readerStability = reader.stability === '' ? 'stable' : reader.stability;
|
|
56
|
+
const fileStability = file.stability === '' ? 'stable' : file.stability;
|
|
57
|
+
// Major versions must match
|
|
58
|
+
if (reader.major !== file.major) {
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
61
|
+
// Stability must match
|
|
62
|
+
if (readerStability !== fileStability) {
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
// Reader revision must be >= file revision (forward compatibility)
|
|
66
|
+
return reader.revision >= file.revision;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Get the current IR version.
|
|
70
|
+
*
|
|
71
|
+
* @returns The current IR version constant
|
|
72
|
+
*/
|
|
73
|
+
export function getCurrentVersion() {
|
|
74
|
+
return CURRENT_IR_VERSION;
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=version.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AA4BA;;GAEG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAc,SAAsB,CAAC;AAEpE;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,cAAc,CAAC,OAAe;IAC5C,MAAM,KAAK,GAAG,uBAAuB,CAAC;IACtC,MAAM,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAElC,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO;QACL,KAAK,EAAE,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAE,EAAE,EAAE,CAAC;QAC9B,SAAS,EAAE,KAAK,CAAC,CAAC,CAAC,IAAI,EAAE;QACzB,QAAQ,EAAE,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAE,EAAE,EAAE,CAAC;KAClC,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,qBAAqB,CACnC,aAAqB,EACrB,WAAmB;IAEnB,MAAM,MAAM,GAAG,cAAc,CAAC,aAAa,CAAC,CAAC;IAC7C,MAAM,IAAI,GAAG,cAAc,CAAC,WAAW,CAAC,CAAC;IAEzC,oCAAoC;IACpC,IAAI,CAAC,MAAM,IAAI,CAAC,IAAI,EAAE,CAAC;QACrB,OAAO,KAAK,CAAC;IACf,CAAC;IAED,wCAAwC;IACxC,MAAM,eAAe,GAAG,MAAM,CAAC,SAAS,KAAK,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC;IAC9E,MAAM,aAAa,GAAG,IAAI,CAAC,SAAS,KAAK,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC;IAExE,4BAA4B;IAC5B,IAAI,MAAM,CAAC,KAAK,KAAK,IAAI,CAAC,KAAK,EAAE,CAAC;QAChC,OAAO,KAAK,CAAC;IACf,CAAC;IAED,uBAAuB;IACvB,IAAI,eAAe,KAAK,aAAa,EAAE,CAAC;QACtC,OAAO,KAAK,CAAC;IACf,CAAC;IAED,mEAAmE;IACnE,OAAO,MAAM,CAAC,QAAQ,IAAI,IAAI,CAAC,QAAQ,CAAC;AAC1C,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,iBAAiB;IAC/B,OAAO,kBAAkB,CAAC;AAC5B,CAAC"}
|
package/dist/warnings.d.ts
CHANGED
|
@@ -15,7 +15,9 @@ export declare enum WarningCode {
|
|
|
15
15
|
/** Git-ignored source with tracked output (or vice versa) */
|
|
16
16
|
BoundaryCrossing = "boundary-crossing",
|
|
17
17
|
/** Sources have conflicting git status (some ignored, some tracked) */
|
|
18
|
-
GitStatusConflict = "git-status-conflict"
|
|
18
|
+
GitStatusConflict = "git-status-conflict",
|
|
19
|
+
/** IR file version is incompatible with current reader version */
|
|
20
|
+
VersionMismatch = "version-mismatch"
|
|
19
21
|
}
|
|
20
22
|
/**
|
|
21
23
|
* A warning about something that happened during conversion.
|
package/dist/warnings.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"warnings.d.ts","sourceRoot":"","sources":["../src/warnings.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,oBAAY,WAAW;IACrB,kDAAkD;IAClD,MAAM,WAAW;IACjB,yCAAyC;IACzC,YAAY,iBAAiB;IAC7B,4CAA4C;IAC5C,OAAO,YAAY;IACnB,iCAAiC;IACjC,WAAW,gBAAgB;IAC3B,0CAA0C;IAC1C,WAAW,iBAAiB;IAC5B,6DAA6D;IAC7D,gBAAgB,sBAAsB;IACtC,uEAAuE;IACvE,iBAAiB,wBAAwB;
|
|
1
|
+
{"version":3,"file":"warnings.d.ts","sourceRoot":"","sources":["../src/warnings.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,oBAAY,WAAW;IACrB,kDAAkD;IAClD,MAAM,WAAW;IACjB,yCAAyC;IACzC,YAAY,iBAAiB;IAC7B,4CAA4C;IAC5C,OAAO,YAAY;IACnB,iCAAiC;IACjC,WAAW,gBAAgB;IAC3B,0CAA0C;IAC1C,WAAW,iBAAiB;IAC5B,6DAA6D;IAC7D,gBAAgB,sBAAsB;IACtC,uEAAuE;IACvE,iBAAiB,wBAAwB;IACzC,kEAAkE;IAClE,eAAe,qBAAqB;CACrC;AAED;;;GAGG;AACH,MAAM,WAAW,OAAO;IACtB,0BAA0B;IAC1B,IAAI,EAAE,WAAW,CAAC;IAClB,8CAA8C;IAC9C,OAAO,EAAE,MAAM,CAAC;IAChB,iDAAiD;IACjD,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,sDAAsD;IACtD,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACnC"}
|
package/dist/warnings.js
CHANGED
|
@@ -17,5 +17,7 @@ export var WarningCode;
|
|
|
17
17
|
WarningCode["BoundaryCrossing"] = "boundary-crossing";
|
|
18
18
|
/** Sources have conflicting git status (some ignored, some tracked) */
|
|
19
19
|
WarningCode["GitStatusConflict"] = "git-status-conflict";
|
|
20
|
+
/** IR file version is incompatible with current reader version */
|
|
21
|
+
WarningCode["VersionMismatch"] = "version-mismatch";
|
|
20
22
|
})(WarningCode || (WarningCode = {}));
|
|
21
23
|
//# sourceMappingURL=warnings.js.map
|
package/dist/warnings.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"warnings.js","sourceRoot":"","sources":["../src/warnings.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAN,IAAY,
|
|
1
|
+
{"version":3,"file":"warnings.js","sourceRoot":"","sources":["../src/warnings.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAN,IAAY,WAiBX;AAjBD,WAAY,WAAW;IACrB,kDAAkD;IAClD,gCAAiB,CAAA;IACjB,yCAAyC;IACzC,4CAA6B,CAAA;IAC7B,4CAA4C;IAC5C,kCAAmB,CAAA;IACnB,iCAAiC;IACjC,0CAA2B,CAAA;IAC3B,0CAA0C;IAC1C,2CAA4B,CAAA;IAC5B,6DAA6D;IAC7D,qDAAsC,CAAA;IACtC,uEAAuE;IACvE,wDAAyC,CAAA;IACzC,kEAAkE;IAClE,mDAAoC,CAAA;AACtC,CAAC,EAjBW,WAAW,KAAX,WAAW,QAiBtB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@a16njs/models",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "Type definitions and plugin interface for a16n",
|
|
5
5
|
"license": "AGPL-3.0",
|
|
6
6
|
"author": "Texarkanine",
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"url": "git+https://github.com/Texarkanine/a16n.git",
|
|
10
10
|
"directory": "packages/models"
|
|
11
11
|
},
|
|
12
|
-
"homepage": "https://github.
|
|
12
|
+
"homepage": "https://texarkanine.github.io/a16n/models",
|
|
13
13
|
"bugs": {
|
|
14
14
|
"url": "https://github.com/Texarkanine/a16n/issues"
|
|
15
15
|
},
|
|
@@ -32,14 +32,19 @@
|
|
|
32
32
|
"dist"
|
|
33
33
|
],
|
|
34
34
|
"devDependencies": {
|
|
35
|
+
"@types/node": "^20.0.0",
|
|
35
36
|
"typescript": "^5.4.0",
|
|
36
37
|
"vitest": "^2.0.0"
|
|
37
38
|
},
|
|
39
|
+
"dependencies": {
|
|
40
|
+
"gray-matter": "^4.0.3"
|
|
41
|
+
},
|
|
38
42
|
"scripts": {
|
|
39
43
|
"build": "tsc",
|
|
40
44
|
"clean": "rimraf dist *.tsbuildinfo",
|
|
41
45
|
"typecheck": "tsc --noEmit",
|
|
42
46
|
"test": "vitest run",
|
|
43
|
-
"test:watch": "vitest"
|
|
47
|
+
"test:watch": "vitest",
|
|
48
|
+
"test:coverage": "vitest run --coverage"
|
|
44
49
|
}
|
|
45
50
|
}
|