Skip to content

feat(runtime): extract shared skills module and adopt it in desktop - #749

Merged
Astro-Han merged 2 commits into
mainfrom
feat/748-extract-runtime-skills
Jul 12, 2026
Merged

Astro-Han merged 2 commits into
mainfrom
feat/748-extract-runtime-skills

Conversation

@Astro-Han

@Astro-Han Astro-Han commented Jul 12, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Extract the runtime-facing skill read path from apps/desktop into a shared @maka/runtime skills module, then adopt it in desktop.
  • InstalledSkill extends RuntimeSkillDefinition; readInstalledSkillDefinitions calls scanWorkspaceSkills and enriches governance on top; runtime-facing functions are deleted from desktop and re-exported so call sites and tests keep importing from ./skills.js unchanged.
  • Behavior-preserving refactor; first slice of feat(runtime+cli): inject skills into the CLI via a shared runtime skills module #748.

Why

The CLI has zero skill support — neither the skill catalog in the system prompt nor the Skill tool is wired — while desktop and CLI share the same workspaceRoot. #748 moves skills into scope. Ticket 1 establishes the shared runtime module as a behavior-preserving foundation so ticket 2 (host-compatibility gate) and ticket 3 (wire CLI injection) build on it without duplicating skill logic.

Refs #748 (ticket 1 of 3: extract + adopt). Closes nothing yet — tickets 2 and 3 land separately.

Scope

Two commits:

  • feat(runtime): add shared workspace skills module — new packages/runtime/src/skills.ts (RuntimeSkillDefinition, scanWorkspaceSkills, buildSkillsPromptFragment, loadSkillInstructions, buildSkillAgentTool, parseSkillFrontMatter, readSkillRuntimeState/writeSkillRuntimeState, shared path-safety primitives), index.ts re-exports, and 11 runtime behavior tests.
  • refactor(desktop): adopt the shared runtime skills module — apps/desktop/src/main/skills.ts switches to the runtime module; governance (lock, provenance, managed-source status, Office seeding) stays in desktop.

Non-goals: host-compatibility gating (ticket 2) and CLI wiring (ticket 3) are out of scope for this PR.

Verification

  • npm run -w @maka/runtime test — 1287 pass, 0 fail (includes the 11 new skills tests).
  • npm run -w @maka/desktop test — 2320 pass, 0 fail, matching the rebased main baseline (behavior-preserving).
  • npm run typecheck and npm run build green across all workspaces.
  • Independent codex review (max effort, read-only sandbox) — PASS, no P0–P3 findings. It noted non-blocking coverage gaps: runtime unit tests do not separately cover the prompt char/count limit branches, SKILL.md / skill-directory symlink scan, and "ignore a corrupted lock and load the workspace copy"; all three remain covered by the desktop integration suite.

Impact

None for end users — desktop behavior is unchanged. No migration, compatibility, documentation, or release-note requirements. Internally, @maka/runtime gains a shared skills module and apps/desktop depends on it for the skill read path; desktop governance stays local.

Reviewer notes

Focus on:

  1. Behavior preservation — buildSkillsPromptFragment now scans via scanWorkspaceSkills (no governance read) instead of the old readInstalledSkillDefinitions; loadSkillInstructions availableSkills type changed from Pick<InstalledSkill, ...> to Pick<RuntimeSkillDefinition, ...>; contentSha256 now comes from ScannedSkill (raw file bytes hash) and is passed to readSkillLockStatus as currentHash. Confirm these are equivalent for desktop callers and IPC.
  2. Extraction boundary — nothing governance-only leaked into runtime; nothing runtime-only (the old sha256Buffer, SkillStateFile, SkillRuntimeStateReadResult, SkillDefinition types; the path primitives) is left duplicated in desktop.
  3. contentSha256 spread — in readInstalledSkillDefinitions, a missing lock must not let ScannedSkill.contentSha256 leak into InstalledSkill.contentSha256 (the explicit field copy + ...status spread handles this; missing-lock status omits contentSha256).

Ready for review

  • Verification is complete and the results above are current
  • Impact, compatibility, migration, documentation, and release-note needs are addressed
  • User-visible UI/UX changes include visual evidence, or Verification explains why it is not applicable — N/A: internal refactor with no UI changes

Add a @maka/runtime skills module owning the runtime-facing skill read
path: scanWorkspaceSkills (scan + parse + per-workspace enablement
read), buildSkillsPromptFragment, loadSkillInstructions,
buildSkillAgentTool, parseSkillFrontMatter, readSkillRuntimeState /
writeSkillRuntimeState, and the shared path-safety primitives. Exports
RuntimeSkillDefinition (stable, no content) and ScannedSkill (adds
content + contentSha256) so a future CLI host can consume skills without
duplicating the read path or pulling in desktop governance.

11 behavior tests cover scan, prompt, lazy load, the Skill tool,
enablement state, and symlink hardening.

Refs #748 (ticket 1: runtime module).
Switch apps/desktop to the new @maka/runtime skills module:
InstalledSkill extends RuntimeSkillDefinition and
readInstalledSkillDefinitions calls scanWorkspaceSkills then enriches
governance (lock, provenance, managed-source status, Office seeding).
The runtime-facing functions (buildSkillsPromptFragment,
loadSkillInstructions, buildSkillAgentTool, parseSkillFrontMatter, MAX_*,
path primitives, enablement state) are deleted from desktop and
re-exported from @maka/runtime, so desktop call sites
(system-prompt-main.ts, main.ts, workspace-resources-ipc-main.ts) and the
1407-line desktop suite keep importing from ./skills.js unchanged.

Desktop behavior is preserved: the 2316-test desktop suite stays green,
matching the pre-change baseline.

Refs #748 (ticket 1: desktop adoption).
@Astro-Han
Astro-Han force-pushed the feat/748-extract-runtime-skills branch from 81cdf2e to f06fedf Compare July 12, 2026 04:23
@Astro-Han
Astro-Han merged commit 9779a3c into main Jul 12, 2026
3 checks passed
@Astro-Han
Astro-Han deleted the feat/748-extract-runtime-skills branch July 14, 2026 05:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant