agentreel 0.3.4 → 0.3.5
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/bin/agentreel.mjs +6 -4
- package/package.json +1 -1
- package/scripts/browser_demo.py +10 -4
- package/scripts/cli_demo.py +7 -4
package/bin/agentreel.mjs
CHANGED
|
@@ -100,13 +100,14 @@ function ensureBrowserDeps() {
|
|
|
100
100
|
});
|
|
101
101
|
}
|
|
102
102
|
|
|
103
|
-
function recordCLI(command, workDir, context) {
|
|
103
|
+
function recordCLI(command, workDir, context, guidelines) {
|
|
104
104
|
const python = findPython();
|
|
105
105
|
const script = join(ROOT, "scripts", "cli_demo.py");
|
|
106
106
|
const outFile = join(tmpdir(), "agentreel-cli-demo.cast");
|
|
107
107
|
|
|
108
108
|
const args = [script, command, workDir, outFile];
|
|
109
109
|
if (context) args.push(context);
|
|
110
|
+
if (guidelines) args.push(guidelines);
|
|
110
111
|
|
|
111
112
|
console.error(`Agent planning CLI demo for: ${command}`);
|
|
112
113
|
execFileSync(python, args, { stdio: ["ignore", "inherit", "inherit"], env: process.env });
|
|
@@ -133,7 +134,7 @@ function browserEnv() {
|
|
|
133
134
|
return { ...process.env, PLAYWRIGHT_BROWSERS_PATH: browsersDir };
|
|
134
135
|
}
|
|
135
136
|
|
|
136
|
-
function recordBrowser(url, task, authState) {
|
|
137
|
+
function recordBrowser(url, task, authState, guidelines) {
|
|
137
138
|
const python = findPython();
|
|
138
139
|
const script = join(ROOT, "scripts", "browser_demo.py");
|
|
139
140
|
const outFile = join(tmpdir(), "agentreel-browser-demo.mp4");
|
|
@@ -141,6 +142,7 @@ function recordBrowser(url, task, authState) {
|
|
|
141
142
|
console.error(`Agent demoing browser app: ${url}`);
|
|
142
143
|
const args = [script, url, outFile, task];
|
|
143
144
|
if (authState) args.push("--auth", authState);
|
|
145
|
+
if (guidelines) args.push("--guidelines", guidelines);
|
|
144
146
|
execFileSync(python, args, {
|
|
145
147
|
stdio: ["ignore", "inherit", "inherit"],
|
|
146
148
|
env: browserEnv(),
|
|
@@ -425,7 +427,7 @@ async function main() {
|
|
|
425
427
|
|
|
426
428
|
if (demoCmd) {
|
|
427
429
|
console.error("Step 1/3: Recording CLI demo...");
|
|
428
|
-
const castPath = recordCLI(demoCmd, process.cwd(), prompt);
|
|
430
|
+
const castPath = recordCLI(demoCmd, process.cwd(), prompt, flags.guidelines);
|
|
429
431
|
|
|
430
432
|
console.error("Step 2/3: Extracting highlights...");
|
|
431
433
|
const highlightsPath = extractHighlightsFromCast(castPath, prompt, flags.guidelines);
|
|
@@ -451,7 +453,7 @@ async function main() {
|
|
|
451
453
|
|
|
452
454
|
ensureBrowserDeps();
|
|
453
455
|
console.error("Step 1/3: Recording browser demo...");
|
|
454
|
-
const videoPath = recordBrowser(demoURL, task, flags.auth);
|
|
456
|
+
const videoPath = recordBrowser(demoURL, task, flags.auth, flags.guidelines);
|
|
455
457
|
|
|
456
458
|
// Copy video to Remotion public dir so it can be served
|
|
457
459
|
const publicDir = join(ROOT, "public");
|
package/package.json
CHANGED
package/scripts/browser_demo.py
CHANGED
|
@@ -30,11 +30,13 @@ def find_claude():
|
|
|
30
30
|
return "claude"
|
|
31
31
|
|
|
32
32
|
|
|
33
|
-
def generate_playwright_script(url, task):
|
|
33
|
+
def generate_playwright_script(url, task, guidelines=""):
|
|
34
34
|
"""Use claude CLI to generate a Playwright demo script."""
|
|
35
|
+
guidelines_part = f"IMPORTANT guidelines: {guidelines}. " if guidelines else ""
|
|
35
36
|
prompt = (
|
|
36
37
|
f"Generate a Playwright Python async function that demos a web app at {url}. "
|
|
37
38
|
f"Task: {task}. "
|
|
39
|
+
f"{guidelines_part}"
|
|
38
40
|
f"The function signature is: async def demo(page). "
|
|
39
41
|
f"Navigate to the URL, wait for load, interact with key features — "
|
|
40
42
|
f"click buttons, fill forms, scroll. Take about 20 seconds total. "
|
|
@@ -124,12 +126,12 @@ def extract_highlights(video_path, task):
|
|
|
124
126
|
return highlights
|
|
125
127
|
|
|
126
128
|
|
|
127
|
-
async def record_browser_demo(url, task, output_path, auth_state=None):
|
|
129
|
+
async def record_browser_demo(url, task, output_path, auth_state=None, guidelines=""):
|
|
128
130
|
"""Generate and run a Playwright demo with video recording."""
|
|
129
131
|
from playwright.async_api import async_playwright
|
|
130
132
|
|
|
131
133
|
print(f"Generating demo script for {url}...", file=sys.stderr)
|
|
132
|
-
script_code = generate_playwright_script(url, task)
|
|
134
|
+
script_code = generate_playwright_script(url, task, guidelines)
|
|
133
135
|
print(f"Script ready ({len(script_code)} chars)", file=sys.stderr)
|
|
134
136
|
|
|
135
137
|
video_dir = tempfile.mkdtemp()
|
|
@@ -269,12 +271,16 @@ if __name__ == "__main__":
|
|
|
269
271
|
# Parse remaining args: [task] [--auth <state_file>]
|
|
270
272
|
task = "Explore the main features"
|
|
271
273
|
auth_state = None
|
|
274
|
+
guidelines = ""
|
|
272
275
|
i = 3
|
|
273
276
|
while i < len(sys.argv):
|
|
274
277
|
if sys.argv[i] == "--auth" and i + 1 < len(sys.argv):
|
|
275
278
|
auth_state = sys.argv[i + 1]
|
|
276
279
|
i += 2
|
|
280
|
+
elif sys.argv[i] == "--guidelines" and i + 1 < len(sys.argv):
|
|
281
|
+
guidelines = sys.argv[i + 1]
|
|
282
|
+
i += 2
|
|
277
283
|
else:
|
|
278
284
|
task = sys.argv[i]
|
|
279
285
|
i += 1
|
|
280
|
-
asyncio.run(record_browser_demo(url, task, output, auth_state=auth_state))
|
|
286
|
+
asyncio.run(record_browser_demo(url, task, output, auth_state=auth_state, guidelines=guidelines))
|
package/scripts/cli_demo.py
CHANGED
|
@@ -33,12 +33,14 @@ def find_claude():
|
|
|
33
33
|
return "claude"
|
|
34
34
|
|
|
35
35
|
|
|
36
|
-
def generate_demo_plan(command: str, context: str) -> list[dict]:
|
|
36
|
+
def generate_demo_plan(command: str, context: str, guidelines: str = "") -> list[dict]:
|
|
37
37
|
"""Use claude CLI to plan a demo sequence."""
|
|
38
|
+
guidelines_block = f"\n\nIMPORTANT guidelines you MUST follow:\n{guidelines}" if guidelines else ""
|
|
39
|
+
|
|
38
40
|
prompt = f"""You are planning a terminal demo for a CLI tool. The tool is invoked with: {command}
|
|
39
41
|
|
|
40
42
|
Context about what this tool does:
|
|
41
|
-
{context}
|
|
43
|
+
{context}{guidelines_block}
|
|
42
44
|
|
|
43
45
|
Generate a JSON array of demo steps. Each step is an object with:
|
|
44
46
|
- "type": "command" (run a shell command)
|
|
@@ -289,9 +291,10 @@ if __name__ == "__main__":
|
|
|
289
291
|
workdir = sys.argv[2]
|
|
290
292
|
output = sys.argv[3]
|
|
291
293
|
context = sys.argv[4] if len(sys.argv) > 4 else ""
|
|
294
|
+
guidelines = sys.argv[5] if len(sys.argv) > 5 else ""
|
|
292
295
|
|
|
293
296
|
print(f"Planning demo for: {command}", file=sys.stderr)
|
|
294
|
-
steps = generate_demo_plan(command, context)
|
|
297
|
+
steps = generate_demo_plan(command, context, guidelines)
|
|
295
298
|
print(f"Generated {len(steps)} steps:", file=sys.stderr)
|
|
296
299
|
for s in steps:
|
|
297
300
|
print(f" $ {s['value']} — {s.get('description', '')}", file=sys.stderr)
|
|
@@ -302,7 +305,7 @@ if __name__ == "__main__":
|
|
|
302
305
|
# Extract highlights from the recording
|
|
303
306
|
highlights_path = output.replace(".cast", "-highlights.json")
|
|
304
307
|
print("Extracting highlights...", file=sys.stderr)
|
|
305
|
-
highlights = extract_highlights(output, context)
|
|
308
|
+
highlights = extract_highlights(output, context, guidelines)
|
|
306
309
|
with open(highlights_path, "w") as f:
|
|
307
310
|
json.dump(highlights, f, indent=2)
|
|
308
311
|
print(f"Saved {len(highlights)} highlights to: {highlights_path}", file=sys.stderr)
|