codeblog-app 2.2.4 → 2.3.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/package.json +8 -71
- package/drizzle/0000_init.sql +0 -34
- package/drizzle/meta/_journal.json +0 -13
- package/drizzle.config.ts +0 -10
- package/src/ai/__tests__/chat.test.ts +0 -179
- package/src/ai/__tests__/provider.test.ts +0 -198
- package/src/ai/__tests__/tools.test.ts +0 -93
- package/src/ai/chat.ts +0 -224
- package/src/ai/configure.ts +0 -134
- package/src/ai/provider.ts +0 -302
- package/src/ai/tools.ts +0 -114
- package/src/auth/index.ts +0 -47
- package/src/auth/oauth.ts +0 -94
- package/src/cli/__tests__/commands.test.ts +0 -225
- package/src/cli/cmd/agent.ts +0 -97
- package/src/cli/cmd/chat.ts +0 -190
- package/src/cli/cmd/comment.ts +0 -67
- package/src/cli/cmd/config.ts +0 -153
- package/src/cli/cmd/feed.ts +0 -53
- package/src/cli/cmd/forum.ts +0 -106
- package/src/cli/cmd/login.ts +0 -45
- package/src/cli/cmd/logout.ts +0 -12
- package/src/cli/cmd/me.ts +0 -188
- package/src/cli/cmd/post.ts +0 -25
- package/src/cli/cmd/publish.ts +0 -64
- package/src/cli/cmd/scan.ts +0 -78
- package/src/cli/cmd/search.ts +0 -35
- package/src/cli/cmd/setup.ts +0 -352
- package/src/cli/cmd/tui.ts +0 -20
- package/src/cli/cmd/uninstall.ts +0 -281
- package/src/cli/cmd/update.ts +0 -123
- package/src/cli/cmd/vote.ts +0 -50
- package/src/cli/cmd/whoami.ts +0 -18
- package/src/cli/mcp-print.ts +0 -6
- package/src/cli/ui.ts +0 -250
- package/src/config/index.ts +0 -54
- package/src/flag/index.ts +0 -23
- package/src/global/index.ts +0 -38
- package/src/id/index.ts +0 -20
- package/src/index.ts +0 -200
- package/src/mcp/__tests__/client.test.ts +0 -149
- package/src/mcp/__tests__/e2e.ts +0 -327
- package/src/mcp/__tests__/integration.ts +0 -148
- package/src/mcp/client.ts +0 -148
- package/src/server/index.ts +0 -48
- package/src/storage/chat.ts +0 -71
- package/src/storage/db.ts +0 -85
- package/src/storage/schema.sql.ts +0 -39
- package/src/storage/schema.ts +0 -1
- package/src/tui/app.tsx +0 -165
- package/src/tui/commands.ts +0 -186
- package/src/tui/context/exit.tsx +0 -15
- package/src/tui/context/helper.tsx +0 -25
- package/src/tui/context/route.tsx +0 -24
- package/src/tui/context/theme.tsx +0 -470
- package/src/tui/routes/home.tsx +0 -660
- package/src/tui/routes/model.tsx +0 -210
- package/src/tui/routes/notifications.tsx +0 -87
- package/src/tui/routes/post.tsx +0 -102
- package/src/tui/routes/search.tsx +0 -105
- package/src/tui/routes/setup.tsx +0 -255
- package/src/tui/routes/trending.tsx +0 -107
- package/src/util/__tests__/context.test.ts +0 -31
- package/src/util/__tests__/lazy.test.ts +0 -37
- package/src/util/context.ts +0 -23
- package/src/util/error.ts +0 -46
- package/src/util/lazy.ts +0 -18
- package/src/util/log.ts +0 -142
- package/tsconfig.json +0 -11
package/src/cli/cmd/me.ts
DELETED
|
@@ -1,188 +0,0 @@
|
|
|
1
|
-
import type { CommandModule } from "yargs"
|
|
2
|
-
import { McpBridge } from "../../mcp/client"
|
|
3
|
-
import { mcpPrint } from "../mcp-print"
|
|
4
|
-
import { UI } from "../ui"
|
|
5
|
-
|
|
6
|
-
export const MeCommand: CommandModule = {
|
|
7
|
-
command: "me",
|
|
8
|
-
describe: "Personal center: dashboard, posts, notifications, bookmarks",
|
|
9
|
-
builder: (yargs) =>
|
|
10
|
-
yargs
|
|
11
|
-
.command({
|
|
12
|
-
command: "dashboard",
|
|
13
|
-
aliases: ["dash"],
|
|
14
|
-
describe: "Your stats, top posts, recent activity",
|
|
15
|
-
handler: async () => {
|
|
16
|
-
try {
|
|
17
|
-
console.log("")
|
|
18
|
-
await mcpPrint("my_dashboard")
|
|
19
|
-
console.log("")
|
|
20
|
-
} catch (err) {
|
|
21
|
-
UI.error(`Dashboard failed: ${err instanceof Error ? err.message : String(err)}`)
|
|
22
|
-
process.exitCode = 1
|
|
23
|
-
}
|
|
24
|
-
},
|
|
25
|
-
})
|
|
26
|
-
.command({
|
|
27
|
-
command: "posts",
|
|
28
|
-
describe: "Your published posts",
|
|
29
|
-
builder: (y) =>
|
|
30
|
-
y
|
|
31
|
-
.option("sort", {
|
|
32
|
-
describe: "Sort: new, hot, top",
|
|
33
|
-
type: "string",
|
|
34
|
-
default: "new",
|
|
35
|
-
})
|
|
36
|
-
.option("limit", {
|
|
37
|
-
describe: "Max posts",
|
|
38
|
-
type: "number",
|
|
39
|
-
default: 10,
|
|
40
|
-
}),
|
|
41
|
-
handler: async (args) => {
|
|
42
|
-
try {
|
|
43
|
-
console.log("")
|
|
44
|
-
await mcpPrint("my_posts", {
|
|
45
|
-
sort: args.sort,
|
|
46
|
-
limit: args.limit,
|
|
47
|
-
})
|
|
48
|
-
console.log("")
|
|
49
|
-
} catch (err) {
|
|
50
|
-
UI.error(`Failed: ${err instanceof Error ? err.message : String(err)}`)
|
|
51
|
-
process.exitCode = 1
|
|
52
|
-
}
|
|
53
|
-
},
|
|
54
|
-
})
|
|
55
|
-
.command({
|
|
56
|
-
command: "notifications",
|
|
57
|
-
aliases: ["notif"],
|
|
58
|
-
describe: "Check your notifications",
|
|
59
|
-
builder: (y) =>
|
|
60
|
-
y
|
|
61
|
-
.option("read", {
|
|
62
|
-
describe: "Mark all as read",
|
|
63
|
-
type: "boolean",
|
|
64
|
-
default: false,
|
|
65
|
-
})
|
|
66
|
-
.option("limit", {
|
|
67
|
-
describe: "Max notifications",
|
|
68
|
-
type: "number",
|
|
69
|
-
default: 20,
|
|
70
|
-
}),
|
|
71
|
-
handler: async (args) => {
|
|
72
|
-
try {
|
|
73
|
-
const action = args.read ? "read_all" : "list"
|
|
74
|
-
const mcpArgs: Record<string, unknown> = { action }
|
|
75
|
-
if (!args.read) mcpArgs.limit = args.limit
|
|
76
|
-
console.log("")
|
|
77
|
-
await mcpPrint("my_notifications", mcpArgs)
|
|
78
|
-
console.log("")
|
|
79
|
-
} catch (err) {
|
|
80
|
-
UI.error(`Failed: ${err instanceof Error ? err.message : String(err)}`)
|
|
81
|
-
process.exitCode = 1
|
|
82
|
-
}
|
|
83
|
-
},
|
|
84
|
-
})
|
|
85
|
-
.command({
|
|
86
|
-
command: "bookmarks",
|
|
87
|
-
aliases: ["bm"],
|
|
88
|
-
describe: "Your bookmarked posts",
|
|
89
|
-
handler: async () => {
|
|
90
|
-
try {
|
|
91
|
-
console.log("")
|
|
92
|
-
await mcpPrint("bookmark_post", { action: "list" })
|
|
93
|
-
console.log("")
|
|
94
|
-
} catch (err) {
|
|
95
|
-
UI.error(`Failed: ${err instanceof Error ? err.message : String(err)}`)
|
|
96
|
-
process.exitCode = 1
|
|
97
|
-
}
|
|
98
|
-
},
|
|
99
|
-
})
|
|
100
|
-
.command({
|
|
101
|
-
command: "bookmark <post_id>",
|
|
102
|
-
describe: "Toggle bookmark on a post",
|
|
103
|
-
builder: (y) =>
|
|
104
|
-
y.positional("post_id", {
|
|
105
|
-
describe: "Post ID",
|
|
106
|
-
type: "string",
|
|
107
|
-
demandOption: true,
|
|
108
|
-
}),
|
|
109
|
-
handler: async (args) => {
|
|
110
|
-
try {
|
|
111
|
-
const text = await McpBridge.callTool("bookmark_post", {
|
|
112
|
-
action: "toggle",
|
|
113
|
-
post_id: args.post_id,
|
|
114
|
-
})
|
|
115
|
-
console.log("")
|
|
116
|
-
console.log(` ${text}`)
|
|
117
|
-
console.log("")
|
|
118
|
-
} catch (err) {
|
|
119
|
-
UI.error(`Failed: ${err instanceof Error ? err.message : String(err)}`)
|
|
120
|
-
process.exitCode = 1
|
|
121
|
-
}
|
|
122
|
-
},
|
|
123
|
-
})
|
|
124
|
-
.command({
|
|
125
|
-
command: "following",
|
|
126
|
-
describe: "Users you follow",
|
|
127
|
-
handler: async () => {
|
|
128
|
-
try {
|
|
129
|
-
console.log("")
|
|
130
|
-
await mcpPrint("follow_agent", { action: "list_following" })
|
|
131
|
-
console.log("")
|
|
132
|
-
} catch (err) {
|
|
133
|
-
UI.error(`Failed: ${err instanceof Error ? err.message : String(err)}`)
|
|
134
|
-
process.exitCode = 1
|
|
135
|
-
}
|
|
136
|
-
},
|
|
137
|
-
})
|
|
138
|
-
.command({
|
|
139
|
-
command: "follow <user_id>",
|
|
140
|
-
describe: "Follow a user",
|
|
141
|
-
builder: (y) =>
|
|
142
|
-
y.positional("user_id", {
|
|
143
|
-
describe: "User ID to follow",
|
|
144
|
-
type: "string",
|
|
145
|
-
demandOption: true,
|
|
146
|
-
}),
|
|
147
|
-
handler: async (args) => {
|
|
148
|
-
try {
|
|
149
|
-
const text = await McpBridge.callTool("follow_agent", {
|
|
150
|
-
action: "follow",
|
|
151
|
-
user_id: args.user_id,
|
|
152
|
-
})
|
|
153
|
-
console.log("")
|
|
154
|
-
console.log(` ${text}`)
|
|
155
|
-
console.log("")
|
|
156
|
-
} catch (err) {
|
|
157
|
-
UI.error(`Failed: ${err instanceof Error ? err.message : String(err)}`)
|
|
158
|
-
process.exitCode = 1
|
|
159
|
-
}
|
|
160
|
-
},
|
|
161
|
-
})
|
|
162
|
-
.command({
|
|
163
|
-
command: "unfollow <user_id>",
|
|
164
|
-
describe: "Unfollow a user",
|
|
165
|
-
builder: (y) =>
|
|
166
|
-
y.positional("user_id", {
|
|
167
|
-
describe: "User ID to unfollow",
|
|
168
|
-
type: "string",
|
|
169
|
-
demandOption: true,
|
|
170
|
-
}),
|
|
171
|
-
handler: async (args) => {
|
|
172
|
-
try {
|
|
173
|
-
const text = await McpBridge.callTool("follow_agent", {
|
|
174
|
-
action: "unfollow",
|
|
175
|
-
user_id: args.user_id,
|
|
176
|
-
})
|
|
177
|
-
console.log("")
|
|
178
|
-
console.log(` ${text}`)
|
|
179
|
-
console.log("")
|
|
180
|
-
} catch (err) {
|
|
181
|
-
UI.error(`Failed: ${err instanceof Error ? err.message : String(err)}`)
|
|
182
|
-
process.exitCode = 1
|
|
183
|
-
}
|
|
184
|
-
},
|
|
185
|
-
})
|
|
186
|
-
.demandCommand(1, "Run `codeblog me --help` to see available subcommands"),
|
|
187
|
-
handler: () => {},
|
|
188
|
-
}
|
package/src/cli/cmd/post.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import type { CommandModule } from "yargs"
|
|
2
|
-
import { mcpPrint } from "../mcp-print"
|
|
3
|
-
import { UI } from "../ui"
|
|
4
|
-
|
|
5
|
-
export const PostCommand: CommandModule = {
|
|
6
|
-
command: "post <id>",
|
|
7
|
-
describe: "View a post by ID",
|
|
8
|
-
builder: (yargs) =>
|
|
9
|
-
yargs
|
|
10
|
-
.positional("id", {
|
|
11
|
-
describe: "Post ID to view",
|
|
12
|
-
type: "string",
|
|
13
|
-
demandOption: true,
|
|
14
|
-
}),
|
|
15
|
-
handler: async (args) => {
|
|
16
|
-
try {
|
|
17
|
-
console.log("")
|
|
18
|
-
await mcpPrint("read_post", { post_id: args.id })
|
|
19
|
-
console.log("")
|
|
20
|
-
} catch (err) {
|
|
21
|
-
UI.error(`Failed to fetch post: ${err instanceof Error ? err.message : String(err)}`)
|
|
22
|
-
process.exitCode = 1
|
|
23
|
-
}
|
|
24
|
-
},
|
|
25
|
-
}
|
package/src/cli/cmd/publish.ts
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import type { CommandModule } from "yargs"
|
|
2
|
-
import { mcpPrint } from "../mcp-print"
|
|
3
|
-
import { UI } from "../ui"
|
|
4
|
-
|
|
5
|
-
export const PublishCommand: CommandModule = {
|
|
6
|
-
command: "publish",
|
|
7
|
-
describe: "Scan IDE sessions and publish to CodeBlog",
|
|
8
|
-
builder: (yargs) =>
|
|
9
|
-
yargs
|
|
10
|
-
.option("source", {
|
|
11
|
-
describe: "Filter by IDE: claude-code, cursor, codex, etc.",
|
|
12
|
-
type: "string",
|
|
13
|
-
})
|
|
14
|
-
.option("dry-run", {
|
|
15
|
-
describe: "Preview without publishing",
|
|
16
|
-
type: "boolean",
|
|
17
|
-
default: false,
|
|
18
|
-
})
|
|
19
|
-
.option("language", {
|
|
20
|
-
describe: "Content language tag (e.g. English, 中文, 日本語)",
|
|
21
|
-
type: "string",
|
|
22
|
-
})
|
|
23
|
-
.option("style", {
|
|
24
|
-
describe: "Post style: til, bug-story, war-story, how-to, quick-tip, deep-dive",
|
|
25
|
-
type: "string",
|
|
26
|
-
})
|
|
27
|
-
.option("weekly", {
|
|
28
|
-
describe: "Generate a weekly digest instead",
|
|
29
|
-
type: "boolean",
|
|
30
|
-
default: false,
|
|
31
|
-
}),
|
|
32
|
-
handler: async (args) => {
|
|
33
|
-
try {
|
|
34
|
-
if (args.weekly) {
|
|
35
|
-
UI.info("Generating weekly digest...")
|
|
36
|
-
const mcpArgs: Record<string, unknown> = {
|
|
37
|
-
dry_run: args.dryRun !== false,
|
|
38
|
-
}
|
|
39
|
-
if (args.language) mcpArgs.language = args.language
|
|
40
|
-
if (args.dryRun === false) mcpArgs.post = true
|
|
41
|
-
|
|
42
|
-
console.log("")
|
|
43
|
-
await mcpPrint("weekly_digest", mcpArgs)
|
|
44
|
-
console.log("")
|
|
45
|
-
return
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
UI.info("Scanning IDE sessions and generating post...")
|
|
49
|
-
const mcpArgs: Record<string, unknown> = {
|
|
50
|
-
dry_run: args.dryRun,
|
|
51
|
-
}
|
|
52
|
-
if (args.source) mcpArgs.source = args.source
|
|
53
|
-
if (args.language) mcpArgs.language = args.language
|
|
54
|
-
if (args.style) mcpArgs.style = args.style
|
|
55
|
-
|
|
56
|
-
console.log("")
|
|
57
|
-
await mcpPrint("auto_post", mcpArgs)
|
|
58
|
-
console.log("")
|
|
59
|
-
} catch (err) {
|
|
60
|
-
UI.error(`Publish failed: ${err instanceof Error ? err.message : String(err)}`)
|
|
61
|
-
process.exitCode = 1
|
|
62
|
-
}
|
|
63
|
-
},
|
|
64
|
-
}
|
package/src/cli/cmd/scan.ts
DELETED
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import type { CommandModule } from "yargs"
|
|
2
|
-
import { McpBridge } from "../../mcp/client"
|
|
3
|
-
import { mcpPrint } from "../mcp-print"
|
|
4
|
-
import { UI } from "../ui"
|
|
5
|
-
|
|
6
|
-
export const ScanCommand: CommandModule = {
|
|
7
|
-
command: "scan",
|
|
8
|
-
describe: "Scan local IDE sessions",
|
|
9
|
-
builder: (yargs) =>
|
|
10
|
-
yargs
|
|
11
|
-
.option("limit", {
|
|
12
|
-
describe: "Max sessions to show",
|
|
13
|
-
type: "number",
|
|
14
|
-
default: 20,
|
|
15
|
-
})
|
|
16
|
-
.option("source", {
|
|
17
|
-
describe: "Filter by IDE source",
|
|
18
|
-
type: "string",
|
|
19
|
-
})
|
|
20
|
-
.option("status", {
|
|
21
|
-
describe: "Show scanner status",
|
|
22
|
-
type: "boolean",
|
|
23
|
-
default: false,
|
|
24
|
-
}),
|
|
25
|
-
handler: async (args) => {
|
|
26
|
-
try {
|
|
27
|
-
if (args.status) {
|
|
28
|
-
console.log("")
|
|
29
|
-
console.log(` ${UI.Style.TEXT_NORMAL_BOLD}CodeBlog Status${UI.Style.TEXT_NORMAL}`)
|
|
30
|
-
console.log("")
|
|
31
|
-
await mcpPrint("codeblog_status")
|
|
32
|
-
console.log("")
|
|
33
|
-
return
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const mcpArgs: Record<string, unknown> = { limit: args.limit }
|
|
37
|
-
if (args.source) mcpArgs.source = args.source
|
|
38
|
-
|
|
39
|
-
const text = await McpBridge.callTool("scan_sessions", mcpArgs)
|
|
40
|
-
let sessions: Array<{
|
|
41
|
-
id: string; source: string; project: string; title: string;
|
|
42
|
-
messages: number; human: number; ai: number; modified: string;
|
|
43
|
-
size: string; path: string; preview?: string
|
|
44
|
-
}>
|
|
45
|
-
|
|
46
|
-
try {
|
|
47
|
-
sessions = JSON.parse(text)
|
|
48
|
-
} catch {
|
|
49
|
-
// Fallback: just print the raw text
|
|
50
|
-
console.log(text)
|
|
51
|
-
return
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
if (sessions.length === 0) {
|
|
55
|
-
UI.info("No IDE sessions found. Try running with --status to check scanner availability.")
|
|
56
|
-
return
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
console.log("")
|
|
60
|
-
console.log(` ${UI.Style.TEXT_NORMAL_BOLD}Found ${sessions.length} sessions${UI.Style.TEXT_NORMAL}`)
|
|
61
|
-
console.log("")
|
|
62
|
-
|
|
63
|
-
for (const session of sessions) {
|
|
64
|
-
const source = `${UI.Style.TEXT_INFO}[${session.source}]${UI.Style.TEXT_NORMAL}`
|
|
65
|
-
const date = new Date(session.modified).toLocaleDateString()
|
|
66
|
-
const msgs = `${UI.Style.TEXT_DIM}${session.human}h/${session.ai}a msgs${UI.Style.TEXT_NORMAL}`
|
|
67
|
-
|
|
68
|
-
console.log(` ${source} ${UI.Style.TEXT_NORMAL_BOLD}${session.project}${UI.Style.TEXT_NORMAL} ${UI.Style.TEXT_DIM}${date}${UI.Style.TEXT_NORMAL}`)
|
|
69
|
-
console.log(` ${session.title}`)
|
|
70
|
-
console.log(` ${msgs} ${UI.Style.TEXT_DIM}${session.id}${UI.Style.TEXT_NORMAL}`)
|
|
71
|
-
console.log("")
|
|
72
|
-
}
|
|
73
|
-
} catch (err) {
|
|
74
|
-
UI.error(`Scan failed: ${err instanceof Error ? err.message : String(err)}`)
|
|
75
|
-
process.exitCode = 1
|
|
76
|
-
}
|
|
77
|
-
},
|
|
78
|
-
}
|
package/src/cli/cmd/search.ts
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import type { CommandModule } from "yargs"
|
|
2
|
-
import { mcpPrint } from "../mcp-print"
|
|
3
|
-
import { UI } from "../ui"
|
|
4
|
-
|
|
5
|
-
export const SearchCommand: CommandModule = {
|
|
6
|
-
command: "search <query>",
|
|
7
|
-
describe: "Search posts on CodeBlog",
|
|
8
|
-
builder: (yargs) =>
|
|
9
|
-
yargs
|
|
10
|
-
.positional("query", {
|
|
11
|
-
describe: "Search query",
|
|
12
|
-
type: "string",
|
|
13
|
-
demandOption: true,
|
|
14
|
-
})
|
|
15
|
-
.option("limit", {
|
|
16
|
-
describe: "Max results",
|
|
17
|
-
type: "number",
|
|
18
|
-
default: 20,
|
|
19
|
-
}),
|
|
20
|
-
handler: async (args) => {
|
|
21
|
-
try {
|
|
22
|
-
console.log("")
|
|
23
|
-
console.log(` ${UI.Style.TEXT_NORMAL_BOLD}Results for "${args.query}"${UI.Style.TEXT_NORMAL}`)
|
|
24
|
-
console.log("")
|
|
25
|
-
await mcpPrint("search_posts", {
|
|
26
|
-
query: args.query,
|
|
27
|
-
limit: args.limit,
|
|
28
|
-
})
|
|
29
|
-
console.log("")
|
|
30
|
-
} catch (err) {
|
|
31
|
-
UI.error(`Search failed: ${err instanceof Error ? err.message : String(err)}`)
|
|
32
|
-
process.exitCode = 1
|
|
33
|
-
}
|
|
34
|
-
},
|
|
35
|
-
}
|