@cydm/pie 1.0.6 → 1.0.7
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/README.md +151 -9
- package/dist/builtin/extensions/ask-user/index.js +2 -3
- package/dist/builtin/extensions/kimi-attachments/index.js +3 -3
- package/dist/builtin/extensions/plan-mode/index.js +85 -87
- package/dist/builtin/extensions/subagent/index.js +73 -8
- package/dist/builtin/extensions/todo/index.js +51 -22
- package/dist/builtin/skills/browser-tools/CHANGELOG.md +2 -44
- package/dist/builtin/skills/browser-tools/README.md +10 -99
- package/dist/builtin/skills/browser-tools/SKILL.md +21 -174
- package/dist/builtin/skills/browser-tools/package.json +6 -13
- package/dist/builtin/skills/browser-tools/playwright-cli.js +24 -0
- package/dist/builtin/skills/pie-unity-rpc/SKILL.md +121 -0
- package/dist/builtin/skills/pie-unity-rpc/pie-unity-rpc.js +417 -0
- package/dist/builtin/skills/skill-creator/SKILL.md +17 -17
- package/dist/builtin/skills/skill-creator/eval-viewer/generate_review.mjs +285 -0
- package/dist/builtin/skills/skill-creator/eval-viewer/viewer.html +1 -1
- package/dist/builtin/skills/skill-creator/scripts/aggregate_benchmark.mjs +271 -0
- package/dist/builtin/skills/skill-creator/scripts/claude_cli.mjs +115 -0
- package/dist/builtin/skills/skill-creator/scripts/generate_report.mjs +224 -0
- package/dist/builtin/skills/skill-creator/scripts/improve_description.mjs +198 -0
- package/dist/builtin/skills/skill-creator/scripts/package_skill.mjs +132 -0
- package/dist/builtin/skills/skill-creator/scripts/pie_runner.mjs +115 -0
- package/dist/builtin/skills/skill-creator/scripts/quick_validate.mjs +44 -0
- package/dist/builtin/skills/skill-creator/scripts/run_eval.mjs +169 -0
- package/dist/builtin/skills/skill-creator/scripts/run_loop.mjs +297 -0
- package/dist/builtin/skills/skill-creator/scripts/skill_metadata.mjs +134 -0
- package/dist/chunks/{chunk-MWFBYJOI.js → chunk-A5JSJAPK.js} +3973 -1313
- package/dist/chunks/chunk-BHNULR7U.js +7991 -0
- package/dist/chunks/chunk-GDTN4UPJ.js +701 -0
- package/dist/chunks/{src-EGWRDMLB.js → src-3X3HBT2G.js} +1 -2
- package/dist/chunks/typescript-GSKWJIO4.js +210747 -0
- package/dist/cli.js +14664 -11973
- package/models.schema.json +238 -0
- package/package.json +34 -8
- package/dist/builtin/skills/browser-tools/browser-content.js +0 -103
- package/dist/builtin/skills/browser-tools/browser-cookies.js +0 -35
- package/dist/builtin/skills/browser-tools/browser-eval.js +0 -49
- package/dist/builtin/skills/browser-tools/browser-hn-scraper.js +0 -108
- package/dist/builtin/skills/browser-tools/browser-nav.js +0 -44
- package/dist/builtin/skills/browser-tools/browser-pick.js +0 -162
- package/dist/builtin/skills/browser-tools/browser-screenshot.js +0 -34
- package/dist/builtin/skills/browser-tools/browser-start.js +0 -86
- package/dist/builtin/skills/skill-creator/eval-viewer/generate_review.py +0 -471
- package/dist/builtin/skills/skill-creator/scripts/__init__.py +0 -0
- package/dist/builtin/skills/skill-creator/scripts/aggregate_benchmark.py +0 -401
- package/dist/builtin/skills/skill-creator/scripts/generate_report.py +0 -326
- package/dist/builtin/skills/skill-creator/scripts/improve_description.py +0 -247
- package/dist/builtin/skills/skill-creator/scripts/package_skill.py +0 -136
- package/dist/builtin/skills/skill-creator/scripts/quick_validate.py +0 -103
- package/dist/builtin/skills/skill-creator/scripts/run_eval.py +0 -310
- package/dist/builtin/skills/skill-creator/scripts/run_loop.py +0 -328
- package/dist/builtin/skills/skill-creator/scripts/utils.py +0 -47
- package/dist/chunks/capabilities-FENCOHVA.js +0 -9
- package/dist/chunks/chunk-JYBXCEJJ.js +0 -315
- package/dist/chunks/chunk-RID3574D.js +0 -2718
- package/dist/chunks/chunk-TBJ25UWB.js +0 -3657
- package/dist/chunks/chunk-XZXLO7YB.js +0 -322
- package/dist/chunks/file-logger-AL5VVZHH.js +0 -22
- package/dist/chunks/src-WRUACRN2.js +0 -132
|
@@ -1,30 +1,37 @@
|
|
|
1
1
|
import { createRequire as __createRequire } from "node:module"; const require = __createRequire(import.meta.url);
|
|
2
2
|
import {
|
|
3
3
|
ManageTodoListParamsSchema,
|
|
4
|
+
buildExecutionReminder,
|
|
5
|
+
createExecutionStateFromTodos,
|
|
6
|
+
createTodoWidgetView,
|
|
4
7
|
executeManageTodoList,
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
import "../../../chunks/chunk-
|
|
8
|
+
executionStateToTodos,
|
|
9
|
+
restoreExecutionState
|
|
10
|
+
} from "../../../chunks/chunk-BHNULR7U.js";
|
|
11
|
+
import "../../../chunks/chunk-A5JSJAPK.js";
|
|
9
12
|
import "../../../chunks/chunk-TG2EQLX2.js";
|
|
10
13
|
|
|
11
14
|
// builtin/extensions/todo/index.ts
|
|
12
|
-
var
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
15
|
+
var EXECUTION_METADATA_KEY = "executionState";
|
|
16
|
+
var TOOL_DESCRIPTION = `Manage a session-local todo list. Use when the user explicitly asks to use the todo tool, create/manage todos, track tasks, follow a todo list, show tasks, or mark a task done.
|
|
17
|
+
NEVER use for: internal planning, tracking your own progress, remembering subtasks, or creating checklists for yourself.
|
|
18
|
+
Use action=create with items to create a list; the tool starts item 1 automatically. Use action=complete_current after finishing the current item; the tool advances to the next item or clears the list after the final item.
|
|
19
|
+
When a todo list exists, keep executing from the current in-progress item until it is cleared. If the work cannot continue, explain the failure and use action=clear with a reason.
|
|
20
|
+
Actions: create, read, complete_current, clear.`;
|
|
21
|
+
function persistExecutionState(ctx, state) {
|
|
22
|
+
const nextState = state ?? restoreExecutionState(null);
|
|
23
|
+
ctx.setSessionMetadata(EXECUTION_METADATA_KEY, nextState);
|
|
24
|
+
ctx.setExecutionState(nextState);
|
|
25
|
+
ctx.setExecutionReminder(buildExecutionReminder(nextState) ?? void 0);
|
|
26
|
+
return nextState;
|
|
27
|
+
}
|
|
28
|
+
function notifyWidget(ctx, state) {
|
|
29
|
+
if (!ctx.hasUI || !ctx.ui) return;
|
|
30
|
+
const steps = createTodoWidgetView(state);
|
|
31
|
+
if (steps.length === 0) return;
|
|
32
|
+
const completed = steps.filter((step) => step.status === "completed").length;
|
|
33
|
+
ctx.ui.notify(`Todo tracking: ${completed}/${steps.length} completed`, "info");
|
|
34
|
+
}
|
|
28
35
|
function todoExtension(ctx) {
|
|
29
36
|
ctx.registerTool({
|
|
30
37
|
name: "manage_todo_list",
|
|
@@ -32,8 +39,30 @@ function todoExtension(ctx) {
|
|
|
32
39
|
description: TOOL_DESCRIPTION,
|
|
33
40
|
parameters: ManageTodoListParamsSchema,
|
|
34
41
|
async execute(args) {
|
|
35
|
-
const currentTodos =
|
|
36
|
-
|
|
42
|
+
const currentTodos = executionStateToTodos(ctx.getExecutionState());
|
|
43
|
+
const execution = executeManageTodoList(args, currentTodos);
|
|
44
|
+
const nextState = createExecutionStateFromTodos(execution.nextTodos, "todo", "user_todo");
|
|
45
|
+
persistExecutionState(ctx, nextState);
|
|
46
|
+
notifyWidget(ctx, nextState);
|
|
47
|
+
return execution.result;
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
ctx.on("session:changed", async () => {
|
|
51
|
+
const state = restoreExecutionState(ctx.getSessionMetadata()?.[EXECUTION_METADATA_KEY]);
|
|
52
|
+
persistExecutionState(ctx, state);
|
|
53
|
+
});
|
|
54
|
+
ctx.on("tool:execution:end", async (event) => {
|
|
55
|
+
if (event.toolName !== "manage_todo_list") return;
|
|
56
|
+
const details = event.result?.details;
|
|
57
|
+
if (!details?.todos) return;
|
|
58
|
+
const state = createExecutionStateFromTodos(details.todos, "todo", "user_todo");
|
|
59
|
+
persistExecutionState(ctx, state);
|
|
60
|
+
});
|
|
61
|
+
ctx.on("agent:end", async () => {
|
|
62
|
+
const state = ctx.getExecutionState();
|
|
63
|
+
if (state.mode !== "todo") return;
|
|
64
|
+
if (state.lifecycle === "completed") {
|
|
65
|
+
persistExecutionState(ctx, null);
|
|
37
66
|
}
|
|
38
67
|
});
|
|
39
68
|
ctx.log("Builtin todo extension ready");
|
|
@@ -1,47 +1,5 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
## 2.0.0
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
-
|
|
8
|
-
## [1.1.0] - 2025-03-10
|
|
9
|
-
|
|
10
|
-
### Fixed
|
|
11
|
-
|
|
12
|
-
- **browser-eval.js**: Fixed complex JavaScript code execution
|
|
13
|
-
- Support for "const", "let", "var" keywords
|
|
14
|
-
- Support for multi-line code and conditionals (if/else, for, while)
|
|
15
|
-
- Support for function declarations and calls
|
|
16
|
-
- Automatic expression return value handling
|
|
17
|
-
- Fixed AsyncFunction wrapping syntax errors
|
|
18
|
-
|
|
19
|
-
### Improved
|
|
20
|
-
|
|
21
|
-
- Improved code execution logic using eval() instead of complex AsyncFunction wrapping
|
|
22
|
-
- Support for more complex browser automation scenarios (e.g., MagicShell 10-round dialog testing)
|
|
23
|
-
|
|
24
|
-
## [1.0.0] - 2025-03-09
|
|
25
|
-
|
|
26
|
-
### Initial Release
|
|
27
|
-
|
|
28
|
-
- Basic browser automation toolset
|
|
29
|
-
- Chrome DevTools Protocol support
|
|
30
|
-
- Included tools:
|
|
31
|
-
- browser-start.js: Start Chrome
|
|
32
|
-
- browser-nav.js: Page navigation
|
|
33
|
-
- browser-eval.js: JavaScript execution (basic)
|
|
34
|
-
- browser-screenshot.js: Screenshots
|
|
35
|
-
- browser-cookies.js: Cookie management
|
|
36
|
-
- browser-content.js: Content extraction
|
|
37
|
-
- browser-hn-scraper.js: HN scraper example
|
|
38
|
-
- browser-pick.js: Interactive element picker
|
|
39
|
-
|
|
40
|
-
### Dependencies
|
|
41
|
-
|
|
42
|
-
- puppeteer: ^24.31.0
|
|
43
|
-
- puppeteer-core: ^23.11.1
|
|
44
|
-
- @mozilla/readability: ^0.6.0
|
|
45
|
-
- cheerio: ^1.1.2
|
|
46
|
-
- jsdom: ^27.0.1
|
|
47
|
-
- turndown: ^7.2.2
|
|
5
|
+
- Replaced Pie's custom Chrome DevTools Protocol scripts with the packaged Microsoft Playwright CLI wrapper.
|
|
@@ -1,106 +1,17 @@
|
|
|
1
1
|
# Browser Tools
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Pie's browser-tools skill is backed by Microsoft Playwright CLI through `playwright-cli.js`.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
| Tool | Function | Usage |
|
|
8
|
-
|------|----------|-------|
|
|
9
|
-
| browser-start.js | Start Chrome with remote debugging | node browser-start.js |
|
|
10
|
-
| browser-nav.js | Navigate to URL | node browser-nav.js https://example.com |
|
|
11
|
-
| browser-eval.js | Execute JavaScript in browser | node browser-eval.js "document.title" |
|
|
12
|
-
| browser-screenshot.js | Take screenshot | node browser-screenshot.js |
|
|
13
|
-
| browser-cookies.js | Manage cookies | node browser-cookies.js |
|
|
14
|
-
| browser-content.js | Extract page content | node browser-content.js |
|
|
15
|
-
| browser-hn-scraper.js | HN scraper example | node browser-hn-scraper.js |
|
|
16
|
-
| browser-pick.js | Interactive element picker | node browser-pick.js |
|
|
17
|
-
|
|
18
|
-
## Quick Start
|
|
19
|
-
|
|
20
|
-
### 1. Install dependencies
|
|
21
|
-
|
|
22
|
-
```bash
|
|
23
|
-
npm install
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
### 2. Start Chrome
|
|
27
|
-
|
|
28
|
-
```bash
|
|
29
|
-
node browser-start.js
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
This starts Chrome with remote debugging port (default: 9222).
|
|
33
|
-
|
|
34
|
-
### 3. Use tools
|
|
5
|
+
Use:
|
|
35
6
|
|
|
36
7
|
```bash
|
|
37
|
-
|
|
38
|
-
node
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
node
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
node browser-eval.js "
|
|
45
|
-
const links = document.querySelectorAll("a");
|
|
46
|
-
const count = links.length;
|
|
47
|
-
count;
|
|
48
|
-
"
|
|
49
|
-
|
|
50
|
-
# Take screenshot
|
|
51
|
-
node browser-screenshot.js
|
|
8
|
+
node playwright-cli.js --help
|
|
9
|
+
node playwright-cli.js open https://example.com
|
|
10
|
+
node playwright-cli.js snapshot
|
|
11
|
+
node playwright-cli.js screenshot
|
|
12
|
+
node playwright-cli.js console
|
|
13
|
+
node playwright-cli.js network
|
|
14
|
+
node playwright-cli.js close
|
|
52
15
|
```
|
|
53
16
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
### Simple expressions
|
|
57
|
-
|
|
58
|
-
```bash
|
|
59
|
-
node browser-eval.js "1 + 1" # Output: 2
|
|
60
|
-
node browser-eval.js "document.title" # Output: Page title
|
|
61
|
-
```
|
|
62
|
-
|
|
63
|
-
### Complex code
|
|
64
|
-
|
|
65
|
-
Supports multi-line code, const/let/var, conditionals:
|
|
66
|
-
|
|
67
|
-
```bash
|
|
68
|
-
node browser-eval.js "
|
|
69
|
-
const buttons = document.querySelectorAll("button");
|
|
70
|
-
const count = buttons.length;
|
|
71
|
-
count;
|
|
72
|
-
"
|
|
73
|
-
|
|
74
|
-
node browser-eval.js "
|
|
75
|
-
let sum = 0;
|
|
76
|
-
for (let i = 1; i <= 5; i++) {
|
|
77
|
-
sum += i;
|
|
78
|
-
}
|
|
79
|
-
sum;
|
|
80
|
-
"
|
|
81
|
-
```
|
|
82
|
-
|
|
83
|
-
## Tech Stack
|
|
84
|
-
|
|
85
|
-
- **Puppeteer Core**: Connect and control Chrome browser
|
|
86
|
-
- **Chrome DevTools Protocol**: Browser remote debugging protocol
|
|
87
|
-
- **ES Modules**: Native ES module system
|
|
88
|
-
|
|
89
|
-
## Dependencies
|
|
90
|
-
|
|
91
|
-
- puppeteer: ^24.31.0
|
|
92
|
-
- puppeteer-core: ^23.11.1
|
|
93
|
-
|
|
94
|
-
## Notes
|
|
95
|
-
|
|
96
|
-
1. Must run browser-start.js first to start Chrome
|
|
97
|
-
2. Chrome must be started in remote debugging mode (default port 9222)
|
|
98
|
-
3. browser-eval.js uses eval() to execute code, ensure input is trusted
|
|
99
|
-
|
|
100
|
-
## Author
|
|
101
|
-
|
|
102
|
-
Mario Zechner
|
|
103
|
-
|
|
104
|
-
## License
|
|
105
|
-
|
|
106
|
-
MIT
|
|
17
|
+
Dependencies are provided by `@cydm/pie`; do not run `npm install` inside this skill directory.
|
|
@@ -1,196 +1,43 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: browser-tools
|
|
3
|
-
description: Interactive browser automation via
|
|
3
|
+
description: Interactive browser automation via Microsoft Playwright CLI. Use when you need to open pages, inspect DOM snapshots, click/type, capture screenshots, inspect console/network output, or test frontend flows in a real browser.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# Browser Tools
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
Use Pie's packaged Microsoft Playwright CLI wrapper. Scripts live next to this skill; use `read_resource("browser-tools", "playwright-cli.js")` or `resolve_resource("browser-tools", "playwright-cli.js")` to get the executable path.
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
No manual dependency install is required when this skill is shipped with Pie.
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
## Common Commands
|
|
13
13
|
|
|
14
14
|
```bash
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
node <resolvedPath for playwright-cli.js> open https://example.com
|
|
16
|
+
node <resolvedPath for playwright-cli.js> goto https://example.com
|
|
17
|
+
node <resolvedPath for playwright-cli.js> snapshot
|
|
18
|
+
node <resolvedPath for playwright-cli.js> click "Submit"
|
|
19
|
+
node <resolvedPath for playwright-cli.js> type "hello"
|
|
20
|
+
node <resolvedPath for playwright-cli.js> screenshot
|
|
21
|
+
node <resolvedPath for playwright-cli.js> console
|
|
22
|
+
node <resolvedPath for playwright-cli.js> network
|
|
23
|
+
node <resolvedPath for playwright-cli.js> close
|
|
17
24
|
```
|
|
18
25
|
|
|
19
|
-
|
|
26
|
+
Use `node <resolvedPath for playwright-cli.js> --help` for the full command list.
|
|
20
27
|
|
|
21
|
-
|
|
22
|
-
{baseDir}/browser-start.js # Fresh profile
|
|
23
|
-
{baseDir}/browser-start.js --profile # Copy user's profile (cookies, logins)
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
Launch Chrome with remote debugging on `:9222`. Use `--profile` to preserve user's authentication state.
|
|
27
|
-
|
|
28
|
-
## Navigate
|
|
29
|
-
|
|
30
|
-
```bash
|
|
31
|
-
{baseDir}/browser-nav.js https://example.com
|
|
32
|
-
{baseDir}/browser-nav.js https://example.com --new
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
Navigate to URLs. Use `--new` flag to open in a new tab instead of reusing current tab.
|
|
36
|
-
|
|
37
|
-
## Evaluate JavaScript
|
|
38
|
-
|
|
39
|
-
```bash
|
|
40
|
-
{baseDir}/browser-eval.js 'document.title'
|
|
41
|
-
{baseDir}/browser-eval.js 'document.querySelectorAll("a").length'
|
|
42
|
-
```
|
|
43
|
-
|
|
44
|
-
Execute JavaScript in the active tab. Code runs in async context. Use this to extract data, inspect page state, or perform DOM operations programmatically.
|
|
45
|
-
|
|
46
|
-
## Screenshot
|
|
47
|
-
|
|
48
|
-
```bash
|
|
49
|
-
{baseDir}/browser-screenshot.js
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
Capture current viewport and return temporary file path. Use this to visually inspect page state or verify UI changes.
|
|
53
|
-
|
|
54
|
-
## Pick Elements
|
|
55
|
-
|
|
56
|
-
```bash
|
|
57
|
-
{baseDir}/browser-pick.js "Click the submit button"
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
**IMPORTANT**: Use this tool when the user wants to select specific DOM elements on the page. This launches an interactive picker that lets the user click elements to select them. The user can select multiple elements (Cmd/Ctrl+Click) and press Enter when done. The tool returns CSS selectors for the selected elements.
|
|
28
|
+
## Workflow
|
|
61
29
|
|
|
62
|
-
|
|
63
|
-
- User says "I want to click that button" → Use this tool to let them select it
|
|
64
|
-
- User says "extract data from these items" → Use this tool to let them select the elements
|
|
65
|
-
- When you need specific selectors but the page structure is complex or ambiguous
|
|
30
|
+
Start with `open` or `goto`, then use `snapshot` before interacting. Prefer snapshot, console, and network output for diagnosis; use screenshots when visual layout matters. Use named sessions with `-s=<session>` when you need to keep multiple browser flows separate.
|
|
66
31
|
|
|
67
|
-
|
|
32
|
+
If the browser is not installed, run:
|
|
68
33
|
|
|
69
34
|
```bash
|
|
70
|
-
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
Display all cookies for the current tab including domain, path, httpOnly, and secure flags. Use this to debug authentication issues or inspect session state.
|
|
74
|
-
|
|
75
|
-
## Extract Page Content
|
|
76
|
-
|
|
77
|
-
```bash
|
|
78
|
-
{baseDir}/browser-content.js https://example.com
|
|
79
|
-
```
|
|
80
|
-
|
|
81
|
-
Navigate to a URL and extract readable content as markdown. Uses Mozilla Readability for article extraction and Turndown for HTML-to-markdown conversion. Works on pages with JavaScript content (waits for page to load).
|
|
82
|
-
|
|
83
|
-
## When to Use
|
|
84
|
-
|
|
85
|
-
- Testing frontend code in a real browser
|
|
86
|
-
- Interacting with pages that require JavaScript
|
|
87
|
-
- When user needs to visually see or interact with a page
|
|
88
|
-
- Debugging authentication or session issues
|
|
89
|
-
- Scraping dynamic content that requires JS execution
|
|
90
|
-
|
|
91
|
-
---
|
|
92
|
-
|
|
93
|
-
## Efficiency Guide
|
|
94
|
-
|
|
95
|
-
### DOM Inspection Over Screenshots
|
|
96
|
-
|
|
97
|
-
**Don't** take screenshots to see page state. **Do** parse the DOM directly:
|
|
98
|
-
|
|
99
|
-
```javascript
|
|
100
|
-
// Get page structure
|
|
101
|
-
document.body.innerHTML.slice(0, 5000)
|
|
102
|
-
|
|
103
|
-
// Find interactive elements
|
|
104
|
-
Array.from(document.querySelectorAll('button, input, [role="button"]')).map(e => ({
|
|
105
|
-
id: e.id,
|
|
106
|
-
text: e.textContent.trim(),
|
|
107
|
-
class: e.className
|
|
108
|
-
}))
|
|
109
|
-
```
|
|
110
|
-
|
|
111
|
-
### Complex Scripts in Single Calls
|
|
112
|
-
|
|
113
|
-
Wrap everything in an IIFE to run multi-statement code:
|
|
114
|
-
|
|
115
|
-
```javascript
|
|
116
|
-
(function() {
|
|
117
|
-
// Multiple operations
|
|
118
|
-
const data = document.querySelector('#target').textContent;
|
|
119
|
-
const buttons = document.querySelectorAll('button');
|
|
120
|
-
|
|
121
|
-
// Interactions
|
|
122
|
-
buttons[0].click();
|
|
123
|
-
|
|
124
|
-
// Return results
|
|
125
|
-
return JSON.stringify({ data, buttonCount: buttons.length });
|
|
126
|
-
})()
|
|
127
|
-
```
|
|
128
|
-
|
|
129
|
-
### Batch Interactions
|
|
130
|
-
|
|
131
|
-
**Don't** make separate calls for each click. **Do** batch them:
|
|
132
|
-
|
|
133
|
-
```javascript
|
|
134
|
-
(function() {
|
|
135
|
-
const actions = ["btn1", "btn2", "btn3"];
|
|
136
|
-
actions.forEach(id => document.getElementById(id).click());
|
|
137
|
-
return "Done";
|
|
138
|
-
})()
|
|
139
|
-
```
|
|
140
|
-
|
|
141
|
-
### Typing/Input Sequences
|
|
142
|
-
|
|
143
|
-
```javascript
|
|
144
|
-
(function() {
|
|
145
|
-
const text = "HELLO";
|
|
146
|
-
for (const char of text) {
|
|
147
|
-
document.getElementById("key-" + char).click();
|
|
148
|
-
}
|
|
149
|
-
document.getElementById("submit").click();
|
|
150
|
-
return "Submitted: " + text;
|
|
151
|
-
})()
|
|
35
|
+
node <resolvedPath for playwright-cli.js> install-browser chromium
|
|
152
36
|
```
|
|
153
37
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
Extract structured state in one call:
|
|
157
|
-
|
|
158
|
-
```javascript
|
|
159
|
-
(function() {
|
|
160
|
-
const state = {
|
|
161
|
-
score: document.querySelector('.score')?.textContent,
|
|
162
|
-
status: document.querySelector('.status')?.className,
|
|
163
|
-
items: Array.from(document.querySelectorAll('.item')).map(el => ({
|
|
164
|
-
text: el.textContent,
|
|
165
|
-
active: el.classList.contains('active')
|
|
166
|
-
}))
|
|
167
|
-
};
|
|
168
|
-
return JSON.stringify(state, null, 2);
|
|
169
|
-
})()
|
|
170
|
-
```
|
|
171
|
-
|
|
172
|
-
### Waiting for Updates
|
|
173
|
-
|
|
174
|
-
If DOM updates after actions, add a small delay with bash:
|
|
38
|
+
If a session gets stuck, use:
|
|
175
39
|
|
|
176
40
|
```bash
|
|
177
|
-
|
|
41
|
+
node <resolvedPath for playwright-cli.js> close
|
|
42
|
+
node <resolvedPath for playwright-cli.js> kill-all
|
|
178
43
|
```
|
|
179
|
-
|
|
180
|
-
### Investigate Before Interacting
|
|
181
|
-
|
|
182
|
-
Always start by understanding the page structure:
|
|
183
|
-
|
|
184
|
-
```javascript
|
|
185
|
-
(function() {
|
|
186
|
-
return {
|
|
187
|
-
title: document.title,
|
|
188
|
-
forms: document.forms.length,
|
|
189
|
-
buttons: document.querySelectorAll('button').length,
|
|
190
|
-
inputs: document.querySelectorAll('input').length,
|
|
191
|
-
mainContent: document.body.innerHTML.slice(0, 3000)
|
|
192
|
-
};
|
|
193
|
-
})()
|
|
194
|
-
```
|
|
195
|
-
|
|
196
|
-
Then target specific elements based on what you find.
|
|
@@ -1,19 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "browser-tools",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"description": "
|
|
6
|
-
"author": "
|
|
5
|
+
"description": "Microsoft Playwright CLI wrapper for collaborative site exploration",
|
|
6
|
+
"author": "",
|
|
7
7
|
"license": "MIT",
|
|
8
|
-
"
|
|
9
|
-
|
|
10
|
-
"
|
|
11
|
-
"jsdom": "^27.0.1",
|
|
12
|
-
"puppeteer": "^24.31.0",
|
|
13
|
-
"puppeteer-core": "^23.11.1",
|
|
14
|
-
"puppeteer-extra": "^3.3.6",
|
|
15
|
-
"puppeteer-extra-plugin-stealth": "^2.11.2",
|
|
16
|
-
"turndown": "^7.2.2",
|
|
17
|
-
"turndown-plugin-gfm": "^1.0.2"
|
|
8
|
+
"private": true,
|
|
9
|
+
"pie": {
|
|
10
|
+
"dependenciesProvidedBy": "@cydm/pie"
|
|
18
11
|
}
|
|
19
12
|
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { spawnSync } from "node:child_process";
|
|
4
|
+
import { createRequire } from "node:module";
|
|
5
|
+
|
|
6
|
+
const require = createRequire(import.meta.url);
|
|
7
|
+
|
|
8
|
+
export function resolvePlaywrightCli() {
|
|
9
|
+
return require.resolve("@playwright/cli/playwright-cli.js");
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function runPlaywrightCli(args = process.argv.slice(2), options = {}) {
|
|
13
|
+
const bin = resolvePlaywrightCli();
|
|
14
|
+
return spawnSync(process.execPath, [bin, ...args], {
|
|
15
|
+
stdio: "inherit",
|
|
16
|
+
shell: false,
|
|
17
|
+
...options,
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
if (import.meta.url === `file://${process.argv[1]}`) {
|
|
22
|
+
const result = runPlaywrightCli();
|
|
23
|
+
process.exitCode = result.status ?? 1;
|
|
24
|
+
}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: pie-unity-rpc
|
|
3
|
+
description: Connect to a local pie-unity instance for Unity project discovery, health checks, manifest lookup, and a small set of stable RPC/tool calls. Use when working on a Unity project that imports pie-unity.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Pie Unity RPC
|
|
7
|
+
|
|
8
|
+
Use the helper script `pie-unity-rpc.js` to talk to local `pie-unity` instances. Prefer the shell-style host workflow:
|
|
9
|
+
|
|
10
|
+
1. Discover instances
|
|
11
|
+
2. Select the target project or instance
|
|
12
|
+
3. Check health
|
|
13
|
+
4. Read only the manifest slice you need
|
|
14
|
+
5. Query or inspect Unity state
|
|
15
|
+
6. Edit the scene, read logs, refresh Unity after file changes, or run a frame-scheduled Unity script task
|
|
16
|
+
7. Verify the result
|
|
17
|
+
|
|
18
|
+
Do not dump the full manifest unless the user explicitly asks for it.
|
|
19
|
+
|
|
20
|
+
Script resource: `pie-unity-rpc.js`
|
|
21
|
+
|
|
22
|
+
Command templates below use `<script>` as a placeholder for the resolved script path in the current host.
|
|
23
|
+
|
|
24
|
+
## Discover
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
node <script> instances
|
|
28
|
+
node <script> instances --project "/abs/path/to/project"
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Selection behavior:
|
|
32
|
+
|
|
33
|
+
- if there is only one active instance, the helper uses it automatically
|
|
34
|
+
- `--project` is treated as a matching hint, not only as an exact path
|
|
35
|
+
- if multiple candidates remain, the helper returns a structured candidate list; show it and ask the user which instance to use
|
|
36
|
+
- prefer `--instance` when the user already knows the target instance ID
|
|
37
|
+
|
|
38
|
+
## Health
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
node <script> health --project "/abs/path/to/project"
|
|
42
|
+
node <script> health --instance "<instance-id>"
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Manifest
|
|
46
|
+
|
|
47
|
+
Read only what you need:
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
node <script> manifest --project "/abs/path/to/project"
|
|
51
|
+
node <script> manifest --project "/abs/path/to/project" --namespace chat
|
|
52
|
+
node <script> manifest --project "/abs/path/to/project" --name unity_project_inspect
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Host Workflow
|
|
56
|
+
|
|
57
|
+
Prefer the host commands over raw `tool` names:
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
node <script> query --project "/abs/path/to/project" --data '{"scope":"scene_object","name":"Main Camera","limit":1}'
|
|
61
|
+
node <script> inspect --project "/abs/path/to/project" --data '{"target":{"path":"Main Camera"}}'
|
|
62
|
+
node <script> edit --project "/abs/path/to/project" --data '{"action":"create_scene_object","name":"CubeA","primitiveType":"Cube","x":0,"y":1,"z":0}'
|
|
63
|
+
node <script> log-read --project "/abs/path/to/project" --data '{"source":"active","tailLines":120,"contains":"error"}'
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
For Unity project files, use normal Pie file tools rooted at the Unity project. The RPC helper deliberately does not provide separate project file read/write commands.
|
|
67
|
+
|
|
68
|
+
## Script Run
|
|
69
|
+
|
|
70
|
+
Use `script-run` only for JavaScript generator tasks that should execute inside Unity. The script must define a generator entrypoint. For multi-frame work, yield `ctx.nextFrame()`, `ctx.waitFrames(n)`, or `ctx.waitSeconds(s)`. The command returns after the task completes, fails, or times out.
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
node <script> script-run --project "/abs/path/to/project" --data '{"script":"export function* run(ctx, args) { return ctx.query({ scope: \"scene_object\", limit: 3 }); }"}'
|
|
74
|
+
node <script> script-run --project "/abs/path/to/project" --data '{"script":"export function* run(ctx, args) { for (let i = 0; i < 60; i++) { ctx.log(\"frame\", i); yield ctx.nextFrame(); } return { ok: true }; }","totalTimeoutMs":10000,"maxFrames":120}'
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Do not pass C#, shader source, or raw file contents to `script-run`. Use normal Pie file tools for Unity project files, then call `unity_refresh` through `tool` if Unity must import changed assets. Do not write long synchronous loops. Express long goals as short generator steps that yield between frames.
|
|
78
|
+
|
|
79
|
+
## Raw Tool / RPC
|
|
80
|
+
|
|
81
|
+
Use raw `tool` or `rpc` only when the shell-style commands do not cover what you need.
|
|
82
|
+
|
|
83
|
+
## Retry Behavior
|
|
84
|
+
|
|
85
|
+
The helper automatically retries when `pie-unity` reports temporary unavailability during compilation or domain reload. Use `--wait-ms` to override the default polling delay.
|
|
86
|
+
|
|
87
|
+
When using `rpc --method pie_chat.set_config`, the helper waits for the Unity-side `configAppliedVersion` ack when available, then adds a short settle window before returning. Use `--config-settle-ms` to override that delay if needed.
|
|
88
|
+
|
|
89
|
+
## Guidance
|
|
90
|
+
|
|
91
|
+
- Start with `instances` if the target Unity project is not yet confirmed.
|
|
92
|
+
- Start with `health` if the project is known.
|
|
93
|
+
- Read this skill contract first. Do not start by scanning the local repo or helper source code unless the task is explicitly about the repo/tooling itself.
|
|
94
|
+
- If a command returns an ambiguous instance error, present the candidate list and ask the user to choose one instance.
|
|
95
|
+
- Read `manifest --namespace unity` or `manifest --namespace unity.script` before using unfamiliar host commands.
|
|
96
|
+
- Once the target `projectPath` is known, keep filesystem exploration scoped to that Unity project. Do not search unrelated repo directories to rediscover the project.
|
|
97
|
+
- For scene setup with named objects such as `Player`, `Goal`, or `Main Camera`, start with `query` for exact names before creating anything.
|
|
98
|
+
- If `query` finds exactly one match, reuse and update it instead of creating a duplicate.
|
|
99
|
+
- If `query` finds multiple matches, do not create another duplicate; inspect/select one explicit result or ask the user.
|
|
100
|
+
- Prefer `query -> inspect -> edit -> inspect` over ad-hoc menu execution. Use `edit` actions `add_component`, `remove_component`, `set_component_enabled`, and `set_component_property` for common scene object component changes instead of writing one-off script-run code.
|
|
101
|
+
- Use normal file tools with the Unity project root for project text files; do not route file access through Unity RPC.
|
|
102
|
+
- Read helper source code only when command behavior is unclear after reading this skill contract or manifest output.
|
|
103
|
+
- After editing C# scripts under `Assets`, call `tool --tool unity_refresh --data {}` if needed, then expect a brief compile/domain-reload window. Re-check `health` or retry the next host command instead of assuming Unity is stuck. If compile/runtime errors appear, use `log-read` instead of guessing.
|
|
104
|
+
- Prefer `script-run` when the task needs filtering, derived values, or multi-frame composition inside Unity.
|
|
105
|
+
|
|
106
|
+
## Smoke Test
|
|
107
|
+
|
|
108
|
+
Recommended minimum verification sequence:
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
node <script> health --project "/abs/path/to/project"
|
|
112
|
+
node <script> manifest --project "/abs/path/to/project" --namespace unity
|
|
113
|
+
node <script> tool --project "/abs/path/to/project" --tool chat_send --data '{"text":"respond with exactly pong"}'
|
|
114
|
+
node <script> tool --project "/abs/path/to/project" --tool chat_get_state
|
|
115
|
+
node <script> tool --project "/abs/path/to/project" --tool chat_get_messages
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
Expected result:
|
|
119
|
+
|
|
120
|
+
- `chat_get_state` eventually returns `isBusy: false`
|
|
121
|
+
- the final assistant message contains the expected response
|