Skip to content

feat(skills): inject skill to help configure kaiden workspaces#491

Open
feloy wants to merge 5 commits into
openkaiden:mainfrom
feloy:skill-config
Open

feat(skills): inject skill to help configure kaiden workspaces#491
feloy wants to merge 5 commits into
openkaiden:mainfrom
feloy:skill-config

Conversation

@feloy

@feloy feloy commented May 10, 2026

Copy link
Copy Markdown
Contributor

Introduces a skills/ package that embeds user-facing skill directories into the kdn binary at compile time. manager.Add() calls ExtractAll() to extract and mount all built-in skills automatically for agents that support them; user-configured skills with the same basename override the built-in version.

The first built-in skill, config-kdn-workspace, helps agents running inside a workspace configure environment variables, mounts, secrets, MCP servers, network policies, and other settings interactively.

Fixes #350

Introduces a skills/ package that embeds user-facing skill directories
into the kdn binary at compile time. manager.Add() calls ExtractAll()
to extract and mount all built-in skills automatically for agents that
support them; user-configured skills with the same basename override
the built-in version.

The first built-in skill, config-kdn-workspace, helps agents running
inside a workspace configure environment variables, mounts, secrets,
MCP servers, network policies, and other settings interactively.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Philippe Martin <phmartin@redhat.com>
@feloy feloy requested review from benoitf, jeffmaury and slemeur May 10, 2026 16:12
@codecov

codecov Bot commented May 10, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 92.00000% with 4 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
pkg/instances/manager.go 90.47% 1 Missing and 1 partial ⚠️
skills/skills.go 93.10% 1 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

@coderabbitai

coderabbitai Bot commented May 10, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

This PR adds an embedded built-in skills system (skills package + ExtractAll), wires extraction into Manager.Add to auto-inject built-in skills into merged workspace config, introduces the config-kdn-workspace skill, updates docs, and adds tests for extraction and injection behavior.

Changes

Built-in Skills System & Configuration Skill

Layer / File(s) Summary
Skills Extraction Implementation
skills/skills.go
embed.FS (builtInFS) embedding config-kdn-workspace and ExtractAll(storageDir) that extracts each top-level embedded directory into storageDir/skills/<name> with directories 0755 and files 0644, returning created paths.
Manager Auto-injection Integration
pkg/instances/manager.go
When the selected agent reports a non-empty SkillsDir(), calls skills.ExtractAll(m.storageDir) and appends any extracted paths not already present into mergedConfig.Skills (allocating slices as needed) before converting skills to container mounts.
Extraction & Injection Tests
skills/skills_test.go, pkg/instances/manager_test.go
TestExtractAll asserts extraction returns paths, directories exist, contain SKILL.md, re-extraction overwrites corrupt files, and extraction errors propagate when dest is non-writable. TestManager_Add_InjectsBuiltInSkills and updated mount test verify injection when no user skills, basename deduplication (e.g., config-kdn-workspace), skipping when agent SkillsDir is empty, and error propagation on extraction failure.
Architecture Documentation
AGENTS.md, README.md
Distinguishes contributor skills (.agents/skills/, discovered via .claude/skills) from built-in user-facing skills (skills/, embedded), documents extraction to <storageDir>/skills/<name>/, manager auto-injection with dedupe, read-only mounting of user skill host dirs by basename, and separate add-skill procedures (contributor vs built-in including //go:embed).
Configuration Skill Guide
skills/config-kdn-workspace/SKILL.md
Comprehensive interactive guide for configuring workspace/global/project/agent settings: metadata, sandbox rules, precedence, JSON snippets for env/mounts/skills/MCP/network/secrets/features/ports, examples, kdn autoconf, validation rules, and merge semantics.

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant Manager
  participant skillsPkg as skills.ExtractAll
  participant Storage as storageDir

  Client->>Manager: Manager.Add(selectedAgent, workspace)
  alt agent supports skills
    Manager->>skillsPkg: ExtractAll(storageDir)
    skillsPkg-->>Storage: write storageDir/skills/<name> (0755/0644)
    skillsPkg-->>Manager: []string (extractedPaths)
    Manager->>Manager: merge/dedupe extractedPaths into mergedConfig.Skills
    Manager->>Client: create/run instance with augmented mounts
  else agent no skills
    Manager->>Client: create/run instance without built-in skill mounts
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • openkaiden/kdn#241: Introduces an OpenCode agent with a SkillsDir() implementation that interacts with this PR's built-in skill injection logic.
  • openkaiden/kdn#228: Prior change converting workspace.Skills into agent skill mounts; this PR extends that flow by injecting built-in skills first.
  • openkaiden/kdn#287: Related repository layout and skills discovery changes that affect embedding/extraction expectations.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 16.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description check ✅ Passed The description clearly explains the purpose of the PR, covering the skills package, automatic extraction/mounting, override behavior, and the specific config-kdn-workspace skill.
Linked Issues check ✅ Passed The PR fully addresses issue #350 by providing a new skill (config-kdn-workspace) that helps users configure kdn interactively, with comprehensive documentation and automatic injection into workspaces.
Out of Scope Changes check ✅ Passed All changes are in scope: the skills package, manager integration for skill extraction/mounting, documentation updates, and comprehensive tests for the new functionality.
Title check ✅ Passed The title accurately reflects the main change: introducing a built-in skill (config-kdn-workspace) that is automatically injected and extracted to help users configure kdn workspaces.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
pkg/instances/manager_test.go (1)

4135-4168: ⚡ Quick win

Consider verifying that the user's skill path takes precedence over the built-in.

The test correctly verifies that no duplication occurs (count == 1), but it doesn't assert which skill is mounted. According to the PR objectives, "the user-configured skill overrides the built-in version." If the implementation incorrectly mounted only the built-in skill and ignored the user's, this test would still pass.

Suggested enhancement to verify user override behavior
 		count := 0
+		var mountedPath string
 		for _, m := range *params.WorkspaceConfig.Mounts {
 			if filepath.Base(m.Host) == "config-kdn-workspace" {
 				count++
+				mountedPath = m.Host
 			}
 		}
 		if count != 1 {
 			t.Errorf("Expected exactly 1 config-kdn-workspace mount, got %d", count)
 		}
+		if mountedPath != userSkillPath {
+			t.Errorf("Expected user skill path %q to be mounted, got %q", userSkillPath, mountedPath)
+		}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@pkg/instances/manager_test.go` around lines 4135 - 4168, Update the test
"built-in skill is not duplicated when user configures same basename" to also
assert that the mounted skill is the user's path (userSkillPath) rather than the
built-in; after collecting the matching mounts from params :=
spy.LastCreateParams() and iterating params.WorkspaceConfig.Mounts, verify at
least one mount has Host equal to userSkillPath (or prefer exact equality) and
fail if the only matching mount points to a built-in location; use the existing
userSkillPath, params.WorkspaceConfig.Mounts, and filepath.Base checks to locate
and compare the mounted Host to ensure user-configured skill takes precedence.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@README.md`:
- Line 33: Update the README wording to avoid saying built-in skills are present
in "every workspace" and instead clarify they are injected only when agent skill
support is enabled (i.e., when SkillsDir() != ""), e.g., change the sentence
referencing "Built-in skills automatically available in every workspace —
including `config-kdn-workspace`..." to indicate built-in skills are available
only in workspaces where SkillsDir() is set/enabled; apply the same rewording to
the repeated section around lines 1901-1907 so both references correctly reflect
the conditional injection behavior.

---

Nitpick comments:
In `@pkg/instances/manager_test.go`:
- Around line 4135-4168: Update the test "built-in skill is not duplicated when
user configures same basename" to also assert that the mounted skill is the
user's path (userSkillPath) rather than the built-in; after collecting the
matching mounts from params := spy.LastCreateParams() and iterating
params.WorkspaceConfig.Mounts, verify at least one mount has Host equal to
userSkillPath (or prefer exact equality) and fail if the only matching mount
points to a built-in location; use the existing userSkillPath,
params.WorkspaceConfig.Mounts, and filepath.Base checks to locate and compare
the mounted Host to ensure user-configured skill takes precedence.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: a62d98d1-4062-4725-933d-89a81078991f

📥 Commits

Reviewing files that changed from the base of the PR and between 1008590 and 6352d99.

📒 Files selected for processing (7)
  • AGENTS.md
  • README.md
  • pkg/instances/manager.go
  • pkg/instances/manager_test.go
  • skills/config-kdn-workspace/SKILL.md
  • skills/skills.go
  • skills/skills_test.go

Comment thread README.md
feloy and others added 3 commits May 10, 2026 16:26
Refactor extractAll into an fs.FS-accepting inner function to enable
custom file system injection in tests. Add TestExtractAll_internal
with four cases: ReadDir failure, ReadFile failure during walk,
non-directory root entries skipped, and the WalkDir callback error
path via readDirErrorFS.

Also add the extraction-failure path to
TestManager_Add_InjectsBuiltInSkills.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Philippe Martin <phmartin@redhat.com>
chmod-based write-permission simulation does not enforce access
restrictions on Windows, causing the "not writable" error tests
to fail. Skip them with runtime.GOOS == "windows", matching the
pattern already used in pkg/config and pkg/credential tests.

Co-Authored-By: Claude Code (claude-sonnet-4-6) <noreply@anthropic.com>
Signed-off-by: Philippe Martin <phmartin@redhat.com>
The manager_test.go already imports pkg/runtime as "runtime"; the
stdlib "runtime" package added for GOOS must use a goruntime alias
to avoid the redeclared-in-block vet error.

Co-Authored-By: Claude Code (claude-sonnet-4-6) <noreply@anthropic.com>
Signed-off-by: Philippe Martin <phmartin@redhat.com>
@feloy feloy changed the title feat(skills): embed and auto-inject built-in skills into workspaces feat(skills): inject skill to help configure kaiden workspaces May 10, 2026
…e skill

Signed-off-by: Philippe Martin <phmartin@redhat.com>

Co-Authored-By: Claude Code (Claude Sonnet 4.5) <noreply@anthropic.com>
@feloy feloy changed the title feat(skills): inject skill to help configure kaiden workspaces feat(skills): inject skill to help configure kaiden workspaces May 11, 2026
@bmahabirbu

Copy link
Copy Markdown
Contributor

Nice, how can I test this? from the issue it said the new skills can help an agent set up kdn for the first time and help them configure the workspace and skill/mcp injection

but it sounds like an agent needs to be running on host with kdn knowledge? Maybe im mistaken but would like a quick test plan!

@feloy

feloy commented May 12, 2026

Copy link
Copy Markdown
Contributor Author

@bmahabirbu you need to have a model provider (vertex ai, etc) configured, then you create and start a workspace, and you ask the agent to help you configure an mcp server.

If you look at https://www.youtube.com/watch?v=bB8t3U1m9pg, I'm using this several times during the recorded session

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.

Write a skill for configuring kdn

2 participants