style: 完成所有文件的lint

This commit is contained in:
claude-code-best
2026-05-01 21:39:30 +08:00
parent d136872cc9
commit 6182015005
1333 changed files with 68255 additions and 77882 deletions

View File

@@ -5,7 +5,9 @@ import plan from './index.js'
describe('plan bridge invocation safety', () => {
test('allows headless plan mode operations over Remote Control', () => {
expect(plan.getBridgeInvocationError?.('')).toBeUndefined()
expect(plan.getBridgeInvocationError?.('write a migration plan')).toBeUndefined()
expect(
plan.getBridgeInvocationError?.('write a migration plan'),
).toBeUndefined()
})
test('blocks /plan open over Remote Control', () => {

View File

@@ -1,24 +1,24 @@
import * as React from 'react'
import { handlePlanModeTransition } from '../../bootstrap/state.js'
import type { LocalJSXCommandContext } from '../../commands.js'
import { Box, Text } from '@anthropic/ink'
import type { LocalJSXCommandOnDone } from '../../types/command.js'
import { getExternalEditor } from '../../utils/editor.js'
import { toIDEDisplayName } from '../../utils/ide.js'
import { applyPermissionUpdate } from '../../utils/permissions/PermissionUpdate.js'
import { prepareContextForPlanMode } from '../../utils/permissions/permissionSetup.js'
import { getPlan, getPlanFilePath } from '../../utils/plans.js'
import { editFileInEditor } from '../../utils/promptEditor.js'
import { renderToString } from '../../utils/staticRender.js'
import * as React from 'react';
import { handlePlanModeTransition } from '../../bootstrap/state.js';
import type { LocalJSXCommandContext } from '../../commands.js';
import { Box, Text } from '@anthropic/ink';
import type { LocalJSXCommandOnDone } from '../../types/command.js';
import { getExternalEditor } from '../../utils/editor.js';
import { toIDEDisplayName } from '../../utils/ide.js';
import { applyPermissionUpdate } from '../../utils/permissions/PermissionUpdate.js';
import { prepareContextForPlanMode } from '../../utils/permissions/permissionSetup.js';
import { getPlan, getPlanFilePath } from '../../utils/plans.js';
import { editFileInEditor } from '../../utils/promptEditor.js';
import { renderToString } from '../../utils/staticRender.js';
function PlanDisplay({
planContent,
planPath,
editorName,
}: {
planContent: string
planPath: string
editorName: string | undefined
planContent: string;
planPath: string;
editorName: string | undefined;
}): React.ReactNode {
return (
<Box flexDirection="column">
@@ -37,7 +37,7 @@ function PlanDisplay({
</Box>
)}
</Box>
)
);
}
export async function call(
@@ -45,63 +45,58 @@ export async function call(
context: LocalJSXCommandContext,
args: string,
): Promise<React.ReactNode> {
const { getAppState, setAppState } = context
const appState = getAppState()
const currentMode = appState.toolPermissionContext.mode
const { getAppState, setAppState } = context;
const appState = getAppState();
const currentMode = appState.toolPermissionContext.mode;
// If not in plan mode, enable it
if (currentMode !== 'plan') {
handlePlanModeTransition(currentMode, 'plan')
handlePlanModeTransition(currentMode, 'plan');
setAppState(prev => ({
...prev,
toolPermissionContext: applyPermissionUpdate(
prepareContextForPlanMode(prev.toolPermissionContext),
{ type: 'setMode', mode: 'plan', destination: 'session' },
),
}))
const description = args.trim()
toolPermissionContext: applyPermissionUpdate(prepareContextForPlanMode(prev.toolPermissionContext), {
type: 'setMode',
mode: 'plan',
destination: 'session',
}),
}));
const description = args.trim();
if (description && description !== 'open') {
onDone('Enabled plan mode', { shouldQuery: true })
onDone('Enabled plan mode', { shouldQuery: true });
} else {
onDone('Enabled plan mode')
onDone('Enabled plan mode');
}
return null
return null;
}
// Already in plan mode - show the current plan
const planContent = getPlan()
const planPath = getPlanFilePath()
const planContent = getPlan();
const planPath = getPlanFilePath();
if (!planContent) {
onDone('Already in plan mode. No plan written yet.')
return null
onDone('Already in plan mode. No plan written yet.');
return null;
}
// If user typed "/plan open", open in editor
const argList = args.trim().split(/\s+/)
const argList = args.trim().split(/\s+/);
if (argList[0] === 'open') {
const result = await editFileInEditor(planPath)
const result = await editFileInEditor(planPath);
if (result.error) {
onDone(`Failed to open plan in editor: ${result.error}`)
onDone(`Failed to open plan in editor: ${result.error}`);
} else {
onDone(`Opened plan in editor: ${planPath}`)
onDone(`Opened plan in editor: ${planPath}`);
}
return null
return null;
}
const editor = getExternalEditor()
const editorName = editor ? toIDEDisplayName(editor) : undefined
const editor = getExternalEditor();
const editorName = editor ? toIDEDisplayName(editor) : undefined;
const display = (
<PlanDisplay
planContent={planContent}
planPath={planPath}
editorName={editorName}
/>
)
const display = <PlanDisplay planContent={planContent} planPath={planPath} editorName={editorName} />;
// Render to string and pass to onDone like local commands do
const output = await renderToString(display)
onDone(output)
return null
const output = await renderToString(display);
onDone(output);
return null;
}