-
Notifications
You must be signed in to change notification settings - Fork 16.3k
Project executor skills through World State #30088
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
cdfb338
Expose extension-owned World State sections
jif-oai 04a50f4
Project executor skills through World State
jif-oai c101de9
Merge branch 'main' into jif/extension-owned-selected-skills
jif-oai 3292f71
Use step-ready roots for executor skills
jif-oai d5e50b1
Merge branch 'main' into jif/extension-owned-selected-skills
jif-oai 9d02761
Distinguish hidden executor skills
jif-oai 0e9a5a5
Compare normalized skill state semantically
jif-oai File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Project executor skills through World State
- Loading branch information
commit 04a50f49c5b0cad7dd3e35c3ad8ca43bf90dc0ef
There are no files selected for viewing
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| use codex_extension_api::ContextualUserFragment; | ||
| use codex_extension_api::PreviousWorldStateSection; | ||
| use codex_extension_api::RenderedWorldStateFragment; | ||
| use codex_extension_api::WorldStateSectionContribution; | ||
| use codex_protocol::protocol::SKILLS_INSTRUCTIONS_CLOSE_TAG; | ||
| use codex_protocol::protocol::SKILLS_INSTRUCTIONS_OPEN_TAG; | ||
| use serde_json::json; | ||
|
|
||
| use crate::catalog::SkillCatalog; | ||
| use crate::render::available_skills_fragment; | ||
|
|
||
| pub(crate) const SKILLS_WORLD_STATE_ID: &str = "skills"; | ||
| const NO_EXECUTOR_SKILLS_BODY: &str = | ||
| "\n## Skills update\nNo selected-environment skills are currently available.\n"; | ||
|
|
||
| pub(crate) fn executor_skills_world_state_section( | ||
| catalog: &SkillCatalog, | ||
| include_instructions: bool, | ||
| ) -> WorldStateSectionContribution { | ||
| let body = if include_instructions { | ||
| available_skills_fragment(catalog).map(|fragment| fragment.body()) | ||
|
jif-oai marked this conversation as resolved.
|
||
| } else { | ||
| None | ||
| }; | ||
| let snapshot = json!({"body": body}); | ||
|
|
||
| WorldStateSectionContribution::new(SKILLS_WORLD_STATE_ID, snapshot, move |previous| { | ||
| let previous_is_absent = matches!(&previous, PreviousWorldStateSection::Absent); | ||
| let previous_is_known = matches!(&previous, PreviousWorldStateSection::Known(_)); | ||
| let previous_body = match &previous { | ||
| PreviousWorldStateSection::Known(previous) => { | ||
| previous.get("body").and_then(serde_json::Value::as_str) | ||
| } | ||
| PreviousWorldStateSection::Absent | PreviousWorldStateSection::Unknown => None, | ||
| }; | ||
| if previous_is_known && previous_body == body.as_deref() { | ||
| return None; | ||
| } | ||
|
|
||
| let body = match body.as_deref() { | ||
| Some(body) => body, | ||
| None if previous_is_absent => return None, | ||
| None => NO_EXECUTOR_SKILLS_BODY, | ||
| }; | ||
| Some(RenderedWorldStateFragment::new( | ||
| "developer", | ||
| (SKILLS_INSTRUCTIONS_OPEN_TAG, SKILLS_INSTRUCTIONS_CLOSE_TAG), | ||
| body, | ||
| )) | ||
| }) | ||
| .with_legacy_matcher(|role, text| { | ||
| role == "developer" | ||
| && text.trim_start().starts_with(SKILLS_INSTRUCTIONS_OPEN_TAG) | ||
| && text.trim_end().ends_with(SKILLS_INSTRUCTIONS_CLOSE_TAG) | ||
|
jif-oai marked this conversation as resolved.
|
||
| }) | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.