skyloom 1.13.5 → 1.13.7
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/.github/workflows/ci.yml +36 -36
- package/README.md +220 -159
- package/config/providers.yaml +39 -39
- package/config/skills/api_integrator/SKILL.md +15 -15
- package/config/skills/arch_designer/SKILL.md +13 -13
- package/config/skills/ci_cd_manager/SKILL.md +14 -14
- package/config/skills/code_analysis/SKILL.md +13 -13
- package/config/skills/code_generator/SKILL.md +12 -12
- package/config/skills/code_reviewer/SKILL.md +13 -13
- package/config/skills/content_writer/SKILL.md +14 -14
- package/config/skills/data_transformer/SKILL.md +15 -15
- package/config/skills/document_analysis/SKILL.md +13 -13
- package/config/skills/emotional_companion/SKILL.md +15 -15
- package/config/skills/performance_checker/SKILL.md +14 -14
- package/config/skills/security_auditor/SKILL.md +14 -14
- package/config/skills/self_evolve/SKILL.md +13 -13
- package/config/skills/sys_operator/SKILL.md +15 -15
- package/config/skills/task_planner/SKILL.md +14 -14
- package/config/skills/web_research/SKILL.md +14 -14
- package/config/skills/workflow_designer/SKILL.md +13 -13
- package/dist/agents/dew.js +52 -52
- package/dist/agents/fair.js +84 -84
- package/dist/agents/fog.js +30 -30
- package/dist/agents/frost.js +32 -32
- package/dist/agents/rain.js +32 -32
- package/dist/agents/snow.js +68 -68
- package/dist/cli/commands_md.d.ts +41 -0
- package/dist/cli/commands_md.d.ts.map +1 -0
- package/dist/cli/commands_md.js +140 -0
- package/dist/cli/commands_md.js.map +1 -0
- package/dist/cli/input_macros.d.ts +28 -0
- package/dist/cli/input_macros.d.ts.map +1 -0
- package/dist/cli/input_macros.js +120 -0
- package/dist/cli/input_macros.js.map +1 -0
- package/dist/cli/loom.d.ts +220 -0
- package/dist/cli/loom.d.ts.map +1 -0
- package/dist/cli/loom.js +1094 -0
- package/dist/cli/loom.js.map +1 -0
- package/dist/cli/loom_chat.d.ts +20 -0
- package/dist/cli/loom_chat.d.ts.map +1 -0
- package/dist/cli/loom_chat.js +685 -0
- package/dist/cli/loom_chat.js.map +1 -0
- package/dist/cli/main.js +310 -14
- package/dist/cli/main.js.map +1 -1
- package/dist/cli/tui.d.ts.map +1 -1
- package/dist/cli/tui.js +7 -1
- package/dist/cli/tui.js.map +1 -1
- package/dist/core/agent/guard.d.ts +45 -0
- package/dist/core/agent/guard.d.ts.map +1 -0
- package/dist/core/agent/guard.js +113 -0
- package/dist/core/agent/guard.js.map +1 -0
- package/dist/core/agent.d.ts +17 -0
- package/dist/core/agent.d.ts.map +1 -1
- package/dist/core/agent.js +182 -93
- package/dist/core/agent.js.map +1 -1
- package/dist/core/factory.d.ts.map +1 -1
- package/dist/core/factory.js +34 -2
- package/dist/core/factory.js.map +1 -1
- package/dist/core/file_checkpoint.d.ts +57 -0
- package/dist/core/file_checkpoint.d.ts.map +1 -0
- package/dist/core/file_checkpoint.js +162 -0
- package/dist/core/file_checkpoint.js.map +1 -0
- package/dist/core/hooks.d.ts +43 -0
- package/dist/core/hooks.d.ts.map +1 -0
- package/dist/core/hooks.js +110 -0
- package/dist/core/hooks.js.map +1 -0
- package/dist/core/llm.d.ts.map +1 -1
- package/dist/core/llm.js +15 -9
- package/dist/core/llm.js.map +1 -1
- package/dist/core/longdoc.js +5 -5
- package/dist/core/mcp.d.ts +16 -0
- package/dist/core/mcp.d.ts.map +1 -1
- package/dist/core/mcp.js +55 -0
- package/dist/core/mcp.js.map +1 -1
- package/dist/core/model_config.d.ts +40 -0
- package/dist/core/model_config.d.ts.map +1 -0
- package/dist/core/model_config.js +191 -0
- package/dist/core/model_config.js.map +1 -0
- package/dist/core/skill.d.ts +7 -0
- package/dist/core/skill.d.ts.map +1 -1
- package/dist/core/skill.js +47 -0
- package/dist/core/skill.js.map +1 -1
- package/dist/core/skymd.d.ts +39 -0
- package/dist/core/skymd.d.ts.map +1 -0
- package/dist/core/skymd.js +177 -0
- package/dist/core/skymd.js.map +1 -0
- package/dist/core/tool.d.ts +12 -0
- package/dist/core/tool.d.ts.map +1 -1
- package/dist/core/tool.js +30 -0
- package/dist/core/tool.js.map +1 -1
- package/dist/core/verify.d.ts +27 -0
- package/dist/core/verify.d.ts.map +1 -0
- package/dist/core/verify.js +62 -0
- package/dist/core/verify.js.map +1 -0
- package/dist/skills/loader.d.ts +22 -2
- package/dist/skills/loader.d.ts.map +1 -1
- package/dist/skills/loader.js +45 -15
- package/dist/skills/loader.js.map +1 -1
- package/dist/tools/builtin.d.ts.map +1 -1
- package/dist/tools/builtin.js +13 -3
- package/dist/tools/builtin.js.map +1 -1
- package/dist/tools/model_tool.d.ts +11 -0
- package/dist/tools/model_tool.d.ts.map +1 -0
- package/dist/tools/model_tool.js +71 -0
- package/dist/tools/model_tool.js.map +1 -0
- package/dist/tools/todo.d.ts +30 -0
- package/dist/tools/todo.d.ts.map +1 -0
- package/dist/tools/todo.js +78 -0
- package/dist/tools/todo.js.map +1 -0
- package/docs/AESTHETIC_DESIGN.md +152 -144
- package/docs/OPTIMIZATION_PLAN.md +178 -178
- package/package.json +1 -1
- package/scripts/install.js +48 -48
- package/scripts/link.js +10 -10
- package/setup.bat +79 -79
- package/skill-test-ty2fOA/test.md +10 -10
- package/src/agents/dew.ts +70 -70
- package/src/agents/fair.ts +102 -102
- package/src/agents/fog.ts +48 -48
- package/src/agents/frost.ts +50 -50
- package/src/agents/rain.ts +50 -50
- package/src/agents/snow.ts +239 -239
- package/src/cli/commands_md.ts +112 -0
- package/src/cli/input_macros.ts +83 -0
- package/src/cli/loom.ts +982 -0
- package/src/cli/loom_chat.ts +598 -0
- package/src/cli/main.ts +255 -9
- package/src/cli/mode.ts +58 -58
- package/src/cli/tui.ts +228 -222
- package/src/core/agent/guard.ts +134 -0
- package/src/core/agent/task.ts +100 -100
- package/src/core/agent.ts +177 -95
- package/src/core/arbitrate.ts +162 -162
- package/src/core/catalog.ts +178 -178
- package/src/core/checkpoint.ts +94 -94
- package/src/core/estimate.ts +104 -104
- package/src/core/evolve.ts +191 -191
- package/src/core/factory.ts +31 -2
- package/src/core/file_checkpoint.ts +136 -0
- package/src/core/filter.ts +103 -103
- package/src/core/graph.ts +156 -156
- package/src/core/hooks.ts +126 -0
- package/src/core/icons.ts +53 -53
- package/src/core/index.ts +37 -37
- package/src/core/learn.ts +146 -146
- package/src/core/llm.ts +15 -9
- package/src/core/longdoc.ts +155 -155
- package/src/core/mcp.ts +48 -0
- package/src/core/mcp_server.ts +176 -176
- package/src/core/model_config.ts +157 -0
- package/src/core/profile.ts +255 -255
- package/src/core/router.ts +124 -124
- package/src/core/sandbox.ts +142 -142
- package/src/core/security.ts +243 -243
- package/src/core/skill.ts +42 -0
- package/src/core/skymd.ts +143 -0
- package/src/core/theme.ts +65 -65
- package/src/core/tool.ts +30 -0
- package/src/core/tool_router.ts +193 -193
- package/src/core/vector.ts +152 -152
- package/src/core/verify.ts +71 -0
- package/src/core/workspace.ts +150 -150
- package/src/plugins/loader.ts +66 -66
- package/src/skills/loader.ts +45 -16
- package/src/sql.js.d.ts +29 -29
- package/src/tools/builtin.ts +13 -3
- package/src/tools/computer.ts +269 -269
- package/src/tools/delegate.ts +49 -49
- package/src/tools/model_tool.ts +74 -0
- package/src/tools/todo.ts +76 -0
- package/src/web/tts.ts +93 -93
- package/tests/agent.test.ts +159 -159
- package/tests/agent_helpers.test.ts +48 -48
- package/tests/bus.test.ts +121 -121
- package/tests/catalog.test.ts +86 -86
- package/tests/checkpoint_commands.test.ts +124 -0
- package/tests/claude_compat.test.ts +110 -0
- package/tests/config.test.ts +41 -41
- package/tests/guard.test.ts +75 -0
- package/tests/icons.test.ts +45 -45
- package/tests/loom.test.ts +248 -0
- package/tests/memory.test.ts +170 -170
- package/tests/model_config.test.ts +109 -0
- package/tests/router.test.ts +86 -86
- package/tests/schemas.test.ts +51 -51
- package/tests/semantic.test.ts +83 -83
- package/tests/setup.ts +10 -10
- package/tests/skill.test.ts +172 -172
- package/tests/skymd.test.ts +146 -0
- package/tests/task.test.ts +60 -60
- package/tests/todo_toolstats.test.ts +94 -0
- package/tests/tool.test.ts +108 -108
- package/tests/tool_router.test.ts +71 -71
- package/tests/tui.test.ts +67 -67
- package/vitest.config.ts +17 -17
package/tests/schemas.test.ts
CHANGED
|
@@ -1,51 +1,51 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Tests for structured output schema validation.
|
|
3
|
-
*/
|
|
4
|
-
import { describe, it, expect } from 'vitest';
|
|
5
|
-
import { validateTaskPlan, TaskPlanSchema, parseSchema, SchemaValidationError } from '../src/core/schemas';
|
|
6
|
-
|
|
7
|
-
describe('validateTaskPlan', () => {
|
|
8
|
-
it('parses valid JSON plan', () => {
|
|
9
|
-
const data = JSON.parse('{"goal": "build app", "steps": [{"id": "1", "description": "design", "agent": "fog"}]}');
|
|
10
|
-
const plan = validateTaskPlan(data);
|
|
11
|
-
expect(plan.goal).toBe('build app');
|
|
12
|
-
expect(plan.steps).toHaveLength(1);
|
|
13
|
-
expect(plan.steps[0].agent).toBe('fog');
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
it('passes through agent name', () => {
|
|
17
|
-
const data = JSON.parse('{"goal": "x", "steps": [{"id": "1", "description": "a", "agent": "unknown"}]}');
|
|
18
|
-
const plan = validateTaskPlan(data);
|
|
19
|
-
// Schema-level validation just passes through; agent fallback is in SnowAgent
|
|
20
|
-
expect(plan.steps[0].agent).toBe('unknown');
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
it('empty steps', () => {
|
|
24
|
-
const data = JSON.parse('{"goal": "x", "steps": []}');
|
|
25
|
-
const plan = validateTaskPlan(data);
|
|
26
|
-
expect(plan.steps).toHaveLength(0);
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
it('parses depends_on', () => {
|
|
30
|
-
const data = JSON.parse('{"goal": "x", "steps": [{"id": "1", "description": "a", "depends_on": ["0"]}]}');
|
|
31
|
-
const plan = validateTaskPlan(data);
|
|
32
|
-
expect(plan.steps[0].depends_on).toEqual(['0']);
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
it('default fields', () => {
|
|
36
|
-
const data = JSON.parse('{"goal": "x", "steps": [{"id": "1", "description": "a"}]}');
|
|
37
|
-
const plan = validateTaskPlan(data);
|
|
38
|
-
expect(plan.steps[0].agent).toBe('rain');
|
|
39
|
-
expect(plan.steps[0].depends_on).toEqual([]);
|
|
40
|
-
});
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
describe('SchemaValidationError', () => {
|
|
44
|
-
it('raises on empty', () => {
|
|
45
|
-
expect(() => parseSchema('', TaskPlanSchema)).toThrow(SchemaValidationError);
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
it('raises on garbage', () => {
|
|
49
|
-
expect(() => parseSchema('<html>garbage</html>', TaskPlanSchema)).toThrow(SchemaValidationError);
|
|
50
|
-
});
|
|
51
|
-
});
|
|
1
|
+
/**
|
|
2
|
+
* Tests for structured output schema validation.
|
|
3
|
+
*/
|
|
4
|
+
import { describe, it, expect } from 'vitest';
|
|
5
|
+
import { validateTaskPlan, TaskPlanSchema, parseSchema, SchemaValidationError } from '../src/core/schemas';
|
|
6
|
+
|
|
7
|
+
describe('validateTaskPlan', () => {
|
|
8
|
+
it('parses valid JSON plan', () => {
|
|
9
|
+
const data = JSON.parse('{"goal": "build app", "steps": [{"id": "1", "description": "design", "agent": "fog"}]}');
|
|
10
|
+
const plan = validateTaskPlan(data);
|
|
11
|
+
expect(plan.goal).toBe('build app');
|
|
12
|
+
expect(plan.steps).toHaveLength(1);
|
|
13
|
+
expect(plan.steps[0].agent).toBe('fog');
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
it('passes through agent name', () => {
|
|
17
|
+
const data = JSON.parse('{"goal": "x", "steps": [{"id": "1", "description": "a", "agent": "unknown"}]}');
|
|
18
|
+
const plan = validateTaskPlan(data);
|
|
19
|
+
// Schema-level validation just passes through; agent fallback is in SnowAgent
|
|
20
|
+
expect(plan.steps[0].agent).toBe('unknown');
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it('empty steps', () => {
|
|
24
|
+
const data = JSON.parse('{"goal": "x", "steps": []}');
|
|
25
|
+
const plan = validateTaskPlan(data);
|
|
26
|
+
expect(plan.steps).toHaveLength(0);
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it('parses depends_on', () => {
|
|
30
|
+
const data = JSON.parse('{"goal": "x", "steps": [{"id": "1", "description": "a", "depends_on": ["0"]}]}');
|
|
31
|
+
const plan = validateTaskPlan(data);
|
|
32
|
+
expect(plan.steps[0].depends_on).toEqual(['0']);
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it('default fields', () => {
|
|
36
|
+
const data = JSON.parse('{"goal": "x", "steps": [{"id": "1", "description": "a"}]}');
|
|
37
|
+
const plan = validateTaskPlan(data);
|
|
38
|
+
expect(plan.steps[0].agent).toBe('rain');
|
|
39
|
+
expect(plan.steps[0].depends_on).toEqual([]);
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
describe('SchemaValidationError', () => {
|
|
44
|
+
it('raises on empty', () => {
|
|
45
|
+
expect(() => parseSchema('', TaskPlanSchema)).toThrow(SchemaValidationError);
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
it('raises on garbage', () => {
|
|
49
|
+
expect(() => parseSchema('<html>garbage</html>', TaskPlanSchema)).toThrow(SchemaValidationError);
|
|
50
|
+
});
|
|
51
|
+
});
|
package/tests/semantic.test.ts
CHANGED
|
@@ -1,83 +1,83 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Tests for lightweight semantic retrieval.
|
|
3
|
-
*/
|
|
4
|
-
import { describe, it, expect } from 'vitest';
|
|
5
|
-
import { SemanticScorer, getScorer } from '../src/core/semantic';
|
|
6
|
-
|
|
7
|
-
describe('SemanticScorer', () => {
|
|
8
|
-
const scorer = new SemanticScorer();
|
|
9
|
-
|
|
10
|
-
it('identical strings score 1.0', () => {
|
|
11
|
-
expect(scorer.similarity('hello world', 'hello world')).toBe(1.0);
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
it('completely different strings score 0.0', () => {
|
|
15
|
-
expect(scorer.similarity('aaaaa', 'bbbbb')).toBe(0.0);
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
it('partial overlap scores between 0 and 1', () => {
|
|
19
|
-
const score = scorer.similarity('deploy to server', 'deployment script');
|
|
20
|
-
expect(score).toBeGreaterThan(0.0);
|
|
21
|
-
expect(score).toBeLessThan(1.0);
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
it('CJK similarity works', () => {
|
|
25
|
-
const score = scorer.similarity('部署', '部署命令');
|
|
26
|
-
expect(score).toBeGreaterThan(0.0);
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
it('empty strings return 0', () => {
|
|
30
|
-
expect(scorer.similarity('', 'hello')).toBe(0.0);
|
|
31
|
-
expect(scorer.similarity('hello', '')).toBe(0.0);
|
|
32
|
-
expect(scorer.similarity('', '')).toBe(0.0);
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
it('case insensitive', () => {
|
|
36
|
-
expect(scorer.similarity('Hello World', 'hello world')).toBe(1.0);
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
it('mixed language overlap', () => {
|
|
40
|
-
const score = scorer.similarity('pnpm install', 'pnpm 安装');
|
|
41
|
-
expect(score).toBeGreaterThan(0.0);
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
it('code identifiers match partially', () => {
|
|
45
|
-
const score = scorer.similarity('snake_case_var', 'snakeCaseVar');
|
|
46
|
-
expect(score).toBeGreaterThan(0.0);
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
it('rank returns ordered results', () => {
|
|
50
|
-
const candidates = [
|
|
51
|
-
{ key: 'k1', value: 'deploy to production' },
|
|
52
|
-
{ key: 'k2', value: 'install dependencies' },
|
|
53
|
-
{ key: 'k3', value: 'rollback version' },
|
|
54
|
-
];
|
|
55
|
-
const ranked = scorer.rank('deploy', candidates, 'value', 2);
|
|
56
|
-
expect(ranked.length).toBeLessThanOrEqual(2);
|
|
57
|
-
expect(ranked[0][1].key).toBe('k1');
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
it('rank filters below minScore', () => {
|
|
61
|
-
const candidates = [
|
|
62
|
-
{ key: 'k1', value: 'completely unrelated text here' },
|
|
63
|
-
];
|
|
64
|
-
const ranked = scorer.rank('zzzzz', candidates, 'value', 1, 0.5);
|
|
65
|
-
expect(ranked).toHaveLength(0);
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
it('rank uses key field boost', () => {
|
|
69
|
-
const candidates = [
|
|
70
|
-
{ key: 'deploy_command', value: 'npm run build' },
|
|
71
|
-
];
|
|
72
|
-
const ranked = scorer.rank('deploy', candidates, 'value', 1);
|
|
73
|
-
expect(ranked).toHaveLength(1);
|
|
74
|
-
});
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
describe('getScorer singleton', () => {
|
|
78
|
-
it('returns the same instance', () => {
|
|
79
|
-
const s1 = getScorer();
|
|
80
|
-
const s2 = getScorer();
|
|
81
|
-
expect(s1).toBe(s2);
|
|
82
|
-
});
|
|
83
|
-
});
|
|
1
|
+
/**
|
|
2
|
+
* Tests for lightweight semantic retrieval.
|
|
3
|
+
*/
|
|
4
|
+
import { describe, it, expect } from 'vitest';
|
|
5
|
+
import { SemanticScorer, getScorer } from '../src/core/semantic';
|
|
6
|
+
|
|
7
|
+
describe('SemanticScorer', () => {
|
|
8
|
+
const scorer = new SemanticScorer();
|
|
9
|
+
|
|
10
|
+
it('identical strings score 1.0', () => {
|
|
11
|
+
expect(scorer.similarity('hello world', 'hello world')).toBe(1.0);
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
it('completely different strings score 0.0', () => {
|
|
15
|
+
expect(scorer.similarity('aaaaa', 'bbbbb')).toBe(0.0);
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it('partial overlap scores between 0 and 1', () => {
|
|
19
|
+
const score = scorer.similarity('deploy to server', 'deployment script');
|
|
20
|
+
expect(score).toBeGreaterThan(0.0);
|
|
21
|
+
expect(score).toBeLessThan(1.0);
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it('CJK similarity works', () => {
|
|
25
|
+
const score = scorer.similarity('部署', '部署命令');
|
|
26
|
+
expect(score).toBeGreaterThan(0.0);
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it('empty strings return 0', () => {
|
|
30
|
+
expect(scorer.similarity('', 'hello')).toBe(0.0);
|
|
31
|
+
expect(scorer.similarity('hello', '')).toBe(0.0);
|
|
32
|
+
expect(scorer.similarity('', '')).toBe(0.0);
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it('case insensitive', () => {
|
|
36
|
+
expect(scorer.similarity('Hello World', 'hello world')).toBe(1.0);
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
it('mixed language overlap', () => {
|
|
40
|
+
const score = scorer.similarity('pnpm install', 'pnpm 安装');
|
|
41
|
+
expect(score).toBeGreaterThan(0.0);
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it('code identifiers match partially', () => {
|
|
45
|
+
const score = scorer.similarity('snake_case_var', 'snakeCaseVar');
|
|
46
|
+
expect(score).toBeGreaterThan(0.0);
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
it('rank returns ordered results', () => {
|
|
50
|
+
const candidates = [
|
|
51
|
+
{ key: 'k1', value: 'deploy to production' },
|
|
52
|
+
{ key: 'k2', value: 'install dependencies' },
|
|
53
|
+
{ key: 'k3', value: 'rollback version' },
|
|
54
|
+
];
|
|
55
|
+
const ranked = scorer.rank('deploy', candidates, 'value', 2);
|
|
56
|
+
expect(ranked.length).toBeLessThanOrEqual(2);
|
|
57
|
+
expect(ranked[0][1].key).toBe('k1');
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
it('rank filters below minScore', () => {
|
|
61
|
+
const candidates = [
|
|
62
|
+
{ key: 'k1', value: 'completely unrelated text here' },
|
|
63
|
+
];
|
|
64
|
+
const ranked = scorer.rank('zzzzz', candidates, 'value', 1, 0.5);
|
|
65
|
+
expect(ranked).toHaveLength(0);
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
it('rank uses key field boost', () => {
|
|
69
|
+
const candidates = [
|
|
70
|
+
{ key: 'deploy_command', value: 'npm run build' },
|
|
71
|
+
];
|
|
72
|
+
const ranked = scorer.rank('deploy', candidates, 'value', 1);
|
|
73
|
+
expect(ranked).toHaveLength(1);
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
describe('getScorer singleton', () => {
|
|
78
|
+
it('returns the same instance', () => {
|
|
79
|
+
const s1 = getScorer();
|
|
80
|
+
const s2 = getScorer();
|
|
81
|
+
expect(s1).toBe(s2);
|
|
82
|
+
});
|
|
83
|
+
});
|
package/tests/setup.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Test setup — global fixtures and mocks for Skyloom tests.
|
|
3
|
-
*/
|
|
4
|
-
import { vi, beforeEach } from 'vitest';
|
|
5
|
-
import { MessageBus } from '../src/core/bus';
|
|
6
|
-
|
|
7
|
-
// Clear tool state before each test
|
|
8
|
-
beforeEach(() => {
|
|
9
|
-
// No-op — individual tests handle their own setup
|
|
10
|
-
});
|
|
1
|
+
/**
|
|
2
|
+
* Test setup — global fixtures and mocks for Skyloom tests.
|
|
3
|
+
*/
|
|
4
|
+
import { vi, beforeEach } from 'vitest';
|
|
5
|
+
import { MessageBus } from '../src/core/bus';
|
|
6
|
+
|
|
7
|
+
// Clear tool state before each test
|
|
8
|
+
beforeEach(() => {
|
|
9
|
+
// No-op — individual tests handle their own setup
|
|
10
|
+
});
|
package/tests/skill.test.ts
CHANGED
|
@@ -1,172 +1,172 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Tests for skill system.
|
|
3
|
-
*/
|
|
4
|
-
import { describe, it, expect } from 'vitest';
|
|
5
|
-
import * as fs from 'fs';
|
|
6
|
-
import * as path from 'path';
|
|
7
|
-
|
|
8
|
-
describe('Skill', () => {
|
|
9
|
-
it('creates a skill with model override', async () => {
|
|
10
|
-
const { Skill } = await import('../src/core/skill');
|
|
11
|
-
const skill = new Skill({
|
|
12
|
-
name: 'test_skill',
|
|
13
|
-
description: 'A test skill',
|
|
14
|
-
model: 'claude-opus-4-7',
|
|
15
|
-
});
|
|
16
|
-
expect(skill.model).toBe('claude-opus-4-7');
|
|
17
|
-
expect(skill.temperature).toBeNull();
|
|
18
|
-
expect(skill.maxTokens).toBeNull();
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
it('creates a skill with temperature override', async () => {
|
|
22
|
-
const { Skill } = await import('../src/core/skill');
|
|
23
|
-
const skill = new Skill({ name: 'test_skill', description: 'A test skill', temperature: 0.3 });
|
|
24
|
-
expect(skill.temperature).toBe(0.3);
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
it('creates a skill with max_tokens override', async () => {
|
|
28
|
-
const { Skill } = await import('../src/core/skill');
|
|
29
|
-
const skill = new Skill({ name: 'test_skill', description: 'A test skill', maxTokens: 32000 });
|
|
30
|
-
expect(skill.maxTokens).toBe(32000);
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
it('default has no overrides', async () => {
|
|
34
|
-
const { Skill } = await import('../src/core/skill');
|
|
35
|
-
const skill = new Skill({ name: 'test', description: 'test' });
|
|
36
|
-
expect(skill.model).toBeNull();
|
|
37
|
-
expect(skill.temperature).toBeNull();
|
|
38
|
-
expect(skill.maxTokens).toBeNull();
|
|
39
|
-
});
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
describe('Skill.fromMarkdown', () => {
|
|
43
|
-
it('loads skill with YAML frontmatter', async () => {
|
|
44
|
-
const { Skill } = await import('../src/core/skill');
|
|
45
|
-
const tmpDir = fs.mkdtempSync('skill-test-');
|
|
46
|
-
const mdPath = path.join(tmpDir, 'test.md');
|
|
47
|
-
fs.writeFileSync(mdPath, `---
|
|
48
|
-
name: test_skill
|
|
49
|
-
description: A test
|
|
50
|
-
model: claude-sonnet-4-6
|
|
51
|
-
temperature: 0.5
|
|
52
|
-
max_tokens: 8192
|
|
53
|
-
---
|
|
54
|
-
|
|
55
|
-
## Test Skill
|
|
56
|
-
This is a test skill.
|
|
57
|
-
`, 'utf-8');
|
|
58
|
-
|
|
59
|
-
const skill = Skill.fromMarkdown(mdPath);
|
|
60
|
-
expect(skill).not.toBeNull();
|
|
61
|
-
if (skill) {
|
|
62
|
-
expect(skill.model).toBe('claude-sonnet-4-6');
|
|
63
|
-
expect(skill.temperature).toBe(0.5);
|
|
64
|
-
expect(skill.maxTokens).toBe(8192);
|
|
65
|
-
expect(skill.systemPrompt).toContain('This is a test skill');
|
|
66
|
-
}
|
|
67
|
-
fs.rmSync(tmpDir, { recursive: true, force: true });
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
it('supports string path', async () => {
|
|
71
|
-
const { Skill } = await import('../src/core/skill');
|
|
72
|
-
const tmpDir = fs.mkdtempSync('skill-test-');
|
|
73
|
-
const mdPath = path.join(tmpDir, 'x.md');
|
|
74
|
-
fs.writeFileSync(mdPath, '---\nname: x\ndescription: x\n---\n\nBody.', 'utf-8');
|
|
75
|
-
const s = Skill.fromMarkdown(mdPath);
|
|
76
|
-
expect(s).not.toBeNull();
|
|
77
|
-
if (s) {
|
|
78
|
-
expect(s.name).toBe('x');
|
|
79
|
-
expect(typeof s.sourcePath).toBe('string');
|
|
80
|
-
}
|
|
81
|
-
fs.rmSync(tmpDir, { recursive: true, force: true });
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
it('derives triggers from quoted descriptions', async () => {
|
|
85
|
-
const { Skill } = await import('../src/core/skill');
|
|
86
|
-
const tmpDir = fs.mkdtempSync('skill-test-');
|
|
87
|
-
const mdPath = path.join(tmpDir, 'pptx.md');
|
|
88
|
-
fs.writeFileSync(mdPath, `---
|
|
89
|
-
name: pptx
|
|
90
|
-
description: |-
|
|
91
|
-
Use this skill any time a .pptx file is involved.
|
|
92
|
-
Trigger whenever the user mentions "deck," "slides," or "presentation."
|
|
93
|
-
If a .pptx file needs to be opened, use it.
|
|
94
|
-
---
|
|
95
|
-
Body.`, 'utf-8');
|
|
96
|
-
|
|
97
|
-
const s = Skill.fromMarkdown(mdPath);
|
|
98
|
-
expect(s).not.toBeNull();
|
|
99
|
-
if (s) {
|
|
100
|
-
const triggersLower = s.triggers.map(t => t.toLowerCase());
|
|
101
|
-
expect(triggersLower).toContain('deck');
|
|
102
|
-
expect(triggersLower).toContain('slides');
|
|
103
|
-
expect(triggersLower).toContain('presentation');
|
|
104
|
-
expect(triggersLower).toContain('.pptx');
|
|
105
|
-
}
|
|
106
|
-
fs.rmSync(tmpDir, { recursive: true, force: true });
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
it('small body loaded in full', async () => {
|
|
110
|
-
const { Skill } = await import('../src/core/skill');
|
|
111
|
-
const tmpDir = fs.mkdtempSync('skill-test-');
|
|
112
|
-
const mdPath = path.join(tmpDir, 'small.md');
|
|
113
|
-
fs.writeFileSync(mdPath, '---\nname: small\ndescription: x\n---\n\n# Small Skill\n\nThis fits inline easily.', 'utf-8');
|
|
114
|
-
const s = Skill.fromMarkdown(mdPath);
|
|
115
|
-
expect(s).not.toBeNull();
|
|
116
|
-
if (s) {
|
|
117
|
-
expect(s.bodyTruncated).toBe(false);
|
|
118
|
-
expect(s.systemPrompt).toContain('This fits inline easily');
|
|
119
|
-
}
|
|
120
|
-
fs.rmSync(tmpDir, { recursive: true, force: true });
|
|
121
|
-
});
|
|
122
|
-
|
|
123
|
-
it('large body truncated to head', async () => {
|
|
124
|
-
const { Skill } = await import('../src/core/skill');
|
|
125
|
-
const tmpDir = fs.mkdtempSync('skill-test-');
|
|
126
|
-
const mdPath = path.join(tmpDir, 'big.md');
|
|
127
|
-
|
|
128
|
-
let body = '# Big Skill\n\n## Quick Reference\nFirst section content.\n\n';
|
|
129
|
-
body += '## Detailed Guide\n';
|
|
130
|
-
body += 'X'.repeat(5000);
|
|
131
|
-
|
|
132
|
-
fs.writeFileSync(mdPath, `---\nname: big\ndescription: x\n---\n\n${body}`, 'utf-8');
|
|
133
|
-
const s = Skill.fromMarkdown(mdPath);
|
|
134
|
-
expect(s).not.toBeNull();
|
|
135
|
-
if (s) {
|
|
136
|
-
expect(s.bodyTruncated).toBe(true);
|
|
137
|
-
expect(s.systemPrompt).toContain('Big Skill');
|
|
138
|
-
expect(s.systemPrompt).toContain('Quick Reference');
|
|
139
|
-
expect(s.systemPrompt).not.toContain('Detailed Guide');
|
|
140
|
-
}
|
|
141
|
-
fs.rmSync(tmpDir, { recursive: true, force: true });
|
|
142
|
-
});
|
|
143
|
-
});
|
|
144
|
-
|
|
145
|
-
describe('SkillRegistry', () => {
|
|
146
|
-
it('registers and retrieves skills', async () => {
|
|
147
|
-
const { Skill, SkillRegistry } = await import('../src/core/skill');
|
|
148
|
-
const reg = new SkillRegistry();
|
|
149
|
-
const skill = new Skill({ name: 'test', description: 'Test' });
|
|
150
|
-
reg.register(skill);
|
|
151
|
-
expect(reg.get('test')).toBe(skill);
|
|
152
|
-
expect(reg.get('missing')).toBeUndefined();
|
|
153
|
-
});
|
|
154
|
-
|
|
155
|
-
it('lists names', async () => {
|
|
156
|
-
const { Skill, SkillRegistry } = await import('../src/core/skill');
|
|
157
|
-
const reg = new SkillRegistry();
|
|
158
|
-
reg.register(new Skill({ name: 'a', description: 'A' }));
|
|
159
|
-
reg.register(new Skill({ name: 'b', description: 'B' }));
|
|
160
|
-
expect(reg.listNames()).toEqual(['a', 'b']);
|
|
161
|
-
});
|
|
162
|
-
|
|
163
|
-
it('merges registries', async () => {
|
|
164
|
-
const { Skill, SkillRegistry } = await import('../src/core/skill');
|
|
165
|
-
const r1 = new SkillRegistry();
|
|
166
|
-
r1.register(new Skill({ name: 'a', description: 'A' }));
|
|
167
|
-
const r2 = new SkillRegistry();
|
|
168
|
-
r2.register(new Skill({ name: 'b', description: 'B' }));
|
|
169
|
-
r1.merge(r2);
|
|
170
|
-
expect(r1.get('b')).toBeDefined();
|
|
171
|
-
});
|
|
172
|
-
});
|
|
1
|
+
/**
|
|
2
|
+
* Tests for skill system.
|
|
3
|
+
*/
|
|
4
|
+
import { describe, it, expect } from 'vitest';
|
|
5
|
+
import * as fs from 'fs';
|
|
6
|
+
import * as path from 'path';
|
|
7
|
+
|
|
8
|
+
describe('Skill', () => {
|
|
9
|
+
it('creates a skill with model override', async () => {
|
|
10
|
+
const { Skill } = await import('../src/core/skill');
|
|
11
|
+
const skill = new Skill({
|
|
12
|
+
name: 'test_skill',
|
|
13
|
+
description: 'A test skill',
|
|
14
|
+
model: 'claude-opus-4-7',
|
|
15
|
+
});
|
|
16
|
+
expect(skill.model).toBe('claude-opus-4-7');
|
|
17
|
+
expect(skill.temperature).toBeNull();
|
|
18
|
+
expect(skill.maxTokens).toBeNull();
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it('creates a skill with temperature override', async () => {
|
|
22
|
+
const { Skill } = await import('../src/core/skill');
|
|
23
|
+
const skill = new Skill({ name: 'test_skill', description: 'A test skill', temperature: 0.3 });
|
|
24
|
+
expect(skill.temperature).toBe(0.3);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it('creates a skill with max_tokens override', async () => {
|
|
28
|
+
const { Skill } = await import('../src/core/skill');
|
|
29
|
+
const skill = new Skill({ name: 'test_skill', description: 'A test skill', maxTokens: 32000 });
|
|
30
|
+
expect(skill.maxTokens).toBe(32000);
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it('default has no overrides', async () => {
|
|
34
|
+
const { Skill } = await import('../src/core/skill');
|
|
35
|
+
const skill = new Skill({ name: 'test', description: 'test' });
|
|
36
|
+
expect(skill.model).toBeNull();
|
|
37
|
+
expect(skill.temperature).toBeNull();
|
|
38
|
+
expect(skill.maxTokens).toBeNull();
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
describe('Skill.fromMarkdown', () => {
|
|
43
|
+
it('loads skill with YAML frontmatter', async () => {
|
|
44
|
+
const { Skill } = await import('../src/core/skill');
|
|
45
|
+
const tmpDir = fs.mkdtempSync('skill-test-');
|
|
46
|
+
const mdPath = path.join(tmpDir, 'test.md');
|
|
47
|
+
fs.writeFileSync(mdPath, `---
|
|
48
|
+
name: test_skill
|
|
49
|
+
description: A test
|
|
50
|
+
model: claude-sonnet-4-6
|
|
51
|
+
temperature: 0.5
|
|
52
|
+
max_tokens: 8192
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
## Test Skill
|
|
56
|
+
This is a test skill.
|
|
57
|
+
`, 'utf-8');
|
|
58
|
+
|
|
59
|
+
const skill = Skill.fromMarkdown(mdPath);
|
|
60
|
+
expect(skill).not.toBeNull();
|
|
61
|
+
if (skill) {
|
|
62
|
+
expect(skill.model).toBe('claude-sonnet-4-6');
|
|
63
|
+
expect(skill.temperature).toBe(0.5);
|
|
64
|
+
expect(skill.maxTokens).toBe(8192);
|
|
65
|
+
expect(skill.systemPrompt).toContain('This is a test skill');
|
|
66
|
+
}
|
|
67
|
+
fs.rmSync(tmpDir, { recursive: true, force: true });
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
it('supports string path', async () => {
|
|
71
|
+
const { Skill } = await import('../src/core/skill');
|
|
72
|
+
const tmpDir = fs.mkdtempSync('skill-test-');
|
|
73
|
+
const mdPath = path.join(tmpDir, 'x.md');
|
|
74
|
+
fs.writeFileSync(mdPath, '---\nname: x\ndescription: x\n---\n\nBody.', 'utf-8');
|
|
75
|
+
const s = Skill.fromMarkdown(mdPath);
|
|
76
|
+
expect(s).not.toBeNull();
|
|
77
|
+
if (s) {
|
|
78
|
+
expect(s.name).toBe('x');
|
|
79
|
+
expect(typeof s.sourcePath).toBe('string');
|
|
80
|
+
}
|
|
81
|
+
fs.rmSync(tmpDir, { recursive: true, force: true });
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
it('derives triggers from quoted descriptions', async () => {
|
|
85
|
+
const { Skill } = await import('../src/core/skill');
|
|
86
|
+
const tmpDir = fs.mkdtempSync('skill-test-');
|
|
87
|
+
const mdPath = path.join(tmpDir, 'pptx.md');
|
|
88
|
+
fs.writeFileSync(mdPath, `---
|
|
89
|
+
name: pptx
|
|
90
|
+
description: |-
|
|
91
|
+
Use this skill any time a .pptx file is involved.
|
|
92
|
+
Trigger whenever the user mentions "deck," "slides," or "presentation."
|
|
93
|
+
If a .pptx file needs to be opened, use it.
|
|
94
|
+
---
|
|
95
|
+
Body.`, 'utf-8');
|
|
96
|
+
|
|
97
|
+
const s = Skill.fromMarkdown(mdPath);
|
|
98
|
+
expect(s).not.toBeNull();
|
|
99
|
+
if (s) {
|
|
100
|
+
const triggersLower = s.triggers.map(t => t.toLowerCase());
|
|
101
|
+
expect(triggersLower).toContain('deck');
|
|
102
|
+
expect(triggersLower).toContain('slides');
|
|
103
|
+
expect(triggersLower).toContain('presentation');
|
|
104
|
+
expect(triggersLower).toContain('.pptx');
|
|
105
|
+
}
|
|
106
|
+
fs.rmSync(tmpDir, { recursive: true, force: true });
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
it('small body loaded in full', async () => {
|
|
110
|
+
const { Skill } = await import('../src/core/skill');
|
|
111
|
+
const tmpDir = fs.mkdtempSync('skill-test-');
|
|
112
|
+
const mdPath = path.join(tmpDir, 'small.md');
|
|
113
|
+
fs.writeFileSync(mdPath, '---\nname: small\ndescription: x\n---\n\n# Small Skill\n\nThis fits inline easily.', 'utf-8');
|
|
114
|
+
const s = Skill.fromMarkdown(mdPath);
|
|
115
|
+
expect(s).not.toBeNull();
|
|
116
|
+
if (s) {
|
|
117
|
+
expect(s.bodyTruncated).toBe(false);
|
|
118
|
+
expect(s.systemPrompt).toContain('This fits inline easily');
|
|
119
|
+
}
|
|
120
|
+
fs.rmSync(tmpDir, { recursive: true, force: true });
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
it('large body truncated to head', async () => {
|
|
124
|
+
const { Skill } = await import('../src/core/skill');
|
|
125
|
+
const tmpDir = fs.mkdtempSync('skill-test-');
|
|
126
|
+
const mdPath = path.join(tmpDir, 'big.md');
|
|
127
|
+
|
|
128
|
+
let body = '# Big Skill\n\n## Quick Reference\nFirst section content.\n\n';
|
|
129
|
+
body += '## Detailed Guide\n';
|
|
130
|
+
body += 'X'.repeat(5000);
|
|
131
|
+
|
|
132
|
+
fs.writeFileSync(mdPath, `---\nname: big\ndescription: x\n---\n\n${body}`, 'utf-8');
|
|
133
|
+
const s = Skill.fromMarkdown(mdPath);
|
|
134
|
+
expect(s).not.toBeNull();
|
|
135
|
+
if (s) {
|
|
136
|
+
expect(s.bodyTruncated).toBe(true);
|
|
137
|
+
expect(s.systemPrompt).toContain('Big Skill');
|
|
138
|
+
expect(s.systemPrompt).toContain('Quick Reference');
|
|
139
|
+
expect(s.systemPrompt).not.toContain('Detailed Guide');
|
|
140
|
+
}
|
|
141
|
+
fs.rmSync(tmpDir, { recursive: true, force: true });
|
|
142
|
+
});
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
describe('SkillRegistry', () => {
|
|
146
|
+
it('registers and retrieves skills', async () => {
|
|
147
|
+
const { Skill, SkillRegistry } = await import('../src/core/skill');
|
|
148
|
+
const reg = new SkillRegistry();
|
|
149
|
+
const skill = new Skill({ name: 'test', description: 'Test' });
|
|
150
|
+
reg.register(skill);
|
|
151
|
+
expect(reg.get('test')).toBe(skill);
|
|
152
|
+
expect(reg.get('missing')).toBeUndefined();
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
it('lists names', async () => {
|
|
156
|
+
const { Skill, SkillRegistry } = await import('../src/core/skill');
|
|
157
|
+
const reg = new SkillRegistry();
|
|
158
|
+
reg.register(new Skill({ name: 'a', description: 'A' }));
|
|
159
|
+
reg.register(new Skill({ name: 'b', description: 'B' }));
|
|
160
|
+
expect(reg.listNames()).toEqual(['a', 'b']);
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
it('merges registries', async () => {
|
|
164
|
+
const { Skill, SkillRegistry } = await import('../src/core/skill');
|
|
165
|
+
const r1 = new SkillRegistry();
|
|
166
|
+
r1.register(new Skill({ name: 'a', description: 'A' }));
|
|
167
|
+
const r2 = new SkillRegistry();
|
|
168
|
+
r2.register(new Skill({ name: 'b', description: 'B' }));
|
|
169
|
+
r1.merge(r2);
|
|
170
|
+
expect(r1.get('b')).toBeDefined();
|
|
171
|
+
});
|
|
172
|
+
});
|