Merge remote-tracking branch 'github/master' into feat/agent-event-payload
# Conflicts: # docs/core-data-structures/core.i18n.yaml
This commit is contained in:
@@ -36,6 +36,7 @@ const CASES = [
|
||||
/** Build one settled assistant reply covering CJK-adjacent strong punctuation boundaries. */
|
||||
function markdownFixture(): string {
|
||||
const session = Session.create(SessionId('markdown-cjk-strong-source'))
|
||||
const eventTimeOrigin = new Date().setHours(12, 0, 0, 0)
|
||||
session.append('turn/start', { turn: 1 })
|
||||
const user = session.append('user/message', createUserMessage({
|
||||
content: [{ type: 'text', text: 'Render adjacent CJK strong emphasis.' }],
|
||||
@@ -75,7 +76,10 @@ function markdownFixture(): string {
|
||||
createdAt: 0,
|
||||
cwd: '{{cwd}}',
|
||||
}),
|
||||
...session.events.map(event => JSON.stringify(event)),
|
||||
...session.events.map(event => JSON.stringify({
|
||||
...event,
|
||||
time: eventTimeOrigin + event.seq * 1_000,
|
||||
})),
|
||||
'',
|
||||
].join('\n')
|
||||
}
|
||||
|
||||
@@ -83,6 +83,7 @@ async function stopServer(server: Server): Promise<void> {
|
||||
/** Build one closed, invariant-checked session fixture with remote and local image Markdown. */
|
||||
function markdownImageFixture(remoteUrl: string): string {
|
||||
const session = Session.create(SessionId('markdown-image-source'))
|
||||
const eventTimeOrigin = new Date().setHours(12, 0, 0, 0)
|
||||
session.append('turn/start', { turn: 1 })
|
||||
const user = session.append('user/message', createUserMessage({
|
||||
content: [{ type: 'text', text: 'Show the Markdown image policy.' }],
|
||||
@@ -126,7 +127,14 @@ function markdownImageFixture(remoteUrl: string): string {
|
||||
}
|
||||
return [
|
||||
JSON.stringify(header),
|
||||
...session.events.map(event => JSON.stringify(event)),
|
||||
// Spaced event times, exactly as the sibling markdown fixtures pin them:
|
||||
// the stats line renders its LLM segment only while the step's measured
|
||||
// milliseconds exceed zero, so a fixture that leaves the times unset lets
|
||||
// the replay's own speed decide whether the golden matches.
|
||||
...session.events.map(event => JSON.stringify({
|
||||
...event,
|
||||
time: eventTimeOrigin + event.seq * 1_000,
|
||||
})),
|
||||
'',
|
||||
].join('\n')
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ const DONE = 'INLINE_CODE_LINK_DONE'
|
||||
/** Build a settled assistant reply with linkable URL code and inert code controls. */
|
||||
function markdownFixture(linkUrl: string): string {
|
||||
const session = Session.create(SessionId('markdown-inline-code-links-source'))
|
||||
const eventTimeOrigin = new Date().setHours(12, 0, 0, 0)
|
||||
session.append('turn/start', { turn: 1 })
|
||||
const user = session.append('user/message', createUserMessage({
|
||||
content: [{ type: 'text', text: 'Show the local preview URL.' }],
|
||||
@@ -72,7 +73,10 @@ function markdownFixture(linkUrl: string): string {
|
||||
createdAt: 0,
|
||||
cwd: '{{cwd}}',
|
||||
}),
|
||||
...session.events.map(event => JSON.stringify(event)),
|
||||
...session.events.map(event => JSON.stringify({
|
||||
...event,
|
||||
time: eventTimeOrigin + event.seq * 1_000,
|
||||
})),
|
||||
'',
|
||||
].join('\n')
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
- button "Settings":
|
||||
- img
|
||||
- text: Settings
|
||||
- text: Let's start building
|
||||
- text: Let's start building Preview
|
||||
- button "Choose workspace":
|
||||
- img
|
||||
- text: workspace
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
- button "Settings":
|
||||
- img
|
||||
- text: Settings
|
||||
- text: Let's start building
|
||||
- text: Let's start building Preview
|
||||
- button "Choose workspace":
|
||||
- img
|
||||
- text: workspace
|
||||
|
||||
@@ -49,4 +49,4 @@
|
||||
- text: Select model
|
||||
- img
|
||||
- button "Send message" [disabled]
|
||||
- text: 1 turns · 1 steps Input 0 tok · Output 0 tok
|
||||
- text: 1 turns · 1 steps LLM {{duration}} Input 0 tok · Output 0 tok
|
||||
|
||||
@@ -28,4 +28,4 @@
|
||||
- text: Select model
|
||||
- img
|
||||
- button "Send message" [disabled]
|
||||
- text: 1 turns · 1 steps Input 0 tok · Output 0 tok
|
||||
- text: 1 turns · 1 steps LLM {{duration}} Input 0 tok · Output 0 tok
|
||||
|
||||
@@ -40,4 +40,4 @@
|
||||
- text: Select model
|
||||
- img
|
||||
- button "Send message" [disabled]
|
||||
- text: 1 turns · 1 steps Input 0 tok · Output 0 tok
|
||||
- text: 1 turns · 1 steps LLM {{duration}} Input 0 tok · Output 0 tok
|
||||
|
||||
@@ -21,3 +21,6 @@
|
||||
- button "添加提供方":
|
||||
- img
|
||||
- text: 添加提供方
|
||||
- button "添加自定义提供方":
|
||||
- img
|
||||
- text: 添加自定义提供方
|
||||
|
||||
@@ -69,3 +69,6 @@
|
||||
- button "添加提供方":
|
||||
- img
|
||||
- text: 添加提供方
|
||||
- button "添加自定义提供方":
|
||||
- img
|
||||
- text: 添加自定义提供方
|
||||
|
||||
@@ -18,10 +18,110 @@ function rejectStandaloneServe(): Plugin {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Vendor-chunk membership, by exact npm package name — the heavy render
|
||||
* families (math, highlight, markdown) that change only on dependency bumps.
|
||||
* Only packages workspace code imports DIRECTLY need listing: their private
|
||||
* transitive dependencies (oniguruma machinery, character tables, …) are
|
||||
* imported solely by these and rollup's chunk coloring pulls them into
|
||||
* vendor automatically. A dependency shared with index-side code falls back
|
||||
* to index — a few kB of dilution, never a correctness problem. Anything not
|
||||
* listed (react family, the vendored cordis workspace, tiny helpers like
|
||||
* anser/clsx, all workspace code) stays in the default `index` chunk, so
|
||||
* editing shell code re-hashes only index and returning clients keep the
|
||||
* cached vendor chunk.
|
||||
*
|
||||
* Boundary invariant: every member must be react-free. A package that
|
||||
* imports react/jsx-runtime must never be listed — rollup folds a module
|
||||
* shared between the entry and a manual chunk into the manual chunk, so one
|
||||
* react-importing member would drag the single shared react copy into
|
||||
* vendor. The React side of markdown/math rendering is workspace code and
|
||||
* rides index.
|
||||
*/
|
||||
const VENDOR_PACKAGES: ReadonlySet<string> = new Set([
|
||||
// math
|
||||
'katex',
|
||||
// syntax highlight (@shikijs/langs is handled separately below —
|
||||
// lazy grammars must not land here)
|
||||
'shiki',
|
||||
// markdown parse pipeline (micromark/mdast; the incremental React renderer
|
||||
// over it is workspace code)
|
||||
'mdast-util-from-markdown',
|
||||
'mdast-util-gfm',
|
||||
'mdast-util-math',
|
||||
'micromark-core-commonmark',
|
||||
'micromark-extension-gfm',
|
||||
'micromark-extension-math',
|
||||
'micromark-factory-space',
|
||||
'micromark-util-character',
|
||||
'micromark-util-classify-character',
|
||||
'micromark-util-sanitize-uri',
|
||||
'micromark-util-symbol',
|
||||
'micromark-util-types',
|
||||
])
|
||||
|
||||
/**
|
||||
* Boot grammars statically imported by ui-primitives' highlight.ts
|
||||
* (`@shikijs/langs/typescript` → `dist/typescript.mjs`, etc.). They live in
|
||||
* the same package as the lazy read-card grammars, but unlike those they are
|
||||
* part of the initial load and belong in the vendor chunk; the lazy ones must
|
||||
* stay unassigned so each keeps its own on-demand chunk.
|
||||
*/
|
||||
const BOOT_GRAMMAR_FILES: readonly string[] = [
|
||||
'dist/typescript.mjs',
|
||||
'dist/shellscript.mjs',
|
||||
'dist/json.mjs',
|
||||
]
|
||||
|
||||
/** Font asset extensions routed to assets/fonts/ (KaTeX's woff2/woff/ttf faces today). */
|
||||
const FONT_EXTENSIONS: readonly string[] = ['.woff2', '.woff', '.ttf']
|
||||
|
||||
/** npm package name of a resolved module id (the segment after the LAST `node_modules/` — pnpm nests the real package under an inner node_modules). */
|
||||
function npmPackageOf(id: string): string | undefined {
|
||||
const parts = id.split('/node_modules/')
|
||||
if (parts.length === 1) return undefined
|
||||
const [first, second] = parts[parts.length - 1].split('/')
|
||||
if (first.startsWith('.')) return undefined // .pnpm store segment, not a package
|
||||
if (first.startsWith('@')) return second === undefined ? undefined : `${first}/${second}`
|
||||
return first
|
||||
}
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [rejectStandaloneServe(), react()],
|
||||
build: {
|
||||
sourcemap: true,
|
||||
rollupOptions: {
|
||||
output: {
|
||||
// Output layout: the two main chunks stay at assets/ root; lazy
|
||||
// @shikijs/langs grammar chunks group under assets/langs/; fonts
|
||||
// (today all KaTeX faces referenced by vendor.css) group under
|
||||
// assets/fonts/. Sourcemaps need no arrangement: rollup writes each
|
||||
// .map next to its js and references it by bare relative filename.
|
||||
chunkFileNames(chunk): string {
|
||||
// Grammar chunks are recognized by their member modules, not the
|
||||
// facade: shared embedded-grammar chunks (e.g. html+javascript,
|
||||
// split out because php/ruby/mdx embed them) have no facade at all.
|
||||
// index and vendor are excluded by name — vendor legitimately
|
||||
// carries the three boot grammars.
|
||||
if (chunk.name === 'index' || chunk.name === 'vendor') return 'assets/[name]-[hash].js'
|
||||
const isLangChunk = chunk.moduleIds.some(id => id.includes('/node_modules/@shikijs/langs/'))
|
||||
return isLangChunk ? 'assets/langs/[name]-[hash].js' : 'assets/[name]-[hash].js'
|
||||
},
|
||||
assetFileNames(asset): string {
|
||||
const fileName = asset.names[0] ?? ''
|
||||
const isFont = FONT_EXTENSIONS.some(ext => fileName.endsWith(ext))
|
||||
return isFont ? 'assets/fonts/[name]-[hash][extname]' : 'assets/[name]-[hash][extname]'
|
||||
},
|
||||
manualChunks(id: string): string | undefined {
|
||||
const pkg = npmPackageOf(id)
|
||||
if (pkg === undefined) return undefined // workspace + vendored cordis: index
|
||||
if (pkg === '@shikijs/langs') {
|
||||
return BOOT_GRAMMAR_FILES.some(file => id.endsWith(`/${file}`)) ? 'vendor' : undefined
|
||||
}
|
||||
return VENDOR_PACKAGES.has(pkg) ? 'vendor' : undefined
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
resolve: {
|
||||
// Workspace packages resolve to SOURCE: package.json exports point at lib
|
||||
|
||||
Reference in New Issue
Block a user