fix: 清理 main 分支的 stub .js 文件,恢复有 .ts 源文件的命令模块

This commit is contained in:
DoSun 2026-05-13 10:36:04 +08:00
parent 3bfc695cb4
commit c2eb6bff90
24 changed files with 275 additions and 277 deletions

View File

@ -1,49 +1,49 @@
// Type declarations for custom Ink JSX elements
// Note: The detailed prop types are defined in ink-jsx.d.ts via React module augmentation.
// This file provides the global JSX namespace fallback declarations.
import type { ReactNode, Ref } from 'react'
import type { ClickEvent } from '../core/events/click-event.js'
import type { FocusEvent } from '../core/events/focus-event.js'
import type { KeyboardEvent } from '../core/events/keyboard-event.js'
import type { Styles, TextStyles } from '../core/styles.js'
import type { DOMElement } from '../core/dom.js'
import type { ReactNode, Ref } from 'react';
import type { ClickEvent } from '../core/events/click-event.js';
import type { FocusEvent } from '../core/events/focus-event.js';
import type { KeyboardEvent } from '../core/events/keyboard-event.js';
import type { Styles, TextStyles } from '../core/styles.js';
import type { DOMElement } from '../core/dom.js';
declare global {
namespace JSX {
interface IntrinsicElements {
'ink-box': {
ref?: Ref<DOMElement>
tabIndex?: number
autoFocus?: boolean
onClick?: (event: ClickEvent) => void
onFocus?: (event: FocusEvent) => void
onFocusCapture?: (event: FocusEvent) => void
onBlur?: (event: FocusEvent) => void
onBlurCapture?: (event: FocusEvent) => void
onMouseEnter?: () => void
onMouseLeave?: () => void
onKeyDown?: (event: KeyboardEvent) => void
onKeyDownCapture?: (event: KeyboardEvent) => void
style?: Styles
stickyScroll?: boolean
children?: ReactNode
}
ref?: Ref<DOMElement>;
tabIndex?: number;
autoFocus?: boolean;
onClick?: (event: ClickEvent) => void;
onFocus?: (event: FocusEvent) => void;
onFocusCapture?: (event: FocusEvent) => void;
onBlur?: (event: FocusEvent) => void;
onBlurCapture?: (event: FocusEvent) => void;
onMouseEnter?: () => void;
onMouseLeave?: () => void;
onKeyDown?: (event: KeyboardEvent) => void;
onKeyDownCapture?: (event: KeyboardEvent) => void;
style?: Styles;
stickyScroll?: boolean;
children?: ReactNode;
};
'ink-text': {
style?: Styles
textStyles?: TextStyles
children?: ReactNode
}
style?: Styles;
textStyles?: TextStyles;
children?: ReactNode;
};
'ink-link': {
href?: string
children?: ReactNode
}
href?: string;
children?: ReactNode;
};
'ink-raw-ansi': {
rawText?: string
rawWidth?: number
rawHeight?: number
}
rawText?: string;
rawWidth?: number;
rawHeight?: number;
};
}
}
}
export {}
export {};

View File

@ -8,47 +8,47 @@
* This file must be a module (have an import/export) for `declare module`
* augmentation to work correctly.
*/
import type { ReactNode, Ref } from 'react'
import type { ClickEvent } from '../core/events/click-event.js'
import type { FocusEvent } from '../core/events/focus-event.js'
import type { KeyboardEvent } from '../core/events/keyboard-event.js'
import type { Styles, TextStyles } from '../core/styles.js'
import type { DOMElement } from '../core/dom.js'
import type { ReactNode, Ref } from 'react';
import type { ClickEvent } from '../core/events/click-event.js';
import type { FocusEvent } from '../core/events/focus-event.js';
import type { KeyboardEvent } from '../core/events/keyboard-event.js';
import type { Styles, TextStyles } from '../core/styles.js';
import type { DOMElement } from '../core/dom.js';
declare module 'react' {
namespace JSX {
interface IntrinsicElements {
'ink-box': {
ref?: Ref<DOMElement>
tabIndex?: number
autoFocus?: boolean
onClick?: (event: ClickEvent) => void
onFocus?: (event: FocusEvent) => void
onFocusCapture?: (event: FocusEvent) => void
onBlur?: (event: FocusEvent) => void
onBlurCapture?: (event: FocusEvent) => void
onMouseEnter?: () => void
onMouseLeave?: () => void
onKeyDown?: (event: KeyboardEvent) => void
onKeyDownCapture?: (event: KeyboardEvent) => void
style?: Styles
stickyScroll?: boolean
children?: ReactNode
}
ref?: Ref<DOMElement>;
tabIndex?: number;
autoFocus?: boolean;
onClick?: (event: ClickEvent) => void;
onFocus?: (event: FocusEvent) => void;
onFocusCapture?: (event: FocusEvent) => void;
onBlur?: (event: FocusEvent) => void;
onBlurCapture?: (event: FocusEvent) => void;
onMouseEnter?: () => void;
onMouseLeave?: () => void;
onKeyDown?: (event: KeyboardEvent) => void;
onKeyDownCapture?: (event: KeyboardEvent) => void;
style?: Styles;
stickyScroll?: boolean;
children?: ReactNode;
};
'ink-text': {
style?: Styles
textStyles?: TextStyles
children?: ReactNode
}
style?: Styles;
textStyles?: TextStyles;
children?: ReactNode;
};
'ink-link': {
href?: string
children?: ReactNode
}
href?: string;
children?: ReactNode;
};
'ink-raw-ansi': {
rawText?: string
rawWidth?: number
rawHeight?: number
}
rawText?: string;
rawWidth?: number;
rawHeight?: number;
};
}
}
}

120
scripts/auto-rebase.ts Normal file
View File

@ -0,0 +1,120 @@
import { execSync } from 'child_process'
import { readFileSync, writeFileSync } from 'fs'
function run(cmd: string): string {
try {
return execSync(cmd, { encoding: 'utf-8', env: { ...process.env, GIT_EDITOR: 'true' } })
} catch (e: any) {
return (e.stdout || '') + (e.stderr || '')
}
}
function getConflictedFiles(): string[] {
const out = run('git diff --name-only --diff-filter=U')
return out.trim().split('\n').filter(Boolean)
}
function resolveConflictMarkers(content: string): string {
if (!content.includes('<<<<<<<')) return content
const lines = content.split('\n')
const result: string[] = []
let state: 'normal' | 'ours' | 'theirs' = 'normal'
let oursLines: string[] = []
let theirsLines: string[] = []
for (const line of lines) {
if (line.startsWith('<<<<<<<')) {
state = 'ours'
oursLines = []
theirsLines = []
} else if (line === '=======') {
state = 'theirs'
} else if (line.startsWith('>>>>>>>')) {
state = 'normal'
result.push(...oursLines, ...theirsLines)
} else if (state === 'ours') {
oursLines.push(line)
} else if (state === 'theirs') {
theirsLines.push(line)
} else {
result.push(line)
}
}
return result.join('\n')
}
function resolveConflicts(): boolean {
const files = getConflictedFiles()
if (files.length === 0) return true
console.log(` Conflicted files: ${files.join(', ')}`)
for (const file of files) {
if (file === 'bun.lock') {
run(`git checkout --theirs "${file}"`)
} else {
try {
const content = readFileSync(file, 'utf-8')
const resolved = resolveConflictMarkers(content)
writeFileSync(file, resolved, 'utf-8')
} catch {
run(`git checkout --theirs "${file}"`)
}
}
run(`git add "${file}"`)
}
return true
}
console.log('Starting automated rebase...\n')
let conflictCount = 0
let iterations = 0
const maxIterations = 300
// Start the rebase
let output = run('git rebase origin/main')
console.log(output.substring(0, 500))
while (iterations++ < maxIterations) {
const status = run('git status')
if (!status.includes('rebasing') && !status.includes('rebase')) {
console.log('\nRebase completed!')
break
}
const conflicted = getConflictedFiles()
if (conflicted.length > 0) {
conflictCount++
const commitMatch = status.match(/Could not apply (\w+)/)
const commitInfo = commitMatch ? commitMatch[1] : 'unknown'
console.log(`\n[${iterations}] Conflict #${conflictCount} (${commitInfo}): ${conflicted.join(', ')}`)
// Handle delete/modify conflicts
for (const file of conflicted) {
const diffOutput = run(`git diff --diff-filter=D -- "${file}"`)
if (diffOutput.includes('deleted in')) {
// If file was deleted in the commit being applied, accept the deletion
run(`git rm "${file}" 2>/dev/null || git checkout --theirs "${file}" && git add "${file}"`)
}
}
resolveConflicts()
}
output = run('git rebase --continue')
if (output.includes('successfully rebased')) {
console.log('\nRebase completed successfully!')
break
}
if (output.includes('CONFLICT') || output.includes('could not apply')) {
continue
}
if (output.includes('fatal') || output.includes('error: failed')) {
console.error('Fatal error:', output)
break
}
console.log(output.substring(0, 300))
}
console.log(`\nTotal conflicts resolved: ${conflictCount}`)

View File

@ -1 +0,0 @@
export default { name: 'agents-platform', type: 'local', isEnabled: () => false }

View File

@ -1,3 +0,0 @@
import type { Command } from '../../types/command.js'
declare const _default: Command
export default _default

View File

@ -1 +0,0 @@
export default { isEnabled: () => false, isHidden: true, name: 'stub' };

View File

@ -1 +0,0 @@
export default { isEnabled: () => false, isHidden: true, name: 'stub' };

View File

@ -1,3 +0,0 @@
import type { Command } from '../../types/command.js'
declare const _default: Command
export default _default

View File

@ -1 +0,0 @@
export default { isEnabled: () => false, isHidden: true, name: 'stub' };

View File

@ -1 +0,0 @@
export default { isEnabled: () => false, isHidden: true, name: 'stub' };

View File

@ -1 +0,0 @@
export default { isEnabled: () => false, isHidden: true, name: 'stub' };

View File

@ -1,3 +0,0 @@
import type { Command } from '../../types/command.js'
declare const _default: Command
export default _default

View File

@ -1 +0,0 @@
export default { isEnabled: () => false, isHidden: true, name: 'stub' };

View File

@ -1 +0,0 @@
export default { isEnabled: () => false, isHidden: true, name: 'stub' };

View File

@ -1,4 +0,0 @@
const stub = { isEnabled: () => false, isHidden: true, name: 'stub' }
export default stub
export const resetLimits = stub
export const resetLimitsNonInteractive = stub

View File

@ -1 +0,0 @@
export default { isEnabled: () => false, isHidden: true, name: 'stub' };

View File

@ -1 +0,0 @@
export default { isEnabled: () => false, isHidden: true, name: 'stub' };

View File

@ -1,8 +0,0 @@
// Auto-generated type stub — replace with real implementation
export type StdoutMessage = any
export type SDKControlInitializeRequest = any
export type SDKControlInitializeResponse = any
export type SDKControlMcpSetServersResponse = any
export type SDKControlReloadPluginsResponse = any
export type StdinMessage = any
export type SDKPartialAssistantMessage = any

View File

@ -1,2 +0,0 @@
// Auto-generated type stub — replace with real implementation
export type EffortLevel = 'low' | 'medium' | 'high' | 'xhigh' | 'max'

18
src/types/global.d.ts vendored
View File

@ -9,7 +9,6 @@
declare namespace MACRO {
export const VERSION: string
export const BUILD_TIME: string
export const COMMIT: string
export const FEEDBACK_CHANNEL: string
export const ISSUES_EXPLAINER: string
export const NATIVE_PACKAGE_URL: string
@ -22,9 +21,7 @@ declare namespace MACRO {
// These are referenced inside `MACRO(() => ...)` or `false && ...` blocks.
// Model resolution (internal)
declare function resolveAntModel(
model: string,
): import('../utils/model/antModels.js').AntModel | undefined
declare function resolveAntModel(model: string): import('../utils/model/antModels.js').AntModel | undefined
declare function getAntModels(): import('../utils/model/antModels.js').AntModel[]
declare function getAntModelOverrideConfig(): {
defaultSystemPromptSuffix?: string
@ -34,13 +31,7 @@ declare function getAntModelOverrideConfig(): {
// Companion reactions handled by src/buddy/companionReact.ts (direct import)
// Metrics (internal)
type ApiMetricEntry = {
ttftMs: number
firstTokenTime: number
lastTokenTime: number
responseLengthBaseline: number
endResponseLength: number
}
type ApiMetricEntry = { ttftMs: number; firstTokenTime: number; lastTokenTime: number; responseLengthBaseline: number; endResponseLength: number }
declare const apiMetricsRef: React.RefObject<ApiMetricEntry[]> | null
declare function computeTtftText(metrics: ApiMetricEntry[]): string
@ -62,10 +53,7 @@ declare const HOOK_TIMING_DISPLAY_THRESHOLD_MS: number
declare type T = unknown
// Tungsten (internal)
declare function TungstenPill(props?: {
key?: string
selected?: boolean
}): JSX.Element | null
declare function TungstenPill(props?: { key?: string; selected?: boolean }): JSX.Element | null
// ============================================================================
// Build-time constants BUILD_TARGET/BUILD_ENV/INTERFACE_TYPE — removed (zero runtime usage)

View File

@ -1,52 +1,45 @@
// Type declarations for custom Ink JSX elements
// Note: The detailed prop types are defined in ink-jsx.d.ts via React module augmentation.
// This file provides the global JSX namespace fallback declarations.
import type { ReactNode, Ref } from 'react'
import type {
ClickEvent,
FocusEvent,
KeyboardEvent,
Styles,
TextStyles,
DOMElement,
} from '@anthropic/ink'
import type { ReactNode, Ref } from 'react';
import type { ClickEvent, FocusEvent, KeyboardEvent, Styles, TextStyles, DOMElement } from '@anthropic/ink';
declare global {
namespace JSX {
interface IntrinsicElements {
'ink-box': {
ref?: Ref<DOMElement>
tabIndex?: number
autoFocus?: boolean
onClick?: (event: ClickEvent) => void
onFocus?: (event: FocusEvent) => void
onFocusCapture?: (event: FocusEvent) => void
onBlur?: (event: FocusEvent) => void
onBlurCapture?: (event: FocusEvent) => void
onMouseEnter?: () => void
onMouseLeave?: () => void
onKeyDown?: (event: KeyboardEvent) => void
onKeyDownCapture?: (event: KeyboardEvent) => void
style?: Styles
stickyScroll?: boolean
children?: ReactNode
}
ref?: Ref<DOMElement>;
tabIndex?: number;
autoFocus?: boolean;
onClick?: (event: ClickEvent) => void;
onFocus?: (event: FocusEvent) => void;
onFocusCapture?: (event: FocusEvent) => void;
onBlur?: (event: FocusEvent) => void;
onBlurCapture?: (event: FocusEvent) => void;
onMouseEnter?: () => void;
onMouseLeave?: () => void;
onKeyDown?: (event: KeyboardEvent) => void;
onKeyDownCapture?: (event: KeyboardEvent) => void;
style?: Styles;
stickyScroll?: boolean;
children?: ReactNode;
};
'ink-text': {
style?: Styles
textStyles?: TextStyles
children?: ReactNode
}
style?: Styles;
textStyles?: TextStyles;
children?: ReactNode;
};
'ink-link': {
href?: string
children?: ReactNode
}
href?: string;
children?: ReactNode;
};
'ink-raw-ansi': {
rawText?: string
rawWidth?: number
rawHeight?: number
}
rawText?: string;
rawWidth?: number;
rawHeight?: number;
};
}
}
}
export {}
export {};

View File

@ -8,50 +8,43 @@
* This file must be a module (have an import/export) for `declare module`
* augmentation to work correctly.
*/
import type { ReactNode, Ref } from 'react'
import type {
ClickEvent,
FocusEvent,
KeyboardEvent,
Styles,
TextStyles,
DOMElement,
} from '@anthropic/ink'
import type { ReactNode, Ref } from 'react';
import type { ClickEvent, FocusEvent, KeyboardEvent, Styles, TextStyles, DOMElement } from '@anthropic/ink';
declare module 'react' {
namespace JSX {
interface IntrinsicElements {
'ink-box': {
ref?: Ref<DOMElement>
tabIndex?: number
autoFocus?: boolean
onClick?: (event: ClickEvent) => void
onFocus?: (event: FocusEvent) => void
onFocusCapture?: (event: FocusEvent) => void
onBlur?: (event: FocusEvent) => void
onBlurCapture?: (event: FocusEvent) => void
onMouseEnter?: () => void
onMouseLeave?: () => void
onKeyDown?: (event: KeyboardEvent) => void
onKeyDownCapture?: (event: KeyboardEvent) => void
style?: Styles
stickyScroll?: boolean
children?: ReactNode
}
ref?: Ref<DOMElement>;
tabIndex?: number;
autoFocus?: boolean;
onClick?: (event: ClickEvent) => void;
onFocus?: (event: FocusEvent) => void;
onFocusCapture?: (event: FocusEvent) => void;
onBlur?: (event: FocusEvent) => void;
onBlurCapture?: (event: FocusEvent) => void;
onMouseEnter?: () => void;
onMouseLeave?: () => void;
onKeyDown?: (event: KeyboardEvent) => void;
onKeyDownCapture?: (event: KeyboardEvent) => void;
style?: Styles;
stickyScroll?: boolean;
children?: ReactNode;
};
'ink-text': {
style?: Styles
textStyles?: TextStyles
children?: ReactNode
}
style?: Styles;
textStyles?: TextStyles;
children?: ReactNode;
};
'ink-link': {
href?: string
children?: ReactNode
}
href?: string;
children?: ReactNode;
};
'ink-raw-ansi': {
rawText?: string
rawWidth?: number
rawHeight?: number
}
rawText?: string;
rawWidth?: number;
rawHeight?: number;
};
}
}
}

View File

@ -7,53 +7,25 @@
// ============================================================================
// bun:bundle — compile-time macros
// ============================================================================
declare module 'bun:bundle' {
export function feature(name: string): boolean
declare module "bun:bundle" {
export function feature(name: string): boolean;
}
declare module 'bun:ffi' {
export function dlopen<
T extends Record<string, { args: readonly string[]; returns: string }>,
>(
path: string,
symbols: T,
): {
symbols: { [K in keyof T]: (...args: unknown[]) => unknown }
close(): void
}
declare module "bun:ffi" {
export function dlopen<T extends Record<string, { args: readonly string[]; returns: string }>>(path: string, symbols: T): { symbols: { [K in keyof T]: (...args: unknown[]) => unknown }; close(): void };
}
// Third-party modules without @types packages
declare module 'bidi-js' {
function getEmbeddingLevels(
text: string,
defaultDirection?: string,
): { paragraphLevel: number; levels: Uint8Array }
function getReorderSegments(
text: string,
embeddingLevels: { paragraphLevel: number; levels: Uint8Array },
start?: number,
end?: number,
): [number, number][]
function getEmbeddingLevels(text: string, defaultDirection?: string): { paragraphLevel: number; levels: Uint8Array }
function getReorderSegments(text: string, embeddingLevels: { paragraphLevel: number; levels: Uint8Array }, start?: number, end?: number): [number, number][]
function getVisualOrder(reorderSegments: [number, number][]): number[]
export { getEmbeddingLevels, getReorderSegments, getVisualOrder }
export default { getEmbeddingLevels, getReorderSegments, getVisualOrder }
}
declare module 'asciichart' {
function plot(
series: number[] | number[][],
config?: Record<string, unknown>,
): string
function plot(series: number[] | number[][], config?: Record<string, unknown>): string
export { plot }
export default { plot }
}
declare module '@napi-rs/keyring' {
export class Entry {
constructor(service: string, account: string)
getPassword(): string | null
setPassword(password: string): void
deletePassword(): boolean
}
}

View File

@ -9,7 +9,7 @@
// ============================================================================
// coreTypes.generated.js — Generated from coreSchemas.ts Zod schemas
// ============================================================================
declare module '*/sdk/coreTypes.generated.js' {
declare module "*/sdk/coreTypes.generated.js" {
// Usage & Model
export type ModelUsage = {
inputTokens: number
@ -32,20 +32,20 @@ declare module '*/sdk/coreTypes.generated.js' {
export type McpServerConfigForProcessTransport = {
command: string
args: string[]
type?: 'stdio'
type?: "stdio"
env?: Record<string, string>
} & { scope: string; pluginSource?: string }
export type McpServerStatus = {
name: string
status: 'connected' | 'disconnected' | 'error'
status: "connected" | "disconnected" | "error"
[key: string]: unknown
}
// Permissions
export type PermissionMode = string
export type PermissionResult =
| { behavior: 'allow' }
| { behavior: 'deny'; message?: string }
| { behavior: "allow" }
| { behavior: "deny"; message?: string }
export type PermissionUpdate = {
path: string
permission: string
@ -91,56 +91,21 @@ declare module '*/sdk/coreTypes.generated.js' {
// SDK Message types
export type SDKMessage = { type: string; [key: string]: unknown }
export type SDKUserMessage = {
type: 'user'
content: unknown
uuid: string
[key: string]: unknown
}
export type SDKUserMessage = { type: "user"; content: unknown; uuid: string; [key: string]: unknown }
export type SDKUserMessageReplay = SDKUserMessage
export type SDKAssistantMessage = {
type: 'assistant'
content: unknown
[key: string]: unknown
}
export type SDKAssistantErrorMessage = {
type: 'assistant_error'
error: unknown
[key: string]: unknown
}
export type SDKAssistantMessageError =
| 'authentication_failed'
| 'billing_error'
| 'rate_limit'
| 'invalid_request'
| 'server_error'
| 'unknown'
| 'max_output_tokens'
export type SDKPartialAssistantMessage = {
type: 'partial_assistant'
[key: string]: unknown
}
export type SDKResultMessage = { type: 'result'; [key: string]: unknown }
export type SDKResultSuccess = {
type: 'result_success'
[key: string]: unknown
}
export type SDKSystemMessage = { type: 'system'; [key: string]: unknown }
export type SDKStatusMessage = { type: 'status'; [key: string]: unknown }
export type SDKToolProgressMessage = {
type: 'tool_progress'
[key: string]: unknown
}
export type SDKCompactBoundaryMessage = {
type: 'compact_boundary'
[key: string]: unknown
}
export type SDKPermissionDenial = {
type: 'permission_denial'
[key: string]: unknown
}
export type SDKRateLimitInfo = { type: 'rate_limit'; [key: string]: unknown }
export type SDKStatus = 'active' | 'idle' | 'error' | string
export type SDKAssistantMessage = { type: "assistant"; content: unknown; [key: string]: unknown }
export type SDKAssistantErrorMessage = { type: "assistant_error"; error: unknown; [key: string]: unknown }
export type SDKAssistantMessageError = 'authentication_failed' | 'billing_error' | 'rate_limit' | 'invalid_request' | 'server_error' | 'unknown' | 'max_output_tokens'
export type SDKPartialAssistantMessage = { type: "partial_assistant"; [key: string]: unknown }
export type SDKResultMessage = { type: "result"; [key: string]: unknown }
export type SDKResultSuccess = { type: "result_success"; [key: string]: unknown }
export type SDKSystemMessage = { type: "system"; [key: string]: unknown }
export type SDKStatusMessage = { type: "status"; [key: string]: unknown }
export type SDKToolProgressMessage = { type: "tool_progress"; [key: string]: unknown }
export type SDKCompactBoundaryMessage = { type: "compact_boundary"; [key: string]: unknown }
export type SDKPermissionDenial = { type: "permission_denial"; [key: string]: unknown }
export type SDKRateLimitInfo = { type: "rate_limit"; [key: string]: unknown }
export type SDKStatus = "active" | "idle" | "error" | string
export type SDKSessionInfo = {
sessionId: string
summary?: string