Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 11 additions & 11 deletions src/cli/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ program
.description('在您的项目中初始化OpenSpec')
.option('--tools <tools>', toolsOptionDescription)
.option('--force', '自动清理旧文件而不提示')
.option('--profile <profile>', 'Override global config profile (core or custom)')
.option('--profile <profile>', '覆盖全局配置档案(core custom')
.action(async (targetPath = '.', options?: { tools?: string; force?: boolean; profile?: string }) => {
try {
// Validate that the path is a valid directory
Expand Down Expand Up @@ -137,8 +137,8 @@ program
program
.command('experimental', { hidden: true })
.description('init 的别名(已弃用)')
.option('--tool <tool-id>', 'Target AI tool (maps to --tools)')
.option('--no-interactive', 'Disable interactive prompts')
.option('--tool <tool-id>', '目标 AI 工具(映射到 --tools')
.option('--no-interactive', '禁用交互式提示')
.action(async (options?: { tool?: string; noInteractive?: boolean }) => {
try {
console.log('注意:"openspec-cn experimental" 已弃用。请使用 "openspec-cn init" 代替。');
Expand All @@ -150,7 +150,7 @@ program
await initCommand.execute('.');
} catch (error) {
console.log();
ora().fail(`Error: ${(error as Error).message}`);
ora().fail(`错误:${(error as Error).message}`);
process.exit(1);
}
});
Expand Down Expand Up @@ -433,7 +433,7 @@ program
await statusCommand(options);
} catch (error) {
console.log();
ora().fail(`Error: ${(error as Error).message}`);
ora().fail(`错误:${(error as Error).message}`);
process.exit(1);
}
});
Expand All @@ -455,7 +455,7 @@ program
}
} catch (error) {
console.log();
ora().fail(`Error: ${(error as Error).message}`);
ora().fail(`错误:${(error as Error).message}`);
process.exit(1);
}
});
Expand All @@ -464,14 +464,14 @@ program
program
.command('templates')
.description('显示 Schema 中所有产出物的已解析模板路径')
.option('--schema <name>', `Schema to use (default: ${DEFAULT_SCHEMA})`)
.option('--schema <name>', `要使用的 Schema(默认:${DEFAULT_SCHEMA}`)
.option('--json', '以 JSON 格式输出产出物 ID 到模板路径的映射')
.action(async (options: TemplatesOptions) => {
try {
await templatesCommand(options);
} catch (error) {
console.log();
ora().fail(`Error: ${(error as Error).message}`);
ora().fail(`错误:${(error as Error).message}`);
process.exit(1);
}
});
Expand All @@ -486,7 +486,7 @@ program
await schemasCommand(options);
} catch (error) {
console.log();
ora().fail(`Error: ${(error as Error).message}`);
ora().fail(`错误:${(error as Error).message}`);
process.exit(1);
}
});
Expand All @@ -497,14 +497,14 @@ const newCmd = program.command('new').description('创建新项目');
newCmd
.command('change <name>')
.description('创建一个新的变更目录')
.option('--description <text>', 'Description to add to README.md')
.option('--description <text>', '添加到 README.md 的描述')
.option('--schema <name>', `要使用的工作流 Schema(默认:${DEFAULT_SCHEMA})`)
.action(async (name: string, options: NewChangeOptions) => {
try {
await newChangeCommand(name, options);
} catch (error) {
console.log();
ora().fail(`Error: ${(error as Error).message}`);
ora().fail(`错误:${(error as Error).message}`);
process.exit(1);
}
});
Expand Down
4 changes: 2 additions & 2 deletions src/commands/change.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ export class ChangeCommand {
} catch (error) {
// Tasks file may not exist, which is okay
if (process.env.DEBUG) {
console.error(`Failed to read tasks file at ${tasksPath}:`, error);
console.error(`\u8bfb\u53d6 ${tasksPath} \u4efb\u52a1\u6587\u4ef6\u5931\u8d25:`, error);
}
}

Expand Down Expand Up @@ -167,7 +167,7 @@ export class ChangeCommand {
taskStatusText = ` [任务 ${completed}/${total}]`;
} catch (error) {
if (process.env.DEBUG) {
console.error(`Failed to read tasks file at ${tasksPath}:`, error);
console.error(`\u8bfb\u53d6 ${tasksPath} \u4efb\u52a1\u6587\u4ef6\u5931\u8d25:`, error);
}
}
const changeDir = path.join(changesPath, changeName);
Expand Down
26 changes: 13 additions & 13 deletions src/commands/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ export function deriveProfileFromWorkflowSelection(selectedWorkflows: string[]):
* Format a compact workflow summary for the profile header.
*/
export function formatWorkflowSummary(workflows: readonly string[], profile: Profile): string {
return `${workflows.length} selected (${profile})`;
return `${workflows.length} 个已选择(${profile}`;
}

function stableWorkflowOrder(workflows: readonly string[]): string[] {
Expand Down Expand Up @@ -154,11 +154,11 @@ export function diffProfileState(before: ProfileState, after: ProfileState): Pro
const lines: string[] = [];

if (before.delivery !== after.delivery) {
lines.push(`delivery: ${before.delivery} -> ${after.delivery}`);
lines.push(`交付方式:${before.delivery} -> ${after.delivery}`);
}

if (before.profile !== after.profile) {
lines.push(`profile: ${before.profile} -> ${after.profile}`);
lines.push(`档案:${before.profile} -> ${after.profile}`);
}

const beforeOrdered = stableWorkflowOrder(before.workflows);
Expand All @@ -172,12 +172,12 @@ export function diffProfileState(before: ProfileState, after: ProfileState): Pro
if (added.length > 0 || removed.length > 0) {
const tokens: string[] = [];
if (added.length > 0) {
tokens.push(`added ${added.join(', ')}`);
tokens.push(`已添加 ${added.join(', ')}`);
}
if (removed.length > 0) {
tokens.push(`removed ${removed.join(', ')}`);
tokens.push(`已移除 ${removed.join(', ')}`);
}
lines.push(`workflows: ${tokens.join('; ')}`);
lines.push(`工作流:${tokens.join('')}`);
}

return {
Expand Down Expand Up @@ -252,17 +252,17 @@ export function registerConfigCommand(program: Command): void {
console.log(formatValueYaml(config));

// Annotate profile settings
const profileSource = rawConfig.profile !== undefined ? '(explicit)' : '(default)';
const deliverySource = rawConfig.delivery !== undefined ? '(explicit)' : '(default)';
console.log(`\nProfile settings:`);
const profileSource = rawConfig.profile !== undefined ? '(显式设置)' : '(默认倦)';
const deliverySource = rawConfig.delivery !== undefined ? '(显式设置)' : '(默认倦)';
console.log(`\n档案设置:`);
console.log(` profile: ${config.profile} ${profileSource}`);
console.log(` delivery: ${config.delivery} ${deliverySource}`);
if (config.profile === 'core') {
console.log(` workflows: ${CORE_WORKFLOWS.join(', ')} (from core profile)`);
console.log(` workflows: ${CORE_WORKFLOWS.join(', ')} (来自 core 档案)`);
} else if (config.workflows && config.workflows.length > 0) {
console.log(` workflows: ${config.workflows.join(', ')} (explicit)`);
console.log(` workflows: ${config.workflows.join(', ')} (显式设置)`);
} else {
console.log(` workflows: (none)`);
console.log(` workflows: ()`);
}
}
});
Expand Down Expand Up @@ -566,7 +566,7 @@ export function registerConfigCommand(program: Command): void {
const formatWorkflowChoice = (workflow: string) => {
const metadata = WORKFLOW_PROMPT_META[workflow] ?? {
name: workflow,
description: `Workflow: ${workflow}`,
description: `工作流: ${workflow}`,
};
return {
value: workflow,
Expand Down
30 changes: 15 additions & 15 deletions src/commands/workflow/instructions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export async function instructionsCommand(
artifactId: string | undefined,
options: InstructionsOptions
): Promise<void> {
const spinner = ora('Generating instructions...').start();
const spinner = ora('正在生成指令...').start();

try {
const projectRoot = process.cwd();
Expand All @@ -63,7 +63,7 @@ export async function instructionsCommand(
spinner.stop();
const validIds = context.graph.getAllArtifacts().map((a) => a.id);
throw new Error(
`Missing required argument <artifact>. Valid artifacts:\n ${validIds.join('\n ')}`
`缺少必需参数 <artifact>。有效的产出物:\n ${validIds.join('\n ')}`
);
}

Expand Down Expand Up @@ -170,7 +170,7 @@ export function printInstructionsText(instructions: ArtifactInstructions, isBloc

// Output location
console.log('<output>');
console.log(`Write to: ${path.join(changeDir, outputPath)}`);
console.log(`\u5199\u5165\u5230: ${path.join(changeDir, outputPath)}`);
console.log('</output>');
console.log();

Expand Down Expand Up @@ -380,7 +380,7 @@ export async function generateApplyInstructions(
} else if (!tracksFile) {
// No tracking file configured in schema - ready to apply
state = 'ready';
instruction = schemaInstruction?.trim() ?? 'All required artifacts complete. Proceed with implementation.';
instruction = schemaInstruction?.trim() ?? '所有必需的产出物已完成。继续实现。';
} else {
state = 'ready';
instruction = schemaInstruction?.trim() ?? '所有必需的产出物已完成。继续实现。';
Expand Down Expand Up @@ -431,23 +431,23 @@ export async function applyInstructionsCommand(options: ApplyInstructionsOptions
export function printApplyInstructionsText(instructions: ApplyInstructions): void {
const { changeName, schemaName, contextFiles, progress, tasks, state, missingArtifacts, instruction } = instructions;

console.log(`## Apply: ${changeName}`);
console.log(`Schema: ${schemaName}`);
console.log(`## 应用: ${changeName}`);
console.log(`架构: ${schemaName}`);
console.log();

// Warning for blocked state
if (state === 'blocked' && missingArtifacts) {
console.log('### ⚠️ Blocked');
console.log('⚠️ 被阻塞');
console.log();
console.log(`Missing artifacts: ${missingArtifacts.join(', ')}`);
console.log('Use the openspec-continue-change skill to create these first.');
console.log(`缺失的产出物: ${missingArtifacts.join(', ')}`);
console.log('请使用 openspec-continue-change 技能首先创建这些产出物。');
console.log();
}

// Context files (dynamically from schema)
const contextFileEntries = Object.entries(contextFiles);
if (contextFileEntries.length > 0) {
console.log('### Context Files');
console.log('上下文文件:');
for (const [artifactId, filePath] of contextFileEntries) {
console.log(`- ${artifactId}: ${filePath}`);
}
Expand All @@ -456,18 +456,18 @@ export function printApplyInstructionsText(instructions: ApplyInstructions): voi

// Progress (only show if we have tracking)
if (progress.total > 0 || tasks.length > 0) {
console.log('### Progress');
console.log('进度:');
if (state === 'all_done') {
console.log(`${progress.complete}/${progress.total} complete ✓`);
console.log(`${progress.complete}/${progress.total} 已完成 ✓`);
} else {
console.log(`${progress.complete}/${progress.total} complete`);
console.log(`${progress.complete}/${progress.total} 已完成`);
}
console.log();
}

// Tasks
if (tasks.length > 0) {
console.log('### Tasks');
console.log('任务:');
for (const task of tasks) {
const checkbox = task.done ? '[x]' : '[ ]';
console.log(`- ${checkbox} ${task.description}`);
Expand All @@ -476,6 +476,6 @@ export function printApplyInstructionsText(instructions: ApplyInstructions): voi
}

// Instruction
console.log('### Instruction');
console.log('指令:');
console.log(instruction);
}
4 changes: 2 additions & 2 deletions src/commands/workflow/new-change.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ export async function newChangeCommand(name: string | undefined, options: NewCha
validateSchemaExists(options.schema, projectRoot);
}

const schemaDisplay = options.schema ? ` with schema '${options.schema}'` : '';
const spinner = ora(`Creating change '${name}'${schemaDisplay}...`).start();
const schemaDisplay = options.schema ? `,使用架构 '${options.schema}'` : '';
const spinner = ora(`正在创建变更 '${name}'${schemaDisplay}...`).start();

try {
const result = await createChange(projectRoot, name, { schema: options.schema });
Expand Down
4 changes: 2 additions & 2 deletions src/commands/workflow/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ export async function validateChangeExists(
// Validate change name format to prevent path traversal
const nameValidation = validateChangeName(changeName);
if (!nameValidation.valid) {
throw new Error(`Invalid change name '${changeName}': ${nameValidation.error}`);
throw new Error(`\u53d8\u66f4\u540d\u79f0\u65e0\u6548 '${changeName}': ${nameValidation.error}`);
}

// Check directory existence directly
Expand Down Expand Up @@ -154,7 +154,7 @@ export function validateSchemaExists(schemaName: string, projectRoot?: string):
if (!schemaDir) {
const availableSchemas = listSchemas(projectRoot);
throw new Error(
`Schema '${schemaName}' not found. Available schemas:\n ${availableSchemas.join('\n ')}`
`未找到架构 '${schemaName}'。可用的架构:\n ${availableSchemas.join('\n ')}`
);
}
return schemaName;
Expand Down
2 changes: 1 addition & 1 deletion src/core/artifact-graph/instruction-loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ export function generateInstructions(
): ArtifactInstructions {
const artifact = context.graph.getArtifact(artifactId);
if (!artifact) {
throw new Error(`Artifact '${artifactId}' not found in schema '${context.schemaName}'`);
throw new Error(`架构 '${context.schemaName}' 中未找到产出物 '${artifactId}'`);
}

const templateContent = loadTemplate(context.schemaName, artifact.template, context.projectRoot);
Expand Down
4 changes: 2 additions & 2 deletions src/core/completions/factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export class CompletionFactory {
case 'powershell':
return new PowerShellGenerator();
default:
throw new Error(`Unsupported shell: ${shell}`);
throw new Error(`不支持的 Shell: ${shell}`);
}
}

Expand All @@ -81,7 +81,7 @@ export class CompletionFactory {
case 'powershell':
return new PowerShellInstaller();
default:
throw new Error(`Unsupported shell: ${shell}`);
throw new Error(`不支持的 Shell: ${shell}`);
}
}

Expand Down
Loading
Loading