incur 0.3.14 → 0.3.15

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.
Files changed (47) hide show
  1. package/dist/Cli.d.ts.map +1 -1
  2. package/dist/Cli.js +55 -4
  3. package/dist/Cli.js.map +1 -1
  4. package/dist/Fetch.d.ts.map +1 -1
  5. package/dist/Fetch.js +10 -9
  6. package/dist/Fetch.js.map +1 -1
  7. package/dist/Formatter.d.ts.map +1 -1
  8. package/dist/Formatter.js +6 -1
  9. package/dist/Formatter.js.map +1 -1
  10. package/dist/Help.d.ts +1 -1
  11. package/dist/Help.d.ts.map +1 -1
  12. package/dist/Help.js +4 -3
  13. package/dist/Help.js.map +1 -1
  14. package/dist/Openapi.js +20 -12
  15. package/dist/Openapi.js.map +1 -1
  16. package/dist/Parser.d.ts +2 -0
  17. package/dist/Parser.d.ts.map +1 -1
  18. package/dist/Parser.js +1 -1
  19. package/dist/Parser.js.map +1 -1
  20. package/dist/Skill.d.ts.map +1 -1
  21. package/dist/Skill.js +1 -1
  22. package/dist/Skill.js.map +1 -1
  23. package/dist/SyncSkills.d.ts +24 -0
  24. package/dist/SyncSkills.d.ts.map +1 -1
  25. package/dist/SyncSkills.js +46 -0
  26. package/dist/SyncSkills.js.map +1 -1
  27. package/dist/internal/command.d.ts +4 -2
  28. package/dist/internal/command.d.ts.map +1 -1
  29. package/dist/internal/command.js +4 -0
  30. package/dist/internal/command.js.map +1 -1
  31. package/package.json +1 -1
  32. package/src/Cli.test.ts +52 -3
  33. package/src/Cli.ts +62 -4
  34. package/src/Fetch.test.ts +21 -0
  35. package/src/Fetch.ts +8 -10
  36. package/src/Formatter.test.ts +15 -2
  37. package/src/Formatter.ts +5 -1
  38. package/src/Help.test.ts +39 -1
  39. package/src/Help.ts +6 -5
  40. package/src/Openapi.test.ts +7 -0
  41. package/src/Openapi.ts +19 -13
  42. package/src/Parser.ts +1 -1
  43. package/src/Skill.ts +2 -1
  44. package/src/SyncSkills.test.ts +63 -0
  45. package/src/SyncSkills.ts +78 -0
  46. package/src/e2e.test.ts +2 -2
  47. package/src/internal/command.ts +4 -0
package/src/SyncSkills.ts CHANGED
@@ -125,6 +125,84 @@ export declare namespace sync {
125
125
  }
126
126
  }
127
127
 
128
+ /** Lists skills derived from a CLI's command map with install status. */
129
+ export async function list(
130
+ name: string,
131
+ commands: Map<string, any>,
132
+ options: list.Options = {},
133
+ ): Promise<list.Skill[]> {
134
+ const { depth = 1, description } = options
135
+ const cwd = options.cwd ?? process.cwd()
136
+
137
+ const groups = new Map<string, string>()
138
+ if (description) groups.set(name, description)
139
+ const entries = collectEntries(commands, [], groups)
140
+ const files = Skill.split(name, entries, depth, groups)
141
+
142
+ const skills: list.Skill[] = []
143
+ const meta = readMeta(name)
144
+ const installed = new Set(meta?.skills)
145
+
146
+ for (const file of files) {
147
+ const nameMatch = file.content.match(/^name:\s*(.+)$/m)
148
+ const descMatch = file.content.match(/^description:\s*(.+)$/m)
149
+ const skillName = nameMatch?.[1] ?? (file.dir || name)
150
+ skills.push({
151
+ name: skillName,
152
+ description: descMatch?.[1],
153
+ installed: installed.has(skillName),
154
+ })
155
+ }
156
+
157
+ // Include additional SKILL.md files matched by glob patterns
158
+ if (options.include) {
159
+ for (const pattern of options.include) {
160
+ const globPattern = pattern === '_root' ? 'SKILL.md' : path.join(pattern, 'SKILL.md')
161
+ for await (const match of fs.glob(globPattern, { cwd })) {
162
+ try {
163
+ const content = await fs.readFile(path.resolve(cwd, match), 'utf8')
164
+ const nameMatch = content.match(/^name:\s*(.+)$/m)
165
+ const skillName =
166
+ pattern === '_root' ? (nameMatch?.[1] ?? name) : path.basename(path.dirname(match))
167
+ if (!skills.some((s) => s.name === skillName)) {
168
+ const descMatch = content.match(/^description:\s*(.+)$/m)
169
+ skills.push({
170
+ name: skillName,
171
+ description: descMatch?.[1],
172
+ installed: installed.has(skillName),
173
+ })
174
+ }
175
+ } catch {}
176
+ }
177
+ }
178
+ }
179
+
180
+ return skills.sort((a, b) => a.name.localeCompare(b.name))
181
+ }
182
+
183
+ export declare namespace list {
184
+ /** Options for listing skills. */
185
+ type Options = {
186
+ /** Working directory for resolving `include` globs. Defaults to `process.cwd()`. */
187
+ cwd?: string | undefined
188
+ /** Grouping depth for skill files. Defaults to `1`. */
189
+ depth?: number | undefined
190
+ /** CLI description, used as the top-level group description. */
191
+ description?: string | undefined
192
+ /** Glob patterns for directories containing SKILL.md files to include. */
193
+ include?: string[] | undefined
194
+ }
195
+ /** A skill entry with install status. */
196
+ type Skill = {
197
+ /** Description extracted from the skill frontmatter. */
198
+ description?: string | undefined
199
+ /** Whether this skill is currently installed. */
200
+ installed: boolean
201
+ /** Skill name. */
202
+ name: string
203
+ }
204
+ }
205
+
128
206
  /** Recursively collects leaf commands as `Skill.CommandInfo`. */
129
207
  function collectEntries(
130
208
  commands: Map<string, any>,
package/src/e2e.test.ts CHANGED
@@ -967,7 +967,7 @@ describe('help', () => {
967
967
  Integrations:
968
968
  completions Generate shell completion script
969
969
  mcp add Register as MCP server
970
- skills add Sync skill files to agents
970
+ skills Sync skill files to agents (add, list)
971
971
 
972
972
  Global Options:
973
973
  --filter-output <keys> Filter output by key paths (e.g. foo,bar.baz,a[0,3])
@@ -1742,7 +1742,7 @@ describe('root command with subcommands', () => {
1742
1742
  Integrations:
1743
1743
  completions Generate shell completion script
1744
1744
  mcp add Register as MCP server
1745
- skills add Sync skill files to agents
1745
+ skills Sync skill files to agents (add, list)
1746
1746
 
1747
1747
  Global Options:
1748
1748
  --filter-output <keys> Filter output by key paths (e.g. foo,bar.baz,a[0,3])
@@ -422,6 +422,10 @@ export const builtinCommands = [
422
422
  noGlobal: z.boolean().optional().describe('Install to project instead of globally'),
423
423
  }),
424
424
  }),
425
+ subcommand({
426
+ name: 'list',
427
+ description: 'List skills',
428
+ }),
425
429
  ],
426
430
  },
427
431
  ] satisfies {