mirror of
https://github.com/modelstudioai/cli.git
synced 2026-09-14 19:49:23 +08:00
b2ca78512f
- define the Command Pack API and integrate pack loading into the CLI runtime - add product-specific package, command prefix, and credential access policies - add plugin install, link, list, and remove commands - add validation, tests, documentation, and generated command references
59 lines
1.4 KiB
JavaScript
59 lines
1.4 KiB
JavaScript
const ping = {
|
|
description: "Ping the Command Pack fixture",
|
|
auth: "none",
|
|
flags: {
|
|
message: {
|
|
type: "string",
|
|
valueHint: "<text>",
|
|
required: true,
|
|
description: "Message returned by the fixture",
|
|
},
|
|
},
|
|
usageArgs: "--message <text>",
|
|
exampleArgs: ['--message "hello"'],
|
|
async run(ctx) {
|
|
process.stdout.write(`command-pack:${ctx.flags.message}\n`);
|
|
},
|
|
};
|
|
|
|
const credential = {
|
|
description: "Read an API key through the Command Pack host adapter",
|
|
auth: "apiKey",
|
|
async run(ctx) {
|
|
const apiKey = ctx.credentials.apiKey();
|
|
process.stdout.write(`credential-source:${apiKey.source}\n`);
|
|
},
|
|
};
|
|
|
|
const credentialDenied = {
|
|
description: "Verify credential access also requires command auth",
|
|
auth: "none",
|
|
async run(ctx) {
|
|
ctx.credentials.apiKey();
|
|
},
|
|
};
|
|
|
|
const output = {
|
|
description: "Exercise the Command Pack output helper",
|
|
auth: "none",
|
|
async run(ctx) {
|
|
ctx.output.result({ source: "command-pack", ok: true }, { text: "command-pack-output" });
|
|
},
|
|
};
|
|
|
|
const fail = {
|
|
description: "Exercise the Command Pack semantic error helper",
|
|
auth: "none",
|
|
async run(ctx) {
|
|
throw ctx.errors.usage("Command Pack fixture usage error.", "Use agent fail only in tests.");
|
|
},
|
|
};
|
|
|
|
export default {
|
|
"agent credential": credential,
|
|
"agent credential-denied": credentialDenied,
|
|
"agent fail": fail,
|
|
"agent output": output,
|
|
"agent ping": ping,
|
|
};
|