Skip to content

An open-source, faster Devin alternative

TypeScript

fix: accept Slack CLI hook metadata

Mohamed Habibeeab22995a9a
diff --git a/cli/src/commands.ts b/cli/src/commands.ts
index 733d2ea2..70e5ca47 100644
--- a/cli/src/commands.ts
+++ b/cli/src/commands.ts
@@ -888,7 +888,9 @@ export async function runCommand(
if (command === "slack-hook") {
const action = args.shift();
- if (args.length) throw new Error(`Unexpected argument: ${args[0]}`);
+ // Slack CLI app hooks append metadata such as --source=<directory>.
+ // The hook already resolves its repository from the working directory,
+ // so these Slack-owned arguments are intentionally ignored.
const root = await requireSlackAgentRoot();
const mode =
process.env.OPENCOMPUTER_SLACK_MODE === "remote" ? "remote" : "local";
diff --git a/cli/src/slack.test.ts b/cli/src/slack.test.ts
index 39b2d289..28f8b98b 100644
--- a/cli/src/slack.test.ts
+++ b/cli/src/slack.test.ts
@@ -5,6 +5,7 @@ import { resolve } from "node:path";
import test from "node:test";
import type { ManagedAgentTemplate } from "./api.js";
+import { runCommand } from "./commands.js";
import {
addSlackChannel,
initializeAgentProject,
@@ -68,3 +69,24 @@ test("Slack channel state renders local and remote manifests", async () => {
await rm(parent, { recursive: true, force: true });
}
});
+
+test("Slack hooks accept source metadata from the Slack CLI", async () => {
+ const parent = await mkdtemp(resolve(tmpdir(), "opencomputer-slack-hook-"));
+ const root = resolve(parent, "research-agent");
+ const previousDirectory = process.cwd();
+ try {
+ await initializeAgentProject(template, root);
+ await addSlackChannel(root);
+ process.chdir(root);
+ await assert.doesNotReject(
+ runCommand(
+ "slack-hook",
+ ["manifest", `--source=${root}`],
+ { json: false },
+ ),
+ );
+ } finally {
+ process.chdir(previousDirectory);
+ await rm(parent, { recursive: true, force: true });
+ }
+});