keystone-cli 2.1.6 → 2.1.8

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "keystone-cli",
3
- "version": "2.1.6",
3
+ "version": "2.1.8",
4
4
  "description": "A local-first, declarative, agentic workflow orchestrator built on Bun",
5
5
  "type": "module",
6
6
  "bin": {
@@ -2,6 +2,7 @@ import { afterEach, beforeEach, describe, expect, it, mock, spyOn } from 'bun:te
2
2
  import * as child_process from 'node:child_process';
3
3
  import { MCPClient } from './mcp-client';
4
4
 
5
+ import * as dns from 'node:dns/promises';
5
6
  import { Readable, Writable } from 'node:stream';
6
7
 
7
8
  describe('MCPClient Audit Fixes', () => {
@@ -78,6 +79,24 @@ describe('MCPClient Audit Fixes', () => {
78
79
  });
79
80
 
80
81
  describe('MCPClient SSRF Protection', () => {
82
+ let lookupSpy: ReturnType<typeof spyOn>;
83
+ let fetchSpy: ReturnType<typeof spyOn>;
84
+
85
+ beforeEach(() => {
86
+ // Mock DNS lookup to return a public IP for api.example.com
87
+ lookupSpy = spyOn(dns, 'lookup').mockResolvedValue([
88
+ { address: '93.184.216.34', family: 4 }, // example.com's actual IP
89
+ ] as any);
90
+
91
+ // Mock fetch to prevent actual network calls
92
+ fetchSpy = spyOn(global, 'fetch').mockRejectedValue(new Error('Connection timeout'));
93
+ });
94
+
95
+ afterEach(() => {
96
+ lookupSpy.mockRestore();
97
+ fetchSpy.mockRestore();
98
+ });
99
+
81
100
  it('should reject localhost URLs', async () => {
82
101
  // Localhost is rejected regardless of protocol
83
102
  await expect(MCPClient.createRemote('http://localhost:8080/sse')).rejects.toThrow(
@@ -1,5 +1,6 @@
1
1
  import { afterEach, beforeEach, describe, expect, it, mock, spyOn } from 'bun:test';
2
2
  import * as child_process from 'node:child_process';
3
+ import * as dns from 'node:dns/promises';
3
4
  import { EventEmitter } from 'node:events';
4
5
  import { Readable, Writable } from 'node:stream';
5
6
  import { MCPClient } from './mcp-client';
@@ -123,6 +124,19 @@ describe('MCPClient', () => {
123
124
  });
124
125
 
125
126
  describe('SSE Transport', () => {
127
+ let lookupSpy: ReturnType<typeof spyOn>;
128
+
129
+ beforeEach(() => {
130
+ // Mock DNS lookup to return a public IP for api.example.com
131
+ lookupSpy = spyOn(dns, 'lookup').mockResolvedValue([
132
+ { address: '93.184.216.34', family: 4 }, // example.com's actual IP
133
+ ] as any);
134
+ });
135
+
136
+ afterEach(() => {
137
+ lookupSpy.mockRestore();
138
+ });
139
+
126
140
  it('should connect and receive endpoint', async () => {
127
141
  let controller: ReadableStreamDefaultController;
128
142
  const stream = new ReadableStream({
@@ -37,10 +37,85 @@ steps:
37
37
  outputMapping:
38
38
  files: files
39
39
 
40
+ - id: validate_workflows
41
+ type: shell
42
+ needs: [generate]
43
+ foreach: ${{ steps.generate.outputs.files.filter(f => f.path.endsWith('.yaml') && f.path.includes('workflows')) }}
44
+ run: |
45
+ echo "${{ item.content }}" | npx tsx src/cli.ts validate --stdin --type workflow
46
+ allowFailure: true
47
+ transform: |
48
+ {
49
+ path: item.path,
50
+ content: item.content,
51
+ valid: result.exitCode === 0,
52
+ error: result.exitCode !== 0 ? result.stderr : null
53
+ }
54
+
55
+ - id: repair_workflows
56
+ type: llm
57
+ needs: [validate_workflows]
58
+ foreach: ${{ steps.validate_workflows.output.filter(f => !f.valid) }}
59
+ agent: software-engineer
60
+ prompt: |
61
+ A generated workflow file failed schema validation. Please fix it.
62
+
63
+ File path: ${{ item.path }}
64
+
65
+ Validation error:
66
+ ${{ item.error }}
67
+
68
+ Current content:
69
+ ```yaml
70
+ ${{ item.content }}
71
+ ```
72
+
73
+ The workflow schema requires:
74
+ 1. A top-level `name` field (string, required)
75
+ 2. A top-level `$schema` field pointing to: https://raw.githubusercontent.com/mhingston/keystone-cli/main/schemas/workflow.json
76
+ 3. A `steps` array with at least one step
77
+ 4. Each step must have `id` and `type` fields
78
+
79
+ Please return the corrected YAML content that conforms to the schema. Return ONLY the fixed YAML content, nothing else.
80
+ outputSchema:
81
+ type: object
82
+ properties:
83
+ content:
84
+ type: string
85
+ description: The fixed YAML content
86
+ required: [content]
87
+
88
+ - id: merge_files
89
+ type: shell
90
+ needs: [validate_workflows, repair_workflows]
91
+ run: |
92
+ const generated = ${{ JSON.stringify(steps.generate.outputs.files) }};
93
+ const validated = ${{ JSON.stringify(steps.validate_workflows.output) }};
94
+ const repaired = ${{ JSON.stringify(steps.repair_workflows.output) }};
95
+
96
+ const repairedMap = new Map();
97
+ if (Array.isArray(repaired)) {
98
+ repaired.forEach((r, idx) => {
99
+ const validatedItem = validated[idx];
100
+ if (validatedItem) {
101
+ repairedMap.set(validatedItem.path, r.content);
102
+ }
103
+ });
104
+ }
105
+
106
+ const final = generated.map(file => {
107
+ if (repairedMap.has(file.path)) {
108
+ return { ...file, content: repairedMap.get(file.path) };
109
+ }
110
+ return file;
111
+ });
112
+
113
+ return { files: final };
114
+
40
115
  - id: write_files
41
116
  type: file
42
- needs: [generate]
43
- foreach: ${{ steps.generate.outputs.files }}
117
+ needs: [merge_files]
118
+ foreach: ${{ steps.merge_files.output.files }}
44
119
  op: write
45
120
  path: ${{ item.path }}
46
121
  content: ${{ item.content }}
@@ -31,6 +31,13 @@ steps:
31
31
  ${{ item }}
32
32
 
33
33
  Produce the full file content for the given path. Ensure it aligns with the architectural constraints and dependencies defined in the blueprint.
34
+
35
+ IMPORTANT: If generating a workflow file (.yaml in workflows/):
36
+ - MUST include a top-level `$schema` field: $schema: https://raw.githubusercontent.com/mhingston/keystone-cli/main/schemas/workflow.json
37
+ - MUST include a top-level `name` field (string, required)
38
+ - MUST include a `steps` array with at least one step
39
+ - Each step MUST have `id` and `type` fields
40
+
34
41
  Return only JSON with fields: path, content.
35
42
  outputSchema:
36
43
  type: object