MCPcopy
hub / github.com/Fission-AI/OpenSpec / applyInstructionsCommand

Function applyInstructionsCommand

src/commands/workflow/instructions.ts:435–478  ·  view source on GitHub ↗
(options: ApplyInstructionsOptions)

Source from the content-addressed store, hash-verified

433}
434
435export async function applyInstructionsCommand(options: ApplyInstructionsOptions): Promise<void> {
436 // Resolve (and banner) before the spinner starts so stderr stays readable.
437 const root = await resolveRootForCommand(options, { json: options.json });
438 if (!root) {
439 return;
440 }
441
442 const spinner = options.json ? undefined : ora('Generating apply instructions...').start();
443
444 try {
445 const planningHome = toPlanningHome(root);
446 const projectRoot = root.path;
447 const changeName = await validateChangeExists(
448 options.change,
449 projectRoot,
450 root.changesDir,
451 { newChangeHint: withStoreFlag(root, 'openspec new change <name>') }
452 );
453
454 // Validate schema if explicitly provided
455 if (options.schema) {
456 validateSchemaExists(options.schema, projectRoot);
457 }
458
459 // generateApplyInstructions uses loadChangeContext which auto-detects schema
460 const { references } = await loadRootConfigContext(root);
461 const instructions = await generateApplyInstructions(projectRoot, changeName, options.schema, {
462 planningHome,
463 references,
464 });
465
466 spinner?.stop();
467
468 if (options.json) {
469 console.log(JSON.stringify({ ...instructions, root: toRootOutput(root) }, null, 2));
470 return;
471 }
472
473 printApplyInstructionsText(instructions);
474 } catch (error) {
475 spinner?.stop();
476 throw error;
477 }
478}
479
480export function printApplyInstructionsText(instructions: ApplyInstructions): void {
481 const { changeName, schemaName, contextFiles, progress, tasks, state, missingArtifacts, instruction } = instructions;

Callers 1

index.tsFile · 0.85

Calls 9

resolveRootForCommandFunction · 0.85
toPlanningHomeFunction · 0.85
validateChangeExistsFunction · 0.85
withStoreFlagFunction · 0.85
validateSchemaExistsFunction · 0.85
loadRootConfigContextFunction · 0.85
toRootOutputFunction · 0.85

Tested by

no test coverage detected