@simonfestl/husky-cli 1.23.0 → 1.24.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/dist/commands/chat.js +18 -6
- package/package.json +1 -1
package/dist/commands/chat.js
CHANGED
|
@@ -100,6 +100,8 @@ chatCommand
|
|
|
100
100
|
.command("send <message>")
|
|
101
101
|
.description("Send a message as supervisor")
|
|
102
102
|
.option("--task-id <id>", "Link to a specific task")
|
|
103
|
+
.option("--dm <user>", "Send as direct message to user")
|
|
104
|
+
.option("--space <name>", "Target Google Chat space (e.g., spaces/ABC123)")
|
|
103
105
|
.action(async (message, options) => {
|
|
104
106
|
const config = getConfig();
|
|
105
107
|
if (!config.apiUrl) {
|
|
@@ -107,21 +109,31 @@ chatCommand
|
|
|
107
109
|
process.exit(1);
|
|
108
110
|
}
|
|
109
111
|
try {
|
|
110
|
-
|
|
112
|
+
let endpoint = `${config.apiUrl}/api/chat/supervisor`;
|
|
113
|
+
let payload = {
|
|
114
|
+
content: message,
|
|
115
|
+
...(options.taskId && { taskId: options.taskId }),
|
|
116
|
+
};
|
|
117
|
+
// If --space is provided, use Google Chat API instead
|
|
118
|
+
if (options.space) {
|
|
119
|
+
endpoint = `${config.apiUrl}/api/google-chat/send`;
|
|
120
|
+
payload = {
|
|
121
|
+
text: message,
|
|
122
|
+
spaceName: options.space,
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
const res = await fetch(endpoint, {
|
|
111
126
|
method: "POST",
|
|
112
127
|
headers: {
|
|
113
128
|
"Content-Type": "application/json",
|
|
114
129
|
...(config.apiKey ? { "x-api-key": config.apiKey } : {}),
|
|
115
130
|
},
|
|
116
|
-
body: JSON.stringify(
|
|
117
|
-
content: message,
|
|
118
|
-
taskId: options.taskId,
|
|
119
|
-
}),
|
|
131
|
+
body: JSON.stringify(payload),
|
|
120
132
|
});
|
|
121
133
|
if (!res.ok) {
|
|
122
134
|
throw new Error(`API error: ${res.status}`);
|
|
123
135
|
}
|
|
124
|
-
console.log("Message sent.");
|
|
136
|
+
console.log(options.space ? "✅ Message sent to Google Chat." : "Message sent.");
|
|
125
137
|
}
|
|
126
138
|
catch (error) {
|
|
127
139
|
console.error("Error sending message:", error);
|