create-merlin-brain 3.8.0-beta.0 → 3.8.0-beta.1
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/files/loop/lib/workflow.sh +41 -25
- package/package.json +1 -1
|
@@ -116,32 +116,34 @@ workflow_run_init() {
|
|
|
116
116
|
|
|
117
117
|
mkdir -p "$(dirname "$WORKFLOW_RUN_FILE")"
|
|
118
118
|
|
|
119
|
-
python3
|
|
119
|
+
echo "$workflow_json" | python3 -c "
|
|
120
120
|
import json, sys
|
|
121
121
|
from datetime import datetime, timezone
|
|
122
122
|
|
|
123
|
-
wf = json.
|
|
124
|
-
task =
|
|
123
|
+
wf = json.load(sys.stdin)
|
|
124
|
+
task = sys.argv[1]
|
|
125
|
+
run_id = sys.argv[2]
|
|
126
|
+
run_file = sys.argv[3]
|
|
125
127
|
|
|
126
128
|
run = {
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
129
|
+
'run_id': run_id,
|
|
130
|
+
'workflow': wf['id'],
|
|
131
|
+
'workflow_name': wf.get('name', wf['id']),
|
|
132
|
+
'task': task,
|
|
133
|
+
'started': datetime.now(timezone.utc).isoformat(),
|
|
134
|
+
'status': 'running',
|
|
135
|
+
'current_step': wf['steps'][0]['id'],
|
|
136
|
+
'steps': {}
|
|
135
137
|
}
|
|
136
138
|
|
|
137
|
-
for step in wf[
|
|
138
|
-
run[
|
|
139
|
+
for step in wf['steps']:
|
|
140
|
+
run['steps'][step['id']] = {'status': 'pending'}
|
|
139
141
|
|
|
140
|
-
with open(
|
|
142
|
+
with open(run_file, 'w') as f:
|
|
141
143
|
json.dump(run, f, indent=2)
|
|
142
144
|
|
|
143
|
-
print(
|
|
144
|
-
|
|
145
|
+
print(run_id)
|
|
146
|
+
" "$task" "$run_id" "$WORKFLOW_RUN_FILE"
|
|
145
147
|
}
|
|
146
148
|
|
|
147
149
|
# ═══════════════════════════════════════════════════════════════════════════════
|
|
@@ -154,15 +156,27 @@ workflow_apply_template() {
|
|
|
154
156
|
local handoff_context="$3"
|
|
155
157
|
local session_dir="$4"
|
|
156
158
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
+
# Write inputs to temp files to avoid heredoc escaping issues
|
|
160
|
+
local tmp_dir
|
|
161
|
+
tmp_dir=$(mktemp -d)
|
|
162
|
+
printf '%s' "$template" > "$tmp_dir/template.txt"
|
|
163
|
+
printf '%s' "$task" > "$tmp_dir/task.txt"
|
|
164
|
+
printf '%s' "$handoff_context" > "$tmp_dir/handoff.txt"
|
|
159
165
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
handoff = """$handoff_context"""
|
|
163
|
-
session_dir = "$session_dir"
|
|
166
|
+
python3 -c "
|
|
167
|
+
import re, os, sys
|
|
164
168
|
|
|
165
|
-
|
|
169
|
+
session_dir = sys.argv[1]
|
|
170
|
+
tmp_dir = sys.argv[2]
|
|
171
|
+
|
|
172
|
+
with open(os.path.join(tmp_dir, 'template.txt')) as f:
|
|
173
|
+
result = f.read()
|
|
174
|
+
with open(os.path.join(tmp_dir, 'task.txt')) as f:
|
|
175
|
+
task = f.read()
|
|
176
|
+
with open(os.path.join(tmp_dir, 'handoff.txt')) as f:
|
|
177
|
+
handoff = f.read()
|
|
178
|
+
|
|
179
|
+
result = result.replace('{{task}}', task).replace('{{handoff}}', handoff)
|
|
166
180
|
|
|
167
181
|
def replace_file_ref(match):
|
|
168
182
|
filename = match.group(1)
|
|
@@ -170,11 +184,13 @@ def replace_file_ref(match):
|
|
|
170
184
|
if os.path.isfile(filepath):
|
|
171
185
|
with open(filepath, 'r') as f:
|
|
172
186
|
return f.read()
|
|
173
|
-
return f
|
|
187
|
+
return f'[File not found: {filename}]'
|
|
174
188
|
|
|
175
189
|
result = re.sub(r'\{\{([a-zA-Z0-9_.-]+)\}\}', replace_file_ref, result)
|
|
176
190
|
print(result)
|
|
177
|
-
|
|
191
|
+
" "$session_dir" "$tmp_dir"
|
|
192
|
+
|
|
193
|
+
rm -rf "$tmp_dir"
|
|
178
194
|
}
|
|
179
195
|
|
|
180
196
|
# ═══════════════════════════════════════════════════════════════════════════════
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-merlin-brain",
|
|
3
|
-
"version": "3.8.0-beta.
|
|
3
|
+
"version": "3.8.0-beta.1",
|
|
4
4
|
"description": "Merlin - The Ultimate AI Brain for Claude Code. One install: workflows, agents, loop, and Sights MCP server.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/server/index.js",
|