File size: 3,546 Bytes
1edbc82
b279669
55b12b6
b279669
 
 
 
55b12b6
 
b279669
55b12b6
 
 
 
 
 
 
 
 
 
 
b279669
55b12b6
 
b279669
55b12b6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1edbc82
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
<!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>