mirror of
https://github.com/deepseek-ai/deepseek-harness
synced 2026-08-15 21:04:50 +00:00
refactor(tsconfig): single root solution graph over host/client aggregates
Root tsconfig.json becomes a pure solution (files:[] + two references); the former root host aggregate moves verbatim to tsconfig.host.json. New tsconfig.base.client.json carries the shared client compiler shape (jsx/DOM lib/types:[]), and tsconfig.client.json plus the 12 packages/client tsconfigs extend it instead of restating the trio. tsconfig.build.json is deleted: the solution covers the full emit graph, absorbing the command-goal typecheck/build drift. Consumers migrate to the single graph: typecheck/build scripts and the lefthook pre-push hook run bare `tsc -b` (pre-push now covers the client side); the run-gates build gate needs typecheck so two concurrent tsc -b runs cannot race the same tsbuildinfo; ts-project.ts and the standalone doc-typecheck mode seed tsconfig.host.json explicitly (never the root solution — flattening host+client into one program collides the cordis Context merges); verify-cordis-config BFS seeds the root solution alone. Per missions/tsconfig-single-graph-migration.md §2–§3.
This commit is contained in:
@@ -55,15 +55,20 @@ const configHost: ts.ParseConfigFileHost = {
|
||||
},
|
||||
}
|
||||
|
||||
/** Load root settings and redirect workspace aliases to declarations from the coordinated build. */
|
||||
/**
|
||||
* Load host-aggregate settings and redirect workspace aliases to declarations
|
||||
* from the coordinated build. Doc fragments speak the host vocabulary; the host
|
||||
* aggregate (never the root solution — it has no compilerOptions) carries the
|
||||
* workspace paths via tsconfig.base.json.
|
||||
*/
|
||||
function builtTypeCompilerOptions(): ts.CompilerOptions {
|
||||
const configPath = join(root, 'tsconfig.json')
|
||||
const configPath = join(root, 'tsconfig.host.json')
|
||||
const parsed = ts.getParsedCommandLineOfConfigFile(configPath, {}, configHost)
|
||||
if (!parsed) throw new Error(`doc-typecheck: cannot parse ${configPath}`)
|
||||
if (parsed.errors.length > 0) {
|
||||
throw new Error(parsed.errors.map(error => ts.flattenDiagnosticMessageText(error.messageText, '\n')).join('\n'))
|
||||
}
|
||||
if (parsed.options.paths === undefined) throw new Error('doc-typecheck: root tsconfig has no workspace paths')
|
||||
if (parsed.options.paths === undefined) throw new Error('doc-typecheck: host tsconfig has no workspace paths')
|
||||
const paths = Object.fromEntries(Object.entries(parsed.options.paths).map(([specifier, candidates]) => [
|
||||
specifier,
|
||||
candidates.map(builtDeclarationPath),
|
||||
@@ -125,9 +130,14 @@ function formatDiagnostics(diagnostics: readonly ts.Diagnostic[], blocks: Block[
|
||||
return remapBlockPaths(formatted, blocks)
|
||||
}
|
||||
|
||||
/** Reuse the repo typecheck graph references from a temp project one directory below root. */
|
||||
/**
|
||||
* Reuse the host-aggregate references from a temp project one directory below
|
||||
* root. Doc fragments speak the host vocabulary, so the standalone project
|
||||
* seeds tsconfig.host.json (never the root solution: flattening host+client
|
||||
* into one program collides the cordis Context merges).
|
||||
*/
|
||||
function workspaceReferences(): { path: string }[] {
|
||||
const file = join(root, 'tsconfig.json')
|
||||
const file = join(root, 'tsconfig.host.json')
|
||||
// Parse with TypeScript's own JSONC reader: a regex comment stripper corrupts the `/*/` path
|
||||
// candidate in the workspace wildcard.
|
||||
const result = ts.readConfigFile(file, path => readFileSync(path, 'utf8'))
|
||||
@@ -144,7 +154,7 @@ function workspaceReferences(): { path: string }[] {
|
||||
/** The standalone temp project used when no coordinated build owns declaration freshness. */
|
||||
function tempTsconfig(): string {
|
||||
return JSON.stringify({
|
||||
extends: '../tsconfig.json',
|
||||
extends: '../tsconfig.host.json',
|
||||
compilerOptions: {
|
||||
noUnusedLocals: false,
|
||||
noUnusedParameters: false,
|
||||
|
||||
@@ -370,7 +370,7 @@ function quote(value: string): string {
|
||||
|
||||
/**
|
||||
* Render the generated scoped-event resolver module for one repository root.
|
||||
* @param projectRoot - repository root carrying tsconfig.json.
|
||||
* @param projectRoot - repository root carrying tsconfig.host.json.
|
||||
* @returns complete generated TypeScript source.
|
||||
*/
|
||||
export function renderScopedEvents(projectRoot: string = root): string {
|
||||
|
||||
@@ -228,7 +228,10 @@ function ciPrimaryGates(): Gate[] {
|
||||
...docSyncLeafGates(),
|
||||
pnpmScript('module-graph', 'verify-module-graph', { label: 'module graph' }),
|
||||
pnpmScript('knip', 'knip'),
|
||||
pnpmScript('build', 'build'),
|
||||
// typecheck and build now drive the same root solution graph; without the
|
||||
// dependency two concurrent `tsc -b` runs race the same tsbuildinfo files.
|
||||
// The tsc step is an incremental no-op after typecheck.
|
||||
pnpmScript('build', 'build', { needs: ['typecheck'] }),
|
||||
pnpmScript('publint', 'publint', { needs: ['build'] }),
|
||||
pnpmScript('node-next-types', 'verify-node-next-types', {
|
||||
label: 'node-next types',
|
||||
|
||||
@@ -22,9 +22,13 @@ const configHost: ts.ParseConfigFileHost = {
|
||||
},
|
||||
}
|
||||
|
||||
/** Parse a root tsconfig and flatten all referenced projects into one semantic graph. */
|
||||
/**
|
||||
* Parse the host aggregate tsconfig and flatten all referenced projects into one
|
||||
* semantic graph. Never seed the root solution: flattening host+client into one
|
||||
* program collides the cordis Context merges.
|
||||
*/
|
||||
function loadProjectGraph(projectRoot: string): ProjectGraph {
|
||||
const rootConfigPath = resolve(projectRoot, 'tsconfig.json')
|
||||
const rootConfigPath = resolve(projectRoot, 'tsconfig.host.json')
|
||||
const rootConfig = parseConfig(rootConfigPath)
|
||||
const rootNames = new Set<string>()
|
||||
const visited = new Set<string>()
|
||||
|
||||
@@ -152,12 +152,13 @@ function localPackageDirectories(): Map<string, string> {
|
||||
}
|
||||
|
||||
function rootProjectReferences(): Set<string> {
|
||||
// Typecheck runs two sibling aggregates (root = host program,
|
||||
// tsconfig.client.json = client program; the two sides merge cordis Context
|
||||
// under the same keys, so one program cannot see both). Seed both and follow
|
||||
// any nested aggregate references to collect the covered leaf project set.
|
||||
// The root solution references the host and client aggregates (the two
|
||||
// sides merge cordis Context under the same keys, so one program cannot see
|
||||
// both — but this BFS only collects reference paths, it never forms a
|
||||
// program). Seed the solution and follow nested aggregate references to
|
||||
// collect the covered leaf project set.
|
||||
const collected = new Set<string>()
|
||||
const queue = [resolve(root, 'tsconfig.json'), resolve(root, 'tsconfig.client.json')]
|
||||
const queue = [resolve(root, 'tsconfig.json')]
|
||||
const seen = new Set<string>()
|
||||
for (let file = queue.pop(); file !== undefined; file = queue.pop()) {
|
||||
if (seen.has(file)) continue
|
||||
|
||||
Reference in New Issue
Block a user