Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions crates/dim-cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1229,7 +1229,7 @@ Pickers (`/resume`, `/models`, `/connect`, `/login`, `/approvals`, `/theme`, `/l

Both scrollback and fullscreen palettes list slash commands in the fixed, curated order defined by the [command menu design](../../docs/design/cli-commands.md#command-menu): `/new` is first and `/exit` is last in the unfiltered command list, and the menu draws no category column. Each row shows its `/command`, description and any command shortcut. Commands requiring a session are drawn unbolded and faint, with `(unavailable)` beside the command name so long descriptions do not truncate it away, including on the selected row, until one exists. Keyboard-only actions are omitted from both menus; `/keys` lists the active [send keys](../../docs/design/cli-commands.md#run-keys-and-queue), `Esc` interrupt, and the fullscreen `Home` / `End` scroll and `Tab` message picker bindings.

Opening `/` selects `/new`; pressing Enter starts a new session. `/permissions` is the single visible permission entry; `/approvals` and `/approval` are compatibility aliases for the same unified flow. Selecting an incomplete `exit` match only fills the command name; its exact name or alias is required before dispatch. Thus `/ex` + Enter completes `/exit` without quitting, and another Enter executes the completed command. `Tab` only completes the selected row and never runs or sends: a command fills its name, a command with an argument also fills the space after it, a Skill row fills its `$skill: <name> ` marker, and an empty match changes nothing.
Opening `/` selects `/new`; pressing Enter starts a new session. `/permissions` is the single visible permission entry; `/approvals` and `/approval` are compatibility aliases for the same unified flow. Selecting an incomplete `exit` match only fills the command name; its exact name or alias is required before dispatch. Thus `/ex` + Enter completes `/exit` without quitting, and another Enter executes the completed command. `Tab` only completes the selected row and never runs or sends: a command fills its name, a command with an argument also fills the space after it, a Skill row fills `/skill:<name> `, and an empty match changes nothing. On a Skill row, Enter also completes without sending. Home offers Skills from the launch workspace before the first message.

Typing ranks the matches: the exact name, a name prefix, an alias prefix, a prefix of a name part (`reload-skills` for `sk`), a name containing the query, a description word starting with it, then three or more letters in order through the name (`stg` for `settings`); a match inside a description word does not count. Equally ranked matches keep the fixed order.

Expand Down Expand Up @@ -1497,7 +1497,7 @@ The terminal UI reaches the same Session methods as the line client:
| `/mcp enable ID` / `/mcp disable ID [--source SOURCE]` | Turns a server on or off with the request `dimcode mcp enable` / `mcp disable` sends and the same result text. Enabling a project entry runs this workspace's `.mcp.json` entry, including later edits, in active and new sessions; disabling stops it in every session before the call returns. The next `/mcp` lists the new state |
| `/plugins` (`/plugin`) | Lists every plugin name from `plugin.list` (built-in, default, installed): the candidate in use, its state, whether it is locked, and for the selected one its candidates and any error, wait or refused content. `Enter` turns an off plugin on (`plugin.enable`) or, after a confirmation, turns it off (`plugin.disable`); a locked one says why it cannot be turned off. `r` reloads it (`plugin.reload`), `Ctrl+R` lists again. The list is read again after each change, and a failed call shows the method's message |
| `/plugins install PATH` | Installs and turns on the plugin directory at `PATH`, relative to the workspace (`plugin.install`), then opens the list with the outcome, including when a restart is required. Git installs, update and remove are `dimcode plugin ...` |
| `/skills` | Lists the Skills of the Session's workspace from `skills.catalog`, grouped under the source each was found in (`user`, `project`, `plugin:<id>`), with its state and, for the selected one, its description and file; the catalog's issues follow the entries. `Enter` or `Space` enables or disables the selected Skill (`skills.set_enabled`) and the list is read again; `Ctrl+R` rescans the roots (`skills.refresh`). A daemon without the methods says it cannot manage skills |
| `/skills` | Lists Skill names and states from `skills.catalog`, grouped by source (`user`, `project`, `plugin:<id>`), without a selection preview; catalog issues follow the entries. `Tab` toggles the selected Skill (`skills.set_enabled`) in place. `Enter` on an invocable Skill returns to the chat composer with its reference; type the task and press `Enter` to send. `Ctrl+R` rescans the roots (`skills.refresh`). A daemon without the methods says it cannot manage skills |
| `/reload-skills` | Runs the rescan of the Session's workspace with no panel and reports the entry and issue counts it found, plus each issue |
| `/hooks` | Lists each hook source of the Session's workspace as an entry from `hooks.catalog`, with its state and detail; `Enter` or `Space` enables or disables the Session's project source (`hooks.set_enabled`), `Ctrl+E` opens the user document in `$EDITOR` and writes it with `hooks.save` and the revision the panel read, `Ctrl+R` reads the area again. A plugin source is read-only and offers no write |
| `/scheduled` (`/schedule`) | Lists the jobs the Scheduler holds from `schedule.list`, one entry per job with its schedule, next window, last outcome, target and disabled reason as its detail, and a job whose schedule the owner cannot use marked with that error; jobs are the host's, not the Session's or workspace's, and only a new job's default `cwd` comes from the Session. `Enter` or `Space` enables or pauses the job (`schedule.set_enabled`), `Ctrl+E` edits the job's document in `$EDITOR` with the revision the list reported (`schedule.save`), `Ctrl+N` creates a job from the document the adapter supplies, `Ctrl+X` removes the job after `Remove NAME? Enter confirm · Esc cancel` (`schedule.delete`), `Ctrl+T` runs it now (`schedule.run_now`) and reports the delivery it recorded for the manual window, `Tab` asks the inspect kind, which the Scheduler serves as history (`schedule.history`), and shows the job's recent runs in place of the list with `Esc` returning to it, `Ctrl+R` reads the list again. An edit sends only the members the draft changed |
Expand Down Expand Up @@ -1616,11 +1616,13 @@ Both surfaces compose their text in the interface language ([`/language`](#termi
The session starts in the language the interface chose and switches on every `/language` save,
so a switch shows from the next reply. A subcommand uses the saved language, else the system's.

The keys are one per action kind in every area, and each keeps one meaning: `Enter` or `Space`
In Skills, `Enter` inserts the enabled Skill into the task draft without sending, `Tab` toggles
the selected entry, and `Space` does not toggle it. In other areas, `Enter` or `Space`
toggles, `Ctrl+E` opens a document in the external editor, `Ctrl+R` re-reads the area or asks its
owner to rescan, `Ctrl+N` adds, `Ctrl+X` removes, `Ctrl+T` runs, `Tab` inspects, and `Esc`
closes. A kind is offered only where the area's method table and the owner's view have one, so
an area with no run action never names `Ctrl+T`. An action key is a Ctrl chord, or a key the
closes. Using a Skill is local to the composer. A management action is offered only where the
area's method table and the owner's view have one, so an area with no run action never names
`Ctrl+T`. An action key is a Ctrl chord, or a key the
filter never takes, because the filter takes every plain letter. The hint names the area's
kinds plus the selected entry's, on the bottom border or, when that cannot hold it, in rows
above the border wrapped by width so no key or action is cut; reload and add act on the area, so
Expand Down
1 change: 1 addition & 0 deletions crates/dim-cli/src/management/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ pub(crate) fn unsupported(area: &Area, kind: Option<ActionKind>) -> String {
/// the read's check has already passed. Skills' reload has its own method.
fn kind_sentence(kind: ActionKind) -> &'static str {
match kind {
ActionKind::UseSkill => unreachable!("drafting a Skill makes no management request"),
ActionKind::Toggle => "This daemon lists {area} but cannot toggle them.",
ActionKind::Edit => "This daemon lists {area} but cannot edit them.",
ActionKind::Reload => "This daemon lists {area} but cannot reload them.",
Expand Down
15 changes: 14 additions & 1 deletion crates/dim-cli/src/management/skills.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,15 @@ fn invocable() -> bool {
true
}

impl Entry {
pub fn can_use(&self) -> bool {
self.enabled
&& self.shadowed_by.is_none()
&& self.user_invocable
&& dim_agent_types::skill_token::names_a_token(&self.name)
}
}

/// A Skill the catalog could not use.
#[derive(Debug, Deserialize)]
pub struct Issue {
Expand Down Expand Up @@ -119,6 +128,10 @@ pub(super) fn view(catalog: &Catalog, actions: &[ActionKind]) -> ManagementView
if let Some(by) = &entry.shadowed_by {
states.push(EntryState::Shadowed { by: by.clone() });
}
let mut actions = super::entry_kinds(actions);
if entry.can_use() {
actions.push(ActionKind::UseSkill);
}
groups.push(
entry.source.as_deref().unwrap_or(t("skills")),
ManagementEntry {
Expand All @@ -128,7 +141,7 @@ pub(super) fn view(catalog: &Catalog, actions: &[ActionKind]) -> ManagementView
detail: [entry.description.clone(), entry.file_path.clone()].to_vec(),
enabled: Some(entry.enabled),
states,
actions: super::entry_kinds(actions),
actions,
remove_verb: RemoveVerb::Remove,
document: None,
run: None,
Expand Down
3 changes: 2 additions & 1 deletion crates/dim-cli/src/model/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -729,9 +729,10 @@ pub enum EntryState {
ReadOnly,
}

/// An action kind the client offers. Every kind has one key in every panel.
/// An action kind the client offers.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum ActionKind {
UseSkill,
Toggle,
Edit,
Reload,
Expand Down
47 changes: 9 additions & 38 deletions crates/dim-cli/src/projection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2273,8 +2273,7 @@ pub(crate) fn raw_input_line(blocks: &[dim_agent_types::InputBlock]) -> Option<S
})
}

/// The one line that names a loaded Skill, in the interface language: the
/// message's presentation and the plain log both say it.
/// The plain log's localized record of a loaded Skill.
pub(crate) fn skill_loaded_label(name: &str) -> String {
crate::ui::i18n::tf("Skill loaded: {name}", &[("name", name)])
}
Expand Down Expand Up @@ -2359,37 +2358,21 @@ fn loaded_skill(index: usize, block: &ContentBlock) -> Option<String> {
})
}

/// The presentation of an operator message: its words with an image marker per
/// image and one line per loaded Skill; `None` when its words are the message.
/// The operator's words interleaved with image markers; `None` for text alone.
fn user_display(blocks: &[ContentBlock]) -> Option<String> {
let mut images = 0;
let mut skills = Vec::new();
let mut lines = Vec::new();
for (index, block) in blocks.iter().enumerate() {
match block {
ContentBlock::Text { text } => match loaded_skill(index, block) {
Some(name) => skills.push(name),
None if markup::runtime_context(index, text) => {}
None => lines.push(text.clone()),
},
ContentBlock::Text { text } if markup::runtime_context(index, text) => {}
ContentBlock::Text { text } => lines.push(text.clone()),
ContentBlock::Image { .. } => {
images += 1;
lines.push(crate::images::marker(images, ""));
}
}
}
if images == 0 && skills.is_empty() {
return None;
}
let mut display = lines.join("\n");
for skill in skills {
let line = skill_loaded_label(&skill);
if !display.is_empty() {
display.push('\n');
}
display.push_str(&line);
}
Some(display)
(images != 0).then(|| lines.join("\n"))
}

/// A provider presentation's line, as today: its own words, prefixed.
Expand Down Expand Up @@ -3531,11 +3514,8 @@ mod tests {
crate::ui::i18n::set(previous);
}

/// A loaded Skill block (Skills §9) is one line under the operator's
/// message, never its instructions; the editable text stays the
/// operator's own words.
#[test]
fn a_loaded_skill_shows_as_one_line_under_the_message() {
fn loaded_skills_do_not_change_the_visible_message() {
let previous = crate::ui::i18n::active();
crate::ui::i18n::set(crate::ui::i18n::Locale::En);
let image = serde_json::json!({
Expand Down Expand Up @@ -3608,25 +3588,16 @@ mod tests {
);
let rows = projection.snapshot().rows;
assert_eq!(rows[0].text, "one $skill: checkin please");
assert_eq!(
rows[0].display.as_deref(),
Some("one $skill: checkin please\nSkill loaded: checkin")
);
assert_eq!(rows[0].display, None);
assert_eq!(rows[1].text, "two");
assert_eq!(
rows[1].display.as_deref(),
Some("two\nSkill loaded: alpha\nSkill loaded: beta")
);
assert_eq!(rows[1].display, None);
assert_eq!(
rows[2].text, "<dim-skill name=\"mine\">as typed",
"a first block is the operator's own text, shown as typed"
);
assert_eq!(rows[2].display, None);
assert_eq!(rows[3].text, "look");
assert_eq!(
rows[3].display.as_deref(),
Some("look\n[Image #1]\nSkill loaded: checkin")
);
assert_eq!(rows[3].display.as_deref(), Some("look\n[Image #1]"));
crate::ui::i18n::set(previous);
}

Expand Down
41 changes: 28 additions & 13 deletions crates/dim-cli/src/session_host.rs
Original file line number Diff line number Diff line change
Expand Up @@ -859,6 +859,7 @@ impl Worker {
"Cannot preview startup model: {error}"
)));
}
self.read_skills().await;
Ok(())
}

Expand Down Expand Up @@ -976,6 +977,7 @@ impl Worker {
}
Err(error) => {
self.parked = attached_session;
self.read_skills().await;
Err(error)
}
}
Expand Down Expand Up @@ -1014,6 +1016,7 @@ impl Worker {
kind,
cwd: None,
});
self.read_skills().await;
self.reportable(
crate::report::Captured::observed(
crate::report::Operation::SessionRead,
Expand Down Expand Up @@ -1169,27 +1172,38 @@ impl Worker {
},
));
}
if self.client.offers("skills.catalog") {
match &self.session_cwd {
Some(cwd) => {
reads.push(("skills.catalog", json!({"cwd":cwd}), OpeningRead::Skills))
}
None => self.send(Update::Notice(
"Skills unavailable: the daemon did not report the Session workspace".into(),
)),
}
}
for (method, params, kind) in reads {
match self.client.send(method, params).await {
Ok(id) => self.opening_reads.push((id, kind)),
Err(error) => self.send(Update::Notice(format!("{method}: {error}"))),
}
}
self.read_skills().await;
self.context_stale = true;
self.publish();
Ok(())
}

async fn read_skills(&mut self) {
if !self.client.offers("skills.catalog") {
return;
}
let cwd = if self.session_id.is_empty() {
self.options.workspace().as_str()
} else if let Some(cwd) = self.session_cwd.as_deref() {
cwd
} else {
self.send(Update::Notice(
"Skills unavailable: the daemon did not report the Session workspace".into(),
));
return;
};
match self.client.send("skills.catalog", json!({"cwd":cwd})).await {
Ok(id) => self.opening_reads.push((id, OpeningRead::Skills)),
Err(error) => self.send(Update::Notice(format!("skills.catalog: {error}"))),
}
}

fn opening_reply(&mut self, kind: OpeningRead, result: Result<Value, client::RpcError>) {
match kind {
OpeningRead::Catalog(model) => {
Expand Down Expand Up @@ -1814,7 +1828,7 @@ impl Worker {
// Home, not a Session: the first message creates one. Every
// `/new` ends here, including the one that was already Home.
Command::NewSession => {
self.home();
self.home().await;
self.send(Update::NewSessionDone);
}
Command::DeleteSession { session_id, name } => {
Expand All @@ -1824,7 +1838,7 @@ impl Worker {
// behind the reply then match no Session and are ignored, so
// they raise no disconnect report.
if shown && outcome.ends_session() {
self.home();
self.home().await;
}
self.send(Update::Deleted(DeleteReply {
session_id,
Expand Down Expand Up @@ -2782,7 +2796,7 @@ impl Worker {
/// Home, not a Session: the first message creates one. `/new`, and a
/// delete of the shown Session, leave to it the same way, so the composer
/// and the `─ new session ─` boundary are what `/new` leaves.
fn home(&mut self) {
async fn home(&mut self) {
if self.session_id.is_empty() {
return;
}
Expand All @@ -2800,6 +2814,7 @@ impl Worker {
kind: SwitchKind::New,
cwd: None,
});
self.read_skills().await;
}

/// `session.delete {sessionId}` for one row of `/resume`, without
Expand Down
Loading