MCPcopy Create free account
hub / github.com/modelscope/ms-agent / write_code

Method write_code

projects/code_genesis/workflow/coding.py:612–643  ·  view source on GitHub ↗
(self, topic, user_story, framework, protocol,
                         file_order, name, description, index, last_batch,
                         siblings, next_batch)

Source from the content-addressed store, hash-verified

610 pass
611
612 async def write_code(self, topic, user_story, framework, protocol,
613 file_order, name, description, index, last_batch,
614 siblings, next_batch):
615 logger.info(f'Writing {name}')
616 _config = deepcopy(self.config)
617 messages = [
618 Message(role='system', content=self.config.prompt.system),
619 Message(
620 role='user',
621 content=f'Original requirements (topic.txt): {topic}\n'
622 f'User story planned by LLM (user_story.txt): {user_story}\n'
623 f'Tech stack (framework.txt): {framework}\n'
624 f'Communication protocol (protocol.txt): {protocol}\n'
625 f'File Order: {file_order}\n'
626 f'File to implement: {name}\n'
627 f'Batch index: {index}\n'
628 f'File description: {description}\n'
629 f'Previous batch output:\n{last_batch}\n'
630 f'Other workers writing in parallel:\n{siblings}\n'
631 f'Next batch planned:\n{next_batch}\n'),
632 ]
633
634 _config = deepcopy(self.config)
635 _config.save_history = True
636 _config.load_cache = False
637 programmer = Programmer(
638 _config,
639 tag=f'programmer-{name.replace(os.sep, "-")}',
640 trust_remote_code=True,
641 code_file=name,
642 shared_lsp_context=self.shared_lsp_context) # Pass shared context
643 await programmer.run(messages)
644
645 async def execute_code(self, inputs, **kwargs):
646 await self._init_lsp_servers()

Callers 1

execute_codeMethod · 0.95

Calls 3

MessageClass · 0.90
ProgrammerClass · 0.85
runMethod · 0.45

Tested by

no test coverage detected