Skip to content

Commit 2b6310b

Browse files
authored
generate title in /issueify (#263)
1 parent 299082c commit 2b6310b

File tree

10 files changed

+459
-425
lines changed

10 files changed

+459
-425
lines changed

package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@
2121
"@babel/plugin-transform-modules-commonjs": "^7.27.1",
2222
"@effect/build-utils": "^0.8.9",
2323
"@effect/eslint-plugin": "^0.3.2",
24-
"@effect/language-service": "^0.35.2",
25-
"@eslint/js": "^9.33.0",
24+
"@effect/language-service": "^0.36.0",
25+
"@eslint/js": "^9.34.0",
2626
"@types/node": "^24.3.0",
2727
"@vitest/coverage-v8": "^3.2.4",
2828
"@vitest/expect": "^3.2.4",
2929
"ast-types": "^0.14.2",
3030
"babel-plugin-annotate-pure-calls": "^0.5.0",
31-
"eslint": "^9.33.0",
31+
"eslint": "^9.34.0",
3232
"eslint-import-resolver-typescript": "^4.4.4",
3333
"eslint-plugin-import-x": "^4.16.1",
3434
"eslint-plugin-local-rules": "^3.0.2",
@@ -38,10 +38,10 @@
3838
"prettier": "^3.6.2",
3939
"rimraf": "^6.0.1",
4040
"tsup": "^8.5.0",
41-
"tsx": "^4.20.4",
41+
"tsx": "^4.20.5",
4242
"typescript": "^5.9.2",
43-
"typescript-eslint": "^8.40.0",
44-
"vite": "^7.1.3",
43+
"typescript-eslint": "^8.41.0",
44+
"vite": "^7.1.4",
4545
"vitest": "^3.2.4"
4646
},
4747
"pnpm": {

packages/discord-bot/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@
1414
"@effect/ai-openai": "^0.29.0",
1515
"@effect/cluster": "^0.48.2",
1616
"@effect/experimental": "^0.54.6",
17-
"@effect/language-service": "^0.35.2",
17+
"@effect/language-service": "^0.36.0",
1818
"@effect/opentelemetry": "^0.56.4",
1919
"@effect/platform": "^0.90.6",
20-
"@effect/platform-node": "^0.96.0",
20+
"@effect/platform-node": "^0.96.1",
2121
"@octokit/plugin-rest-endpoint-methods": "^16.0.0",
2222
"@octokit/types": "^14.1.0",
2323
"@types/node": "^24.3.0",
2424
"dfx": "^0.124.1",
25-
"effect": "^3.17.8",
25+
"effect": "^3.17.10",
2626
"fuzzysort": "^3.1.0",
2727
"html-entities": "^2.6.0",
2828
"octokit": "^5.0.3"

packages/discord-bot/src/Github.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { Octokit } from "octokit"
1414
import { nestedConfigProvider } from "./utils/Config.ts"
1515

1616
export class GithubError extends Data.TaggedError("GithubError")<{
17-
readonly reason: unknown
17+
readonly cause: unknown
1818
}> {}
1919

2020
export class Github extends Effect.Service<Github>()("app/Github", {
@@ -28,7 +28,7 @@ export class Github extends Effect.Service<Github>()("app/Github", {
2828
Effect.withSpan(
2929
Effect.tryPromise({
3030
try: () => f(rest as any),
31-
catch: (reason) => new GithubError({ reason })
31+
catch: (cause) => new GithubError({ cause })
3232
}),
3333
"Github.request"
3434
)
@@ -40,7 +40,7 @@ export class Github extends Effect.Service<Github>()("app/Github", {
4040
Effect.map(
4141
Effect.tryPromise({
4242
try: () => f(rest as any)(...args),
43-
catch: (reason) => new GithubError({ reason })
43+
catch: (cause) => new GithubError({ cause })
4444
}),
4545
(_) => _.data
4646
)
@@ -52,7 +52,7 @@ export class Github extends Effect.Service<Github>()("app/Github", {
5252
Effect.map(
5353
Effect.tryPromise({
5454
try: () => f(rest as any, page),
55-
catch: (reason) => new GithubError({ reason })
55+
catch: (cause) => new GithubError({ cause })
5656
}),
5757
(_) => [
5858
Chunk.unsafeFromArray(_.data),

packages/discord-bot/src/Issueifier.ts

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import { DiscordGatewayLayer } from "@chat/discord/DiscordGateway"
22
import { DiscordApplication } from "@chat/discord/DiscordRest"
33
import { Messages } from "@chat/discord/Messages"
4-
import { AiInput } from "@effect/ai"
4+
import { AiInput, AiLanguageModel } from "@effect/ai"
5+
import { OpenAiLanguageModel } from "@effect/ai-openai"
56
import { Discord, DiscordREST, Ix } from "dfx"
67
import { InteractionsRegistry } from "dfx/gateway"
78
import {
@@ -13,9 +14,10 @@ import {
1314
FiberMap,
1415
Layer,
1516
pipe,
17+
Schema,
1618
Stream
1719
} from "effect"
18-
import { AiHelpers } from "./Ai.ts"
20+
import { OpenAiLive } from "./Ai.ts"
1921
import { ChannelsCache } from "./ChannelsCache.ts"
2022
import { Github } from "./Github.ts"
2123

@@ -32,11 +34,11 @@ type GithubRepo = (typeof githubRepos)[number]
3234
const make = Effect.gen(function*() {
3335
const rest = yield* DiscordREST
3436
const channels = yield* ChannelsCache
35-
const ai = yield* AiHelpers
3637
const messages = yield* Messages
3738
const registry = yield* InteractionsRegistry
3839
const github = yield* Github
3940
const fiberMap = yield* FiberMap.make<Discord.Snowflake>()
41+
const summaryModel = yield* OpenAiLanguageModel.model("gpt-4.1-mini")
4042

4143
const createGithubIssue = github.wrap((_) => _.issues.create)
4244

@@ -59,13 +61,24 @@ const make = Effect.gen(function*() {
5961
),
6062
AiInput.make
6163
)
62-
const summary = yield* ai.generateSummary(channelName, input)
64+
const summary = yield* AiLanguageModel.generateObject({
65+
system:
66+
`You are a helpful assistant that summarizes Discord threads into concise titles and summaries for Github issues.
67+
68+
In the summary, include some key takeaways or important points discussed in the thread.
69+
70+
The title of this conversation is: "${channelName}"`,
71+
prompt: input,
72+
schema: ThreadSummary
73+
}).pipe(
74+
Effect.provide(summaryModel)
75+
)
6376
return yield* createGithubIssue({
6477
owner: repo.owner,
6578
repo: repo.repo,
66-
title: `From Discord: ${channelName}`,
79+
title: `From Discord: ${summary.value.title}`,
6780
body: `# Summary
68-
${summary}
81+
${summary.value.summary}
6982
7083
# Discord thread
7184
@@ -175,9 +188,21 @@ https://discord.com/channels/${channel.guild_id}/${channel.id}
175188
})
176189

177190
export const IssueifierLive = Layer.scopedDiscard(make).pipe(
178-
Layer.provide(AiHelpers.Default),
191+
Layer.provide(OpenAiLive),
179192
Layer.provide(ChannelsCache.Default),
180193
Layer.provide(DiscordGatewayLayer),
181194
Layer.provide(Messages.Default),
182195
Layer.provide(Github.Default)
183196
)
197+
198+
class ThreadSummary extends Schema.Class<ThreadSummary>("ThreadSummary")({
199+
title: Schema.String.annotations({
200+
description: "A short title summarizing the messages"
201+
}),
202+
summary: Schema.String.annotations({
203+
description:
204+
"A summary of the messages for a Github issue bug report or feature request"
205+
})
206+
}, {
207+
description: "A summary of a Discord thread"
208+
}) {}

packages/discord/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
},
1111
"dependencies": {
1212
"@effect/platform": "^0.90.6",
13-
"@effect/platform-node": "^0.96.0",
13+
"@effect/platform-node": "^0.96.1",
1414
"dfx": "^0.124.1",
15-
"effect": "^3.17.8"
15+
"effect": "^3.17.10"
1616
}
1717
}

packages/domain/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@
1414
"@effect/rpc": "^0.69.1",
1515
"@effect/sql": "^0.44.2",
1616
"@effect/workflow": "^0.9.2",
17-
"effect": "^3.17.8"
17+
"effect": "^3.17.10"
1818
}
1919
}

packages/runner/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@
1414
"@effect/ai-openai": "^0.29.0",
1515
"@effect/cluster": "^0.48.2",
1616
"@effect/platform": "^0.90.6",
17-
"@effect/platform-node": "^0.96.0",
17+
"@effect/platform-node": "^0.96.1",
1818
"@effect/rpc": "^0.69.1",
1919
"@effect/sql": "^0.44.2",
2020
"@effect/sql-pg": "^0.45.1",
2121
"dfx": "^0.124.1",
22-
"effect": "^3.17.8"
22+
"effect": "^3.17.10"
2323
},
2424
"dependencies": {
2525
"@effect/workflow": "^0.9.2"

packages/shard-manager/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
"devDependencies": {
1616
"@chat/shared": "workspace:*",
1717
"@effect/cluster": "^0.48.2",
18-
"@effect/platform-node": "^0.96.0",
18+
"@effect/platform-node": "^0.96.1",
1919
"@effect/sql": "^0.44.2",
2020
"@effect/sql-pg": "^0.45.1",
21-
"effect": "^3.17.8"
21+
"effect": "^3.17.10"
2222
}
2323
}

packages/shared/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
},
1111
"dependencies": {
1212
"@effect/opentelemetry": "^0.56.4",
13-
"@effect/platform-node": "^0.96.0",
13+
"@effect/platform-node": "^0.96.1",
1414
"@effect/sql": "^0.44.2",
1515
"@effect/sql-pg": "^0.45.1",
16-
"effect": "^3.17.8"
16+
"effect": "^3.17.10"
1717
}
1818
}

0 commit comments

Comments
 (0)