فهرست منبع

refactor(headless): keep the startup process seam out of the public entry

Address the Code Entropy finding on f67d722243: the `./startup` entry exported
`internals` only so tests could substitute process facts, which added avoidable
package API. Move the seam to `src/startup-internals.ts`, which no package
export names, and have the provider and its tests import it from there.
lsdsjy 1 ماه پیش
والد
کامیت
6d05765405

+ 14 - 0
packages/bundle/headless/src/startup-internals.ts

@@ -0,0 +1,14 @@
+/**
+ * Process facts the startup provider reads, kept out of the `./startup` entry
+ * so substituting them in tests adds no public package API.
+ * @module @deepseek-ai/dsh-headless/startup-internals
+ */
+
+/** Process facts the provider reads; tests substitute them. */
+export const internals: {
+  stdinIsTty: () => boolean
+  stdout: { write(chunk: string): unknown }
+} = {
+  stdinIsTty: () => process.stdin.isTTY,
+  stdout: process.stdout,
+}

+ 1 - 9
packages/bundle/headless/src/startup.ts

@@ -10,6 +10,7 @@ import { Command, CommanderError } from 'commander'
 import type { Context } from '@deepseek-ai/cordis'
 import { parseCmdline } from '@deepseek-ai/dsh-cmdline'
 import { boundJsonLine } from './json-stream.ts'
+import { internals } from './startup-internals.ts'
 
 /** Stable Cordis plugin name. */
 export const name = 'headless-startup'
@@ -30,15 +31,6 @@ export interface HeadlessStartupValues {
   json: boolean
 }
 
-/** Process facts the provider reads; tests substitute them. */
-export const internals: {
-  stdinIsTty: () => boolean
-  stdout: { write(chunk: string): unknown }
-} = {
-  stdinIsTty: () => process.stdin.isTTY,
-  stdout: process.stdout,
-}
-
 /**
  * This app's command: the task positional, its options, and its help text.
  * @returns a fresh program, so one process can parse more than once (tests).

+ 1 - 1
packages/bundle/headless/tests/startup.spec.ts

@@ -16,9 +16,9 @@ import { afterEach, describe, expect, it } from 'vitest'
 import {
   apply,
   HEADLESS_STARTUP_SERVICE,
-  internals as startupInternals,
   type HeadlessStartupValues,
 } from '../src/startup.ts'
+import { internals as startupInternals } from '../src/startup-internals.ts'
 
 /** What one boot of the fixture tree observed. */
 interface Observed {