Skip to content

Commit b3c25b7

Browse files
authored
Merge pull request #1585 from endolith/skills_messages
Improve internal documentation of skills system
2 parents c287953 + a33d123 commit b3c25b7

File tree

1 file changed

+60
-1
lines changed

1 file changed

+60
-1
lines changed

interpreter/core/computer/skills/skills.py

Lines changed: 60 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,34 +21,93 @@
2121

2222

2323
class Skills:
24+
"""
25+
Manages access to pre-imported automation skills.
26+
27+
Note: Skills system must be enabled via profile (like 'the01') or by creating
28+
OpenInterpreter with import_skills=True.
29+
30+
Available methods:
31+
- list(): Returns names of available skills
32+
- search(query): Lists available skills (currently same as list())
33+
34+
Usage:
35+
To use a skill, call it directly as a function:
36+
example_skill()
37+
38+
To create a new skill:
39+
computer.skills.new_skill.create()
40+
"""
2441
def __init__(self, computer):
2542
self.computer = computer
2643
self.path = str(Path(oi_dir) / "skills")
2744
self.new_skill = NewSkill(self)
2845

2946
def list(self):
47+
"""
48+
Lists all available skills. Skills are already imported and can be called directly.
49+
50+
Returns:
51+
list[str]: Names of available skills with () to indicate they're callable
52+
"""
53+
if not self.computer.import_skills:
54+
print("Skills are disabled. To enable skills, either use a profile like 'the01' that supports skills, "
55+
"or create an instance of OpenInterpreter with import_skills=True")
56+
return []
57+
58+
if not self.computer._has_imported_skills:
59+
print("Skills have not been imported yet.")
60+
return []
61+
3062
return [
3163
file.replace(".py", "()")
3264
for file in os.listdir(self.path)
3365
if file.endswith(".py")
3466
]
3567

3668
def run(self, skill):
69+
"""
70+
DEPRECATED: Do not use this method.
71+
Skills are already imported - call them directly as functions instead.
72+
"""
3773
print(
3874
"To run a skill, run its name as a function name (it is already imported)."
3975
)
4076

4177
def search(self, query):
4278
"""
43-
This just lists all for now.
79+
Lists available skills (currently same as list()).
80+
Skills are already imported and can be called directly.
81+
82+
Returns:
83+
list[str]: Names of available skills with () to indicate they're callable
4484
"""
85+
if not self.computer.import_skills:
86+
print("Skills are disabled. To enable skills, either use a profile like 'the01' that supports skills, "
87+
"or create an instance of OpenInterpreter with import_skills=True")
88+
return []
89+
90+
if not self.computer._has_imported_skills:
91+
print("Skills have not been imported yet.")
92+
return []
93+
4594
return [
4695
file.replace(".py", "()")
4796
for file in os.listdir(self.path)
4897
if file.endswith(".py")
4998
]
5099

51100
def import_skills(self):
101+
"""
102+
[INTERNAL METHOD - NOT FOR Assistant USE]
103+
System initialization method that imports all Python files from the skills directory.
104+
105+
This method is called automatically during system setup to load available skills.
106+
Assistant should use list(), search(), or call skills directly instead of this method.
107+
"""
108+
if not self.computer.import_skills:
109+
return
110+
52111
previous_save_skills_setting = self.computer.save_skills
53112

54113
self.computer.save_skills = False

0 commit comments

Comments
 (0)