skilllib 1.11.1 → 1.11.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -9,6 +9,8 @@ import {
9
9
  globalCommand,
10
10
  harnessesCommand,
11
11
  importSkills,
12
+ isJsonMode,
13
+ json,
12
14
  link,
13
15
  list,
14
16
  newSkill,
@@ -28,7 +30,7 @@ import {
28
30
  unhide,
29
31
  update,
30
32
  usage
31
- } from "./chunk-LO4FMXDE.js";
33
+ } from "./chunk-3XDWEHI4.js";
32
34
 
33
35
  // src/index.ts
34
36
  import { readFileSync } from "fs";
@@ -89,34 +91,67 @@ function packageVersion() {
89
91
  return "unknown";
90
92
  }
91
93
  }
94
+ var FLAGS_OF = {
95
+ "": ["days"],
96
+ ui: [],
97
+ status: ["days"],
98
+ add: ["force", "allow-tracked"],
99
+ remove: ["force"],
100
+ sync: ["all", "force", "allow-tracked"],
101
+ update: ["all", "force", "allow-tracked"],
102
+ outdated: ["all"],
103
+ list: ["days"],
104
+ show: [],
105
+ import: ["force", "global"],
106
+ scan: [],
107
+ projects: [],
108
+ link: ["all", "allow-tracked"],
109
+ tidy: ["all", "global", "dry-run", "allow-git", "keep"],
110
+ harnesses: [],
111
+ folders: [],
112
+ unhide: [],
113
+ new: [],
114
+ global: ["allow-tracked", "to"],
115
+ restore: [],
116
+ doctor: ["fix", "days"],
117
+ apply: ["days"],
118
+ usage: ["days"],
119
+ "agent-skill": [],
120
+ version: [],
121
+ help: []
122
+ };
92
123
  async function main() {
93
- const [command, ...rest] = process.argv.slice(2);
124
+ const argv = process.argv.slice(2);
125
+ setJsonMode(argv.includes("--json"));
126
+ let at = 0;
127
+ while (argv[at]?.startsWith("--") && !["--version", "--help"].includes(argv[at])) at += ["--days", "--keep", "--to"].includes(argv[at]) ? 2 : 1;
128
+ const command = argv[at];
129
+ const rest = [...argv.slice(0, at), ...argv.slice(at + 1)];
94
130
  const args = parseArgs(rest);
95
- setJsonMode(args.json);
131
+ const takes = FLAGS_OF[command ?? ""];
132
+ const flagOf = (a) => a.slice(2).split("=")[0];
133
+ const wrong = takes ? rest.filter((a) => a.startsWith("--") && flagOf(a) !== "json" && !takes.includes(flagOf(a))) : [];
134
+ if (wrong.length) throw new Error(`skilllib${command ? ` ${command}` : ""} doesn't take ${wrong.join(", ")}`);
96
135
  if (!["--version", "-v", "version", "help", "--help", "-h"].includes(command ?? "")) refreshAgentSkill();
97
136
  switch (command) {
98
137
  case void 0:
99
- return process.stdin.isTTY && process.stdout.isTTY ? (await import("./tui-3LDZ5GOZ.js")).tui() : overview(args);
138
+ return process.stdin.isTTY && process.stdout.isTTY ? (await import("./tui-WSHQRBPF.js")).tui() : overview(args);
100
139
  case "ui":
101
140
  if (!process.stdin.isTTY || !process.stdout.isTTY) throw new Error("`skilllib ui` needs an interactive terminal. Agents and scripts: use `skilllib status --json`.");
102
- return (await import("./tui-3LDZ5GOZ.js")).tui();
141
+ return (await import("./tui-WSHQRBPF.js")).tui();
103
142
  case "status":
104
143
  return status(args);
105
144
  case "add":
106
145
  return add(args);
107
146
  case "remove":
108
- case "rm":
109
147
  return remove(args);
110
148
  case "sync":
111
- case "install":
112
149
  return sync(args);
113
150
  case "update":
114
- case "upgrade":
115
151
  return update(args);
116
152
  case "outdated":
117
153
  return outdated(args);
118
154
  case "list":
119
- case "ls":
120
155
  return list(args);
121
156
  case "show":
122
157
  return show(args);
@@ -129,18 +164,14 @@ async function main() {
129
164
  case "link":
130
165
  return link(args);
131
166
  case "tidy":
132
- case "dedup":
133
167
  return tidy(args);
134
168
  case "harnesses":
135
- case "agents":
136
169
  return harnessesCommand(args);
137
170
  case "folders":
138
- case "roots":
139
171
  return folders(args);
140
172
  case "unhide":
141
173
  return unhide(args);
142
174
  case "new":
143
- case "create":
144
175
  return newSkill(args);
145
176
  case "global":
146
177
  return globalCommand(args);
@@ -157,7 +188,7 @@ async function main() {
157
188
  case "--version":
158
189
  case "-v":
159
190
  case "version":
160
- console.log(packageVersion());
191
+ console.log(isJsonMode() ? JSON.stringify(packageVersion()) : packageVersion());
161
192
  return;
162
193
  case "help":
163
194
  case "--help":
@@ -165,6 +196,7 @@ async function main() {
165
196
  console.log(HELP);
166
197
  return;
167
198
  default:
199
+ if (isJsonMode()) throw new Error(`Unknown command: ${command} (skilllib help lists them)`);
168
200
  console.error(`Unknown command: ${command}
169
201
  `);
170
202
  console.log(HELP);
@@ -172,7 +204,9 @@ async function main() {
172
204
  }
173
205
  }
174
206
  main().catch((err) => {
175
- error(err instanceof Error ? err.message : String(err));
207
+ const message = err instanceof Error ? err.message : String(err);
208
+ if (isJsonMode()) json("error", { error: message });
209
+ error(message);
176
210
  if (process.env.DEBUG && err instanceof Error) console.error(err.stack);
177
211
  process.exit(1);
178
212
  });
package/dist/json.d.cts CHANGED
@@ -15,7 +15,8 @@ type SkillState = "ok" | "update available" | "edited locally" | "edited locally
15
15
  type Change = {
16
16
  name: string;
17
17
  /** reset: back to the version it had; its local edits were overwritten (and backed up, see `backedUp`). */
18
- action: "installed" | "updated" | "reset" | "removed" | "skipped";
18
+ /** relinked: the copy was as pinned; only the links skilllib.json records were put back. */
19
+ action: "installed" | "updated" | "reset" | "relinked" | "removed" | "skipped";
19
20
  reason?: string;
20
21
  from?: number;
21
22
  to?: number;
@@ -178,6 +179,10 @@ type DoctorJson = {
178
179
  message: string;
179
180
  };
180
181
  }[];
182
+ /** Any command with --json that fails: it exits 1, and this is the one line on stdout. */
183
+ type ErrorJson = {
184
+ error: string;
185
+ };
181
186
  /** `skilllib apply <issue-id> [choice] --json` */
182
187
  type ApplyJson = {
183
188
  id: string;
@@ -219,4 +224,4 @@ type AgentSkillJson = {
219
224
  removed?: string[];
220
225
  };
221
226
 
222
- export type { AgentSkillJson, AgentSkillState, AllChangesJson, ApplyJson, ChangeJson, ChangesJson, DoctorJson, GitState, GlobalMoveJson, HarnessId, ImportJson, ListJson, OutdatedJson, ProjectSource, ProjectsJson, ShowJson, SkillState, SourceKind, StatusGlobalGroup, StatusIssue, StatusJson, StatusSkillGroup, UsageJson };
227
+ export type { AgentSkillJson, AgentSkillState, AllChangesJson, ApplyJson, ChangeJson, ChangesJson, DoctorJson, ErrorJson, GitState, GlobalMoveJson, HarnessId, ImportJson, ListJson, OutdatedJson, ProjectSource, ProjectsJson, ShowJson, SkillState, SourceKind, StatusGlobalGroup, StatusIssue, StatusJson, StatusSkillGroup, UsageJson };
package/dist/json.d.ts CHANGED
@@ -15,7 +15,8 @@ type SkillState = "ok" | "update available" | "edited locally" | "edited locally
15
15
  type Change = {
16
16
  name: string;
17
17
  /** reset: back to the version it had; its local edits were overwritten (and backed up, see `backedUp`). */
18
- action: "installed" | "updated" | "reset" | "removed" | "skipped";
18
+ /** relinked: the copy was as pinned; only the links skilllib.json records were put back. */
19
+ action: "installed" | "updated" | "reset" | "relinked" | "removed" | "skipped";
19
20
  reason?: string;
20
21
  from?: number;
21
22
  to?: number;
@@ -178,6 +179,10 @@ type DoctorJson = {
178
179
  message: string;
179
180
  };
180
181
  }[];
182
+ /** Any command with --json that fails: it exits 1, and this is the one line on stdout. */
183
+ type ErrorJson = {
184
+ error: string;
185
+ };
181
186
  /** `skilllib apply <issue-id> [choice] --json` */
182
187
  type ApplyJson = {
183
188
  id: string;
@@ -219,4 +224,4 @@ type AgentSkillJson = {
219
224
  removed?: string[];
220
225
  };
221
226
 
222
- export type { AgentSkillJson, AgentSkillState, AllChangesJson, ApplyJson, ChangeJson, ChangesJson, DoctorJson, GitState, GlobalMoveJson, HarnessId, ImportJson, ListJson, OutdatedJson, ProjectSource, ProjectsJson, ShowJson, SkillState, SourceKind, StatusGlobalGroup, StatusIssue, StatusJson, StatusSkillGroup, UsageJson };
227
+ export type { AgentSkillJson, AgentSkillState, AllChangesJson, ApplyJson, ChangeJson, ChangesJson, DoctorJson, ErrorJson, GitState, GlobalMoveJson, HarnessId, ImportJson, ListJson, OutdatedJson, ProjectSource, ProjectsJson, ShowJson, SkillState, SourceKind, StatusGlobalGroup, StatusIssue, StatusJson, StatusSkillGroup, UsageJson };