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

Class Spec

ms_agent/skill/spec.py:9–60  ·  view source on GitHub ↗

Specification for an AI agent's task planning and execution.

Source from the content-addressed store, hash-verified

7
8@dataclass
9class Spec:
10 """
11 Specification for an AI agent's task planning and execution.
12 """
13
14 plan: str
15
16 tasks: str
17
18 implementation: str = ''
19
20 def __post_init__(self):
21
22 if not self.plan:
23 self.plan = DEFAULT_PLAN
24
25 if not self.tasks:
26 self.tasks = DEFAULT_TASKS
27
28 if not self.implementation:
29 self.implementation = DEFAULT_IMPLEMENTATION
30
31 def dump(self, output_dir: str) -> str:
32 """
33 Dump the spec to the specified output directory.
34
35 Args:
36 output_dir (str): The directory to dump the spec files.
37
38 Returns:
39 str: The path to the dumped spec directory.
40 """
41 output_path: str = os.path.join(output_dir, '.spec')
42 os.makedirs(output_path, exist_ok=True)
43
44 with open(
45 os.path.join(output_path, 'plan.md'), 'w',
46 encoding='utf-8') as f:
47 f.write(self.plan)
48
49 with open(
50 os.path.join(output_path, 'tasks.md'), 'w',
51 encoding='utf-8') as f:
52 f.write(self.tasks)
53
54 with open(
55 os.path.join(output_path, 'implementation.md'),
56 'w',
57 encoding='utf-8') as f:
58 f.write(self.implementation)
59
60 return output_path
61
62
63if __name__ == '__main__':

Callers 2

__post_init__Method · 0.85
spec.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected