@crewhaus/slash-commands 0.3.1 → 0.3.2
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.d.ts +15 -5
- package/dist/index.js +11 -5
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -17,6 +17,15 @@ export type LoadCommandsOptions = {
|
|
|
17
17
|
* (`<cwd>/.crewhaus/commands`) commands override builtins by name.
|
|
18
18
|
*/
|
|
19
19
|
readonly builtinDirs?: ReadonlyArray<string>;
|
|
20
|
+
/**
|
|
21
|
+
* Pre-parsed builtin commands, seeded at the LOWEST precedence of all —
|
|
22
|
+
* below `builtinDirs`, user, and project. This is the disk-free path for
|
|
23
|
+
* shipped defaults (`@crewhaus/default-skills`' `DEFAULT_COMMANDS`): a
|
|
24
|
+
* `bun build --compile` binary has no on-disk `commands/` directory to
|
|
25
|
+
* point `builtinDirs` at, so without this the builtin slash commands would
|
|
26
|
+
* silently vanish from compiled binaries.
|
|
27
|
+
*/
|
|
28
|
+
readonly builtinCommands?: ReadonlyArray<SlashCommand>;
|
|
20
29
|
};
|
|
21
30
|
export type ExpandResult = {
|
|
22
31
|
readonly handled: boolean;
|
|
@@ -29,11 +38,12 @@ export declare class SlashCommandError extends CrewhausError {
|
|
|
29
38
|
constructor(message: string, cause?: unknown);
|
|
30
39
|
}
|
|
31
40
|
/**
|
|
32
|
-
* Read every `.md` file directly under each command root —
|
|
33
|
-
* first, then
|
|
34
|
-
* so later
|
|
35
|
-
* extension) becomes its key in the
|
|
36
|
-
* currently walked (v1 keeps the
|
|
41
|
+
* Read every `.md` file directly under each command root — pre-parsed
|
|
42
|
+
* `builtinCommands` first, then builtin dirs, then `~/.crewhaus/commands/`,
|
|
43
|
+
* then `<cwd>/.crewhaus/commands/` — so later sources override earlier ones
|
|
44
|
+
* by name. Each file's basename (sans extension) becomes its key in the
|
|
45
|
+
* returned map. Subdirectories are not currently walked (v1 keeps the
|
|
46
|
+
* namespace flat).
|
|
37
47
|
*/
|
|
38
48
|
export declare function loadCommands(opts?: LoadCommandsOptions): Promise<Map<string, SlashCommand>>;
|
|
39
49
|
type ParsedCommand = {
|
package/dist/index.js
CHANGED
|
@@ -49,11 +49,12 @@ export class SlashCommandError extends CrewhausError {
|
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
51
|
/**
|
|
52
|
-
* Read every `.md` file directly under each command root —
|
|
53
|
-
* first, then
|
|
54
|
-
* so later
|
|
55
|
-
* extension) becomes its key in the
|
|
56
|
-
* currently walked (v1 keeps the
|
|
52
|
+
* Read every `.md` file directly under each command root — pre-parsed
|
|
53
|
+
* `builtinCommands` first, then builtin dirs, then `~/.crewhaus/commands/`,
|
|
54
|
+
* then `<cwd>/.crewhaus/commands/` — so later sources override earlier ones
|
|
55
|
+
* by name. Each file's basename (sans extension) becomes its key in the
|
|
56
|
+
* returned map. Subdirectories are not currently walked (v1 keeps the
|
|
57
|
+
* namespace flat).
|
|
57
58
|
*/
|
|
58
59
|
export async function loadCommands(opts = {}) {
|
|
59
60
|
const cwd = opts.cwd ?? process.cwd();
|
|
@@ -64,6 +65,11 @@ export async function loadCommands(opts = {}) {
|
|
|
64
65
|
if (projectRoot !== userRoot)
|
|
65
66
|
roots.push(projectRoot);
|
|
66
67
|
const out = new Map();
|
|
68
|
+
// Lowest precedence: pre-parsed builtins (disk-free, so they survive in a
|
|
69
|
+
// compiled binary). On-disk roots below override them by name.
|
|
70
|
+
for (const command of opts.builtinCommands ?? []) {
|
|
71
|
+
out.set(command.name, command);
|
|
72
|
+
}
|
|
67
73
|
for (const root of roots) {
|
|
68
74
|
readCommandsUnder(root, out);
|
|
69
75
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crewhaus/slash-commands",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Markdown-templated slash commands with $ARGUMENTS substitution",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"test": "bun test src"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@crewhaus/errors": "0.3.
|
|
18
|
+
"@crewhaus/errors": "0.3.2",
|
|
19
19
|
"yaml": "^2.6.0"
|
|
20
20
|
},
|
|
21
21
|
"license": "Apache-2.0",
|