@skillctl/manifest 0.2.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 +21 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/manifest.d.ts +12 -0
- package/dist/manifest.d.ts.map +1 -0
- package/dist/manifest.js +59 -0
- package/dist/manifest.js.map +1 -0
- package/dist/schema.d.ts +34 -0
- package/dist/schema.d.ts.map +1 -0
- package/dist/schema.js +36 -0
- package/dist/schema.js.map +1 -0
- package/dist/test/manifest-validation.test.d.ts +3 -0
- package/dist/test/manifest-validation.test.d.ts.map +1 -0
- package/dist/test/manifest-validation.test.js +54 -0
- package/dist/test/manifest-validation.test.js.map +1 -0
- package/package.json +43 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 skillctl contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type AgentSkillsManifest } from './schema.js';
|
|
2
|
+
export { AgentSkillsManifestSchema, validateManifest, type AgentSkillsManifest } from './schema.js';
|
|
3
|
+
/**
|
|
4
|
+
* Manifest parser / generator for agent-skills.json
|
|
5
|
+
* Uses Zod for schema + validation. Follows package-manager style.
|
|
6
|
+
*/
|
|
7
|
+
export declare const DEFAULT_MANIFEST_NAME = "agent-skills.json";
|
|
8
|
+
export declare function loadManifest(cwd?: string, fileName?: string): Promise<AgentSkillsManifest | null>;
|
|
9
|
+
export declare function saveManifest(manifest: AgentSkillsManifest, cwd?: string, fileName?: string): Promise<string>;
|
|
10
|
+
export declare function createDefaultManifest(projectName?: string): AgentSkillsManifest;
|
|
11
|
+
export declare function checkNameCollision(manifest: AgentSkillsManifest): string[];
|
|
12
|
+
//# sourceMappingURL=manifest.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manifest.d.ts","sourceRoot":"","sources":["../src/manifest.ts"],"names":[],"mappings":"AAEA,OAAO,EAA+C,KAAK,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAIpG,OAAO,EAAE,yBAAyB,EAAE,gBAAgB,EAAE,KAAK,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAEpG;;;GAGG;AAEH,eAAO,MAAM,qBAAqB,sBAAsB,CAAC;AAEzD,wBAAsB,YAAY,CAAC,GAAG,SAAgB,EAAE,QAAQ,SAAwB,GAAG,OAAO,CAAC,mBAAmB,GAAG,IAAI,CAAC,CAe7H;AAED,wBAAsB,YAAY,CAAC,QAAQ,EAAE,mBAAmB,EAAE,GAAG,SAAgB,EAAE,QAAQ,SAAwB,GAAG,OAAO,CAAC,MAAM,CAAC,CAMxI;AAED,wBAAgB,qBAAqB,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,mBAAmB,CAS/E;AAGD,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,mBAAmB,GAAG,MAAM,EAAE,CAU1E"}
|
package/dist/manifest.js
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { readFile } from 'node:fs/promises';
|
|
2
|
+
import { resolve } from 'node:path';
|
|
3
|
+
import { validateManifest } from './schema.js';
|
|
4
|
+
import { writeFileAtomic } from '@skillctl/core';
|
|
5
|
+
// Re-export schema symbols + types for consumers/tests importing from manifest entry
|
|
6
|
+
export { AgentSkillsManifestSchema, validateManifest } from './schema.js';
|
|
7
|
+
/**
|
|
8
|
+
* Manifest parser / generator for agent-skills.json
|
|
9
|
+
* Uses Zod for schema + validation. Follows package-manager style.
|
|
10
|
+
*/
|
|
11
|
+
export const DEFAULT_MANIFEST_NAME = 'agent-skills.json';
|
|
12
|
+
export async function loadManifest(cwd = process.cwd(), fileName = DEFAULT_MANIFEST_NAME) {
|
|
13
|
+
const path = resolve(cwd, fileName);
|
|
14
|
+
try {
|
|
15
|
+
const raw = await readFile(path, 'utf8');
|
|
16
|
+
const json = JSON.parse(raw);
|
|
17
|
+
return validateManifest(json);
|
|
18
|
+
}
|
|
19
|
+
catch (err) {
|
|
20
|
+
if (err.code === 'ENOENT') {
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
if (err instanceof SyntaxError) {
|
|
24
|
+
throw new Error(`Invalid JSON in ${fileName}: ${err.message}`);
|
|
25
|
+
}
|
|
26
|
+
throw err;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
export async function saveManifest(manifest, cwd = process.cwd(), fileName = DEFAULT_MANIFEST_NAME) {
|
|
30
|
+
const validated = validateManifest(manifest);
|
|
31
|
+
const path = resolve(cwd, fileName);
|
|
32
|
+
const data = JSON.stringify(validated, null, 2) + '\n';
|
|
33
|
+
await writeFileAtomic(path, data);
|
|
34
|
+
return path;
|
|
35
|
+
}
|
|
36
|
+
export function createDefaultManifest(projectName) {
|
|
37
|
+
return {
|
|
38
|
+
name: projectName,
|
|
39
|
+
version: '0.0.0',
|
|
40
|
+
agentSkills: {
|
|
41
|
+
dependencies: {},
|
|
42
|
+
devDependencies: {},
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
// Collision policy helper (project > global precedence documented; here for names in one manifest)
|
|
47
|
+
export function checkNameCollision(manifest) {
|
|
48
|
+
const deps = Object.keys(manifest.agentSkills?.dependencies || {});
|
|
49
|
+
const dev = Object.keys(manifest.agentSkills?.devDependencies || {});
|
|
50
|
+
const seen = new Set();
|
|
51
|
+
const collisions = [];
|
|
52
|
+
for (const n of [...deps, ...dev]) {
|
|
53
|
+
if (seen.has(n))
|
|
54
|
+
collisions.push(n);
|
|
55
|
+
seen.add(n);
|
|
56
|
+
}
|
|
57
|
+
return collisions;
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=manifest.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manifest.js","sourceRoot":"","sources":["../src/manifest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAa,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAA6B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,EAAE,IAAI,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC;IACvD,MAAM,eAAe,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAClC,OAAO,IAAI,CAAC;AACd,CAAC;AAED,MAAM,UAAU,qBAAqB,CAAC,WAAoB;IACxD,OAAO;QACL,IAAI,EAAE,WAAW;QACjB,OAAO,EAAE,OAAO;QAChB,WAAW,EAAE;YACX,YAAY,EAAE,EAAE;YAChB,eAAe,EAAE,EAAE;SACpB;KACF,CAAC;AACJ,CAAC;AAED,mGAAmG;AACnG,MAAM,UAAU,kBAAkB,CAAC,QAA6B;IAC9D,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,WAAW,EAAE,YAAY,IAAI,EAAE,CAAC,CAAC;IACnE,MAAM,GAAG,GAAG,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,WAAW,EAAE,eAAe,IAAI,EAAE,CAAC,CAAC;IACrE,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAC;IAC/B,MAAM,UAAU,GAAa,EAAE,CAAC;IAChC,KAAK,MAAM,CAAC,IAAI,CAAC,GAAG,IAAI,EAAE,GAAG,GAAG,CAAC,EAAE,CAAC;QAClC,IAAI,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;YAAE,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QACpC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IACd,CAAC;IACD,OAAO,UAAU,CAAC;AACpB,CAAC"}
|
package/dist/schema.d.ts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { SkillManifest } from '@skillctl/core';
|
|
3
|
+
export declare const AgentSkillsManifestSchema: z.ZodObject<{
|
|
4
|
+
name: z.ZodOptional<z.ZodString>;
|
|
5
|
+
version: z.ZodOptional<z.ZodString>;
|
|
6
|
+
agentSkills: z.ZodDefault<z.ZodOptional<z.ZodObject<{
|
|
7
|
+
dependencies: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
8
|
+
devDependencies: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
9
|
+
}, "strip", z.ZodTypeAny, {
|
|
10
|
+
dependencies: Record<string, string>;
|
|
11
|
+
devDependencies: Record<string, string>;
|
|
12
|
+
}, {
|
|
13
|
+
dependencies?: Record<string, string> | undefined;
|
|
14
|
+
devDependencies?: Record<string, string> | undefined;
|
|
15
|
+
}>>>;
|
|
16
|
+
}, "strip", z.ZodTypeAny, {
|
|
17
|
+
agentSkills: {
|
|
18
|
+
dependencies: Record<string, string>;
|
|
19
|
+
devDependencies: Record<string, string>;
|
|
20
|
+
};
|
|
21
|
+
name?: string | undefined;
|
|
22
|
+
version?: string | undefined;
|
|
23
|
+
}, {
|
|
24
|
+
name?: string | undefined;
|
|
25
|
+
version?: string | undefined;
|
|
26
|
+
agentSkills?: {
|
|
27
|
+
dependencies?: Record<string, string> | undefined;
|
|
28
|
+
devDependencies?: Record<string, string> | undefined;
|
|
29
|
+
} | undefined;
|
|
30
|
+
}>;
|
|
31
|
+
export type AgentSkillsManifest = z.infer<typeof AgentSkillsManifestSchema>;
|
|
32
|
+
export declare function validateManifest(input: unknown): AgentSkillsManifest;
|
|
33
|
+
export declare function toSkillManifest(m: AgentSkillsManifest): SkillManifest;
|
|
34
|
+
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAQpD,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;;;;;EAUpC,CAAC;AAEH,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAC;AAG5E,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,mBAAmB,CAYpE;AAED,wBAAgB,eAAe,CAAC,CAAC,EAAE,mBAAmB,GAAG,aAAa,CAMrE"}
|
package/dist/schema.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
// Specifier grammar (MVP): (github:|skills.sh/|npm:|file:)[^ ]+ (optional @ref or ^semver range)
|
|
3
|
+
const SpecifierSchema = z.string().regex(/^(github:|skills\.sh\/|npm:|file:).+/, 'Invalid specifier. Must start with github:, skills.sh/, npm:, or file:');
|
|
4
|
+
export const AgentSkillsManifestSchema = z.object({
|
|
5
|
+
name: z.string().optional(),
|
|
6
|
+
version: z.string().optional(),
|
|
7
|
+
agentSkills: z
|
|
8
|
+
.object({
|
|
9
|
+
dependencies: z.record(z.string(), SpecifierSchema).default({}),
|
|
10
|
+
devDependencies: z.record(z.string(), SpecifierSchema).default({}),
|
|
11
|
+
})
|
|
12
|
+
.optional()
|
|
13
|
+
.default({ dependencies: {}, devDependencies: {} }),
|
|
14
|
+
});
|
|
15
|
+
// Validate + normalize manifest
|
|
16
|
+
export function validateManifest(input) {
|
|
17
|
+
const parsed = AgentSkillsManifestSchema.parse(input);
|
|
18
|
+
// Basic name collision policy within manifest: no duplicate keys across dep types
|
|
19
|
+
const deps = parsed.agentSkills?.dependencies || {};
|
|
20
|
+
const devDeps = parsed.agentSkills?.devDependencies || {};
|
|
21
|
+
const allNames = [...Object.keys(deps), ...Object.keys(devDeps)];
|
|
22
|
+
const unique = new Set(allNames);
|
|
23
|
+
if (unique.size !== allNames.length) {
|
|
24
|
+
const dups = allNames.filter((n, i) => allNames.indexOf(n) !== i);
|
|
25
|
+
throw new Error(`Manifest collision: duplicate skill names in dependencies and devDependencies: ${[...new Set(dups)].join(', ')}`);
|
|
26
|
+
}
|
|
27
|
+
return parsed;
|
|
28
|
+
}
|
|
29
|
+
export function toSkillManifest(m) {
|
|
30
|
+
return {
|
|
31
|
+
name: m.name,
|
|
32
|
+
version: m.version,
|
|
33
|
+
agentSkills: m.agentSkills,
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,iGAAiG;AACjG,MAAM,eAAe,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,KAAK,CACtC,sCAAsC,EACtC,wEAAwE,CACzE,CAAC;AAEF,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC,CAAC,MAAM,CAAC;IAChD,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC3B,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC9B,WAAW,EAAE,CAAC;SACX,MAAM,CAAC;QACN,YAAY,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,eAAe,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC;QAC/D,eAAe,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,eAAe,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC;KACnE,CAAC;SACD,QAAQ,EAAE;SACV,OAAO,CAAC,EAAE,YAAY,EAAE,EAAE,EAAE,eAAe,EAAE,EAAE,EAAE,CAAC;CACtD,CAAC,CAAC;AAIH,gCAAgC;AAChC,MAAM,UAAU,gBAAgB,CAAC,KAAc;IAC7C,MAAM,MAAM,GAAG,yBAAyB,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IACtD,kFAAkF;IAClF,MAAM,IAAI,GAAG,MAAM,CAAC,WAAW,EAAE,YAAY,IAAI,EAAE,CAAC;IACpD,MAAM,OAAO,GAAG,MAAM,CAAC,WAAW,EAAE,eAAe,IAAI,EAAE,CAAC;IAC1D,MAAM,QAAQ,GAAG,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;IACjE,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,QAAQ,CAAC,CAAC;IACjC,IAAI,MAAM,CAAC,IAAI,KAAK,QAAQ,CAAC,MAAM,EAAE,CAAC;QACpC,MAAM,IAAI,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;QAClE,MAAM,IAAI,KAAK,CAAC,kFAAkF,CAAC,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACrI,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,CAAsB;IACpD,OAAO;QACL,IAAI,EAAE,CAAC,CAAC,IAAI;QACZ,OAAO,EAAE,CAAC,CAAC,OAAO;QAClB,WAAW,EAAE,CAAC,CAAC,WAAW;KAC3B,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manifest-validation.test.d.ts","sourceRoot":"","sources":["../../src/test/manifest-validation.test.ts"],"names":[],"mappings":"AAiBA,iBAAe,QAAQ,kBA0CtB;AAMD,OAAO,EAAE,QAAQ,EAAE,CAAC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Validation tests for manifest (run via node --test after build to dist/test).
|
|
3
|
+
* Fixtures + schema validation + collision policy.
|
|
4
|
+
*/
|
|
5
|
+
import assert from 'node:assert/strict';
|
|
6
|
+
import { readFileSync } from 'node:fs';
|
|
7
|
+
import { fileURLToPath } from 'node:url';
|
|
8
|
+
import { dirname, join } from 'node:path';
|
|
9
|
+
import { validateManifest, checkNameCollision, createDefaultManifest, loadManifest, saveManifest, AgentSkillsManifestSchema } from '../manifest.js';
|
|
10
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
11
|
+
const fixturesDir = join(__dirname, '..', '..', 'fixtures');
|
|
12
|
+
function loadFixture(name) {
|
|
13
|
+
return JSON.parse(readFileSync(join(fixturesDir, name), 'utf8'));
|
|
14
|
+
}
|
|
15
|
+
async function runTests() {
|
|
16
|
+
console.log('Running manifest validation tests...');
|
|
17
|
+
// valid example
|
|
18
|
+
const valid = loadFixture('example-agent-skills.json');
|
|
19
|
+
const parsed = validateManifest(valid);
|
|
20
|
+
assert.ok(parsed.agentSkills?.dependencies?.['web-design-guidelines']);
|
|
21
|
+
assert.equal(checkNameCollision(parsed).length, 0);
|
|
22
|
+
console.log('✓ valid manifest + no collision');
|
|
23
|
+
// default
|
|
24
|
+
const def = createDefaultManifest('test-proj');
|
|
25
|
+
assert.equal(def.name, 'test-proj');
|
|
26
|
+
assert.deepEqual(def.agentSkills?.dependencies, {});
|
|
27
|
+
console.log('✓ createDefaultManifest');
|
|
28
|
+
// schema direct
|
|
29
|
+
const zvalid = AgentSkillsManifestSchema.parse(valid);
|
|
30
|
+
assert.ok(zvalid);
|
|
31
|
+
// invalid specifier
|
|
32
|
+
const bad = loadFixture('invalid-specifier.json');
|
|
33
|
+
assert.throws(() => validateManifest(bad), /Invalid specifier/);
|
|
34
|
+
console.log('✓ rejects invalid specifier');
|
|
35
|
+
// duplicate collision policy
|
|
36
|
+
const dup = loadFixture('duplicate-names.json');
|
|
37
|
+
assert.throws(() => validateManifest(dup), /Manifest collision/);
|
|
38
|
+
console.log('✓ collision policy enforced on dup names');
|
|
39
|
+
// load from disk (using this dir's fixture)
|
|
40
|
+
const loaded = await loadManifest(join(fixturesDir, '..'), 'fixtures/example-agent-skills.json');
|
|
41
|
+
assert.ok(loaded);
|
|
42
|
+
console.log('✓ loadManifest from fixture');
|
|
43
|
+
// save roundtrip (temp)
|
|
44
|
+
const tmpDir = join(__dirname, 'tmp-test-' + Date.now());
|
|
45
|
+
const savedPath = await saveManifest({ agentSkills: { dependencies: { 'x': 'github:foo/x' }, devDependencies: {} } }, tmpDir, 'agent-skills.test.json');
|
|
46
|
+
assert.ok(savedPath.includes('agent-skills.test.json'));
|
|
47
|
+
console.log('✓ saveManifest atomic roundtrip');
|
|
48
|
+
console.log('All manifest validation tests passed.');
|
|
49
|
+
}
|
|
50
|
+
if (import.meta.url === `file://${process.argv[1]}` || process.argv[1]?.endsWith('manifest-validation.test.ts')) {
|
|
51
|
+
runTests().catch((e) => { console.error(e); process.exit(1); });
|
|
52
|
+
}
|
|
53
|
+
export { runTests };
|
|
54
|
+
//# sourceMappingURL=manifest-validation.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manifest-validation.test.js","sourceRoot":"","sources":["../../src/test/manifest-validation.test.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,MAAM,MAAM,oBAAoB,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,YAAY,EAAE,YAAY,EAAE,yBAAyB,EAAE,MAAM,gBAAgB,CAAC;AAEpJ,MAAM,SAAS,GAAG,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AAC1D,MAAM,WAAW,GAAG,IAAI,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,UAAU,CAAC,CAAC;AAE5D,SAAS,WAAW,CAAC,IAAY;IAC/B,OAAO,IAAI,CAAC,KAAK,CAAC,YAA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AAClE,CAAC;AAED,OAAO,EAAE,QAAQ,EAAE,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@skillctl/manifest",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "agent-skills.json parser, generator, and Zod schema for skillctl",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": "skillctl contributors",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"main": "./dist/index.js",
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"files": [
|
|
11
|
+
"dist"
|
|
12
|
+
],
|
|
13
|
+
"dependencies": {
|
|
14
|
+
"zod": "^3.23.8",
|
|
15
|
+
"@skillctl/core": "0.2.0"
|
|
16
|
+
},
|
|
17
|
+
"devDependencies": {
|
|
18
|
+
"@types/node": "^20.14.0",
|
|
19
|
+
"rimraf": "^5.0.7",
|
|
20
|
+
"typescript": "^5.6.3"
|
|
21
|
+
},
|
|
22
|
+
"engines": {
|
|
23
|
+
"node": ">=22.13"
|
|
24
|
+
},
|
|
25
|
+
"repository": {
|
|
26
|
+
"type": "git",
|
|
27
|
+
"url": "https://github.com/xFurti/skillctl.git",
|
|
28
|
+
"directory": "packages/manifest"
|
|
29
|
+
},
|
|
30
|
+
"keywords": [
|
|
31
|
+
"manifest",
|
|
32
|
+
"agent-skills.json",
|
|
33
|
+
"schema",
|
|
34
|
+
"zod"
|
|
35
|
+
],
|
|
36
|
+
"scripts": {
|
|
37
|
+
"build": "tsc -b",
|
|
38
|
+
"dev": "tsc -b --watch",
|
|
39
|
+
"clean": "rimraf dist",
|
|
40
|
+
"lint": "tsc --noEmit",
|
|
41
|
+
"test": "node --test ./dist/test/*.test.js 2>&1 || echo 'no dist tests or node test runner skipped; run after build'"
|
|
42
|
+
}
|
|
43
|
+
}
|