Dodaios is an open-source agent OS for your desktop: it runs your coding agents, browser and apps by voice or chat, on your own machine. Formerly Personal Jarvis.
Python agent-orchestrationai-agentai-coding-assistantclaude-codecoding-agentcomputer-usedesktop-applocal-firstmcppersonal-jarvisvoice-assistantvoice-coding
feat(skills): list every active skill to the model, user skills first
rubenluetke10-beep51613f111c7a
diff --git a/jarvis/skills/prompt_injection.py b/jarvis/skills/prompt_injection.pyindex b3d84c415e..9310ade067 100644--- a/jarvis/skills/prompt_injection.py+++ b/jarvis/skills/prompt_injection.py@@ -25,6 +25,14 @@ from jarvis.skills.registry import SkillRegistry# 1536-char listing cap in Claude Code's skill listing, AD-S2)._PER_ENTRY_CHAR_CAP = 1536+# How many folded skill NAMES the overflow tail enumerates. The tail exists so+# a folded skill stays *callable* — run-skill resolves by exact name, and a+# bare "… and 5 more" hides exactly the name the model would need. Live+# forensic 2026-08-12: with 25 active skills and the old cap of 20, the five+# alphabetically-last skills (including `skill-creator`) were invisible to the+# model, and model-initiated run-skill calls measured ZERO over 14 days.+_OVERFLOW_TAIL_NAME_CAP = 15+def _skill_mtime(skill: object) -> float:"""Last-modified time used for budget eviction; 0.0 when unknown."""@@ -37,10 +45,26 @@ def _skill_mtime(skill: object) -> float:return 0.0+def _is_builtin(skill: object) -> bool:+ """True when this skill ships with Jarvis (a bootstrap copy of a builtin).++ User-authored skills are the ones the user deliberately added, so when the+ listing must shrink, shipped defaults fold before the user's own work.+ Fails toward "user" on purpose: an import fault must never demote a user+ skill to fold-first status.+ """+ try:+ from jarvis.skills.builtin import BUILTIN_SKILL_NAMES++ return str(getattr(skill, "name", "")) in BUILTIN_SKILL_NAMES+ except Exception: # noqa: BLE001+ return False++def render_available_skills_section(registry: SkillRegistry,*,- max_skills: int = 20,+ max_skills: int = 48,total_char_budget: int = 8000,) -> str | None:"""Render the AVAILABLE SKILLS markdown section for the system prompt.@@ -48,22 +72,31 @@ def render_available_skills_section(Returns ``None`` when no active skills exist (callers should skipappending an empty section).+ Ordering and folding policy (2026-08-12, "skills never fire" rework):+ user-authored skills render BEFORE builtins, and when the listing must+ shrink (cap or char budget) builtins fold first. The default cap covers+ the full realistic install (25 builtins + user growth) because a skill+ missing from this list can effectively never be chosen by the model —+ the measured model-initiated run-skill rate with folded skills was zero.+Args:registry: The live ``SkillRegistry``. Only ACTIVE/VALIDATED skillsare considered (``registry.list_active()``).max_skills: Hard cap on the number of bullets rendered. Skills- beyond the cap are folded into a single ``… and N more``- tail bullet so the prompt does not grow unbounded.+ beyond the cap fold into a tail bullet that still NAMES them+ (run-skill resolves by exact name), so the prompt stays bounded+ without making any skill uncallable.total_char_budget: Overall character budget for the bullet block(AD-S2 L1, mirrors Claude Code's listing budget). When exceeded,- the least-recently-modified skills are evicted first — names of- fresh skills stay visible, stale ones fold into the tail bullet.+ builtins are evicted before user skills, least-recently-modified+ first within each group."""active = registry.list_active()if not active:return None- entries: list[tuple[str, float]] = []+ # (bullet, mtime, is_builtin, name) per renderable skill.+ entries: list[tuple[str, float, bool, str]] = []skipped_no_frontmatter = 0for skill in active:fm = skill.frontmatter@@ -82,28 +115,56 @@ def render_available_skills_section(description = f"{description} {when_to_use}"if len(description) > _PER_ENTRY_CHAR_CAP:description = description[: _PER_ENTRY_CHAR_CAP - 1] + "…"- entries.append((f"- `{skill.name}` — {description}", _skill_mtime(skill)))+ name = str(skill.name)+ entries.append(+ (+ f"- `{name}` — {description}",+ _skill_mtime(skill),+ _is_builtin(skill),+ name,+ )+ )if not entries:return None+ # User-authored skills first (stable within each group): the user added+ # them deliberately, and position in a long listing is attention.+ entries.sort(key=lambda e: e[2])++ folded_names: list[str] = []overflow = max(0, len(entries) - max_skills)if overflow:+ folded_names.extend(name for _, _, _, name in entries[max_skills:])entries = entries[:max_skills]- # Total budget eviction (AD-S2): drop least-recently-modified first- # while preserving the display order of the survivors.- def _block_len(items: list[tuple[str, float]]) -> int:- return sum(len(b) + 1 for b, _ in items)+ # Total budget eviction (AD-S2): builtins before user skills, oldest+ # first within each group, preserving display order of the survivors.+ def _block_len(items: list[tuple[str, float, bool, str]]) -> int:+ return sum(len(b) + 1 for b, _, _, _ in items)while len(entries) > 1 and _block_len(entries) > total_char_budget:- oldest_idx = min(range(len(entries)), key=lambda i: entries[i][1])- entries.pop(oldest_idx)+ evict_idx = min(+ range(len(entries)),+ # is_builtin=True sorts as 0 → builtins evict first.+ key=lambda i: (not entries[i][2], entries[i][1]),+ )+ folded_names.append(entries[evict_idx][3])+ entries.pop(evict_idx)overflow += 1- bullets = [b for b, _ in entries]+ bullets = [b for b, _, _, _ in entries]if overflow:- bullets.append(f"- … and {overflow} more")+ named = ", ".join(f"`{n}`" for n in folded_names[:_OVERFLOW_TAIL_NAME_CAP])+ if len(folded_names) > _OVERFLOW_TAIL_NAME_CAP:+ named += ", …"+ # The names keep folded skills callable: run-skill takes the exact name.+ bullets.append(+ f"- … and {overflow} more (no description shown; still callable "+ f"via `run-skill` by exact name): {named}"+ if named+ else f"- … and {overflow} more"+ )header = "## AVAILABLE SKILLS\n"intro = (diff --git a/tests/unit/skills/test_prompt_injection.py b/tests/unit/skills/test_prompt_injection.pyindex c4a2243b4d..62ace9b22e 100644--- a/tests/unit/skills/test_prompt_injection.py+++ b/tests/unit/skills/test_prompt_injection.py@@ -176,7 +176,7 @@ def test_per_entry_char_cap() -> None:out = render_available_skills_section(registry) # type: ignore[arg-type]assert out is not None- line = next(l for l in out.splitlines() if l.startswith("- `huge`"))+ line = next(ln for ln in out.splitlines() if ln.startswith("- `huge`"))# 1536-char cap on description+when_to_use, plus bullet/name overhead.assert len(line) <= 1600assert line.endswith("…")@@ -263,3 +263,121 @@ def test_total_budget_keeps_all_when_under_budget() -> None:assert out is not Noneassert "- `a`" in out and "- `b`" in outassert "more" not in out+++# ----------------------------------------------------------------------+# 2026-08-12 "skills never fire" rework: complete-by-default listing,+# user skills before builtins, and a NAMED overflow tail.+# ----------------------------------------------------------------------+++def test_default_cap_covers_full_builtin_install() -> None:+ """With the default cap, a realistic install (25+ skills) renders every+ bullet — no skill is folded into the tail. Live forensic 2026-08-12: the+ old default of 20 hid five of the user's 25 active skills (including+ ``skill-creator``) and the measured model-initiated run-skill rate was 0.+ """+ skills = [+ _FakeSkill(+ name=f"skill-{i:02d}",+ frontmatter=_FakeFrontmatter(description=f"description {i}"),+ )+ for i in range(30)+ ]+ registry = _FakeRegistry(skills=skills)++ out = render_available_skills_section(registry) # type: ignore[arg-type]++ assert out is not None+ assert "- `skill-29` — description 29" in out+ assert "more" not in out+++def test_overflow_tail_names_folded_skills() -> None:+ """A folded skill must stay CALLABLE: the tail bullet enumerates the+ folded names, because run-skill resolves by exact name and an anonymous+ "… and 5 more" hides exactly the string the model would need.+ """+ skills = [+ _FakeSkill(+ name=f"skill-{i:02d}",+ frontmatter=_FakeFrontmatter(description=f"description {i}"),+ )+ for i in range(25)+ ]+ registry = _FakeRegistry(skills=skills)++ out = render_available_skills_section(registry, max_skills=20) # type: ignore[arg-type]++ assert out is not None+ tail = next(ln for ln in out.splitlines() if ln.startswith("- …"))+ for i in range(20, 25):+ assert f"`skill-{i:02d}`" in tail+ # Folded skills carry no description in the tail — names only.+ assert "description 24" not in out+++def test_user_skills_render_before_builtins() -> None:+ """User-authored skills sort before shipped builtins in the listing."""+ registry = _FakeRegistry(skills=[+ # Real builtin name → _is_builtin() classifies it as shipped.+ _FakeSkill(name="morning-routine", frontmatter=_FakeFrontmatter(+ description="builtin briefing")),+ _FakeSkill(name="my-own-skill", frontmatter=_FakeFrontmatter(+ description="user authored")),+ ])++ out = render_available_skills_section(registry) # type: ignore[arg-type]++ assert out is not None+ assert out.index("- `my-own-skill`") < out.index("- `morning-routine`")+++def test_builtins_fold_before_user_skills_on_overflow() -> None:+ """When the cap forces folding, shipped builtins fold first — the user's+ own skills keep their described bullets.+ """+ registry = _FakeRegistry(skills=[+ _FakeSkill(name="morning-routine", frontmatter=_FakeFrontmatter(+ description="builtin briefing")),+ _FakeSkill(name="deep-work-mode", frontmatter=_FakeFrontmatter(+ description="builtin focus")),+ _FakeSkill(name="my-own-skill", frontmatter=_FakeFrontmatter(+ description="user authored")),+ ])++ out = render_available_skills_section(registry, max_skills=2) # type: ignore[arg-type]++ assert out is not None+ assert "- `my-own-skill` — user authored" in out+ # One builtin survives (cap 2), the other folds into the named tail.+ tail = next(ln for ln in out.splitlines() if ln.startswith("- …"))+ assert "`deep-work-mode`" in tail+++def test_budget_eviction_prefers_builtins_over_user_skills() -> None:+ """Char-budget eviction drops a STALE builtin before a user skill, even+ when the user skill is older.+ """+ registry = _FakeRegistry(skills=[+ _FakeSkillWithMtime(+ name="morning-routine",+ frontmatter=_FakeFrontmatter(description="B" * 200),+ mtime=100.0, # newer than the user skill+ ),+ _FakeSkillWithMtime(+ name="my-own-skill",+ frontmatter=_FakeFrontmatter(description="U" * 200),+ mtime=1.0, # oldest overall+ ),+ ])++ out = render_available_skills_section(+ registry, total_char_budget=300, # type: ignore[arg-type]+ )++ assert out is not None+ assert "- `my-own-skill`" in out+ assert "- `morning-routine` — " not in out+ tail = next(ln for ln in out.splitlines() if ln.startswith("- …"))+ assert "`morning-routine`" in tail