@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.
Files changed (119) hide show
  1. package/dist/browser.d.ts +11 -5
  2. package/dist/browser.js +11 -11
  3. package/dist/claude.d.ts +16 -0
  4. package/dist/claude.js +98 -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/loader.d.ts +40 -0
  13. package/dist/loader.js +73 -0
  14. package/dist/mcp-catalog.d.ts +47 -0
  15. package/dist/mcp-catalog.js +304 -0
  16. package/dist/mcp.d.ts +6 -9
  17. package/dist/mcp.js +24 -314
  18. package/dist/schema.d.ts +183 -151
  19. package/dist/schema.js +49 -7
  20. package/dist/skills/custom-loader.d.ts +40 -0
  21. package/dist/skills/custom-loader.js +107 -32
  22. package/dist/skills/index.d.ts +13 -1
  23. package/dist/skills/index.js +12 -3
  24. package/dist/studio.js +4 -1
  25. package/dist/templates.d.ts +29 -8
  26. package/dist/templates.js +30 -20
  27. package/dist/types.d.ts +12 -0
  28. package/dist/verify.js +42 -4
  29. package/package.json +8 -4
  30. package/dist/__tests__/cascade.test.d.ts +0 -11
  31. package/dist/__tests__/cascade.test.js +0 -452
  32. package/dist/__tests__/claude.test.d.ts +0 -1
  33. package/dist/__tests__/claude.test.js +0 -427
  34. package/dist/__tests__/custom-loader.test.d.ts +0 -1
  35. package/dist/__tests__/custom-loader.test.js +0 -116
  36. package/dist/__tests__/executor.test.d.ts +0 -1
  37. package/dist/__tests__/executor.test.js +0 -1635
  38. package/dist/__tests__/integration/datadog.integration.test.d.ts +0 -1
  39. package/dist/__tests__/integration/datadog.integration.test.js +0 -23
  40. package/dist/__tests__/integration/e2e-workflow.integration.test.d.ts +0 -1
  41. package/dist/__tests__/integration/e2e-workflow.integration.test.js +0 -75
  42. package/dist/__tests__/integration/github.integration.test.d.ts +0 -1
  43. package/dist/__tests__/integration/github.integration.test.js +0 -37
  44. package/dist/__tests__/integration/harness.d.ts +0 -24
  45. package/dist/__tests__/integration/harness.js +0 -34
  46. package/dist/__tests__/integration/linear.integration.test.d.ts +0 -1
  47. package/dist/__tests__/integration/linear.integration.test.js +0 -15
  48. package/dist/__tests__/integration/sentry.integration.test.d.ts +0 -1
  49. package/dist/__tests__/integration/sentry.integration.test.js +0 -20
  50. package/dist/__tests__/integration/slack.integration.test.d.ts +0 -1
  51. package/dist/__tests__/integration/slack.integration.test.js +0 -22
  52. package/dist/__tests__/integration/sources.integration.test.d.ts +0 -1
  53. package/dist/__tests__/integration/sources.integration.test.js +0 -123
  54. package/dist/__tests__/publish.test.d.ts +0 -1
  55. package/dist/__tests__/publish.test.js +0 -180
  56. package/dist/__tests__/requires.test.d.ts +0 -1
  57. package/dist/__tests__/requires.test.js +0 -82
  58. package/dist/__tests__/retry.test.d.ts +0 -1
  59. package/dist/__tests__/retry.test.js +0 -213
  60. package/dist/__tests__/schema.test.d.ts +0 -1
  61. package/dist/__tests__/schema.test.js +0 -600
  62. package/dist/__tests__/skill-config-integration.test.d.ts +0 -1
  63. package/dist/__tests__/skill-config-integration.test.js +0 -204
  64. package/dist/__tests__/skills-index.test.d.ts +0 -1
  65. package/dist/__tests__/skills-index.test.js +0 -119
  66. package/dist/__tests__/skills.test.d.ts +0 -1
  67. package/dist/__tests__/skills.test.js +0 -565
  68. package/dist/__tests__/spec-conformance.test.d.ts +0 -18
  69. package/dist/__tests__/spec-conformance.test.js +0 -1084
  70. package/dist/__tests__/studio.test.d.ts +0 -1
  71. package/dist/__tests__/studio.test.js +0 -403
  72. package/dist/__tests__/templates.test.d.ts +0 -1
  73. package/dist/__tests__/templates.test.js +0 -49
  74. package/dist/__tests__/testing.test.d.ts +0 -1
  75. package/dist/__tests__/testing.test.js +0 -242
  76. package/dist/__tests__/verify.test.d.ts +0 -1
  77. package/dist/__tests__/verify.test.js +0 -517
  78. package/dist/__tests__/version-consistency.test.d.ts +0 -1
  79. package/dist/__tests__/version-consistency.test.js +0 -312
  80. package/dist/__tests__/workflow-builder.test.d.ts +0 -1
  81. package/dist/__tests__/workflow-builder.test.js +0 -110
  82. package/dist/__tests__/workflow-yaml.test.d.ts +0 -1
  83. package/dist/__tests__/workflow-yaml.test.js +0 -201
  84. package/dist/cli/__tests__/diagram.test.d.ts +0 -1
  85. package/dist/cli/__tests__/diagram.test.js +0 -225
  86. package/dist/cli/__tests__/report-cloud.test.d.ts +0 -1
  87. package/dist/cli/__tests__/report-cloud.test.js +0 -165
  88. package/dist/cli/__tests__/upgrade.test.d.ts +0 -1
  89. package/dist/cli/__tests__/upgrade.test.js +0 -317
  90. package/dist/cli/__tests__/version-check.test.d.ts +0 -1
  91. package/dist/cli/__tests__/version-check.test.js +0 -209
  92. package/dist/cli/config.test.d.ts +0 -1
  93. package/dist/cli/config.test.js +0 -200
  94. package/dist/cli/credentials.test.d.ts +0 -1
  95. package/dist/cli/credentials.test.js +0 -172
  96. package/dist/cli/e2e.test.d.ts +0 -1
  97. package/dist/cli/e2e.test.js +0 -690
  98. package/dist/cli/marketplace.test.d.ts +0 -1
  99. package/dist/cli/marketplace.test.js +0 -355
  100. package/dist/cli/new.test.d.ts +0 -1
  101. package/dist/cli/new.test.js +0 -1043
  102. package/dist/cli/output.test.d.ts +0 -1
  103. package/dist/cli/output.test.js +0 -180
  104. package/dist/cli/publish.test.d.ts +0 -1
  105. package/dist/cli/publish.test.js +0 -610
  106. package/dist/cli/renderer.test.d.ts +0 -1
  107. package/dist/cli/renderer.test.js +0 -302
  108. package/dist/executor.test.d.ts +0 -1
  109. package/dist/executor.test.js +0 -618
  110. package/dist/mcp.test.d.ts +0 -1
  111. package/dist/mcp.test.js +0 -735
  112. package/dist/mermaid.test.d.ts +0 -1
  113. package/dist/mermaid.test.js +0 -256
  114. package/dist/sources.test.d.ts +0 -1
  115. package/dist/sources.test.js +0 -265
  116. package/dist/sources.validation.test.d.ts +0 -12
  117. package/dist/sources.validation.test.js +0 -380
  118. package/dist/workflow-builder.test.d.ts +0 -1
  119. package/dist/workflow-builder.test.js +0 -123
@@ -1,452 +0,0 @@
1
- /**
2
- * Rules / Context Cascade + max_turns Tests
3
- *
4
- * Covers the spec sections:
5
- * - Workflow > Rules & Context
6
- * - Workflow > Runtime Input (rules/context)
7
- * - Nodes > Max Turns Semantics
8
- * - Nodes > Rules & Context (cascade + `only` flag)
9
- * - Nodes > Input Augmentation (assembly order)
10
- */
11
- import { describe, it, expect } from "vitest";
12
- import { mkdirSync, writeFileSync, rmSync } from "node:fs";
13
- import * as path from "node:path";
14
- import { tmpdir } from "node:os";
15
- import { randomBytes } from "node:crypto";
16
- import { execute } from "../executor.js";
17
- import { nodeZ, workflowZ, parseWorkflow, workflowJsonSchema } from "../schema.js";
18
- import { createSkillMap } from "../skills/index.js";
19
- // ─── Helpers ────────────────────────────────────────────────────
20
- function freshDir(tag) {
21
- const dir = path.join(tmpdir(), `sweny-cascade-${tag}-${Date.now()}-${randomBytes(4).toString("hex")}`);
22
- rmSync(dir, { recursive: true, force: true });
23
- mkdirSync(dir, { recursive: true });
24
- return dir;
25
- }
26
- /** Minimal Claude that records every run() call for assertion. */
27
- function recordingClaude(defaultData = {}) {
28
- const runs = [];
29
- const claude = {
30
- async run(opts) {
31
- runs.push({ instruction: opts.instruction, maxTurns: opts.maxTurns });
32
- return { status: "success", data: defaultData, toolCalls: [] };
33
- },
34
- async evaluate(opts) {
35
- return opts.choices[0].id;
36
- },
37
- async ask() {
38
- return "";
39
- },
40
- };
41
- return { claude, runs };
42
- }
43
- function singleNodeWorkflow(overrides = {}, workflowOverrides = {}) {
44
- return {
45
- id: "t",
46
- name: "T",
47
- description: "",
48
- entry: "a",
49
- edges: [],
50
- nodes: {
51
- a: {
52
- name: "A",
53
- instruction: overrides.instruction ?? "Base instruction.",
54
- skills: overrides.skills ?? [],
55
- ...overrides,
56
- },
57
- },
58
- ...workflowOverrides,
59
- };
60
- }
61
- // ─── max_turns ──────────────────────────────────────────────────
62
- describe("spec: node.max_turns", () => {
63
- it("passes max_turns to claude.run when set on the node", async () => {
64
- const { claude, runs } = recordingClaude();
65
- const w = singleNodeWorkflow({ instruction: "Do A.", max_turns: 7 });
66
- await execute(w, {}, { skills: createSkillMap([]), claude });
67
- expect(runs).toHaveLength(1);
68
- expect(runs[0].maxTurns).toBe(7);
69
- });
70
- it("passes undefined when max_turns is absent (executor defers to Claude default)", async () => {
71
- const { claude, runs } = recordingClaude();
72
- const w = singleNodeWorkflow({ instruction: "Do A." });
73
- await execute(w, {}, { skills: createSkillMap([]), claude });
74
- expect(runs).toHaveLength(1);
75
- expect(runs[0].maxTurns).toBeUndefined();
76
- });
77
- it("Zod schema accepts positive integers and rejects 0 / negatives / floats", () => {
78
- expect(() => nodeZ.parse({ name: "X", instruction: "Go.", max_turns: 5 })).not.toThrow();
79
- expect(() => nodeZ.parse({ name: "X", instruction: "Go." })).not.toThrow();
80
- expect(() => nodeZ.parse({ name: "X", instruction: "Go.", max_turns: 0 })).toThrow();
81
- expect(() => nodeZ.parse({ name: "X", instruction: "Go.", max_turns: -3 })).toThrow();
82
- expect(() => nodeZ.parse({ name: "X", instruction: "Go.", max_turns: 1.5 })).toThrow();
83
- });
84
- });
85
- // ─── Zod parsing for rules/context ──────────────────────────────
86
- describe("spec: Zod parsing of rules/context", () => {
87
- it("accepts top-level workflow rules/context as Source arrays", () => {
88
- const w = parseWorkflow({
89
- id: "wf",
90
- name: "Wf",
91
- entry: "a",
92
- nodes: { a: { name: "A", instruction: "Go." } },
93
- edges: [],
94
- rules: ["Never break API.", { file: "./rules.md" }, { url: "https://x.test/r.md" }],
95
- context: ["Prod is degraded."],
96
- });
97
- expect(w.rules).toHaveLength(3);
98
- expect(w.context).toEqual(["Prod is degraded."]);
99
- });
100
- it("accepts per-node rules in additive (array) form", () => {
101
- const node = nodeZ.parse({
102
- name: "N",
103
- instruction: "Go.",
104
- rules: ["Rule 1", { inline: "Rule 2" }],
105
- });
106
- expect(Array.isArray(node.rules)).toBe(true);
107
- expect(node.rules).toHaveLength(2);
108
- });
109
- it("accepts per-node rules in object form with `only`", () => {
110
- const node = nodeZ.parse({
111
- name: "N",
112
- instruction: "Go.",
113
- rules: { only: true, sources: ["Only this rule."] },
114
- });
115
- expect(node.rules).toEqual({ only: true, sources: ["Only this rule."] });
116
- });
117
- it("accepts object form without `only` (equivalent to additive)", () => {
118
- const node = nodeZ.parse({
119
- name: "N",
120
- instruction: "Go.",
121
- context: { sources: ["Background."] },
122
- });
123
- expect(node.context).toEqual({ sources: ["Background."] });
124
- });
125
- it("rejects object form without `sources`", () => {
126
- expect(() => nodeZ.parse({ name: "N", instruction: "Go.", rules: { only: true } })).toThrow();
127
- });
128
- it("workflowZ round-trips rules/context through parse", () => {
129
- const raw = {
130
- id: "wf",
131
- name: "Wf",
132
- entry: "a",
133
- nodes: {
134
- a: {
135
- name: "A",
136
- instruction: "Go.",
137
- rules: ["N-rule"],
138
- context: { only: true, sources: ["N-ctx-only"] },
139
- },
140
- },
141
- edges: [],
142
- rules: ["W-rule"],
143
- context: ["W-ctx"],
144
- };
145
- const w = workflowZ.parse(raw);
146
- expect(w.rules).toEqual(["W-rule"]);
147
- expect(w.context).toEqual(["W-ctx"]);
148
- expect(w.nodes.a.rules).toEqual(["N-rule"]);
149
- expect(w.nodes.a.context).toEqual({ only: true, sources: ["N-ctx-only"] });
150
- });
151
- });
152
- // ─── Exported JSON Schema ───────────────────────────────────────
153
- describe("spec: workflowJsonSchema exports rules/context", () => {
154
- it("declares workflow-level rules/context as Source arrays", () => {
155
- const props = workflowJsonSchema.properties;
156
- expect(props.rules).toMatchObject({ type: "array" });
157
- expect(props.context).toMatchObject({ type: "array" });
158
- });
159
- it("declares per-node rules/context using NodeSources $defs", () => {
160
- const nodeProps = workflowJsonSchema.properties.nodes.additionalProperties.properties;
161
- expect(nodeProps.rules).toMatchObject({ $ref: "#/$defs/NodeSources" });
162
- expect(nodeProps.context).toMatchObject({ $ref: "#/$defs/NodeSources" });
163
- expect(workflowJsonSchema.$defs.NodeSources).toBeDefined();
164
- });
165
- it("NodeSources accepts either array or object-with-sources", () => {
166
- const ns = workflowJsonSchema.$defs.NodeSources;
167
- expect(ns.oneOf).toHaveLength(2);
168
- });
169
- it("declares per-node max_turns as integer >= 1", () => {
170
- const nodeProps = workflowJsonSchema.properties.nodes.additionalProperties.properties;
171
- expect(nodeProps.max_turns).toMatchObject({ type: "integer", minimum: 1 });
172
- });
173
- });
174
- // ─── Cascade resolution in executor ─────────────────────────────
175
- describe("spec: rules/context cascade resolution", () => {
176
- it("base instruction only when no rules/context anywhere", async () => {
177
- const { claude, runs } = recordingClaude();
178
- const w = singleNodeWorkflow({ instruction: "JUST_THE_BASE" });
179
- await execute(w, {}, { skills: createSkillMap([]), claude });
180
- expect(runs[0].instruction).toBe("JUST_THE_BASE");
181
- expect(runs[0].instruction).not.toContain("## Rules");
182
- expect(runs[0].instruction).not.toContain("## Background Context");
183
- });
184
- it("workflow-level rules are prepended with the canonical heading", async () => {
185
- const { claude, runs } = recordingClaude();
186
- const w = singleNodeWorkflow({ instruction: "Do A." }, { rules: ["Never break API."] });
187
- await execute(w, {}, { skills: createSkillMap([]), claude });
188
- expect(runs[0].instruction).toContain("## Rules — You MUST Follow These");
189
- expect(runs[0].instruction).toContain("Never break API.");
190
- expect(runs[0].instruction).toContain("Do A.");
191
- });
192
- it("workflow-level context is prepended with the canonical heading", async () => {
193
- const { claude, runs } = recordingClaude();
194
- const w = singleNodeWorkflow({ instruction: "Do A." }, { context: ["Prod is down."] });
195
- await execute(w, {}, { skills: createSkillMap([]), claude });
196
- expect(runs[0].instruction).toContain("## Background Context");
197
- expect(runs[0].instruction).toContain("Prod is down.");
198
- });
199
- it("per-node rules (array form) are additive — both workflow and node rules appear", async () => {
200
- const { claude, runs } = recordingClaude();
201
- const w = {
202
- id: "t",
203
- name: "T",
204
- description: "",
205
- entry: "a",
206
- edges: [],
207
- rules: ["WORKFLOW_RULE"],
208
- nodes: {
209
- a: { name: "A", instruction: "base", skills: [], rules: ["NODE_RULE"] },
210
- },
211
- };
212
- await execute(w, {}, { skills: createSkillMap([]), claude });
213
- const instr = runs[0].instruction;
214
- expect(instr).toContain("WORKFLOW_RULE");
215
- expect(instr).toContain("NODE_RULE");
216
- // Order: workflow rules appear before node rules
217
- expect(instr.indexOf("WORKFLOW_RULE")).toBeLessThan(instr.indexOf("NODE_RULE"));
218
- });
219
- it("per-node rules with `only: true` blocks the cascade for rules", async () => {
220
- const { claude, runs } = recordingClaude();
221
- const w = {
222
- id: "t",
223
- name: "T",
224
- description: "",
225
- entry: "a",
226
- edges: [],
227
- rules: ["WORKFLOW_RULE"],
228
- nodes: {
229
- a: {
230
- name: "A",
231
- instruction: "base",
232
- skills: [],
233
- rules: { only: true, sources: ["OVERRIDE_RULE"] },
234
- },
235
- },
236
- };
237
- await execute(w, {}, { skills: createSkillMap([]), claude });
238
- const instr = runs[0].instruction;
239
- expect(instr).toContain("OVERRIDE_RULE");
240
- expect(instr).not.toContain("WORKFLOW_RULE");
241
- });
242
- it("`only: true` on rules does NOT block context cascade", async () => {
243
- const { claude, runs } = recordingClaude();
244
- const w = {
245
- id: "t",
246
- name: "T",
247
- description: "",
248
- entry: "a",
249
- edges: [],
250
- rules: ["WORKFLOW_RULE"],
251
- context: ["WORKFLOW_CTX"],
252
- nodes: {
253
- a: {
254
- name: "A",
255
- instruction: "base",
256
- skills: [],
257
- rules: { only: true, sources: ["NODE_RULE"] },
258
- // No node-level context override → inherits normally
259
- },
260
- },
261
- };
262
- await execute(w, {}, { skills: createSkillMap([]), claude });
263
- const instr = runs[0].instruction;
264
- expect(instr).not.toContain("WORKFLOW_RULE");
265
- expect(instr).toContain("NODE_RULE");
266
- expect(instr).toContain("WORKFLOW_CTX"); // context still cascades
267
- });
268
- it("runtime input + workflow + node rules concatenate in order", async () => {
269
- const { claude, runs } = recordingClaude();
270
- const w = {
271
- id: "t",
272
- name: "T",
273
- description: "",
274
- entry: "a",
275
- edges: [],
276
- rules: ["WORKFLOW_RULE"],
277
- nodes: {
278
- a: { name: "A", instruction: "base", skills: [], rules: ["NODE_RULE"] },
279
- },
280
- };
281
- await execute(w, { rules: ["INPUT_RULE"] }, { skills: createSkillMap([]), claude });
282
- const instr = runs[0].instruction;
283
- const inp = instr.indexOf("INPUT_RULE");
284
- const wfl = instr.indexOf("WORKFLOW_RULE");
285
- const nd = instr.indexOf("NODE_RULE");
286
- expect(inp).toBeGreaterThanOrEqual(0);
287
- expect(wfl).toBeGreaterThan(inp);
288
- expect(nd).toBeGreaterThan(wfl);
289
- });
290
- it("accepts runtime input rules as a bare string (classified as inline Source)", async () => {
291
- const { claude, runs } = recordingClaude();
292
- const w = singleNodeWorkflow({ instruction: "base" });
293
- await execute(w, { rules: "SINGLE_STRING_RULE" }, { skills: createSkillMap([]), claude });
294
- expect(runs[0].instruction).toContain("SINGLE_STRING_RULE");
295
- expect(runs[0].instruction).toContain("## Rules — You MUST Follow These");
296
- });
297
- it("accepts runtime input rules as a tagged object source", async () => {
298
- const { claude, runs } = recordingClaude();
299
- const w = singleNodeWorkflow({ instruction: "base" });
300
- await execute(w, { rules: { inline: "TAGGED_RULE" } }, { skills: createSkillMap([]), claude });
301
- expect(runs[0].instruction).toContain("TAGGED_RULE");
302
- });
303
- it("resolves file sources in workflow.rules and records them in trace.sources", async () => {
304
- const dir = freshDir("file-rules");
305
- writeFileSync(path.join(dir, "rules.md"), "RULES_FROM_FILE");
306
- const { claude, runs } = recordingClaude();
307
- const w = {
308
- id: "t",
309
- name: "T",
310
- description: "",
311
- entry: "a",
312
- edges: [],
313
- rules: [{ file: "./rules.md" }],
314
- nodes: { a: { name: "A", instruction: "base", skills: [] } },
315
- };
316
- const result = await execute(w, {}, { skills: createSkillMap([]), claude, cwd: dir });
317
- expect(runs[0].instruction).toContain("RULES_FROM_FILE");
318
- expect(result.trace.sources["workflow.rules.0"]).toBeDefined();
319
- expect(result.trace.sources["workflow.rules.0"].kind).toBe("file");
320
- expect(result.trace.sources["workflow.rules.0"].hash).toMatch(/^[0-9a-f]{16}$/);
321
- });
322
- it("resolves node-level rules/context file sources and records them under correct trace keys", async () => {
323
- const dir = freshDir("node-cascade");
324
- writeFileSync(path.join(dir, "n-rules.md"), "N_RULES_FILE");
325
- writeFileSync(path.join(dir, "n-ctx.md"), "N_CTX_FILE");
326
- const { claude, runs } = recordingClaude();
327
- const w = {
328
- id: "t",
329
- name: "T",
330
- description: "",
331
- entry: "a",
332
- edges: [],
333
- nodes: {
334
- a: {
335
- name: "A",
336
- instruction: "base",
337
- skills: [],
338
- rules: [{ file: "./n-rules.md" }],
339
- context: [{ file: "./n-ctx.md" }],
340
- },
341
- },
342
- };
343
- const result = await execute(w, {}, { skills: createSkillMap([]), claude, cwd: dir });
344
- expect(runs[0].instruction).toContain("N_RULES_FILE");
345
- expect(runs[0].instruction).toContain("N_CTX_FILE");
346
- expect(result.trace.sources["nodes.a.rules.0"]).toBeDefined();
347
- expect(result.trace.sources["nodes.a.context.0"]).toBeDefined();
348
- expect(result.trace.sources["nodes.a.rules.0"].kind).toBe("file");
349
- expect(result.trace.sources["nodes.a.context.0"].kind).toBe("file");
350
- });
351
- it("different nodes in the same workflow see different effective cascades", async () => {
352
- const { claude, runs } = recordingClaude();
353
- const w = {
354
- id: "t",
355
- name: "T",
356
- description: "",
357
- entry: "a",
358
- edges: [{ from: "a", to: "b" }],
359
- rules: ["WORKFLOW_RULE"],
360
- nodes: {
361
- a: {
362
- name: "A",
363
- instruction: "Node A base",
364
- skills: [],
365
- rules: { only: true, sources: ["A_ONLY"] },
366
- },
367
- b: {
368
- name: "B",
369
- instruction: "Node B base",
370
- skills: [],
371
- rules: ["B_ADDITIVE"],
372
- },
373
- },
374
- };
375
- await execute(w, {}, { skills: createSkillMap([]), claude });
376
- const aInstr = runs.find((r) => r.instruction.includes("Node A base")).instruction;
377
- const bInstr = runs.find((r) => r.instruction.includes("Node B base")).instruction;
378
- expect(aInstr).toContain("A_ONLY");
379
- expect(aInstr).not.toContain("WORKFLOW_RULE");
380
- expect(bInstr).toContain("WORKFLOW_RULE");
381
- expect(bInstr).toContain("B_ADDITIVE");
382
- });
383
- it("sections are separated by `---` in assembly order: rules → context → skill → base", async () => {
384
- const { claude, runs } = recordingClaude();
385
- const w = {
386
- id: "t",
387
- name: "T",
388
- description: "",
389
- entry: "a",
390
- edges: [],
391
- rules: ["R"],
392
- context: ["C"],
393
- nodes: {
394
- a: { name: "A", instruction: "BASE", skills: ["rubric"] },
395
- },
396
- };
397
- const rubric = {
398
- id: "rubric",
399
- name: "Rubric",
400
- description: "",
401
- category: "general",
402
- config: {},
403
- tools: [],
404
- instruction: "SCORE_IT",
405
- };
406
- await execute(w, {}, { skills: createSkillMap([rubric]), claude });
407
- const instr = runs[0].instruction;
408
- const rIdx = instr.indexOf("## Rules — You MUST Follow These");
409
- const cIdx = instr.indexOf("## Background Context");
410
- const sIdx = instr.indexOf("## Skill: Rubric");
411
- const bIdx = instr.indexOf("BASE");
412
- expect(rIdx).toBeGreaterThanOrEqual(0);
413
- expect(cIdx).toBeGreaterThan(rIdx);
414
- expect(sIdx).toBeGreaterThan(cIdx);
415
- expect(bIdx).toBeGreaterThan(sIdx);
416
- });
417
- it("empty arrays produce no rules/context sections", async () => {
418
- const { claude, runs } = recordingClaude();
419
- const w = {
420
- id: "t",
421
- name: "T",
422
- description: "",
423
- entry: "a",
424
- edges: [],
425
- rules: [],
426
- context: [],
427
- nodes: {
428
- a: { name: "A", instruction: "BASE", skills: [], rules: [], context: [] },
429
- },
430
- };
431
- await execute(w, {}, { skills: createSkillMap([]), claude });
432
- expect(runs[0].instruction).toBe("BASE");
433
- });
434
- });
435
- // ─── Legacy input.additionalContext compatibility ───────────────
436
- describe("backward compat: input.additionalContext", () => {
437
- it("still renders under the legacy heading when no rules/context are present", async () => {
438
- const { claude, runs } = recordingClaude();
439
- const w = singleNodeWorkflow({ instruction: "base" });
440
- await execute(w, { additionalContext: "LEGACY_TEXT" }, { skills: createSkillMap([]), claude });
441
- expect(runs[0].instruction).toContain("## Additional Context & Rules");
442
- expect(runs[0].instruction).toContain("LEGACY_TEXT");
443
- });
444
- it("is suppressed once rules or context are present (rules/context take priority)", async () => {
445
- const { claude, runs } = recordingClaude();
446
- const w = singleNodeWorkflow({ instruction: "base" }, { rules: ["NEW_RULE"] });
447
- await execute(w, { additionalContext: "LEGACY_TEXT" }, { skills: createSkillMap([]), claude });
448
- expect(runs[0].instruction).toContain("NEW_RULE");
449
- expect(runs[0].instruction).not.toContain("LEGACY_TEXT");
450
- expect(runs[0].instruction).not.toContain("## Additional Context & Rules");
451
- });
452
- });
@@ -1 +0,0 @@
1
- export {};