Mike0021 commited on
Commit
381b90d
·
verified ·
1 Parent(s): e53923d

Add live J1 agent verification fixture

Browse files
Files changed (6) hide show
  1. README.md +10 -6
  2. app.mjs +3 -0
  3. index.html +11 -12
  4. math.mjs +3 -0
  5. math.test.mjs +7 -0
  6. server.mjs +23 -0
README.md CHANGED
@@ -1,10 +1,14 @@
1
  ---
2
- title: Chat Ui Agent J1 Fixture
3
- emoji: 🏆
4
- colorFrom: yellow
5
- colorTo: blue
6
  sdk: static
7
- pinned: false
 
8
  ---
9
 
10
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
1
  ---
2
+ title: Agent J1 Fixture
3
+ emoji: 🧪
4
+ colorFrom: blue
5
+ colorTo: indigo
6
  sdk: static
7
+ app_file: index.html
8
+ short_description: Live coding-agent fix and preview fixture
9
  ---
10
 
11
+ # Agent J1 fixture
12
+
13
+ This intentionally tiny Space is used to verify the Chat UI Agent flow against a real HF repo.
14
+ `add()` contains a regression which the agent is expected to diagnose, test, fix, preview, and push.
app.mjs ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ import { add } from "./math.mjs";
2
+
3
+ document.querySelector("#answer").textContent = String(add(2, 2));
index.html CHANGED
@@ -1,19 +1,18 @@
1
  <!doctype html>
2
- <html>
3
  <head>
4
  <meta charset="utf-8" />
5
- <meta name="viewport" content="width=device-width" />
6
- <title>My static Space</title>
7
- <link rel="stylesheet" href="style.css" />
 
 
 
8
  </head>
9
  <body>
10
- <div class="card">
11
- <h1>Welcome to your static Space!</h1>
12
- <p>You can modify this app directly by editing <i>index.html</i> in the Files and versions tab.</p>
13
- <p>
14
- Also don't forget to check the
15
- <a href="https://huggingface.co/docs/hub/spaces" target="_blank">Spaces documentation</a>.
16
- </p>
17
- </div>
18
  </body>
19
  </html>
 
1
  <!doctype html>
2
+ <html lang="en">
3
  <head>
4
  <meta charset="utf-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
6
+ <title>Agent arithmetic fixture</title>
7
+ <style>
8
+ body { font-family: system-ui, sans-serif; max-width: 42rem; margin: 5rem auto; padding: 0 1rem; }
9
+ output { display: block; font-size: 3rem; font-weight: 700; color: #2563eb; }
10
+ </style>
11
  </head>
12
  <body>
13
+ <h1>Arithmetic health check</h1>
14
+ <p>Two plus two should be four.</p>
15
+ <output id="answer" aria-live="polite">Checking…</output>
16
+ <script type="module" src="./app.mjs"></script>
 
 
 
 
17
  </body>
18
  </html>
math.mjs ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ export function add(left, right) {
2
+ return left - right;
3
+ }
math.test.mjs ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ import assert from "node:assert/strict";
2
+ import test from "node:test";
3
+ import { add } from "./math.mjs";
4
+
5
+ test("add combines positive values", () => {
6
+ assert.equal(add(2, 2), 4);
7
+ });
server.mjs ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { createReadStream } from "node:fs";
2
+ import { stat } from "node:fs/promises";
3
+ import { createServer } from "node:http";
4
+ import { extname, join, normalize } from "node:path";
5
+
6
+ const port = Number(process.env.PORT || process.argv[2] || 8000);
7
+ const root = process.cwd();
8
+ const types = { ".html": "text/html", ".mjs": "text/javascript", ".md": "text/markdown" };
9
+
10
+ createServer(async (request, response) => {
11
+ const pathname = new URL(request.url || "/", "http://fixture.local").pathname;
12
+ const relative = pathname === "/" ? "index.html" : normalize(pathname).replace(/^[/\\]+/, "");
13
+ const target = join(root, relative);
14
+ if (!target.startsWith(root)) return response.writeHead(403).end("Forbidden");
15
+ try {
16
+ const info = await stat(target);
17
+ if (!info.isFile()) throw new Error("not a file");
18
+ response.writeHead(200, { "Content-Type": types[extname(target)] || "application/octet-stream" });
19
+ createReadStream(target).pipe(response);
20
+ } catch {
21
+ response.writeHead(404).end("Not found");
22
+ }
23
+ }).listen(port, "0.0.0.0", () => console.log(`fixture ready on ${port}`));