Skip to content

Commit 236c32f

Browse files
committed
feat: enhance read_files block to accept patterns as a JSON string or array, with updated schema, documentation, and new tests, and add .DS_Store to gitignore.
BREAKING: removed built-in templates as these were not maintained and potentially risky. A better alternative is in the works and will come soon.
1 parent 6668ad8 commit 236c32f

99 files changed

Lines changed: 359 additions & 28792 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,3 +231,6 @@ src/workflows_mcp/templates/agents/*
231231
!src/workflows_mcp/templates/agents/investigation/
232232
!src/workflows_mcp/templates/agents/cortex/
233233
!src/workflows_mcp/templates/agents/cortex-cell-v2/
234+
235+
# OS
236+
.DS_Store

docs/llm/block-reference.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ Field names are **exact** - use them precisely in your workflows.
8080

8181
### Optional Inputs
8282

83-
- **`inputs`** (object): Inputs to pass to child workflow (variables resolved in parent context)
83+
- **`inputs`** (any): Inputs to pass to child workflow (variables resolved in parent context)
8484
- **`timeout_ms`** (any): Optional timeout for child execution in milliseconds
8585

8686
### Example
@@ -139,7 +139,7 @@ Field names are **exact** - use them precisely in your workflows.
139139
### Required Inputs
140140

141141
- **`path`** (string): Path to file to edit (relative or absolute)
142-
- **`operations`** (array): List of edit operations to apply sequentially
142+
- **`operations`** (any): List of edit operations to apply sequentially
143143

144144
### Optional Inputs
145145

@@ -183,8 +183,8 @@ Field names are **exact** - use them precisely in your workflows.
183183
### Optional Inputs
184184

185185
- **`path`** (any): Single file path to read (absolute or relative). Mutually exclusive with patterns. Use for single-file reads.
186-
- **`patterns`** (array): Glob patterns for files to read (e.g., ['*.py', '**/*.ts', 'docs/**/*.md'])
187-
- **`base_path`** (string) *(default: `.`)*: Base directory to search from (relative or absolute). Used with patterns.
186+
- **`patterns`** (any): Glob patterns for files to read (e.g., ['*.py', '**/*.ts', 'docs/**/*.md'])
187+
- **`base_path`** (any) *(default: `.`)*: Base directory to search from (relative or absolute). Used with patterns.
188188
- **`mode`** (any) *(default: `full`)*: Output mode: 'full' (complete content), 'outline' (symbol tree with line ranges), 'summary' (outline + docstrings)
189189
- **`exclude_patterns`** (array): Additional patterns to exclude beyond defaults (e.g., ['*test*', '*.min.js'])
190190
- **`max_files`** (any) *(default: `20`)*: Maximum number of files to read (1-100, supports interpolation)

schema.json

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -538,13 +538,20 @@
538538
"title": "Path"
539539
},
540540
"patterns": {
541+
"anyOf": [
542+
{
543+
"items": {
544+
"type": "string"
545+
},
546+
"type": "array"
547+
},
548+
{
549+
"type": "string"
550+
}
551+
],
541552
"description": "Glob patterns for files to read (e.g., ['*.py', '**/*.ts', 'docs/**/*.md'])",
542-
"items": {
543-
"type": "string"
544-
},
545-
"maxItems": 50,
546-
"title": "Patterns",
547-
"type": "array"
553+
"maxLength": 50,
554+
"title": "Patterns"
548555
},
549556
"base_path": {
550557
"anyOf": [
@@ -2300,13 +2307,20 @@
23002307
"title": "Path"
23012308
},
23022309
"patterns": {
2310+
"anyOf": [
2311+
{
2312+
"items": {
2313+
"type": "string"
2314+
},
2315+
"type": "array"
2316+
},
2317+
{
2318+
"type": "string"
2319+
}
2320+
],
23032321
"description": "Glob patterns for files to read (e.g., ['*.py', '**/*.ts', 'docs/**/*.md'])",
2304-
"items": {
2305-
"type": "string"
2306-
},
2307-
"maxItems": 50,
2308-
"title": "Patterns",
2309-
"type": "array"
2322+
"maxLength": 50,
2323+
"title": "Patterns"
23102324
},
23112325
"base_path": {
23122326
"anyOf": [

src/workflows_mcp/engine/executors_file.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,12 +233,28 @@ class ReadFilesInput(BlockInput):
233233
),
234234
)
235235

236-
patterns: list[str] = Field(
236+
patterns: list[str] | str = Field(
237237
default_factory=list,
238238
description="Glob patterns for files to read (e.g., ['*.py', '**/*.ts', 'docs/**/*.md'])",
239239
max_length=50,
240240
)
241241

242+
@field_validator("patterns", mode="before")
243+
@classmethod
244+
def _parse_patterns_json(cls, v: Any) -> list[str] | Any:
245+
"""Parse JSON string patterns into list."""
246+
if isinstance(v, str):
247+
try:
248+
import json
249+
250+
value = json.loads(v)
251+
if not isinstance(value, list):
252+
raise ValueError(f"Parsed JSON must be a list, got {type(value).__name__}")
253+
return value
254+
except json.JSONDecodeError as e:
255+
raise ValueError(f"Invalid JSON in patterns: {e}")
256+
return v
257+
242258
base_path: str | None = Field(
243259
default=".",
244260
description="Base directory to search from (relative or absolute). Used with patterns.",

0 commit comments

Comments
 (0)