@hexdecimal16/nexo 0.4.7 → 0.4.8

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.
Files changed (45) hide show
  1. package/cli/src/areas.js +49 -0
  2. package/cli/src/common.js +1 -1
  3. package/cli/src/main.js +3 -0
  4. package/cli/src/optimize.js +2 -5
  5. package/core/src/config/schema.js +1 -0
  6. package/core/src/engine/charged-completion.js +9 -4
  7. package/core/src/engine/errors.js +29 -2
  8. package/core/src/engine/prompts.js +1 -1
  9. package/core/src/engine/run.js +9 -4
  10. package/core/src/index.js +1 -0
  11. package/core/src/learn/areas.js +179 -0
  12. package/core/src/learn/job.js +13 -0
  13. package/core/src/learn/wiki.js +15 -10
  14. package/core/src/optimize/climb.js +0 -2
  15. package/core/src/optimize/optimize.js +1 -4
  16. package/optimize/src/engine.js +1 -22
  17. package/optimize/src/index.js +0 -1
  18. package/optimize/src/report.js +0 -2
  19. package/package.json +1 -1
  20. package/skills/bundled/wiki/SKILL.md +21 -11
  21. package/store/src/eval-cases.js +12 -6
  22. package/tools/src/index.js +1 -0
  23. package/tools/src/wiki-page.js +78 -0
  24. package/tui/src/questions.js +31 -0
  25. package/web/public/area.html +23 -0
  26. package/web/public/cost.html +1 -1
  27. package/web/public/home.html +23 -0
  28. package/web/public/index.html +1 -1
  29. package/web/public/judge.html +1 -1
  30. package/web/public/learning.html +1 -1
  31. package/web/public/lib/api-types.ts +0 -2
  32. package/web/public/lib/optim-view.ts +1 -1
  33. package/web/public/lib/wikis-view.ts +3 -1
  34. package/web/public/optim.html +1 -1
  35. package/web/public/pages/area.ts +49 -0
  36. package/web/public/pages/home.ts +60 -0
  37. package/web/public/pages/wikis.ts +43 -6
  38. package/web/public/run.html +1 -1
  39. package/web/public/sessions.html +1 -1
  40. package/web/public/style.css +31 -0
  41. package/web/public/wikis.html +1 -1
  42. package/web/src/api.js +11 -6
  43. package/web/src/home-api.js +99 -0
  44. package/web/src/server.js +6 -0
  45. package/optimize/src/merge.js +0 -73
@@ -1,12 +1,9 @@
1
- import { findMerge } from "./merge.js";
2
1
  import { bestCandidate, meanOf, paretoMembers, selectCandidate } from "./pareto.js";
3
2
  import { NOVELTY_MAX_JACCARD, NOVELTY_MAX_SIMILARITY, textCosine, wordJaccard } from "./novelty.js";
4
3
  import { checkPrediction, emptyScratchpad, SCRATCHPAD_ENTRIES, scratchpadEntry } from "./proposer.js";
5
4
  import { sampleWithoutReplacement } from "./rng.js";
6
5
  /** Feedback cases per minibatch (spec §8.2.2.3). */
7
6
  export const MINIBATCH_SIZE = 3;
8
- /** Most system-aware merges per optimization (spec §8.2.2.6). */
9
- export const MAX_MERGES = 5;
10
7
  /** Thrown by an adapter or a callback when the optimization's budget cannot pay for the next rollout or call. */
11
8
  export class BudgetStop extends Error {
12
9
  reason;
@@ -40,12 +37,10 @@ export async function runGepa(options) {
40
37
  const refs = new Map([[options.seed.id, options.seed]]);
41
38
  const nodes = new Map([[options.seed.id, { id: options.seed.id, parentIds: [] }]]);
42
39
  const texts = new Map([[options.seed.id, options.seed.texts]]);
43
- const tried = new Set();
44
40
  const memberIds = () => new Set(paretoMembers(table, caseIds).map((m) => m.id));
45
41
  const emit = (event) => callbacks.onEvent?.(event);
46
42
  let iterations = 0;
47
43
  let stale = 0;
48
- let merges = 0;
49
44
  let componentIndex = 0;
50
45
  const scratchpad = emptyScratchpad();
51
46
  if (options.scratchpad) {
@@ -160,22 +155,6 @@ export async function runGepa(options) {
160
155
  stale = newMember ? 0 : stale + 1;
161
156
  const mean = meanOf(perCase, caseIds);
162
157
  emit({ type: "pareto", candidateId: child.id, meanQuality: mean.quality, meanCostUsd: mean.costUsd, newMember });
163
- if (!options.merge || merges >= MAX_MERGES)
164
- continue;
165
- const plan = findMerge([...after], nodes, texts, tried);
166
- if (!plan)
167
- continue;
168
- tried.add(`${plan.a}|${plan.b}`);
169
- const merged = callbacks.createCandidate({ parentIds: [plan.a, plan.b], texts: plan.texts, iteration: iterations, origin: "merge", component: null });
170
- remember(merged, [plan.a, plan.b]);
171
- merges++;
172
- const mergedCases = await evaluatePareto(merged);
173
- table.set(merged.id, mergedCases);
174
- const kept = memberIds().has(merged.id);
175
- if (!kept)
176
- table.delete(merged.id);
177
- callbacks.recordPareto(merged.id, mergedCases, kept);
178
- emit({ type: "merge", candidateId: merged.id, parents: [plan.a, plan.b], accepted: kept });
179
158
  }
180
159
  }
181
160
  catch (error) {
@@ -186,7 +165,7 @@ export async function runGepa(options) {
186
165
  else
187
166
  throw error;
188
167
  }
189
- return { table, bestId: bestCandidate(table, caseIds), stopReason: stopReason ?? "patience", iterations, merges, scratchpad };
168
+ return { table, bestId: bestCandidate(table, caseIds), stopReason: stopReason ?? "patience", iterations, scratchpad };
190
169
  }
191
170
  /** Children per candidate, counted from the lineage (rejected children count too). */
192
171
  function offspringCounts(nodes) {
@@ -1,5 +1,4 @@
1
1
  export * from "./engine.js";
2
- export * from "./merge.js";
3
2
  export * from "./novelty.js";
4
3
  export * from "./pareto.js";
5
4
  export * from "./proposer.js";
@@ -100,8 +100,6 @@ export function buildReport(input) {
100
100
  spentUsd: input.spentUsd,
101
101
  rollouts: input.rollouts,
102
102
  iterations: input.iterations,
103
- merges: input.merges,
104
- mergeNote: input.mergeNote,
105
103
  createdAt: input.createdAt,
106
104
  };
107
105
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hexdecimal16/nexo",
3
- "version": "0.4.7",
3
+ "version": "0.4.8",
4
4
  "description": "nexo agent engine",
5
5
  "license": "PolyForm-Noncommercial-1.0.0",
6
6
  "repository": {
@@ -1,13 +1,13 @@
1
1
  ---
2
2
  name: wiki
3
- description: Create and maintain a persistent markdown wiki on one topic in the user's wikis directory (Karpathy's LLM-wiki pattern). Use it to start a wiki, ingest a source (article, paper, notes, research results) into it, answer a question from it, or health-check it. Load it before reading or writing any wiki.
3
+ description: Create and maintain a persistent wiki of HTML pages on one topic in the user's wikis directory (Karpathy's LLM-wiki pattern). Use it to start a wiki, ingest a source (article, paper, notes, research results) into it, answer a question from it, or health-check it. Load it before reading or writing any wiki.
4
4
  metadata:
5
5
  nexo-parallel-safe: "false"
6
6
  ---
7
7
 
8
8
  # Wiki
9
9
 
10
- A wiki is a folder of interlinked markdown pages that you build and keep current for the user. Knowledge is compiled once, when a source arrives, instead of being rediscovered on every question. You write and maintain the pages. The user brings sources and asks questions.
10
+ A wiki is a folder of interlinked HTML pages that you build and keep current for the user. Knowledge is compiled once, when a source arrives, instead of being rediscovered on every question. You write and maintain the pages. The user brings sources and asks questions.
11
11
 
12
12
  The wikis directory is named in your system prompt. Each wiki is one folder in it, named for its topic in lowercase with hyphens: `<wikis>/<name>/`. Reach it with absolute paths in `read`, `write`, `edit` and `bash`. Never put wiki pages in the run workspace and never touch other nexo files.
13
13
 
@@ -20,21 +20,31 @@ The wiki holds knowledge about a subject. Lessons about how you should behave ne
20
20
  ```
21
21
  <name>/
22
22
  AGENTS.md this wiki's schema: purpose, conventions, extra folders
23
- index.md catalog: one line per page (link, summary, date), grouped by folder
23
+ index.html catalog: one line per page (link, summary, date), grouped by folder
24
24
  log.md append-only record of operations
25
25
  raw/ immutable sources; read them, never edit them (raw/assets/ for images)
26
26
  sources/ one summary page per raw source
27
27
  entities/ people, organisations, tools, places
28
28
  concepts/ ideas, methods, themes
29
29
  analyses/ answers and comparisons worth keeping
30
- overview.md the evolving top-level synthesis
30
+ overview.html the evolving top-level synthesis
31
31
  ```
32
32
 
33
+ ## Areas
34
+
35
+ `<wikis>/areas.json` lists the user's life areas (for example work, builds, research). Each area has a scope note, aliases and the wikis it holds. The user approves every area.
36
+
37
+ - Before creating a wiki, read `areas.json` and pick the area whose scope fits. Put the new wiki's name in that area's `wikis` list.
38
+ - Never add, rename, merge or approve an area. If nothing fits, say so in your answer; the post-run step queues it and proposes a new area once three tasks need it.
39
+ - Do not write `feed.jsonl` or `decisions.jsonl`; the post-run step writes them after the run is scored.
40
+
33
41
  ## Page rules
34
42
 
35
- - Each page starts with a frontmatter block (between two `---` lines) holding `summary:` (one specific line), `updated:` (YYYY-MM-DD) and `sources:` (raw files or URLs).
36
- - Link pages as `[[folder/slug]]`. One topic per page.
37
- - Search before you write (`grep -ril`, then read `index.md`) and update the existing page instead of adding a near-duplicate.
43
+ - Each page is one self-contained HTML file: inline CSS, no external files, no script elements unless the user asks for interactivity. The head holds <meta name="summary" content="...">, <meta name="updated" content="YYYY-MM-DD"> and <meta name="sources" content="...">.
44
+ - Write for a human who reads the page once: open with a <div class="tldr"> that answers in two or three sentences, then h2 sections, tables for comparisons, <details> for side detail, and inline SVG for flows.
45
+ - Pages written earlier as .md stay valid and are still read. When you edit one, convert it to .html and delete the .md in the same commit.
46
+ - Link pages with relative hrefs such as <a href="../concepts/slug.html">. One topic per page.
47
+ - Search before you write (`grep -ril`, then read `index.html`) and update the existing page instead of adding a near-duplicate.
38
48
  - When a fact changes, replace it and note what changed. Do not leave two claims that contradict each other.
39
49
  - Date facts and say where they came from.
40
50
  - Split a page that grows past about 150 lines.
@@ -42,21 +52,21 @@ The wiki holds knowledge about a subject. Lessons about how you should behave ne
42
52
  ## Create a wiki
43
53
 
44
54
  1. Create the wiki directory and initial files (`write` creates parent folders automatically, or use `mkdir -p` and `git -C <wiki> init`).
45
- 2. Write `AGENTS.md` (topic, one-line purpose, the layout and page rules above, any extra folders), `index.md` (a title and an empty section per folder), `log.md` and `overview.md`.
55
+ 2. Write `AGENTS.md` (topic, one-line purpose, the layout and page rules above, any extra folders), `index.html` (a title and an empty section per folder), `log.md` and `overview.html`.
46
56
  3. Log and commit (below).
47
57
 
48
58
  ## Ingest a source
49
59
 
50
60
  1. Put the source in `raw/` (copy a file, or save the fetched text). Do not edit it afterwards.
51
61
  2. Read it. Tell the user the key takeaways in a few lines and what you plan to emphasise.
52
- 3. Write `sources/<slug>.md`.
62
+ 3. Write `sources/<slug>.html`.
53
63
  4. Update the entity and concept pages it touches, creating the ones that are missing. A single source often touches several pages. Flag where it contradicts an existing claim.
54
- 5. Update `overview.md` if the synthesis changed, and add or refresh the pages' lines in `index.md`.
64
+ 5. Update `overview.html` if the synthesis changed, and add or refresh the pages' lines in `index.html`.
55
65
  6. Log and commit.
56
66
 
57
67
  ## Answer a question
58
68
 
59
- Read `index.md` first, open the pages it points to, and answer with citations to those pages. If the answer is worth keeping (a comparison, an analysis, a connection), offer to file it as `analyses/<slug>.md`. Once the user agrees, write it, update the index, then log and commit. If the wiki cannot answer, say what is missing instead of guessing.
69
+ Read `index.html` first, open the pages it points to, and answer with citations to those pages. If the answer is worth keeping (a comparison, an analysis, a connection), offer to file it as `analyses/<slug>.html`. Once the user agrees, write it, update the index, then log and commit. If the wiki cannot answer, say what is missing instead of guessing.
60
70
 
61
71
  ## Lint
62
72
 
@@ -39,6 +39,8 @@ export function normalizeCaseInput(input) {
39
39
  export function caseSplit(input) {
40
40
  return evalSplitFor(normalizeCaseInput(input));
41
41
  }
42
+ /** Final judge score below which a run becomes an eval case without human feedback. */
43
+ export const LOW_JUDGE_SCORE = 0.6;
42
44
  /** Root runs that can be eval cases of `target`: finished, not optimization runs, not a session turn after the first. */
43
45
  export function targetRunFilter(target) {
44
46
  const base = "r.parent_run_id IS NULL AND r.optim_run_id IS NULL AND r.status != 'running' AND (r.session_id IS NULL OR r.turn_index = 1)";
@@ -63,9 +65,13 @@ function clip(text) {
63
65
  */
64
66
  export function syncRunEvalCases(db, target, nowIso) {
65
67
  const filter = targetRunFilter(target);
68
+ // A run is reviewed when a human gave feedback. For agent targets, a run whose final judge round scored below LOW_JUDGE_SCORE also counts.
69
+ const lowScore = target.kind === "judge_rubric"
70
+ ? ""
71
+ : " OR EXISTS (SELECT 1 FROM scores s WHERE s.run_id = r.id AND s.scorer_type = 'llm_judge' AND s.status = 'ok' AND s.value < ? AND s.round = (SELECT MAX(s2.round) FROM scores s2 WHERE s2.run_id = r.id))";
66
72
  const ids = db
67
- .prepare(`SELECT r.id FROM runs r WHERE ${filter.sql} AND EXISTS (SELECT 1 FROM feedback f WHERE f.run_id = r.id) ORDER BY r.started_at, r.id`)
68
- .all(...filter.args)
73
+ .prepare(`SELECT r.id FROM runs r WHERE ${filter.sql} AND (EXISTS (SELECT 1 FROM feedback f WHERE f.run_id = r.id)${lowScore}) ORDER BY r.started_at, r.id`)
74
+ .all(...filter.args, ...(lowScore ? [LOW_JUDGE_SCORE] : []))
69
75
  .map((row) => String(row.id));
70
76
  let added = 0;
71
77
  let updated = 0;
@@ -73,11 +79,11 @@ export function syncRunEvalCases(db, target, nowIso) {
73
79
  for (const id of ids) {
74
80
  const run = getRun(db, id);
75
81
  const feedback = latestFeedback(db, id);
76
- if (!run || !feedback)
82
+ if (!run || (!feedback && target.kind === "judge_rubric"))
77
83
  continue;
78
84
  let expected;
79
85
  if (target.kind === "judge_rubric") {
80
- expected = feedback.verdict;
86
+ expected = feedback?.verdict ?? null;
81
87
  }
82
88
  else {
83
89
  let output = "";
@@ -87,9 +93,9 @@ export function syncRunEvalCases(db, target, nowIso) {
87
93
  catch {
88
94
  output = "";
89
95
  }
90
- expected = feedback.verdict === "done" && output.trim() ? clip(output) : null;
96
+ expected = feedback?.verdict === "done" && output.trim() ? clip(output) : null;
91
97
  }
92
- const reference = feedback.comment.trim() ? clip(feedback.comment) : null;
98
+ const reference = feedback?.comment.trim() ? clip(feedback.comment) : null;
93
99
  const rubric = target.kind === "judge_rubric";
94
100
  const existing = db.prepare("SELECT id, expected, golden_source FROM eval_cases WHERE target = ? AND source_run_id = ?").get(target.key, id);
95
101
  if (existing) {
@@ -8,3 +8,4 @@ export * from "./policy.js";
8
8
  export * from "./read-only.js";
9
9
  export * from "./session-rules.js";
10
10
  export * from "./web-search.js";
11
+ export * from "./wiki-page.js";
@@ -0,0 +1,78 @@
1
+ import { existsSync } from "node:fs";
2
+ import { join } from "node:path";
3
+ /** Wiki pages are HTML (preferred) or markdown (legacy, still read during the migration). */
4
+ const WIKI_PAGE_EXT = /\.(md|html)$/;
5
+ export function isWikiPageFile(name) {
6
+ return WIKI_PAGE_EXT.test(name);
7
+ }
8
+ /** The page path without its .md or .html extension. */
9
+ export function wikiPageSlug(relPath) {
10
+ return relPath.replace(WIKI_PAGE_EXT, "");
11
+ }
12
+ /** Maps an extensionless page path (concepts/raft) to the .html file when it exists, else the .md one. Paths with an extension are returned unchanged. */
13
+ export function resolveWikiPagePath(wikiDir, relPath) {
14
+ if (WIKI_PAGE_EXT.test(relPath))
15
+ return relPath;
16
+ const html = `${relPath}.html`;
17
+ return existsSync(join(wikiDir, html)) ? html : `${relPath}.md`;
18
+ }
19
+ const ESCAPES = {
20
+ "\u0026": "\u0026amp;",
21
+ "<": "\u0026lt;",
22
+ ">": "\u0026gt;",
23
+ '"': "\u0026quot;",
24
+ "'": "\u0026#39;",
25
+ };
26
+ export function escapeHtml(text) {
27
+ return text.replace(/[\u0026<>"']/g, (c) => ESCAPES[c] ?? c);
28
+ }
29
+ const UNESCAPES = Object.fromEntries(Object.entries(ESCAPES).map(([k, v]) => [v, k]));
30
+ function unescapeHtml(text) {
31
+ return text.replace(/\u0026(amp|lt|gt|quot|#39);/g, (m) => UNESCAPES[m] ?? m);
32
+ }
33
+ /** Reads summary, updated and sources from meta tags in the head of an HTML wiki page. Returns an empty object for non-HTML content. */
34
+ export function parseWikiMeta(content) {
35
+ const head = content.slice(0, 4096);
36
+ if (!/^\s*<(!doctype|html)/i.test(head))
37
+ return {};
38
+ const meta = {};
39
+ for (const m of head.matchAll(/<meta\s+name=["']([a-z]+)["']\s+content=["']([^"']*)["']/gi)) {
40
+ if (m[1] && m[2] !== undefined)
41
+ meta[m[1].toLowerCase()] = unescapeHtml(m[2]);
42
+ }
43
+ return { summary: meta.summary || undefined, updated: meta.updated || undefined, sources: meta.sources || undefined };
44
+ }
45
+ const PAGE_STYLE = ":root{--bg:#fafaf7;--fg:#1c1c1a;--muted:#6b6b66;--line:#e2e1da;--accent:#1f5fbf;--card:#fff}" +
46
+ "body{margin:0;background:var(--bg);color:var(--fg);font:16px/1.6 system-ui,sans-serif}" +
47
+ "main{max-width:760px;margin:0 auto;padding:32px 20px 80px}h1{font-size:28px;line-height:1.25}" +
48
+ "h2{font-size:20px;margin-top:36px;border-top:1px solid var(--line);padding-top:20px}a{color:var(--accent)}" +
49
+ ".meta{color:var(--muted);font-size:14px}table{border-collapse:collapse;width:100%;background:var(--card)}" +
50
+ "th,td{border:1px solid var(--line);padding:8px 10px;text-align:left}code{background:#efeee8;padding:1px 5px;border-radius:3px}" +
51
+ "pre{background:#efeee8;padding:12px;border-radius:6px;overflow:auto}svg{max-width:100%;height:auto}@media print{body{background:#fff}}";
52
+ /** Wraps a body fragment into a complete, self-contained wiki page with summary, updated and sources in meta tags. */
53
+ export function wrapWikiHtml(input) {
54
+ const body = input.body.replace(/<script[\s\S]*?<\/script>/gi, "").trim();
55
+ const summary = escapeHtml(input.summary.replace(/\s+/g, " ").trim());
56
+ return [
57
+ "<!doctype html>",
58
+ '<html lang="en">',
59
+ "<head>",
60
+ '<meta charset="utf-8">',
61
+ '<meta name="viewport" content="width=device-width, initial-scale=1">',
62
+ `<meta name="summary" content="${summary}">`,
63
+ `<meta name="updated" content="${escapeHtml(input.updated)}">`,
64
+ `<meta name="sources" content="${escapeHtml(input.sources.join("; "))}">`,
65
+ `<title>${escapeHtml(input.title)}</title>`,
66
+ `<style>${PAGE_STYLE}</style>`,
67
+ "</head>",
68
+ "<body>",
69
+ "<main>",
70
+ `<h1>${escapeHtml(input.title)}</h1>`,
71
+ `<p class="meta">Updated ${escapeHtml(input.updated)}</p>`,
72
+ body,
73
+ "</main>",
74
+ "</body>",
75
+ "</html>",
76
+ "",
77
+ ].join("\n");
78
+ }
@@ -5,6 +5,8 @@ const UP = "\u001b[A";
5
5
  const DOWN = "\u001b[B";
6
6
  const ESC = "\u001b";
7
7
  const OTHER_LABEL = "Type your own answer";
8
+ const PASTE_START = "\u001b[200~";
9
+ const PASTE_END = "\u001b[201~";
8
10
  /**
9
11
  * An `ask_user` box: one question at a time, ↑↓ to move, space to toggle (multi-select), enter to answer, and a
10
12
  * "Type your own answer" row that opens a one-line text field. Esc declines the whole request.
@@ -15,6 +17,8 @@ export class QuestionBox extends Container {
15
17
  picked = new Set();
16
18
  typing = false;
17
19
  draft = "";
20
+ inPaste = false;
21
+ pasteBuffer = "";
18
22
  answers = [];
19
23
  request;
20
24
  onDone;
@@ -34,6 +38,10 @@ export class QuestionBox extends Container {
34
38
  const q = this.question;
35
39
  const other = q.options.length;
36
40
  if (this.typing) {
41
+ if (this.inPaste || data.includes(PASTE_START)) {
42
+ this.paste(data);
43
+ return;
44
+ }
37
45
  if (data === "\r" || data === "\n") {
38
46
  if (this.draft.trim())
39
47
  this.commit([], this.draft.trim());
@@ -75,6 +83,27 @@ export class QuestionBox extends Container {
75
83
  else if (data === ESC)
76
84
  this.onDone(null);
77
85
  }
86
+ /** Bracketed paste (the terminal wraps pasted text in ESC[200~ … ESC[201~), possibly split across chunks. */
87
+ paste(data) {
88
+ const start = data.indexOf(PASTE_START);
89
+ if (start !== -1) {
90
+ this.inPaste = true;
91
+ this.pasteBuffer = "";
92
+ data = data.slice(start + PASTE_START.length);
93
+ }
94
+ this.pasteBuffer += data;
95
+ const end = this.pasteBuffer.indexOf(PASTE_END);
96
+ if (end === -1)
97
+ return;
98
+ const text = this.pasteBuffer.slice(0, end);
99
+ const rest = this.pasteBuffer.slice(end + PASTE_END.length);
100
+ this.inPaste = false;
101
+ this.pasteBuffer = "";
102
+ // One-line field: newlines and tabs become spaces, other control characters are dropped.
103
+ this.draft += text.replace(/[\r\n\t]+/g, " ").replace(/[\u0000-\u001f\u007f]/g, "");
104
+ if (rest)
105
+ this.handleInput(rest);
106
+ }
78
107
  commit(selected, text) {
79
108
  this.answers.push({ question: this.question.question, selected, ...(text ? { text } : {}) });
80
109
  this.index++;
@@ -82,6 +111,8 @@ export class QuestionBox extends Container {
82
111
  this.picked = new Set();
83
112
  this.typing = false;
84
113
  this.draft = "";
114
+ this.inPaste = false;
115
+ this.pasteBuffer = "";
85
116
  if (this.index >= this.request.questions.length)
86
117
  this.onDone({ answers: [...this.answers] });
87
118
  }
@@ -0,0 +1,23 @@
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
+ <meta name="nexo-token" content="{{NEXO_TOKEN}}">
7
+ <title>nexo · area</title>
8
+ <link rel="stylesheet" href="/style.css">
9
+ <script type="module" src="/lib/theme.ts"></script>
10
+ <script type="module" src="/pages/companion.ts"></script>
11
+ <script type="module" src="/pages/area.ts"></script>
12
+ </head>
13
+ <body>
14
+ <a class="skip" href="#main">Skip to content</a>
15
+ <nav class="top" aria-label="Primary"><a href="/" class="brand">nexo</a><a href="/home.html" aria-current="page">Home</a><a href="/">Runs</a><a href="/sessions.html">Sessions</a><a href="/cost.html">Cost</a><a href="/learning.html">Learning</a><a href="/judge.html">Judge</a><a href="/optim.html">Optimization</a><a href="/wikis.html">Wikis</a></nav>
16
+ <main id="main" tabindex="-1">
17
+ <p class="muted"><a href="/home.html">&larr; Home</a></p>
18
+ <h1 id="area-title">Area</h1>
19
+ <div id="error"></div>
20
+ <div id="area"></div>
21
+ </main>
22
+ </body>
23
+ </html>
@@ -12,7 +12,7 @@
12
12
  </head>
13
13
  <body>
14
14
  <a class="skip" href="#main">Skip to content</a>
15
- <nav class="top" aria-label="Primary"><a href="/" class="brand">nexo</a><a href="/">Runs</a><a href="/sessions.html">Sessions</a><a href="/cost.html">Cost</a><a href="/learning.html">Learning</a><a href="/judge.html">Judge</a><a href="/optim.html">Optimization</a><a href="/wikis.html">Wikis</a></nav>
15
+ <nav class="top" aria-label="Primary"><a href="/" class="brand">nexo</a><a href="/home.html">Home</a><a href="/">Runs</a><a href="/sessions.html">Sessions</a><a href="/cost.html">Cost</a><a href="/learning.html">Learning</a><a href="/judge.html">Judge</a><a href="/optim.html">Optimization</a><a href="/wikis.html">Wikis</a></nav>
16
16
  <main id="main" tabindex="-1">
17
17
  <h1>Cost</h1>
18
18
  <form id="cost-form" class="filters">
@@ -0,0 +1,23 @@
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
+ <meta name="nexo-token" content="{{NEXO_TOKEN}}">
7
+ <title>nexo · home</title>
8
+ <link rel="stylesheet" href="/style.css">
9
+ <script type="module" src="/lib/theme.ts"></script>
10
+ <script type="module" src="/pages/companion.ts"></script>
11
+ <script type="module" src="/pages/home.ts"></script>
12
+ </head>
13
+ <body>
14
+ <a class="skip" href="#main">Skip to content</a>
15
+ <nav class="top" aria-label="Primary"><a href="/" class="brand">nexo</a><a href="/home.html" aria-current="page">Home</a><a href="/">Runs</a><a href="/sessions.html">Sessions</a><a href="/cost.html">Cost</a><a href="/learning.html">Learning</a><a href="/judge.html">Judge</a><a href="/optim.html">Optimization</a><a href="/wikis.html">Wikis</a></nav>
16
+ <main id="main" tabindex="-1">
17
+ <h1>Home</h1>
18
+ <div id="error"></div>
19
+ <input id="home-search" class="home-search" type="search" placeholder="Search areas, wikis, recent activity and decisions" aria-label="Search">
20
+ <div id="home"></div>
21
+ </main>
22
+ </body>
23
+ </html>
@@ -12,7 +12,7 @@
12
12
  </head>
13
13
  <body>
14
14
  <a class="skip" href="#main">Skip to content</a>
15
- <nav class="top" aria-label="Primary"><a href="/" class="brand">nexo</a><a href="/">Runs</a><a href="/sessions.html">Sessions</a><a href="/cost.html">Cost</a><a href="/learning.html">Learning</a><a href="/judge.html">Judge</a><a href="/optim.html">Optimization</a><a href="/wikis.html">Wikis</a></nav>
15
+ <nav class="top" aria-label="Primary"><a href="/" class="brand">nexo</a><a href="/home.html">Home</a><a href="/">Runs</a><a href="/sessions.html">Sessions</a><a href="/cost.html">Cost</a><a href="/learning.html">Learning</a><a href="/judge.html">Judge</a><a href="/optim.html">Optimization</a><a href="/wikis.html">Wikis</a></nav>
16
16
  <main id="main" tabindex="-1">
17
17
  <h1>Runs</h1>
18
18
  <div id="session-filter"></div>
@@ -12,7 +12,7 @@
12
12
  </head>
13
13
  <body>
14
14
  <a class="skip" href="#main">Skip to content</a>
15
- <nav class="top" aria-label="Primary"><a href="/" class="brand">nexo</a><a href="/">Runs</a><a href="/sessions.html">Sessions</a><a href="/cost.html">Cost</a><a href="/learning.html">Learning</a><a href="/judge.html">Judge</a><a href="/optim.html">Optimization</a><a href="/wikis.html">Wikis</a></nav>
15
+ <nav class="top" aria-label="Primary"><a href="/" class="brand">nexo</a><a href="/home.html">Home</a><a href="/">Runs</a><a href="/sessions.html">Sessions</a><a href="/cost.html">Cost</a><a href="/learning.html">Learning</a><a href="/judge.html">Judge</a><a href="/optim.html">Optimization</a><a href="/wikis.html">Wikis</a></nav>
16
16
  <main id="main" tabindex="-1">
17
17
  <h1>Judge calibration</h1>
18
18
  <div id="error"></div>
@@ -12,7 +12,7 @@
12
12
  </head>
13
13
  <body>
14
14
  <a class="skip" href="#main">Skip to content</a>
15
- <nav class="top" aria-label="Primary"><a href="/" class="brand">nexo</a><a href="/">Runs</a><a href="/sessions.html">Sessions</a><a href="/cost.html">Cost</a><a href="/learning.html">Learning</a><a href="/judge.html">Judge</a><a href="/optim.html">Optimization</a><a href="/wikis.html">Wikis</a></nav>
15
+ <nav class="top" aria-label="Primary"><a href="/" class="brand">nexo</a><a href="/home.html">Home</a><a href="/">Runs</a><a href="/sessions.html">Sessions</a><a href="/cost.html">Cost</a><a href="/learning.html">Learning</a><a href="/judge.html">Judge</a><a href="/optim.html">Optimization</a><a href="/wikis.html">Wikis</a></nav>
16
16
  <main id="main" tabindex="-1">
17
17
  <h1>Learning</h1>
18
18
  <div id="error"></div>
@@ -554,8 +554,6 @@ export interface OptimReport {
554
554
  spentUsd: number;
555
555
  rollouts: number;
556
556
  iterations: number;
557
- merges: number;
558
- mergeNote: string | null;
559
557
  climb?: { caseId: string; guardIds: string[]; outcome: string; critique: string | null; comparisons: { label: string; winner: "A" | "B" | "tie" }[] };
560
558
  createdAt: string;
561
559
  }
@@ -46,7 +46,7 @@ ${h.wins} win${h.wins === 1 ? "" : "s"}, ${h.losses} loss${h.losses === 1 ? "" :
46
46
  ${report.improved ? "" : html`<span class="muted">No candidate beat the starting version.</span>`}</p>
47
47
  <table class="runs holdout"><thead><tr><th>Case</th><th>Before</th><th>After</th><th>Outcome</th></tr></thead>
48
48
  <tbody>${h.cases.map((c) => html`<tr><td>${truncate(c.input, 120)}</td><td>${scoreCell(c.before)}</td><td>${scoreCell(c.after)}</td><td><span class="badge outcome-${c.outcome}">${c.outcome}</span></td></tr>`)}</tbody></table>
49
- <p class="muted">Stopped by ${report.stopReason} after ${report.iterations} iteration${report.iterations === 1 ? "" : "s"} and ${report.rollouts} rollouts (${formatUsd(report.spentUsd)}); ${report.merges} merge${report.merges === 1 ? "" : "s"}${report.mergeNote ? ` (${report.mergeNote})` : ""}.</p>`;
49
+ <p class="muted">Stopped by ${report.stopReason} after ${report.iterations} iteration${report.iterations === 1 ? "" : "s"} and ${report.rollouts} rollouts (${formatUsd(report.spentUsd)}).</p>`;
50
50
  }
51
51
 
52
52
  /** The base → best text diff, one line per row. */
@@ -239,7 +239,9 @@ export function renderWikiTree(pages: readonly WikiPageItem[], activeWiki: strin
239
239
 
240
240
  /** Renders a full wiki page view with breadcrumbs, summary box, rendered content and metadata. */
241
241
  export function renderWikiPage(page: WikiPageResponse, activeWiki: string): SafeHtml {
242
- const renderedContent = renderMarkdown(page.content, activeWiki);
242
+ const renderedContent = page.path.endsWith(".html")
243
+ ? new SafeHtml(`<div class="wiki-html" id="wiki-html-body"></div>`)
244
+ : renderMarkdown(page.content, activeWiki);
243
245
  return html`<article class="wiki-page">
244
246
  <header class="wiki-page-header">
245
247
  <div class="wiki-crumbs mono">
@@ -12,7 +12,7 @@
12
12
  </head>
13
13
  <body>
14
14
  <a class="skip" href="#main">Skip to content</a>
15
- <nav class="top" aria-label="Primary"><a href="/" class="brand">nexo</a><a href="/">Runs</a><a href="/sessions.html">Sessions</a><a href="/cost.html">Cost</a><a href="/learning.html">Learning</a><a href="/judge.html">Judge</a><a href="/optim.html">Optimization</a><a href="/wikis.html">Wikis</a></nav>
15
+ <nav class="top" aria-label="Primary"><a href="/" class="brand">nexo</a><a href="/home.html">Home</a><a href="/">Runs</a><a href="/sessions.html">Sessions</a><a href="/cost.html">Cost</a><a href="/learning.html">Learning</a><a href="/judge.html">Judge</a><a href="/optim.html">Optimization</a><a href="/wikis.html">Wikis</a></nav>
16
16
  <main id="main" tabindex="-1">
17
17
  <h1>Optimization</h1>
18
18
  <div id="error"></div>
@@ -0,0 +1,49 @@
1
+ import { renderError } from "../lib/common-view.ts";
2
+ import { formatTime } from "../lib/format.ts";
3
+ import { html, type SafeHtml } from "../lib/html.ts";
4
+ import { asErrorBody, el, getJson } from "./api.ts";
5
+
6
+ interface HomeWiki { name: string; summary?: string; pageCount: number }
7
+ interface HomeArea { id: string; name: string; scope: string; wikis: HomeWiki[]; recent: number }
8
+ interface HomeFeedItem { at: string; text: string; areaId: string | null; wiki: string | null; sessionId: string | null; runId: string; verified: boolean }
9
+ interface HomeDecision { at: string; choice: string; reason: string; areaId: string | null; wiki: string | null; sessionId: string | null; runId: string }
10
+ interface HomeSession { id: string; title: string; cwd: string; updatedAt: string; areaId: string | null }
11
+ interface Home { areas: HomeArea[]; feed: HomeFeedItem[]; decisions: HomeDecision[]; sessions: HomeSession[] }
12
+
13
+ const box = el<HTMLDivElement>("#area");
14
+ const title = el<HTMLHeadingElement>("#area-title");
15
+ const errorBox = el<HTMLDivElement>("#error");
16
+
17
+ function list(items: SafeHtml[], empty: string): SafeHtml {
18
+ return items.length > 0 ? html`<ul class="home-list">${items}</ul>` : html`<p class="muted">${empty}</p>`;
19
+ }
20
+
21
+ function render(d: Home, id: string): void {
22
+ const a = d.areas.find((x) => x.id === id);
23
+ if (!a) {
24
+ title.textContent = "Area not found";
25
+ box.innerHTML = html`<p class="muted">No active area "${id}". <a href="/home.html">Back to Home</a>.</p>`.value;
26
+ return;
27
+ }
28
+ title.textContent = a.name;
29
+ document.title = `nexo · ${a.name}`;
30
+ const wikis = a.wikis.map((w) => html`<li><a href="/wikis.html#${encodeURIComponent(w.name)}/index">${w.name}</a> <span class="muted">${String(w.pageCount)} pages${w.summary ? ` · ${w.summary}` : ""}</span></li>`);
31
+ const feed = d.feed.filter((f) => f.areaId === a.id).slice(0, 30).map((f) => {
32
+ const link = f.sessionId ? html`<a href="/?session=${encodeURIComponent(f.sessionId)}">session</a>` : html`<a href="/run.html?id=${encodeURIComponent(f.runId)}">run</a>`;
33
+ return html`<li><span class="muted mono">${formatTime(f.at)}</span> ${f.text}${f.verified ? "" : html` <span class="home-tag">unverified</span>`}${f.wiki ? html` <span class="muted">· ${f.wiki}</span>` : ""} ${link}</li>`;
34
+ });
35
+ const decisions = d.decisions.filter((x) => x.areaId === a.id).map((x) => html`<li><span class="muted mono">${formatTime(x.at)}</span> <strong>${x.choice}</strong>${x.reason ? html` <span class="muted">because ${x.reason}</span>` : ""}</li>`);
36
+ const sessions = d.sessions.filter((s) => s.areaId === a.id).map((s) => html`<li><a href="/?session=${encodeURIComponent(s.id)}">${s.title || s.id}</a> <span class="muted">${s.cwd} · ${formatTime(s.updatedAt)}</span></li>`);
37
+ box.innerHTML = html`<p class="home-note">${a.scope}</p>
38
+ <section><h2>Wikis</h2>${list(wikis, "No wikis in this area yet.")}</section>
39
+ <section><h2>Recent</h2>${list(feed, "Nothing filed here yet. Finished tasks appear here after they are scored.")}</section>
40
+ <section><h2>Decisions</h2>${list(decisions, "No decisions recorded here yet.")}</section>
41
+ <section><h2>Sessions</h2>${list(sessions, "No linked sessions yet.")}</section>`.value;
42
+ }
43
+
44
+ const id = new URLSearchParams(location.search).get("id") ?? "";
45
+ getJson<Home>("/api/home")
46
+ .then((d) => render(d, id))
47
+ .catch((error) => {
48
+ errorBox.innerHTML = renderError(asErrorBody(error)).value;
49
+ });
@@ -0,0 +1,60 @@
1
+ import { renderError } from "../lib/common-view.ts";
2
+ import { formatTime } from "../lib/format.ts";
3
+ import { html, type SafeHtml } from "../lib/html.ts";
4
+ import { asErrorBody, el, getJson } from "./api.ts";
5
+
6
+ interface HomeWiki { name: string; summary?: string; pageCount: number }
7
+ interface HomeArea { id: string; name: string; scope: string; wikis: HomeWiki[]; recent: number }
8
+ interface HomeFeedItem { at: string; text: string; areaId: string | null; wiki: string | null; sessionId: string | null; runId: string; verified: boolean }
9
+ interface HomeDecision { at: string; choice: string; reason: string; areaId: string | null; wiki: string | null; sessionId: string | null; runId: string }
10
+ interface HomeSession { id: string; title: string; cwd: string; updatedAt: string; areaId: string | null }
11
+ interface Home { areas: HomeArea[]; proposed: { id: string; name: string }[]; unsorted: number; feed: HomeFeedItem[]; decisions: HomeDecision[]; sessions: HomeSession[] }
12
+
13
+ const box = el<HTMLDivElement>("#home");
14
+ const errorBox = el<HTMLDivElement>("#error");
15
+ const search = el<HTMLInputElement>("#home-search");
16
+ let data: Home | null = null;
17
+
18
+ const hit = (q: string, ...parts: (string | null | undefined)[]) => !q || parts.some((p) => (p ?? "").toLowerCase().includes(q));
19
+ const areaName = (id: string | null) => data?.areas.find((a) => a.id === id)?.name ?? "unsorted";
20
+
21
+ function feedItem(f: HomeFeedItem): SafeHtml {
22
+ const link = f.sessionId ? html`<a href="/?session=${encodeURIComponent(f.sessionId)}">session</a>` : html`<a href="/run.html?id=${encodeURIComponent(f.runId)}">run</a>`;
23
+ return html`<li><span class="muted mono">${formatTime(f.at)}</span> ${f.text}${f.verified ? "" : html` <span class="home-tag">unverified</span>`} <span class="muted">· ${areaName(f.areaId)}${f.wiki ? ` · ${f.wiki}` : ""}</span> ${link}</li>`;
24
+ }
25
+
26
+ function list(items: SafeHtml[], empty: string): SafeHtml {
27
+ return items.length > 0 ? html`<ul class="home-list">${items}</ul>` : html`<p class="muted">${empty}</p>`;
28
+ }
29
+
30
+ function areaCard(a: HomeArea): SafeHtml {
31
+ return html`<a class="home-area" href="/area.html?id=${encodeURIComponent(a.id)}"><strong>${a.name}</strong> <span class="muted">${String(a.recent)} this week · ${String(a.wikis.length)} wikis</span><span class="home-scope muted">${a.scope}</span></a>`;
32
+ }
33
+
34
+ function render(): void {
35
+ if (!data) return;
36
+ const d = data;
37
+ const q = search.value.trim().toLowerCase();
38
+ const feed = d.feed.filter((f) => hit(q, f.text, f.wiki, areaName(f.areaId)));
39
+ const decisions = d.decisions.filter((x) => hit(q, x.choice, x.reason, x.wiki, areaName(x.areaId)));
40
+ const areas = d.areas.filter((a) => hit(q, a.name, a.scope, ...a.wikis.map((w) => `${w.name} ${w.summary ?? ""}`)) || (q !== "" && feed.some((f) => f.areaId === a.id)));
41
+ const sessions = d.sessions.filter((s) => hit(q, s.title, s.cwd, areaName(s.areaId)));
42
+ const pending = d.proposed.length > 0 ? html`<p class="home-note">${String(d.proposed.length)} proposed area(s) waiting for approval: ${d.proposed.map((p) => p.name).join(", ")}. Run <code>nexo areas list</code>.</p>` : "";
43
+ const decisionItems = decisions.slice(0, 20).map((x) => html`<li><span class="muted mono">${formatTime(x.at)}</span> <strong>${x.choice}</strong>${x.reason ? html` <span class="muted">because ${x.reason}</span>` : ""} <span class="muted">· ${areaName(x.areaId)}</span></li>`);
44
+ const sessionItems = sessions.map((s) => html`<li><a href="/?session=${encodeURIComponent(s.id)}">${s.title || s.id}</a> <span class="muted">${s.cwd} · ${formatTime(s.updatedAt)}</span></li>`);
45
+ box.innerHTML = html`${pending}
46
+ <section><h2>Areas</h2><div class="home-areas">${areas.map((a) => areaCard(a))}</div></section>
47
+ <section><h2>Recent</h2>${list(feed.slice(0, 20).map(feedItem), "No activity yet. Each finished task adds a line here after it is scored.")}</section>
48
+ <section><h2>Decisions</h2>${list(decisionItems, "No decisions recorded yet.")}</section>
49
+ <section><h2>Recent sessions</h2>${list(sessionItems, "No sessions.")}</section>`.value;
50
+ }
51
+
52
+ search.addEventListener("input", render);
53
+ getJson<Home>("/api/home")
54
+ .then((d) => {
55
+ data = d;
56
+ render();
57
+ })
58
+ .catch((error) => {
59
+ errorBox.innerHTML = renderError(asErrorBody(error)).value;
60
+ });