@@ -14,6 +14,7 @@ const SEED_FILES = [
|
||||
'TOOLS.md',
|
||||
'PERSONA.md',
|
||||
'skills/skill-creator/SKILL.md',
|
||||
'skills/browser/SKILL.md',
|
||||
];
|
||||
|
||||
export function normalizeAssistantName(value) {
|
||||
@@ -37,6 +38,32 @@ function copyIfMissing(from, to) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const OLD_AGENTS_BROWSER = '- `web_search` / `google_search` / `fetch_page` / `web_fetch` / `wiki_search` / `hn_search` / `code_search` — Playwright Chromium. For cookie walls or extra clicks, call `browser` with snapshot then click or type.';
|
||||
const NEW_AGENTS_BROWSER = `- Web tools share one headed Playwright Chromium window. \`web_search\` / \`google_search\` / \`wiki_search\` / \`hn_search\` / \`code_search\` find links. \`fetch_page\` / \`web_fetch\` read a public page. For cookie banners, forms, logins, or leftover challenges, call \`browser\`. Before a multi-step browse, \`read_file\` \`skills/browser/SKILL.md\`.
|
||||
- \`browser\` actions: \`navigate\` (needs \`url\`), \`snapshot\`, \`click\` (\`ref\` from the last snapshot), \`type\` (\`ref\` + \`text\`, optional \`submit\`), \`press\` (\`key\`), \`scroll\` (\`dy\`), \`wait\` (\`ms\`). Snapshot or navigate first. Refs change after every click. Do not use \`cu_observe\` or the shell for websites.`;
|
||||
const OLD_TOOLS_BROWSER = '- Public HTTP via curl or wget is blocked. Use `web_search` / `web_fetch` in the Jarvis Chromium window. For cookie walls, call `browser` with snapshot then click or type.';
|
||||
const NEW_TOOLS_BROWSER = `- Public HTTP via curl or wget is blocked. Use \`web_search\` / \`web_fetch\` in the Jarvis Chromium window.
|
||||
|
||||
## Browser
|
||||
|
||||
- Search, fetch, and \`browser\` share one headed Playwright Chromium window.
|
||||
- \`web_search\` finds links. \`fetch_page\` reads a public page.
|
||||
- Cookie walls, forms, leftover challenges: call \`browser\`. \`read_file\` \`skills/browser/SKILL.md\` for the playbook.
|
||||
- \`browser\` actions: \`navigate\` + \`url\`, \`snapshot\`, \`click\`/\`type\` with \`ref\` from the last snapshot, \`press\` + \`key\`, \`scroll\` + \`dy\`, \`wait\` + \`ms\`.
|
||||
- Snapshot or navigate before every click or type. Refs go stale after a click.
|
||||
- Do not use \`cu_observe\` or the shell for websites.`;
|
||||
|
||||
function replaceOnce(file, from, to) {
|
||||
try {
|
||||
const text = fs.readFileSync(file, 'utf8');
|
||||
if (!from || !text.includes(from)) return false;
|
||||
fs.writeFileSync(file, text.replace(from, to));
|
||||
return true;
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function escapeRegExp(value) {
|
||||
return String(value).replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
||||
}
|
||||
@@ -90,6 +117,8 @@ export function ensureAgentWorkspace({ name = 'Jarvis', prompt = '' } = {}) {
|
||||
for (const rel of SEED_FILES) {
|
||||
copyIfMissing(path.join(TEMPLATE_DIR, rel), path.join(dest, rel));
|
||||
}
|
||||
replaceOnce(path.join(dest, 'AGENTS.md'), OLD_AGENTS_BROWSER, NEW_AGENTS_BROWSER);
|
||||
replaceOnce(path.join(dest, 'TOOLS.md'), OLD_TOOLS_BROWSER, NEW_TOOLS_BROWSER);
|
||||
applyAssistantName(dest, name);
|
||||
applyAssistantPrompt(dest, prompt);
|
||||
return dest;
|
||||
|
||||
Reference in New Issue
Block a user