2026-06-20 19:47:09 +08:00
/**
2026-07-28 23:48:35 +08:00
* Generate committed Cordis artifacts from the Typert catalog projector and
* the independent vendored-core projector.
2026-06-20 19:47:09 +08:00
*/
2026-07-28 23:48:35 +08:00
import { mkdirSync , readFileSync , writeFileSync } from 'node:fs'
import { dirname , resolve } from 'node:path'
import {
projectCordisCatalog ,
renderEvents ,
renderServices ,
} from '@deepseek-ai/dsh-typert-generator'
import type { CordisCatalogPolicy } from '@deepseek-ai/dsh-typert-generator'
2026-07-20 16:32:08 +08:00
import { renderCordisCoreApiPages } from './cordis-core-api.ts'
2026-06-20 19:47:09 +08:00
const root = resolve ( import . meta . dirname , '..' )
2026-07-05 00:45:06 +08:00
const OUT_EVENTS = 'docs/cordis-catalog/events.md'
const OUT_SERVICES = 'docs/cordis-catalog/services.md'
2026-07-28 23:48:35 +08:00
const OUT_RUNTIME_API = 'packages/cordis/tool-cordis/src/api-catalog.ts'
2026-06-20 19:47:09 +08:00
2026-07-28 23:48:35 +08:00
/** One primary core-data-structures page per project type used by a generated signature. */
export const LINK_MAP : Readonly < Record < string , string > > = {
2026-06-20 19:47:09 +08:00
Agent : 'core.md' ,
2026-07-21 12:48:46 +08:00
AgentCancelCause : 'core.md' ,
2026-07-19 14:57:52 +08:00
AgentOptions : 'core.md' ,
AgentStatus : 'core.md' ,
2026-06-20 19:47:09 +08:00
ContentBlock : 'core.md' ,
2026-07-19 14:57:52 +08:00
ContinuationDecision : 'core.md' ,
ContinuationStop : 'core.md' ,
2026-06-20 19:47:09 +08:00
GenerateOptions : 'core.md' ,
2026-07-28 13:55:59 +08:00
MessageId : 'core.md' ,
2026-07-21 16:46:48 +08:00
HookContext : 'core.md' ,
2026-07-27 17:38:42 +08:00
SettleReason : 'core.md' ,
2026-07-30 16:37:28 +08:00
AdapterRegistrationHandle : 'core.md' ,
2026-08-04 11:42:35 +08:00
DirectoryRegistrationHandle : 'core.md' ,
2026-07-06 03:07:34 +08:00
LlmCallConfig : 'core.md' ,
2026-07-20 15:34:00 +08:00
LlmModelContext : 'core.md' ,
2026-07-25 07:47:51 +08:00
LlmModelReasoningInfo : 'core.md' ,
2026-07-26 13:07:27 +08:00
LlmResolvedModelInfo : 'core.md' ,
2026-07-20 03:34:19 +08:00
LlmFailure : 'llm-streaming.md' ,
2026-07-19 14:57:52 +08:00
LlmModelInfo : 'core.md' ,
LlmProviderInfo : 'core.md' ,
2026-07-30 10:53:39 +08:00
LlmConfigurableProvider : 'core.md' ,
2026-08-04 10:14:46 +08:00
LlmModelDiscoveryRequest : 'core.md' ,
LlmDiscoveredModel : 'core.md' ,
2026-07-25 10:18:16 +08:00
ResolvedRetryPolicy : 'llm-streaming.md' ,
2026-07-19 14:57:52 +08:00
Message : 'core.md' ,
MessageSource : 'core.md' ,
2026-07-28 13:55:59 +08:00
UserMessage : 'session.md' ,
2026-07-31 19:21:16 +08:00
PreStepDecision : 'core.md' ,
PreStepContext : 'core.md' ,
2026-07-28 23:48:35 +08:00
RequestErrorAction : 'core.md' ,
2026-07-30 13:49:57 +08:00
RequestFailureContext : 'core.md' ,
2026-07-21 16:46:48 +08:00
PreparedReferencedMessage : 'session-reference.md' ,
SessionReferenceCandidate : 'session-reference.md' ,
SessionReferenceInput : 'session-reference.md' ,
2026-06-20 19:47:09 +08:00
SessionEvent : 'core.md' ,
2026-07-19 14:57:52 +08:00
SessionId : 'core.md' ,
2026-07-12 08:57:05 +08:00
SessionStartSource : 'core.md' ,
2026-07-24 12:31:26 +08:00
SessionLogSnapshot : 'session-query.md' ,
2026-07-21 16:46:48 +08:00
SessionSurfaceSnapshot : 'session-query.md' ,
2026-07-11 21:37:38 +08:00
ApprovalOutcome : 'approval.md' ,
ApprovalPolicy : 'approval.md' ,
ApprovalRequest : 'approval.md' ,
2026-07-19 14:57:52 +08:00
ApprovalService : 'approval.md' ,
2026-06-20 19:47:09 +08:00
BashExecRequest : 'bash.md' ,
BashExecSpec : 'bash.md' ,
2026-07-19 14:57:52 +08:00
BashProcess : 'bash.md' ,
2026-06-20 19:47:09 +08:00
BashRunResult : 'bash.md' ,
2026-07-26 12:43:14 +08:00
DshEnvironment : 'subprocess.md' ,
SubprocessHandle : 'subprocess.md' ,
SubprocessOutcome : 'subprocess.md' ,
SubprocessOutputRead : 'subprocess.md' ,
SubprocessOutputReader : 'subprocess.md' ,
SubprocessSpawnSpec : 'subprocess.md' ,
2026-07-08 02:38:47 +08:00
CodeRunRequest : 'code-runtime.md' ,
CodeRunResult : 'code-runtime.md' ,
2026-07-19 14:57:52 +08:00
CompactionResult : 'compaction.md' ,
2026-07-19 16:41:51 +08:00
CompactionTrigger : 'compaction.md' ,
2026-07-19 17:54:55 +08:00
PruneResult : 'compaction.md' ,
2026-07-19 14:57:52 +08:00
FileReadOutcome : 'filesystem.md' ,
FsDirEntry : 'filesystem.md' ,
2026-06-22 14:53:36 +08:00
FsEditOutcome : 'filesystem.md' ,
FsEditRequest : 'filesystem.md' ,
2026-06-26 18:14:30 +08:00
FsInfo : 'filesystem.md' ,
2026-07-19 14:57:52 +08:00
FsPathInfo : 'filesystem.md' ,
FsPolicyExec : 'filesystem.md' ,
2026-06-22 14:53:36 +08:00
FsTarget : 'filesystem.md' ,
FsVersion : 'filesystem.md' ,
2026-07-02 03:12:38 +08:00
FsWriteIntent : 'filesystem.md' ,
2026-06-22 14:53:36 +08:00
FsWriteOutcome : 'filesystem.md' ,
2026-07-19 18:47:34 +08:00
CreateGoalRequest : 'goal.md' ,
EditGoalRequest : 'goal.md' ,
2026-07-20 16:39:40 +08:00
GoalBlockReason : 'goal.md' ,
2026-07-19 18:47:34 +08:00
GoalChanged : 'goal.md' ,
GoalRef : 'goal.md' ,
GoalView : 'goal.md' ,
2026-07-19 22:11:59 +08:00
CommandDefinition : 'commands.md' ,
CommandDescriptor : 'commands.md' ,
CommandResult : 'commands.md' ,
CommandSurface : 'commands.md' ,
2026-07-19 14:57:52 +08:00
LlmAdapter : 'llm-streaming.md' ,
2026-07-25 22:59:45 +08:00
PreparedLlmCall : 'llm-streaming.md' ,
2026-07-19 14:57:52 +08:00
LlmService : 'llm-streaming.md' ,
StreamChunk : 'llm-streaming.md' ,
2026-07-29 02:06:07 +08:00
SkillProviderControl : 'skills.md' ,
2026-07-19 14:57:52 +08:00
CreateSessionOptions : 'persistence.md' ,
2026-08-05 22:54:55 +08:00
PrepareSessionOptions : 'persistence.md' ,
2026-07-19 14:57:52 +08:00
SessionHeader : 'persistence.md' ,
2026-08-05 22:54:55 +08:00
SessionInspection : 'persistence.md' ,
2026-07-19 14:57:52 +08:00
SessionLocation : 'persistence.md' ,
2026-08-05 22:54:55 +08:00
SessionPreparation : 'persistence.md' ,
2026-07-23 13:56:56 +08:00
SessionPersistenceSnapshot : 'persistence.md' ,
2026-07-19 14:57:52 +08:00
ConfinedArgv : 'sandbox.md' ,
2026-07-21 00:44:28 +08:00
SandboxExecutionPolicy : 'sandbox.md' ,
2026-07-19 14:57:52 +08:00
SandboxMode : 'sandbox.md' ,
SandboxPolicy : 'sandbox.md' ,
2026-07-21 16:01:00 +08:00
PtyBackend : 'pty.md' ,
PtyReadRequest : 'pty.md' ,
PtyReadResult : 'pty.md' ,
PtySendOperation : 'pty.md' ,
PtySendRequest : 'pty.md' ,
PtySessionId : 'pty.md' ,
PtySessionSnapshot : 'pty.md' ,
PtySignal : 'pty.md' ,
PtySignalResult : 'pty.md' ,
PtySpawnRequest : 'pty.md' ,
PtySpawnResult : 'pty.md' ,
2026-07-21 00:44:28 +08:00
SandboxPolicyRequest : 'sandbox.md' ,
2026-07-19 14:57:52 +08:00
ScopeKey : 'scope.md' ,
Scoped : 'scope.md' ,
EpochHeader : 'session.md' ,
Session : 'session.md' ,
2026-07-21 01:54:00 +08:00
SessionEventMap : 'session.md' ,
2026-07-19 14:57:52 +08:00
TurnEndReason : 'session.md' ,
2026-07-21 01:54:00 +08:00
TurnTrigger : 'session.md' ,
2026-07-19 14:57:52 +08:00
SessionEventReadRequest : 'session-query.md' ,
SessionEventRecord : 'session-query.md' ,
2026-07-23 13:56:56 +08:00
SessionEventResultFilter : 'session-query.md' ,
SessionEventSearchDocument : 'session-query.md' ,
SessionEventSearchHit : 'session-query.md' ,
2026-07-24 16:40:08 +08:00
SessionEventSearchPage : 'session-query.md' ,
2026-07-23 13:56:56 +08:00
SessionEventSearchRequest : 'session-query.md' ,
2026-07-19 14:57:52 +08:00
SessionEventTrace : 'session-query.md' ,
2026-07-24 16:40:08 +08:00
SessionEventTraceObservation : 'session-query.md' ,
2026-07-19 14:57:52 +08:00
SessionEventTraceRequest : 'session-query.md' ,
SessionEventWindow : 'session-query.md' ,
SessionLineageTrace : 'session-query.md' ,
SessionRecord : 'session-query.md' ,
2026-07-23 13:56:56 +08:00
SessionResultFilter : 'session-query.md' ,
SessionSearchExecContext : 'session-query.md' ,
SessionSearchHit : 'session-query.md' ,
SessionSearchPage : 'session-query.md' ,
SessionSearchRequest : 'session-query.md' ,
2026-07-24 16:40:08 +08:00
SessionTitleObservation : 'session-query.md' ,
2026-07-24 18:13:11 +08:00
SessionTitleObservationResult : 'session-query.md' ,
2026-07-21 01:54:00 +08:00
SessionTitleProvider : 'session-title.md' ,
SessionTitleSnapshot : 'session-title.md' ,
2026-07-27 16:50:56 +08:00
SkillCatalogSnapshot : 'skills.md' ,
2026-07-19 14:57:52 +08:00
SkillDefinition : 'skills.md' ,
SkillLookupOptions : 'skills.md' ,
SkillProvider : 'skills.md' ,
2026-07-29 21:08:10 +08:00
SkillProviderObservation : 'skills.md' ,
2026-07-19 14:57:52 +08:00
SkillRegistration : 'skills.md' ,
SkillSummary : 'skills.md' ,
SaveTextSpill : 'spill.md' ,
SpillRef : 'spill.md' ,
2026-07-30 13:41:59 +08:00
ContinuableCreateRequest : 'subagent.md' ,
ContinuableCreateSpec : 'subagent.md' ,
2026-07-31 22:45:21 +08:00
ContinuableSetupContribution : 'subagent.md' ,
2026-07-23 17:07:38 +08:00
ContinuableStart : 'subagent.md' ,
ContinuableStartSpec : 'subagent.md' ,
2026-07-24 13:18:35 +08:00
CoordinatorMessageSource : 'subagent.md' ,
2026-07-28 00:10:24 +08:00
SubagentFollowupOptions : 'subagent.md' ,
2026-07-26 02:32:34 +08:00
SubagentListEntry : 'subagent.md' ,
2026-07-19 14:57:52 +08:00
SubagentProvider : 'subagent.md' ,
2026-07-31 22:45:21 +08:00
SubagentReportDelivery : 'subagent.md' ,
SubagentReportMessageSource : 'subagent.md' ,
SubagentReportOptions : 'subagent.md' ,
2026-07-19 14:57:52 +08:00
SubagentRun : 'subagent.md' ,
SubagentService : 'subagent.md' ,
SubagentStartRequest : 'subagent.md' ,
AssembleContext : 'system-prompt.md' ,
2026-07-30 22:09:15 +08:00
PromptContext : 'system-prompt.md' ,
2026-07-19 14:57:52 +08:00
PromptSection : 'system-prompt.md' ,
SystemPrompt : 'system-prompt.md' ,
ToolProviderResult : 'system-prompt.md' ,
TaskDoneListener : 'tasks.md' ,
TaskId : 'tasks.md' ,
TaskRead : 'tasks.md' ,
TaskSnapshot : 'tasks.md' ,
TaskStart : 'tasks.md' ,
TokenMeasurement : 'token-meter.md' ,
2026-07-26 09:01:03 +08:00
CodeDispatchLog : 'tools.md' ,
2026-07-19 14:57:52 +08:00
PostToolDecision : 'tools.md' ,
PreToolDecision : 'tools.md' ,
ToolDefinition : 'tools.md' ,
ToolExecution : 'tools.md' ,
2026-07-19 23:38:54 +08:00
ToolDispatchExecution : 'tools.md' ,
2026-07-19 14:57:52 +08:00
ToolExecutionInput : 'tools.md' ,
ToolExecutionMode : 'tools.md' ,
ToolExecutionResult : 'tools.md' ,
ToolExecutionToken : 'tools.md' ,
ToolGuard : 'tools.md' ,
ToolRegistry : 'tools.md' ,
ToolRestriction : 'tools.md' ,
ToolSchema : 'tools.md' ,
2026-07-28 18:18:34 +08:00
SettingsNamespace : 'settings.md' ,
SettingsRegisterOptions : 'settings.md' ,
SettingsScope : 'settings.md' ,
SettingsDescriptor : 'settings.md' ,
2026-07-30 19:24:21 +08:00
SettingsPathOp : 'settings.md' ,
2026-07-30 10:53:39 +08:00
SettingsDescribeOptions : 'settings.md' ,
2026-07-28 18:18:34 +08:00
SettingsUpdateSource : 'settings.md' ,
2026-07-29 14:20:06 +08:00
CredentialRef : 'credentials.md' ,
CredentialInfo : 'credentials.md' ,
ResolvedCredential : 'credentials.md' ,
2026-07-19 14:57:52 +08:00
AskUserQuestionAnswer : 'user-interaction.md' ,
AskUserQuestionRequest : 'user-interaction.md' ,
UserInteractionProvider : 'user-interaction.md' ,
WebFetchProvider : 'web.md' ,
WebFetchRequest : 'web.md' ,
WebFetchResult : 'web.md' ,
WebSearchProvider : 'web.md' ,
WebSearchRequest : 'web.md' ,
WebSearchResult : 'web.md' ,
WorkflowRun : 'workflow.md' ,
WorkflowRunInfo : 'workflow.md' ,
WorkflowStartRequest : 'workflow.md' ,
}
2026-07-28 23:48:35 +08:00
/** TypeScript lib and pinned framework types with no repository-owned data page. */
export const FOUNDATION_TYPE_NAMES : ReadonlySet < string > = new Set ( [
2026-07-19 14:57:52 +08:00
'AbortSignal' ,
'AsyncIterable' ,
'Context' ,
'Error' ,
2026-07-28 23:48:35 +08:00
'Map' ,
2026-07-28 02:11:31 +08:00
'Partial' ,
2026-07-19 14:57:52 +08:00
'Pick' ,
'Promise' ,
'Readonly' ,
] )
/** Project types deliberately documented outside the core-data catalog. */
2026-07-28 23:48:35 +08:00
export const TYPE_LINK_EXEMPTIONS : Readonly < Record < string , string > > = {
2026-07-19 14:57:52 +08:00
AgentFactory : 'agent creation seam is owned by packages/core/agent/README.md' ,
2026-07-28 17:30:12 +08:00
z : 'schemastery schema constructor is owned by vendor/schemastery (vendored upstream)' ,
2026-07-27 03:17:52 +08:00
BeginCommandRequest : 'event-local request contract is owned by packages/client/ui-slash/src/types.ts' ,
InsertReferenceRequest : 'event-local request contract is owned by packages/client/ui-slash/src/types.ts' ,
ConsumeTokenRequest : 'event-local request contract is owned by packages/client/ui-slash/src/types.ts' ,
InsertTextRequest : 'event-local request contract is owned by packages/client/ui-slash/src/types.ts' ,
2026-07-19 14:57:52 +08:00
AgentHandle : 'agent ownership handle is owned by packages/core/agent/README.md' ,
2026-08-03 20:30:33 +08:00
AgentPreset : 'discovered preset record is owned by packages/preset/agent-presets/README.md' ,
2026-08-05 16:30:14 +08:00
PresetMetadata : 'preset display text is owned by packages/preset/agent-presets/README.md' ,
2026-07-19 14:57:52 +08:00
BashEnvContributor : 'service-local extension type is owned by packages/bash/tool-bash/src/index.ts' ,
BashEnvVariableInfo : 'service-local metadata type is owned by packages/bash/tool-bash/src/index.ts' ,
CompactAgentContext : 'compaction service input is owned by packages/compact/compact/src/index.ts' ,
2026-07-30 17:40:25 +08:00
ManualCompactAgentContext : 'manual compaction service input is owned by packages/compact/compact/src/index.ts' ,
2026-07-28 15:44:53 +08:00
DirectoryPickerCapability : 'picker interaction contract is owned by packages/host/directory-picker/README.md' ,
2026-07-19 14:57:52 +08:00
CreateAgentOptions : 'agent creation contract is owned by packages/core/agent/README.md' ,
2026-07-25 16:04:48 +08:00
Domain : 'domain interface is owned by packages/storage/storage-domain/README.md' ,
2026-07-25 01:11:39 +08:00
DomainChanged : 'event-local snapshot is owned by packages/storage/storage-domain/src/events.ts' ,
DomainFacility : 'domain form facility is owned by packages/storage/storage-domain/README.md' ,
2026-07-25 16:04:48 +08:00
DomainImpl : 'domain implementation contract is owned by packages/storage/storage-domain/README.md' ,
2026-07-25 01:11:39 +08:00
DomainSpec : 'domain declaration contract is owned by packages/storage/storage-domain/README.md' ,
2026-07-24 22:49:57 +08:00
StorageBackend : 'backend contract is owned by packages/storage/storage/src/backend.ts' ,
StorageForms : 'merge-extensible form map is owned by packages/storage/storage/src/index.ts' ,
2026-07-28 01:09:55 +08:00
ProjectionDefinition : 'projection unit contract is owned by packages/session-projection/session-projection/README.md' ,
SessionProjectionMap : 'merge-extensible projection key map is owned by packages/session-projection/session-projection/src/types.ts' ,
ProjectionChangeListener : 'change-feed listener contract is owned by packages/session-projection/session-projection/src/index.ts' ,
ProjectionSnapshot : 'watermark snapshot shape is owned by packages/session-projection/session-projection/src/index.ts' ,
2026-07-28 02:11:31 +08:00
ProjectionCheckpoint : 'persisted checkpoint row map is owned by packages/session-projection/session-projection/src/index.ts' ,
2026-07-28 01:09:55 +08:00
CommandExecution : 'executor return contract is owned by packages/ui/commands/src/index.ts' ,
2026-07-28 23:48:35 +08:00
TypertContribution : 'registry contribution contract is owned by packages/typert/registry/README.md' ,
TypertFace : 'registry face identity is owned by packages/typert/registry/README.md' ,
TypertPackageFilter : 'registry package query filter is owned by packages/typert/registry/README.md' ,
TypertPackageRecord : 'registry package record is owned by packages/typert/registry/README.md' ,
TypertSchemaFilter : 'registry schema query filter is owned by packages/typert/registry/README.md' ,
TypertSchemaRecord : 'registry schema record is owned by packages/typert/registry/README.md' ,
'z.core.JSONSchema.BaseSchema' : 'zod projection output is owned by the zod v4 API' ,
'z.core.ToJSONSchemaParams' : 'zod projection parameters are owned by the zod v4 API' ,
2026-07-19 19:19:57 +08:00
InvariantInstaller : 'service-local contribution contract is owned by packages/support/invariants/README.md' ,
2026-07-19 21:17:57 +08:00
LocaleDict : 'service-local dictionary shape is owned by packages/client/i18n/src/index.ts' ,
2026-07-25 02:15:58 +08:00
WebBootGraph : 'web boot graph wire shape is owned by packages/client/modules/src/client/index.ts' ,
WebRoute : 'route registration contract is owned by packages/host/webserver/src/index.ts' ,
2026-08-04 16:21:09 +08:00
WebUpgradeRoute :
'upgrade route registration contract is owned by packages/host/webserver/src/index.ts' ,
2026-07-19 21:17:57 +08:00
ThemeTokens : 'service-local token dictionary is owned by packages/client/ui-theme/src/index.ts' ,
Translate : 'service-local bound translator is owned by packages/client/i18n/src/index.ts' ,
2026-07-19 19:19:57 +08:00
InvariantRegistration : 'service-local lifecycle handle is owned by packages/support/invariants/README.md' ,
2026-07-19 14:57:52 +08:00
PresetOption : 'deployment menu metadata is owned by packages/ui/permission/README.md' ,
PresetSpec : 'deployment preset composition is owned by packages/ui/permission/README.md' ,
2026-07-28 23:55:00 +08:00
KnobState : 'projection unit state shape is owned by packages/ui/permission/README.md' ,
PermissionSelect : 'permissions projection payload is owned by packages/ui/permission/src/types.ts' ,
2026-07-19 14:57:52 +08:00
PromptAssembly : 'assembly result is owned by packages/core/system-prompt/README.md' ,
ResumeAgentOptions : 'agent resume contract is owned by packages/core/agent/README.md' ,
SessionForkSource : 'service-local fork input is owned by packages/core/session/src/index.ts' ,
2026-07-30 17:47:48 +08:00
SubagentRunEndInfo : 'event payload contract is owned by packages/subagent/subagent/src/types.ts' ,
SubagentRunInfo : 'event payload contract is owned by packages/subagent/subagent/src/types.ts' ,
2026-07-23 03:06:57 +08:00
TelemetryRecord : 'seam-local record contract is owned by packages/telemetry/session-telemetry/src/index.ts' ,
2026-07-19 14:57:52 +08:00
WorkflowAgentEndInfo : 'event-local snapshot is owned by packages/workflow/workflow/src/index.ts' ,
WorkflowAgentInfo : 'event-local snapshot is owned by packages/workflow/workflow/src/index.ts' ,
WorkflowResultInfo : 'event-local snapshot is owned by packages/workflow/workflow/src/index.ts' ,
2026-07-24 22:49:57 +08:00
Workspace : 'workspace entity contract is owned by packages/workspace/workspace/README.md' ,
WorkspaceId : 'branded id is owned by packages/workspace/workspace/README.md' ,
2026-07-19 14:57:52 +08:00
}
2026-07-28 23:48:35 +08:00
/** Repository data policy consumed by the Cordis catalog projector. */
export const CORDIS_CATALOG_POLICY : CordisCatalogPolicy = {
linkedTypePages : LINK_MAP ,
foundationTypeNames : FOUNDATION_TYPE_NAMES ,
typeLinkExemptions : TYPE_LINK_EXEMPTIONS ,
inheritedEvents : [
{ name : 'internal/plugin' , summary : 'A plugin fiber was created.' , source : 'vendor/cordis/src/events.ts:328' } ,
{ name : 'internal/status' , summary : 'A fiber changed lifecycle state.' , source : 'vendor/cordis/src/events.ts:330' } ,
{ name : 'internal/service' , summary : 'Interception hook for a service binding (no core producer).' , source : 'vendor/cordis/src/events.ts:332' } ,
{ name : 'internal/update' , summary : 'Waterfall: a fiber config update is being applied.' , source : 'vendor/cordis/src/events.ts:334' } ,
{ name : 'internal/get' , summary : 'Waterfall: a service is being read from the store.' , source : 'vendor/cordis/src/events.ts:336' } ,
{ name : 'internal/set' , summary : 'Waterfall: a service is being written to the store.' , source : 'vendor/cordis/src/events.ts:338' } ,
{ name : 'internal/listener' , summary : 'A listener was registered.' , source : 'vendor/cordis/src/events.ts:340' } ,
{ name : 'internal/dispatch' , summary : 'An event is being dispatched to listeners.' , source : 'vendor/cordis/src/events.ts:342' } ,
{ name : 'hmr/change' , summary : 'A watched source file changed on disk.' , source : 'vendor/hmr/src/index.ts:20' } ,
2026-07-30 03:11:16 +08:00
{ name : 'hmr/reload' , summary : 'Plugins are being reloaded after a change.' , source : 'vendor/hmr/src/index.ts:22' } ,
{ name : 'hmr/config-update-failed' , summary : 'A watched config-file refresh failed.' , source : 'vendor/hmr/src/index.ts:29' } ,
2026-07-28 23:48:35 +08:00
{ name : 'exit' , summary : 'The process is exiting on a signal.' , source : 'vendor/loader/src/index.ts:23' } ,
{ name : 'loader/config-update' , summary : 'The loader config tree changed.' , source : 'vendor/loader/src/index.ts:24' } ,
{ name : 'loader/entry-init' , summary : 'A config entry is being initialized.' , source : 'vendor/loader/src/index.ts:25' } ,
{ name : 'loader/partial-dispose' , summary : 'An entry is being partially disposed on reload.' , source : 'vendor/loader/src/index.ts:26' } ,
{ name : 'loader/patch-context' , summary : 'A context is being patched during a reload.' , source : 'vendor/loader/src/index.ts:27' } ,
] ,
inheritedServices : [
{ name : 'ctx.on / ctx.once' , summary : 'Register an event listener (disposable).' , source : 'vendor/cordis/src/events.ts:34' } ,
{ name : 'ctx.emit / ctx.parallel / ctx.serial / ctx.bail / ctx.waterfall' , summary : 'Dispatch an event (sync / awaited / first-bail / veto-chain).' , source : 'vendor/cordis/src/events.ts:34' } ,
{ name : 'ctx.plugin / ctx.inject' , summary : 'Load a plugin / declare required services.' , source : 'vendor/cordis/src/registry.ts:164' } ,
{ name : 'ctx.effect' , summary : 'Register a disposable side effect tied to the fiber.' , source : 'vendor/cordis/src/fiber.ts:9' } ,
{ name : 'ctx.get / ctx.set / ctx.provide / ctx.accessor / ctx.mixin' , summary : 'Low-level service-store access and binding.' , source : 'vendor/cordis/src/reflect.ts:7' } ,
{ name : 'ctx.extend / ctx.isolate / ctx.intercept' , summary : 'Derive a child context (scoped services / isolation / interception).' , source : 'vendor/cordis/src/context.ts:42' } ,
{ name : 'ctx.root / ctx.scope / ctx.fiber / ctx.registry / ctx.reflect / ctx.events / ctx.logger' , summary : 'Ambient handles onto the running context graph.' , source : 'vendor/cordis/src/context.ts:16' } ,
{ name : 'ctx.timer (+ interval / timeout / throttle / debounce / setTimeout / setInterval)' , summary : 'Disposable timer helpers. The `timer` key is provided at runtime; the six helpers are mixed onto ctx directly (declared via Pick).' , source : 'vendor/timer/src/index.ts:4' } ,
{ name : 'ctx.loader' , summary : 'The config Loader that booted the app (present under the loader).' , source : 'vendor/loader/src/index.ts:30' } ,
{ name : 'ctx.hmr' , summary : 'The hot-module-reload watcher (present under the hmr plugin).' , source : 'vendor/hmr/src/index.ts:15' } ,
] ,
2026-06-20 19:47:09 +08:00
}
2026-07-28 23:48:35 +08:00
/** CLI entry: default writes every artifact; `--check` reports stale files.
* @returns nothing; writes files or reports freshness through the process.
2026-06-20 19:47:09 +08:00
*/
2026-07-28 23:48:35 +08:00
export function main ( ) : void {
const { projector , model } = projectCordisCatalog ( root , CORDIS_CATALOG_POLICY )
2026-07-05 00:45:06 +08:00
const outputs : [ string , string ] [ ] = [
2026-07-28 23:48:35 +08:00
[ OUT_EVENTS , renderEvents ( [ . . . model . events ] , CORDIS_CATALOG_POLICY ) ] ,
[ OUT_SERVICES , renderServices ( [ . . . model . services ] , CORDIS_CATALOG_POLICY ) ] ,
[ OUT_RUNTIME_API , projector . renderRuntimeApi ( model ) ] ,
2026-07-20 16:32:08 +08:00
. . . renderCordisCoreApiPages ( ) ,
2026-07-05 00:45:06 +08:00
]
2026-06-20 19:47:09 +08:00
if ( process . argv . includes ( '--check' ) ) {
2026-07-05 00:45:06 +08:00
const stale : string [ ] = [ ]
for ( const [ out , content ] of outputs ) {
let committed : string | null = null
try {
committed = readFileSync ( resolve ( root , out ) , 'utf8' )
} catch {
2026-07-28 23:48:35 +08:00
// Only ENOENT is expected; either read failure has the same remedy.
2026-07-05 00:45:06 +08:00
committed = null
}
if ( committed !== content ) stale . push ( out )
2026-06-20 19:47:09 +08:00
}
2026-07-05 00:45:06 +08:00
if ( stale . length === 0 ) {
2026-07-20 16:32:08 +08:00
console . log ( ` gen-cordis-catalog: ${ outputs . length } generated file(s) are up to date. ` )
2026-06-20 19:47:09 +08:00
process . exit ( 0 )
}
2026-07-05 00:45:06 +08:00
console . error ( ` gen-cordis-catalog: ${ stale . join ( ' and ' ) } ${ stale . length === 1 ? 'is' : 'are' } stale. Run \` pnpm run gen-cordis-catalog \` and commit the result. ` )
2026-06-20 19:47:09 +08:00
process . exit ( 1 )
}
2026-07-20 16:32:08 +08:00
for ( const [ out , content ] of outputs ) {
const destination = resolve ( root , out )
mkdirSync ( dirname ( destination ) , { recursive : true } )
writeFileSync ( destination , content )
}
console . log ( ` gen-cordis-catalog: wrote ${ outputs . length } generated file(s). ` )
2026-06-20 19:47:09 +08:00
}
2026-07-28 23:48:35 +08:00
if ( process . argv [ 1 ] && import . meta . filename === resolve ( process . argv [ 1 ] ) ) main ( )