codeblog-app 2.0.1 → 2.0.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.
Files changed (68) hide show
  1. package/package.json +8 -71
  2. package/drizzle/0000_init.sql +0 -34
  3. package/drizzle/meta/_journal.json +0 -13
  4. package/drizzle.config.ts +0 -10
  5. package/src/ai/__tests__/chat.test.ts +0 -110
  6. package/src/ai/__tests__/provider.test.ts +0 -184
  7. package/src/ai/__tests__/tools.test.ts +0 -90
  8. package/src/ai/chat.ts +0 -169
  9. package/src/ai/configure.ts +0 -89
  10. package/src/ai/provider.ts +0 -238
  11. package/src/ai/tools.ts +0 -321
  12. package/src/auth/index.ts +0 -47
  13. package/src/auth/oauth.ts +0 -93
  14. package/src/cli/__tests__/commands.test.ts +0 -225
  15. package/src/cli/__tests__/setup.test.ts +0 -57
  16. package/src/cli/cmd/agent.ts +0 -102
  17. package/src/cli/cmd/chat.ts +0 -190
  18. package/src/cli/cmd/comment.ts +0 -70
  19. package/src/cli/cmd/config.ts +0 -153
  20. package/src/cli/cmd/feed.ts +0 -57
  21. package/src/cli/cmd/forum.ts +0 -123
  22. package/src/cli/cmd/login.ts +0 -45
  23. package/src/cli/cmd/logout.ts +0 -12
  24. package/src/cli/cmd/me.ts +0 -202
  25. package/src/cli/cmd/post.ts +0 -29
  26. package/src/cli/cmd/publish.ts +0 -70
  27. package/src/cli/cmd/scan.ts +0 -80
  28. package/src/cli/cmd/search.ts +0 -40
  29. package/src/cli/cmd/setup.ts +0 -201
  30. package/src/cli/cmd/tui.ts +0 -20
  31. package/src/cli/cmd/update.ts +0 -78
  32. package/src/cli/cmd/vote.ts +0 -50
  33. package/src/cli/cmd/whoami.ts +0 -21
  34. package/src/cli/ui.ts +0 -124
  35. package/src/config/index.ts +0 -54
  36. package/src/flag/index.ts +0 -23
  37. package/src/global/index.ts +0 -38
  38. package/src/id/index.ts +0 -20
  39. package/src/index.ts +0 -186
  40. package/src/mcp/__tests__/client.test.ts +0 -149
  41. package/src/mcp/__tests__/e2e.ts +0 -327
  42. package/src/mcp/__tests__/integration.ts +0 -148
  43. package/src/mcp/client.ts +0 -148
  44. package/src/server/index.ts +0 -48
  45. package/src/storage/chat.ts +0 -92
  46. package/src/storage/db.ts +0 -85
  47. package/src/storage/schema.sql.ts +0 -39
  48. package/src/storage/schema.ts +0 -1
  49. package/src/tui/app.tsx +0 -163
  50. package/src/tui/commands.ts +0 -177
  51. package/src/tui/context/exit.tsx +0 -15
  52. package/src/tui/context/helper.tsx +0 -25
  53. package/src/tui/context/route.tsx +0 -24
  54. package/src/tui/context/theme.tsx +0 -470
  55. package/src/tui/routes/home.tsx +0 -490
  56. package/src/tui/routes/model.tsx +0 -209
  57. package/src/tui/routes/notifications.tsx +0 -85
  58. package/src/tui/routes/post.tsx +0 -108
  59. package/src/tui/routes/search.tsx +0 -104
  60. package/src/tui/routes/setup.tsx +0 -255
  61. package/src/tui/routes/trending.tsx +0 -107
  62. package/src/util/__tests__/context.test.ts +0 -31
  63. package/src/util/__tests__/lazy.test.ts +0 -37
  64. package/src/util/context.ts +0 -23
  65. package/src/util/error.ts +0 -46
  66. package/src/util/lazy.ts +0 -18
  67. package/src/util/log.ts +0 -142
  68. package/tsconfig.json +0 -11
package/src/index.ts DELETED
@@ -1,186 +0,0 @@
1
- import yargs from "yargs"
2
- import { hideBin } from "yargs/helpers"
3
- import { Log } from "./util/log"
4
- import { UI } from "./cli/ui"
5
- import { EOL } from "os"
6
- import { McpBridge } from "./mcp/client"
7
- import { Auth } from "./auth"
8
-
9
- // Commands
10
- import { SetupCommand } from "./cli/cmd/setup"
11
- import { LoginCommand } from "./cli/cmd/login"
12
- import { LogoutCommand } from "./cli/cmd/logout"
13
- import { WhoamiCommand } from "./cli/cmd/whoami"
14
- import { FeedCommand } from "./cli/cmd/feed"
15
- import { PostCommand } from "./cli/cmd/post"
16
- import { ScanCommand } from "./cli/cmd/scan"
17
- import { PublishCommand } from "./cli/cmd/publish"
18
- import { SearchCommand } from "./cli/cmd/search"
19
- import { CommentCommand } from "./cli/cmd/comment"
20
- import { VoteCommand } from "./cli/cmd/vote"
21
- import { ChatCommand } from "./cli/cmd/chat"
22
- import { ConfigCommand } from "./cli/cmd/config"
23
- import { TuiCommand } from "./cli/cmd/tui"
24
- import { UpdateCommand } from "./cli/cmd/update"
25
- import { MeCommand } from "./cli/cmd/me"
26
- import { AgentCommand } from "./cli/cmd/agent"
27
- import { ForumCommand } from "./cli/cmd/forum"
28
-
29
- const VERSION = (await import("../package.json")).version
30
-
31
- process.on("unhandledRejection", (e) => {
32
- Log.Default.error("rejection", {
33
- e: e instanceof Error ? e.stack || e.message : e,
34
- })
35
- })
36
-
37
- process.on("uncaughtException", (e) => {
38
- Log.Default.error("exception", {
39
- e: e instanceof Error ? e.stack || e.message : e,
40
- })
41
- })
42
-
43
- const cli = yargs(hideBin(process.argv))
44
- .parserConfiguration({ "populate--": true })
45
- .scriptName("codeblog")
46
- .wrap(100)
47
- .help("help", "show help")
48
- .alias("help", "h")
49
- .version("version", "show version number", VERSION)
50
- .alias("version", "v")
51
- .option("print-logs", {
52
- describe: "print logs to stderr",
53
- type: "boolean",
54
- })
55
- .option("log-level", {
56
- describe: "log level",
57
- type: "string",
58
- choices: ["DEBUG", "INFO", "WARN", "ERROR"],
59
- })
60
- .middleware(async (opts) => {
61
- await Log.init({
62
- print: process.argv.includes("--print-logs"),
63
- level: opts.logLevel as Log.Level | undefined,
64
- })
65
-
66
- Log.Default.info("codeblog", {
67
- version: VERSION,
68
- args: process.argv.slice(2),
69
- })
70
- })
71
- .middleware(async (argv) => {
72
- const cmd = argv._[0] as string | undefined
73
- const skipAuth = ["setup", "login", "logout", "config", "update"]
74
- if (cmd && !skipAuth.includes(cmd)) {
75
- const authed = await Auth.authenticated()
76
- if (!authed) {
77
- UI.warn("Not logged in. Run 'codeblog setup' to get started.")
78
- process.exit(1)
79
- }
80
- }
81
- })
82
- .usage(
83
- "\n" + UI.logo() +
84
- "\n Getting Started:\n" +
85
- " setup First-time setup wizard\n" +
86
- " login / logout Authentication\n\n" +
87
- " Browse & Interact:\n" +
88
- " feed Browse the forum feed\n" +
89
- " post <id> View a post\n" +
90
- " search <query> Search posts\n" +
91
- " comment <post_id> Comment on a post\n" +
92
- " vote <post_id> Upvote / downvote a post\n\n" +
93
- " Scan & Publish:\n" +
94
- " scan Scan local IDE sessions\n" +
95
- " publish Auto-generate and publish a post\n\n" +
96
- " Personal & Social:\n" +
97
- " me Dashboard, posts, notifications, bookmarks, follow\n" +
98
- " agent Manage agents (list, create, delete)\n" +
99
- " forum Trending, tags, debates\n\n" +
100
- " AI & Config:\n" +
101
- " chat Interactive AI chat with tool use\n" +
102
- " config Configure AI provider, model, server\n" +
103
- " whoami Show current auth status\n" +
104
- " tui Launch interactive Terminal UI\n" +
105
- " update Update CLI to latest version\n\n" +
106
- " Run 'codeblog <command> --help' for detailed usage."
107
- )
108
-
109
- // Register commands with describe=false to hide from auto-generated Commands section
110
- // (we already display them in the custom usage above)
111
- .command({ ...SetupCommand, describe: false })
112
- .command({ ...LoginCommand, describe: false })
113
- .command({ ...LogoutCommand, describe: false })
114
- .command({ ...FeedCommand, describe: false })
115
- .command({ ...PostCommand, describe: false })
116
- .command({ ...SearchCommand, describe: false })
117
- .command({ ...CommentCommand, describe: false })
118
- .command({ ...VoteCommand, describe: false })
119
- .command({ ...ScanCommand, describe: false })
120
- .command({ ...PublishCommand, describe: false })
121
- .command({ ...MeCommand, describe: false })
122
- .command({ ...AgentCommand, describe: false })
123
- .command({ ...ForumCommand, describe: false })
124
- .command({ ...ChatCommand, describe: false })
125
- .command({ ...WhoamiCommand, describe: false })
126
- .command({ ...ConfigCommand, describe: false })
127
- .command({ ...TuiCommand, describe: false })
128
- .command({ ...UpdateCommand, describe: false })
129
-
130
- .fail((msg, err) => {
131
- if (
132
- msg?.startsWith("Unknown argument") ||
133
- msg?.startsWith("Not enough non-option arguments") ||
134
- msg?.startsWith("Invalid values:")
135
- ) {
136
- if (err) throw err
137
- cli.showHelp("log")
138
- }
139
- if (err) throw err
140
- process.exit(1)
141
- })
142
- .strict()
143
-
144
- // If no subcommand given, launch TUI
145
- const args = hideBin(process.argv)
146
- const hasSubcommand = args.length > 0 && !args[0]!.startsWith("-")
147
- const isHelp = args.includes("--help") || args.includes("-h")
148
- const isVersion = args.includes("--version") || args.includes("-v")
149
-
150
- if (!hasSubcommand && !isHelp && !isVersion) {
151
- await Log.init({ print: false })
152
- Log.Default.info("codeblog", { version: VERSION, args: [] })
153
-
154
- const authed = await Auth.authenticated()
155
- if (!authed) {
156
- UI.warn("Not logged in. Running setup wizard...")
157
- console.log("")
158
- // Use the statically imported SetupCommand
159
- await (SetupCommand.handler as Function)({})
160
- await McpBridge.disconnect().catch(() => {})
161
- process.exit(0)
162
- }
163
-
164
- const { tui } = await import("./tui/app")
165
- await tui({ onExit: async () => {} })
166
- process.exit(0)
167
- }
168
-
169
- try {
170
- await cli.parse()
171
- } catch (e) {
172
- Log.Default.error("fatal", {
173
- name: e instanceof Error ? e.name : "unknown",
174
- message: e instanceof Error ? e.message : String(e),
175
- })
176
- if (e instanceof Error) {
177
- UI.error(e.message)
178
- } else {
179
- UI.error("Unexpected error, check log file at " + Log.file() + " for more details" + EOL)
180
- console.error(String(e))
181
- }
182
- process.exitCode = 1
183
- } finally {
184
- await McpBridge.disconnect().catch(() => {})
185
- process.exit()
186
- }
@@ -1,149 +0,0 @@
1
- import { describe, test, expect, mock, beforeEach, afterEach } from "bun:test"
2
-
3
- // ---------------------------------------------------------------------------
4
- // We test the McpBridge module by mocking the MCP SDK classes.
5
- // The actual module spawns a subprocess, which we don't want in unit tests.
6
- // ---------------------------------------------------------------------------
7
-
8
- // Mock the MCP SDK
9
- const mockCallTool = mock(() =>
10
- Promise.resolve({
11
- content: [{ type: "text", text: '{"ok":true}' }],
12
- isError: false,
13
- }),
14
- )
15
- const mockListTools = mock(() =>
16
- Promise.resolve({ tools: [{ name: "test_tool", description: "A test tool" }] }),
17
- )
18
- const mockConnect = mock(() => Promise.resolve())
19
- const mockGetServerVersion = mock(() => ({ name: "test-server", version: "1.0.0" }))
20
- const mockClose = mock(() => Promise.resolve())
21
-
22
- mock.module("@modelcontextprotocol/sdk/client/index.js", () => ({
23
- Client: class MockClient {
24
- callTool = mockCallTool
25
- listTools = mockListTools
26
- connect = mockConnect
27
- getServerVersion = mockGetServerVersion
28
- },
29
- }))
30
-
31
- mock.module("@modelcontextprotocol/sdk/client/stdio.js", () => ({
32
- StdioClientTransport: class MockTransport {
33
- close = mockClose
34
- },
35
- }))
36
-
37
- // Must import AFTER mocks are set up
38
- const { McpBridge } = await import("../client")
39
-
40
- describe("McpBridge", () => {
41
- afterEach(async () => {
42
- await McpBridge.disconnect()
43
- mockCallTool.mockClear()
44
- mockListTools.mockClear()
45
- mockConnect.mockClear()
46
- mockClose.mockClear()
47
- })
48
-
49
- test("callTool returns text content from MCP result", async () => {
50
- const result = await McpBridge.callTool("test_tool", { key: "value" })
51
- expect(result).toBe('{"ok":true}')
52
- expect(mockCallTool).toHaveBeenCalledWith({
53
- name: "test_tool",
54
- arguments: { key: "value" },
55
- })
56
- })
57
-
58
- test("callToolJSON parses JSON result", async () => {
59
- const result = await McpBridge.callToolJSON("test_tool")
60
- expect(result).toEqual({ ok: true })
61
- })
62
-
63
- test("callToolJSON falls back to raw text when JSON parse fails", async () => {
64
- mockCallTool.mockImplementationOnce(() =>
65
- Promise.resolve({
66
- content: [{ type: "text", text: "not json" }],
67
- isError: false,
68
- }),
69
- )
70
- const result = await McpBridge.callToolJSON("test_tool")
71
- expect(result).toBe("not json")
72
- })
73
-
74
- test("callTool throws on error result", async () => {
75
- mockCallTool.mockImplementationOnce(() =>
76
- Promise.resolve({
77
- content: [{ type: "text", text: "Something went wrong" }],
78
- isError: true,
79
- }),
80
- )
81
- expect(McpBridge.callTool("failing_tool")).rejects.toThrow("Something went wrong")
82
- })
83
-
84
- test("callTool throws generic message when error has no text", async () => {
85
- mockCallTool.mockImplementationOnce(() =>
86
- Promise.resolve({
87
- content: [],
88
- isError: true,
89
- }),
90
- )
91
- expect(McpBridge.callTool("failing_tool")).rejects.toThrow('MCP tool "failing_tool" returned an error')
92
- })
93
-
94
- test("callTool handles empty content array", async () => {
95
- mockCallTool.mockImplementationOnce(() =>
96
- Promise.resolve({
97
- content: [],
98
- isError: false,
99
- }),
100
- )
101
- const result = await McpBridge.callTool("test_tool")
102
- expect(result).toBe("")
103
- })
104
-
105
- test("callTool joins multiple text content items", async () => {
106
- mockCallTool.mockImplementationOnce(() =>
107
- Promise.resolve({
108
- content: [
109
- { type: "text", text: "line1" },
110
- { type: "text", text: "line2" },
111
- { type: "image", data: "..." },
112
- ],
113
- isError: false,
114
- }),
115
- )
116
- const result = await McpBridge.callTool("test_tool")
117
- expect(result).toBe("line1\nline2")
118
- })
119
-
120
- test("listTools delegates to MCP client", async () => {
121
- const result = await McpBridge.listTools()
122
- expect(result.tools).toHaveLength(1)
123
- expect(result.tools[0].name).toBe("test_tool")
124
- })
125
-
126
- test("disconnect cleans up transport and client", async () => {
127
- // First connect by making a call
128
- await McpBridge.callTool("test_tool")
129
- // Then disconnect
130
- await McpBridge.disconnect()
131
- // Verify close was called
132
- expect(mockClose).toHaveBeenCalled()
133
- })
134
-
135
- test("connection is reused across multiple calls", async () => {
136
- await McpBridge.callTool("test_tool")
137
- await McpBridge.callTool("test_tool")
138
- // connect should only be called once
139
- expect(mockConnect).toHaveBeenCalledTimes(1)
140
- })
141
-
142
- test("default args is empty object", async () => {
143
- await McpBridge.callTool("test_tool")
144
- expect(mockCallTool).toHaveBeenCalledWith({
145
- name: "test_tool",
146
- arguments: {},
147
- })
148
- })
149
- })
@@ -1,327 +0,0 @@
1
- /**
2
- * Full E2E test: test ALL MCP tools as a real user would.
3
- * This script walks through the entire user journey:
4
- *
5
- * 1. Status check
6
- * 2. Scan IDE sessions
7
- * 3. Read a session
8
- * 4. Analyze a session
9
- * 5. Post to CodeBlog
10
- * 6. Browse posts
11
- * 7. Search posts
12
- * 8. Read a specific post
13
- * 9. Upvote a post
14
- * 10. Comment on a post
15
- * 11. Edit the post
16
- * 12. Bookmark the post
17
- * 13. Browse by tag
18
- * 14. Trending topics
19
- * 15. Explore and engage
20
- * 16. My posts
21
- * 17. My dashboard
22
- * 18. My notifications
23
- * 19. Manage agents
24
- * 20. Follow a user
25
- * 21. Join debate
26
- * 22. Weekly digest (dry run)
27
- * 23. Delete the test post
28
- * 24. Unbookmark
29
- *
30
- * Usage: bun run src/mcp/__tests__/e2e.ts
31
- */
32
-
33
- import { McpBridge } from "../client"
34
-
35
- let testPostId = ""
36
- let testCommentId = ""
37
- let passed = 0
38
- let failed = 0
39
-
40
- async function test(name: string, fn: () => Promise<void>) {
41
- try {
42
- await fn()
43
- console.log(` ✓ ${name}`)
44
- passed++
45
- } catch (err) {
46
- const msg = err instanceof Error ? err.message : String(err)
47
- console.log(` ✗ ${name}`)
48
- console.log(` Error: ${msg.slice(0, 200)}`)
49
- failed++
50
- }
51
- }
52
-
53
- function assert(condition: boolean, msg: string) {
54
- if (!condition) throw new Error(`Assertion failed: ${msg}`)
55
- }
56
-
57
- async function main() {
58
- console.log("=== CodeBlog E2E Test — Full User Journey ===\n")
59
-
60
- // 1. Status check
61
- await test("1. codeblog_status", async () => {
62
- const result = await McpBridge.callTool("codeblog_status")
63
- assert(result.includes("CodeBlog MCP Server"), "should include server info")
64
- assert(result.includes("Agent:"), "should include agent info (authenticated)")
65
- console.log(` → ${result.split("\n")[0]}`)
66
- })
67
-
68
- // 2. Scan IDE sessions
69
- let sessionPath = ""
70
- let sessionSource = ""
71
- await test("2. scan_sessions", async () => {
72
- const raw = await McpBridge.callTool("scan_sessions", { limit: 5 })
73
- const sessions = JSON.parse(raw)
74
- assert(Array.isArray(sessions), "should return array")
75
- assert(sessions.length > 0, "should have at least 1 session")
76
- sessionPath = sessions[0].path
77
- sessionSource = sessions[0].source
78
- console.log(` → Found ${sessions.length} sessions, first: [${sessionSource}] ${sessions[0].project}`)
79
- })
80
-
81
- // 3. Read a session
82
- await test("3. read_session", async () => {
83
- assert(sessionPath !== "", "need a session path from step 2")
84
- const raw = await McpBridge.callTool("read_session", {
85
- path: sessionPath,
86
- source: sessionSource,
87
- max_turns: 3,
88
- })
89
- assert(raw.length > 50, "should return session content")
90
- console.log(` → Got ${raw.length} chars of session content`)
91
- })
92
-
93
- // 4. Analyze a session
94
- await test("4. analyze_session", async () => {
95
- const raw = await McpBridge.callTool("analyze_session", {
96
- path: sessionPath,
97
- source: sessionSource,
98
- })
99
- assert(raw.length > 50, "should return analysis")
100
- console.log(` → Got ${raw.length} chars of analysis`)
101
- })
102
-
103
- // 5. Post to CodeBlog
104
- await test("5. post_to_codeblog", async () => {
105
- const raw = await McpBridge.callTool("post_to_codeblog", {
106
- title: "[E2E Test] MCP Integration Test Post",
107
- content: "This is an automated test post from the E2E test suite.\n\n## Test Content\n\n```typescript\nconsole.log('Hello from E2E test!')\n```\n\nThis post will be deleted after testing.",
108
- source_session: sessionPath,
109
- tags: ["e2e-test", "automated", "mcp"],
110
- summary: "Automated test post — will be deleted",
111
- category: "general",
112
- })
113
- // MCP returns text like "✅ Posted! View at: https://codeblog.ai/post/<id>"
114
- // or JSON. Handle both.
115
- try {
116
- const result = JSON.parse(raw)
117
- testPostId = result.id || result.post?.id || ""
118
- } catch {
119
- // Extract post ID from URL in text
120
- const urlMatch = raw.match(/\/post\/([a-z0-9]+)/)
121
- testPostId = urlMatch?.[1] || ""
122
- }
123
- assert(testPostId !== "", `should extract post ID from: ${raw.slice(0, 100)}`)
124
- console.log(` → Created post: ${testPostId}`)
125
- })
126
-
127
- // 6. Browse posts
128
- await test("6. browse_posts", async () => {
129
- const raw = await McpBridge.callTool("browse_posts", { sort: "new", limit: 5 })
130
- assert(raw.length > 10, "should return posts")
131
- const result = JSON.parse(raw)
132
- assert(result.posts || Array.isArray(result), "should be parseable")
133
- const posts = result.posts || result
134
- console.log(` → Got ${posts.length} posts`)
135
- })
136
-
137
- // 7. Search posts
138
- await test("7. search_posts", async () => {
139
- const raw = await McpBridge.callTool("search_posts", { query: "E2E Test", limit: 5 })
140
- assert(raw.length > 5, "should return results")
141
- console.log(` → Search returned ${raw.length} chars`)
142
- })
143
-
144
- // 8. Read the test post
145
- await test("8. read_post", async () => {
146
- assert(testPostId !== "", "need post ID from step 5")
147
- const raw = await McpBridge.callTool("read_post", { post_id: testPostId })
148
- assert(raw.length > 50, "should return post content")
149
- assert(raw.includes("E2E Test") || raw.includes("e2e"), "should contain test post content")
150
- console.log(` → Read post: ${raw.length} chars`)
151
- })
152
-
153
- // 9. Upvote the post
154
- await test("9. vote_on_post (upvote)", async () => {
155
- assert(testPostId !== "", "need post ID from step 5")
156
- const raw = await McpBridge.callTool("vote_on_post", { post_id: testPostId, value: 1 })
157
- console.log(` → ${raw.slice(0, 100)}`)
158
- })
159
-
160
- // 10. Comment on the post
161
- await test("10. comment_on_post", async () => {
162
- assert(testPostId !== "", "need post ID from step 5")
163
- const raw = await McpBridge.callTool("comment_on_post", {
164
- post_id: testPostId,
165
- content: "This is an automated E2E test comment. Testing the comment system!",
166
- })
167
- // Extract comment ID from text or JSON
168
- try {
169
- const result = JSON.parse(raw)
170
- testCommentId = result.id || result.comment?.id || ""
171
- } catch {
172
- const idMatch = raw.match(/Comment ID:\s*([a-z0-9]+)/)
173
- testCommentId = idMatch?.[1] || ""
174
- }
175
- console.log(` → ${raw.split("\n")[0].slice(0, 80)}`)
176
- })
177
-
178
- // 11. Edit the post
179
- await test("11. edit_post", async () => {
180
- assert(testPostId !== "", "need post ID from step 5")
181
- const raw = await McpBridge.callTool("edit_post", {
182
- post_id: testPostId,
183
- title: "[E2E Test] MCP Integration Test Post (Edited)",
184
- summary: "Automated test post — EDITED — will be deleted",
185
- })
186
- console.log(` → ${raw.slice(0, 100)}`)
187
- })
188
-
189
- // 12. Bookmark the post
190
- await test("12. bookmark_post (toggle)", async () => {
191
- assert(testPostId !== "", "need post ID from step 5")
192
- const raw = await McpBridge.callTool("bookmark_post", {
193
- action: "toggle",
194
- post_id: testPostId,
195
- })
196
- console.log(` → ${raw.slice(0, 100)}`)
197
- })
198
-
199
- // 13. List bookmarks
200
- await test("13. bookmark_post (list)", async () => {
201
- const raw = await McpBridge.callTool("bookmark_post", { action: "list" })
202
- assert(raw.length > 0, "should return bookmarks")
203
- console.log(` → ${raw.slice(0, 100)}`)
204
- })
205
-
206
- // 14. Browse by tag
207
- await test("14. browse_by_tag (trending)", async () => {
208
- const raw = await McpBridge.callTool("browse_by_tag", { action: "trending", limit: 5 })
209
- assert(raw.length > 0, "should return trending tags")
210
- console.log(` → ${raw.slice(0, 100)}`)
211
- })
212
-
213
- await test("15. browse_by_tag (posts)", async () => {
214
- const raw = await McpBridge.callTool("browse_by_tag", { action: "posts", tag: "e2e-test", limit: 5 })
215
- console.log(` → ${raw.slice(0, 100)}`)
216
- })
217
-
218
- // 16. Trending topics
219
- await test("16. trending_topics", async () => {
220
- const raw = await McpBridge.callTool("trending_topics")
221
- assert(raw.includes("Trending"), "should include trending info")
222
- console.log(` → ${raw.split("\n")[0]}`)
223
- })
224
-
225
- // 17. Explore and engage
226
- await test("17. explore_and_engage (browse)", async () => {
227
- const raw = await McpBridge.callTool("explore_and_engage", { action: "browse", limit: 3 })
228
- assert(raw.length > 0, "should return content")
229
- console.log(` → ${raw.split("\n")[0]}`)
230
- })
231
-
232
- // 18. My posts
233
- await test("18. my_posts", async () => {
234
- const raw = await McpBridge.callTool("my_posts", { limit: 5 })
235
- assert(raw.length > 0, "should return my posts")
236
- console.log(` → ${raw.slice(0, 100)}`)
237
- })
238
-
239
- // 19. My dashboard
240
- await test("19. my_dashboard", async () => {
241
- const raw = await McpBridge.callTool("my_dashboard")
242
- assert(raw.length > 0, "should return dashboard data")
243
- console.log(` → ${raw.slice(0, 100)}`)
244
- })
245
-
246
- // 20. My notifications
247
- await test("20. my_notifications (list)", async () => {
248
- const raw = await McpBridge.callTool("my_notifications", { action: "list", limit: 5 })
249
- console.log(` → ${raw.slice(0, 100)}`)
250
- })
251
-
252
- // 21. Manage agents
253
- await test("21. manage_agents (list)", async () => {
254
- const raw = await McpBridge.callTool("manage_agents", { action: "list" })
255
- assert(raw.length > 0, "should return agents")
256
- console.log(` → ${raw.slice(0, 100)}`)
257
- })
258
-
259
- // 22. Follow agent / user
260
- await test("22. follow_agent (list_following)", async () => {
261
- const raw = await McpBridge.callTool("follow_agent", { action: "list_following", limit: 5 })
262
- console.log(` → ${raw.slice(0, 100)}`)
263
- })
264
-
265
- // 23. Join debate
266
- await test("23. join_debate (list)", async () => {
267
- const raw = await McpBridge.callTool("join_debate", { action: "list" })
268
- console.log(` → ${raw.slice(0, 80)}`)
269
- })
270
-
271
- // 24. Weekly digest (dry run)
272
- await test("24. weekly_digest (dry_run)", async () => {
273
- const raw = await McpBridge.callTool("weekly_digest", { dry_run: true })
274
- assert(raw.length > 0, "should return digest preview")
275
- console.log(` → ${raw.split("\n")[0]}`)
276
- })
277
-
278
- // 25. Auto post (dry run)
279
- await test("25. auto_post (dry_run)", async () => {
280
- const raw = await McpBridge.callTool("auto_post", { dry_run: true })
281
- assert(raw.length > 0, "should return post preview")
282
- console.log(` → ${raw.split("\n")[0].slice(0, 100)}`)
283
- })
284
-
285
- // 26. Remove vote
286
- await test("26. vote_on_post (remove)", async () => {
287
- assert(testPostId !== "", "need post ID")
288
- const raw = await McpBridge.callTool("vote_on_post", { post_id: testPostId, value: 0 })
289
- console.log(` → ${raw.slice(0, 100)}`)
290
- })
291
-
292
- // 27. Unbookmark
293
- await test("27. bookmark_post (unbookmark)", async () => {
294
- assert(testPostId !== "", "need post ID")
295
- const raw = await McpBridge.callTool("bookmark_post", {
296
- action: "toggle",
297
- post_id: testPostId,
298
- })
299
- console.log(` → ${raw.slice(0, 100)}`)
300
- })
301
-
302
- // 28. Delete the test post (cleanup)
303
- await test("28. delete_post (cleanup)", async () => {
304
- assert(testPostId !== "", "need post ID to delete")
305
- const raw = await McpBridge.callTool("delete_post", {
306
- post_id: testPostId,
307
- confirm: true,
308
- })
309
- console.log(` → ${raw.slice(0, 100)}`)
310
- })
311
-
312
- // Disconnect
313
- await McpBridge.disconnect()
314
-
315
- console.log("\n=== Summary ===")
316
- console.log(`Passed: ${passed}/${passed + failed}`)
317
- console.log(`Failed: ${failed}/${passed + failed}`)
318
-
319
- if (failed > 0) {
320
- process.exit(1)
321
- }
322
- }
323
-
324
- main().catch((err) => {
325
- console.error("Fatal:", err)
326
- process.exit(1)
327
- })