@hexdecimal16/nexo 0.4.7 → 0.4.9
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.
- package/cli/src/areas.js +49 -0
- package/cli/src/common.js +1 -1
- package/cli/src/home-migrate.js +168 -0
- package/cli/src/main.js +6 -0
- package/cli/src/optimize.js +2 -5
- package/cli/src/ui.js +1 -1
- package/core/src/config/schema.js +1 -0
- package/core/src/engine/charged-completion.js +9 -4
- package/core/src/engine/errors.js +29 -2
- package/core/src/engine/prompts.js +1 -1
- package/core/src/engine/run.js +11 -6
- package/core/src/index.js +1 -0
- package/core/src/learn/areas.js +192 -0
- package/core/src/learn/job.js +15 -1
- package/core/src/learn/wiki.js +26 -18
- package/core/src/optimize/climb.js +0 -2
- package/core/src/optimize/optimize.js +2 -5
- package/core/src/optimize/scratchpad-wiki.js +7 -3
- package/optimize/src/engine.js +1 -22
- package/optimize/src/index.js +0 -1
- package/optimize/src/report.js +0 -2
- package/package.json +1 -1
- package/skills/bundled/wiki/SKILL.md +23 -13
- package/store/src/eval-cases.js +12 -6
- package/store/src/paths.js +2 -2
- package/tools/src/home-folders.js +36 -0
- package/tools/src/index.js +2 -0
- package/tools/src/wiki-page.js +78 -0
- package/tui/src/questions.js +31 -0
- package/web/public/area.html +23 -0
- package/web/public/cost.html +1 -1
- package/web/public/home.html +23 -0
- package/web/public/index.html +1 -1
- package/web/public/judge.html +1 -1
- package/web/public/learning.html +1 -1
- package/web/public/lib/api-types.ts +0 -2
- package/web/public/lib/optim-view.ts +1 -1
- package/web/public/lib/wikis-view.ts +3 -1
- package/web/public/optim.html +1 -1
- package/web/public/page.html +24 -0
- package/web/public/pages/area.ts +59 -0
- package/web/public/pages/home.ts +66 -0
- package/web/public/pages/page.ts +62 -0
- package/web/public/pages/wikis.ts +43 -6
- package/web/public/run.html +1 -1
- package/web/public/sessions.html +1 -1
- package/web/public/style.css +58 -0
- package/web/public/wikis.html +1 -1
- package/web/src/api.js +14 -9
- package/web/src/home-api.js +156 -0
- package/web/src/server.js +16 -0
- package/optimize/src/merge.js +0 -73
package/store/src/eval-cases.js
CHANGED
|
@@ -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
|
|
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
|
|
96
|
+
expected = feedback?.verdict === "done" && output.trim() ? clip(output) : null;
|
|
91
97
|
}
|
|
92
|
-
const reference = feedback
|
|
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) {
|
package/store/src/paths.js
CHANGED
|
@@ -13,11 +13,11 @@ export function resolveNexoPaths(env = process.env) {
|
|
|
13
13
|
skills: join(home, "skills"),
|
|
14
14
|
config: join(home, "config.json"),
|
|
15
15
|
credentials: join(home, "credentials.json"),
|
|
16
|
-
|
|
16
|
+
homeRoot: join(home, "home"),
|
|
17
17
|
promptHistory: join(home, "history.jsonl"),
|
|
18
18
|
};
|
|
19
19
|
}
|
|
20
20
|
export function ensureNexoDirs(paths) {
|
|
21
|
-
for (const dir of [paths.home, paths.runs, paths.sessions, paths.optim, paths.logs, paths.skills, paths.
|
|
21
|
+
for (const dir of [paths.home, paths.runs, paths.sessions, paths.optim, paths.logs, paths.skills, paths.homeRoot])
|
|
22
22
|
mkdirSync(dir, { recursive: true });
|
|
23
23
|
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { existsSync, readdirSync, statSync } from "node:fs";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
/** Where a new folder goes before it has an area. */
|
|
4
|
+
export const UNSORTED_AREA = "unsorted";
|
|
5
|
+
function isDir(path) {
|
|
6
|
+
try {
|
|
7
|
+
return statSync(path).isDirectory();
|
|
8
|
+
}
|
|
9
|
+
catch {
|
|
10
|
+
return false;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
/** Every <area>/<name> folder under the home root, sorted by area then name. */
|
|
14
|
+
export function listHomeFolders(root) {
|
|
15
|
+
if (!existsSync(root))
|
|
16
|
+
return [];
|
|
17
|
+
const out = [];
|
|
18
|
+
for (const area of readdirSync(root).sort()) {
|
|
19
|
+
if (area.startsWith("."))
|
|
20
|
+
continue;
|
|
21
|
+
const areaDir = join(root, area);
|
|
22
|
+
if (!isDir(areaDir))
|
|
23
|
+
continue;
|
|
24
|
+
for (const name of readdirSync(areaDir).sort()) {
|
|
25
|
+
if (name.startsWith("."))
|
|
26
|
+
continue;
|
|
27
|
+
const dir = join(areaDir, name);
|
|
28
|
+
if (isDir(dir))
|
|
29
|
+
out.push({ area, name, dir });
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return out;
|
|
33
|
+
}
|
|
34
|
+
export function findHomeFolder(root, name) {
|
|
35
|
+
return listHomeFolders(root).find((f) => f.name === name);
|
|
36
|
+
}
|
package/tools/src/index.js
CHANGED
|
@@ -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
|
+
}
|
package/tui/src/questions.js
CHANGED
|
@@ -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></nav>
|
|
16
|
+
<main id="main" tabindex="-1">
|
|
17
|
+
<p class="muted"><a href="/home.html">← 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>
|
package/web/public/cost.html
CHANGED
|
@@ -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
|
|
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></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></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>
|
package/web/public/index.html
CHANGED
|
@@ -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
|
|
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></nav>
|
|
16
16
|
<main id="main" tabindex="-1">
|
|
17
17
|
<h1>Runs</h1>
|
|
18
18
|
<div id="session-filter"></div>
|
package/web/public/judge.html
CHANGED
|
@@ -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
|
|
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></nav>
|
|
16
16
|
<main id="main" tabindex="-1">
|
|
17
17
|
<h1>Judge calibration</h1>
|
|
18
18
|
<div id="error"></div>
|
package/web/public/learning.html
CHANGED
|
@@ -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
|
|
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></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)})
|
|
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 =
|
|
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">
|
package/web/public/optim.html
CHANGED
|
@@ -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
|
|
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></nav>
|
|
16
16
|
<main id="main" tabindex="-1">
|
|
17
17
|
<h1>Optimization</h1>
|
|
18
18
|
<div id="error"></div>
|
|
@@ -0,0 +1,24 @@
|
|
|
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 · page</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/page.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">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></nav>
|
|
16
|
+
<main id="main" tabindex="-1">
|
|
17
|
+
<p class="muted" id="page-crumbs"><a href="/home.html">Home</a></p>
|
|
18
|
+
<h1 id="page-title">Page</h1>
|
|
19
|
+
<p class="muted" id="page-meta"></p>
|
|
20
|
+
<div id="error"></div>
|
|
21
|
+
<div id="page-body" class="wiki-prose wiki-html"></div>
|
|
22
|
+
</main>
|
|
23
|
+
</body>
|
|
24
|
+
</html>
|
|
@@ -0,0 +1,59 @@
|
|
|
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; path: string }
|
|
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; pages?: string[] }
|
|
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
|
+
const empty = (text: string): SafeHtml => html`<p class="muted">${text}</p>`;
|
|
18
|
+
const stat = (n: number, label: string): SafeHtml => html`<div class="area-stat"><b>${String(n)}</b><span class="muted">${label}</span></div>`;
|
|
19
|
+
|
|
20
|
+
function pageLinks(f: { pages?: string[]; wiki: string | null; areaId: string | null }): SafeHtml {
|
|
21
|
+
const pages = (f.pages ?? []).filter((p) => p.endsWith(".html") && p.includes("/") && !p.includes(".."));
|
|
22
|
+
if (pages.length > 0) return html`${pages.map((p) => html`<a class="feed-page" href="/page.html?path=${encodeURIComponent(p)}">${p.slice(p.lastIndexOf("/") + 1, -5)}</a> `)}`;
|
|
23
|
+
return f.wiki && f.areaId ? html`<a class="feed-page" href="/page.html?path=${encodeURIComponent(`${f.areaId}/${f.wiki}/index.html`)}">${f.wiki}</a>` : html``;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function render(d: Home, id: string): void {
|
|
27
|
+
const a = d.areas.find((x) => x.id === id);
|
|
28
|
+
if (!a) {
|
|
29
|
+
title.textContent = "Area not found";
|
|
30
|
+
box.innerHTML = html`<p class="muted">No active area "${id}". <a href="/home.html">Back to Home</a>.</p>`.value;
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
title.textContent = a.name;
|
|
34
|
+
document.title = `nexo · ${a.name}`;
|
|
35
|
+
const feed = d.feed.filter((f) => f.areaId === a.id).slice(0, 30);
|
|
36
|
+
const decisions = d.decisions.filter((x) => x.areaId === a.id);
|
|
37
|
+
const sessions = d.sessions.filter((s) => s.areaId === a.id);
|
|
38
|
+
const pages = a.wikis.reduce((n, w) => n + w.pageCount, 0);
|
|
39
|
+
const wikis = a.wikis.map((w) => html`<a class="area-card" href="/page.html?path=${encodeURIComponent(`${w.path}/index.html`)}"><strong>${w.name}</strong><span class="muted">${String(w.pageCount)} pages</span>${w.summary ? html`<span class="area-card-text">${w.summary}</span>` : ""}</a>`);
|
|
40
|
+
const timeline = feed.map((f) => {
|
|
41
|
+
const link = f.sessionId ? html`<a href="/?session=${encodeURIComponent(f.sessionId)}">session</a>` : html`<a href="/run.html?id=${encodeURIComponent(f.runId)}">run</a>`;
|
|
42
|
+
return html`<li><time>${formatTime(f.at)}${f.wiki ? ` · ${f.wiki}` : ""}</time>${f.text}${f.verified ? "" : html` <span class="home-tag">unverified</span>`} ${pageLinks(f)} ${link}</li>`;
|
|
43
|
+
});
|
|
44
|
+
const decisionCards = decisions.map((x) => html`<div class="area-decision"><strong>${x.choice}</strong>${x.reason ? html`<span class="muted">Because ${x.reason}</span>` : ""}<time class="muted">${formatTime(x.at)}</time></div>`);
|
|
45
|
+
const rows = sessions.map((s) => html`<tr><td><a href="/?session=${encodeURIComponent(s.id)}">${s.title || s.id}</a></td><td class="mono muted">${s.cwd}</td><td class="muted">${formatTime(s.updatedAt)}</td></tr>`);
|
|
46
|
+
box.innerHTML = html`<p class="home-note">${a.scope}</p>
|
|
47
|
+
<div class="area-stats">${stat(a.wikis.length, "wikis")}${stat(pages, "pages")}${stat(a.recent, "filed this week")}${stat(decisions.length, "decisions")}</div>
|
|
48
|
+
<section><h2>Wikis</h2>${wikis.length > 0 ? html`<div class="area-grid">${wikis}</div>` : empty("No wikis in this area yet.")}</section>
|
|
49
|
+
<section><h2>Recent</h2>${timeline.length > 0 ? html`<ol class="area-timeline">${timeline}</ol>` : empty("Nothing filed here yet. Finished tasks appear here after they are scored.")}</section>
|
|
50
|
+
<section><h2>Decisions</h2>${decisionCards.length > 0 ? decisionCards : empty("No decisions recorded here yet.")}</section>
|
|
51
|
+
<section><h2>Sessions</h2>${rows.length > 0 ? html`<table class="area-table"><thead><tr><th>Session</th><th>Folder</th><th>Updated</th></tr></thead><tbody>${rows}</tbody></table>` : empty("No linked sessions yet.")}</section>`.value;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const id = new URLSearchParams(location.search).get("id") ?? "";
|
|
55
|
+
getJson<Home>("/api/home")
|
|
56
|
+
.then((d) => render(d, id))
|
|
57
|
+
.catch((error) => {
|
|
58
|
+
errorBox.innerHTML = renderError(asErrorBody(error)).value;
|
|
59
|
+
});
|
|
@@ -0,0 +1,66 @@
|
|
|
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; path: string }
|
|
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; pages?: string[] }
|
|
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 pageLinks(f: { pages?: string[]; wiki: string | null; areaId: string | null }): SafeHtml {
|
|
22
|
+
const pages = (f.pages ?? []).filter((p) => p.endsWith(".html") && p.includes("/") && !p.includes(".."));
|
|
23
|
+
if (pages.length > 0) return html`${pages.map((p) => html`<a class="feed-page" href="/page.html?path=${encodeURIComponent(p)}">${p.slice(p.lastIndexOf("/") + 1, -5)}</a> `)}`;
|
|
24
|
+
return f.wiki && f.areaId ? html`<a class="feed-page" href="/page.html?path=${encodeURIComponent(`${f.areaId}/${f.wiki}/index.html`)}">${f.wiki}</a>` : html``;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function feedItem(f: HomeFeedItem): SafeHtml {
|
|
28
|
+
const link = f.sessionId ? html`<a href="/?session=${encodeURIComponent(f.sessionId)}">session</a>` : html`<a href="/run.html?id=${encodeURIComponent(f.runId)}">run</a>`;
|
|
29
|
+
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> ${pageLinks(f)} ${link}</li>`;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function list(items: SafeHtml[], empty: string): SafeHtml {
|
|
33
|
+
return items.length > 0 ? html`<ul class="home-list">${items}</ul>` : html`<p class="muted">${empty}</p>`;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function areaCard(a: HomeArea): SafeHtml {
|
|
37
|
+
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>`;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function render(): void {
|
|
41
|
+
if (!data) return;
|
|
42
|
+
const d = data;
|
|
43
|
+
const q = search.value.trim().toLowerCase();
|
|
44
|
+
const feed = d.feed.filter((f) => hit(q, f.text, f.wiki, areaName(f.areaId)));
|
|
45
|
+
const decisions = d.decisions.filter((x) => hit(q, x.choice, x.reason, x.wiki, areaName(x.areaId)));
|
|
46
|
+
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)));
|
|
47
|
+
const sessions = d.sessions.filter((s) => hit(q, s.title, s.cwd, areaName(s.areaId)));
|
|
48
|
+
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>` : "";
|
|
49
|
+
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>`);
|
|
50
|
+
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>`);
|
|
51
|
+
box.innerHTML = html`${pending}
|
|
52
|
+
<section><h2>Areas</h2><div class="home-areas">${areas.map((a) => areaCard(a))}</div></section>
|
|
53
|
+
<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>
|
|
54
|
+
<section><h2>Decisions</h2>${list(decisionItems, "No decisions recorded yet.")}</section>
|
|
55
|
+
<section><h2>Recent sessions</h2>${list(sessionItems, "No sessions.")}</section>`.value;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
search.addEventListener("input", render);
|
|
59
|
+
getJson<Home>("/api/home")
|
|
60
|
+
.then((d) => {
|
|
61
|
+
data = d;
|
|
62
|
+
render();
|
|
63
|
+
})
|
|
64
|
+
.catch((error) => {
|
|
65
|
+
errorBox.innerHTML = renderError(asErrorBody(error)).value;
|
|
66
|
+
});
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { renderError } from "../lib/common-view.ts";
|
|
2
|
+
import { formatTime } from "../lib/format.ts";
|
|
3
|
+
import { asErrorBody, el, getJson } from "./api.ts";
|
|
4
|
+
|
|
5
|
+
interface HomePage { path: string; title: string; summary?: string; updated?: string; content: string; modifiedAt: string }
|
|
6
|
+
|
|
7
|
+
const crumbs = el<HTMLParagraphElement>("#page-crumbs");
|
|
8
|
+
const titleEl = el<HTMLHeadingElement>("#page-title");
|
|
9
|
+
const meta = el<HTMLParagraphElement>("#page-meta");
|
|
10
|
+
const body = el<HTMLDivElement>("#page-body");
|
|
11
|
+
const errorBox = el<HTMLDivElement>("#error");
|
|
12
|
+
const DROP = "script,style,iframe,object,embed,form,link,meta,base,title";
|
|
13
|
+
|
|
14
|
+
function link(text: string, href: string): HTMLAnchorElement {
|
|
15
|
+
const a = document.createElement("a");
|
|
16
|
+
a.href = href;
|
|
17
|
+
a.textContent = text;
|
|
18
|
+
return a;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** Shows the page body inline: active content removed, links to other pages kept inside page.html. */
|
|
22
|
+
function mount(page: HomePage): void {
|
|
23
|
+
const doc = new DOMParser().parseFromString(page.content, "text/html");
|
|
24
|
+
const root = doc.querySelector("main") ?? doc.body;
|
|
25
|
+
root.querySelectorAll(DROP).forEach((n) => n.remove());
|
|
26
|
+
root.querySelectorAll(":scope > nav, :scope > p.meta, :scope > h1").forEach((n) => n.remove());
|
|
27
|
+
root.querySelectorAll("*").forEach((node) => {
|
|
28
|
+
for (const attr of Array.from(node.attributes)) {
|
|
29
|
+
const name = attr.name.toLowerCase();
|
|
30
|
+
if (name.startsWith("on") || name === "style") node.removeAttribute(attr.name);
|
|
31
|
+
else if ((name === "href" || name === "src" || name === "xlink:href") && /^\s*(javascript|data):/i.test(attr.value)) node.removeAttribute(attr.name);
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
const base = page.path.slice(0, page.path.lastIndexOf("/") + 1);
|
|
35
|
+
root.querySelectorAll<HTMLAnchorElement>("a[href]").forEach((a) => {
|
|
36
|
+
const href = a.getAttribute("href") ?? "";
|
|
37
|
+
if (/^(https?:|mailto:)/i.test(href)) {
|
|
38
|
+
a.target = "_blank";
|
|
39
|
+
a.rel = "noopener noreferrer";
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
if (href.startsWith("#")) return;
|
|
43
|
+
const target = decodeURIComponent(new URL(href, `https://home.invalid/${base}`).pathname.slice(1));
|
|
44
|
+
if (target.endsWith(".html")) a.setAttribute("href", `/page.html?path=${encodeURIComponent(target)}`);
|
|
45
|
+
else a.removeAttribute("href");
|
|
46
|
+
});
|
|
47
|
+
body.replaceChildren(...Array.from(root.childNodes).map((n) => document.importNode(n, true)));
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const path = new URLSearchParams(location.search).get("path") ?? "";
|
|
51
|
+
const [area = "", folder = ""] = path.split("/");
|
|
52
|
+
crumbs.replaceChildren(link("Home", "/home.html"), " / ", link(area, `/area.html?id=${encodeURIComponent(area)}`), " / ", link(folder, `/page.html?path=${encodeURIComponent(`${area}/${folder}/index.html`)}`));
|
|
53
|
+
getJson<HomePage>(`/api/home/page?path=${encodeURIComponent(path)}`)
|
|
54
|
+
.then((page) => {
|
|
55
|
+
titleEl.textContent = page.title;
|
|
56
|
+
document.title = `nexo · ${page.title}`;
|
|
57
|
+
meta.textContent = `Updated ${page.updated || formatTime(page.modifiedAt)}`;
|
|
58
|
+
mount(page);
|
|
59
|
+
})
|
|
60
|
+
.catch((error) => {
|
|
61
|
+
errorBox.innerHTML = renderError(asErrorBody(error)).value;
|
|
62
|
+
});
|