Skip to content

Commit ec35b41

Browse files
committed
添加 soloncode cli 技能提示
1 parent 8a869bd commit ec35b41

3 files changed

Lines changed: 39 additions & 3 deletions

File tree

soloncode-cli/src/main/java/org/noear/solon/codecli/portal/cli/CliCompleter.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import org.noear.solon.ai.harness.HarnessEngine;
2424
import org.noear.solon.ai.harness.agent.AgentDefinition;
2525
import org.noear.solon.ai.harness.command.Command;
26+
import org.noear.solon.ai.skills.cli.SkillDir;
2627

2728
import java.util.List;
2829

@@ -74,5 +75,27 @@ public void complete(LineReader reader, ParsedLine line, List<Candidate> candida
7475
}
7576
}
7677
}
78+
79+
if (line.word().startsWith("$")) {
80+
String prefix = line.word().substring(1).toLowerCase();
81+
for (SkillDir skill : engine.getPoolManager().getSkillMap().values()) {
82+
if (skill.getName().startsWith(prefix)) {
83+
// 构建补全提示:description + argument-hint
84+
String desc = skill.getDescription();
85+
if (desc != null) {
86+
// 取第一行,并限制最大长度
87+
int newlineIdx = desc.indexOf('\n');
88+
if (newlineIdx > 0) {
89+
desc = desc.substring(0, newlineIdx);
90+
}
91+
if (desc.length() > 30) {
92+
desc = desc.substring(0, 30) + "...";
93+
}
94+
}
95+
96+
candidates.add(new Candidate("$" + skill.getName(), "$" + skill.getName() + " " + desc, null, null, null, null, true));
97+
}
98+
}
99+
}
77100
}
78101
}

soloncode-cli/src/main/java/org/noear/solon/codecli/portal/cli/CliShell.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -666,8 +666,9 @@ protected void printWelcome(AgentSession session) {
666666
terminal.writer().println(DIM + path + RESET);
667667
terminal.writer().println(DIM + "Tips: " +
668668
RESET + "(esc)" + DIM + " interrupt | " +
669-
RESET + "/(tab)" + DIM + " ls command | " +
670-
RESET + "@(tab)" + DIM + " ls agent" + RESET);
669+
RESET + "/(tab)" + DIM + " command | " +
670+
RESET + "$(tab)" + DIM + " skill | " +
671+
RESET + "@(tab)" + DIM + " agent" + RESET);
671672

672673
terminal.flush();
673674
}

soloncode-cli/src/main/java/org/noear/solon/codecli/portal/web/WebController.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -476,9 +476,21 @@ public Result<List<Map>> hints() {
476476
}
477477

478478
for (SkillDir skill : engine.getPoolManager().getSkillMap().values()) {
479+
String desc = skill.getDescription();
480+
if (desc != null) {
481+
// 取第一行,并限制最大长度
482+
int newlineIdx = desc.indexOf('\n');
483+
if (newlineIdx > 0) {
484+
desc = desc.substring(0, newlineIdx);
485+
}
486+
if (desc.length() > 30) {
487+
desc = desc.substring(0, 30) + "...";
488+
}
489+
}
490+
479491
Map<String, String> item = new LinkedHashMap<>();
480492
item.put("name", skill.getName());
481-
item.put("description", skill.getDescription());
493+
item.put("description", desc);
482494
item.put("type", "skill");
483495
data.add(item);
484496
}

0 commit comments

Comments
 (0)