daemora 1.0.3 → 1.0.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.
Files changed (121) hide show
  1. package/LICENSE +663 -0
  2. package/README.md +69 -19
  3. package/SOUL.md +25 -24
  4. package/daemora-ui/README.md +11 -0
  5. package/package.json +12 -2
  6. package/skills/api-development.md +35 -0
  7. package/skills/artifacts-builder/SKILL.md +74 -0
  8. package/skills/artifacts-builder/scripts/bundle-artifact.sh +54 -0
  9. package/skills/artifacts-builder/scripts/init-artifact.sh +322 -0
  10. package/skills/artifacts-builder/scripts/shadcn-components.tar.gz +0 -0
  11. package/skills/brand-guidelines.md +73 -0
  12. package/skills/browser.md +77 -0
  13. package/skills/changelog-generator.md +104 -0
  14. package/skills/coding.md +26 -10
  15. package/skills/content-research-writer.md +538 -0
  16. package/skills/data-analysis.md +27 -0
  17. package/skills/debugging.md +33 -0
  18. package/skills/devops.md +37 -0
  19. package/skills/document-docx.md +197 -0
  20. package/skills/document-pdf.md +294 -0
  21. package/skills/document-pptx.md +484 -0
  22. package/skills/document-xlsx.md +289 -0
  23. package/skills/domain-name-brainstormer.md +212 -0
  24. package/skills/file-organizer.md +433 -0
  25. package/skills/frontend-design.md +42 -0
  26. package/skills/image-enhancer.md +99 -0
  27. package/skills/invoice-organizer.md +446 -0
  28. package/skills/lead-research-assistant.md +199 -0
  29. package/skills/mcp-builder/SKILL.md +328 -0
  30. package/skills/mcp-builder/reference/evaluation.md +602 -0
  31. package/skills/mcp-builder/reference/mcp_best_practices.md +915 -0
  32. package/skills/mcp-builder/reference/node_mcp_server.md +916 -0
  33. package/skills/mcp-builder/reference/python_mcp_server.md +752 -0
  34. package/skills/mcp-builder/scripts/connections.py +151 -0
  35. package/skills/mcp-builder/scripts/evaluation.py +373 -0
  36. package/skills/mcp-builder/scripts/example_evaluation.xml +22 -0
  37. package/skills/mcp-builder/scripts/requirements.txt +2 -0
  38. package/skills/meeting-insights-analyzer.md +327 -0
  39. package/skills/orchestration.md +93 -0
  40. package/skills/raffle-winner-picker.md +159 -0
  41. package/skills/slack-gif-creator/SKILL.md +646 -0
  42. package/skills/slack-gif-creator/core/color_palettes.py +302 -0
  43. package/skills/slack-gif-creator/core/easing.py +230 -0
  44. package/skills/slack-gif-creator/core/frame_composer.py +469 -0
  45. package/skills/slack-gif-creator/core/gif_builder.py +246 -0
  46. package/skills/slack-gif-creator/core/typography.py +357 -0
  47. package/skills/slack-gif-creator/core/validators.py +264 -0
  48. package/skills/slack-gif-creator/core/visual_effects.py +494 -0
  49. package/skills/slack-gif-creator/requirements.txt +4 -0
  50. package/skills/slack-gif-creator/templates/bounce.py +106 -0
  51. package/skills/slack-gif-creator/templates/explode.py +331 -0
  52. package/skills/slack-gif-creator/templates/fade.py +329 -0
  53. package/skills/slack-gif-creator/templates/flip.py +291 -0
  54. package/skills/slack-gif-creator/templates/kaleidoscope.py +211 -0
  55. package/skills/slack-gif-creator/templates/morph.py +329 -0
  56. package/skills/slack-gif-creator/templates/move.py +293 -0
  57. package/skills/slack-gif-creator/templates/pulse.py +268 -0
  58. package/skills/slack-gif-creator/templates/shake.py +127 -0
  59. package/skills/slack-gif-creator/templates/slide.py +291 -0
  60. package/skills/slack-gif-creator/templates/spin.py +269 -0
  61. package/skills/slack-gif-creator/templates/wiggle.py +300 -0
  62. package/skills/slack-gif-creator/templates/zoom.py +312 -0
  63. package/skills/system-admin.md +44 -0
  64. package/skills/tailored-resume-generator.md +345 -0
  65. package/skills/theme-factory/SKILL.md +59 -0
  66. package/skills/theme-factory/theme-showcase.pdf +0 -0
  67. package/skills/theme-factory/themes/arctic-frost.md +19 -0
  68. package/skills/theme-factory/themes/botanical-garden.md +19 -0
  69. package/skills/theme-factory/themes/desert-rose.md +19 -0
  70. package/skills/theme-factory/themes/forest-canopy.md +19 -0
  71. package/skills/theme-factory/themes/golden-hour.md +19 -0
  72. package/skills/theme-factory/themes/midnight-galaxy.md +19 -0
  73. package/skills/theme-factory/themes/modern-minimalist.md +19 -0
  74. package/skills/theme-factory/themes/ocean-depths.md +19 -0
  75. package/skills/theme-factory/themes/sunset-boulevard.md +19 -0
  76. package/skills/theme-factory/themes/tech-innovation.md +19 -0
  77. package/skills/video-downloader.md +99 -0
  78. package/skills/web-development.md +32 -0
  79. package/skills/webapp-testing/SKILL.md +96 -0
  80. package/skills/webapp-testing/examples/console_logging.py +35 -0
  81. package/skills/webapp-testing/examples/element_discovery.py +40 -0
  82. package/skills/webapp-testing/examples/static_html_automation.py +33 -0
  83. package/skills/webapp-testing/scripts/with_server.py +106 -0
  84. package/src/agents/SubAgentManager.js +57 -12
  85. package/src/api/openai-compat.js +212 -0
  86. package/src/channels/TelegramChannel.js +5 -2
  87. package/src/channels/index.js +7 -10
  88. package/src/cli.js +129 -50
  89. package/src/config/agentProfiles.js +1 -0
  90. package/src/config/default.js +10 -0
  91. package/src/config/models.js +317 -71
  92. package/src/config/permissions.js +12 -0
  93. package/src/core/AgentLoop.js +70 -50
  94. package/src/core/Compaction.js +84 -2
  95. package/src/core/MessageQueue.js +90 -0
  96. package/src/core/Task.js +13 -0
  97. package/src/core/TaskQueue.js +1 -1
  98. package/src/core/TaskRunner.js +80 -5
  99. package/src/index.js +328 -48
  100. package/src/mcp/MCPAgentRunner.js +48 -11
  101. package/src/mcp/MCPManager.js +40 -2
  102. package/src/models/ModelRouter.js +67 -1
  103. package/src/safety/DockerSandbox.js +212 -0
  104. package/src/safety/ExecApproval.js +118 -0
  105. package/src/scheduler/Heartbeat.js +56 -21
  106. package/src/services/cleanup.js +106 -0
  107. package/src/services/sessions.js +39 -1
  108. package/src/setup/wizard.js +75 -4
  109. package/src/skills/SkillLoader.js +104 -17
  110. package/src/storage/TaskStore.js +19 -1
  111. package/src/systemPrompt.js +171 -328
  112. package/src/tools/browserAutomation.js +615 -104
  113. package/src/tools/executeCommand.js +19 -1
  114. package/src/tools/index.js +6 -0
  115. package/src/tools/manageAgents.js +55 -4
  116. package/src/tools/replyWithFile.js +62 -0
  117. package/src/tools/screenCapture.js +12 -1
  118. package/src/tools/taskManager.js +164 -0
  119. package/src/tools/useMCP.js +3 -1
  120. package/src/utils/Embeddings.js +157 -10
  121. package/src/webhooks/WebhookHandler.js +107 -0
@@ -0,0 +1,59 @@
1
+ ---
2
+ name: theme-factory
3
+ description: Toolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with colors/fonts that you can apply to any artifact that has been creating, or can generate a new theme on-the-fly.
4
+ license: Complete terms in LICENSE.txt
5
+ ---
6
+
7
+
8
+ # Theme Factory Skill
9
+
10
+ This skill provides a curated collection of professional font and color themes themes, each with carefully selected color palettes and font pairings. Once a theme is chosen, it can be applied to any artifact.
11
+
12
+ ## Purpose
13
+
14
+ To apply consistent, professional styling to presentation slide decks, use this skill. Each theme includes:
15
+ - A cohesive color palette with hex codes
16
+ - Complementary font pairings for headers and body text
17
+ - A distinct visual identity suitable for different contexts and audiences
18
+
19
+ ## Usage Instructions
20
+
21
+ To apply styling to a slide deck or other artifact:
22
+
23
+ 1. **Show the theme showcase**: Display the `theme-showcase.pdf` file to allow users to see all available themes visually. Do not make any modifications to it; simply show the file for viewing.
24
+ 2. **Ask for their choice**: Ask which theme to apply to the deck
25
+ 3. **Wait for selection**: Get explicit confirmation about the chosen theme
26
+ 4. **Apply the theme**: Once a theme has been chosen, apply the selected theme's colors and fonts to the deck/artifact
27
+
28
+ ## Themes Available
29
+
30
+ The following 10 themes are available, each showcased in `theme-showcase.pdf`:
31
+
32
+ 1. **Ocean Depths** - Professional and calming maritime theme
33
+ 2. **Sunset Boulevard** - Warm and vibrant sunset colors
34
+ 3. **Forest Canopy** - Natural and grounded earth tones
35
+ 4. **Modern Minimalist** - Clean and contemporary grayscale
36
+ 5. **Golden Hour** - Rich and warm autumnal palette
37
+ 6. **Arctic Frost** - Cool and crisp winter-inspired theme
38
+ 7. **Desert Rose** - Soft and sophisticated dusty tones
39
+ 8. **Tech Innovation** - Bold and modern tech aesthetic
40
+ 9. **Botanical Garden** - Fresh and organic garden colors
41
+ 10. **Midnight Galaxy** - Dramatic and cosmic deep tones
42
+
43
+ ## Theme Details
44
+
45
+ Each theme is defined in the `themes/` directory with complete specifications including:
46
+ - Cohesive color palette with hex codes
47
+ - Complementary font pairings for headers and body text
48
+ - Distinct visual identity suitable for different contexts and audiences
49
+
50
+ ## Application Process
51
+
52
+ After a preferred theme is selected:
53
+ 1. Read the corresponding theme file from the `themes/` directory
54
+ 2. Apply the specified colors and fonts consistently throughout the deck
55
+ 3. Ensure proper contrast and readability
56
+ 4. Maintain the theme's visual identity across all slides
57
+
58
+ ## Create your Own Theme
59
+ To handle cases where none of the existing themes work for an artifact, create a custom theme. Based on provided inputs, generate a new theme similar to the ones above. Give the theme a similar name describing what the font/color combinations represent. Use any basic description provided to choose appropriate colors/fonts. After generating the theme, show it for review and verification. Following that, apply the theme as described above.
@@ -0,0 +1,19 @@
1
+ # Arctic Frost
2
+
3
+ A cool and crisp winter-inspired theme that conveys clarity, precision, and professionalism.
4
+
5
+ ## Color Palette
6
+
7
+ - **Ice Blue**: `#d4e4f7` - Light backgrounds and highlights
8
+ - **Steel Blue**: `#4a6fa5` - Primary accent color
9
+ - **Silver**: `#c0c0c0` - Metallic accent elements
10
+ - **Crisp White**: `#fafafa` - Clean backgrounds and text
11
+
12
+ ## Typography
13
+
14
+ - **Headers**: DejaVu Sans Bold
15
+ - **Body Text**: DejaVu Sans
16
+
17
+ ## Best Used For
18
+
19
+ Healthcare presentations, technology solutions, winter sports, clean tech, pharmaceutical content.
@@ -0,0 +1,19 @@
1
+ # Botanical Garden
2
+
3
+ A fresh and organic theme featuring vibrant garden-inspired colors for lively presentations.
4
+
5
+ ## Color Palette
6
+
7
+ - **Fern Green**: `#4a7c59` - Rich natural green
8
+ - **Marigold**: `#f9a620` - Bright floral accent
9
+ - **Terracotta**: `#b7472a` - Earthy warm tone
10
+ - **Cream**: `#f5f3ed` - Soft neutral backgrounds
11
+
12
+ ## Typography
13
+
14
+ - **Headers**: DejaVu Serif Bold
15
+ - **Body Text**: DejaVu Sans
16
+
17
+ ## Best Used For
18
+
19
+ Garden centers, food presentations, farm-to-table content, botanical brands, natural products.
@@ -0,0 +1,19 @@
1
+ # Desert Rose
2
+
3
+ A soft and sophisticated theme with dusty, muted tones perfect for elegant presentations.
4
+
5
+ ## Color Palette
6
+
7
+ - **Dusty Rose**: `#d4a5a5` - Soft primary color
8
+ - **Clay**: `#b87d6d` - Earthy accent
9
+ - **Sand**: `#e8d5c4` - Warm neutral backgrounds
10
+ - **Deep Burgundy**: `#5d2e46` - Rich dark contrast
11
+
12
+ ## Typography
13
+
14
+ - **Headers**: FreeSans Bold
15
+ - **Body Text**: FreeSans
16
+
17
+ ## Best Used For
18
+
19
+ Fashion presentations, beauty brands, wedding planning, interior design, boutique businesses.
@@ -0,0 +1,19 @@
1
+ # Forest Canopy
2
+
3
+ A natural and grounded theme featuring earth tones inspired by dense forest environments.
4
+
5
+ ## Color Palette
6
+
7
+ - **Forest Green**: `#2d4a2b` - Primary dark green
8
+ - **Sage**: `#7d8471` - Muted green accent
9
+ - **Olive**: `#a4ac86` - Light accent color
10
+ - **Ivory**: `#faf9f6` - Backgrounds and text
11
+
12
+ ## Typography
13
+
14
+ - **Headers**: FreeSerif Bold
15
+ - **Body Text**: FreeSans
16
+
17
+ ## Best Used For
18
+
19
+ Environmental presentations, sustainability reports, outdoor brands, wellness content, organic products.
@@ -0,0 +1,19 @@
1
+ # Golden Hour
2
+
3
+ A rich and warm autumnal palette that creates an inviting and sophisticated atmosphere.
4
+
5
+ ## Color Palette
6
+
7
+ - **Mustard Yellow**: `#f4a900` - Bold primary accent
8
+ - **Terracotta**: `#c1666b` - Warm secondary color
9
+ - **Warm Beige**: `#d4b896` - Neutral backgrounds
10
+ - **Chocolate Brown**: `#4a403a` - Dark text and anchors
11
+
12
+ ## Typography
13
+
14
+ - **Headers**: FreeSans Bold
15
+ - **Body Text**: FreeSans
16
+
17
+ ## Best Used For
18
+
19
+ Restaurant presentations, hospitality brands, fall campaigns, cozy lifestyle content, artisan products.
@@ -0,0 +1,19 @@
1
+ # Midnight Galaxy
2
+
3
+ A dramatic and cosmic theme with deep purples and mystical tones for impactful presentations.
4
+
5
+ ## Color Palette
6
+
7
+ - **Deep Purple**: `#2b1e3e` - Rich dark base
8
+ - **Cosmic Blue**: `#4a4e8f` - Mystical mid-tone
9
+ - **Lavender**: `#a490c2` - Soft accent color
10
+ - **Silver**: `#e6e6fa` - Light highlights and text
11
+
12
+ ## Typography
13
+
14
+ - **Headers**: FreeSans Bold
15
+ - **Body Text**: FreeSans
16
+
17
+ ## Best Used For
18
+
19
+ Entertainment industry, gaming presentations, nightlife venues, luxury brands, creative agencies.
@@ -0,0 +1,19 @@
1
+ # Modern Minimalist
2
+
3
+ A clean and contemporary theme with a sophisticated grayscale palette for maximum versatility.
4
+
5
+ ## Color Palette
6
+
7
+ - **Charcoal**: `#36454f` - Primary dark color
8
+ - **Slate Gray**: `#708090` - Medium gray for accents
9
+ - **Light Gray**: `#d3d3d3` - Backgrounds and dividers
10
+ - **White**: `#ffffff` - Text and clean backgrounds
11
+
12
+ ## Typography
13
+
14
+ - **Headers**: DejaVu Sans Bold
15
+ - **Body Text**: DejaVu Sans
16
+
17
+ ## Best Used For
18
+
19
+ Tech presentations, architecture portfolios, design showcases, modern business proposals, data visualization.
@@ -0,0 +1,19 @@
1
+ # Ocean Depths
2
+
3
+ A professional and calming maritime theme that evokes the serenity of deep ocean waters.
4
+
5
+ ## Color Palette
6
+
7
+ - **Deep Navy**: `#1a2332` - Primary background color
8
+ - **Teal**: `#2d8b8b` - Accent color for highlights and emphasis
9
+ - **Seafoam**: `#a8dadc` - Secondary accent for lighter elements
10
+ - **Cream**: `#f1faee` - Text and light backgrounds
11
+
12
+ ## Typography
13
+
14
+ - **Headers**: DejaVu Sans Bold
15
+ - **Body Text**: DejaVu Sans
16
+
17
+ ## Best Used For
18
+
19
+ Corporate presentations, financial reports, professional consulting decks, trust-building content.
@@ -0,0 +1,19 @@
1
+ # Sunset Boulevard
2
+
3
+ A warm and vibrant theme inspired by golden hour sunsets, perfect for energetic and creative presentations.
4
+
5
+ ## Color Palette
6
+
7
+ - **Burnt Orange**: `#e76f51` - Primary accent color
8
+ - **Coral**: `#f4a261` - Secondary warm accent
9
+ - **Warm Sand**: `#e9c46a` - Highlighting and backgrounds
10
+ - **Deep Purple**: `#264653` - Dark contrast and text
11
+
12
+ ## Typography
13
+
14
+ - **Headers**: DejaVu Serif Bold
15
+ - **Body Text**: DejaVu Sans
16
+
17
+ ## Best Used For
18
+
19
+ Creative pitches, marketing presentations, lifestyle brands, event promotions, inspirational content.
@@ -0,0 +1,19 @@
1
+ # Tech Innovation
2
+
3
+ A bold and modern theme with high-contrast colors perfect for cutting-edge technology presentations.
4
+
5
+ ## Color Palette
6
+
7
+ - **Electric Blue**: `#0066ff` - Vibrant primary accent
8
+ - **Neon Cyan**: `#00ffff` - Bright highlight color
9
+ - **Dark Gray**: `#1e1e1e` - Deep backgrounds
10
+ - **White**: `#ffffff` - Clean text and contrast
11
+
12
+ ## Typography
13
+
14
+ - **Headers**: DejaVu Sans Bold
15
+ - **Body Text**: DejaVu Sans
16
+
17
+ ## Best Used For
18
+
19
+ Tech startups, software launches, innovation showcases, AI/ML presentations, digital transformation content.
@@ -0,0 +1,99 @@
1
+ ---
2
+ name: youtube-downloader
3
+ description: Download YouTube videos with customizable quality and format options. Use this skill when the user asks to download, save, or grab YouTube videos. Supports various quality settings (best, 1080p, 720p, 480p, 360p), multiple formats (mp4, webm, mkv), and audio-only downloads as MP3.
4
+ ---
5
+
6
+ # YouTube Video Downloader
7
+
8
+ Download YouTube videos with full control over quality and format settings.
9
+
10
+ ## Quick Start
11
+
12
+ The simplest way to download a video:
13
+
14
+ ```bash
15
+ python scripts/download_video.py "https://www.youtube.com/watch?v=VIDEO_ID"
16
+ ```
17
+
18
+ This downloads the video in best available quality as MP4 to `/mnt/user-data/outputs/`.
19
+
20
+ ## Options
21
+
22
+ ### Quality Settings
23
+
24
+ Use `-q` or `--quality` to specify video quality:
25
+
26
+ - `best` (default): Highest quality available
27
+ - `1080p`: Full HD
28
+ - `720p`: HD
29
+ - `480p`: Standard definition
30
+ - `360p`: Lower quality
31
+ - `worst`: Lowest quality available
32
+
33
+ Example:
34
+ ```bash
35
+ python scripts/download_video.py "URL" -q 720p
36
+ ```
37
+
38
+ ### Format Options
39
+
40
+ Use `-f` or `--format` to specify output format (video downloads only):
41
+
42
+ - `mp4` (default): Most compatible
43
+ - `webm`: Modern format
44
+ - `mkv`: Matroska container
45
+
46
+ Example:
47
+ ```bash
48
+ python scripts/download_video.py "URL" -f webm
49
+ ```
50
+
51
+ ### Audio Only
52
+
53
+ Use `-a` or `--audio-only` to download only audio as MP3:
54
+
55
+ ```bash
56
+ python scripts/download_video.py "URL" -a
57
+ ```
58
+
59
+ ### Custom Output Directory
60
+
61
+ Use `-o` or `--output` to specify a different output directory:
62
+
63
+ ```bash
64
+ python scripts/download_video.py "URL" -o /path/to/directory
65
+ ```
66
+
67
+ ## Complete Examples
68
+
69
+ 1. Download video in 1080p as MP4:
70
+ ```bash
71
+ python scripts/download_video.py "https://www.youtube.com/watch?v=dQw4w9WgXcQ" -q 1080p
72
+ ```
73
+
74
+ 2. Download audio only as MP3:
75
+ ```bash
76
+ python scripts/download_video.py "https://www.youtube.com/watch?v=dQw4w9WgXcQ" -a
77
+ ```
78
+
79
+ 3. Download in 720p as WebM to custom directory:
80
+ ```bash
81
+ python scripts/download_video.py "https://www.youtube.com/watch?v=dQw4w9WgXcQ" -q 720p -f webm -o /custom/path
82
+ ```
83
+
84
+ ## How It Works
85
+
86
+ The skill uses `yt-dlp`, a robust YouTube downloader that:
87
+ - Automatically installs itself if not present
88
+ - Fetches video information before downloading
89
+ - Selects the best available streams matching your criteria
90
+ - Merges video and audio streams when needed
91
+ - Supports a wide range of YouTube video formats
92
+
93
+ ## Important Notes
94
+
95
+ - Downloads are saved to `/mnt/user-data/outputs/` by default
96
+ - Video filename is automatically generated from the video title
97
+ - The script handles installation of yt-dlp automatically
98
+ - Only single videos are downloaded (playlists are skipped by default)
99
+ - Higher quality videos may take longer to download and use more disk space
@@ -0,0 +1,32 @@
1
+ ---
2
+ name: web-development
3
+ description: Frontend/UI development with visual verification, dev server testing, browser automation
4
+ triggers: frontend, ui, web, react, next, html, css, dashboard, landing page, component, dev server, browser, visual, responsive, layout, vite, webpack
5
+ ---
6
+
7
+ # Web Development & UI Testing
8
+
9
+ ## UI Testing Loop (MANDATORY for frontend tasks)
10
+ 1. Start dev server in background: `executeCommand("npm run dev", {"background":true,"cwd":"/project"})`
11
+ 2. Navigate: `browserAction("navigate", "http://localhost:3000")`
12
+ 3. Screenshot: `browserAction("screenshot", "/tmp/ui-check.png")`
13
+ 4. Analyze: `imageAnalysis("/tmp/ui-check.png", "Check layout, spacing, responsiveness, broken elements, visual bugs.")`
14
+ 5. If issues found → fix code → screenshot → analyze again. Loop until clean.
15
+ 6. Test interactions: click buttons, fill forms, check navigation with browserAction.
16
+ 7. Only finish after visual verification passes.
17
+
18
+ ## Dev Server Workflow
19
+ - Start with `background:true` to keep server running while you test.
20
+ - Capture the PID from the response.
21
+ - Navigate with `browserAction("navigate", url)` to test.
22
+ - When done: `executeCommand("kill <pid>")`.
23
+
24
+ ## Testing Workflow
25
+ - After meaningful code changes → write tests → run them → fix failures → repeat until green.
26
+ - For bug fixes: write a test that PROVES the bug is fixed before finishing.
27
+ - Never tell the user to run tests manually. Run them yourself.
28
+
29
+ ## Build Verification
30
+ - After any code change → run build command (`npm run build` or equivalent).
31
+ - If build fails → read error → diagnose root cause → fix → rebuild. Repeat until clean.
32
+ - NEVER finish while a build error exists.
@@ -0,0 +1,96 @@
1
+ ---
2
+ name: webapp-testing
3
+ description: Toolkit for interacting with and testing local web applications using Playwright. Supports verifying frontend functionality, debugging UI behavior, capturing browser screenshots, and viewing browser logs.
4
+ license: Complete terms in LICENSE.txt
5
+ ---
6
+
7
+ # Web Application Testing
8
+
9
+ To test local web applications, write native Python Playwright scripts.
10
+
11
+ **Helper Scripts Available**:
12
+ - `scripts/with_server.py` - Manages server lifecycle (supports multiple servers)
13
+
14
+ **Always run scripts with `--help` first** to see usage. DO NOT read the source until you try running the script first and find that a customized solution is abslutely necessary. These scripts can be very large and thus pollute your context window. They exist to be called directly as black-box scripts rather than ingested into your context window.
15
+
16
+ ## Decision Tree: Choosing Your Approach
17
+
18
+ ```
19
+ User task → Is it static HTML?
20
+ ├─ Yes → Read HTML file directly to identify selectors
21
+ │ ├─ Success → Write Playwright script using selectors
22
+ │ └─ Fails/Incomplete → Treat as dynamic (below)
23
+
24
+ └─ No (dynamic webapp) → Is the server already running?
25
+ ├─ No → Run: python scripts/with_server.py --help
26
+ │ Then use the helper + write simplified Playwright script
27
+
28
+ └─ Yes → Reconnaissance-then-action:
29
+ 1. Navigate and wait for networkidle
30
+ 2. Take screenshot or inspect DOM
31
+ 3. Identify selectors from rendered state
32
+ 4. Execute actions with discovered selectors
33
+ ```
34
+
35
+ ## Example: Using with_server.py
36
+
37
+ To start a server, run `--help` first, then use the helper:
38
+
39
+ **Single server:**
40
+ ```bash
41
+ python scripts/with_server.py --server "npm run dev" --port 5173 -- python your_automation.py
42
+ ```
43
+
44
+ **Multiple servers (e.g., backend + frontend):**
45
+ ```bash
46
+ python scripts/with_server.py \
47
+ --server "cd backend && python server.py" --port 3000 \
48
+ --server "cd frontend && npm run dev" --port 5173 \
49
+ -- python your_automation.py
50
+ ```
51
+
52
+ To create an automation script, include only Playwright logic (servers are managed automatically):
53
+ ```python
54
+ from playwright.sync_api import sync_playwright
55
+
56
+ with sync_playwright() as p:
57
+ browser = p.chromium.launch(headless=True) # Always launch chromium in headless mode
58
+ page = browser.new_page()
59
+ page.goto('http://localhost:5173') # Server already running and ready
60
+ page.wait_for_load_state('networkidle') # CRITICAL: Wait for JS to execute
61
+ # ... your automation logic
62
+ browser.close()
63
+ ```
64
+
65
+ ## Reconnaissance-Then-Action Pattern
66
+
67
+ 1. **Inspect rendered DOM**:
68
+ ```python
69
+ page.screenshot(path='/tmp/inspect.png', full_page=True)
70
+ content = page.content()
71
+ page.locator('button').all()
72
+ ```
73
+
74
+ 2. **Identify selectors** from inspection results
75
+
76
+ 3. **Execute actions** using discovered selectors
77
+
78
+ ## Common Pitfall
79
+
80
+ ❌ **Don't** inspect the DOM before waiting for `networkidle` on dynamic apps
81
+ ✅ **Do** wait for `page.wait_for_load_state('networkidle')` before inspection
82
+
83
+ ## Best Practices
84
+
85
+ - **Use bundled scripts as black boxes** - To accomplish a task, consider whether one of the scripts available in `scripts/` can help. These scripts handle common, complex workflows reliably without cluttering the context window. Use `--help` to see usage, then invoke directly.
86
+ - Use `sync_playwright()` for synchronous scripts
87
+ - Always close the browser when done
88
+ - Use descriptive selectors: `text=`, `role=`, CSS selectors, or IDs
89
+ - Add appropriate waits: `page.wait_for_selector()` or `page.wait_for_timeout()`
90
+
91
+ ## Reference Files
92
+
93
+ - **examples/** - Examples showing common patterns:
94
+ - `element_discovery.py` - Discovering buttons, links, and inputs on a page
95
+ - `static_html_automation.py` - Using file:// URLs for local HTML
96
+ - `console_logging.py` - Capturing console logs during automation
@@ -0,0 +1,35 @@
1
+ from playwright.sync_api import sync_playwright
2
+
3
+ # Example: Capturing console logs during browser automation
4
+
5
+ url = 'http://localhost:5173' # Replace with your URL
6
+
7
+ console_logs = []
8
+
9
+ with sync_playwright() as p:
10
+ browser = p.chromium.launch(headless=True)
11
+ page = browser.new_page(viewport={'width': 1920, 'height': 1080})
12
+
13
+ # Set up console log capture
14
+ def handle_console_message(msg):
15
+ console_logs.append(f"[{msg.type}] {msg.text}")
16
+ print(f"Console: [{msg.type}] {msg.text}")
17
+
18
+ page.on("console", handle_console_message)
19
+
20
+ # Navigate to page
21
+ page.goto(url)
22
+ page.wait_for_load_state('networkidle')
23
+
24
+ # Interact with the page (triggers console logs)
25
+ page.click('text=Dashboard')
26
+ page.wait_for_timeout(1000)
27
+
28
+ browser.close()
29
+
30
+ # Save console logs to file
31
+ with open('/mnt/user-data/outputs/console.log', 'w') as f:
32
+ f.write('\n'.join(console_logs))
33
+
34
+ print(f"\nCaptured {len(console_logs)} console messages")
35
+ print(f"Logs saved to: /mnt/user-data/outputs/console.log")
@@ -0,0 +1,40 @@
1
+ from playwright.sync_api import sync_playwright
2
+
3
+ # Example: Discovering buttons and other elements on a page
4
+
5
+ with sync_playwright() as p:
6
+ browser = p.chromium.launch(headless=True)
7
+ page = browser.new_page()
8
+
9
+ # Navigate to page and wait for it to fully load
10
+ page.goto('http://localhost:5173')
11
+ page.wait_for_load_state('networkidle')
12
+
13
+ # Discover all buttons on the page
14
+ buttons = page.locator('button').all()
15
+ print(f"Found {len(buttons)} buttons:")
16
+ for i, button in enumerate(buttons):
17
+ text = button.inner_text() if button.is_visible() else "[hidden]"
18
+ print(f" [{i}] {text}")
19
+
20
+ # Discover links
21
+ links = page.locator('a[href]').all()
22
+ print(f"\nFound {len(links)} links:")
23
+ for link in links[:5]: # Show first 5
24
+ text = link.inner_text().strip()
25
+ href = link.get_attribute('href')
26
+ print(f" - {text} -> {href}")
27
+
28
+ # Discover input fields
29
+ inputs = page.locator('input, textarea, select').all()
30
+ print(f"\nFound {len(inputs)} input fields:")
31
+ for input_elem in inputs:
32
+ name = input_elem.get_attribute('name') or input_elem.get_attribute('id') or "[unnamed]"
33
+ input_type = input_elem.get_attribute('type') or 'text'
34
+ print(f" - {name} ({input_type})")
35
+
36
+ # Take screenshot for visual reference
37
+ page.screenshot(path='/tmp/page_discovery.png', full_page=True)
38
+ print("\nScreenshot saved to /tmp/page_discovery.png")
39
+
40
+ browser.close()
@@ -0,0 +1,33 @@
1
+ from playwright.sync_api import sync_playwright
2
+ import os
3
+
4
+ # Example: Automating interaction with static HTML files using file:// URLs
5
+
6
+ html_file_path = os.path.abspath('path/to/your/file.html')
7
+ file_url = f'file://{html_file_path}'
8
+
9
+ with sync_playwright() as p:
10
+ browser = p.chromium.launch(headless=True)
11
+ page = browser.new_page(viewport={'width': 1920, 'height': 1080})
12
+
13
+ # Navigate to local HTML file
14
+ page.goto(file_url)
15
+
16
+ # Take screenshot
17
+ page.screenshot(path='/mnt/user-data/outputs/static_page.png', full_page=True)
18
+
19
+ # Interact with elements
20
+ page.click('text=Click Me')
21
+ page.fill('#name', 'John Doe')
22
+ page.fill('#email', 'john@example.com')
23
+
24
+ # Submit form
25
+ page.click('button[type="submit"]')
26
+ page.wait_for_timeout(500)
27
+
28
+ # Take final screenshot
29
+ page.screenshot(path='/mnt/user-data/outputs/after_submit.png', full_page=True)
30
+
31
+ browser.close()
32
+
33
+ print("Static HTML automation completed!")