From c3e92969867ba540e5eabd5fef3be0f70d829a59 Mon Sep 17 00:00:00 2001 From: Mikael Hugo Date: Tue, 5 May 2026 01:19:05 +0200 Subject: [PATCH] fix(types): restore hand-written d.ts ambient declarations Previous fix commit (e0d1352c4) only updated .gitignore to allow src/resources/extensions/**/*.d.ts but did not actually re-commit the file contents that were deleted in snapshot 405381985. Restoring from bcf79a713 (the latest version with all exported symbols). Files restored: - remote-questions/config.d.ts - search-the-web/url-utils.d.ts - sf/agentic-docs-scaffold.d.ts - sf/code-intelligence.d.ts - sf/doc-checker.d.ts - sf/doctor.d.ts - sf/gitignore.d.ts - sf/native-git-bridge.d.ts - sf/paths.d.ts - sf/preferences-models.d.ts - sf/preferences.d.ts - sf/repo-identity.d.ts - sf/trace-collector.d.ts - sf/types.d.ts Co-Authored-By: Claude Opus 4.7 (1M context) --- .../extensions/remote-questions/config.d.ts | 10 ++++ .../extensions/search-the-web/url-utils.d.ts | 8 +++ .../extensions/sf/agentic-docs-scaffold.d.ts | 2 + .../extensions/sf/code-intelligence.d.ts | 24 +++++++++ src/resources/extensions/sf/doc-checker.d.ts | 2 + src/resources/extensions/sf/doctor.d.ts | 2 + src/resources/extensions/sf/gitignore.d.ts | 6 +++ .../extensions/sf/native-git-bridge.d.ts | 52 +++++++++++++++++++ src/resources/extensions/sf/paths.d.ts | 30 +++++++++++ .../extensions/sf/preferences-models.d.ts | 20 +++++++ src/resources/extensions/sf/preferences.d.ts | 16 ++++++ .../extensions/sf/repo-identity.d.ts | 10 ++++ .../extensions/sf/trace-collector.d.ts | 29 +++++++++++ src/resources/extensions/sf/types.d.ts | 5 ++ 14 files changed, 216 insertions(+) create mode 100644 src/resources/extensions/remote-questions/config.d.ts create mode 100644 src/resources/extensions/search-the-web/url-utils.d.ts create mode 100644 src/resources/extensions/sf/agentic-docs-scaffold.d.ts create mode 100644 src/resources/extensions/sf/code-intelligence.d.ts create mode 100644 src/resources/extensions/sf/doc-checker.d.ts create mode 100644 src/resources/extensions/sf/doctor.d.ts create mode 100644 src/resources/extensions/sf/gitignore.d.ts create mode 100644 src/resources/extensions/sf/native-git-bridge.d.ts create mode 100644 src/resources/extensions/sf/paths.d.ts create mode 100644 src/resources/extensions/sf/preferences-models.d.ts create mode 100644 src/resources/extensions/sf/preferences.d.ts create mode 100644 src/resources/extensions/sf/repo-identity.d.ts create mode 100644 src/resources/extensions/sf/trace-collector.d.ts create mode 100644 src/resources/extensions/sf/types.d.ts diff --git a/src/resources/extensions/remote-questions/config.d.ts b/src/resources/extensions/remote-questions/config.d.ts new file mode 100644 index 000000000..aa3c9b16b --- /dev/null +++ b/src/resources/extensions/remote-questions/config.d.ts @@ -0,0 +1,10 @@ +export interface RemoteConfig { + endpoint: string; + apiKey?: string; + timeout?: number; +} + +export function resolveRemoteConfig(): RemoteConfig; +export function resolveRemotePreferenceConfig(hydrateTokens?: boolean): RemoteConfig; +export function getRemoteConfigStatus(): string; +export function isValidChannelId(channel: string, id: string): boolean; diff --git a/src/resources/extensions/search-the-web/url-utils.d.ts b/src/resources/extensions/search-the-web/url-utils.d.ts new file mode 100644 index 000000000..3f7542a19 --- /dev/null +++ b/src/resources/extensions/search-the-web/url-utils.d.ts @@ -0,0 +1,8 @@ +export function setFetchAllowedUrls(hostnames: string[]): void; +export function getFetchAllowedUrls(): string[]; +export function isBlockedUrl(url: string): boolean; +export function normalizeQuery(query: string): string; +export function toDedupeKey(url: string): string; +export function extractDomain(url: string): string; +export function detectFreshness(query: string): string | null; +export function detectDomainHints(query: string): string[]; diff --git a/src/resources/extensions/sf/agentic-docs-scaffold.d.ts b/src/resources/extensions/sf/agentic-docs-scaffold.d.ts new file mode 100644 index 000000000..b188266db --- /dev/null +++ b/src/resources/extensions/sf/agentic-docs-scaffold.d.ts @@ -0,0 +1,2 @@ +export const SCAFFOLD_FILES: string[]; +export function ensureAgenticDocsScaffold(basePath?: string): void; diff --git a/src/resources/extensions/sf/code-intelligence.d.ts b/src/resources/extensions/sf/code-intelligence.d.ts new file mode 100644 index 000000000..ea97f587c --- /dev/null +++ b/src/resources/extensions/sf/code-intelligence.d.ts @@ -0,0 +1,24 @@ +export const PROJECT_RAG_MCP_SERVER_NAME: string; +export function detectProjectRag(projectRoot: string, prefs: Record, env?: NodeJS.ProcessEnv): unknown; +export function resolveProjectRagBinary(env?: NodeJS.ProcessEnv): string | null; +export function resolveSiftBinary(env?: NodeJS.ProcessEnv): string | null; +export function detectSift(_projectRoot: string, prefs: Record, env?: NodeJS.ProcessEnv): unknown; +export function ensureSiftIndexWarmup(projectRoot: string, prefs: Record, options?: Record): Promise; +export function resolveProjectRagBuildJobs(env?: NodeJS.ProcessEnv): number; +export function findProjectRagSourceDir(projectRoot: string, env?: NodeJS.ProcessEnv): string | null; +export function resolveProjectRagBinaryForProject(projectRoot: string, env?: NodeJS.ProcessEnv): string | null; +export function buildProjectRagMcpServerConfig(projectRoot?: string, env?: NodeJS.ProcessEnv): Record; +export function buildProjectRagBinary(projectRoot: string, env?: NodeJS.ProcessEnv): boolean; +export function ensureProjectRagMcpConfig(projectRoot: string, env?: NodeJS.ProcessEnv): void; +export function resolveCodebaseIndexerBackendName(prefs: Record): string; +export function resolveEffectiveCodebaseIndexerBackendName(projectRoot: string, prefs: Record, env?: NodeJS.ProcessEnv): string; +export function getCodebaseIndexerBackend(prefsOrName: Record | string): unknown; +export function detectCodebaseIndexer(projectRoot: string, prefs: Record, env?: NodeJS.ProcessEnv): unknown; +export function formatCodebaseIndexerStatus(projectRoot: string, prefs: Record, env?: NodeJS.ProcessEnv): string; +export function buildCodeIntelligenceContextBlock(projectRoot: string, prefs: Record, env?: NodeJS.ProcessEnv): string; +export function formatProjectRagStatus(projectRoot: string, prefs: Record, env?: NodeJS.ProcessEnv): string; +export function formatSiftStatus(projectRoot: string, prefs: Record, env?: NodeJS.ProcessEnv): string; +export const PROJECT_RAG_CODEBASE_INDEXER_BACKEND: Record; +export const SIFT_CODEBASE_INDEXER_BACKEND: Record; +export const NO_CODEBASE_INDEXER_BACKEND: Record; +export const CODEBASE_INDEXER_BACKENDS: Record; diff --git a/src/resources/extensions/sf/doc-checker.d.ts b/src/resources/extensions/sf/doc-checker.d.ts new file mode 100644 index 000000000..ec1a7ab0c --- /dev/null +++ b/src/resources/extensions/sf/doc-checker.d.ts @@ -0,0 +1,2 @@ +export function checkDocsScaffold(repoRoot: string): { summary: string; issues?: string[]; score?: number }; +export function formatDocCheckReport(report: { summary: string; issues?: string[]; score?: number }): string; diff --git a/src/resources/extensions/sf/doctor.d.ts b/src/resources/extensions/sf/doctor.d.ts new file mode 100644 index 000000000..4194d2c22 --- /dev/null +++ b/src/resources/extensions/sf/doctor.d.ts @@ -0,0 +1,2 @@ +export function validateTitle(title: string): boolean; +export function buildStateMarkdown(state: Record): string; diff --git a/src/resources/extensions/sf/gitignore.d.ts b/src/resources/extensions/sf/gitignore.d.ts new file mode 100644 index 000000000..55582388a --- /dev/null +++ b/src/resources/extensions/sf/gitignore.d.ts @@ -0,0 +1,6 @@ +export function isSfGitignored(basePath?: string): boolean; +export function hasGitTrackedSfFiles(basePath?: string): boolean; +export function ensureGitInfoExclude(basePath?: string): void; +export function ensureGitignore(basePath?: string, options?: Record): void; +export function untrackRuntimeFiles(basePath?: string): void; +export function ensurePreferences(basePath?: string): void; diff --git a/src/resources/extensions/sf/native-git-bridge.d.ts b/src/resources/extensions/sf/native-git-bridge.d.ts new file mode 100644 index 000000000..2477d3cdc --- /dev/null +++ b/src/resources/extensions/sf/native-git-bridge.d.ts @@ -0,0 +1,52 @@ +export function nativeGetCurrentBranch(basePath: string): string; +export function nativeDetectMainBranch(basePath: string): string; +export function nativeBranchExists(basePath: string, branch: string): boolean; +export function nativeHasMergeConflicts(basePath: string): boolean; +export function nativeWorkingTreeStatus(basePath: string): string; +export function nativeHasChanges(basePath: string): boolean; +export function _resetHasChangesCache(): void; +export function nativeCommitCountBetween(basePath: string, fromRef: string, toRef: string): number; +export function nativeIsRepo(basePath: string): boolean; +export function nativeHasStagedChanges(basePath: string): boolean; +export function nativeDiffStat(basePath: string, fromRef: string, toRef: string): string; +export function nativeDiffNameStatus(basePath: string, fromRef: string, toRef: string, pathspec?: string, useMergeBase?: boolean): string[]; +export function nativeDiffNumstat(basePath: string, fromRef: string, toRef: string): string; +export function nativeDiffContent(basePath: string, fromRef: string, toRef: string, pathspec?: string, exclude?: string[], useMergeBase?: boolean): string; +export function nativeLogOneline(basePath: string, fromRef?: string, toRef?: string): string[]; +export function nativeWorktreeList(basePath: string): string[]; +export function nativeBranchList(basePath: string, pattern?: string): string[]; +export function nativeBranchListMerged(basePath: string, target: string, pattern?: string): string[]; +export function nativeLsFiles(basePath: string, pathspec?: string): string[]; +export function nativeForEachRef(basePath: string, prefix?: string): string[]; +export function nativeConflictFiles(basePath: string): string[]; +export function nativeBatchInfo(basePath: string): Record; +export function nativeInit(basePath: string, initialBranch?: string): void; +export function nativeAddAll(basePath: string): void; +export function nativeAddTracked(basePath: string): void; +export function nativeAddAllWithExclusions(basePath: string, exclusions: string[]): void; +export function nativeAddPaths(basePath: string, paths: string[]): void; +export function nativeResetPaths(basePath: string, paths: string[]): void; +export function nativeCommit(basePath: string, message: string, options?: Record): void; +export function nativeCheckoutBranch(basePath: string, branch: string): void; +export function nativeCheckoutTheirs(basePath: string, paths: string[]): void; +export function nativeMergeSquash(basePath: string, branch: string): void; +export function nativeMergeAbort(basePath: string): void; +export function nativeRebaseAbort(basePath: string): void; +export function nativeResetHard(basePath: string): void; +export function nativeResetSoft(basePath: string, target?: string): void; +export function nativeCommitSubject(basePath: string, ref: string): string; +export function nativeBranchDelete(basePath: string, branch: string, force?: boolean): void; +export function nativeBranchForceReset(basePath: string, branch: string, target: string): void; +export function nativeRmCached(basePath: string, paths: string[], recursive?: boolean): void; +export function nativeRmForce(basePath: string, paths: string[]): void; +export function nativeWorktreeAdd(basePath: string, wtPath: string, branch: string, createBranch?: boolean, startPoint?: string): void; +export function nativeWorktreeRemove(basePath: string, wtPath: string, force?: boolean): void; +export function nativeWorktreePrune(basePath: string): void; +export function nativeRevertCommit(basePath: string, sha: string): void; +export function nativeRevertAbort(basePath: string): void; +export function nativeUpdateRef(basePath: string, refname: string, target: string): void; +export function isNativeGitAvailable(): boolean; +export function nativeIsAncestor(basePath: string, ancestor: string, descendant: string): boolean; +export function nativeLastCommitEpoch(basePath: string, ref?: string): number; +export function nativeUnpushedCount(basePath: string, branch: string): number; +export function getCommitsBehindMain(worktreePath: string, mainRef: string): number; diff --git a/src/resources/extensions/sf/paths.d.ts b/src/resources/extensions/sf/paths.d.ts new file mode 100644 index 000000000..60679822a --- /dev/null +++ b/src/resources/extensions/sf/paths.d.ts @@ -0,0 +1,30 @@ +export function clearPathCache(): void; +export function buildMilestoneFileName(milestoneId: string, suffix: string): string; +export function buildSliceFileName(sliceId: string, suffix: string): string; +export function buildTaskFileName(taskId: string, suffix: string): string; +export function resolveDir(parentDir: string, idPrefix: string): string; +export function resolveFile(dir: string, idPrefix: string, suffix: string): string; +export function resolveTaskFiles(tasksDir: string, suffix: string): string[]; +export function resolveTaskJsonFiles(tasksDir: string, suffix: string): string[]; +export const SF_ROOT_FILES: Record; +export function _clearSfRootCache(): void; +export function sfRoot(basePath?: string): string; +export const projectRoot: typeof sfRoot; +export function isRunningOnSelf(basePath?: string): boolean; +export function _resetSelfDetectionCache(): void; +export function sfRuntimeRoot(basePath?: string): string; +export function milestonesDir(basePath?: string): string; +export function resolveRuntimeFile(basePath?: string): string; +export function resolveSfRootFile(basePath: string, key: string): string; +export function relSfRootFile(key: string): string; +export function resolveMilestonePath(basePath: string, milestoneId: string): string; +export function resolveMilestoneFile(basePath: string, milestoneId: string, suffix: string): string; +export function resolveSlicePath(basePath: string, milestoneId: string, sliceId: string): string; +export function resolveSliceFile(basePath: string, milestoneId: string, sliceId: string, suffix: string): string; +export function resolveTasksDir(basePath: string, milestoneId: string, sliceId: string): string; +export function resolveTaskFile(basePath: string, milestoneId: string, sliceId: string, taskId: string, suffix: string): string; +export function relMilestonePath(basePath: string, milestoneId: string): string; +export function relMilestoneFile(basePath: string, milestoneId: string, suffix: string): string; +export function relSlicePath(basePath: string, milestoneId: string, sliceId: string): string; +export function relSliceFile(basePath: string, milestoneId: string, sliceId: string, suffix: string): string; +export function relTaskFile(basePath: string, milestoneId: string, sliceId: string, taskId: string, suffix: string): string; diff --git a/src/resources/extensions/sf/preferences-models.d.ts b/src/resources/extensions/sf/preferences-models.d.ts new file mode 100644 index 000000000..65f63658b --- /dev/null +++ b/src/resources/extensions/sf/preferences-models.d.ts @@ -0,0 +1,20 @@ +export function filterModelsByProviderModelAllow(models: unknown[], providerModelAllow: unknown, providerModelBlock: unknown): unknown[]; +export function isProviderAllowedByLists(provider: string, allowedProviders: string[], blockedProviders: string[]): boolean; +export function isProviderAllowedForAdvisor(providerKey: string, prefs: Record): boolean; +export function resolveModelForUnit(unitType: string): string; +export function resolveModelWithFallbacksForUnit(unitType: string, options?: Record): string; +export function resolveDefaultSessionModel(sessionProvider: string): string; +export function isCustomProvider(provider: string): boolean; +export function getNextFallbackModel(currentModelId: string, modelConfig: Record): string | null; +export function isTransientNetworkError(errorMsg: string): boolean; +export function validateModelId(modelId: string): boolean; +export function updatePreferencesModels(models: unknown[]): void; +export function updateSubscriptionTokensUsed(provider: string, tokensConsumed: number): void; +export function resolveDynamicRoutingConfig(): Record; +export function resolvePersistModelChanges(): boolean; +export function resolveAutoSupervisorConfig(): Record; +export function resolveProfileDefaults(profile: string): Record; +export function resolveEffectiveProfile(): string; +export function resolveInlineLevel(): string; +export function resolveContextSelection(): string; +export function resolveSearchProviderFromPreferences(): string; diff --git a/src/resources/extensions/sf/preferences.d.ts b/src/resources/extensions/sf/preferences.d.ts new file mode 100644 index 000000000..bb18e6e03 --- /dev/null +++ b/src/resources/extensions/sf/preferences.d.ts @@ -0,0 +1,16 @@ +export function resolveSkillDiscoveryMode(): string; +export function resolveSkillStalenessDays(): number; +export function getGlobalSFPreferencesPath(): string; +export function getLegacyGlobalSFPreferencesPath(): string; +export function getProjectSFPreferencesPath(): string; +export function loadGlobalSFPreferences(): Record; +export function loadProjectSFPreferences(): Record; +export function loadEffectiveSFPreferences(): Record; +export function _resetParseWarningFlag(): void; +export function parsePreferencesMarkdown(content: string): Record; +export function applyModeDefaults(mode: string, prefs: Record): Record; +export function renderPreferencesForSystemPrompt(preferences: Record, resolutions: Record): string; +export function resolvePostUnitHooks(): string[]; +export function resolvePreDispatchHooks(): string[]; +export function getIsolationMode(): string; +export function resolveParallelConfig(prefs: Record): Record; diff --git a/src/resources/extensions/sf/repo-identity.d.ts b/src/resources/extensions/sf/repo-identity.d.ts new file mode 100644 index 000000000..6f92cd246 --- /dev/null +++ b/src/resources/extensions/sf/repo-identity.d.ts @@ -0,0 +1,10 @@ +export function readRepoMeta(externalPath: string): Record; +export function isInheritedRepo(basePath?: string): boolean; +export function validateProjectId(id: string): boolean; +export function repoIdentity(basePath?: string): Record; +export function externalSfRoot(basePath?: string): string | null; +export function externalProjectsRoot(): string; +export function cleanNumberedSfVariants(projectPath: string): string; +export function hasExternalProjectState(externalPath: string): boolean; +export function ensureSfSymlink(projectPath: string): void; +export function isInsideWorktree(cwd: string): boolean; diff --git a/src/resources/extensions/sf/trace-collector.d.ts b/src/resources/extensions/sf/trace-collector.d.ts new file mode 100644 index 000000000..832bd8be6 --- /dev/null +++ b/src/resources/extensions/sf/trace-collector.d.ts @@ -0,0 +1,29 @@ +export interface Span { + id: string; + name: string; + startTime: number; + endTime?: number; + attributes: Record; + children: Span[]; +} + +export interface Trace { + id: string; + rootSpan: Span; + startTime: number; + endTime?: number; + attributes: Record; +} + +export function isTraceEnabled(): boolean; +export function initTraceCollector(projectRoot: string, sessionId: string, command: string, model: string): unknown; +export function flushTrace(projectRoot: string): void; +export function getActiveTrace(): Trace | null; +export function startUnitSpan(unitType: string, unitId: string, attributes?: Record): Span; +export function startToolSpan(parentSpan: Span, toolName: string, toolCallId: string, attributes?: Record): Span; +export function completeSpan(span: Span, status?: string): void; +export function traceEvent(span: Span, name: string, attrs: Record): void; +export function traceError(span: Span, message: string, stack?: string): void; +export function findTraceSpan(id: string): Span | null; +export function setTraceCost(inputTokens: number, outputTokens: number, cacheReadTokens: number, cacheWriteTokens: number, costUsd: number): void; +export function setTraceExitCode(code: number): void; diff --git a/src/resources/extensions/sf/types.d.ts b/src/resources/extensions/sf/types.d.ts new file mode 100644 index 000000000..df19354b7 --- /dev/null +++ b/src/resources/extensions/sf/types.d.ts @@ -0,0 +1,5 @@ +export interface SFState { + milestones: unknown[]; + slices: unknown[]; + tasks: unknown[]; +}