@sweny-ai/core 0.1.77 → 0.1.78
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/browser.d.ts +11 -5
- package/dist/browser.js +11 -11
- package/dist/claude.d.ts +16 -0
- package/dist/claude.js +98 -9
- package/dist/cli/config.d.ts +22 -0
- package/dist/cli/config.js +56 -9
- package/dist/cli/main.d.ts +1 -1
- package/dist/cli/main.js +56 -57
- package/dist/cli/marketplace.js +35 -9
- package/dist/cli/publish.d.ts +10 -0
- package/dist/cli/publish.js +22 -14
- package/dist/loader.d.ts +40 -0
- package/dist/loader.js +73 -0
- package/dist/mcp-catalog.d.ts +47 -0
- package/dist/mcp-catalog.js +304 -0
- package/dist/mcp.d.ts +6 -9
- package/dist/mcp.js +24 -314
- package/dist/schema.d.ts +183 -151
- package/dist/schema.js +49 -7
- package/dist/skills/custom-loader.d.ts +40 -0
- package/dist/skills/custom-loader.js +107 -32
- package/dist/skills/index.d.ts +13 -1
- package/dist/skills/index.js +12 -3
- package/dist/studio.js +4 -1
- package/dist/templates.d.ts +29 -8
- package/dist/templates.js +30 -20
- package/dist/types.d.ts +12 -0
- package/dist/verify.js +42 -4
- package/package.json +8 -4
- package/dist/__tests__/cascade.test.d.ts +0 -11
- package/dist/__tests__/cascade.test.js +0 -452
- package/dist/__tests__/claude.test.d.ts +0 -1
- package/dist/__tests__/claude.test.js +0 -427
- package/dist/__tests__/custom-loader.test.d.ts +0 -1
- package/dist/__tests__/custom-loader.test.js +0 -116
- package/dist/__tests__/executor.test.d.ts +0 -1
- package/dist/__tests__/executor.test.js +0 -1635
- package/dist/__tests__/integration/datadog.integration.test.d.ts +0 -1
- package/dist/__tests__/integration/datadog.integration.test.js +0 -23
- package/dist/__tests__/integration/e2e-workflow.integration.test.d.ts +0 -1
- package/dist/__tests__/integration/e2e-workflow.integration.test.js +0 -75
- package/dist/__tests__/integration/github.integration.test.d.ts +0 -1
- package/dist/__tests__/integration/github.integration.test.js +0 -37
- package/dist/__tests__/integration/harness.d.ts +0 -24
- package/dist/__tests__/integration/harness.js +0 -34
- package/dist/__tests__/integration/linear.integration.test.d.ts +0 -1
- package/dist/__tests__/integration/linear.integration.test.js +0 -15
- package/dist/__tests__/integration/sentry.integration.test.d.ts +0 -1
- package/dist/__tests__/integration/sentry.integration.test.js +0 -20
- package/dist/__tests__/integration/slack.integration.test.d.ts +0 -1
- package/dist/__tests__/integration/slack.integration.test.js +0 -22
- package/dist/__tests__/integration/sources.integration.test.d.ts +0 -1
- package/dist/__tests__/integration/sources.integration.test.js +0 -123
- package/dist/__tests__/publish.test.d.ts +0 -1
- package/dist/__tests__/publish.test.js +0 -180
- package/dist/__tests__/requires.test.d.ts +0 -1
- package/dist/__tests__/requires.test.js +0 -82
- package/dist/__tests__/retry.test.d.ts +0 -1
- package/dist/__tests__/retry.test.js +0 -213
- package/dist/__tests__/schema.test.d.ts +0 -1
- package/dist/__tests__/schema.test.js +0 -600
- package/dist/__tests__/skill-config-integration.test.d.ts +0 -1
- package/dist/__tests__/skill-config-integration.test.js +0 -204
- package/dist/__tests__/skills-index.test.d.ts +0 -1
- package/dist/__tests__/skills-index.test.js +0 -119
- package/dist/__tests__/skills.test.d.ts +0 -1
- package/dist/__tests__/skills.test.js +0 -565
- package/dist/__tests__/spec-conformance.test.d.ts +0 -18
- package/dist/__tests__/spec-conformance.test.js +0 -1084
- package/dist/__tests__/studio.test.d.ts +0 -1
- package/dist/__tests__/studio.test.js +0 -403
- package/dist/__tests__/templates.test.d.ts +0 -1
- package/dist/__tests__/templates.test.js +0 -49
- package/dist/__tests__/testing.test.d.ts +0 -1
- package/dist/__tests__/testing.test.js +0 -242
- package/dist/__tests__/verify.test.d.ts +0 -1
- package/dist/__tests__/verify.test.js +0 -517
- package/dist/__tests__/version-consistency.test.d.ts +0 -1
- package/dist/__tests__/version-consistency.test.js +0 -312
- package/dist/__tests__/workflow-builder.test.d.ts +0 -1
- package/dist/__tests__/workflow-builder.test.js +0 -110
- package/dist/__tests__/workflow-yaml.test.d.ts +0 -1
- package/dist/__tests__/workflow-yaml.test.js +0 -201
- package/dist/cli/__tests__/diagram.test.d.ts +0 -1
- package/dist/cli/__tests__/diagram.test.js +0 -225
- package/dist/cli/__tests__/report-cloud.test.d.ts +0 -1
- package/dist/cli/__tests__/report-cloud.test.js +0 -165
- package/dist/cli/__tests__/upgrade.test.d.ts +0 -1
- package/dist/cli/__tests__/upgrade.test.js +0 -317
- package/dist/cli/__tests__/version-check.test.d.ts +0 -1
- package/dist/cli/__tests__/version-check.test.js +0 -209
- package/dist/cli/config.test.d.ts +0 -1
- package/dist/cli/config.test.js +0 -200
- package/dist/cli/credentials.test.d.ts +0 -1
- package/dist/cli/credentials.test.js +0 -172
- package/dist/cli/e2e.test.d.ts +0 -1
- package/dist/cli/e2e.test.js +0 -690
- package/dist/cli/marketplace.test.d.ts +0 -1
- package/dist/cli/marketplace.test.js +0 -355
- package/dist/cli/new.test.d.ts +0 -1
- package/dist/cli/new.test.js +0 -1043
- package/dist/cli/output.test.d.ts +0 -1
- package/dist/cli/output.test.js +0 -180
- package/dist/cli/publish.test.d.ts +0 -1
- package/dist/cli/publish.test.js +0 -610
- package/dist/cli/renderer.test.d.ts +0 -1
- package/dist/cli/renderer.test.js +0 -302
- package/dist/executor.test.d.ts +0 -1
- package/dist/executor.test.js +0 -618
- package/dist/mcp.test.d.ts +0 -1
- package/dist/mcp.test.js +0 -735
- package/dist/mermaid.test.d.ts +0 -1
- package/dist/mermaid.test.js +0 -256
- package/dist/sources.test.d.ts +0 -1
- package/dist/sources.test.js +0 -265
- package/dist/sources.validation.test.d.ts +0 -12
- package/dist/sources.validation.test.js +0 -380
- package/dist/workflow-builder.test.d.ts +0 -1
- package/dist/workflow-builder.test.js +0 -123
|
@@ -1,242 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect, beforeEach } from "vitest";
|
|
2
|
-
import { mkdirSync, writeFileSync, readFileSync, existsSync, rmSync } from "node:fs";
|
|
3
|
-
import * as path from "node:path";
|
|
4
|
-
import { tmpdir } from "node:os";
|
|
5
|
-
import { MockClaude, createFileSkill } from "../testing.js";
|
|
6
|
-
// ─── Fixtures ────────────────────────────────────────────────────
|
|
7
|
-
const tmpBase = path.join(tmpdir(), "sweny-testing-test");
|
|
8
|
-
function freshDir(name) {
|
|
9
|
-
const dir = path.join(tmpBase, `${name}-${Date.now()}`);
|
|
10
|
-
rmSync(dir, { recursive: true, force: true });
|
|
11
|
-
mkdirSync(dir, { recursive: true });
|
|
12
|
-
return dir;
|
|
13
|
-
}
|
|
14
|
-
const testWorkflow = {
|
|
15
|
-
id: "test",
|
|
16
|
-
name: "Test",
|
|
17
|
-
description: "",
|
|
18
|
-
entry: "first",
|
|
19
|
-
nodes: {
|
|
20
|
-
first: { name: "First", instruction: "Do the first thing", skills: [] },
|
|
21
|
-
second: { name: "Second", instruction: "Do the second thing", skills: [] },
|
|
22
|
-
alt: { name: "Alt", instruction: "Alternative path", skills: [] },
|
|
23
|
-
},
|
|
24
|
-
edges: [
|
|
25
|
-
{ from: "first", to: "second" },
|
|
26
|
-
{ from: "first", to: "alt", when: "needs alternative" },
|
|
27
|
-
],
|
|
28
|
-
};
|
|
29
|
-
// ─── MockClaude tests ────────────────────────────────────────────
|
|
30
|
-
describe("MockClaude", () => {
|
|
31
|
-
it("returns scripted responses in order", async () => {
|
|
32
|
-
const claude = new MockClaude({
|
|
33
|
-
responses: {
|
|
34
|
-
first: { data: { step: 1 } },
|
|
35
|
-
second: { data: { step: 2 } },
|
|
36
|
-
},
|
|
37
|
-
});
|
|
38
|
-
const r1 = await claude.run({ instruction: "Do first", context: {}, tools: [] });
|
|
39
|
-
expect(r1.data.step).toBe(1);
|
|
40
|
-
const r2 = await claude.run({ instruction: "Do second", context: {}, tools: [] });
|
|
41
|
-
expect(r2.data.step).toBe(2);
|
|
42
|
-
});
|
|
43
|
-
it("matches nodes by instruction when workflow is provided", async () => {
|
|
44
|
-
const claude = new MockClaude({
|
|
45
|
-
workflow: testWorkflow,
|
|
46
|
-
responses: {
|
|
47
|
-
first: { data: { step: "first" } },
|
|
48
|
-
alt: { data: { step: "alt" } },
|
|
49
|
-
},
|
|
50
|
-
});
|
|
51
|
-
// Call in non-sequential order using exact instructions
|
|
52
|
-
const r1 = await claude.run({
|
|
53
|
-
instruction: "Alternative path",
|
|
54
|
-
context: {},
|
|
55
|
-
tools: [],
|
|
56
|
-
});
|
|
57
|
-
expect(r1.data.step).toBe("alt");
|
|
58
|
-
const r2 = await claude.run({
|
|
59
|
-
instruction: "Do the first thing",
|
|
60
|
-
context: {},
|
|
61
|
-
tools: [],
|
|
62
|
-
});
|
|
63
|
-
expect(r2.data.step).toBe("first");
|
|
64
|
-
});
|
|
65
|
-
it("tracks execution order", async () => {
|
|
66
|
-
const claude = new MockClaude({
|
|
67
|
-
responses: {
|
|
68
|
-
a: { data: {} },
|
|
69
|
-
b: { data: {} },
|
|
70
|
-
},
|
|
71
|
-
});
|
|
72
|
-
await claude.run({ instruction: "x", context: {}, tools: [] });
|
|
73
|
-
await claude.run({ instruction: "y", context: {}, tools: [] });
|
|
74
|
-
expect(claude.executedNodes).toEqual(["a", "b"]);
|
|
75
|
-
});
|
|
76
|
-
it("returns default response for unknown nodes", async () => {
|
|
77
|
-
const claude = new MockClaude({ responses: {} });
|
|
78
|
-
const result = await claude.run({ instruction: "anything", context: {}, tools: [] });
|
|
79
|
-
expect(result.status).toBe("success");
|
|
80
|
-
expect(result.data.summary).toContain("no scripted response");
|
|
81
|
-
});
|
|
82
|
-
it("executes scripted tool calls", async () => {
|
|
83
|
-
const dir = freshDir("mock-tools");
|
|
84
|
-
const fileSkill = createFileSkill(dir);
|
|
85
|
-
const claude = new MockClaude({
|
|
86
|
-
responses: {
|
|
87
|
-
node1: {
|
|
88
|
-
toolCalls: [{ tool: "fs_write_json", input: { path: "test.json", data: { ok: true } } }],
|
|
89
|
-
data: { wrote: true },
|
|
90
|
-
},
|
|
91
|
-
},
|
|
92
|
-
});
|
|
93
|
-
const result = await claude.run({
|
|
94
|
-
instruction: "Write file",
|
|
95
|
-
context: {},
|
|
96
|
-
tools: fileSkill.tools,
|
|
97
|
-
});
|
|
98
|
-
expect(result.toolCalls).toHaveLength(1);
|
|
99
|
-
expect(result.toolCalls[0].tool).toBe("fs_write_json");
|
|
100
|
-
expect(existsSync(path.join(dir, "test.json"))).toBe(true);
|
|
101
|
-
});
|
|
102
|
-
it("records tool not found errors", async () => {
|
|
103
|
-
const claude = new MockClaude({
|
|
104
|
-
responses: {
|
|
105
|
-
node1: {
|
|
106
|
-
toolCalls: [{ tool: "nonexistent_tool", input: {} }],
|
|
107
|
-
data: {},
|
|
108
|
-
},
|
|
109
|
-
},
|
|
110
|
-
});
|
|
111
|
-
const result = await claude.run({ instruction: "x", context: {}, tools: [] });
|
|
112
|
-
expect(result.toolCalls[0].output).toEqual({ error: "tool not found" });
|
|
113
|
-
});
|
|
114
|
-
describe("evaluate", () => {
|
|
115
|
-
it("follows scripted routes", async () => {
|
|
116
|
-
const claude = new MockClaude({
|
|
117
|
-
responses: { first: { data: {} } },
|
|
118
|
-
routes: { first: "alt" },
|
|
119
|
-
});
|
|
120
|
-
await claude.run({ instruction: "x", context: {}, tools: [] });
|
|
121
|
-
const chosen = await claude.evaluate({
|
|
122
|
-
question: "Which path?",
|
|
123
|
-
context: {},
|
|
124
|
-
choices: [
|
|
125
|
-
{ id: "second", description: "Normal path" },
|
|
126
|
-
{ id: "alt", description: "Alternative path" },
|
|
127
|
-
],
|
|
128
|
-
});
|
|
129
|
-
expect(chosen).toBe("alt");
|
|
130
|
-
});
|
|
131
|
-
it("defaults to first choice when no route is scripted", async () => {
|
|
132
|
-
const claude = new MockClaude({ responses: { a: { data: {} } } });
|
|
133
|
-
await claude.run({ instruction: "x", context: {}, tools: [] });
|
|
134
|
-
const chosen = await claude.evaluate({
|
|
135
|
-
question: "Where?",
|
|
136
|
-
context: {},
|
|
137
|
-
choices: [
|
|
138
|
-
{ id: "x", description: "First" },
|
|
139
|
-
{ id: "y", description: "Second" },
|
|
140
|
-
],
|
|
141
|
-
});
|
|
142
|
-
expect(chosen).toBe("x");
|
|
143
|
-
});
|
|
144
|
-
it("ignores invalid scripted routes", async () => {
|
|
145
|
-
const claude = new MockClaude({
|
|
146
|
-
responses: { a: { data: {} } },
|
|
147
|
-
routes: { a: "nonexistent" },
|
|
148
|
-
});
|
|
149
|
-
await claude.run({ instruction: "x", context: {}, tools: [] });
|
|
150
|
-
const chosen = await claude.evaluate({
|
|
151
|
-
question: "Where?",
|
|
152
|
-
context: {},
|
|
153
|
-
choices: [{ id: "valid", description: "Valid" }],
|
|
154
|
-
});
|
|
155
|
-
expect(chosen).toBe("valid"); // falls back to first choice
|
|
156
|
-
});
|
|
157
|
-
});
|
|
158
|
-
describe("ask", () => {
|
|
159
|
-
it("returns scripted response from ask handler", async () => {
|
|
160
|
-
const claude = new MockClaude({
|
|
161
|
-
responses: {},
|
|
162
|
-
ask: (instruction, context) => `Got: ${instruction}; ctx keys: ${Object.keys(context).join(",")}`,
|
|
163
|
-
});
|
|
164
|
-
const result = await claude.ask({
|
|
165
|
-
instruction: "diagnose this",
|
|
166
|
-
context: { error: "x" },
|
|
167
|
-
});
|
|
168
|
-
expect(result).toBe("Got: diagnose this; ctx keys: error");
|
|
169
|
-
});
|
|
170
|
-
it("returns empty string when no ask handler is provided (exercises default-preamble fallback)", async () => {
|
|
171
|
-
const claude = new MockClaude({ responses: {} });
|
|
172
|
-
const result = await claude.ask({ instruction: "anything", context: {} });
|
|
173
|
-
expect(result).toBe("");
|
|
174
|
-
});
|
|
175
|
-
});
|
|
176
|
-
});
|
|
177
|
-
// ─── File skill tests ────────────────────────────────────────────
|
|
178
|
-
describe("createFileSkill", () => {
|
|
179
|
-
let dir;
|
|
180
|
-
beforeEach(() => {
|
|
181
|
-
dir = freshDir("fileskill");
|
|
182
|
-
});
|
|
183
|
-
it("reads and writes JSON", async () => {
|
|
184
|
-
const skill = createFileSkill(dir);
|
|
185
|
-
const write = skill.tools.find((t) => t.name === "fs_write_json");
|
|
186
|
-
const read = skill.tools.find((t) => t.name === "fs_read_json");
|
|
187
|
-
const ctx = { config: {}, logger: console };
|
|
188
|
-
await write.handler({ path: "test.json", data: { hello: "world" } }, ctx);
|
|
189
|
-
const result = await read.handler({ path: "test.json" }, ctx);
|
|
190
|
-
expect(result).toEqual({ hello: "world" });
|
|
191
|
-
});
|
|
192
|
-
it("reads text files", async () => {
|
|
193
|
-
const skill = createFileSkill(dir);
|
|
194
|
-
writeFileSync(path.join(dir, "hello.txt"), "hello world");
|
|
195
|
-
const read = skill.tools.find((t) => t.name === "fs_read_text");
|
|
196
|
-
const ctx = { config: {}, logger: console };
|
|
197
|
-
const result = await read.handler({ path: "hello.txt" }, ctx);
|
|
198
|
-
expect(result).toBe("hello world");
|
|
199
|
-
});
|
|
200
|
-
it("writes markdown with nested dirs", async () => {
|
|
201
|
-
const skill = createFileSkill(dir);
|
|
202
|
-
const write = skill.tools.find((t) => t.name === "fs_write_markdown");
|
|
203
|
-
const ctx = { config: {}, logger: console };
|
|
204
|
-
await write.handler({ path: "issues/ISSUE-1.md", content: "# Bug\n\nBroken" }, ctx);
|
|
205
|
-
const content = readFileSync(path.join(dir, "issues/ISSUE-1.md"), "utf-8");
|
|
206
|
-
expect(content).toContain("# Bug");
|
|
207
|
-
});
|
|
208
|
-
it("lists directory contents", async () => {
|
|
209
|
-
const skill = createFileSkill(dir);
|
|
210
|
-
writeFileSync(path.join(dir, "a.txt"), "a");
|
|
211
|
-
writeFileSync(path.join(dir, "b.txt"), "b");
|
|
212
|
-
const list = skill.tools.find((t) => t.name === "fs_list_dir");
|
|
213
|
-
const ctx = { config: {}, logger: console };
|
|
214
|
-
const result = await list.handler({}, ctx);
|
|
215
|
-
expect(result).toContain("a.txt");
|
|
216
|
-
expect(result).toContain("b.txt");
|
|
217
|
-
});
|
|
218
|
-
it("returns error info for non-existent directory", async () => {
|
|
219
|
-
const skill = createFileSkill(dir);
|
|
220
|
-
const list = skill.tools.find((t) => t.name === "fs_list_dir");
|
|
221
|
-
const ctx = { config: {}, logger: console };
|
|
222
|
-
const result = await list.handler({ path: "nonexistent" }, ctx);
|
|
223
|
-
expect(result).toHaveProperty("error");
|
|
224
|
-
});
|
|
225
|
-
it("creates deeply nested directories for JSON", async () => {
|
|
226
|
-
const skill = createFileSkill(dir);
|
|
227
|
-
const write = skill.tools.find((t) => t.name === "fs_write_json");
|
|
228
|
-
const ctx = { config: {}, logger: console };
|
|
229
|
-
await write.handler({ path: "deep/nested/dir/file.json", data: { deep: true } }, ctx);
|
|
230
|
-
expect(existsSync(path.join(dir, "deep/nested/dir/file.json"))).toBe(true);
|
|
231
|
-
});
|
|
232
|
-
it("has correct skill metadata", () => {
|
|
233
|
-
const skill = createFileSkill(dir);
|
|
234
|
-
expect(skill.id).toBe("filesystem");
|
|
235
|
-
expect(skill.tools).toHaveLength(5);
|
|
236
|
-
expect(skill.tools.map((t) => t.name)).toContain("fs_read_json");
|
|
237
|
-
expect(skill.tools.map((t) => t.name)).toContain("fs_read_text");
|
|
238
|
-
expect(skill.tools.map((t) => t.name)).toContain("fs_write_json");
|
|
239
|
-
expect(skill.tools.map((t) => t.name)).toContain("fs_write_markdown");
|
|
240
|
-
expect(skill.tools.map((t) => t.name)).toContain("fs_list_dir");
|
|
241
|
-
});
|
|
242
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|