@llmist/testing 16.1.0 → 16.2.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/dist/index.cjs +104 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +101 -2
- package/dist/index.d.ts +101 -2
- package/dist/index.js +102 -0
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -1896,6 +1896,8 @@ __export(index_exports, {
|
|
|
1896
1896
|
MockManager: () => MockManager,
|
|
1897
1897
|
MockPromptRecorder: () => MockPromptRecorder,
|
|
1898
1898
|
MockProviderAdapter: () => MockProviderAdapter,
|
|
1899
|
+
MockSkillBuilder: () => MockSkillBuilder,
|
|
1900
|
+
assertSkillContains: () => assertSkillContains,
|
|
1899
1901
|
collectOutput: () => collectOutput,
|
|
1900
1902
|
collectStream: () => collectStream,
|
|
1901
1903
|
collectStreamText: () => collectStreamText,
|
|
@@ -1927,9 +1929,13 @@ __export(index_exports, {
|
|
|
1927
1929
|
getStreamFinalChunk: () => getStreamFinalChunk,
|
|
1928
1930
|
mockGadget: () => mockGadget,
|
|
1929
1931
|
mockLLM: () => mockLLM,
|
|
1932
|
+
mockSkill: () => mockSkill,
|
|
1930
1933
|
resetMocks: () => resetMocks,
|
|
1931
1934
|
testGadget: () => testGadget,
|
|
1932
1935
|
testGadgetBatch: () => testGadgetBatch,
|
|
1936
|
+
testSkillActivation: () => testSkillActivation,
|
|
1937
|
+
testSkillParse: () => testSkillParse,
|
|
1938
|
+
validateSkill: () => validateSkill,
|
|
1933
1939
|
waitFor: () => waitFor
|
|
1934
1940
|
});
|
|
1935
1941
|
module.exports = __toCommonJS(index_exports);
|
|
@@ -3532,6 +3538,98 @@ function mockGadget() {
|
|
|
3532
3538
|
return new MockGadgetBuilder();
|
|
3533
3539
|
}
|
|
3534
3540
|
|
|
3541
|
+
// src/skill-testing.ts
|
|
3542
|
+
var import_llmist7 = require("llmist");
|
|
3543
|
+
function testSkillParse(content, sourcePath = "/test/skill/SKILL.md") {
|
|
3544
|
+
return (0, import_llmist7.parseSkillContent)(content, sourcePath, { type: "directory", path: "/test/skill" }, true);
|
|
3545
|
+
}
|
|
3546
|
+
async function testSkillActivation(skill, options) {
|
|
3547
|
+
return skill.activate({
|
|
3548
|
+
...options,
|
|
3549
|
+
// Disable shell preprocessing in tests by default for safety
|
|
3550
|
+
cwd: options?.cwd ?? "/test"
|
|
3551
|
+
});
|
|
3552
|
+
}
|
|
3553
|
+
function assertSkillContains(activation, expected) {
|
|
3554
|
+
for (const text of expected) {
|
|
3555
|
+
if (!activation.resolvedInstructions.includes(text)) {
|
|
3556
|
+
throw new Error(
|
|
3557
|
+
`Expected skill instructions to contain "${text}" but it was not found.
|
|
3558
|
+
Instructions: ${activation.resolvedInstructions.slice(0, 500)}...`
|
|
3559
|
+
);
|
|
3560
|
+
}
|
|
3561
|
+
}
|
|
3562
|
+
}
|
|
3563
|
+
function validateSkill(content) {
|
|
3564
|
+
const parsed = testSkillParse(content);
|
|
3565
|
+
return (0, import_llmist7.validateMetadata)(parsed.metadata);
|
|
3566
|
+
}
|
|
3567
|
+
function mockSkill(overrides, instructions = "Mock skill instructions for testing.") {
|
|
3568
|
+
const name = overrides?.name ?? "mock-skill";
|
|
3569
|
+
const description = overrides?.description ?? "A mock skill for testing";
|
|
3570
|
+
const metadataLines = Object.entries({ name, description, ...overrides }).filter(([_, v2]) => v2 !== void 0).map(([k2, v2]) => {
|
|
3571
|
+
if (Array.isArray(v2)) return `${k2}:
|
|
3572
|
+
${v2.map((i) => ` - "${i}"`).join("\n")}`;
|
|
3573
|
+
return `${k2}: ${v2}`;
|
|
3574
|
+
}).join("\n");
|
|
3575
|
+
return import_llmist7.Skill.fromContent(
|
|
3576
|
+
`---
|
|
3577
|
+
${metadataLines}
|
|
3578
|
+
---
|
|
3579
|
+
${instructions}`,
|
|
3580
|
+
`/mock/${name}/SKILL.md`,
|
|
3581
|
+
{ type: "directory", path: `/mock/${name}` }
|
|
3582
|
+
);
|
|
3583
|
+
}
|
|
3584
|
+
var MockSkillBuilder = class {
|
|
3585
|
+
_name = "mock-skill";
|
|
3586
|
+
_description = "A mock skill";
|
|
3587
|
+
_instructions = "Mock instructions.";
|
|
3588
|
+
_overrides = {};
|
|
3589
|
+
withName(name) {
|
|
3590
|
+
this._name = name;
|
|
3591
|
+
return this;
|
|
3592
|
+
}
|
|
3593
|
+
withDescription(description) {
|
|
3594
|
+
this._description = description;
|
|
3595
|
+
return this;
|
|
3596
|
+
}
|
|
3597
|
+
withInstructions(instructions) {
|
|
3598
|
+
this._instructions = instructions;
|
|
3599
|
+
return this;
|
|
3600
|
+
}
|
|
3601
|
+
withModel(model) {
|
|
3602
|
+
this._overrides.model = model;
|
|
3603
|
+
return this;
|
|
3604
|
+
}
|
|
3605
|
+
withContext(context) {
|
|
3606
|
+
this._overrides.context = context;
|
|
3607
|
+
return this;
|
|
3608
|
+
}
|
|
3609
|
+
withPaths(paths) {
|
|
3610
|
+
this._overrides.paths = paths;
|
|
3611
|
+
return this;
|
|
3612
|
+
}
|
|
3613
|
+
withAllowedTools(tools) {
|
|
3614
|
+
this._overrides["allowed-tools"] = tools;
|
|
3615
|
+
return this;
|
|
3616
|
+
}
|
|
3617
|
+
withGadgets(gadgets) {
|
|
3618
|
+
this._overrides.gadgets = gadgets;
|
|
3619
|
+
return this;
|
|
3620
|
+
}
|
|
3621
|
+
build() {
|
|
3622
|
+
return mockSkill(
|
|
3623
|
+
{
|
|
3624
|
+
name: this._name,
|
|
3625
|
+
description: this._description,
|
|
3626
|
+
...this._overrides
|
|
3627
|
+
},
|
|
3628
|
+
this._instructions
|
|
3629
|
+
);
|
|
3630
|
+
}
|
|
3631
|
+
};
|
|
3632
|
+
|
|
3535
3633
|
// src/stream-helpers.ts
|
|
3536
3634
|
function createTestStream(chunks) {
|
|
3537
3635
|
return (async function* () {
|
|
@@ -20346,6 +20444,8 @@ var createMockTUIApp = () => {
|
|
|
20346
20444
|
MockManager,
|
|
20347
20445
|
MockPromptRecorder,
|
|
20348
20446
|
MockProviderAdapter,
|
|
20447
|
+
MockSkillBuilder,
|
|
20448
|
+
assertSkillContains,
|
|
20349
20449
|
collectOutput,
|
|
20350
20450
|
collectStream,
|
|
20351
20451
|
collectStreamText,
|
|
@@ -20377,9 +20477,13 @@ var createMockTUIApp = () => {
|
|
|
20377
20477
|
getStreamFinalChunk,
|
|
20378
20478
|
mockGadget,
|
|
20379
20479
|
mockLLM,
|
|
20480
|
+
mockSkill,
|
|
20380
20481
|
resetMocks,
|
|
20381
20482
|
testGadget,
|
|
20382
20483
|
testGadgetBatch,
|
|
20484
|
+
testSkillActivation,
|
|
20485
|
+
testSkillParse,
|
|
20486
|
+
validateSkill,
|
|
20383
20487
|
waitFor
|
|
20384
20488
|
});
|
|
20385
20489
|
/*! Bundled license information:
|