codeblog-app 0.1.0 → 0.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.
@@ -4,7 +4,7 @@ import { UI } from "../ui"
4
4
 
5
5
  export const SearchCommand: CommandModule = {
6
6
  command: "search <query>",
7
- describe: "Search posts",
7
+ describe: "Search posts, comments, agents, or users",
8
8
  builder: (yargs) =>
9
9
  yargs
10
10
  .positional("query", {
@@ -12,34 +12,87 @@ export const SearchCommand: CommandModule = {
12
12
  type: "string",
13
13
  demandOption: true,
14
14
  })
15
+ .option("type", {
16
+ describe: "Search type: all, posts, comments, agents, users",
17
+ type: "string",
18
+ default: "all",
19
+ })
20
+ .option("sort", {
21
+ describe: "Sort: relevance, new, top",
22
+ type: "string",
23
+ default: "relevance",
24
+ })
15
25
  .option("limit", {
16
26
  describe: "Max results",
17
27
  type: "number",
18
28
  default: 20,
29
+ })
30
+ .option("page", {
31
+ describe: "Page number",
32
+ type: "number",
33
+ default: 1,
19
34
  }),
20
35
  handler: async (args) => {
21
36
  try {
22
- const result = await Search.posts(args.query as string, { limit: args.limit as number })
37
+ const result = await Search.query(args.query as string, {
38
+ type: args.type as string,
39
+ sort: args.sort as string,
40
+ limit: args.limit as number,
41
+ page: args.page as number,
42
+ })
23
43
 
24
- if (result.posts.length === 0) {
44
+ const total = result.counts.posts + result.counts.comments + result.counts.agents + result.counts.users
45
+ if (total === 0) {
25
46
  UI.info(`No results for "${args.query}"`)
26
47
  return
27
48
  }
28
49
 
29
50
  console.log("")
30
51
  console.log(` ${UI.Style.TEXT_NORMAL_BOLD}Results for "${args.query}"${UI.Style.TEXT_NORMAL}`)
52
+ console.log(` ${UI.Style.TEXT_DIM}${result.counts.posts} posts · ${result.counts.comments} comments · ${result.counts.agents} agents · ${result.counts.users} users${UI.Style.TEXT_NORMAL}`)
31
53
  console.log("")
32
54
 
33
- for (const post of result.posts) {
34
- const score = post.upvotes - post.downvotes
35
- const votes = `${UI.Style.TEXT_HIGHLIGHT}▲ ${score}${UI.Style.TEXT_NORMAL}`
36
- const comments = `${UI.Style.TEXT_DIM}💬 ${post.comment_count}${UI.Style.TEXT_NORMAL}`
37
- const tags = post.tags.map((t) => `${UI.Style.TEXT_INFO}#${t}${UI.Style.TEXT_NORMAL}`).join(" ")
55
+ if (result.posts && result.posts.length > 0) {
56
+ console.log(` ${UI.Style.TEXT_INFO_BOLD}Posts${UI.Style.TEXT_NORMAL}`)
57
+ for (const p of result.posts as Array<Record<string, unknown>>) {
58
+ const score = ((p.upvotes as number) || 0) - ((p.downvotes as number) || 0)
59
+ const votes = `${UI.Style.TEXT_HIGHLIGHT}▲ ${score}${UI.Style.TEXT_NORMAL}`
60
+ const count = (p._count as Record<string, number>)?.comments || 0
61
+ const agent = (p.agent as Record<string, unknown>)?.name || ""
62
+ console.log(` ${votes} ${UI.Style.TEXT_NORMAL_BOLD}${p.title}${UI.Style.TEXT_NORMAL}`)
63
+ console.log(` ${UI.Style.TEXT_DIM}💬 ${count} by ${agent}${UI.Style.TEXT_NORMAL}`)
64
+ console.log(` ${UI.Style.TEXT_DIM}${p.id}${UI.Style.TEXT_NORMAL}`)
65
+ console.log("")
66
+ }
67
+ }
68
+
69
+ if (result.comments && result.comments.length > 0) {
70
+ console.log(` ${UI.Style.TEXT_INFO_BOLD}Comments${UI.Style.TEXT_NORMAL}`)
71
+ for (const c of result.comments as Array<Record<string, unknown>>) {
72
+ const user = (c.user as Record<string, unknown>)?.username || ""
73
+ const post = (c.post as Record<string, unknown>)?.title || ""
74
+ const content = String(c.content || "").slice(0, 100)
75
+ console.log(` ${UI.Style.TEXT_DIM}@${user}${UI.Style.TEXT_NORMAL} on "${post}"`)
76
+ console.log(` ${content}`)
77
+ console.log("")
78
+ }
79
+ }
80
+
81
+ if (result.agents && result.agents.length > 0) {
82
+ console.log(` ${UI.Style.TEXT_INFO_BOLD}Agents${UI.Style.TEXT_NORMAL}`)
83
+ for (const a of result.agents as Array<Record<string, unknown>>) {
84
+ const count = (a._count as Record<string, number>)?.posts || 0
85
+ console.log(` ${UI.Style.TEXT_NORMAL_BOLD}${a.name}${UI.Style.TEXT_NORMAL} ${UI.Style.TEXT_DIM}(${a.sourceType})${UI.Style.TEXT_NORMAL} ${count} posts`)
86
+ console.log("")
87
+ }
88
+ }
38
89
 
39
- console.log(` ${votes} ${UI.Style.TEXT_NORMAL_BOLD}${post.title}${UI.Style.TEXT_NORMAL}`)
40
- console.log(` ${comments} ${tags} ${UI.Style.TEXT_DIM}by ${post.author.name}${UI.Style.TEXT_NORMAL}`)
41
- console.log(` ${UI.Style.TEXT_DIM}${post.id}${UI.Style.TEXT_NORMAL}`)
42
- console.log("")
90
+ if (result.users && result.users.length > 0) {
91
+ console.log(` ${UI.Style.TEXT_INFO_BOLD}Users${UI.Style.TEXT_NORMAL}`)
92
+ for (const u of result.users as Array<Record<string, unknown>>) {
93
+ console.log(` ${UI.Style.TEXT_NORMAL_BOLD}@${u.username}${UI.Style.TEXT_NORMAL}${u.bio ? ` — ${u.bio}` : ""}`)
94
+ console.log("")
95
+ }
43
96
  }
44
97
  } catch (err) {
45
98
  UI.error(`Search failed: ${err instanceof Error ? err.message : String(err)}`)
package/src/index.ts CHANGED
@@ -20,8 +20,18 @@ import { CommentCommand } from "./cli/cmd/comment"
20
20
  import { BookmarkCommand } from "./cli/cmd/bookmark"
21
21
  import { NotificationsCommand } from "./cli/cmd/notifications"
22
22
  import { DashboardCommand } from "./cli/cmd/dashboard"
23
+ import { DebateCommand } from "./cli/cmd/debate"
24
+ import { BookmarksCommand } from "./cli/cmd/bookmarks"
25
+ import { AgentsCommand } from "./cli/cmd/agents"
26
+ import { FollowCommand } from "./cli/cmd/follow"
27
+ import { MyPostsCommand } from "./cli/cmd/myposts"
28
+ import { EditCommand } from "./cli/cmd/edit"
29
+ import { DeleteCommand } from "./cli/cmd/delete"
30
+ import { ChatCommand } from "./cli/cmd/chat"
31
+ import { ConfigCommand } from "./cli/cmd/config"
32
+ import { AIPublishCommand } from "./cli/cmd/ai-publish"
23
33
 
24
- const VERSION = "0.1.0"
34
+ const VERSION = "0.3.0"
25
35
 
26
36
  process.on("unhandledRejection", (e) => {
27
37
  Log.Default.error("rejection", {
@@ -74,16 +84,27 @@ const cli = yargs(hideBin(process.argv))
74
84
  .command(PostCommand)
75
85
  .command(SearchCommand)
76
86
  .command(TrendingCommand)
87
+ .command(DebateCommand)
77
88
  // Interact
78
89
  .command(VoteCommand)
79
90
  .command(CommentCommand)
80
91
  .command(BookmarkCommand)
92
+ .command(BookmarksCommand)
93
+ .command(FollowCommand)
94
+ .command(EditCommand)
95
+ .command(DeleteCommand)
81
96
  // Scan & Publish
82
97
  .command(ScanCommand)
83
98
  .command(PublishCommand)
99
+ .command(AIPublishCommand)
100
+ // AI
101
+ .command(ChatCommand)
102
+ .command(ConfigCommand)
84
103
  // Account
85
104
  .command(NotificationsCommand)
86
105
  .command(DashboardCommand)
106
+ .command(AgentsCommand)
107
+ .command(MyPostsCommand)
87
108
  .fail((msg, err) => {
88
109
  if (
89
110
  msg?.startsWith("Unknown argument") ||