incur 0.3.13 → 0.3.14
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/Cli.d.ts.map +1 -1
- package/dist/Cli.js +27 -6
- package/dist/Cli.js.map +1 -1
- package/dist/Skill.d.ts +2 -1
- package/dist/Skill.d.ts.map +1 -1
- package/dist/Skill.js +29 -15
- package/dist/Skill.js.map +1 -1
- package/dist/Skillgen.js +1 -1
- package/dist/Skillgen.js.map +1 -1
- package/dist/SyncSkills.d.ts +10 -0
- package/dist/SyncSkills.d.ts.map +1 -1
- package/dist/SyncSkills.js +23 -4
- package/dist/SyncSkills.js.map +1 -1
- package/package.json +1 -1
- package/src/Cli.test.ts +32 -0
- package/src/Cli.ts +21 -5
- package/src/Skill.test.ts +64 -0
- package/src/Skill.ts +32 -16
- package/src/Skillgen.ts +1 -1
- package/src/SyncSkills.ts +38 -3
package/src/SyncSkills.ts
CHANGED
|
@@ -18,7 +18,7 @@ export async function sync(
|
|
|
18
18
|
|
|
19
19
|
const groups = new Map<string, string>()
|
|
20
20
|
if (description) groups.set(name, description)
|
|
21
|
-
const entries = collectEntries(commands, [], groups)
|
|
21
|
+
const entries = collectEntries(commands, [], groups, options.rootCommand)
|
|
22
22
|
const files = Skill.split(name, entries, depth, groups)
|
|
23
23
|
|
|
24
24
|
const tmpDir = await fs.mkdtemp(path.join(os.tmpdir(), `incur-skills-${name}-`))
|
|
@@ -70,7 +70,7 @@ export async function sync(
|
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
// Write skills hash + names for staleness detection
|
|
73
|
-
const hashEntries = collectEntries(commands, [])
|
|
73
|
+
const hashEntries = collectEntries(commands, [], undefined, options.rootCommand)
|
|
74
74
|
writeMeta(name, Skill.hash(hashEntries), [...currentNames])
|
|
75
75
|
|
|
76
76
|
return { skills, paths, agents }
|
|
@@ -92,6 +92,18 @@ export declare namespace sync {
|
|
|
92
92
|
global?: boolean | undefined
|
|
93
93
|
/** Glob patterns for directories containing SKILL.md files to include (e.g. `"skills/*"`, `"my-skill"`). Skill name is the parent directory name. */
|
|
94
94
|
include?: string[] | undefined
|
|
95
|
+
/** Root command definition (when the CLI itself has a `run` handler). */
|
|
96
|
+
rootCommand?:
|
|
97
|
+
| {
|
|
98
|
+
description?: string | undefined
|
|
99
|
+
args?: any
|
|
100
|
+
env?: any
|
|
101
|
+
hint?: string | undefined
|
|
102
|
+
options?: any
|
|
103
|
+
output?: any
|
|
104
|
+
examples?: any[] | undefined
|
|
105
|
+
}
|
|
106
|
+
| undefined
|
|
95
107
|
}
|
|
96
108
|
/** Result of a sync operation. */
|
|
97
109
|
type Result = {
|
|
@@ -118,8 +130,31 @@ function collectEntries(
|
|
|
118
130
|
commands: Map<string, any>,
|
|
119
131
|
prefix: string[],
|
|
120
132
|
groups: Map<string, string> = new Map(),
|
|
133
|
+
rootCommand?:
|
|
134
|
+
| {
|
|
135
|
+
description?: string | undefined
|
|
136
|
+
args?: any
|
|
137
|
+
env?: any
|
|
138
|
+
hint?: string | undefined
|
|
139
|
+
options?: any
|
|
140
|
+
output?: any
|
|
141
|
+
examples?: any[] | undefined
|
|
142
|
+
}
|
|
143
|
+
| undefined,
|
|
121
144
|
): Skill.CommandInfo[] {
|
|
122
145
|
const result: Skill.CommandInfo[] = []
|
|
146
|
+
if (rootCommand) {
|
|
147
|
+
const cmd: Skill.CommandInfo = {}
|
|
148
|
+
if (rootCommand.description) cmd.description = rootCommand.description
|
|
149
|
+
if (rootCommand.args) cmd.args = rootCommand.args
|
|
150
|
+
if (rootCommand.env) cmd.env = rootCommand.env
|
|
151
|
+
if (rootCommand.hint) cmd.hint = rootCommand.hint
|
|
152
|
+
if (rootCommand.options) cmd.options = rootCommand.options
|
|
153
|
+
if (rootCommand.output) cmd.output = rootCommand.output
|
|
154
|
+
const examples = formatExamples(rootCommand.examples)
|
|
155
|
+
if (examples) cmd.examples = examples
|
|
156
|
+
result.push(cmd)
|
|
157
|
+
}
|
|
123
158
|
for (const [name, entry] of commands) {
|
|
124
159
|
const entryPath = [...prefix, name]
|
|
125
160
|
if ('_group' in entry && entry._group) {
|
|
@@ -144,7 +179,7 @@ function collectEntries(
|
|
|
144
179
|
result.push(cmd)
|
|
145
180
|
}
|
|
146
181
|
}
|
|
147
|
-
return result.sort((a, b) => a.name.localeCompare(b.name))
|
|
182
|
+
return result.sort((a, b) => (a.name ?? '').localeCompare(b.name ?? ''))
|
|
148
183
|
}
|
|
149
184
|
|
|
150
185
|
/** Resolves the package root from the executing bin script (`process.argv[1]`). Walks up from the bin's directory looking for `package.json`. Falls back to `process.cwd()`. */
|