@sweny-ai/core 0.1.76 → 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.
Files changed (123) hide show
  1. package/dist/browser.d.ts +11 -5
  2. package/dist/browser.js +11 -11
  3. package/dist/claude.d.ts +20 -0
  4. package/dist/claude.js +139 -9
  5. package/dist/cli/config.d.ts +22 -0
  6. package/dist/cli/config.js +56 -9
  7. package/dist/cli/main.d.ts +1 -1
  8. package/dist/cli/main.js +56 -57
  9. package/dist/cli/marketplace.js +35 -9
  10. package/dist/cli/publish.d.ts +10 -0
  11. package/dist/cli/publish.js +22 -14
  12. package/dist/executor.js +104 -43
  13. package/dist/loader.d.ts +40 -0
  14. package/dist/loader.js +73 -0
  15. package/dist/mcp-catalog.d.ts +47 -0
  16. package/dist/mcp-catalog.js +304 -0
  17. package/dist/mcp.d.ts +6 -9
  18. package/dist/mcp.js +24 -314
  19. package/dist/requires.d.ts +7 -0
  20. package/dist/requires.js +34 -0
  21. package/dist/retry.d.ts +23 -0
  22. package/dist/retry.js +72 -0
  23. package/dist/schema.d.ts +667 -80
  24. package/dist/schema.js +144 -5
  25. package/dist/skills/custom-loader.d.ts +40 -0
  26. package/dist/skills/custom-loader.js +107 -32
  27. package/dist/skills/index.d.ts +13 -1
  28. package/dist/skills/index.js +12 -3
  29. package/dist/studio.js +4 -1
  30. package/dist/templates.d.ts +29 -8
  31. package/dist/templates.js +30 -20
  32. package/dist/testing.d.ts +7 -0
  33. package/dist/testing.js +7 -0
  34. package/dist/types.d.ts +76 -0
  35. package/dist/verify.d.ts +1 -0
  36. package/dist/verify.js +43 -5
  37. package/package.json +8 -4
  38. package/dist/__tests__/cascade.test.d.ts +0 -11
  39. package/dist/__tests__/cascade.test.js +0 -449
  40. package/dist/__tests__/claude.test.d.ts +0 -1
  41. package/dist/__tests__/claude.test.js +0 -427
  42. package/dist/__tests__/custom-loader.test.d.ts +0 -1
  43. package/dist/__tests__/custom-loader.test.js +0 -116
  44. package/dist/__tests__/executor.test.d.ts +0 -1
  45. package/dist/__tests__/executor.test.js +0 -736
  46. package/dist/__tests__/integration/datadog.integration.test.d.ts +0 -1
  47. package/dist/__tests__/integration/datadog.integration.test.js +0 -23
  48. package/dist/__tests__/integration/e2e-workflow.integration.test.d.ts +0 -1
  49. package/dist/__tests__/integration/e2e-workflow.integration.test.js +0 -75
  50. package/dist/__tests__/integration/github.integration.test.d.ts +0 -1
  51. package/dist/__tests__/integration/github.integration.test.js +0 -37
  52. package/dist/__tests__/integration/harness.d.ts +0 -24
  53. package/dist/__tests__/integration/harness.js +0 -34
  54. package/dist/__tests__/integration/linear.integration.test.d.ts +0 -1
  55. package/dist/__tests__/integration/linear.integration.test.js +0 -15
  56. package/dist/__tests__/integration/sentry.integration.test.d.ts +0 -1
  57. package/dist/__tests__/integration/sentry.integration.test.js +0 -20
  58. package/dist/__tests__/integration/slack.integration.test.d.ts +0 -1
  59. package/dist/__tests__/integration/slack.integration.test.js +0 -22
  60. package/dist/__tests__/integration/sources.integration.test.d.ts +0 -1
  61. package/dist/__tests__/integration/sources.integration.test.js +0 -123
  62. package/dist/__tests__/publish.test.d.ts +0 -1
  63. package/dist/__tests__/publish.test.js +0 -180
  64. package/dist/__tests__/schema.test.d.ts +0 -1
  65. package/dist/__tests__/schema.test.js +0 -526
  66. package/dist/__tests__/skill-config-integration.test.d.ts +0 -1
  67. package/dist/__tests__/skill-config-integration.test.js +0 -204
  68. package/dist/__tests__/skills-index.test.d.ts +0 -1
  69. package/dist/__tests__/skills-index.test.js +0 -119
  70. package/dist/__tests__/skills.test.d.ts +0 -1
  71. package/dist/__tests__/skills.test.js +0 -565
  72. package/dist/__tests__/spec-conformance.test.d.ts +0 -18
  73. package/dist/__tests__/spec-conformance.test.js +0 -1074
  74. package/dist/__tests__/studio.test.d.ts +0 -1
  75. package/dist/__tests__/studio.test.js +0 -403
  76. package/dist/__tests__/templates.test.d.ts +0 -1
  77. package/dist/__tests__/templates.test.js +0 -49
  78. package/dist/__tests__/testing.test.d.ts +0 -1
  79. package/dist/__tests__/testing.test.js +0 -224
  80. package/dist/__tests__/verify.test.d.ts +0 -1
  81. package/dist/__tests__/verify.test.js +0 -517
  82. package/dist/__tests__/version-consistency.test.d.ts +0 -1
  83. package/dist/__tests__/version-consistency.test.js +0 -312
  84. package/dist/__tests__/workflow-builder.test.d.ts +0 -1
  85. package/dist/__tests__/workflow-builder.test.js +0 -110
  86. package/dist/__tests__/workflow-yaml.test.d.ts +0 -1
  87. package/dist/__tests__/workflow-yaml.test.js +0 -201
  88. package/dist/cli/__tests__/diagram.test.d.ts +0 -1
  89. package/dist/cli/__tests__/diagram.test.js +0 -225
  90. package/dist/cli/__tests__/report-cloud.test.d.ts +0 -1
  91. package/dist/cli/__tests__/report-cloud.test.js +0 -165
  92. package/dist/cli/__tests__/upgrade.test.d.ts +0 -1
  93. package/dist/cli/__tests__/upgrade.test.js +0 -317
  94. package/dist/cli/__tests__/version-check.test.d.ts +0 -1
  95. package/dist/cli/__tests__/version-check.test.js +0 -209
  96. package/dist/cli/config.test.d.ts +0 -1
  97. package/dist/cli/config.test.js +0 -200
  98. package/dist/cli/credentials.test.d.ts +0 -1
  99. package/dist/cli/credentials.test.js +0 -172
  100. package/dist/cli/e2e.test.d.ts +0 -1
  101. package/dist/cli/e2e.test.js +0 -690
  102. package/dist/cli/marketplace.test.d.ts +0 -1
  103. package/dist/cli/marketplace.test.js +0 -355
  104. package/dist/cli/new.test.d.ts +0 -1
  105. package/dist/cli/new.test.js +0 -1043
  106. package/dist/cli/output.test.d.ts +0 -1
  107. package/dist/cli/output.test.js +0 -180
  108. package/dist/cli/publish.test.d.ts +0 -1
  109. package/dist/cli/publish.test.js +0 -610
  110. package/dist/cli/renderer.test.d.ts +0 -1
  111. package/dist/cli/renderer.test.js +0 -302
  112. package/dist/executor.test.d.ts +0 -1
  113. package/dist/executor.test.js +0 -603
  114. package/dist/mcp.test.d.ts +0 -1
  115. package/dist/mcp.test.js +0 -735
  116. package/dist/mermaid.test.d.ts +0 -1
  117. package/dist/mermaid.test.js +0 -256
  118. package/dist/sources.test.d.ts +0 -1
  119. package/dist/sources.test.js +0 -265
  120. package/dist/sources.validation.test.d.ts +0 -12
  121. package/dist/sources.validation.test.js +0 -380
  122. package/dist/workflow-builder.test.d.ts +0 -1
  123. package/dist/workflow-builder.test.js +0 -117
@@ -1,224 +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
- });
159
- // ─── File skill tests ────────────────────────────────────────────
160
- describe("createFileSkill", () => {
161
- let dir;
162
- beforeEach(() => {
163
- dir = freshDir("fileskill");
164
- });
165
- it("reads and writes JSON", async () => {
166
- const skill = createFileSkill(dir);
167
- const write = skill.tools.find((t) => t.name === "fs_write_json");
168
- const read = skill.tools.find((t) => t.name === "fs_read_json");
169
- const ctx = { config: {}, logger: console };
170
- await write.handler({ path: "test.json", data: { hello: "world" } }, ctx);
171
- const result = await read.handler({ path: "test.json" }, ctx);
172
- expect(result).toEqual({ hello: "world" });
173
- });
174
- it("reads text files", async () => {
175
- const skill = createFileSkill(dir);
176
- writeFileSync(path.join(dir, "hello.txt"), "hello world");
177
- const read = skill.tools.find((t) => t.name === "fs_read_text");
178
- const ctx = { config: {}, logger: console };
179
- const result = await read.handler({ path: "hello.txt" }, ctx);
180
- expect(result).toBe("hello world");
181
- });
182
- it("writes markdown with nested dirs", async () => {
183
- const skill = createFileSkill(dir);
184
- const write = skill.tools.find((t) => t.name === "fs_write_markdown");
185
- const ctx = { config: {}, logger: console };
186
- await write.handler({ path: "issues/ISSUE-1.md", content: "# Bug\n\nBroken" }, ctx);
187
- const content = readFileSync(path.join(dir, "issues/ISSUE-1.md"), "utf-8");
188
- expect(content).toContain("# Bug");
189
- });
190
- it("lists directory contents", async () => {
191
- const skill = createFileSkill(dir);
192
- writeFileSync(path.join(dir, "a.txt"), "a");
193
- writeFileSync(path.join(dir, "b.txt"), "b");
194
- const list = skill.tools.find((t) => t.name === "fs_list_dir");
195
- const ctx = { config: {}, logger: console };
196
- const result = await list.handler({}, ctx);
197
- expect(result).toContain("a.txt");
198
- expect(result).toContain("b.txt");
199
- });
200
- it("returns error info for non-existent directory", async () => {
201
- const skill = createFileSkill(dir);
202
- const list = skill.tools.find((t) => t.name === "fs_list_dir");
203
- const ctx = { config: {}, logger: console };
204
- const result = await list.handler({ path: "nonexistent" }, ctx);
205
- expect(result).toHaveProperty("error");
206
- });
207
- it("creates deeply nested directories for JSON", async () => {
208
- const skill = createFileSkill(dir);
209
- const write = skill.tools.find((t) => t.name === "fs_write_json");
210
- const ctx = { config: {}, logger: console };
211
- await write.handler({ path: "deep/nested/dir/file.json", data: { deep: true } }, ctx);
212
- expect(existsSync(path.join(dir, "deep/nested/dir/file.json"))).toBe(true);
213
- });
214
- it("has correct skill metadata", () => {
215
- const skill = createFileSkill(dir);
216
- expect(skill.id).toBe("filesystem");
217
- expect(skill.tools).toHaveLength(5);
218
- expect(skill.tools.map((t) => t.name)).toContain("fs_read_json");
219
- expect(skill.tools.map((t) => t.name)).toContain("fs_read_text");
220
- expect(skill.tools.map((t) => t.name)).toContain("fs_write_json");
221
- expect(skill.tools.map((t) => t.name)).toContain("fs_write_markdown");
222
- expect(skill.tools.map((t) => t.name)).toContain("fs_list_dir");
223
- });
224
- });
@@ -1 +0,0 @@
1
- export {};