@affectively/slash-commands 1.0.0 → 1.1.0
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/CHANGELOG.md +8 -0
- package/dist/index.js +33 -0
- package/dist/index.mjs +33 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
|
|
5
|
+
## [1.1.0] - 2026-02-17
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
|
|
9
|
+
- Native `/help` and `/?` command support in `executeSlashCommand`
|
|
10
|
+
- Categorized help output with parameter documentation
|
|
11
|
+
- Tier-aware help filtering (only shows commands available to user)
|
|
12
|
+
|
|
5
13
|
## [1.0.0] - 2026-01-25
|
|
6
14
|
|
|
7
15
|
### Added
|
package/dist/index.js
CHANGED
|
@@ -687,6 +687,39 @@ var SlashCommandRegistry = class {
|
|
|
687
687
|
var slashCommandRegistry = new SlashCommandRegistry();
|
|
688
688
|
async function executeSlashCommand(input, context, executor) {
|
|
689
689
|
const startTime = Date.now();
|
|
690
|
+
const trimmedInput = input.trim();
|
|
691
|
+
if (trimmedInput === "/help" || trimmedInput === "/?") {
|
|
692
|
+
const commands = slashCommandRegistry.getForTier(context.userTier);
|
|
693
|
+
const categories = slashCommandRegistry.getCountByCategory();
|
|
694
|
+
let helpText = "## Available Slash Commands\n\n";
|
|
695
|
+
const grouped = commands.reduce((acc, cmd) => {
|
|
696
|
+
if (!acc[cmd.category]) acc[cmd.category] = [];
|
|
697
|
+
acc[cmd.category].push(cmd);
|
|
698
|
+
return acc;
|
|
699
|
+
}, {});
|
|
700
|
+
for (const [category, cmds] of Object.entries(grouped)) {
|
|
701
|
+
helpText += `### ${category.toUpperCase()}
|
|
702
|
+
`;
|
|
703
|
+
for (const cmd of cmds) {
|
|
704
|
+
helpText += `- \`/${cmd.name}\`: ${cmd.description}
|
|
705
|
+
`;
|
|
706
|
+
if (cmd.parameters.length > 0) {
|
|
707
|
+
const params = cmd.parameters.map((p) => `${p.name}${p.required ? "*" : ""}`).join(", ");
|
|
708
|
+
helpText += ` *Params: ${params}*
|
|
709
|
+
`;
|
|
710
|
+
}
|
|
711
|
+
}
|
|
712
|
+
helpText += "\n";
|
|
713
|
+
}
|
|
714
|
+
helpText += '\n*Type `/command {args}` to execute a command. JSON input is supported: `/command {"key": "value"}`*';
|
|
715
|
+
return {
|
|
716
|
+
success: true,
|
|
717
|
+
data: helpText,
|
|
718
|
+
executionTimeMs: Date.now() - startTime,
|
|
719
|
+
command: "help",
|
|
720
|
+
args: {}
|
|
721
|
+
};
|
|
722
|
+
}
|
|
690
723
|
const parsed = parseSlashCommand(input, slashCommandRegistry.getMap());
|
|
691
724
|
if (!parsed.found) {
|
|
692
725
|
return {
|
package/dist/index.mjs
CHANGED
|
@@ -637,6 +637,39 @@ var SlashCommandRegistry = class {
|
|
|
637
637
|
var slashCommandRegistry = new SlashCommandRegistry();
|
|
638
638
|
async function executeSlashCommand(input, context, executor) {
|
|
639
639
|
const startTime = Date.now();
|
|
640
|
+
const trimmedInput = input.trim();
|
|
641
|
+
if (trimmedInput === "/help" || trimmedInput === "/?") {
|
|
642
|
+
const commands = slashCommandRegistry.getForTier(context.userTier);
|
|
643
|
+
const categories = slashCommandRegistry.getCountByCategory();
|
|
644
|
+
let helpText = "## Available Slash Commands\n\n";
|
|
645
|
+
const grouped = commands.reduce((acc, cmd) => {
|
|
646
|
+
if (!acc[cmd.category]) acc[cmd.category] = [];
|
|
647
|
+
acc[cmd.category].push(cmd);
|
|
648
|
+
return acc;
|
|
649
|
+
}, {});
|
|
650
|
+
for (const [category, cmds] of Object.entries(grouped)) {
|
|
651
|
+
helpText += `### ${category.toUpperCase()}
|
|
652
|
+
`;
|
|
653
|
+
for (const cmd of cmds) {
|
|
654
|
+
helpText += `- \`/${cmd.name}\`: ${cmd.description}
|
|
655
|
+
`;
|
|
656
|
+
if (cmd.parameters.length > 0) {
|
|
657
|
+
const params = cmd.parameters.map((p) => `${p.name}${p.required ? "*" : ""}`).join(", ");
|
|
658
|
+
helpText += ` *Params: ${params}*
|
|
659
|
+
`;
|
|
660
|
+
}
|
|
661
|
+
}
|
|
662
|
+
helpText += "\n";
|
|
663
|
+
}
|
|
664
|
+
helpText += '\n*Type `/command {args}` to execute a command. JSON input is supported: `/command {"key": "value"}`*';
|
|
665
|
+
return {
|
|
666
|
+
success: true,
|
|
667
|
+
data: helpText,
|
|
668
|
+
executionTimeMs: Date.now() - startTime,
|
|
669
|
+
command: "help",
|
|
670
|
+
args: {}
|
|
671
|
+
};
|
|
672
|
+
}
|
|
640
673
|
const parsed = parseSlashCommand(input, slashCommandRegistry.getMap());
|
|
641
674
|
if (!parsed.found) {
|
|
642
675
|
return {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@affectively/slash-commands",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Slash command parser with Zod schema integration. Auto-generates commands from Zod schemas with autocomplete, validation, and type coercion for CLI and chat interfaces.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|