-
Notifications
You must be signed in to change notification settings - Fork 1
Skill Crafting
A skill is a self-contained unit of AI behavior. It listens to input, decides if it should act, and outputs an algorithm if triggered. This wiki walks you through building one from scratch.
Every skill extends the Skill class and overrides input().
class DiMySkill(Skill):
def input(self, ear: str, skin: str, eye: str):
# your trigger logic here
pass
def skillNotes(self, param: str) -> str:
if param == "notes":
return "describe what this skill does"
elif param == "triggers":
return "describe what triggers it"
return "note unavailable"-
ear— typed or speech input -
skin— sensor input -
eye— visual input
Follow the naming convention:
-
Di — standard skills. Example:
DiTellTime,DiGreeting,DiWeatherReport. -
AH — skills that have a Brain object attribute, giving them the ability to add/remove other skills at runtime. Example:
AHMoodRegulator,AHPassword. -
AX — Auxiliary/helper classes used inside skills. Example:
AXLearnability. -
AP — AlgPart classes. Example:
APSayHello. - Da — Asynchronous skills.
Inside input(), check the incoming data and decide whether to act.
def input(self, ear: str, skin: str, eye: str):
if ear == "what time is it":
self.setSimpleAlg("it is 3pm")You can use any Python logic here — string matching, conditionals, regex, match statements, auxiliary trigger classes (AX), etc.
Three built-in shortcut methods for generating output algorithms:
# outputs at default priority 4
self.setSimpleAlg("hello", "how are you")
# outputs at a specific priority (1 is highest, 5 is lowest)
self.setVerbatimAlg(2, "alert!", "pay attention")
# same as setVerbatimAlg but accepts a list
self.setVebatimAlgFromList(3, ["line one", "line two"])Each string is passed to the hardware lobe skills one per think cycle — what happens to it depends on which lobe 2 skill is equipped (console print, TTS, robot command, etc).
The default skill type is 1 (regular). Change it in __init__ if needed.
def __init__(self):
super().__init__()
self.set_skill_type(3)| Type | Value | Description |
|---|---|---|
| Regular | 1 | Triggered by input, runs once |
| Aware | 2 | Has a Brain object attribute — can add/remove other skills at runtime |
| Continuous | 3 | Suited for skills that should always respond (e.g. an LLM fallback), but goes dormant when a type 1 or type 2 skill fires first |
The default lobe is 1 (logical). Change it if the skill belongs elsewhere.
def __init__(self):
super().__init__()
self.set_skill_lobe(2) # hardware output| Lobe | Value | Description |
|---|---|---|
| Logical | 1 | Thinking / reasoning skills |
| Hardware | 2 | Output skills (e.g. console, TTS, motors) |
| Ear | 3 | Audio / speech-to-text input |
| Skin | 4 | Sensor input |
| Eye | 5 | Visual input |
The lobes form a pipeline. Lobe 1 (logical) skills do the thinking and produce a string output. That output becomes the ear input of lobe 2 (hardware) skills, which act on it — printing to the terminal, speaking it aloud via TTS, sending it to a robot motor controller, etc.
DiSysOut is the simplest hardware skill — it just prints whatever it receives to the console:
class DiSysOut(Skill):
def __init__(self):
super().__init__()
self.set_skill_type(3) # continuous
self.set_skill_lobe(2) # hardware
def input(self, ear: str, skin: str, eye: str):
if ear and "#" not in ear:
print(ear)A TTS skill works the same way — lobe 2, receives the logical output as ear, and speaks it instead of printing it. This separation means you can swap DiSysOut for a TTS skill without touching any of your logical skills.
Lobes 3 (ear), 4 (skin), and 5 (eye) are for input processing — speech-to-text, sensors, cameras. Their output feeds into the logical lobe's ear, skin, and eye parameters on the next think cycle.
manifest() runs once when the skill is added to the Brain. Use it for anything that needs to happen before the skill starts receiving input — loading saved state from the database, opening a connection, initializing hardware, or adding child skills.
ghost() runs once when the skill is removed. Use it for atexit-style cleanup — closing file handles, disconnecting from services, saving final state, or stopping background threads.
def manifest(self):
# load persisted data from the database on startup
saved = self._kokoro.grimoireMemento.load(self.skill_name)
if saved and saved != "null":
self.data = saved
def ghost(self):
# save state and clean up when the skill is removed
self._kokoro.grimoireMemento.save(self.skill_name, self.data)
self.connection.close()Use self._kokoro.toHeart to pass data between skills. The "cmd" key is a common convention for sending commands across skills.
# send a command
self._kokoro.toHeart["cmd"] = "change voice"
# read it in another skill
if self._kokoro.toHeart.get("cmd") == "change voice":
self.speech.setVoice(self.voices.renewableDraw())Use self._kokoro.grimoireMemento to save and load persistent data.
self._kokoro.grimoireMemento.save("key", "value")
value = self._kokoro.grimoireMemento.load("key")class DiGreet(Skill):
def __init__(self):
super().__init__()
def manifest(self):
print("DiGreet skill online")
def ghost(self):
print("DiGreet skill offline")
def input(self, ear: str, skin: str, eye: str):
if ear == "hi":
self.setSimpleAlg("hey there!", "how can I help?")
def skillNotes(self, param: str) -> str:
if param == "notes":
return "greets the user"
elif param == "triggers":
return "say hi"
return "note unavailable"Add it to the Brain:
brain = Brain()
brain.add_skill(DiGreet())
brain.add_skill(DiSysOut())
brain.think_default("hi")Output:
hey there!
# next think cycle:
how can I help?
For more advanced skill patterns — installers, AH hormone skills, multi-step algorithms, hardware lobes — browse the skills in the DLC directory of any LivinGrimoire language repo. The existing skills are the best reference for what's possible.
| What you want | How to do it |
|---|---|
| Simple output | setSimpleAlg("text") |
| Priority output | setVerbatimAlg(priority, "text") |
| List output | setVebatimAlgFromList(priority, list) |
| Multi-step behavior | algPartsFusion(priority, *algParts) |
| Send a command to another skill | self._kokoro.toHeart["cmd"] = "command" |
| Read a command from another skill | self._kokoro.toHeart.get("cmd") |
| Persistent storage | self._kokoro.grimoireMemento.save/load |
| Setup on add | manifest() |
| Cleanup on remove | ghost() |