gm-oc 2.0.375 → 2.0.377
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/gm-oc.mjs +13 -11
- package/package.json +1 -1
- package/skills/browser/SKILL.md +52 -0
package/gm-oc.mjs
CHANGED
|
@@ -27,17 +27,19 @@ function safePrintf(s) {
|
|
|
27
27
|
function stripFooter(s) { return s ? s.replace(/\n\[Running tools\][\s\S]*$/, '').trimEnd() : ''; }
|
|
28
28
|
|
|
29
29
|
function tryLangPlugin(lang, code, cwd) {
|
|
30
|
-
const
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
30
|
+
const projectDir = cwd || process.cwd();
|
|
31
|
+
const candidates = [join(projectDir, 'lang', lang+'.js'), join(__dirname, '..', 'lang', lang+'.js')];
|
|
32
|
+
for (const langPluginFile of candidates) {
|
|
33
|
+
if (!existsSync(langPluginFile)) continue;
|
|
34
|
+
try {
|
|
35
|
+
const plugin = require(langPluginFile);
|
|
36
|
+
if (plugin && plugin.exec && plugin.exec.run) {
|
|
37
|
+
const result = plugin.exec.run(code, projectDir);
|
|
38
|
+
if (result && typeof result.then === 'function') continue;
|
|
39
|
+
return String(result === undefined ? '' : result);
|
|
40
|
+
}
|
|
41
|
+
} catch(e) {}
|
|
42
|
+
}
|
|
41
43
|
return null;
|
|
42
44
|
}
|
|
43
45
|
|
package/package.json
CHANGED
package/skills/browser/SKILL.md
CHANGED
|
@@ -74,6 +74,58 @@ exec:browser
|
|
|
74
74
|
console.log(JSON.stringify(state.consoleMsgs))
|
|
75
75
|
```
|
|
76
76
|
|
|
77
|
+
### Web Worker Console Monitoring
|
|
78
|
+
|
|
79
|
+
Capture console output from Dedicated Web Workers (e.g. game server workers):
|
|
80
|
+
|
|
81
|
+
```
|
|
82
|
+
exec:browser
|
|
83
|
+
state.workerMsgs = []
|
|
84
|
+
// Capture from already-spawned workers
|
|
85
|
+
for (const w of page.workers()) {
|
|
86
|
+
w.evaluate(() => {
|
|
87
|
+
const orig = console.log.bind(console)
|
|
88
|
+
console.log = (...a) => { orig(...a); self.postMessage({ __log: a.map(String).join(' ') }) }
|
|
89
|
+
}).catch(() => {})
|
|
90
|
+
}
|
|
91
|
+
// Capture from workers spawned after this point
|
|
92
|
+
page.on('worker', w => {
|
|
93
|
+
state.workerMsgs.push('[worker attached] ' + w.url())
|
|
94
|
+
w.evaluate(() => {
|
|
95
|
+
const orig = console.log.bind(console)
|
|
96
|
+
console.log = (...a) => { orig(...a); self.postMessage({ __log: a.map(String).join(' ') }) }
|
|
97
|
+
}).catch(() => {})
|
|
98
|
+
})
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
```
|
|
102
|
+
exec:browser
|
|
103
|
+
// List all active workers and their URLs
|
|
104
|
+
const workers = page.workers()
|
|
105
|
+
console.log('Workers:', workers.length, workers.map(w => w.url()).join(', '))
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
```
|
|
109
|
+
exec:browser
|
|
110
|
+
// Evaluate JS inside the first worker
|
|
111
|
+
const result = await page.workers()[0].evaluate(() => typeof self.someGlobal)
|
|
112
|
+
console.log(result)
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
### Inject Global Debug State into Page
|
|
116
|
+
|
|
117
|
+
```
|
|
118
|
+
exec:browser
|
|
119
|
+
const result = await page.evaluate(() => {
|
|
120
|
+
// Access app globals exposed on window
|
|
121
|
+
return JSON.stringify({
|
|
122
|
+
entityCount: window.debug?.scene?.children?.length,
|
|
123
|
+
playerId: window.debug?.client?.playerId
|
|
124
|
+
})
|
|
125
|
+
})
|
|
126
|
+
console.log(result)
|
|
127
|
+
```
|
|
128
|
+
|
|
77
129
|
## Key Rules
|
|
78
130
|
|
|
79
131
|
**Only `exec:browser`** — never run any browser CLI tool directly via Bash.
|