fix(agent): lazy-reload skill registry on CLI slash invocation miss (#57)#203
Merged
Merged
Conversation
The TUI input path (src/tui/app/input.rs) already does a synchronous `SkillRegistry::load_for_working_dir` on a slash-skill miss so that project-local skills installed under `.jcode/skills/` work the moment `skill_manage reload_all` finishes. The CLI loop in agent/turn_execution.rs captured `skills` once at the top of the session and never refreshed it, so users in headless / non-TUI mode saw "Unknown skill: /<name>" even after a successful reload_all. Mirror the TUI behavior: - On a slash miss, re-derive the registry from the session's working directory, replace the shared registry under try_write so subsequent invocations see the fresh snapshot, and retry the lookup once. - After the print-Unknown branch, list available skills from the freshly-snapshotted registry (current_skills_snapshot) instead of the stale top-of-loop `skills` capture, so the user sees what *would* have been resolvable. Closes #57
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
The TUI input path (
src/tui/app/input.rs:2014-2038) already does a synchronousSkillRegistry::load_for_working_diron a slash-skill miss so project-local skills installed under.jcode/skills/work the momentskill_manage reload_allfinishes. The CLI loop insrc/agent/turn_execution.rscapturedskillsonce at the top of the session and never refreshed it, so users in headless / non-TUI mode sawUnknown skill: /<name>even after a successfulreload_all.This addresses issue #57: #57
Changes
try_writeso subsequent invocations see the fresh snapshot.current_skills_snapshotso it reflects whatever the lazy-reload just discovered, not the stale top-of-loop capture.Tests
cargo check -p jcode --libclean. The fix is symmetric with the TUI path that has its own coverage insrc/tui/app/tests/remote_startup_input_03/. The CLI loop is interactive (stdin().read_line), making a focused unit test require pty plumbing that doesn't exist here today; the change itself is a small mechanical mirror of an existing, tested pattern.Notes
The shared registry update uses
try_writeso a reader holding the lock at that exact moment doesn't deadlock the CLI loop — same defensive style ascurrent_skills_snapshot.