Skip to content

Commit f0b040c

Browse files
committed
add --robot flag, remove redundant path command
- list --robot: TSV output (name<tab>path/to/SKILL.md) - show --robot: raw SKILL.md content, no wrapper - remove path command (redundant with list --robot) - clean up unused --name option
1 parent 7156e43 commit f0b040c

5 files changed

Lines changed: 20 additions & 42 deletions

File tree

src/cli.ts

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import { parseArgs } from "node:util";
44
import { initCommand } from "./commands/init";
55
import { installCommand } from "./commands/install";
66
import { listCommand } from "./commands/list";
7-
import { runPathCommand } from "./commands/path";
87
import { searchCommand } from "./commands/search";
98
import { show } from "./commands/show";
109
import { uninstallCommand } from "./commands/uninstall";
@@ -13,10 +12,10 @@ import type { OutputFormat, Scope } from "./types";
1312

1413
type CliOptions = {
1514
json: boolean;
15+
robot: boolean;
1616
format?: OutputFormat | undefined;
1717
local: boolean;
1818
global: boolean;
19-
name?: string | undefined;
2019
source?: string | undefined;
2120
};
2221

@@ -25,19 +24,18 @@ const USAGE = `gitgud <command> [args] [options]
2524
Commands:
2625
list
2726
show <name>
28-
path <name>
2927
search <query>
3028
install <name>
3129
uninstall <name>
3230
init
3331
update
3432
3533
Options:
36-
--format Output format: text|json
34+
--format Output format: text|json|robot
3735
--json Output JSON
36+
--robot Robot-friendly output (TSV for list, raw content for show)
3837
--local Use local registry
3938
--global Use global registry
40-
--name Skill name (for path)
4139
--source Install source (for install)
4240
-h, --help Show help
4341
`;
@@ -53,9 +51,9 @@ function parseCli(argv: string[]) {
5351
options: {
5452
format: { type: "string" },
5553
json: { type: "boolean" },
54+
robot: { type: "boolean" },
5655
local: { type: "boolean" },
5756
global: { type: "boolean" },
58-
name: { type: "string" },
5957
source: { type: "string" },
6058
help: { type: "boolean", short: "h" },
6159
},
@@ -65,10 +63,10 @@ function parseCli(argv: string[]) {
6563
const help = values.help ?? false;
6664
const options: CliOptions = {
6765
json: values.json ?? false,
66+
robot: values.robot ?? false,
6867
format: (values.format as OutputFormat | undefined) ?? undefined,
6968
local: values.local ?? false,
7069
global: values.global ?? false,
71-
name: values.name as string | undefined,
7270
source: values.source as string | undefined,
7371
};
7472

@@ -81,7 +79,7 @@ function parseCli(argv: string[]) {
8179
async function dispatch(command: string, args: string[], options: CliOptions): Promise<void> {
8280
switch (command) {
8381
case "list": {
84-
const format: OutputFormat = options.format ?? (options.json ? "json" : "text");
82+
const format: OutputFormat = options.format ?? (options.robot ? "robot" : options.json ? "json" : "text");
8583
listCommand({
8684
format,
8785
local: options.local,
@@ -94,11 +92,6 @@ async function dispatch(command: string, args: string[], options: CliOptions): P
9492
await initCommand(args, { scope });
9593
return;
9694
}
97-
case "path": {
98-
const format: OutputFormat = options.format ?? (options.json ? "json" : "text");
99-
await runPathCommand(args, { name: options.name, format });
100-
return;
101-
}
10295
case "search": {
10396
const format: OutputFormat = options.format ?? (options.json ? "json" : "text");
10497
await searchCommand(args, { format });
@@ -116,15 +109,14 @@ async function dispatch(command: string, args: string[], options: CliOptions): P
116109
case "uninstall": {
117110
const format: OutputFormat = options.format ?? (options.json ? "json" : "text");
118111
uninstallCommand(args, {
119-
name: options.name,
120112
local: options.local,
121113
format,
122114
});
123115
return;
124116
}
125117
case "show": {
126118
const name = args[0];
127-
const format = options.json ? "json" : "text";
119+
const format: OutputFormat = options.format ?? (options.robot ? "robot" : options.json ? "json" : "text");
128120
await show({ name, format });
129121
return;
130122
}

src/commands/path.ts

Lines changed: 0 additions & 24 deletions
This file was deleted.

src/commands/uninstall.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,12 @@ import { formatError } from "../output";
66
import type { OutputFormat } from "../types";
77

88
export type UninstallOptions = {
9-
name?: string | undefined;
109
local: boolean;
1110
format: OutputFormat;
1211
};
1312

1413
export function uninstallCommand(args: string[], options: UninstallOptions): void {
15-
const name = options.name ?? args[0];
14+
const name = args[0];
1615
if (!name) {
1716
process.stderr.write(`${formatError("Missing skill name.", options.format)}\n`);
1817
process.exit(1);

src/output.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
1+
import path from "node:path";
12
import type { OutputFormat, Skill } from "./types";
23

34
export function formatSkillList(skills: Skill[], format: OutputFormat): string {
45
if (format === "json") {
56
return JSON.stringify(skills, null, 2);
67
}
78

9+
if (format === "robot") {
10+
// TSV: name<tab>path/to/SKILL.md
11+
return skills.map((skill) => `${skill.name}\t${path.join(skill.path, "SKILL.md")}`).join("\n");
12+
}
13+
814
return skills.map((skill) => `${skill.name} (${skill.scope}) - ${skill.description}`).join("\n");
915
}
1016

@@ -18,6 +24,11 @@ export function formatSkillDetail(
1824
return JSON.stringify({ ...skill, base: basePath, content }, null, 2);
1925
}
2026

27+
if (format === "robot") {
28+
// Raw SKILL.md content only
29+
return content;
30+
}
31+
2132
return `Skill: ${skill.name}\nBase: ${basePath}\n\n---\n${content}`;
2233
}
2334

src/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,6 @@ export type InstallSource =
2727
| { type: "github"; repo: string; subdir?: string; ref?: string }
2828
| { type: "registry"; package: string; version?: string };
2929

30-
export type OutputFormat = "text" | "json";
30+
export type OutputFormat = "text" | "json" | "robot";
3131

3232
export type Result<T, E = Error> = { ok: true; value: T } | { ok: false; error: E };

0 commit comments

Comments
 (0)