agent-memory / index.html
edbeeching's picture
edbeeching HF Staff
Simplify onboarding page with copy-bootstrap button
55b12b6 verified
Raw History Blame Contribute Delete
3.55 kB
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>Agent Memory</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<main>
<h1>Agent Memory</h1>
<p class="description">Shared memory and reusable skills for your agents, wherever you work. Your notes and skills stay in your private Hugging Face bucket.</p>
<button id="copy-bootstrap" type="button" disabled>
<svg aria-hidden="true" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8"><rect x="8" y="8" width="12" height="13" rx="2"/><path d="M16 8V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2h3"/></svg>
<span id="copy-label">Loading instructions…</span>
</button>
<p class="hint">Paste into Codex or Claude Code to get started.</p>
<p id="copy-status" role="status" aria-live="polite"></p>
<div id="manual-copy" hidden>
<label for="bootstrap-text">Select and copy these instructions:</label>
<textarea id="bootstrap-text" readonly spellcheck="false"></textarea>
</div>
<p id="load-error" hidden>Couldn’t load the instructions. Reload this page or <a href="bootstrap.md">open them directly</a>.</p>
<noscript><p><a href="bootstrap.md">Open the bootstrap instructions</a> to copy them.</p></noscript>
</main>
<script>
const button = document.getElementById('copy-bootstrap');
const label = document.getElementById('copy-label');
const status = document.getElementById('copy-status');
const manual = document.getElementById('manual-copy');
const instructions = document.getElementById('bootstrap-text');
let bootstrap = '';
let resetLabel;
// Load ahead of the click so clipboard access keeps the user's activation.
fetch('bootstrap.md')
.then(response => {
if (!response.ok) throw new Error('Instructions unavailable');
return response.text();
})
.then(text => {
if (!text.startsWith('# Install portable agent memory')) throw new Error('Unexpected response');
bootstrap = 'Set up portable agent memory using the instructions below.\n'
+ 'Source Space: https://huggingface.co/spaces/edbeeching/agent-memory\n'
+ 'Release descriptor: https://huggingface.co/spaces/edbeeching/agent-memory/resolve/main/release.json\n\n'
+ text;
instructions.value = bootstrap;
label.textContent = 'Copy bootstrap instructions';
button.disabled = false;
})
.catch(() => {
label.textContent = 'Instructions unavailable';
document.getElementById('load-error').hidden = false;
});
button.addEventListener('click', async () => {
clearTimeout(resetLabel);
let copied = false;
try {
await navigator.clipboard.writeText(bootstrap);
copied = true;
} catch {
// Embedded browsers may deny Clipboard API access. Keep manual copy usable.
manual.hidden = false;
instructions.focus();
instructions.select();
try { copied = document.execCommand('copy'); } catch { /* Leave text selected. */ }
}
if (copied) {
manual.hidden = true;
button.focus();
label.textContent = 'Copied!';
status.textContent = 'Ready to paste into your agent.';
resetLabel = setTimeout(() => { label.textContent = 'Copy bootstrap instructions'; }, 3000);
} else {
label.textContent = 'Copy bootstrap instructions';
status.textContent = 'Automatic copy is unavailable. Copy the selected text below.';
}
});
</script>
</body>
</html>