Beautiful, AI-native markdown IDE and LLM wiki
TypeScript 2nd-brainagent-skillsclaudecodexcompany-braindocsknowledge-knowledge-baseknowledge-managementllmllm-wikillm-wiki-karpathymarkdownmarkdown-editormdmdxnotespkmsecond-brainskills
Hide Windows console windows for server subprocesses (#2514)
miles-kt-inkeep2cd01ce3c09c
diff --git a/.changeset/windows-hide-git-subprocesses.md b/.changeset/windows-hide-git-subprocesses.mdnew file mode 100644index 000000000..e0a662a9b--- /dev/null+++ b/.changeset/windows-hide-git-subprocesses.md@@ -0,0 +1,5 @@+---+"@inkeep/open-knowledge": patch+---++Hide server-launched Git and helper subprocess console windows on Windows by setting hidden console spawn options on direct child-process calls.diff --git a/packages/cli/src/auth/gh-detect.test.ts b/packages/cli/src/auth/gh-detect.test.tsindex e80df2199..64b48ed27 100644--- a/packages/cli/src/auth/gh-detect.test.ts+++ b/packages/cli/src/auth/gh-detect.test.ts@@ -35,6 +35,24 @@ describe('detectGh', () => {expect(calls[0]).toBe('gh auth token --hostname github.acme.com');});+ test('hides Windows console windows when probing gh auth token', () => {+ let seenOptions: unknown;+ const exec = ((_cmd: string, _args: readonly string[], options?: unknown) => {+ seenOptions = options;+ return 'ghu_hidden';+ }) as unknown as ExecFileSyncFn;++ const result = detectGh(undefined, { _exec: exec, _fileExists: () => false });++ expect(result).toEqual({ available: true, token: 'ghu_hidden' });+ expect(seenOptions).toMatchObject({+ encoding: 'utf-8',+ timeout: 5000,+ windowsHide: true,+ });+ expect((seenOptions as { stdio?: unknown }).stdio).toEqual(['ignore', 'pipe', 'pipe']);+ });+test('returns available:false when bare gh and no known paths exist', () => {const { exec } = makeExec({});const result = detectGh(undefined, { _exec: exec, _fileExists: () => false });diff --git a/packages/cli/src/auth/gh-detect.ts b/packages/cli/src/auth/gh-detect.tsindex 566de7b08..450e24858 100644--- a/packages/cli/src/auth/gh-detect.ts+++ b/packages/cli/src/auth/gh-detect.ts@@ -1,4 +1,4 @@-import { execFileSync } from 'node:child_process';+import { type ExecFileSyncOptionsWithStringEncoding, execFileSync } from 'node:child_process';import { existsSync } from 'node:fs';export interface GhDetectResult {@@ -25,6 +25,13 @@ const KNOWN_GH_PATHS: readonly string[] = ['/usr/bin/gh', // Linux distro packages];+const GH_AUTH_TOKEN_OPTIONS: ExecFileSyncOptionsWithStringEncoding = {+ encoding: 'utf-8',+ stdio: ['ignore', 'pipe', 'pipe'],+ timeout: 5000,+ windowsHide: true,+};+interface DetectGhOptions {/** Injectable for tests. */_exec?: ExecFileSyncFn;@@ -53,13 +60,7 @@ export function detectGh(host?: string, options: DetectGhOptions = {}): GhDetectfor (const cmd of candidates) {try {- const token = exec(cmd, args, {- encoding: 'utf-8',- stdio: ['ignore', 'pipe', 'pipe'],- timeout: 5000,- })- .toString()- .trim();+ const token = exec(cmd, args, GH_AUTH_TOKEN_OPTIONS).toString().trim();if (token.length > 0) return { available: true, token };} catch {// Try next candidatediff --git a/packages/core/src/bridge/bind-frontmatter-doc.ts b/packages/core/src/bridge/bind-frontmatter-doc.tsindex c014b1413..8f9d95287 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/doc-boundary-space.ts b/packages/core/src/bridge/doc-boundary-space.tsindex 8890f6739..c18c086d5 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';const LEADING_BOUNDARY_RE = /^(?:\r?\n)+/;diff --git a/packages/core/src/bridge/merge-three-way.ts b/packages/core/src/bridge/merge-three-way.tsindex b0a80fbd9..864bc7245 100644--- a/packages/core/src/bridge/merge-three-way.ts+++ b/packages/core/src/bridge/merge-three-way.ts@@ -37,6 +37,7 @@ function mergeThreeWayImpl(baseline: string, userText: string, agentText: stringreturn parts.join('\n');}+export type BridgeMergeContentLossSide = 'user' | 'agent';export type BridgeMergeContentLossWhich = 'substring' | 'order';diff --git a/packages/core/src/bridge/normalize.ts b/packages/core/src/bridge/normalize.tsindex e67f33b40..592f0b956 100644--- a/packages/core/src/bridge/normalize.ts+++ b/packages/core/src/bridge/normalize.ts@@ -1,3 +1,4 @@+const COMMONMARK_ESCAPE_RE = /\\([!"#$%&'()*+,\-./:;<=>?@[\]^_`{|}~])/g;const TABLE_ALIGN_ROW_RE = /^\s*\|?\s*:?-+:?\s*(\|\s*:?-+:?\s*)+\|?\s*$/;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/comment-promoter.ts b/packages/core/src/markdown/comment-promoter.tsindex 193e286b0..47f0d07e4 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/fence-regions.ts b/packages/core/src/markdown/fence-regions.tsindex c7518d614..fb5ac8e8a 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 f758cf737..7a22e8016 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 78fdfeb02..2f082e6d0 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 { Root as HastRoot } from 'hast';import type { Root as MdastRoot } from 'mdast';import rehypeParse from 'rehype-parse';@@ -75,7 +76,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 58be35302..c58d0847d 100644--- a/packages/core/src/markdown/index.ts+++ b/packages/core/src/markdown/index.ts@@ -1,3 +1,4 @@+import {type FromProseMirrorOptions,fromPmMark,@@ -196,6 +197,7 @@ export class MarkdownManager {}}+const registry = createRegistry();function destructureAttrs(@@ -244,6 +246,7 @@ function destructureAttrs(return result;}+function hasDirtyDescendant(node: PmNode): boolean {let found = false;node.descendants((child) => {@@ -263,6 +266,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 ?? [];@@ -331,6 +335,7 @@ function extractTextFromMdastNodes(nodes: MdastNodes[]): string {return out;}+import {AUDIO_EXTENSIONS,FILE_ATTACHMENT_EXTENSIONS,@@ -580,6 +585,7 @@ function buildMdastToPmHandlers(}));}+if (m.emphasis) {handlers.emphasis = toPmMark(m.emphasis, (node: Emphasis) => ({sourceDelimiter: node.data?.sourceDelimiter ?? '*',@@ -659,6 +665,7 @@ function buildMdastToPmHandlers(}));}+if (m.link) {const sourceLiteralMark = m.sourceLiteral;handlers.link = (node: Link, _parent: MdastParent, state: MdastToPmState) => {@@ -937,6 +944,7 @@ function buildMdastToPmHandlers(};}+const blockUnknownHandler = (node: {type: string;position?: { start: { offset: number }; end: { offset: number } };@@ -1062,6 +1070,7 @@ function buildMdastToPmHandlers(return handlers as RemarkProseMirrorOptions['handlers'];}+function buildPmToMdastHandlers(schema: Schema,freshness: FreshnessCheckerHolder,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 679c72ef7..f84967798 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 35d74b85e..a58f8c720 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 9864b3b60..7e4a9a48b 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 5d6db7aa8..5b9550e90 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 248685cfe..4ac5731e7 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';diff --git a/packages/core/src/markdown/position-slice.ts b/packages/core/src/markdown/position-slice.tsindex 50a193a16..240be90e6 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';@@ -466,7 +467,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-helpers.ts b/packages/core/src/markdown/serialize-helpers.tsindex 46cc6a074..542204403 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, MdxJsxExpressionAttribute, MdxJsxFlowElement } from 'mdast-util-mdx';import type { PropDef, SerializeContext } from '../registry/types.ts';diff --git a/packages/core/src/markdown/single-dollar-math-promoter.ts b/packages/core/src/markdown/single-dollar-math-promoter.tsindex be97d4d62..fe73659e6 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 1a2fb5d50..e1161455b 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/unknown-mdast-guard.ts b/packages/core/src/markdown/unknown-mdast-guard.tsindex cd245c38c..c5bfd2386 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 a100cad76..1b75ba564 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/server/src/api-extension.ts b/packages/server/src/api-extension.tsindex 6f3e69974..6a3e8186b 100644--- a/packages/server/src/api-extension.ts+++ b/packages/server/src/api-extension.ts@@ -6,7 +6,7 @@* and the Vite dev plugin.*/-import { spawn } from 'node:child_process';+import { type SpawnOptions, spawn } from 'node:child_process';import { createHash, randomUUID } from 'node:crypto';import {closeSync,@@ -423,6 +423,7 @@ import {import { getBootTimings } from './boot-timings.ts';import { composeAndWriteRawBody, replaceRawBody } from './bridge-intake.ts';import { isConfigDoc, isSystemDoc } from './cc1-broadcast.ts';+import { withHiddenWindowsConsole } from './child-process-windows-hide.ts';import type { ResolveStrategy } from './conflict-storage.ts';import type { ContentFilter } from './content-filter.ts';import {@@ -11023,6 +11024,15 @@ export function createApiExtension(options: ApiExtensionOptions): Extension {const LOCAL_OP_TIMEOUT_MS = 10 * 60 * 1000;/** Max time to wait for a spawned server's lock file to show a port > 0. */const LOCAL_OP_OPEN_TIMEOUT_MS = 45_000;+ const LOCAL_OP_STDERR_ONLY_OPTIONS: { stdio: ['ignore', 'ignore', 'pipe'] } = {+ stdio: ['ignore', 'ignore', 'pipe'],+ };+ const LOCAL_OP_PIPE_STDIO_OPTIONS: { stdio: ['ignore', 'pipe', 'pipe'] } = {+ stdio: ['ignore', 'pipe', 'pipe'],+ };+ const LOCAL_OP_IGNORED_STDIO_OPTIONS: Pick<SpawnOptions, 'stdio'> = {+ stdio: 'ignore',+ };/*** POST /api/local-op/clone@@ -11296,15 +11306,19 @@ export function createApiExtension(options: ApiExtensionOptions): Extension {const spawnAndAwaitUi = async (cliCmd: 'ui' | 'start',): Promise<{ port: number } | { error: string; exited: boolean }> => {- const child = spawn(cmd, buildArgs(cliCmd), {- cwd: absDir,- detached: true,- stdio: ['ignore', 'ignore', 'pipe'],- // Explicit `interactive` — `OK_LOCK_KIND` may be inherited from a- // surrounding MCP-spawn parent and we don't want a user-driven- // clone relay to mark its child server as `mcp-spawned`.- env: { ...process.env, OK_LOCK_KIND: 'interactive' },- });+ const child = spawn(+ cmd,+ buildArgs(cliCmd),+ withHiddenWindowsConsole({+ ...LOCAL_OP_STDERR_ONLY_OPTIONS,+ cwd: absDir,+ detached: true,+ // Explicit `interactive` — `OK_LOCK_KIND` may be inherited from a+ // surrounding MCP-spawn parent and we don't want a user-driven+ // clone relay to mark its child server as `mcp-spawned`.+ env: { ...process.env, OK_LOCK_KIND: 'interactive' },+ }),+ );const stderrChunks: Buffer[] = [];child.stderr?.on('data', (chunk: Buffer) => {@@ -11793,10 +11807,14 @@ export function createApiExtension(options: ApiExtensionOptions): Extension {const spawnArgs = [...baseArgs, 'auth', 'status', '--json', '--host', host];const output = await new Promise<string>((resolve, reject) => {- const child = spawn(cmd, spawnArgs, {- stdio: ['ignore', 'pipe', 'pipe'],- env: { ...process.env },- });+ const child = spawn(+ cmd,+ spawnArgs,+ withHiddenWindowsConsole({+ ...LOCAL_OP_PIPE_STDIO_OPTIONS,+ env: { ...process.env },+ }),+ );let timedOut = false;const killTimer = setTimeout(() => {timedOut = true;@@ -11929,10 +11947,14 @@ export function createApiExtension(options: ApiExtensionOptions): Extension {let settled = false;let stdoutBuffer = '';- const child = spawn(cmd, spawnArgs, {- stdio: ['ignore', 'pipe', 'pipe'],- env: { ...process.env },- });+ const child = spawn(+ cmd,+ spawnArgs,+ withHiddenWindowsConsole({+ ...LOCAL_OP_PIPE_STDIO_OPTIONS,+ env: { ...process.env },+ }),+ );const killTimer = setTimeout(() => {child.kill('SIGTERM');@@ -12063,10 +12085,14 @@ export function createApiExtension(options: ApiExtensionOptions): Extension {const spawnArgs = [...baseArgs, 'auth', 'signout', '--host', host];await new Promise<void>((resolve, reject) => {- const child = spawn(cmd, spawnArgs, {- stdio: 'ignore',- env: { ...process.env },- });+ const child = spawn(+ cmd,+ spawnArgs,+ withHiddenWindowsConsole({+ ...LOCAL_OP_IGNORED_STDIO_OPTIONS,+ env: { ...process.env },+ }),+ );const killTimer = setTimeout(() => {child.kill('SIGTERM');}, 30_000);@@ -16847,10 +16873,14 @@ export function createApiExtension(options: ApiExtensionOptions): Extension {const [cmd, ...baseArgs] = localOpCliArgs;const spawnArgs = [...baseArgs, ...args];return await new Promise<{ stdout: string; code: number | null }>((resolveSpawn, reject) => {- const child = spawn(cmd, spawnArgs, {- stdio: ['ignore', 'pipe', 'pipe'],- env: { ...process.env },- });+ const child = spawn(+ cmd,+ spawnArgs,+ withHiddenWindowsConsole({+ ...LOCAL_OP_PIPE_STDIO_OPTIONS,+ env: { ...process.env },+ }),+ );let timedOut = false;const killTimer = setTimeout(() => {timedOut = true;diff --git a/packages/server/src/child-process-windows-hide.test.ts b/packages/server/src/child-process-windows-hide.test.tsnew file mode 100644index 000000000..a944bd84d--- /dev/null+++ b/packages/server/src/child-process-windows-hide.test.ts@@ -0,0 +1,162 @@+import { describe, expect, test } from 'bun:test';+import { readdirSync } from 'node:fs';+import { resolve } from 'node:path';+import {+ type CallExpression,+ type Identifier,+ Node,+ type ObjectLiteralExpression,+ Project,+ type SourceFile,+} from 'ts-morph';+import { withHiddenWindowsConsole } from './child-process-windows-hide.ts';++const SERVER_SRC_DIR = import.meta.dir;+const CHILD_PROCESS_MODULE = 'node:child_process';+const CHILD_PROCESS_APIS = new Set(['spawn', 'spawnSync', 'execFile']);+const HIDDEN_HELPERS = new Set(['withHiddenWindowsConsole']);++function collectSourceFiles(dir: string): string[] {+ const out: string[] = [];+ for (const entry of readdirSync(dir, { withFileTypes: true })) {+ if (entry.name === 'node_modules') continue;+ const abs = resolve(dir, entry.name);+ if (entry.isDirectory()) {+ out.push(...collectSourceFiles(abs));+ continue;+ }+ if (+ entry.name.endsWith('.ts') &&+ !entry.name.endsWith('.test.ts') &&+ !entry.name.endsWith('.test-helper.ts')+ ) {+ out.push(abs);+ }+ }+ return out;+}++function childProcessImports(sourceFile: SourceFile): Map<string, string> {+ const imports = new Map<string, string>();+ for (const declaration of sourceFile.getImportDeclarations()) {+ if (declaration.getModuleSpecifierValue() !== CHILD_PROCESS_MODULE) continue;+ for (const namedImport of declaration.getNamedImports()) {+ const importedName = namedImport.getName();+ if (!CHILD_PROCESS_APIS.has(importedName)) continue;+ const localName = namedImport.getAliasNode()?.getText() ?? importedName;+ imports.set(localName, importedName);+ }+ }+ return imports;+}++function promisifiedExecFileBindings(+ sourceFile: SourceFile,+ imports: Map<string, string>,+): Map<string, string> {+ const bindings = new Map<string, string>();+ sourceFile.forEachDescendant((node) => {+ if (!Node.isVariableDeclaration(node)) return;+ const initializer = node.getInitializer();+ if (!initializer || !Node.isCallExpression(initializer)) return;+ const callee = initializer.getExpression();+ if (!Node.isIdentifier(callee) || callee.getText() !== 'promisify') return;+ const [firstArg] = initializer.getArguments();+ if (!firstArg || !Node.isIdentifier(firstArg)) return;+ if (imports.get(firstArg.getText()) !== 'execFile') return;+ const name = node.getNameNode();+ if (Node.isIdentifier(name)) bindings.set(name.getText(), 'execFile');+ });+ return bindings;+}++function unwrapExpression(node: Node): Node {+ if (+ Node.isAsExpression(node) ||+ Node.isSatisfiesExpression(node) ||+ Node.isParenthesizedExpression(node)+ ) {+ return unwrapExpression(node.getExpression());+ }+ return node;+}++function objectHasWindowsHideTrue(node: ObjectLiteralExpression): boolean {+ return node.getProperties().some((property) => {+ if (!Node.isPropertyAssignment(property)) return false;+ const name = property.getNameNode().getText().replaceAll(/['"]/g, '');+ if (name !== 'windowsHide') return false;+ return property.getInitializer()?.getText() === 'true';+ });+}++function initializerForIdentifier(identifier: Identifier): Node | undefined {+ const symbol = identifier.getSymbol();+ const declaration = symbol?.getDeclarations()[0];+ if (!declaration || !Node.isVariableDeclaration(declaration)) return undefined;+ return declaration.getInitializer();+}++function hidesWindowsConsole(node: Node | undefined): boolean {+ if (!node) return false;+ const unwrapped = unwrapExpression(node);+ if (Node.isObjectLiteralExpression(unwrapped)) return objectHasWindowsHideTrue(unwrapped);+ if (Node.isCallExpression(unwrapped)) {+ const callee = unwrapped.getExpression();+ return Node.isIdentifier(callee) && HIDDEN_HELPERS.has(callee.getText());+ }+ if (Node.isIdentifier(unwrapped)) {+ return hidesWindowsConsole(initializerForIdentifier(unwrapped));+ }+ return false;+}++function optionsArgFor(call: CallExpression, api: string): Node | undefined {+ const args = call.getArguments();+ if (api === 'spawn' || api === 'spawnSync') return args[2];+ if (api === 'execFile') return args[2];+ return undefined;+}++describe('Windows child-process console hiding', () => {+ test('option helper forces windowsHide true without mutating the caller options', () => {+ const options = { cwd: '/tmp/project', stdio: 'ignore' as const, windowsHide: false };+ const hidden = withHiddenWindowsConsole(options);++ expect(hidden).toEqual({ cwd: '/tmp/project', stdio: 'ignore', windowsHide: true });+ expect(options.windowsHide).toBe(false);+ });++ test('server child_process call sites hide Windows console windows', () => {+ const project = new Project({ skipAddingFilesFromTsConfig: true });+ for (const file of collectSourceFiles(SERVER_SRC_DIR)) {+ project.addSourceFileAtPath(file);+ }++ const violations: string[] = [];+ for (const sourceFile of project.getSourceFiles()) {+ const imports = childProcessImports(sourceFile);+ if (imports.size === 0) continue;+ const trackedNames = new Map([+ ...imports,+ ...promisifiedExecFileBindings(sourceFile, imports),+ ]);++ sourceFile.forEachDescendant((node) => {+ if (!Node.isCallExpression(node)) return;+ const callee = node.getExpression();+ if (!Node.isIdentifier(callee)) return;+ const api = trackedNames.get(callee.getText());+ if (!api) return;+ const optionsArg = optionsArgFor(node, api);+ if (hidesWindowsConsole(optionsArg)) return;+ const loc = sourceFile.getLineAndColumnAtPos(node.getStart());+ violations.push(+ `${sourceFile.getFilePath()}:${loc.line}:${loc.column} ${callee.getText()}()`,+ );+ });+ }++ expect(violations).toEqual([]);+ });+});diff --git a/packages/server/src/child-process-windows-hide.ts b/packages/server/src/child-process-windows-hide.tsnew file mode 100644index 000000000..87dd9a8d6--- /dev/null+++ b/packages/server/src/child-process-windows-hide.ts@@ -0,0 +1,12 @@+export type HiddenWindowsConsoleOptions<T extends object> = T & { windowsHide: true };++/**+ * GUI-launched Windows server processes have no inherited console. Without+ * `windowsHide`, console-subsystem children such as git.exe allocate a visible+ * conhost window for the duration of each subprocess.+ */+export function withHiddenWindowsConsole<T extends object>(+ options: T,+): HiddenWindowsConsoleOptions<T> {+ return { ...options, windowsHide: true };+}diff --git a/packages/server/src/content-filter.ts b/packages/server/src/content-filter.tsindex 551583f08..2d4501a4c 100644--- a/packages/server/src/content-filter.ts+++ b/packages/server/src/content-filter.ts@@ -27,6 +27,7 @@ import { promisify } from 'node:util';import { LINKABLE_ASSET_EXTENSIONS, SKILL_CONTENT_ROOT } from '@inkeep/open-knowledge-core';import ignore, { type Ignore } from 'ignore';import { isReservedForUserTree } from './cc1-broadcast.ts';+import { withHiddenWindowsConsole } from './child-process-windows-hide.ts';import { isSupportedDocFile, stripDocExtension } from './doc-extensions.ts';import { getLogger } from './logger.ts';import { toPosix } from './path-utils.ts';@@ -385,22 +386,30 @@ async function loadGitExcludeSourcesAsync(}function readGitCommonDirSync(projectDir: string): string | null {- const probe = spawnSync('git', ['rev-parse', '--git-common-dir'], {- cwd: projectDir,- encoding: 'utf-8',- timeout: 5_000,- });+ const probe = spawnSync(+ 'git',+ ['rev-parse', '--git-common-dir'],+ withHiddenWindowsConsole({+ cwd: projectDir,+ encoding: 'utf-8',+ timeout: 5_000,+ }),+ );if (probe.status !== 0 || !probe.stdout) return null;return resolve(projectDir, probe.stdout.trim());}async function readGitCommonDirAsync(projectDir: string): Promise<string | null> {try {- const { stdout } = await execFileAsync('git', ['rev-parse', '--git-common-dir'], {- cwd: projectDir,- encoding: 'utf-8',- timeout: 5_000,- });+ const { stdout } = await execFileAsync(+ 'git',+ ['rev-parse', '--git-common-dir'],+ withHiddenWindowsConsole({+ cwd: projectDir,+ encoding: 'utf-8',+ timeout: 5_000,+ }),+ );if (!stdout) return null;return resolve(projectDir, stdout.trim());} catch {@@ -420,11 +429,15 @@ async function readGitCommonDirAsync(projectDir: string): Promise<string | null>* to prevent.*/function resolveGlobalExcludesfileSync(projectDir: string): string | null {- const configProbe = spawnSync('git', ['config', '--get', '--type=path', 'core.excludesfile'], {- cwd: projectDir,- encoding: 'utf-8',- timeout: 5_000,- });+ const configProbe = spawnSync(+ 'git',+ ['config', '--get', '--type=path', 'core.excludesfile'],+ withHiddenWindowsConsole({+ cwd: projectDir,+ encoding: 'utf-8',+ timeout: 5_000,+ }),+ );if (configProbe.status === 0 && configProbe.stdout) {const raw = configProbe.stdout.trim();if (raw) return raw;@@ -437,7 +450,7 @@ async function resolveGlobalExcludesfileAsync(projectDir: string): Promise<strinconst { stdout } = await execFileAsync('git',['config', '--get', '--type=path', 'core.excludesfile'],- { cwd: projectDir, encoding: 'utf-8', timeout: 5_000 },+ withHiddenWindowsConsole({ cwd: projectDir, encoding: 'utf-8', timeout: 5_000 }),);const raw = stdout.trim();if (raw) return raw;diff --git a/packages/server/src/ensure-single-file-session.ts b/packages/server/src/ensure-single-file-session.tsindex fdca6c3cb..277342d6b 100644--- a/packages/server/src/ensure-single-file-session.ts+++ b/packages/server/src/ensure-single-file-session.ts@@ -19,10 +19,11 @@* the production surface (self-spawn via this process's own CLI entry).*/-import { spawn } from 'node:child_process';+import { type SpawnOptions, spawn } from 'node:child_process';import { existsSync } from 'node:fs';import { realpath as fsRealpath } from 'node:fs/promises';import { resolve } from 'node:path';+import { withHiddenWindowsConsole } from './child-process-windows-hide.ts';import { isSupportedDocFile } from './doc-extensions.ts';import { createOffCwdResolverDeps, resolveOffCwdTarget } from './off-cwd-resolver.ts';@@ -54,6 +55,10 @@ const DEFAULT_POLL_INTERVAL_MS = 500;// the first `preview_url({file})` returns a URL (opens in the in-app browser)// instead of timing out and pushing the agent to the `ok open` (Desktop) hint.const DEFAULT_TIMEOUT_MS = 15000;+const SINGLE_FILE_SESSION_SPAWN_OPTIONS: Pick<SpawnOptions, 'detached' | 'stdio'> = {+ detached: true,+ stdio: 'ignore',+};/** Module-level single-flight: realpath → in-flight ensure promise. */const inflight = new Map<string, Promise<boolean>>();@@ -145,11 +150,14 @@ export function createEnsureSingleFileSession(): (absFile: string) => Promise<boOK_SINGLE_FILE_NO_OPEN: '1',ELECTRON_RUN_AS_NODE: '1',};- const child = spawn(process.execPath, [entry, absFile], {- detached: true,- stdio: 'ignore',- env,- });+ const child = spawn(+ process.execPath,+ [entry, absFile],+ withHiddenWindowsConsole({+ ...SINGLE_FILE_SESSION_SPAWN_OPTIONS,+ env,+ }),+ );child.unref();},isServing: async (absFile) =>diff --git a/packages/server/src/git-identity.ts b/packages/server/src/git-identity.tsindex 90f919d9d..c544d146c 100644--- a/packages/server/src/git-identity.ts+++ b/packages/server/src/git-identity.ts@@ -18,6 +18,7 @@import { spawnSync } from 'node:child_process';import { resolve } from 'node:path';+import { withHiddenWindowsConsole } from './child-process-windows-hide.ts';// ─── Types ────────────────────────────────────────────────────────────────────@@ -61,11 +62,15 @@ export type GitConfigReader = (const defaultGitConfigReader: GitConfigReader = (projectDir, key, scope) => {const scopeFlag =scope === 'worktree' ? '--worktree' : scope === 'local' ? '--local' : '--global';- const result = spawnSync('git', ['config', scopeFlag, key], {- cwd: projectDir,- encoding: 'utf-8',- timeout: 5_000,- });+ const result = spawnSync(+ 'git',+ ['config', scopeFlag, key],+ withHiddenWindowsConsole({+ cwd: projectDir,+ encoding: 'utf-8',+ timeout: 5_000,+ }),+ );if (result.status !== 0 || !result.stdout) return null;return result.stdout.trim() || null;};@@ -83,16 +88,24 @@ const defaultGitConfigReader: GitConfigReader = (projectDir, key, scope) => {* the `--worktree` flag (which requires `extensions.worktreeConfig`).*/function isLinkedWorktree(projectDir: string): boolean {- const gd = spawnSync('git', ['rev-parse', '--git-dir'], {- cwd: projectDir,- encoding: 'utf-8',- timeout: 5_000,- });- const cd = spawnSync('git', ['rev-parse', '--git-common-dir'], {- cwd: projectDir,- encoding: 'utf-8',- timeout: 5_000,- });+ const gd = spawnSync(+ 'git',+ ['rev-parse', '--git-dir'],+ withHiddenWindowsConsole({+ cwd: projectDir,+ encoding: 'utf-8',+ timeout: 5_000,+ }),+ );+ const cd = spawnSync(+ 'git',+ ['rev-parse', '--git-common-dir'],+ withHiddenWindowsConsole({+ cwd: projectDir,+ encoding: 'utf-8',+ timeout: 5_000,+ }),+ );if (gd.status !== 0 || cd.status !== 0) return false;const gdPath = resolve(projectDir, gd.stdout.trim());const cdPath = resolve(projectDir, cd.stdout.trim());@@ -112,18 +125,26 @@ function ensureWorktreeConfigExtension(projectDir: string): void {// the same scope. Git only honors `extensions.*` from the repo-level config,// so a stray `extensions.worktreeConfig=true` in `~/.gitconfig` would short-// circuit a scope-less probe but git would still reject `--worktree`.- const probe = spawnSync('git', ['config', '--local', '--get', 'extensions.worktreeConfig'], {- cwd: projectDir,- encoding: 'utf-8',- timeout: 5_000,- });+ const probe = spawnSync(+ 'git',+ ['config', '--local', '--get', 'extensions.worktreeConfig'],+ withHiddenWindowsConsole({+ cwd: projectDir,+ encoding: 'utf-8',+ timeout: 5_000,+ }),+ );if (probe.status === 0 && /^(true|yes|on|1)$/i.test(probe.stdout.trim())) return;- const enable = spawnSync('git', ['config', '--local', 'extensions.worktreeConfig', 'true'], {- cwd: projectDir,- encoding: 'utf-8',- timeout: 5_000,- });+ const enable = spawnSync(+ 'git',+ ['config', '--local', 'extensions.worktreeConfig', 'true'],+ withHiddenWindowsConsole({+ cwd: projectDir,+ encoding: 'utf-8',+ timeout: 5_000,+ }),+ );if (enable.status !== 0) {const stderr = enable.stderr?.trim() ?? '';const spawnErr = enable.error ? ` [${enable.error.message}]` : '';@@ -220,11 +241,15 @@ export function writeGitIdentity(projectDir: string, name: string, email: stringscopeFlag = '--worktree';}const setConfig = (key: string, value: string) => {- const result = spawnSync('git', ['config', scopeFlag, key, value], {- cwd: projectDir,- encoding: 'utf-8',- timeout: 5_000,- });+ const result = spawnSync(+ 'git',+ ['config', scopeFlag, key, value],+ withHiddenWindowsConsole({+ cwd: projectDir,+ encoding: 'utf-8',+ timeout: 5_000,+ }),+ );if (result.status !== 0) {const stderr = result.stderr?.trim() ?? '';const spawnErr = result.error ? ` [${result.error.message}]` : '';diff --git a/packages/server/src/git-preflight.ts b/packages/server/src/git-preflight.tsindex 96731cf20..712583e48 100644--- a/packages/server/src/git-preflight.ts+++ b/packages/server/src/git-preflight.ts@@ -28,6 +28,7 @@ import { type SpawnSyncOptions, spawnSync } from 'node:child_process';import { existsSync, readFileSync } from 'node:fs';import { homedir } from 'node:os';import { join, delimiter as PATH_DELIM } from 'node:path';+import { withHiddenWindowsConsole } from './child-process-windows-hide.ts';/*** Minimum git version OK requires.@@ -198,11 +199,11 @@ type ProbeResult =* stderr text in stable English (important if downstream regex inspects it).*/function probeGit(command: string): ProbeResult {- const opts: SpawnSyncOptions = {+ const opts: SpawnSyncOptions = withHiddenWindowsConsole({encoding: 'utf-8',timeout: PROBE_TIMEOUT_MS,env: { ...process.env, LANG: 'C', LC_ALL: 'C' },- };+ });const result = spawnSync(command, ['--version'], opts);if (result.error) {// `spawnSync` sets `signal` to `'SIGTERM'` on timeout.@@ -318,7 +319,11 @@ export function resolveOnPath(name: string): string | null {// install guidance.let resolved: string | null;if (process.platform === 'win32') {- const result = spawnSync('where', [name], { encoding: 'utf-8', timeout: PROBE_TIMEOUT_MS });+ const result = spawnSync(+ 'where',+ [name],+ withHiddenWindowsConsole({ encoding: 'utf-8', timeout: PROBE_TIMEOUT_MS }),+ );if (result.status !== 0) {resolved = null;} else {@@ -329,10 +334,14 @@ export function resolveOnPath(name: string): string | null {}} else {// POSIX: `command -v` is a shell builtin, not a binary on disk.- const result = spawnSync('/bin/sh', ['-c', `command -v ${name}`], {- encoding: 'utf-8',- timeout: PROBE_TIMEOUT_MS,- });+ const result = spawnSync(+ '/bin/sh',+ ['-c', `command -v ${name}`],+ withHiddenWindowsConsole({+ encoding: 'utf-8',+ timeout: PROBE_TIMEOUT_MS,+ }),+ );if (result.status !== 0) {resolved = null;} else {diff --git a/packages/server/src/handoff-api.ts b/packages/server/src/handoff-api.tsindex 752d2d87e..3884d7e72 100644--- a/packages/server/src/handoff-api.ts+++ b/packages/server/src/handoff-api.ts@@ -23,6 +23,7 @@import { execFile } from 'node:child_process';import type { IncomingMessage, ServerResponse } from 'node:http';import { InstalledAgentsSuccessSchema } from '@inkeep/open-knowledge-core';+import { withHiddenWindowsConsole } from './child-process-windows-hide.ts';import { errorResponse } from './http/error-response.ts';import { successResponse } from './http/success-response.ts';@@ -54,7 +55,7 @@ const MACOS_APP_NAMES: Record<InstalledAgentScheme, ReadonlyArray<string>> = {export type ExecFileLike = (file: string,args: readonly string[],- opts: { timeout?: number; encoding?: BufferEncoding },+ opts: { timeout?: number; encoding?: BufferEncoding; windowsHide?: boolean },cb: (err: (Error & { code?: number | string }) | null, stdout: string, stderr: string) => void,) => void;@@ -259,7 +260,10 @@ function probeMacOs(scheme: InstalledAgentScheme, exec: ExecFileLike): Promise<bexec('osascript',['-e', `id of app "${appName}"`],- { timeout: INSTALLED_AGENTS_PROBE_TIMEOUT_MS, encoding: 'utf-8' },+ withHiddenWindowsConsole({+ timeout: INSTALLED_AGENTS_PROBE_TIMEOUT_MS,+ encoding: 'utf-8',+ }),(err, stdout) => {if (err) {resolve(false);@@ -285,7 +289,10 @@ function probeWindows(scheme: InstalledAgentScheme, exec: ExecFileLike): Promiseexec('reg',['query', `HKCR\\${scheme}`, '/ve'],- { timeout: INSTALLED_AGENTS_PROBE_TIMEOUT_MS, encoding: 'utf-8' },+ withHiddenWindowsConsole({+ timeout: INSTALLED_AGENTS_PROBE_TIMEOUT_MS,+ encoding: 'utf-8',+ }),(err) => {resolve(!err);},@@ -298,7 +305,10 @@ function probeLinux(scheme: InstalledAgentScheme, exec: ExecFileLike): Promise<bexec('xdg-mime',['query', 'default', `x-scheme-handler/${scheme}`],- { timeout: INSTALLED_AGENTS_PROBE_TIMEOUT_MS, encoding: 'utf-8' },+ withHiddenWindowsConsole({+ timeout: INSTALLED_AGENTS_PROBE_TIMEOUT_MS,+ encoding: 'utf-8',+ }),(err, stdout) => {if (err) {resolve(false);diff --git a/packages/server/src/local-ops/subprocess.ts b/packages/server/src/local-ops/subprocess.tsindex 1a5143f9e..e534ff362 100644--- a/packages/server/src/local-ops/subprocess.ts+++ b/packages/server/src/local-ops/subprocess.ts@@ -13,6 +13,11 @@import { spawn } from 'node:child_process';import { delimiter as PATH_DELIMITER } from 'node:path';+import { withHiddenWindowsConsole } from '../child-process-windows-hide.ts';++const SUBPROCESS_PIPE_STDIO_OPTIONS: { stdio: ['ignore', 'pipe', 'pipe'] } = {+ stdio: ['ignore', 'pipe', 'pipe'],+};/** A parsed JSON line plus the raw line (for HTTP NDJSON pass-through). */interface ParsedLine {@@ -96,11 +101,15 @@ export function runSubprocess(opts: SubprocessRunOptions): SubprocessController.join(PATH_DELIMITER);}- const child = spawn(cmd, argv, {- cwd: opts.cwd,- stdio: ['ignore', 'pipe', 'pipe'],- env: childEnv,- });+ const child = spawn(+ cmd,+ argv,+ withHiddenWindowsConsole({+ ...SUBPROCESS_PIPE_STDIO_OPTIONS,+ cwd: opts.cwd,+ env: childEnv,+ }),+ );const killTimer = setTimeout(() => {timedOut = true;diff --git a/packages/server/src/process-scan.ts b/packages/server/src/process-scan.tsindex 3937c2d35..12c938f79 100644--- a/packages/server/src/process-scan.ts+++ b/packages/server/src/process-scan.ts@@ -16,6 +16,7 @@ import { spawnSync } from 'node:child_process';import { existsSync, lstatSync, readdirSync } from 'node:fs';import { realpath } from 'node:fs/promises';import { basename, isAbsolute, join } from 'node:path';+import { withHiddenWindowsConsole } from './child-process-windows-hide.ts';const SPAWN_TIMEOUT_MS = 2000;const LOCK_SCAN_MAX_DEPTH = 3;@@ -145,10 +146,14 @@ function parsePsOutput(output: string): OkProcessEntry[] {* pgrep exit code 1 means "no matches" — that is NOT a fallback trigger.*/async function findOkProcessEntries(): Promise<OkProcessEntry[]> {- const pgrepResult = spawnSync('pgrep', ['-a', '-f', OK_PROCESS_PGREP_QUERY], {- encoding: 'utf-8',- timeout: SPAWN_TIMEOUT_MS,- });+ const pgrepResult = spawnSync(+ 'pgrep',+ ['-a', '-f', OK_PROCESS_PGREP_QUERY],+ withHiddenWindowsConsole({+ encoding: 'utf-8',+ timeout: SPAWN_TIMEOUT_MS,+ }),+ );const pgrepUnavailable =pgrepResult.error != null && (pgrepResult.error as NodeJS.ErrnoException).code === 'ENOENT';@@ -163,10 +168,14 @@ async function findOkProcessEntries(): Promise<OkProcessEntry[]> {}// pgrep not available or returned PID-only lines — fall back to ps- const psResult = spawnSync('ps', ['-axo', 'pid,command'], {- encoding: 'utf-8',- timeout: SPAWN_TIMEOUT_MS,- });+ const psResult = spawnSync(+ 'ps',+ ['-axo', 'pid,command'],+ withHiddenWindowsConsole({+ encoding: 'utf-8',+ timeout: SPAWN_TIMEOUT_MS,+ }),+ );if (psResult.error != null || !psResult.stdout) {return [];@@ -208,10 +217,14 @@ export function extractOkBinaryPath(command: string): string | null {}export function processCommand(pid: number): string | null {- const result = spawnSync('ps', ['-p', String(pid), '-o', 'command='], {- encoding: 'utf-8',- timeout: SPAWN_TIMEOUT_MS,- });+ const result = spawnSync(+ 'ps',+ ['-p', String(pid), '-o', 'command='],+ withHiddenWindowsConsole({+ encoding: 'utf-8',+ timeout: SPAWN_TIMEOUT_MS,+ }),+ );if (result.error != null || !result.stdout) return null;return result.stdout.trim() || null;@@ -223,10 +236,14 @@ export interface ProcessUsage {}export function processUsage(pid: number): ProcessUsage | null {- const result = spawnSync('ps', ['-p', String(pid), '-o', '%cpu=,%mem='], {- encoding: 'utf-8',- timeout: SPAWN_TIMEOUT_MS,- });+ const result = spawnSync(+ 'ps',+ ['-p', String(pid), '-o', '%cpu=,%mem='],+ withHiddenWindowsConsole({+ encoding: 'utf-8',+ timeout: SPAWN_TIMEOUT_MS,+ }),+ );if (result.error != null || !result.stdout) return null;const [cpuRaw, memRaw] = result.stdout.trim().split(/\s+/);@@ -237,10 +254,14 @@ export function processUsage(pid: number): ProcessUsage | null {}export async function pidCwd(pid: number): Promise<string | null> {- const result = spawnSync('lsof', ['-p', String(pid), '-a', '-d', 'cwd', '-Fn'], {- encoding: 'utf-8',- timeout: SPAWN_TIMEOUT_MS,- });+ const result = spawnSync(+ 'lsof',+ ['-p', String(pid), '-a', '-d', 'cwd', '-Fn'],+ withHiddenWindowsConsole({+ encoding: 'utf-8',+ timeout: SPAWN_TIMEOUT_MS,+ }),+ );if (result.error != null) {// ENOENT = lsof unavailable; ETIMEDOUT / killed by timeout signal@@ -366,10 +387,14 @@ export async function discoverLockDirs(): Promise<string[]> {}// Step 3: supplementary port scan — catches PIDs missed by process matching- const lsofResult = spawnSync('lsof', ['-iTCP', '-sTCP:LISTEN', '-nP'], {- encoding: 'utf-8',- timeout: SPAWN_TIMEOUT_MS,- });+ const lsofResult = spawnSync(+ 'lsof',+ ['-iTCP', '-sTCP:LISTEN', '-nP'],+ withHiddenWindowsConsole({+ encoding: 'utf-8',+ timeout: SPAWN_TIMEOUT_MS,+ }),+ );if (lsofResult.error == null && lsofResult.stdout) {const listeningPids = parseListeningPids(lsofResult.stdout);diff --git a/packages/server/src/project-git.ts b/packages/server/src/project-git.tsindex 8966df587..fa46586a5 100644--- a/packages/server/src/project-git.ts+++ b/packages/server/src/project-git.ts@@ -16,6 +16,7 @@ import { execFile } from 'node:child_process';import { existsSync, statSync } from 'node:fs';import { resolve } from 'node:path';import { promisify } from 'node:util';+import { withHiddenWindowsConsole } from './child-process-windows-hide.ts';import {assertGitAvailable,type GitDetected,@@ -50,9 +51,11 @@ export interface EnsureProjectGitResult {async function isInsideExistingWorkTree(gitBin: string, cwd: string): Promise<boolean> {try {- const { stdout } = await execFileAsync(gitBin, ['rev-parse', '--is-inside-work-tree'], {- cwd,- });+ const { stdout } = await execFileAsync(+ gitBin,+ ['rev-parse', '--is-inside-work-tree'],+ withHiddenWindowsConsole({ cwd, encoding: 'utf-8' }),+ );return stdout.trim() === 'true';} catch {// Non-zero `rev-parse` here means "not a work tree" (or an unreadable cwd)@@ -147,7 +150,11 @@ export async function ensureProjectGit(projectRoot: string): Promise<EnsureProjelet stderr = '';try {- const result = await execFileAsync(gitBin, ['init', '--initial-branch=main', abs]);+ const result = await execFileAsync(+ gitBin,+ ['init', '--initial-branch=main', abs],+ withHiddenWindowsConsole({ encoding: 'utf-8' }),+ );stderr = result.stderr ?? '';} catch (err) {const capturedStderr =diff --git a/packages/server/src/rename-log.ts b/packages/server/src/rename-log.tsindex d526b9dbb..d3df5b663 100644--- a/packages/server/src/rename-log.ts+++ b/packages/server/src/rename-log.ts@@ -18,6 +18,7 @@ import { createHash } from 'node:crypto';import { existsSync, readFileSync, statSync } from 'node:fs';import { resolve } from 'node:path';import { parseOkActors } from '@inkeep/open-knowledge-core/shadow-repo-layout';+import { withHiddenWindowsConsole } from './child-process-windows-hide.ts';import {tracedAppendFileSync,tracedRenameSync,@@ -584,6 +585,12 @@ export async function buildSeeds(* and other arguments while keeping the fast path for typical small lists.*/const REV_LIST_STDIN_THRESHOLD_BYTES = 100 * 1024;+const GIT_STDIN_STDIO_OPTIONS: { stdio: ['pipe', 'pipe', 'pipe'] } = {+ stdio: ['pipe', 'pipe', 'pipe'],+};+const GIT_BATCH_CHECK_STDIO_OPTIONS: { stdio: ['pipe', 'pipe', 'ignore'] } = {+ stdio: ['pipe', 'pipe', 'ignore'],+};/*** Run `git rev-list <refs>` over an arbitrary-size ref list. Falls through@@ -601,10 +608,14 @@ async function revListReachable(shadow: ShadowHandle, refs: string[]): Promise<s}const timeoutMs = parseGitTimeoutMs();return new Promise<string>((resolvePromise, rejectPromise) => {- const child = spawn('git', ['rev-list', '--stdin'], {- env: { ...process.env, GIT_DIR: shadow.gitDir, GIT_WORK_TREE: shadow.workTree },- stdio: ['pipe', 'pipe', 'pipe'],- });+ const child = spawn(+ 'git',+ ['rev-list', '--stdin'],+ withHiddenWindowsConsole({+ ...GIT_STDIN_STDIO_OPTIONS,+ env: { ...process.env, GIT_DIR: shadow.gitDir, GIT_WORK_TREE: shadow.workTree },+ }),+ );const stdoutChunks: Buffer[] = [];const stderrChunks: Buffer[] = [];child.stdout.on('data', (c: Buffer) => stdoutChunks.push(c));@@ -677,10 +688,14 @@ export async function logSeededReachable(// from argv after `--`. Combining stdin + argv pathspec is documented// and stable across git versions.const args = ['log', '--stdin', ...flags, ...(pathspec ? ['--', pathspec] : [])];- const child = spawn('git', args, {- env: { ...process.env, GIT_DIR: shadow.gitDir, GIT_WORK_TREE: shadow.workTree },- stdio: ['pipe', 'pipe', 'pipe'],- });+ const child = spawn(+ 'git',+ args,+ withHiddenWindowsConsole({+ ...GIT_STDIN_STDIO_OPTIONS,+ env: { ...process.env, GIT_DIR: shadow.gitDir, GIT_WORK_TREE: shadow.workTree },+ }),+ );const stdoutChunks: Buffer[] = [];const stderrChunks: Buffer[] = [];child.stdout.on('data', (c: Buffer) => stdoutChunks.push(c));@@ -803,10 +818,14 @@ export function batchCheckExistence(// typical) and block the child until the timeout fires — git can write// diagnostic messages to stderr under repository corruption or// concurrent gc, both of which are realistic failure modes here.- const child = spawn('git', ['cat-file', '--batch-check', '--buffer'], {- env: { ...process.env, GIT_DIR: shadow.gitDir, GIT_WORK_TREE: shadow.workTree },- stdio: ['pipe', 'pipe', 'ignore'],- });+ const child = spawn(+ 'git',+ ['cat-file', '--batch-check', '--buffer'],+ withHiddenWindowsConsole({+ ...GIT_BATCH_CHECK_STDIO_OPTIONS,+ env: { ...process.env, GIT_DIR: shadow.gitDir, GIT_WORK_TREE: shadow.workTree },+ }),+ );const stdoutChunks: Buffer[] = [];child.stdout.on('data', (chunk: Buffer) => stdoutChunks.push(chunk));diff --git a/packages/server/src/server-factory.ts b/packages/server/src/server-factory.tsindex 3586125a1..e5bb4656d 100644--- a/packages/server/src/server-factory.ts+++ b/packages/server/src/server-factory.ts@@ -49,6 +49,7 @@ import {isReservedForUserTree,SYSTEM_DOC_NAME,} from './cc1-broadcast.ts';+import { withHiddenWindowsConsole } from './child-process-windows-hide.ts';import { getLocalDir } from './config/paths.ts';import {type ConfigFileWatcherUnsubscribe,@@ -445,7 +446,7 @@ export function resolveUpstreamChanges('--name-only','--format=C%x00%an%x00%ae',],- { cwd: projectDir, encoding: 'utf-8', timeout: 5000 },+ withHiddenWindowsConsole({ cwd: projectDir, encoding: 'utf-8', timeout: 5000 }),);} catch (err) {// spawnSync normally surfaces ENOENT/timeout via result.error rather than@@ -3081,11 +3082,15 @@ export function createServer(options: ServerOptions): ServerInstance {// it up.let gitInfoExcludePath: string | null = null;try {- const probe = spawnSync('git', ['rev-parse', '--git-common-dir'], {- cwd: projectDir,- encoding: 'utf-8',- timeout: 5_000,- });+ const probe = spawnSync(+ 'git',+ ['rev-parse', '--git-common-dir'],+ withHiddenWindowsConsole({+ cwd: projectDir,+ encoding: 'utf-8',+ timeout: 5_000,+ }),+ );if (probe.status === 0 && probe.stdout) {const commonDir = resolve(projectDir, probe.stdout.trim());const candidate = join(commonDir, 'info', 'exclude');diff --git a/packages/server/src/skill-install.test.ts b/packages/server/src/skill-install.test.tsindex 915c68827..020d9e228 100644--- a/packages/server/src/skill-install.test.ts+++ b/packages/server/src/skill-install.test.ts@@ -551,12 +551,14 @@ describe('buildAndOpenSkill', () => {function makeFakeSpawn(capture: {command?: string;args?: readonly string[];+ opts?: SpawnOptions;threw?: Error;}): SpawnLike {- return ((command: string, args: readonly string[]) => {+ return ((command: string, args: readonly string[], opts: SpawnOptions) => {if (capture.threw) throw capture.threw;capture.command = command;capture.args = args;+ capture.opts = opts;return { unref: () => {} } as ReturnType<SpawnLike>;}) as SpawnLike;}@@ -580,7 +582,7 @@ describe('buildAndOpenSkill', () => {test('darwin: spawns `open <path>` and returns status="installed"', async () => {const home = freshHome();- const capture: { command?: string; args?: readonly string[] } = {};+ const capture: { command?: string; args?: readonly string[]; opts?: SpawnOptions } = {};const out = join(home, 'darwin.skill');const result = await buildAndOpenSkill({@@ -593,11 +595,12 @@ describe('buildAndOpenSkill', () => {expect(result.status).toBe('installed');expect(capture.command).toBe('open');expect(capture.args).toEqual([out]);+ expect(capture.opts?.windowsHide).toBe(true);});test('win32: spawns `cmd /c start "" <path>` and returns status="installed"', async () => {const home = freshHome();- const capture: { command?: string; args?: readonly string[] } = {};+ const capture: { command?: string; args?: readonly string[]; opts?: SpawnOptions } = {};const out = join(home, 'win32.skill');const result = await buildAndOpenSkill({@@ -612,11 +615,12 @@ describe('buildAndOpenSkill', () => {expect(capture.args?.[0]).toBe('/c');expect(capture.args?.[1]).toBe('start');expect(capture.args?.[3]).toBe(out);+ expect(capture.opts?.windowsHide).toBe(true);});test('linux: spawns `xdg-open <path>` and returns status="installed"', async () => {const home = freshHome();- const capture: { command?: string; args?: readonly string[] } = {};+ const capture: { command?: string; args?: readonly string[]; opts?: SpawnOptions } = {};const result = await buildAndOpenSkill({home,@@ -627,6 +631,7 @@ describe('buildAndOpenSkill', () => {expect(result.status).toBe('installed');expect(capture.command).toBe('xdg-open');+ expect(capture.opts?.windowsHide).toBe(true);});test('unsupported platform: status="built" with handoffError reason=unsupported-platform', async () => {diff --git a/packages/server/src/skill-install.ts b/packages/server/src/skill-install.tsindex 723775c1f..92fd482b1 100644--- a/packages/server/src/skill-install.ts+++ b/packages/server/src/skill-install.ts@@ -7,6 +7,7 @@ import {buildSkillZip,resolveBundledSkillDir,} from './build-skill-zip.ts';+import { withHiddenWindowsConsole } from './child-process-windows-hide.ts';import { tracedMkdir } from './fs-traced.ts';import { BUNDLE_SKILL_NAME, type BundleId } from './skill-bundles.ts';import { recordSkillInstallEvent, type SkillInstallEventOutcome } from './skill-install-events.ts';@@ -165,11 +166,15 @@ function runSpawn(const useShell = platform === 'win32';const spawnArgs = useShell ? args.map(quoteForWindowsShell) : args;try {- child = spawnFn(command, spawnArgs, {- env,- stdio: ['ignore', 'pipe', 'pipe'],- ...(useShell ? { shell: true } : {}),- });+ child = spawnFn(+ command,+ spawnArgs,+ withHiddenWindowsConsole({+ env,+ stdio: ['ignore', 'pipe', 'pipe'],+ ...(useShell ? { shell: true } : {}),+ }),+ );} catch (err) {resolve({ kind: 'spawn-error', stderr: '', error: err as Error });return;@@ -525,7 +530,10 @@ function invokeFileAssociation(platformName: NodeJS.Platform,spawnFn: SpawnLike,): { ok: true } | { ok: false; reason: 'unsupported-platform' | 'spawn-error'; message: string } {- const detached: SpawnOptions = { detached: true, stdio: 'ignore' };+ const detached: SpawnOptions = withHiddenWindowsConsole({+ detached: true,+ stdio: 'ignore',+ });try {if (platformName === 'darwin') {spawnFn('open', [skillPath], detached).unref();diff --git a/packages/server/src/spawn-cursor-api.ts b/packages/server/src/spawn-cursor-api.tsindex 534a8cd09..95851b4fd 100644--- a/packages/server/src/spawn-cursor-api.ts+++ b/packages/server/src/spawn-cursor-api.ts@@ -51,6 +51,7 @@ import type { IncomingMessage, ServerResponse } from 'node:http';import { homedir } from 'node:os';import { posix as pathPosix, win32 as pathWin32 } from 'node:path';import { SpawnCursorSuccessSchema } from '@inkeep/open-knowledge-core';+import { withHiddenWindowsConsole } from './child-process-windows-hide.ts';import { errorResponse } from './http/error-response.ts';import {PayloadTooLargeError,@@ -325,14 +326,19 @@ export async function resolveCursorBinaryDefault(timeoutMs: number): Promise<str// PATH lookup — covers all platforms including Linux (no bundle paths).return new Promise((resolve) => {const cmd = process.platform === 'win32' ? 'where' : 'which';- execFile(cmd, ['cursor'], { timeout: timeoutMs, encoding: 'utf-8' }, (err, stdout) => {- if (err) {- resolve(null);- return;- }- const first = stdout.split(/\r?\n/)[0]?.trim();- resolve(first && first.length > 0 ? first : null);- });+ execFile(+ cmd,+ ['cursor'],+ withHiddenWindowsConsole({ timeout: timeoutMs, encoding: 'utf-8' }),+ (err, stdout) => {+ if (err) {+ resolve(null);+ return;+ }+ const first = stdout.split(/\r?\n/)[0]?.trim();+ resolve(first && first.length > 0 ? first : null);+ },+ );});}diff --git a/packages/server/src/spawn-detached.ts b/packages/server/src/spawn-detached.tsindex a67ca78ee..992d708e3 100644--- a/packages/server/src/spawn-detached.ts+++ b/packages/server/src/spawn-detached.ts@@ -19,7 +19,14 @@* wire boundary; this helper never constructs problem+json bodies itself.*/-import { spawn as nodeSpawn } from 'node:child_process';+import { spawn as nodeSpawn, type SpawnOptions } from 'node:child_process';+import { withHiddenWindowsConsole } from './child-process-windows-hide.ts';++const DETACHED_IGNORED_STDIO_OPTIONS: Pick<SpawnOptions, 'detached' | 'stdio' | 'shell'> = {+ detached: true,+ stdio: 'ignore',+ shell: false,+};export type SpawnDetachedOutcome =| { ok: true }@@ -52,11 +59,11 @@ export function spawnDetached(};const timer = setTimeout(() => settle({ ok: false, reason: 'timeout' }), timeoutMs);try {- const child = nodeSpawn(exec, [...args], {- detached: true,- stdio: 'ignore',- shell: false,- });+ const child = nodeSpawn(+ exec,+ [...args],+ withHiddenWindowsConsole(DETACHED_IGNORED_STDIO_OPTIONS),+ );child.once('error', (err) => {clearTimeout(timer);settle(classifySpawnError(err));