mirror of
https://github.com/openclaw/lobster.git
synced 2026-08-14 00:48:09 +00:00
feat: add commands.list for pipeline discovery
This commit is contained in:
+1
-1
@@ -297,5 +297,5 @@ function helpText() {
|
||||
` lobster 'exec --json "echo [1,2,3]" | json'\n` +
|
||||
` lobster run --mode tool 'exec --json "echo [1]" | approve --prompt "ok?"'\n\n` +
|
||||
`Commands:\n` +
|
||||
` exec, head, json, pick, table, where, approve, clawd.invoke, state.get, state.set, diff.last, workflows.list, workflows.run\n`;
|
||||
` exec, head, json, pick, table, where, approve, clawd.invoke, state.get, state.set, diff.last, commands.list, workflows.list, workflows.run\n`;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
export const commandsListCommand = {
|
||||
name: 'commands.list',
|
||||
help() {
|
||||
return (
|
||||
`commands.list — list available Lobster pipeline commands\n\n` +
|
||||
`Usage:\n` +
|
||||
` commands.list\n\n` +
|
||||
`Notes:\n` +
|
||||
` - Intended for agents (e.g. Clawdbot) to discover available pipeline stages dynamically.\n` +
|
||||
` - Output includes the command name and a short description extracted from help().\n`
|
||||
);
|
||||
},
|
||||
async run({ input, ctx }) {
|
||||
// Drain input
|
||||
for await (const _ of input) {
|
||||
// no-op
|
||||
}
|
||||
|
||||
const names = ctx.registry.list();
|
||||
const output = names.map((name) => {
|
||||
const cmd = ctx.registry.get(name);
|
||||
const help = typeof cmd?.help === 'function' ? String(cmd.help()) : '';
|
||||
const firstLine = help.split('\n').find((l) => l.trim().length > 0) ?? '';
|
||||
|
||||
// Expected pattern: "name — description" but fall back to the line as-is.
|
||||
const desc = firstLine.includes('—') ? firstLine.split('—').slice(1).join('—').trim() : firstLine.trim();
|
||||
|
||||
return {
|
||||
name,
|
||||
description: desc,
|
||||
};
|
||||
});
|
||||
|
||||
return {
|
||||
output: (async function* () {
|
||||
for (const item of output) yield item;
|
||||
})(),
|
||||
};
|
||||
},
|
||||
};
|
||||
@@ -10,6 +10,7 @@ import { stateGetCommand, stateSetCommand } from "./stdlib/state.js";
|
||||
import { diffLastCommand } from "./stdlib/diff_last.js";
|
||||
import { workflowsListCommand } from "./workflows/workflows_list.js";
|
||||
import { workflowsRunCommand } from "./workflows/workflows_run.js";
|
||||
import { commandsListCommand } from "./commands_list.js";
|
||||
import { gogGmailSearchCommand } from "./stdlib/gog_gmail_search.js";
|
||||
import { gogGmailSendCommand } from "./stdlib/gog_gmail_send.js";
|
||||
import { emailTriageCommand } from "./stdlib/email_triage.js";
|
||||
@@ -31,6 +32,7 @@ export function createDefaultRegistry() {
|
||||
diffLastCommand,
|
||||
workflowsListCommand,
|
||||
workflowsRunCommand,
|
||||
commandsListCommand,
|
||||
gogGmailSearchCommand,
|
||||
gogGmailSendCommand,
|
||||
emailTriageCommand,
|
||||
|
||||
Reference in New Issue
Block a user