document360-writer 0.3.1 → 0.4.0
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/dist/cli.js +5 -0
- package/dist/cli.js.map +1 -1
- package/dist/commands/logsCli.d.ts +2 -0
- package/dist/commands/logsCli.js +31 -0
- package/dist/commands/logsCli.js.map +1 -0
- package/dist/d360/portalLink.d.ts +18 -0
- package/dist/d360/portalLink.js +43 -0
- package/dist/d360/portalLink.js.map +1 -0
- package/dist/lib/mdRender.d.ts +7 -0
- package/dist/lib/mdRender.js +172 -0
- package/dist/lib/mdRender.js.map +1 -0
- package/dist/lib/streaming.d.ts +23 -0
- package/dist/lib/streaming.js +51 -0
- package/dist/lib/streaming.js.map +1 -0
- package/dist/lib/toolFormat.d.ts +26 -0
- package/dist/lib/toolFormat.js +115 -0
- package/dist/lib/toolFormat.js.map +1 -0
- package/dist/repl.js +49 -6
- package/dist/repl.js.map +1 -1
- package/dist/tui/App.js +231 -63
- package/dist/tui/App.js.map +1 -1
- package/dist/tui/catalog.js +1 -0
- package/dist/tui/catalog.js.map +1 -1
- package/dist/tui/itemRender.d.ts +56 -0
- package/dist/tui/itemRender.js +72 -0
- package/dist/tui/itemRender.js.map +1 -0
- package/package.json +5 -3
- package/dist/tui/markdown.d.ts +0 -4
- package/dist/tui/markdown.js +0 -139
- package/dist/tui/markdown.js.map +0 -1
package/dist/cli.js
CHANGED
|
@@ -5,6 +5,7 @@ import { AUTH_MODES } from 'document360-engine';
|
|
|
5
5
|
import { runLogin, runLogout, runWhoami } from './d360/authCli.js';
|
|
6
6
|
import { runProfileList, runProfileShow, runProfileUse } from './d360/profileCli.js';
|
|
7
7
|
import { runWorkspacePicker, runWorkspaceUse } from './d360/workspaceCli.js';
|
|
8
|
+
import { runLogs } from './commands/logsCli.js';
|
|
8
9
|
import { runOnce } from './oneShot.js';
|
|
9
10
|
import { runRepl } from './repl.js';
|
|
10
11
|
import { runTui } from './tui/index.js';
|
|
@@ -78,6 +79,10 @@ workspaceCmd
|
|
|
78
79
|
.action(async (name, opts) => {
|
|
79
80
|
process.exitCode = await runWorkspaceUse(process.cwd(), name, opts.profile);
|
|
80
81
|
});
|
|
82
|
+
program
|
|
83
|
+
.command('logs')
|
|
84
|
+
.description('Show the Document360 API log files (send these to support when reporting a problem)')
|
|
85
|
+
.action(() => runLogs());
|
|
81
86
|
program
|
|
82
87
|
.name('d360-writer')
|
|
83
88
|
.description('Standalone documentation agent CLI. Reads your code, writes your docs.')
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAiB,MAAM,oBAAoB,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrF,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAC7E,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAExC,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC/C,MAAM,GAAG,GAAG,OAAO,CAAC,iBAAiB,CAAwB,CAAC;AAE9D,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;AAE9B,2FAA2F;AAC3F,SAAS,eAAe,CAAC,IAAsB;IAC7C,IAAI,IAAI,CAAC,GAAG,EAAE,CAAC;QACb,OAAO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GAAG,CAAC,OAAO,CAAC,CAAC;IAC3E,CAAC;AACH,CAAC,CAAC,CAAC;AAEL,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE;IAC3C,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IAClB,OAAO,CAAC,KAAK,CAAC,KAAM,GAAa,CAAC,OAAO,EAAE,CAAC,CAAC;IAC7C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { existsSync, readdirSync, statSync } from 'node:fs';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
import { apiLogDir } from 'document360-engine';
|
|
4
|
+
import { accent, dim } from '../lib/colors.js';
|
|
5
|
+
/** `d360-writer logs` — the one command to give a customer reporting a problem. */
|
|
6
|
+
export function runLogs() {
|
|
7
|
+
const dir = apiLogDir();
|
|
8
|
+
console.log('');
|
|
9
|
+
console.log(`Document360 API logs: ${accent(dir)}`);
|
|
10
|
+
if (!existsSync(dir)) {
|
|
11
|
+
console.log(dim(' No logs yet — they appear after the first Document360 API call.'));
|
|
12
|
+
console.log('');
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
const files = readdirSync(dir)
|
|
16
|
+
.filter(f => f.endsWith('.jsonl'))
|
|
17
|
+
.sort()
|
|
18
|
+
.reverse();
|
|
19
|
+
if (files.length === 0) {
|
|
20
|
+
console.log(dim(' No logs yet — they appear after the first Document360 API call.'));
|
|
21
|
+
}
|
|
22
|
+
for (const f of files.slice(0, 14)) {
|
|
23
|
+
const kb = (statSync(join(dir, f)).size / 1024).toFixed(1);
|
|
24
|
+
console.log(` ${f} ${dim(`${kb} KB`)}`);
|
|
25
|
+
}
|
|
26
|
+
console.log('');
|
|
27
|
+
console.log(dim('Failed calls include request/response bodies (tokens redacted, 4 KB cap).'));
|
|
28
|
+
console.log(dim('Set D360_LOG_BODIES=1 to also log bodies for successful calls.'));
|
|
29
|
+
console.log('');
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=logsCli.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logsCli.js","sourceRoot":"","sources":["../../src/commands/logsCli.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC5D,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAC;AAE/C,mFAAmF;AACnF,MAAM,UAAU,OAAO;IACrB,MAAM,GAAG,GAAG,SAAS,EAAE,CAAC;IACxB,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAChB,OAAO,CAAC,GAAG,CAAC,yBAAyB,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IACpD,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;QACrB,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,mEAAmE,CAAC,CAAC,CAAC;QACtF,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAChB,OAAO;IACT,CAAC;IACD,MAAM,KAAK,GAAG,WAAW,CAAC,GAAG,CAAC;SAC3B,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;SACjC,IAAI,EAAE;SACN,OAAO,EAAE,CAAC;IACb,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACvB,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,mEAAmE,CAAC,CAAC,CAAC;IACxF,CAAC;IACD,KAAK,MAAM,CAAC,IAAI,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC;QACnC,MAAM,EAAE,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;QAC3D,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,CAAC,CAAC;IAC5C,CAAC;IACD,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAChB,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,2EAA2E,CAAC,CAAC,CAAC;IAC9F,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,gEAAgE,CAAC,CAAC,CAAC;IACnF,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;AAClB,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Deep links into the Document360 author portal, surfaced after the agent creates or
|
|
3
|
+
* updates an article so the real rendered outcome is one click away.
|
|
4
|
+
*
|
|
5
|
+
* NOTE: the editor path shape (`/{projectId}/document/v1/{lang}/{articleId}`) is a
|
|
6
|
+
* best-effort guess pending verification against the berlin portal during dogfood —
|
|
7
|
+
* if it 404s, fix it HERE (single source) or override the base via the profile's
|
|
8
|
+
* `connection.portalUrl` / `D360_PORTAL_URL`.
|
|
9
|
+
*/
|
|
10
|
+
/** Portal editor URL for a draft article. */
|
|
11
|
+
export declare function articleEditorUrl(portalUrl: string, projectId: string, articleId: string, languageCode?: string): string;
|
|
12
|
+
/**
|
|
13
|
+
* Pull the article id out of a write-tool exchange: update/fork/publish carry it in
|
|
14
|
+
* the input; create returns it in the result (bulk-create → array with one item).
|
|
15
|
+
*/
|
|
16
|
+
export declare function extractArticleId(input: Record<string, unknown>, output: string): string | null;
|
|
17
|
+
/** Public KB URL from a tool result, if the API returned one (live after publish). */
|
|
18
|
+
export declare function extractPublicUrl(output: string): string | null;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Deep links into the Document360 author portal, surfaced after the agent creates or
|
|
3
|
+
* updates an article so the real rendered outcome is one click away.
|
|
4
|
+
*
|
|
5
|
+
* NOTE: the editor path shape (`/{projectId}/document/v1/{lang}/{articleId}`) is a
|
|
6
|
+
* best-effort guess pending verification against the berlin portal during dogfood —
|
|
7
|
+
* if it 404s, fix it HERE (single source) or override the base via the profile's
|
|
8
|
+
* `connection.portalUrl` / `D360_PORTAL_URL`.
|
|
9
|
+
*/
|
|
10
|
+
/** Portal editor URL for a draft article. */
|
|
11
|
+
export function articleEditorUrl(portalUrl, projectId, articleId, languageCode = 'en') {
|
|
12
|
+
return `${portalUrl.replace(/\/$/, '')}/${projectId}/document/v1/${languageCode}/${articleId}`;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Pull the article id out of a write-tool exchange: update/fork/publish carry it in
|
|
16
|
+
* the input; create returns it in the result (bulk-create → array with one item).
|
|
17
|
+
*/
|
|
18
|
+
export function extractArticleId(input, output) {
|
|
19
|
+
if (typeof input['article_id'] === 'string' && input['article_id'])
|
|
20
|
+
return input['article_id'];
|
|
21
|
+
try {
|
|
22
|
+
const data = JSON.parse(output);
|
|
23
|
+
const first = Array.isArray(data) ? data[0] : data;
|
|
24
|
+
const id = first?.['id'];
|
|
25
|
+
return typeof id === 'string' && id ? id : null;
|
|
26
|
+
}
|
|
27
|
+
catch {
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
/** Public KB URL from a tool result, if the API returned one (live after publish). */
|
|
32
|
+
export function extractPublicUrl(output) {
|
|
33
|
+
try {
|
|
34
|
+
const data = JSON.parse(output);
|
|
35
|
+
const first = Array.isArray(data) ? data[0] : data;
|
|
36
|
+
const url = first?.['url'];
|
|
37
|
+
return typeof url === 'string' && /^https?:\/\//.test(url) ? url : null;
|
|
38
|
+
}
|
|
39
|
+
catch {
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=portalLink.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"portalLink.js","sourceRoot":"","sources":["../../src/d360/portalLink.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,6CAA6C;AAC7C,MAAM,UAAU,gBAAgB,CAAC,SAAiB,EAAE,SAAiB,EAAE,SAAiB,EAAE,YAAY,GAAG,IAAI;IAC3G,OAAO,GAAG,SAAS,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,SAAS,gBAAgB,YAAY,IAAI,SAAS,EAAE,CAAC;AACjG,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,gBAAgB,CAAC,KAA8B,EAAE,MAAc;IAC7E,IAAI,OAAO,KAAK,CAAC,YAAY,CAAC,KAAK,QAAQ,IAAI,KAAK,CAAC,YAAY,CAAC;QAAE,OAAO,KAAK,CAAC,YAAY,CAAC,CAAC;IAC/F,IAAI,CAAC;QACH,MAAM,IAAI,GAAY,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QACzC,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;QACnD,MAAM,EAAE,GAAI,KAAwC,EAAE,CAAC,IAAI,CAAC,CAAC;QAC7D,OAAO,OAAO,EAAE,KAAK,QAAQ,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;IAClD,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC;AAED,sFAAsF;AACtF,MAAM,UAAU,gBAAgB,CAAC,MAAc;IAC7C,IAAI,CAAC;QACH,MAAM,IAAI,GAAY,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QACzC,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;QACnD,MAAM,GAAG,GAAI,KAAwC,EAAE,CAAC,KAAK,CAAC,CAAC;QAC/D,OAAO,OAAO,GAAG,KAAK,QAAQ,IAAI,cAAc,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC;IAC1E,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** Render inline **bold**, *italic*, `code` as ANSI-styled spans. */
|
|
2
|
+
export declare function inlineMd(text: string): string;
|
|
3
|
+
/**
|
|
4
|
+
* Render finalized markdown to an ANSI string. Blocks are joined with one blank line
|
|
5
|
+
* (uniform spacing — source blocks are blank-line separated, so render them so).
|
|
6
|
+
*/
|
|
7
|
+
export declare function renderMarkdown(md: string, width: number): string;
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Markdown → ANSI string renderer for finalized transcript content. Pure functions —
|
|
3
|
+
* no Ink. Replaces the Ink <Markdown> component so the transcript can be printed (and
|
|
4
|
+
* REPLAYED at a new width on resize) through Ink's console patch; also reusable by the
|
|
5
|
+
* plain REPL. Covers what a documentation agent actually emits: headings, bold/italic/
|
|
6
|
+
* inline-code, bullet/numbered lists, fenced code, ---, and GitHub-style tables.
|
|
7
|
+
*/
|
|
8
|
+
import pc from 'picocolors';
|
|
9
|
+
import wrapAnsi from 'wrap-ansi';
|
|
10
|
+
import stringWidth from 'string-width';
|
|
11
|
+
const isHr = (line) => /^\s*(-{3,}|\*{3,}|_{3,})\s*$/.test(line);
|
|
12
|
+
const isTableSep = (line) => /^\s*\|?[\s:|-]*-[\s:|-]*\|?\s*$/.test(line) && line.includes('-');
|
|
13
|
+
const splitCells = (line) => line.replace(/^\s*\|/, '').replace(/\|\s*$/, '').split('|').map(c => c.trim());
|
|
14
|
+
function parseBlocks(md) {
|
|
15
|
+
const lines = md.replace(/\r/g, '').split('\n');
|
|
16
|
+
const blocks = [];
|
|
17
|
+
let i = 0;
|
|
18
|
+
while (i < lines.length) {
|
|
19
|
+
const line = lines[i];
|
|
20
|
+
// fenced code
|
|
21
|
+
if (/^\s*```/.test(line)) {
|
|
22
|
+
const code = [];
|
|
23
|
+
i++;
|
|
24
|
+
while (i < lines.length && !/^\s*```/.test(lines[i]))
|
|
25
|
+
code.push(lines[i++]);
|
|
26
|
+
i++; // closing fence
|
|
27
|
+
blocks.push({ kind: 'code', lines: code });
|
|
28
|
+
continue;
|
|
29
|
+
}
|
|
30
|
+
// horizontal rule (---, ***, ___) — must precede the para fallback
|
|
31
|
+
if (isHr(line)) {
|
|
32
|
+
blocks.push({ kind: 'hr' });
|
|
33
|
+
i++;
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
// table: a `| … |`-ish line followed by a separator row
|
|
37
|
+
if (line.includes('|') && i + 1 < lines.length && isTableSep(lines[i + 1])) {
|
|
38
|
+
const header = splitCells(line);
|
|
39
|
+
i += 2;
|
|
40
|
+
const rows = [];
|
|
41
|
+
while (i < lines.length && lines[i].includes('|') && lines[i].trim() !== '') {
|
|
42
|
+
rows.push(splitCells(lines[i++]));
|
|
43
|
+
}
|
|
44
|
+
blocks.push({ kind: 'table', header, rows });
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
47
|
+
// heading
|
|
48
|
+
const h = line.match(/^(#{1,6})\s+(.*)$/);
|
|
49
|
+
if (h) {
|
|
50
|
+
blocks.push({ kind: 'heading', level: h[1].length, text: h[2] });
|
|
51
|
+
i++;
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
// list (consecutive bullet / numbered lines)
|
|
55
|
+
if (/^\s*([-*]|\d+\.)\s+/.test(line)) {
|
|
56
|
+
const items = [];
|
|
57
|
+
while (i < lines.length && /^\s*([-*]|\d+\.)\s+/.test(lines[i])) {
|
|
58
|
+
items.push(lines[i++].replace(/^\s*([-*]|\d+\.)\s+/, ''));
|
|
59
|
+
}
|
|
60
|
+
blocks.push({ kind: 'list', items });
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
63
|
+
// blank
|
|
64
|
+
if (line.trim() === '') {
|
|
65
|
+
i++;
|
|
66
|
+
continue;
|
|
67
|
+
}
|
|
68
|
+
// paragraph (gather until blank / block boundary)
|
|
69
|
+
const para = [];
|
|
70
|
+
while (i < lines.length &&
|
|
71
|
+
lines[i].trim() !== '' &&
|
|
72
|
+
!/^\s*```/.test(lines[i]) &&
|
|
73
|
+
!/^(#{1,6})\s/.test(lines[i]) &&
|
|
74
|
+
!/^\s*([-*]|\d+\.)\s+/.test(lines[i]) &&
|
|
75
|
+
!isHr(lines[i]) &&
|
|
76
|
+
!(lines[i].includes('|') && i + 1 < lines.length && isTableSep(lines[i + 1]))) {
|
|
77
|
+
para.push(lines[i++]);
|
|
78
|
+
}
|
|
79
|
+
blocks.push({ kind: 'para', text: para.join(' ') });
|
|
80
|
+
}
|
|
81
|
+
return blocks;
|
|
82
|
+
}
|
|
83
|
+
/** Render inline **bold**, *italic*, `code` as ANSI-styled spans. */
|
|
84
|
+
export function inlineMd(text) {
|
|
85
|
+
return text.replace(/(\*\*[^*]+\*\*|`[^`]+`|\*[^*]+\*)/g, tok => {
|
|
86
|
+
if (tok.startsWith('**'))
|
|
87
|
+
return pc.bold(tok.slice(2, -2));
|
|
88
|
+
if (tok.startsWith('`'))
|
|
89
|
+
return pc.cyan(tok.slice(1, -1));
|
|
90
|
+
return pc.italic(tok.slice(1, -1));
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
const padTo = (line, w) => line + ' '.repeat(Math.max(0, w - stringWidth(line)));
|
|
94
|
+
function renderTable(header, rows, width) {
|
|
95
|
+
const cols = header.length;
|
|
96
|
+
// Natural width = widest cell per column; shrink the widest column until the table
|
|
97
|
+
// fits (min 6) and wrap cells inside their fixed-width column.
|
|
98
|
+
const natural = header.map((h, c) => Math.max(stringWidth(h), ...rows.map(r => stringWidth(r[c] ?? ''))));
|
|
99
|
+
const avail = Math.max(24, width);
|
|
100
|
+
// Per cell: left border (1) + padding (2); plus the table's closing right border (1).
|
|
101
|
+
const overhead = 3 * cols + 1;
|
|
102
|
+
const widths = [...natural];
|
|
103
|
+
const total = () => widths.reduce((a, b) => a + b, 0) + overhead;
|
|
104
|
+
let guard = 0;
|
|
105
|
+
while (total() > avail && guard++ < 10000) {
|
|
106
|
+
let idx = -1;
|
|
107
|
+
let max = 6; // floor
|
|
108
|
+
for (let c = 0; c < cols; c++) {
|
|
109
|
+
if (widths[c] > max) {
|
|
110
|
+
max = widths[c];
|
|
111
|
+
idx = c;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
if (idx === -1)
|
|
115
|
+
break; // all at floor
|
|
116
|
+
widths[idx] -= 1;
|
|
117
|
+
}
|
|
118
|
+
const rule = (left, mid, right) => pc.gray(left + widths.map(w => '─'.repeat(w + 2)).join(mid) + right);
|
|
119
|
+
const v = pc.gray('│');
|
|
120
|
+
const renderRow = (cells, head) => {
|
|
121
|
+
const cellLines = widths.map((w, c) => {
|
|
122
|
+
const raw = cells[c] ?? '';
|
|
123
|
+
const styled = head ? pc.bold(pc.cyan(raw)) : inlineMd(raw);
|
|
124
|
+
return wrapAnsi(styled, w, { hard: true }).split('\n');
|
|
125
|
+
});
|
|
126
|
+
const height = Math.max(...cellLines.map(l => l.length));
|
|
127
|
+
const out = [];
|
|
128
|
+
for (let r = 0; r < height; r++) {
|
|
129
|
+
out.push(widths.map((w, c) => `${v} ${padTo(cellLines[c][r] ?? '', w)} `).join('') + v);
|
|
130
|
+
}
|
|
131
|
+
return out.join('\n');
|
|
132
|
+
};
|
|
133
|
+
const parts = [rule('┌', '┬', '┐'), renderRow(header, true)];
|
|
134
|
+
parts.push(rows.length === 0 ? rule('└', '┴', '┘') : rule('├', '┼', '┤'));
|
|
135
|
+
rows.forEach((r, ri) => {
|
|
136
|
+
parts.push(renderRow(r, false));
|
|
137
|
+
parts.push(ri === rows.length - 1 ? rule('└', '┴', '┘') : rule('├', '┼', '┤'));
|
|
138
|
+
});
|
|
139
|
+
return parts.join('\n');
|
|
140
|
+
}
|
|
141
|
+
function renderBlock(b, width) {
|
|
142
|
+
switch (b.kind) {
|
|
143
|
+
case 'heading':
|
|
144
|
+
return pc.bold(pc.cyan(b.text));
|
|
145
|
+
case 'hr':
|
|
146
|
+
return pc.gray('─'.repeat(width));
|
|
147
|
+
case 'para':
|
|
148
|
+
return wrapAnsi(inlineMd(b.text), width);
|
|
149
|
+
case 'list':
|
|
150
|
+
return b.items
|
|
151
|
+
.map(it => {
|
|
152
|
+
const [first = '', ...rest] = wrapAnsi(inlineMd(it), Math.max(10, width - 4)).split('\n');
|
|
153
|
+
return pc.cyan(' • ') + first + rest.map(r => '\n ' + r).join('');
|
|
154
|
+
})
|
|
155
|
+
.join('\n');
|
|
156
|
+
case 'code':
|
|
157
|
+
return b.lines.map(l => pc.gray(' ' + l)).join('\n');
|
|
158
|
+
case 'table':
|
|
159
|
+
return renderTable(b.header, b.rows, width);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Render finalized markdown to an ANSI string. Blocks are joined with one blank line
|
|
164
|
+
* (uniform spacing — source blocks are blank-line separated, so render them so).
|
|
165
|
+
*/
|
|
166
|
+
export function renderMarkdown(md, width) {
|
|
167
|
+
const w = Math.max(20, width);
|
|
168
|
+
return parseBlocks(md)
|
|
169
|
+
.map(b => renderBlock(b, w))
|
|
170
|
+
.join('\n\n');
|
|
171
|
+
}
|
|
172
|
+
//# sourceMappingURL=mdRender.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mdRender.js","sourceRoot":"","sources":["../../src/lib/mdRender.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAA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AG,CAAC,CAAC,CAAC,EAAE,CAAC,WAAW,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;SAC3B,IAAI,CAAC,MAAM,CAAC,CAAC;AAClB,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Streaming-markdown flush support. While the agent streams, completed paragraphs are
|
|
3
|
+
* flushed into the static (markdown-rendered) transcript so what scrolls out of the
|
|
4
|
+
* viewport is already pretty — Ink can only repaint what's still on screen, so raw
|
|
5
|
+
* streamed text left in scrollback stays raw forever (Claude Code flushes the same way).
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Cut position after the last blank line that lies outside any ``` fence, or 0 when
|
|
9
|
+
* there's no safe cut yet. Text before the cut is a complete run of markdown blocks
|
|
10
|
+
* (a fence keeps code blocks intact; tables/lists have no internal blank lines).
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* Tail of the live streaming buffer, capped to ~maxRows visual rows so the dynamic
|
|
14
|
+
* region can never outgrow the viewport — Ink erases the live area by line count, and
|
|
15
|
+
* anything that scrolls off-screen leaves un-repaintable raw frames in scrollback.
|
|
16
|
+
* Row usage is estimated as ceil(len/width) per source line (Ink word-wraps, so this
|
|
17
|
+
* is approximate — callers should leave headroom when picking maxRows).
|
|
18
|
+
*/
|
|
19
|
+
export declare function liveTail(text: string, maxRows: number, width: number): {
|
|
20
|
+
text: string;
|
|
21
|
+
truncated: boolean;
|
|
22
|
+
};
|
|
23
|
+
export declare function streamCut(text: string): number;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Streaming-markdown flush support. While the agent streams, completed paragraphs are
|
|
3
|
+
* flushed into the static (markdown-rendered) transcript so what scrolls out of the
|
|
4
|
+
* viewport is already pretty — Ink can only repaint what's still on screen, so raw
|
|
5
|
+
* streamed text left in scrollback stays raw forever (Claude Code flushes the same way).
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Cut position after the last blank line that lies outside any ``` fence, or 0 when
|
|
9
|
+
* there's no safe cut yet. Text before the cut is a complete run of markdown blocks
|
|
10
|
+
* (a fence keeps code blocks intact; tables/lists have no internal blank lines).
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* Tail of the live streaming buffer, capped to ~maxRows visual rows so the dynamic
|
|
14
|
+
* region can never outgrow the viewport — Ink erases the live area by line count, and
|
|
15
|
+
* anything that scrolls off-screen leaves un-repaintable raw frames in scrollback.
|
|
16
|
+
* Row usage is estimated as ceil(len/width) per source line (Ink word-wraps, so this
|
|
17
|
+
* is approximate — callers should leave headroom when picking maxRows).
|
|
18
|
+
*/
|
|
19
|
+
export function liveTail(text, maxRows, width) {
|
|
20
|
+
const w = Math.max(1, width);
|
|
21
|
+
const lines = text.split('\n');
|
|
22
|
+
let rows = 0;
|
|
23
|
+
for (let i = lines.length - 1; i >= 0; i--) {
|
|
24
|
+
const line = lines[i];
|
|
25
|
+
rows += Math.max(1, Math.ceil(line.length / w));
|
|
26
|
+
if (rows >= maxRows) {
|
|
27
|
+
const over = rows - maxRows;
|
|
28
|
+
// A single over-tall line: drop its leading rows so the tail fits.
|
|
29
|
+
const head = over > 0 ? line.slice(over * w) : line;
|
|
30
|
+
return { text: [head, ...lines.slice(i + 1)].join('\n'), truncated: i > 0 || over > 0 };
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return { text, truncated: false };
|
|
34
|
+
}
|
|
35
|
+
export function streamCut(text) {
|
|
36
|
+
let fence = false;
|
|
37
|
+
let cut = 0;
|
|
38
|
+
let offset = 0;
|
|
39
|
+
for (const line of text.split('\n')) {
|
|
40
|
+
const end = offset + line.length;
|
|
41
|
+
if (/^\s*```/.test(line))
|
|
42
|
+
fence = !fence;
|
|
43
|
+
// `end < length` ⇒ the newline after the blank line has arrived, so the blank
|
|
44
|
+
// line is complete and everything before it is final.
|
|
45
|
+
else if (!fence && line.trim() === '' && end < text.length)
|
|
46
|
+
cut = end + 1;
|
|
47
|
+
offset = end + 1;
|
|
48
|
+
}
|
|
49
|
+
return cut;
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=streaming.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"streaming.js","sourceRoot":"","sources":["../../src/lib/streaming.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;;GAIG;AACH;;;;;;GAMG;AACH,MAAM,UAAU,QAAQ,CAAC,IAAY,EAAE,OAAe,EAAE,KAAa;IACnE,MAAM,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;IAC7B,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC/B,IAAI,IAAI,GAAG,CAAC,CAAC;IACb,KAAK,IAAI,CAAC,GAAG,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QAC3C,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,CAAE,CAAC;QACvB,IAAI,IAAI,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC;QAChD,IAAI,IAAI,IAAI,OAAO,EAAE,CAAC;YACpB,MAAM,IAAI,GAAG,IAAI,GAAG,OAAO,CAAC;YAC5B,mEAAmE;YACnE,MAAM,IAAI,GAAG,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;YACpD,OAAO,EAAE,IAAI,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,SAAS,EAAE,CAAC,GAAG,CAAC,IAAI,IAAI,GAAG,CAAC,EAAE,CAAC;QAC1F,CAAC;IACH,CAAC;IACD,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;AACpC,CAAC;AAED,MAAM,UAAU,SAAS,CAAC,IAAY;IACpC,IAAI,KAAK,GAAG,KAAK,CAAC;IAClB,IAAI,GAAG,GAAG,CAAC,CAAC;IACZ,IAAI,MAAM,GAAG,CAAC,CAAC;IACf,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;QACpC,MAAM,GAAG,GAAG,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;QACjC,IAAI,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC;YAAE,KAAK,GAAG,CAAC,KAAK,CAAC;QACzC,8EAA8E;QAC9E,sDAAsD;aACjD,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,IAAI,GAAG,GAAG,IAAI,CAAC,MAAM;YAAE,GAAG,GAAG,GAAG,GAAG,CAAC,CAAC;QAC1E,MAAM,GAAG,GAAG,GAAG,CAAC,CAAC;IACnB,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Claude Code-style formatting of tool calls and results for terminal display.
|
|
3
|
+
* Pure functions — shared by the Ink TUI and the plain REPL renderer.
|
|
4
|
+
*
|
|
5
|
+
* ● Bash(npm run build)
|
|
6
|
+
* ⎿ first lines of output…
|
|
7
|
+
* … +12 lines
|
|
8
|
+
*/
|
|
9
|
+
/** `sep` goes between title and `(arg)`: built-ins are tight (`Bash(…)`, Claude Code
|
|
10
|
+
* style); MCP titles read as words, so they get a space (`Document360: get article (…)`). */
|
|
11
|
+
export type ToolHeader = {
|
|
12
|
+
title: string;
|
|
13
|
+
sep: '' | ' ';
|
|
14
|
+
arg: string | null;
|
|
15
|
+
};
|
|
16
|
+
export type ToolResultView = {
|
|
17
|
+
lines: string[];
|
|
18
|
+
hidden: number;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Header line for a tool call: display title + inline argument summary.
|
|
22
|
+
* Returns null for internal tools that should stay hidden.
|
|
23
|
+
*/
|
|
24
|
+
export declare function formatToolUse(name: string, input: Record<string, unknown>): ToolHeader | null;
|
|
25
|
+
/** Preview of a tool result: first `maxLines` lines + how many were held back. */
|
|
26
|
+
export declare function formatToolResult(output: string, maxLines?: number): ToolResultView;
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Claude Code-style formatting of tool calls and results for terminal display.
|
|
3
|
+
* Pure functions — shared by the Ink TUI and the plain REPL renderer.
|
|
4
|
+
*
|
|
5
|
+
* ● Bash(npm run build)
|
|
6
|
+
* ⎿ first lines of output…
|
|
7
|
+
* … +12 lines
|
|
8
|
+
*/
|
|
9
|
+
/** The one input field worth showing inline for each built-in tool. */
|
|
10
|
+
const PRIMARY_ARG = {
|
|
11
|
+
Bash: 'command',
|
|
12
|
+
PowerShell: 'command',
|
|
13
|
+
Read: 'file_path',
|
|
14
|
+
Write: 'file_path',
|
|
15
|
+
Edit: 'file_path',
|
|
16
|
+
NotebookEdit: 'notebook_path',
|
|
17
|
+
Glob: 'pattern',
|
|
18
|
+
Grep: 'pattern',
|
|
19
|
+
WebFetch: 'url',
|
|
20
|
+
WebSearch: 'query',
|
|
21
|
+
Agent: 'description',
|
|
22
|
+
Task: 'description',
|
|
23
|
+
Skill: 'skill',
|
|
24
|
+
};
|
|
25
|
+
const HEADER_MAX = 160;
|
|
26
|
+
const LINE_MAX = 200;
|
|
27
|
+
const VALUE_MAX = 40;
|
|
28
|
+
/** Collapse whitespace and cap length with a trailing ellipsis. */
|
|
29
|
+
function squeeze(s, max) {
|
|
30
|
+
const flat = s.replace(/\s+/g, ' ').trim();
|
|
31
|
+
return flat.length <= max ? flat : flat.slice(0, max - 1) + '…';
|
|
32
|
+
}
|
|
33
|
+
/** Compact `key: value` pairs of the supplied inputs (for MCP tools and fallbacks). */
|
|
34
|
+
function compactPairs(input) {
|
|
35
|
+
const entries = Object.entries(input).filter(([, v]) => v !== undefined && v !== null && v !== '');
|
|
36
|
+
if (entries.length === 0)
|
|
37
|
+
return null;
|
|
38
|
+
const parts = entries.slice(0, 4).map(([k, v]) => `${k}: ${squeeze(typeof v === 'string' ? v : JSON.stringify(v), VALUE_MAX)}`);
|
|
39
|
+
if (entries.length > 4)
|
|
40
|
+
parts.push('…');
|
|
41
|
+
return squeeze(parts.join(', '), HEADER_MAX);
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Header line for a tool call: display title + inline argument summary.
|
|
45
|
+
* Returns null for internal tools that should stay hidden.
|
|
46
|
+
*/
|
|
47
|
+
export function formatToolUse(name, input) {
|
|
48
|
+
if (name === 'ToolSearch')
|
|
49
|
+
return null; // deferred-tool search — internal noise
|
|
50
|
+
if (name.startsWith('mcp__')) {
|
|
51
|
+
const [, server = '', ...rest] = name.split('__');
|
|
52
|
+
const tool = rest.join('__').replace(/^d360_/, '').replace(/_/g, ' ');
|
|
53
|
+
const serverPretty = server === 'document360' ? 'Document360' : server.charAt(0).toUpperCase() + server.slice(1);
|
|
54
|
+
return { title: `${serverPretty}: ${tool}`, sep: ' ', arg: compactPairs(input) };
|
|
55
|
+
}
|
|
56
|
+
const primary = PRIMARY_ARG[name];
|
|
57
|
+
const value = primary ? input[primary] : undefined;
|
|
58
|
+
if (typeof value === 'string' && value)
|
|
59
|
+
return { title: name, sep: '', arg: squeeze(value, HEADER_MAX) };
|
|
60
|
+
return { title: name, sep: '', arg: compactPairs(input) };
|
|
61
|
+
}
|
|
62
|
+
/** Pull a human label out of a list item (D360 payloads carry name/title/id). */
|
|
63
|
+
function itemLabel(item) {
|
|
64
|
+
if (item === null || typeof item !== 'object')
|
|
65
|
+
return typeof item === 'string' ? item : null;
|
|
66
|
+
const o = item;
|
|
67
|
+
for (const key of ['name', 'title', 'slug', 'id']) {
|
|
68
|
+
if (typeof o[key] === 'string' && o[key])
|
|
69
|
+
return o[key];
|
|
70
|
+
}
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Tool-aware summary for JSON payloads (our D360 tools return pretty-printed JSON):
|
|
75
|
+
* arrays → "N items" + one label per line; objects → one compact line of scalar fields.
|
|
76
|
+
* Returns null when the output isn't JSON (callers fall back to raw lines).
|
|
77
|
+
*/
|
|
78
|
+
function summarizeJson(text) {
|
|
79
|
+
if (!/^[[{]/.test(text))
|
|
80
|
+
return null;
|
|
81
|
+
let data;
|
|
82
|
+
try {
|
|
83
|
+
data = JSON.parse(text);
|
|
84
|
+
}
|
|
85
|
+
catch {
|
|
86
|
+
return null;
|
|
87
|
+
}
|
|
88
|
+
if (Array.isArray(data)) {
|
|
89
|
+
const labels = data.map(itemLabel).filter((s) => s !== null);
|
|
90
|
+
const head = `${data.length} item${data.length === 1 ? '' : 's'}`;
|
|
91
|
+
if (labels.length === 0)
|
|
92
|
+
return [head];
|
|
93
|
+
return [head, ...labels.map(l => squeeze(l, LINE_MAX))];
|
|
94
|
+
}
|
|
95
|
+
if (data !== null && typeof data === 'object') {
|
|
96
|
+
const pairs = Object.entries(data)
|
|
97
|
+
.filter(([, v]) => v !== null && (typeof v === 'string' || typeof v === 'number' || typeof v === 'boolean'))
|
|
98
|
+
.slice(0, 6)
|
|
99
|
+
.map(([k, v]) => `${k}: ${squeeze(String(v), VALUE_MAX)}`);
|
|
100
|
+
return pairs.length > 0 ? [squeeze(pairs.join(' · '), LINE_MAX)] : null;
|
|
101
|
+
}
|
|
102
|
+
return null;
|
|
103
|
+
}
|
|
104
|
+
/** Preview of a tool result: first `maxLines` lines + how many were held back. */
|
|
105
|
+
export function formatToolResult(output, maxLines = 4) {
|
|
106
|
+
const text = output.replace(/\r\n/g, '\n').trimEnd();
|
|
107
|
+
if (!text)
|
|
108
|
+
return { lines: ['(no output)'], hidden: 0 };
|
|
109
|
+
const all = summarizeJson(text) ?? text.split('\n');
|
|
110
|
+
return {
|
|
111
|
+
lines: all.slice(0, maxLines).map(l => squeeze(l, LINE_MAX)),
|
|
112
|
+
hidden: Math.max(0, all.length - maxLines),
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
//# sourceMappingURL=toolFormat.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toolFormat.js","sourceRoot":"","sources":["../../src/lib/toolFormat.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAOH,uEAAuE;AACvE,MAAM,WAAW,GAA2B;IAC1C,IAAI,EAAE,SAAS;IACf,UAAU,EAAE,SAAS;IACrB,IAAI,EAAE,WAAW;IACjB,KAAK,EAAE,WAAW;IAClB,IAAI,EAAE,WAAW;IACjB,YAAY,EAAE,eAAe;IAC7B,IAAI,EAAE,SAAS;IACf,IAAI,EAAE,SAAS;IACf,QAAQ,EAAE,KAAK;IACf,SAAS,EAAE,OAAO;IAClB,KAAK,EAAE,aAAa;IACpB,IAAI,EAAE,aAAa;IACnB,KAAK,EAAE,OAAO;CACf,CAAC;AAEF,MAAM,UAAU,GAAG,GAAG,CAAC;AACvB,MAAM,QAAQ,GAAG,GAAG,CAAC;AACrB,MAAM,SAAS,GAAG,EAAE,CAAC;AAErB,mEAAmE;AACnE,SAAS,OAAO,CAAC,CAAS,EAAE,GAAW;IACrC,MAAM,IAAI,GAAG,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;IAC3C,OAAO,IAAI,CAAC,MAAM,IAAI,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,GAAG,CAAC,CAAC,GAAG,GAAG,CAAC;AAClE,CAAC;AAED,uFAAuF;AACvF,SAAS,YAAY,CAAC,KAA8B;IAClD,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC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