Beautiful, AI-native markdown IDE and LLM wiki
TypeScript 2nd-brainagent-skillsclaudecodexcompany-braindocsknowledge-knowledge-baseknowledge-managementllmllm-wikillm-wiki-karpathymarkdownmarkdown-editormdmdxnotespkmsecond-brainskills
fix(ok): put desktop smoke stderr in CI artifacts (PRD-8290) (#3886)
Andrew Mikofalvy5674fe3f8708
diff --git a/.github/scripts/smoke-packaged-dmg.mjs b/.github/scripts/smoke-packaged-dmg.mjsindex 78c24750a..56adab4ec 100644--- a/.github/scripts/smoke-packaged-dmg.mjs+++ b/.github/scripts/smoke-packaged-dmg.mjs@@ -46,7 +46,7 @@ export const EXIT_CODES = {const SCRIPT_DIR = dirname(fileURLToPath(import.meta.url));const DESKTOP_DIR = resolve(SCRIPT_DIR, '..', '..', 'packages', 'desktop');const PACKAGED_CONFIG = 'playwright.packaged.config.ts';-const PACKAGED_REPORT = join('test-results', 'desktop-smoke-packaged-results.json');+export const PACKAGED_REPORT = join('test-results', 'desktop-smoke-packaged-results.json');/*** Pure verdict function. `report` is the parsed Playwright JSON report, or nulldiff --git a/.gitignore b/.gitignoreindex e6ac7b600..ed4e1952b 100644--- a/.gitignore+++ b/.gitignore@@ -14,6 +14,7 @@ tmp/.vercel/packages/content/test-results/+packages/desktop/test-results-packaged/packages/app/test-results/playwright-report/blob-report/diff --git a/biome.jsonc b/biome.jsoncindex 6c9852075..05bf0355e 100644--- a/biome.jsonc+++ b/biome.jsonc@@ -427,6 +427,7 @@"!**/.turbo","!**/tmp","!**/test-results",+ "!**/test-results-packaged","!**/playwright-report","!**/next-env.d.ts","!.claude",diff --git a/knip.config.ts b/knip.config.tsindex b61debe5e..8ad68f996 100644--- a/knip.config.ts+++ b/knip.config.ts@@ -124,7 +124,9 @@ export default {'packages/server': {entry: ['src/**/*.test.ts', 'src/parse-worker.ts'],project: 'src/**',- ignoreDependencies: ['@types/shell-quote'],+ ignoreDependencies: [+ '@types/shell-quote',+ ],},'packages/cli': {entry: ['src/**/*.test.ts', 'scripts/*.ts', 'tests/**/*.ts', 'src/parse-worker.ts'],diff --git a/packages/cli/vitest.config.ts b/packages/cli/vitest.config.tsindex fe85d21f1..594445be5 100644--- a/packages/cli/vitest.config.ts+++ b/packages/cli/vitest.config.ts@@ -6,8 +6,7 @@ import { okVitestBase } from '../../test-support/vitest.base';** Spreads the shared workspace base (`development` export-condition pin,* `bun:test` alias shim, `Bun` global facade, `import.meta.dir` transform, 30s- * timeout). The base `include` matches every `*.test.ts` under the package,- * which reproduces the file set `bun test` auto-discovered before the flip. The+ * timeout). The base `include` matches every `*.test.ts` under the package. The* black-box `tests/e2e/cli-linux-e2e.ts` deliberately omits the `.test` infix so* it stays out of this tier; it runs under `vitest.e2e.config.ts`.*/diff --git a/packages/core/src/bridge/bind-frontmatter-doc.ts b/packages/core/src/bridge/bind-frontmatter-doc.tsindex d7a845280..dfd95ef49 100644--- a/packages/core/src/bridge/bind-frontmatter-doc.ts+++ b/packages/core/src/bridge/bind-frontmatter-doc.ts@@ -1,3 +1,4 @@+import type * as Y from 'yjs';import type { Err, Ok, Result } from '../config/result.ts';import { type FrontmatterValidationError, toFrontmatterIssue } from '../frontmatter/errors.ts';diff --git a/packages/core/src/bridge/bridge-invariant.ts b/packages/core/src/bridge/bridge-invariant.tsindex 005627195..8bfdb40cd 100644--- a/packages/core/src/bridge/bridge-invariant.ts+++ b/packages/core/src/bridge/bridge-invariant.ts@@ -1,3 +1,4 @@+import { fnv1aDigest } from './hash-util.ts';export type BridgeInvariantSite = 'observer-b' | 'persistence' | 'test-harness';diff --git a/packages/core/src/bridge/compose.ts b/packages/core/src/bridge/compose.tsindex f4cc8a286..2a597ec3d 100644--- a/packages/core/src/bridge/compose.ts+++ b/packages/core/src/bridge/compose.ts@@ -1,3 +1,4 @@+import { prependFrontmatter, stripFrontmatter } from '../extensions/frontmatter.ts';export type ComposeAdjustment = 'none' | 'body' | 'frontmatter' | 'unresolved';diff --git a/packages/core/src/bridge/divergence-locate.ts b/packages/core/src/bridge/divergence-locate.tsindex 6b505314d..d979f4b39 100644--- a/packages/core/src/bridge/divergence-locate.ts+++ b/packages/core/src/bridge/divergence-locate.ts@@ -1,3 +1,4 @@+import { findFirstDivergenceIndex } from './tolerance-telemetry.ts';export const BRIDGE_LINE_KINDS = [diff --git a/packages/core/src/bridge/doc-boundary-space.ts b/packages/core/src/bridge/doc-boundary-space.tsindex 8fb428b90..01ef76a9f 100644--- a/packages/core/src/bridge/doc-boundary-space.ts+++ b/packages/core/src/bridge/doc-boundary-space.ts@@ -1,3 +1,4 @@+import { FRONTMATTER_RE, stripFrontmatter } from '../extensions/frontmatter.ts';import { carriedEdgeEmpties, type DocEdgeEmpties } from '../markdown/doc-edge-blank-runs.ts';diff --git a/packages/core/src/bridge/growth-detect.ts b/packages/core/src/bridge/growth-detect.tsindex 9d9c244b0..463e89595 100644--- a/packages/core/src/bridge/growth-detect.ts+++ b/packages/core/src/bridge/growth-detect.ts@@ -1,3 +1,4 @@+const DEFAULT_MIN_SUBSTANTIVE_LINE_LENGTH = 16;export const DUPLICATION_GATE_MIN_LINE_LENGTH = 8;diff --git a/packages/core/src/bridge/intraline-predicate.ts b/packages/core/src/bridge/intraline-predicate.tsindex c43fdd7e7..0939885bb 100644--- a/packages/core/src/bridge/intraline-predicate.ts+++ b/packages/core/src/bridge/intraline-predicate.ts@@ -1,3 +1,4 @@+export function rawLineCounts(doc: string): Map<string, number> {const counts = new Map<string, number>();for (const line of doc.split('\n')) {diff --git a/packages/core/src/bridge/merge-three-way.ts b/packages/core/src/bridge/merge-three-way.tsindex 251560a35..c0dc65705 100644--- a/packages/core/src/bridge/merge-three-way.ts+++ b/packages/core/src/bridge/merge-three-way.ts@@ -65,6 +65,7 @@ export function tryLineLevelCombine(return { clean: true, merged };}+export type BridgeMergeContentLossSide = 'user' | 'agent';export type BridgeMergeContentLossWhich = 'substring' | 'order' | 'growth';diff --git a/packages/core/src/bridge/normalize.ts b/packages/core/src/bridge/normalize.tsindex 01ac80099..dcc5b0690 100644--- a/packages/core/src/bridge/normalize.ts+++ b/packages/core/src/bridge/normalize.ts@@ -1,3 +1,4 @@+import { stripFrontmatter } from '../extensions/frontmatter.ts';import { bodyEdgeEmpties } from './doc-boundary-space.ts';diff --git a/packages/core/src/bridge/pm-structural-equivalence.ts b/packages/core/src/bridge/pm-structural-equivalence.tsindex 754dc5cc2..0be5203e4 100644--- a/packages/core/src/bridge/pm-structural-equivalence.ts+++ b/packages/core/src/bridge/pm-structural-equivalence.ts@@ -32,6 +32,7 @@ const BR_SENTINEL: PmStructuralNode = { type: '__br__' };const BR_LITERAL_RE = /^<br\s*\/?>$/i;+interface DegradeEntry {readonly label: string;readonly severity: ToleranceClassSeverity;@@ -127,6 +128,7 @@ export interface ComparePmStructuralOptions {ignoreAttrs?: (attrKey: string) => boolean;}+/** Rebuild a node with `fn` applied to each child; identity when childless.* Shared by the degrade canonicalizers so none re-implements the walk. */function mapChildren(@@ -248,6 +250,7 @@ function applyDegrades(tree: PmStructuralNode): {return { normalized: current, fired };}+export function comparePmStructural(expected: PmStructuralNode,actual: PmStructuralNode,diff --git a/packages/core/src/bridge/subsequence.ts b/packages/core/src/bridge/subsequence.tsindex af20de1e2..dca644141 100644--- a/packages/core/src/bridge/subsequence.ts+++ b/packages/core/src/bridge/subsequence.ts@@ -1,3 +1,4 @@+/** True when `needle` is a subsequence of `haystack` (two-pointer, O(n+m)):* insertions in `haystack` are free; any dropped or substituted `needle` byte* fails. */diff --git a/packages/core/src/markdown/callout-transformer.ts b/packages/core/src/markdown/callout-transformer.tsindex 83d47404a..a363dfd54 100644--- a/packages/core/src/markdown/callout-transformer.ts+++ b/packages/core/src/markdown/callout-transformer.ts@@ -1,3 +1,4 @@+import type { Blockquote, Paragraph, Root } from 'mdast';import type { MdxJsxAttribute, MdxJsxFlowElement } from 'mdast-util-mdx';import { visit } from 'unist-util-visit';diff --git a/packages/core/src/markdown/code-fence.ts b/packages/core/src/markdown/code-fence.tsindex 9807a7e82..4499dbc92 100644--- a/packages/core/src/markdown/code-fence.ts+++ b/packages/core/src/markdown/code-fence.ts@@ -1,3 +1,4 @@+export function selectFenceChar(info: string): '`' | '~' {return info.includes('`') ? '~' : '`';}diff --git a/packages/core/src/markdown/comment-promoter.ts b/packages/core/src/markdown/comment-promoter.tsindex 7415c474a..34704165b 100644--- a/packages/core/src/markdown/comment-promoter.ts+++ b/packages/core/src/markdown/comment-promoter.ts@@ -1,3 +1,4 @@+import type { Nodes, Paragraph, PhrasingContent, Root, RootContent, Text } from 'mdast';import { SKIP, visit } from 'unist-util-visit';import type { VFile } from 'vfile';diff --git a/packages/core/src/markdown/dedent-block-jsx-close.ts b/packages/core/src/markdown/dedent-block-jsx-close.tsindex ece5c02a1..b6299a948 100644--- a/packages/core/src/markdown/dedent-block-jsx-close.ts+++ b/packages/core/src/markdown/dedent-block-jsx-close.ts@@ -1,3 +1,4 @@+import { findFencedRegions, isInsideFence } from './fence-regions.ts';const INDENTED_BLOCK_JSX_CLOSE_RE = /^([ ]{1,3})(<\/[A-Z][A-Za-z0-9_]*\s*>)([ \t]*)$/gm;diff --git a/packages/core/src/markdown/details-accordion-promoter.ts b/packages/core/src/markdown/details-accordion-promoter.tsindex 54774764a..acd398aa6 100644--- a/packages/core/src/markdown/details-accordion-promoter.ts+++ b/packages/core/src/markdown/details-accordion-promoter.ts@@ -1,3 +1,4 @@+import type { Nodes, Paragraph, Parent, Root, Text } from 'mdast';import type { MdxJsxAttribute, MdxJsxFlowElement } from 'mdast-util-mdx';import { visit } from 'unist-util-visit';diff --git a/packages/core/src/markdown/div-align-promoter.ts b/packages/core/src/markdown/div-align-promoter.tsindex 43ecdc709..ba9b56384 100644--- a/packages/core/src/markdown/div-align-promoter.ts+++ b/packages/core/src/markdown/div-align-promoter.ts@@ -1,3 +1,4 @@+import type { Nodes, Paragraph, Parent, Root, Text } from 'mdast';import type { MdxJsxFlowElement } from 'mdast-util-mdx';import { visit } from 'unist-util-visit';diff --git a/packages/core/src/markdown/fence-regions.ts b/packages/core/src/markdown/fence-regions.tsindex 6d3f3643e..4513da9bb 100644--- a/packages/core/src/markdown/fence-regions.ts+++ b/packages/core/src/markdown/fence-regions.ts@@ -1,3 +1,4 @@+const FENCE_RE = /^(`{3,}|~{3,})/gm;export function findFencedRegions(src: string): Array<[number, number]> {diff --git a/packages/core/src/markdown/fixtures/index.ts b/packages/core/src/markdown/fixtures/index.tsindex 00f5771ee..6931623c7 100644--- a/packages/core/src/markdown/fixtures/index.ts+++ b/packages/core/src/markdown/fixtures/index.ts@@ -1,3 +1,4 @@+import { readFileSync } from 'node:fs';import { dirname, resolve } from 'node:path';import { fileURLToPath } from 'node:url';@@ -8,6 +9,7 @@ function fixturePath(...segments: string[]): string {return resolve(FIXTURES_DIR, ...segments);}+interface GfmExample {section: string;markdown: string;@@ -17,6 +19,7 @@ export function loadGfmExamples(): GfmExample[] {return JSON.parse(readFileSync(fixturePath('gfm', 'examples.json'), 'utf8')) as GfmExample[];}+interface MdxCrashEntry {id: string;input: string;@@ -68,6 +71,7 @@ export function loadLargeEmbedFixtures(): LargeEmbedFixture[] {) as LargeEmbedFixture[];}+export function loadPrd6955Before(): string {return readFileSync(fixturePath('regression', 'prd-6955-before.md'), 'utf8');}@@ -76,6 +80,7 @@ export function loadPrd6955CorruptedTriplicated(): string {return readFileSync(fixturePath('regression', 'prd-6955-corrupted-triplicated.md'), 'utf8');}+export interface NgPinnedCase {id: string;name: string;@@ -92,6 +97,7 @@ export function loadNgPinnedCases(): NgPinnedCase[] {) as NgPinnedCase[];}+export function loadLargeRealistic(): string {return readFileSync(fixturePath('perf', 'large-realistic.md'), 'utf8');}diff --git a/packages/core/src/markdown/fixtures/perf/generate.ts b/packages/core/src/markdown/fixtures/perf/generate.tsindex 8b1eb8519..daa3ef82b 100644--- a/packages/core/src/markdown/fixtures/perf/generate.ts+++ b/packages/core/src/markdown/fixtures/perf/generate.ts@@ -1,3 +1,4 @@+import { writeFileSync } from 'node:fs';import { dirname, resolve } from 'node:path';import { fileURLToPath } from 'node:url';@@ -10,6 +11,7 @@ const BASELINE_ONLY_COUNTS = [500, 2500] as const;const SEED = 0xf1de1117;+function mulberry32(seed: number): () => number {let a = seed >>> 0;return () => {@@ -36,6 +38,7 @@ function pickWeighted<T>(rand: () => number, items: readonly [T, number][]): T {return items[items.length - 1][0];}+const WORDS = ['lorem','ipsum',@@ -153,6 +156,7 @@ function mdxBlock(rand: () => number): string {return `<${name}>\n\n${sentence(rand)}\n\n</${name}>`;}+type BlockKind = 'paragraph' | 'heading' | 'list' | 'code' | 'table' | 'mdx';const MIX: readonly [BlockKind, number][] = [@@ -191,6 +195,7 @@ function generateDocument(blockCount: number, seed: number): string {return `${blocks.join('\n\n')}\n`;}+function main(): void {for (const count of [...BLOCK_COUNTS, ...BASELINE_ONLY_COUNTS]) {const doc = generateDocument(count, SEED);diff --git a/packages/core/src/markdown/guard-flanking-matrix.ts b/packages/core/src/markdown/guard-flanking-matrix.tsindex 420dc0fe5..32c055c5b 100644--- a/packages/core/src/markdown/guard-flanking-matrix.ts+++ b/packages/core/src/markdown/guard-flanking-matrix.ts@@ -7,6 +7,7 @@ import {import { BACKSLASH_GUARD_SUBSTITUTIONS, encodeBackslashEscapes } from './backslash-escape-guard.ts';import { ENTITY_REF_GUARD_SUBSTITUTIONS, encodeEntityRefs } from './entity-ref-guard.ts';+export const ATTENTION_DELIMITERS = ['*', '_', '**', '~~', '=='] as const;export type FlankClass = 'whitespace' | 'punctuation' | 'other';diff --git a/packages/core/src/markdown/handler-shadow-audit.ts b/packages/core/src/markdown/handler-shadow-audit.tsindex 2653473da..283913255 100644--- a/packages/core/src/markdown/handler-shadow-audit.ts+++ b/packages/core/src/markdown/handler-shadow-audit.ts@@ -1,3 +1,4 @@+export interface HandlerShadowWitness {input: string;expect: 'byte' | 'byte-and-reparse-type';diff --git a/packages/core/src/markdown/highlight-promoter.ts b/packages/core/src/markdown/highlight-promoter.tsindex da0a81d23..5d1000cc4 100644--- a/packages/core/src/markdown/highlight-promoter.ts+++ b/packages/core/src/markdown/highlight-promoter.ts@@ -1,3 +1,4 @@+import type { Nodes, Parent, PhrasingContent, Root, Text } from 'mdast';import type { MdxJsxTextElement } from 'mdast-util-mdx';import { SKIP, visit } from 'unist-util-visit';diff --git a/packages/core/src/markdown/html-to-mdast.ts b/packages/core/src/markdown/html-to-mdast.tsindex 787315157..9681c0056 100644--- a/packages/core/src/markdown/html-to-mdast.ts+++ b/packages/core/src/markdown/html-to-mdast.ts@@ -1,3 +1,4 @@+import type { Element as HastElement, Root as HastRoot } from 'hast';import type { List, Nodes as MdastNodes, Root as MdastRoot } from 'mdast';import rehypeParse from 'rehype-parse';@@ -128,7 +129,8 @@ export function htmlToMdast(html: string, options?: HtmlToMdastOptions): MdastRothrow new HtmlPayloadTooLargeError(html.length, maxBytes);}- const processor = unified().use(rehypeParse, { fragment: true });+ const processor = unified()+ .use(rehypeParse, { fragment: true });for (const plugin of cleanupPlugins) {processor.use(plugin);diff --git a/packages/core/src/markdown/image-promoter.ts b/packages/core/src/markdown/image-promoter.tsindex 706fa9afb..994eb6917 100644--- a/packages/core/src/markdown/image-promoter.ts+++ b/packages/core/src/markdown/image-promoter.ts@@ -1,3 +1,4 @@+import type { Image, Paragraph, Root } from 'mdast';import type { MdxJsxAttribute, MdxJsxFlowElement } from 'mdast-util-mdx';import { visit } from 'unist-util-visit';diff --git a/packages/core/src/markdown/index.ts b/packages/core/src/markdown/index.tsindex 779e27500..ec1ac1b7e 100644--- a/packages/core/src/markdown/index.ts+++ b/packages/core/src/markdown/index.ts@@ -1,3 +1,4 @@+import {type FromProseMirrorOptions,fromPmMark,@@ -206,6 +207,7 @@ export class MarkdownManager {}}+const registry = createRegistry();function destructureAttrs(@@ -254,6 +256,7 @@ function destructureAttrs(return result;}+function hasDirtyDescendant(node: PmNode): boolean {let found = false;node.descendants((child) => {@@ -276,6 +279,7 @@ function effectiveDirty(node: PmNode, freshnessChecker?: StructuralFreshnessChecreturn freshnessChecker ? freshnessChecker.isDiverged(node.toJSON()) : false;}+function isEmptyMdastParagraph(node: MdastNodes): boolean {if (node.type !== 'paragraph') return false;const children = node.children ?? [];@@ -344,6 +348,7 @@ function extractTextFromMdastNodes(nodes: MdastNodes[]): string {return out;}+import {AUDIO_EXTENSIONS,FILE_ATTACHMENT_EXTENSIONS,@@ -596,6 +601,7 @@ function buildMdastToPmHandlers(}));}+if (m.emphasis) {handlers.emphasis = toPmMark(m.emphasis, (node: Emphasis) => ({sourceDelimiter: node.data?.sourceDelimiter ?? '*',@@ -676,6 +682,7 @@ function buildMdastToPmHandlers(}));}+if (m.link) {const sourceLiteralMark = m.sourceLiteral;handlers.link = (node: Link, _parent: MdastParent, state: MdastToPmState) => {@@ -973,6 +980,7 @@ function buildMdastToPmHandlers(};}+const blockUnknownHandler = (node: {type: string;position?: { start: { offset: number }; end: { offset: number } };@@ -1098,6 +1106,7 @@ function buildMdastToPmHandlers(return handlers as RemarkProseMirrorOptions['handlers'];}+function buildPmToMdastHandlers(schema: Schema,freshness: FreshnessCheckerHolder,diff --git a/packages/core/src/markdown/lint/applies-to.ts b/packages/core/src/markdown/lint/applies-to.tsindex fa0be9e86..b79e9aef7 100644--- a/packages/core/src/markdown/lint/applies-to.ts+++ b/packages/core/src/markdown/lint/applies-to.ts@@ -1,3 +1,4 @@+import picomatch from 'picomatch';import { SUPPORTED_DOC_EXTENSIONS } from '../../constants/doc-extensions.ts';diff --git a/packages/core/src/markdown/lint/config-files.ts b/packages/core/src/markdown/lint/config-files.tsindex 312c9c74b..94b34dee1 100644--- a/packages/core/src/markdown/lint/config-files.ts+++ b/packages/core/src/markdown/lint/config-files.ts@@ -1,3 +1,4 @@+const MARKDOWNLINT_JSON_CONFIG_FILES: ReadonlySet<string> = new Set(['.markdownlint.json','.markdownlint.jsonc',diff --git a/packages/core/src/markdown/lint/config-schemas.ts b/packages/core/src/markdown/lint/config-schemas.tsindex cc667b93e..7c54c0a73 100644--- a/packages/core/src/markdown/lint/config-schemas.ts+++ b/packages/core/src/markdown/lint/config-schemas.ts@@ -52,6 +52,7 @@ const fullPluginShape = Object.fromEntries(LINT_PLUGINS.map((plugin) => [plugin.id, plugin.sliceSchema]),) as z.ZodRawShape;+export const LinterConfigSchema = z.object({enabled: z.boolean(),plugins: z.object(fullPluginShape),diff --git a/packages/core/src/markdown/lint/default-config.ts b/packages/core/src/markdown/lint/default-config.tsindex d48eea5e4..a51f2ffb0 100644--- a/packages/core/src/markdown/lint/default-config.ts+++ b/packages/core/src/markdown/lint/default-config.ts@@ -6,6 +6,7 @@ export const DEFAULT_MARKDOWNLINT_CONFIG: Record<string, MarkdownlintRuleSettingMD013: false,};+export function resolveMarkdownlintConfig(rules: Record<string, MarkdownlintRuleSetting> | undefined,): Configuration {diff --git a/packages/core/src/markdown/lint/frontmatter-schema-edit.ts b/packages/core/src/markdown/lint/frontmatter-schema-edit.tsindex ef478e268..9c9542661 100644--- a/packages/core/src/markdown/lint/frontmatter-schema-edit.ts+++ b/packages/core/src/markdown/lint/frontmatter-schema-edit.ts@@ -1,3 +1,4 @@+import { CANONICAL_SCHEMA_DIALECT_URIS, DEFAULT_SCHEMA_DIALECT } from './frontmatter-validate.ts';export interface FrontmatterFieldConstraint {diff --git a/packages/core/src/markdown/lint/frontmatter-validate.ts b/packages/core/src/markdown/lint/frontmatter-validate.tsindex 5f953d667..b0e7833fd 100644--- a/packages/core/src/markdown/lint/frontmatter-validate.ts+++ b/packages/core/src/markdown/lint/frontmatter-validate.ts@@ -1,3 +1,4 @@+import Ajv, { type ValidateFunction } from 'ajv';import Ajv2019 from 'ajv/dist/2019.js';import Ajv2020 from 'ajv/dist/2020.js';diff --git a/packages/core/src/markdown/lint/index.ts b/packages/core/src/markdown/lint/index.tsindex 781226a5d..26fbc2b22 100644--- a/packages/core/src/markdown/lint/index.ts+++ b/packages/core/src/markdown/lint/index.ts@@ -1,3 +1,4 @@+import type { LintPluginFailureReporter } from './plugin-failure.ts';import { isLintPluginSelected, LINT_PLUGINS, type LinterConfig } from './plugins.ts';import type { LintDiagnostic } from './types.ts';@@ -79,7 +80,8 @@ function renderErrorMessage(error: unknown, depth = 0): string {try {const json = JSON.stringify(error);if (json !== undefined) return json;- } catch {}+ } catch {+ }}return String(error);}diff --git a/packages/core/src/markdown/lint/okf-frontmatter/materialize.ts b/packages/core/src/markdown/lint/okf-frontmatter/materialize.tsindex 7a5af097e..f438f1b16 100644--- a/packages/core/src/markdown/lint/okf-frontmatter/materialize.ts+++ b/packages/core/src/markdown/lint/okf-frontmatter/materialize.ts@@ -1,3 +1,4 @@+import type { OkfRuleId } from '../okf-rule-meta.ts';import { fileNameFor, OKF_SCHEMA_DIR, okfSchemaPathFor } from './paths.ts';import { OKF_FRONTMATTER_REGISTRY } from './registry.ts';diff --git a/packages/core/src/markdown/lint/okf-frontmatter/paths.ts b/packages/core/src/markdown/lint/okf-frontmatter/paths.tsindex 1ee913527..c290b6878 100644--- a/packages/core/src/markdown/lint/okf-frontmatter/paths.ts+++ b/packages/core/src/markdown/lint/okf-frontmatter/paths.ts@@ -1,3 +1,4 @@+import type { OkfRuleId } from '../okf-rule-meta.ts';export const OKF_SCHEMA_DIR = '.ok/okf';diff --git a/packages/core/src/markdown/lint/okf-frontmatter/registry.ts b/packages/core/src/markdown/lint/okf-frontmatter/registry.tsindex f325fbbb4..53ecb619d 100644--- a/packages/core/src/markdown/lint/okf-frontmatter/registry.ts+++ b/packages/core/src/markdown/lint/okf-frontmatter/registry.ts@@ -1,3 +1,4 @@+import { compileAppliesTo } from '../applies-to.ts';import { validateFrontmatterSource } from '../frontmatter-validate.ts';import {diff --git a/packages/core/src/markdown/lint/okf-frontmatter/schemas.ts b/packages/core/src/markdown/lint/okf-frontmatter/schemas.tsindex f1c37671b..89845d3d5 100644--- a/packages/core/src/markdown/lint/okf-frontmatter/schemas.ts+++ b/packages/core/src/markdown/lint/okf-frontmatter/schemas.ts@@ -1,3 +1,4 @@+// file-level form is deliberate: the sibling `biome-ignore` must sit on the line// oxlint-disable unicorn/no-thenablediff --git a/packages/core/src/markdown/lint/okf-project/rules.ts b/packages/core/src/markdown/lint/okf-project/rules.tsindex 6d691ae2b..8b476332e 100644--- a/packages/core/src/markdown/lint/okf-project/rules.ts+++ b/packages/core/src/markdown/lint/okf-project/rules.ts@@ -1,3 +1,4 @@+import { SUPPORTED_DOC_EXTENSIONS } from '../../../constants/doc-extensions.ts';import { isOkfRuleEnabled, type OkfRuleId, type OkfRuleToggles } from '../okf-rule-meta.ts';diff --git a/packages/core/src/markdown/lint/okf-rule-meta.ts b/packages/core/src/markdown/lint/okf-rule-meta.tsindex 4de50d79f..44913a9dc 100644--- a/packages/core/src/markdown/lint/okf-rule-meta.ts+++ b/packages/core/src/markdown/lint/okf-rule-meta.ts@@ -1,3 +1,4 @@+export const OKF_RULE_IDS = ['no-wiki-links','log-shape',diff --git a/packages/core/src/markdown/lint/okf-rules.ts b/packages/core/src/markdown/lint/okf-rules.tsindex 1d5538421..d0999b62e 100644--- a/packages/core/src/markdown/lint/okf-rules.ts+++ b/packages/core/src/markdown/lint/okf-rules.ts@@ -1,3 +1,4 @@+import { isOkfRuleEnabled, type OkfRuleId, type OkfRuleToggles } from './okf-rule-meta.ts';import type { OkfRule } from './okf-runner.ts';import { indexShape } from './rules/index-shape.ts';diff --git a/packages/core/src/markdown/lint/okf-runner.ts b/packages/core/src/markdown/lint/okf-runner.tsindex de130e3f4..fabb08d6e 100644--- a/packages/core/src/markdown/lint/okf-runner.ts+++ b/packages/core/src/markdown/lint/okf-runner.ts@@ -1,3 +1,4 @@+import type { Root } from 'mdast';import remarkFrontmatter from 'remark-frontmatter';import remarkGfm from 'remark-gfm';diff --git a/packages/core/src/markdown/lint/plugin-failure.ts b/packages/core/src/markdown/lint/plugin-failure.tsindex e7d694890..1cd0d2543 100644--- a/packages/core/src/markdown/lint/plugin-failure.ts+++ b/packages/core/src/markdown/lint/plugin-failure.ts@@ -1,3 +1,4 @@+import type { LintPluginId } from './types.ts';export interface LintPluginFailure {diff --git a/packages/core/src/markdown/lint/plugins.ts b/packages/core/src/markdown/lint/plugins.tsindex e7455ccf7..1dae8316d 100644--- a/packages/core/src/markdown/lint/plugins.ts+++ b/packages/core/src/markdown/lint/plugins.ts@@ -1,3 +1,4 @@+import { z } from 'zod';import { DEFAULT_MARKDOWNLINT_CONFIG, resolveMarkdownlintConfig } from './default-config.ts';import {@@ -23,6 +24,7 @@ import {type OkfSlice,} from './types.ts';+const MarkdownlintRuleSettingSchema = z.union([z.boolean(),z.enum(MARKDOWNLINT_RULE_SEVERITIES),diff --git a/packages/core/src/markdown/lint/rules/index-shape.ts b/packages/core/src/markdown/lint/rules/index-shape.tsindex 59fe9b87d..fcbb1b56c 100644--- a/packages/core/src/markdown/lint/rules/index-shape.ts+++ b/packages/core/src/markdown/lint/rules/index-shape.ts@@ -1,3 +1,4 @@+import type { List, ListItem } from 'mdast';import { EXIT, visit } from 'unist-util-visit';import { defineScopedOkfRule } from '../okf-runner.ts';diff --git a/packages/core/src/markdown/lint/rules/log-shape.ts b/packages/core/src/markdown/lint/rules/log-shape.tsindex e0159519f..431e4e9c8 100644--- a/packages/core/src/markdown/lint/rules/log-shape.ts+++ b/packages/core/src/markdown/lint/rules/log-shape.ts@@ -1,3 +1,4 @@+import type { Heading } from 'mdast';import { toString as headingText } from 'mdast-util-to-string';import { visit } from 'unist-util-visit';diff --git a/packages/core/src/markdown/lint/rules/no-wiki-links.ts b/packages/core/src/markdown/lint/rules/no-wiki-links.tsindex 2123e977f..f75a04d15 100644--- a/packages/core/src/markdown/lint/rules/no-wiki-links.ts+++ b/packages/core/src/markdown/lint/rules/no-wiki-links.ts@@ -1,3 +1,4 @@+import type { Point } from 'unist';import { visit } from 'unist-util-visit';import { defineOkfRule } from '../okf-runner.ts';diff --git a/packages/core/src/markdown/lint/rules/reserved-casing.ts b/packages/core/src/markdown/lint/rules/reserved-casing.tsindex 89ef3e4a9..c8b4d8f28 100644--- a/packages/core/src/markdown/lint/rules/reserved-casing.ts+++ b/packages/core/src/markdown/lint/rules/reserved-casing.ts@@ -1,3 +1,4 @@+import { SUPPORTED_DOC_EXTENSIONS } from '../../../constants/doc-extensions.ts';import { defineOkfRule } from '../okf-runner.ts';diff --git a/packages/core/src/markdown/lint/types.ts b/packages/core/src/markdown/lint/types.tsindex 2cffecae6..594830b88 100644--- a/packages/core/src/markdown/lint/types.ts+++ b/packages/core/src/markdown/lint/types.ts@@ -1,3 +1,4 @@+import type { BrokenLinkReason } from '../../schemas/api/agent-write.ts';import type { OkfRuleId } from './okf-rule-meta.ts';@@ -112,6 +113,7 @@ export interface OkfSlice {generate?: { index?: boolean };}+interface RuleOptionSpecBase {key: string;description: string;diff --git a/packages/core/src/markdown/lint/validation-counts.ts b/packages/core/src/markdown/lint/validation-counts.tsindex 98238656e..437cc539a 100644--- a/packages/core/src/markdown/lint/validation-counts.ts+++ b/packages/core/src/markdown/lint/validation-counts.ts@@ -1,3 +1,4 @@+export interface ValidationSourceCounts {errorCount: number;warningCount: number;diff --git a/packages/core/src/markdown/math-promoter.ts b/packages/core/src/markdown/math-promoter.tsindex a5b511f25..bd79424c7 100644--- a/packages/core/src/markdown/math-promoter.ts+++ b/packages/core/src/markdown/math-promoter.ts@@ -1,3 +1,4 @@+import type { Code, Root } from 'mdast';import type { Math as MdastMath } from 'mdast-util-math';import type { MdxJsxAttribute, MdxJsxFlowElement } from 'mdast-util-mdx';diff --git a/packages/core/src/markdown/mdast-to-hast-handlers.ts b/packages/core/src/markdown/mdast-to-hast-handlers.tsindex ed89371d0..00fbc0035 100644--- a/packages/core/src/markdown/mdast-to-hast-handlers.ts+++ b/packages/core/src/markdown/mdast-to-hast-handlers.ts@@ -1,3 +1,4 @@+import type { Comment, Element, ElementContent, Properties } from 'hast';import type { FootnoteDefinition, FootnoteReference } from 'mdast';import type { MdxJsxFlowElement, MdxJsxTextElement } from 'mdast-util-mdx';diff --git a/packages/core/src/markdown/mdast-to-html.ts b/packages/core/src/markdown/mdast-to-html.tsindex 8ce2b2492..df788a80d 100644--- a/packages/core/src/markdown/mdast-to-html.ts+++ b/packages/core/src/markdown/mdast-to-html.ts@@ -1,3 +1,4 @@+import type { Element, Root as HastRoot, Text as HastText } from 'hast';import type { Root as MdastRoot, Text as MdastText } from 'mdast';import type { Handler } from 'mdast-util-to-hast';diff --git a/packages/core/src/markdown/merged-walker.ts b/packages/core/src/markdown/merged-walker.tsindex bfd7e3109..fa3cfcd86 100644--- a/packages/core/src/markdown/merged-walker.ts+++ b/packages/core/src/markdown/merged-walker.ts@@ -1,3 +1,4 @@+import type { Nodes, Parent, Root } from 'mdast';import { SKIP, visit } from 'unist-util-visit';import type { VFile } from 'vfile';diff --git a/packages/core/src/markdown/mermaid-promoter.ts b/packages/core/src/markdown/mermaid-promoter.tsindex 1a897fca8..17ed2b829 100644--- a/packages/core/src/markdown/mermaid-promoter.ts+++ b/packages/core/src/markdown/mermaid-promoter.ts@@ -1,3 +1,4 @@+import type { Code, Root } from 'mdast';import type { MdxJsxAttribute, MdxJsxFlowElement } from 'mdast-util-mdx';import { visit } from 'unist-util-visit';diff --git a/packages/core/src/markdown/parse-with-fallback.ts b/packages/core/src/markdown/parse-with-fallback.tsindex d988f4b8b..4aa0490c4 100644--- a/packages/core/src/markdown/parse-with-fallback.ts+++ b/packages/core/src/markdown/parse-with-fallback.ts@@ -168,6 +168,7 @@ export function parseRecursive(}}+interface VFilePlace {offset?: number;start?: { offset?: number };@@ -186,6 +187,7 @@ function extractErrorOffset(err: unknown): number | undefined {return undefined;}+interface Region {start: number;end: number;@@ -209,6 +211,7 @@ function nearestBlankLineAfter(src: string, offset: number): number | null {return null;}+export interface TagEvent {kind: 'open' | 'close' | 'self-close';name: string;@@ -355,6 +358,7 @@ function findFallbackRegion(src: string, errorOffset: number): Region {return { start: blockStart, end: blockEnd };}+interface SourceBlock {src: string;start: number;@@ -452,6 +456,7 @@ function tryPerBlockFallback(};}+function wholeDocRawText(source: string): JSONContent {return {type: 'doc',diff --git a/packages/core/src/markdown/parser-drop-closure.ts b/packages/core/src/markdown/parser-drop-closure.tsindex e6ab4fd57..43d420187 100644--- a/packages/core/src/markdown/parser-drop-closure.ts+++ b/packages/core/src/markdown/parser-drop-closure.ts@@ -1,3 +1,4 @@+export type DroppedTokenAdjudication =| {kind: 'format-dof-axis';diff --git a/packages/core/src/markdown/pipeline.ts b/packages/core/src/markdown/pipeline.tsindex 0e3224206..55736041c 100644--- a/packages/core/src/markdown/pipeline.ts+++ b/packages/core/src/markdown/pipeline.ts@@ -1,3 +1,4 @@+import {type FromProseMirrorOptions,fromProseMirror,diff --git a/packages/core/src/markdown/position-aware-join.ts b/packages/core/src/markdown/position-aware-join.tsindex 91cdf658f..ccf06e94d 100644--- a/packages/core/src/markdown/position-aware-join.ts+++ b/packages/core/src/markdown/position-aware-join.ts@@ -1,3 +1,4 @@+import type { Join } from 'mdast-util-to-markdown';import type { Position } from 'unist';import { isBlankLineParagraph } from './zero-emission-blocks.ts';diff --git a/packages/core/src/markdown/position-slice.ts b/packages/core/src/markdown/position-slice.tsindex 0f399d34c..e5b4c9eba 100644--- a/packages/core/src/markdown/position-slice.ts+++ b/packages/core/src/markdown/position-slice.ts@@ -1,3 +1,4 @@+import type { Nodes, Root } from 'mdast';import { visit } from 'unist-util-visit';import type { VFile } from 'vfile';@@ -476,7 +477,8 @@ export function applyPositionSliceToNode(const first = source[startOff];if (first !== '[' && first !== '<' && !node.title) {node.data.sourceStyle = 'gfm-autolink';- } else if (first === '[') {+ }+ else if (first === '[') {const slice = source.slice(startOff, endOff);const closeBracketIdx = slice.lastIndexOf('](');if (closeBracketIdx !== -1) {diff --git a/packages/core/src/markdown/rehype-plugins/skip-notion-whitespace.ts b/packages/core/src/markdown/rehype-plugins/skip-notion-whitespace.tsindex db10fa54b..ca225ce9b 100644--- a/packages/core/src/markdown/rehype-plugins/skip-notion-whitespace.ts+++ b/packages/core/src/markdown/rehype-plugins/skip-notion-whitespace.ts@@ -1,3 +1,4 @@+import type { Comment, Element, Root, Text } from 'hast';import type { Plugin } from 'unified';diff --git a/packages/core/src/markdown/rehype-plugins/strip-cocoa-meta.ts b/packages/core/src/markdown/rehype-plugins/strip-cocoa-meta.tsindex 34068d103..3a2524a9a 100644--- a/packages/core/src/markdown/rehype-plugins/strip-cocoa-meta.ts+++ b/packages/core/src/markdown/rehype-plugins/strip-cocoa-meta.ts@@ -1,3 +1,4 @@+import type { Element, ElementContent, Root } from 'hast';import type { Plugin } from 'unified';diff --git a/packages/core/src/markdown/rehype-plugins/strip-gdocs-wrapper.ts b/packages/core/src/markdown/rehype-plugins/strip-gdocs-wrapper.tsindex 93151d43b..2279a0189 100644--- a/packages/core/src/markdown/rehype-plugins/strip-gdocs-wrapper.ts+++ b/packages/core/src/markdown/rehype-plugins/strip-gdocs-wrapper.ts@@ -1,3 +1,4 @@+import type { Element, Root } from 'hast';import type { Plugin } from 'unified';diff --git a/packages/core/src/markdown/rehype-plugins/strip-github-hovercard.ts b/packages/core/src/markdown/rehype-plugins/strip-github-hovercard.tsindex 188f02d83..a0f467c42 100644--- a/packages/core/src/markdown/rehype-plugins/strip-github-hovercard.ts+++ b/packages/core/src/markdown/rehype-plugins/strip-github-hovercard.ts@@ -1,3 +1,4 @@+import type { Element, Root } from 'hast';import type { Plugin } from 'unified';diff --git a/packages/core/src/markdown/rehype-plugins/strip-gmail-classes.ts b/packages/core/src/markdown/rehype-plugins/strip-gmail-classes.tsindex 4ba2c3418..4e8542a21 100644--- a/packages/core/src/markdown/rehype-plugins/strip-gmail-classes.ts+++ b/packages/core/src/markdown/rehype-plugins/strip-gmail-classes.ts@@ -1,3 +1,4 @@+import type { Element, Root } from 'hast';import type { Plugin } from 'unified';diff --git a/packages/core/src/markdown/rehype-plugins/strip-gsheets-wrapper.ts b/packages/core/src/markdown/rehype-plugins/strip-gsheets-wrapper.tsindex 1a74b1272..a3c96b24a 100644--- a/packages/core/src/markdown/rehype-plugins/strip-gsheets-wrapper.ts+++ b/packages/core/src/markdown/rehype-plugins/strip-gsheets-wrapper.ts@@ -1,3 +1,4 @@+import type { Element, ElementContent, Root } from 'hast';import type { Plugin } from 'unified';diff --git a/packages/core/src/markdown/rehype-plugins/strip-mso-styles.ts b/packages/core/src/markdown/rehype-plugins/strip-mso-styles.tsindex de35e7b79..e95cf43d6 100644--- a/packages/core/src/markdown/rehype-plugins/strip-mso-styles.ts+++ b/packages/core/src/markdown/rehype-plugins/strip-mso-styles.ts@@ -1,3 +1,4 @@+import type { Comment, Element, ElementContent, Root } from 'hast';import type { Plugin } from 'unified';diff --git a/packages/core/src/markdown/rehype-plugins/strip-slack-classes.ts b/packages/core/src/markdown/rehype-plugins/strip-slack-classes.tsindex b4be1b2ea..ffdb4d5b5 100644--- a/packages/core/src/markdown/rehype-plugins/strip-slack-classes.ts+++ b/packages/core/src/markdown/rehype-plugins/strip-slack-classes.ts@@ -1,3 +1,4 @@+import type { Element, ElementContent, Root } from 'hast';import type { Plugin } from 'unified';diff --git a/packages/core/src/markdown/rehype-plugins/strip-vscode-spans.ts b/packages/core/src/markdown/rehype-plugins/strip-vscode-spans.tsindex 3c8d88b7c..e2a96d1a7 100644--- a/packages/core/src/markdown/rehype-plugins/strip-vscode-spans.ts+++ b/packages/core/src/markdown/rehype-plugins/strip-vscode-spans.ts@@ -1,3 +1,4 @@+import type { Element, Root } from 'hast';import type { Plugin } from 'unified';diff --git a/packages/core/src/markdown/resolve-image-url.ts b/packages/core/src/markdown/resolve-image-url.tsindex cf2c9da8e..0389575ac 100644--- a/packages/core/src/markdown/resolve-image-url.ts+++ b/packages/core/src/markdown/resolve-image-url.ts@@ -1,3 +1,4 @@+import { isRelativeUrl } from './safe-url.ts';function isDevDiagnosticContext(): boolean {diff --git a/packages/core/src/markdown/safe-url.ts b/packages/core/src/markdown/safe-url.tsindex 4d3250d3a..8be632ba4 100644--- a/packages/core/src/markdown/safe-url.ts+++ b/packages/core/src/markdown/safe-url.ts@@ -1,3 +1,4 @@+export const SAFE_URL_SCHEMES = ['https', 'http', 'mailto', 'tel', 'ftp', 'sms'] as const;const SCHEME_ALT = SAFE_URL_SCHEMES.map((s) => `${s}:`).join('|');diff --git a/packages/core/src/markdown/serialize-fidelity.test-helper.ts b/packages/core/src/markdown/serialize-fidelity.test-helper.tsindex 0dd54070e..96304e7a5 100644--- a/packages/core/src/markdown/serialize-fidelity.test-helper.ts+++ b/packages/core/src/markdown/serialize-fidelity.test-helper.ts@@ -1,3 +1,4 @@+import type { JSONContent } from '@tiptap/core';import type { Nodes } from 'mdast';import { expect } from 'vitest';diff --git a/packages/core/src/markdown/serialize-helpers.ts b/packages/core/src/markdown/serialize-helpers.tsindex 7cac5b042..93798cf83 100644--- a/packages/core/src/markdown/serialize-helpers.ts+++ b/packages/core/src/markdown/serialize-helpers.ts@@ -1,3 +1,4 @@+import type { Node as PmNode } from '@tiptap/pm/model';import type {MdxJsxAttribute,diff --git a/packages/core/src/markdown/single-dollar-math-promoter.ts b/packages/core/src/markdown/single-dollar-math-promoter.tsindex b012a5aff..8c08b7a04 100644--- a/packages/core/src/markdown/single-dollar-math-promoter.ts+++ b/packages/core/src/markdown/single-dollar-math-promoter.ts@@ -1,3 +1,4 @@+import type { PhrasingContent, Root, Text } from 'mdast';import type { InlineMath } from 'mdast-util-math';import { SKIP, visit } from 'unist-util-visit';diff --git a/packages/core/src/markdown/to-markdown-handlers.ts b/packages/core/src/markdown/to-markdown-handlers.tsindex b50bea5ec..83d4af672 100644--- a/packages/core/src/markdown/to-markdown-handlers.ts+++ b/packages/core/src/markdown/to-markdown-handlers.ts@@ -1,3 +1,4 @@+import type { Nodes, Parents } from 'mdast';import type { MdxJsxAttribute, MdxJsxExpressionAttribute, MdxJsxFlowElement } from 'mdast-util-mdx';import type { Handle, Info, State } from 'mdast-util-to-markdown';diff --git a/packages/core/src/markdown/underline-promoter.ts b/packages/core/src/markdown/underline-promoter.tsindex 0f1b0f27d..6e6d73400 100644--- a/packages/core/src/markdown/underline-promoter.ts+++ b/packages/core/src/markdown/underline-promoter.ts@@ -1,3 +1,4 @@+import type { Nodes, Parent, Root } from 'mdast';import type { MdxJsxTextElement } from 'mdast-util-mdx';import { visit } from 'unist-util-visit';diff --git a/packages/core/src/markdown/unknown-mdast-guard.ts b/packages/core/src/markdown/unknown-mdast-guard.tsindex 1a082bda7..932d7d2a8 100644--- a/packages/core/src/markdown/unknown-mdast-guard.ts+++ b/packages/core/src/markdown/unknown-mdast-guard.ts@@ -1,3 +1,4 @@+import type { Root as MdastRoot } from 'mdast';import type { VFile } from 'vfile';diff --git a/packages/core/src/markdown/whitespace-char-ref.ts b/packages/core/src/markdown/whitespace-char-ref.tsindex d578476a7..ac9f5239b 100644--- a/packages/core/src/markdown/whitespace-char-ref.ts+++ b/packages/core/src/markdown/whitespace-char-ref.ts@@ -1,3 +1,4 @@+const INLINE_WHITESPACE_BY_CODE: ReadonlyMap<number, string> = new Map([[0x20, ' '],[0x09, '\t'],diff --git a/packages/core/src/markdown/wiki-link-micromark.ts b/packages/core/src/markdown/wiki-link-micromark.tsindex 6dad26200..afd9936fe 100644--- a/packages/core/src/markdown/wiki-link-micromark.ts+++ b/packages/core/src/markdown/wiki-link-micromark.ts@@ -17,6 +17,7 @@ declare module 'micromark-util-types' {}}+const CODE_BANG = 33; // !const CODE_LBRACKET = 91; // [const CODE_RBRACKET = 93; // ]@@ -260,6 +261,7 @@ export function wikiLinkSyntax(): Extension {};}+function enterWikiLink(this: CompileContext, token: Token) {this.enter({@@ -385,6 +387,7 @@ export const wikiLinkToMarkdown: {unsafe: [{ character: '[', inConstruct: ['phrasing'] }],};+const MICROMARK_EXT = wikiLinkSyntax();export function remarkWikiLink(this: Processor) {diff --git a/packages/core/vitest.config.ts b/packages/core/vitest.config.tsindex 18f0a84c0..b51d88c79 100644--- a/packages/core/vitest.config.ts+++ b/packages/core/vitest.config.ts@@ -7,7 +7,6 @@ import { okVitestBase } from '../../test-support/vitest.base';* Spreads the shared workspace base (`development` export-condition pin,* `bun:test` alias shim, `Bun` global facade, `import.meta.dir` transform, 30s* timeout). The base `include` matches every `*.test.ts` under the package; each- * `test*` npm script narrows to its tier with path positionals, mirroring what- * `bun test <dir…>` selected before the flip.+ * `test*` npm script narrows to its tier with path positionals.*/export default defineConfig({ ...okVitestBase });diff --git a/packages/desktop/playwright.config.ts b/packages/desktop/playwright.config.tsindex 23a2a9a6d..9ddab55ca 100644--- a/packages/desktop/playwright.config.ts+++ b/packages/desktop/playwright.config.ts@@ -31,9 +31,8 @@ export default defineConfig({// pattern test (create-new-project.e2e.ts at 140s). Tests that// structurally exceed this (e.g. qa-create-new-extended.e2e.ts which// launches Electron twice for cross-restart state checks) opt into a- // launches Electron twice for cross-restart state checks) opt into a- // structural reason is local to the test that needs it. Local dev keeps- // 60s so real regressions surface immediately. Same CI-vs-local+ // larger budget with `test.setTimeout`, so the structural reason is+ // local to the test that needs it. Local dev keeps// 60s so real regressions surface immediately. Same CI-vs-local// divergence shape as `retries: process.env.CI ? 2 : 0` below.timeout: process.env.CI ? 150_000 : 60_000,@@ -65,14 +64,15 @@ export default defineConfig({// parallelize meaningfully (they poke at OS-level URL scheme dispatch).workers: 1,fullyParallel: false,- // `html` reporter generates `playwright-report/` so testInfo.attach() body-- // style attachments (e.g. `main-process-stderr` from the smoke tests'- // electron-stderr capture) materialize as artifact files in the CI upload.- // Without it, the workflow's `if-no-files-found: ignore` silently skips.+ // `html` reporter generates `playwright-report/`, one of the two trees CI+ // uploads. Without it the workflow's `if-no-files-found: ignore` silently+ // skips that upload. It does NOT by itself decide whether an attachment+ // lands as a file — the carrier does, and+ // `tests/smoke/_helpers/electron-stderr.ts` owns that rule.// `open: never` suppresses the auto-open browser tab during local runs.// `json` writes machine-readable run stats so the desktop-smoke job can assert// the gate isn't vacuous (a whole-suite env-skip reads green but asserts- // nothing). Parsed by scripts/assert-smoke-not-vacuous.mjs.+ // nothing). Parsed by the CI vacuity control.reporter: [['list'],['html', { open: 'never' }],diff --git a/packages/desktop/playwright.packaged.config.ts b/packages/desktop/playwright.packaged.config.tsindex 84cdf5f73..20864c869 100644--- a/packages/desktop/playwright.packaged.config.ts+++ b/packages/desktop/playwright.packaged.config.ts@@ -37,11 +37,34 @@ export const PACKAGED_SMOKE_SUBSET = ['mcp-wiring.e2e.ts',] as const;-/** Distinct from the unpackaged report so the two never overwrite each other. */+/**+ * Distinct filename so one directory can hold both tiers' JSON reports. The+ * reports still SHARE `test-results/`; only the per-test artifact trees are+ * separated, by `outputDir` below.+ */export const PACKAGED_JSON_REPORT_PATH = 'test-results/desktop-smoke-packaged-results.json';export default defineConfig({testDir: './tests/smoke',+ // Without this, the tier would default to the unpackaged run's+ // `test-results/` and clear it at run start, taking that run's per-test+ // artifacts with it — Playwright 1.59.1, re-verify on any upgrade, not just+ // a major, since the range admits minors and this is undocumented behavior+ // of a public API.+ //+ // That was never reachable: a captured main-process stderr file exists only+ // when the smoke FAILED, a failing smoke fails its step, and this tier+ // carries no `if:` — so it skips exactly when there is something to lose.+ // The safety was that `if:` and nothing else, and one `if: !cancelled()`+ // here would have put a failing smoke's only evidence behind a clear. A+ // separate tree makes it structural instead of conditional.+ //+ // Only the artifact trees separate. A reporter's `outputFile` is its own+ // path — same 1.59.1 measurement, same re-verify-on-any-upgrade — so+ // `PACKAGED_JSON_REPORT_PATH` still lands in `test-results/` beside its+ // sibling, and nothing clears it now: fine on a fresh CI workspace, worth+ // knowing on a reused one. Both trees upload on failure.+ outputDir: 'test-results-packaged',testMatch: PACKAGED_SMOKE_SUBSET.map((file) => `**/${file}`),// Matches the unpackaged config's CI budget. A packaged launch is if anything// slower than `electron out/main/index.js` (Gatekeeper assessment, first-rundiff --git a/packages/desktop/tests/smoke/_helpers/electron-stderr.ts b/packages/desktop/tests/smoke/_helpers/electron-stderr.tsindex 8b76ed4e2..c5b2ae4e8 100644--- a/packages/desktop/tests/smoke/_helpers/electron-stderr.ts+++ b/packages/desktop/tests/smoke/_helpers/electron-stderr.ts@@ -3,36 +3,89 @@** Playwright's `_electron.launch` returns an `ElectronApplication` with a* `.process()` accessor exposing the underlying Node `ChildProcess`. The- * child's `stdout` and `stderr` are normally captured by Playwright into- * the test runner's reporter, but they DO NOT appear in CI artifacts when- * a test times out — the worker is killed mid-stream and the buffer is- * lost. The structured warns- * (`show-gate-timeout`, `whenReady-unhandled-rejection`,+ * child's `stdout` and `stderr` reach the test runner's reporter, but no+ * outcome puts them in a CI artifact on their own, and on a timeout the+ * worker is killed mid-stream and the buffer is lost outright. The+ * structured warns (`show-gate-timeout`, `whenReady-unhandled-rejection`,* `navigator-load-failed`, `theme-applied-no-window-for-sender`) are* therefore invisible at exactly the moment they would diagnose a hang.** This helper subscribes to both streams BEFORE the test body runs and- * keeps a per-test buffer. On test exit (success or failure), the buffer- * is attached to Playwright's `testInfo` as a `text/plain` artifact —- * downloadable from the workflow run, visible in the HTML report. The- * try/finally pattern in the consumer ensures the attachment fires even- * on test timeout.+ * keeps a per-test buffer. On test exit the buffer is written to a file+ * under the test's output directory and attached to Playwright's+ * `testInfo` by PATH. Fixture teardown owns the call, so it fires even+ * when a per-test timeout cancels the test body.+ *+ * WARN — attach by `path`, never by `body`. The carrier rationale lives+ * here; the sites that depend on it point at this block instead of+ * restating it. Measured against Playwright 1.59.1; re-verify on any+ * upgrade, not just a major — the range admits minors, and these are+ * behaviors of public APIs that the docs do not specify.+ *+ * A `body` attachment never touches disk — Playwright keeps the buffer+ * inline instead of writing it — so nothing lands under the test's output+ * directory. The HTML reporter then inlines a `text/` content type into+ * the compressed report payload embedded in `index.html` rather than+ * writing a file under `playwright-report/data/`; a non-text body does get+ * a `data/` file, so it is specifically the text case that leaves no file+ * behind. CI uploads exactly two trees — the test output directory and the+ * HTML report directory — so a text body is a FILE in neither. The bytes+ * do ship, embedded in that payload, but only a browser opening the report+ * (or a hand-decode of the embedded zip) reaches them, and nothing greps+ * them. The terminal reporter is no fallback: it prints an inlined text+ * body truncated to its first 300 characters, against a main-process+ * buffer measured at 26,383. A `path` attachment is copied into+ * `<outputDir>/attachments/` and hash-copied into+ * `playwright-report/data/`, so the bytes survive in both trees as files,+ * greppable and untruncated.+ *+ * The one Playwright behavior the write leans on: `testInfo.outputPath()`+ * creates the output directory as a side effect — same 1.59.1 measurement,+ * same re-verify-on-any-upgrade.+ * If it stops holding, the write throws `ENOENT`. The failure is+ * surfaced rather than silent (the walk warns, and the CI control notices+ * an absent artifact on a failing run), but the bytes are gone.** No production code dependency. Test infrastructure only.*/-import type { ElectronApplication, TestInfo } from '@playwright/test';+import type { ChildProcess } from 'node:child_process';+import { writeFileSync } from 'node:fs';+import type { TestInfo } from '@playwright/test';++/**+ * The slice of `TestInfo` an attach needs. Narrowed rather than taken+ * whole so a test double is a real value the compiler checks against+ * Playwright's own signatures, not a cast past them.+ */+export type StderrAttachTarget = Pick<TestInfo, 'outputPath' | 'attach'>;++/** The slice of the launched app a capture needs, narrowed the same way. */+export interface StderrCaptureSource {+ process(): Pick<ChildProcess, 'stdout' | 'stderr'>;+}++/**+ * Artifact name for a registered app, shared by the file on disk+ * (`<name>.txt`), the attachment name, and any message that has to tell a+ * reader which file to go looking for. One rule, one place, so a warn can+ * never name a file that was never written.+ */+function stderrArtifactName(slot: number): string {+ return slot === 0 ? 'main-process-stderr' : `main-process-stderr-${slot + 1}`;+}export interface ElectronStderrCapture {- /** Read the buffered output as a single string. */- drain(): string;/**- * Attach the current buffer to the running Playwright test as a- * `text/plain` artifact named `main-process-stderr`. Safe to call on- * test timeout — the wrapping try/finally in the test body owns the- * call site.+ * Write the current buffer to a file under the test's output directory+ * and attach THAT FILE — see the WARN in the file header for why the+ * carrier is load-bearing. Safe to call on test timeout.+ *+ * `slot` is the app's zero-based registration index; it is required, and+ * `attachCapturedStderr`'s JSDoc explains why callers should let that+ * function supply it rather than passing one here.*/- attachTo(testInfo: TestInfo): Promise<void>;+ attachTo(testInfo: StderrAttachTarget, slot: number): Promise<void>;}/**@@ -47,13 +100,18 @@ export interface ElectronStderrCapture {* to the Electron Helper subprocess when a Playwright test attempt times* out. The helper emits XPC errors to stderr during shutdown. Our* `captureElectronStderr` listener is still attached to `proc.stderr` at- * that point and dutifully buffers them. If the fixture then attaches- * that buffer to the failed-attempt's `testInfo`, Playwright's reporter+ * that point and dutifully buffers them. If the fixture then attaches the+ * capture to the failed-attempt's `testInfo`, Playwright's reporter* surfaces the attempt's `main-process-stderr` artifact in the run* output — and the reporter then counts the failed-attempt block as an* "error not part of any test", exiting the job with status 1 even when* `failOnFlakyTests: false` and the retry passes.*+ * That chain turns on WHETHER an attempt carries an attachment, not on+ * what the attachment carries, so this gate is independent of the carrier+ * rule in the file header. Worth stating because the chain was observed+ * against a body attachment and has not been re-measured since.+ ** The predicate's contract: attach iff the buffer carries diagnostic* value that justifies the cost of surfacing it. A failed-attempt that* may still retry-pass has no diagnostic value (the next attempt's@@ -72,6 +130,50 @@ export function shouldAttachStderr(return isFinalAttempt && isFailing;}+/**+ * Attach every capture registered by one test, deriving each capture's+ * slot from its registration order. This, not `attachTo`, is what a+ * fixture calls.+ *+ * Two invariants live here, and other sites point at this block rather+ * than restating them.+ *+ * SLOTS. The slot is the whole defense against a second launch+ * overwriting the first, and passing it per call put a droppable argument+ * at the one site that must never drop it — `0` is a legitimate slot, so+ * an omission is indistinguishable from a deliberate first one except by+ * the call's arity. Deriving the slots here removes the argument from the+ * call site, so the wrong call cannot be written.+ *+ * FAILURE CONTAINMENT. A failure is reported and stepped over rather than+ * thrown, and the walk continues to the next capture. Callers run their+ * process-reap and directory-cleanup contracts after this returns, and+ * those only run if control reaches them. Losing one test's diagnostics is+ * recoverable; leaking an Electron process group into the worker-teardown+ * deadline is not.+ */+export async function attachCapturedStderr(+ testInfo: StderrAttachTarget,+ captures: readonly ElectronStderrCapture[],+): Promise<void> {+ for (const [slot, capture] of captures.entries()) {+ try {+ await capture.attachTo(testInfo, slot);+ } catch (error) {+ // Name the artifact, not the slot: a zero-based index sends a reader+ // looking for the wrong filename. The write runs before the attach,+ // so the two failure modes leave different evidence and the message+ // must not send a reader hunting a file that was never created.+ const reason = error instanceof Error ? error.message : String(error);+ console.warn(+ `[electron-stderr] could not attach ${stderrArtifactName(slot)}.txt: ${reason}. ` ++ 'An attach-only failure leaves the bytes under the output directory; ' ++ 'a write failure leaves nothing there.',+ );+ }+ }+}+/*** Subscribe to the Electron app's stdout + stderr immediately. Must be* called BEFORE the test body's first await on app behavior; the@@ -80,10 +182,11 @@ export function shouldAttachStderr(** The subscription is fire-and-forget. Node's stream `data` events queue* into an array in this process; Playwright's worker exits do not- * disturb the host process's buffer. The attachment-as-text-plain at- * test end is what surfaces the buffer as a CI artifact.+ * disturb the host process's buffer. Writing that buffer to a file and+ * attaching the FILE at test end — not the `attach()` call by itself — is+ * what surfaces it as a CI artifact; see the WARN in the file header.*/-export function captureElectronStderr(app: ElectronApplication): ElectronStderrCapture {+export function captureElectronStderr(app: StderrCaptureSource): ElectronStderrCapture {const buffer: string[] = [];const proc = app.process();@@ -98,17 +201,23 @@ export function captureElectronStderr(app: ElectronApplication): ElectronStderrCproc.stderr?.on('data', onChunk('stderr'));return {- drain() {- return buffer.join('');- },- async attachTo(testInfo) {- // Empty buffer is still attached so the artifact's presence /- // absence at the path is itself a signal — "instrumentation ran"+ async attachTo(testInfo, slot) {+ // An empty buffer still produces the file so the artifact's presence+ // / absence at the path is itself a signal — "instrumentation ran"// vs "instrumentation crashed pre-launch" are distinguishable.- await testInfo.attach('main-process-stderr', {- body: buffer.join('') || '(no stdout/stderr captured)',- contentType: 'text/plain',- });+ const text = buffer.join('') || '(no stdout/stderr captured)';+ const name = stderrArtifactName(slot);+ // `outputPath` creates the test's output directory as a side effect,+ // so the write below needs no separate mkdir. Routing through it is+ // load-bearing, not stylistic: a readable path anywhere else is in+ // neither uploaded tree.+ const file = testInfo.outputPath(`${name}.txt`);+ writeFileSync(file, text, 'utf8');+ // The attachment name carries the slot too. Playwright renames a+ // path attachment to a content hash inside `playwright-report/data/`,+ // so in the tree uploaded unconditionally the name is all that says+ // which launch produced which buffer.+ await testInfo.attach(name, { path: file, contentType: 'text/plain' });},};}diff --git a/packages/desktop/tests/smoke/_helpers/smoke-test.ts b/packages/desktop/tests/smoke/_helpers/smoke-test.tsindex 5f9e63632..eab5dee5e 100644--- a/packages/desktop/tests/smoke/_helpers/smoke-test.ts+++ b/packages/desktop/tests/smoke/_helpers/smoke-test.ts@@ -5,14 +5,17 @@* smoke test must satisfy:** (1) STDERR ATTACH CONTRACT — the Electron app's stdout/stderr is- * captured during the test attempt, and the captured buffer is attached- * to `testInfo` as the `main-process-stderr` artifact ONLY when (a) this- * is the final attempt — retries exhausted — AND (b) the final attempt- * is failing. Flake-passed and success-first-try attempts skip the- * attachment because the captured buffer can carry helper-teardown XPC- * noise that Playwright's reporter would otherwise surface as "errors- * not part of any test". The gating predicate (`shouldAttachStderr`,- * exported from `./electron-stderr`) owns the decision.+ * captured during the test attempt, and the captured buffer is written+ * to a file under the test's output directory and attached to+ * `testInfo` by path as the `main-process-stderr` artifact ONLY when+ * (a) this is the final attempt — retries exhausted — AND (b) the final+ * attempt is failing. Flake-passed and success-first-try attempts skip+ * the attachment because the captured buffer can carry helper-teardown+ * XPC noise that Playwright's reporter would otherwise surface as+ * "errors not part of any test". The gating predicate+ * (`shouldAttachStderr`, exported from `./electron-stderr`) owns the+ * decision; `./electron-stderr` also owns why the attachment must carry+ * a path rather than a body to reach the CI artifacts at all.** (2) BOUNDED CLEANUP CONTRACT — every Electron process group launched* in the test is reaped within bounded time after the test body@@ -56,23 +59,23 @@* body initiates close ahead of it (enforced by the static guard at* `_helpers/no-unbounded-app-close.test.ts`).*- * Both contracts engage off the SAME registration call: `captureStderrFor(app)`+ * All three contracts engage off the SAME registration call: `captureStderrFor(app)`* after each `electron.launch(...)`. Tests do not need a separate* cleanup-registration call.** Why a fixture instead of helper-call-in-finally:*- * 1. Single source of truth. Adding both contracts to a new test is one- * line (`captureStderrFor(app)`) instead of an attach-finally and a- * close-finally per test.+ * 1. Single source of truth. Adding all three contracts to a new test is+ * one line (`captureStderrFor(app)`) instead of an attach-finally and+ * a close-finally per test.* 2. Survives test timeout. Playwright fixture cleanup runs even when* the worker kills the test body mid-await — same guarantee the* manual finally provides, but contract-as-fixture means it can't be* forgotten and can't be skipped by per-test timeout cancellation.* 3. Multi-launch tolerant. Tests that boot multiple Electron processes- * (rare today, but the switch-project case in nav-close-on-open- * already does this) register each app once; both contracts apply- * to every registered app.+ * in one test (a handful of relaunch / cross-restart specs do)+ * register each app once; every contract applies to every registered+ * app, and each gets its own stderr artifact.* 4. Centralized decisions. The attach-or-skip decision and the* bounded-cleanup loop are taken once each, so consumers cannot* accidentally regress either contract.@@ -89,6 +92,7 @@ import { rmSync } from 'node:fs';import { expect as baseExpect, test as baseTest, type ElectronApplication } from '@playwright/test';import { captureAppProcess, closeAppBounded, reapDetachedServers } from './electron-cleanup';import {+ attachCapturedStderr,captureElectronStderr,type ElectronStderrCapture,shouldAttachStderr,@@ -112,7 +116,8 @@ export interface SmokeFixtures {* Subscribes to `app.process()` streams immediately, captures the* underlying Node `ChildProcess` for later cleanup (capture must happen* WHILE the channel is alive — see file-level comment), and queues:- * 1. an attach to `testInfo` on test end (gated by `shouldAttachStderr`)+ * 1. a file-backed attach to `testInfo` on test end (gated by+ * `shouldAttachStderr`)* 2. a `closeAppBounded` cleanup on the captured ChildProcess* 3. (when `opts.cleanupDirs` is set) rmSync of each dir AFTER (2)*@@ -157,13 +162,14 @@ export const test = baseTest.extend<SmokeFixtures>({// Contract (1): stderr-attach. Skip when the predicate says the// captured buffer has no diagnostic value (success first try, flake-// passed on retry, non-final timed-out attempt that may still retry-- // pass, skipped). The captured buffer goes out of scope when this- // function returns and is reclaimed by GC. Rationale lives in- // `shouldAttachStderr`'s JSDoc.+ // pass, skipped); rationale lives in `shouldAttachStderr`'s JSDoc.+ // `attachCapturedStderr` takes the whole registration list, so this+ // call has no index-shaped argument to get wrong, and it absorbs its+ // own failures so contracts (2) and (3) below still run — both+ // documented at that function. The captured buffers go out of scope+ // when this function returns.if (shouldAttachStderr(testInfo)) {- for (const capture of captures) {- await capture.attachTo(testInfo);- }+ await attachCapturedStderr(testInfo, captures);}// Contract (2): bounded cleanup. Runs unconditionally for every// registered app, every attempt. This is the FIRST and ONLY@@ -201,9 +207,14 @@ export const test = baseTest.extend<SmokeFixtures>({for (const dir of cleanupDirs) {try {rmSync(dir, { recursive: true, force: true });- } catch {- // Defensive: post-reap residual race is rare but not impossible;- // tmpdir reaper handles GC. Swallow rather than fail the test.+ } catch (error) {+ // A post-reap residual race is rare but not impossible, and the+ // tmpdir reaper handles GC, so this must not fail the test. It+ // must still be visible: a silent catch here turns a repeatable+ // "something is still writing after the reap" signal into no+ // signal at all.+ const reason = error instanceof Error ? error.message : String(error);+ console.warn(`[smoke-test] tmp-dir cleanup failed for ${dir}: ${reason}`);}}},diff --git a/packages/desktop/tests/unit/electron-stderr-attachment-file.test.ts b/packages/desktop/tests/unit/electron-stderr-attachment-file.test.tsnew file mode 100644index 000000000..5dcb7f387--- /dev/null+++ b/packages/desktop/tests/unit/electron-stderr-attachment-file.test.ts@@ -0,0 +1,221 @@+import { mkdirSync, mkdtempSync, readFileSync, rmSync } from 'node:fs';+import { tmpdir } from 'node:os';+import { basename, dirname, join } from 'node:path';+import { PassThrough } from 'node:stream';+import type { TestInfo } from '@playwright/test';+import { afterEach, beforeEach, describe, expect, test, vi } from 'vitest';+import {+ attachCapturedStderr,+ captureElectronStderr,+ type ElectronStderrCapture,+ type StderrAttachTarget,+ type StderrCaptureSource,+} from '../smoke/_helpers/electron-stderr';++/**+ * Proves what a `main-process-stderr` attachment IS, on disk and in the+ * attach call: carrier is a `path` and never a `body`, the path is under+ * the test's own output directory, the bytes are readable there, and an+ * empty buffer still produces a file. `_helpers/electron-stderr.ts` owns+ * why each of those is load-bearing.+ *+ * The assertions are deliberately never about the call happening. An+ * attachment that regresses to a body would still "attach"; so would one+ * that writes somewhere readable outside the uploaded tree. Only a check+ * on the shape catches either.+ */++/** Options Playwright's own `attach` accepts, so the double cannot drift. */+type AttachOptions = NonNullable<Parameters<TestInfo['attach']>[1]>;++interface RecordedAttachment {+ name: string;+ options: AttachOptions;+}++let outputDir: string;+let attachments: RecordedAttachment[];++/**+ * A real value the compiler checks against Playwright's signatures. The+ * helper takes only the slice it needs, so no cast is required.+ */+const makeTestInfo = (): StderrAttachTarget => ({+ outputPath: (...segments: string[]) => {+ const target = join(outputDir, ...segments);+ mkdirSync(dirname(target), { recursive: true });+ return target;+ },+ attach: async (name, options = {}) => {+ attachments.push({ name, options });+ },+});++const makeApp = () => {+ const stdout = new PassThrough();+ const stderr = new PassThrough();+ const app: StderrCaptureSource = { process: () => ({ stdout, stderr }) };+ return { app, stdout, stderr };+};++const makeCapture = (payload: string): ElectronStderrCapture => {+ const { app, stderr } = makeApp();+ const capture = captureElectronStderr(app);+ stderr.write(payload);+ return capture;+};++/**+ * PassThrough delivers `data` on the next tick. Deterministic today: Node+ * drains the nextTick queue fully before reaching the check phase.+ */+const drainStreams = () => new Promise((resolve) => setImmediate(resolve));++const startFixture = (prefix: string) => {+ outputDir = mkdtempSync(join(tmpdir(), prefix));+ attachments = [];+};++const endFixture = () => {+ rmSync(outputDir, { recursive: true, force: true });+ vi.restoreAllMocks();+};++describe('captureElectronStderr: attachment materializes a file', () => {+ beforeEach(() => startFixture('ok-stderr-attach-'));+ afterEach(endFixture);++ test('attaches a path under the output directory, not a body', async () => {+ const { app, stderr } = makeApp();+ const capture = captureElectronStderr(app);+ stderr.write('show-gate-timeout after 4000ms\n');+ await drainStreams();++ await capture.attachTo(makeTestInfo(), 0);++ expect(attachments).toHaveLength(1);+ const [{ name, options }] = attachments;+ expect(name).toBe('main-process-stderr');+ expect(options.contentType).toBe('text/plain');+ // The carrier assertion. A `body` leaves no file in either tree CI+ // uploads, which is the whole defect.+ expect(options.body).toBeUndefined();+ expect(typeof options.path).toBe('string');+ // The destination assertion. A readable path outside the test's own+ // output directory satisfies everything above and is still in neither+ // tree CI uploads.+ expect(options.path as string).toContain(outputDir);++ const written = readFileSync(options.path as string, 'utf8');+ expect(written).toContain('show-gate-timeout after 4000ms');+ expect(written).toContain('[stderr] ');+ });++ test('an empty buffer still produces a file, so a missing file stays a signal', async () => {+ const { app } = makeApp();+ const capture = captureElectronStderr(app);++ await capture.attachTo(makeTestInfo(), 0);++ const written = readFileSync(attachments[0].options.path as string, 'utf8');+ expect(written).toBe('(no stdout/stderr captured)');+ });++ test('stdout and stderr are both captured, each tagged with its stream', async () => {+ const { app, stdout, stderr } = makeApp();+ const capture = captureElectronStderr(app);+ stdout.write('renderer ready\n');+ stderr.write('navigator-load-failed\n');+ await drainStreams();++ await capture.attachTo(makeTestInfo(), 0);++ const written = readFileSync(attachments[0].options.path as string, 'utf8');+ expect(written).toContain('[stdout] renderer ready');+ expect(written).toContain('[stderr] navigator-load-failed');+ });+});++/**+ * Pins the entry point a fixture actually calls. Per-slot correctness in+ * `attachTo` is worth nothing if the slots are never supplied, and the+ * supplier is this walk — so it is the walk that has to be exercised, not+ * a hand-fed index.+ */+describe('attachCapturedStderr: the registration walk a fixture calls', () => {+ beforeEach(() => startFixture('ok-stderr-walk-'));+ afterEach(endFixture);++ test('two registered apps get distinct files AND distinct attachment names', async () => {+ const first = makeCapture('from the first launch\n');+ const second = makeCapture('from the second launch\n');+ await drainStreams();++ await attachCapturedStderr(makeTestInfo(), [first, second]);++ expect(attachments.map((a) => a.name)).toEqual([+ 'main-process-stderr',+ 'main-process-stderr-2',+ ]);+ const pathA = attachments[0].options.path as string;+ const pathB = attachments[1].options.path as string;+ expect(basename(pathA)).toBe('main-process-stderr.txt');+ expect(basename(pathB)).toBe('main-process-stderr-2.txt');+ // The property the slots exist for: the second launch did not land on+ // top of the first.+ expect(readFileSync(pathA, 'utf8')).toContain('from the first launch');+ expect(readFileSync(pathB, 'utf8')).toContain('from the second launch');+ });++ test('one capture failing does not throw, and the next capture still lands', async () => {+ const warn = vi.spyOn(console, 'warn').mockImplementation(() => {});+ const exploding: ElectronStderrCapture = {+ attachTo: async () => {+ throw new Error('output dir vanished');+ },+ };+ const healthy = makeCapture('second launch survived\n');+ await drainStreams();++ // Must resolve — see FAILURE CONTAINMENT on `attachCapturedStderr`.+ await expect(+ attachCapturedStderr(makeTestInfo(), [exploding, healthy]),+ ).resolves.toBeUndefined();++ // The load-bearing half — the SECOND capture still produced its file.+ const survivor = attachments.find((a) => a.name === 'main-process-stderr-2');+ expect(survivor).toBeDefined();+ expect(readFileSync(survivor?.options.path as string, 'utf8')).toContain(+ 'second launch survived',+ );+ // Reported, not swallowed, and naming the artifact rather than the slot.+ expect(warn).toHaveBeenCalledTimes(1);+ expect(warn.mock.calls[0][0]).toContain('main-process-stderr.txt');+ expect(warn.mock.calls[0][0]).toContain('output dir vanished');+ });++ test('a real capture whose attach throws still leaves the file on disk', async () => {+ const warn = vi.spyOn(console, 'warn').mockImplementation(() => {});+ const capture = makeCapture('bytes written before the attach threw\n');+ await drainStreams();+ const rejecting: StderrAttachTarget = {+ ...makeTestInfo(),+ attach: async () => {+ throw new Error('testInfo torn down');+ },+ };++ await attachCapturedStderr(rejecting, [capture]);++ // The warn promises the file may still be there; this is that promise+ // under test, and it is what the CI artifact control depends on.+ const written = readFileSync(join(outputDir, 'main-process-stderr.txt'), 'utf8');+ expect(written).toContain('bytes written before the attach threw');+ expect(warn).toHaveBeenCalledTimes(1);+ });++ test('no registered apps attaches nothing', async () => {+ await attachCapturedStderr(makeTestInfo(), []);+ expect(attachments).toHaveLength(0);+ });+});diff --git a/packages/desktop/tests/unit/packaged-report-path.test.mjs b/packages/desktop/tests/unit/packaged-report-path.test.mjsnew file mode 100644index 000000000..b0f166ef7--- /dev/null+++ b/packages/desktop/tests/unit/packaged-report-path.test.mjs@@ -0,0 +1,35 @@+import { sep } from 'node:path';+import { describe, expect, test } from 'vitest';+import { PACKAGED_REPORT } from '../../../../.github/scripts/smoke-packaged-dmg.mjs';+import { PACKAGED_JSON_REPORT_PATH } from '../../playwright.packaged.config.ts';++/**+ * The release driver hardcodes the packaged report path; the config owns it.+ * Nothing in the type system relates the two, and the release workflow overlays+ * the driver while pinning the config to a tag, so they can move apart.+ *+ * The trap is specific: per-test ARTIFACTS go to `test-results-packaged/` while+ * the JSON report deliberately stays in `test-results/`, which makes "align the+ * driver with the artifact tree" a plausible and wrong edit.+ *+ * This lives in `packages/desktop/tests/unit/` because both values are real+ * here — the config is imported by `playwright-packaged-config.test.ts` in this+ * directory, and `verify-native-config-driver.test.mjs` beside it already+ * reaches a `.mjs` driver four levels up. Comparing values rather than reading+ * either as source keeps the guard blind to formatting: hoisting a literal into+ * a call, a template literal, or a type annotation changes no path and must not+ * fail this.+ */+describe('packaged report path', () => {+ test('the release driver and the Playwright config name the same file', () => {+ // `join` yields the platform separator; the config declares POSIX.+ expect(PACKAGED_REPORT.split(sep).join('/')).toBe(PACKAGED_JSON_REPORT_PATH);+ });++ test('and that file is the one the workflow reads', () => {+ // A coordinated rename of both sides would satisfy the equality above while+ // leaving the third copy — hardcoded in the desktop-smoke vacuity step —+ // pointing at a report nobody writes.+ expect(PACKAGED_JSON_REPORT_PATH).toBe('test-results/desktop-smoke-packaged-results.json');+ });+});diff --git a/packages/desktop/tests/unit/playwright-packaged-config.test.ts b/packages/desktop/tests/unit/playwright-packaged-config.test.tsindex 2613f7492..946698ba9 100644--- a/packages/desktop/tests/unit/playwright-packaged-config.test.ts+++ b/packages/desktop/tests/unit/playwright-packaged-config.test.ts@@ -50,6 +50,13 @@ describe('playwright.packaged.config', () => {expect(json?.[1]?.outputFile).toBe(PACKAGED_JSON_REPORT_PATH);});+ it('writes its per-test artifacts to a tree the unpackaged tier does not share', () => {+ // The config owns why the trees are separate. Pinned here because+ // dropping the line brings the collision back silently.+ expect(packagedConfig.outputDir).toBe('test-results-packaged');+ expect(unpackagedSource).not.toContain('test-results-packaged');+ });+it('leaves the required desktop-smoke check untouched', () => {// A `projects` array on the unpackaged config would change// testInfo.project.retries, which electron-stderr.ts reads. The packageddiff --git a/packages/desktop/tests/unit/smoke-test-fixture-attach-conditional.test.ts b/packages/desktop/tests/unit/smoke-test-fixture-attach-conditional.test.tsindex d0bdb3faf..a59301bc7 100644--- a/packages/desktop/tests/unit/smoke-test-fixture-attach-conditional.test.ts+++ b/packages/desktop/tests/unit/smoke-test-fixture-attach-conditional.test.ts@@ -4,25 +4,13 @@ import { shouldAttachStderr } from '../smoke/_helpers/electron-stderr';/*** Pins the conditional-attach predicate that gates whether the smoke-test- * `captureStderrFor` fixture writes its captured `main-process-stderr`- * artifact to Playwright's `testInfo`.+ * `captureStderrFor` fixture surfaces its captured `main-process-stderr`+ * artifact on `testInfo`.*- * Why this predicate is load-bearing: when a smoke test attempt times out- * on a CI runner under load, macOS kills the Electron Helper subprocess- * mid-teardown, and the helper emits XPC errors to stderr during shutdown- * (`Electron Helper[…] XPC error for connection com…`). Those errors get- * captured into the fixture's per-test buffer. If the fixture then- * unconditionally attaches that buffer to `testInfo`, Playwright's- * reporter surfaces the failed-attempt block AND its `main-process-stderr`- * attachment in the run output, even when the retry succeeds and the test- * is reported as "flaky" (passed). The reporter then counts the- * failed-attempt block as an "error not part of any test", which exits the- * job with status 1 — even with `failOnFlakyTests: false`.- *- * The fix is to attach iff (a) this is the FINAL attempt (retries- * exhausted) AND (b) the final attempt is failing. Non-final failed- * attempts that may yet retry-pass DO NOT attach — their captured stderr- * is informational at best and exit-1-causing at worst.+ * `shouldAttachStderr`'s JSDoc in `_helpers/electron-stderr.ts` owns why+ * the predicate exists — the XPC-kill to reporter to exit-1 chain, the+ * final-attempt-only rule it produces, and the caveat about what that+ * chain has and has not been re-measured against.** If you change the predicate's truth table, you are changing the contract* between the smoke fixture and Playwright's flake-tolerance gate.diff --git a/packages/desktop/vitest.config.ts b/packages/desktop/vitest.config.tsindex 65e80eb34..d1045e12b 100644--- a/packages/desktop/vitest.config.ts+++ b/packages/desktop/vitest.config.ts@@ -10,10 +10,12 @@ import { okVitestBase } from '../../test-support/vitest.base';* utility processes and never touch a DOM, so the base `node` environment is* correct — no jsdom project.*- * The include adds `**\/*.test.mjs`: the base glob is `**\/*.test.ts?(x)`, which- * would miss the two native-driver verification tests written as `.mjs`. Both- * globs together reproduce the file set `bun test` auto-discovered before the- * flip.+ * The include adds `**\/*.test.mjs`: the base glob is `**\/*.test.ts?(x)`, so+ * on its own it would miss any suite written as `.mjs` — e.g. the guards that+ * import a plain `.mjs` driver directly rather than through TypeScript.+ * Keep the glob broad: narrowing it to match today's filenames would+ * un-discover the next one silently, with vitest reporting fewer tests and no+ * error.*/export default defineConfig({...okVitestBase,diff --git a/packages/server/vitest.config.ts b/packages/server/vitest.config.tsindex 3b99f7862..81512476f 100644--- a/packages/server/vitest.config.ts+++ b/packages/server/vitest.config.ts@@ -6,7 +6,6 @@ import { okVitestBase } from '../../test-support/vitest.base';** Spreads the shared workspace base (`development` export-condition pin,* `bun:test` alias shim, `Bun` global facade, `import.meta.dir` transform, 30s- * timeout). The base `include` matches every `*.test.ts` under the package,- * reproducing the file set `bun test` auto-discovered before the flip.+ * timeout). The base `include` matches every `*.test.ts` under the package.*/export default defineConfig({ ...okVitestBase });diff --git a/turbo.json b/turbo.jsonindex e5e7a75c1..9a40ec77b 100644--- a/turbo.json+++ b/turbo.json@@ -60,6 +60,24 @@"cache": true,"inputs": ["src/**/*.ts", "src/**/*.tsx", "src/**/*.json", "tests/contract/**/*.ts"]},+ "@inkeep/open-knowledge-desktop#test": {+ "dependsOn": ["^build"],+ "cache": true,+ "inputs": [+ "$TURBO_DEFAULT$",+ "!CHANGELOG.md",+ "!README.md",+ "../../biome.jsonc",+ "../../biome-plugins/**",+ "../../test-support/**",+ "../../.github/scripts/smoke-packaged-dmg.mjs",+ "../../scripts/verify-native-config-in-packaged-dmg.mjs",+ "../../scripts/verify-keyring-in-packaged-dmg.mjs",+ "../app/*.ts",+ "../app/*.html",+ "../app/src/**"+ ]+ },"@inkeep/md-conformance#test": {"dependsOn": ["^build"],"cache": true,