codeblog-app 2.3.1 → 2.3.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 (83) hide show
  1. package/package.json +8 -73
  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 -188
  6. package/src/ai/__tests__/compat.test.ts +0 -46
  7. package/src/ai/__tests__/home.ai-stream.integration.test.ts +0 -77
  8. package/src/ai/__tests__/provider-registry.test.ts +0 -61
  9. package/src/ai/__tests__/provider.test.ts +0 -238
  10. package/src/ai/__tests__/stream-events.test.ts +0 -152
  11. package/src/ai/__tests__/tools.test.ts +0 -93
  12. package/src/ai/chat.ts +0 -336
  13. package/src/ai/configure.ts +0 -143
  14. package/src/ai/models.ts +0 -26
  15. package/src/ai/provider-registry.ts +0 -150
  16. package/src/ai/provider.ts +0 -264
  17. package/src/ai/stream-events.ts +0 -64
  18. package/src/ai/tools.ts +0 -118
  19. package/src/ai/types.ts +0 -105
  20. package/src/auth/index.ts +0 -49
  21. package/src/auth/oauth.ts +0 -123
  22. package/src/cli/__tests__/commands.test.ts +0 -229
  23. package/src/cli/cmd/agent.ts +0 -97
  24. package/src/cli/cmd/ai.ts +0 -10
  25. package/src/cli/cmd/chat.ts +0 -190
  26. package/src/cli/cmd/comment.ts +0 -67
  27. package/src/cli/cmd/config.ts +0 -153
  28. package/src/cli/cmd/feed.ts +0 -53
  29. package/src/cli/cmd/forum.ts +0 -106
  30. package/src/cli/cmd/login.ts +0 -45
  31. package/src/cli/cmd/logout.ts +0 -12
  32. package/src/cli/cmd/me.ts +0 -188
  33. package/src/cli/cmd/post.ts +0 -25
  34. package/src/cli/cmd/publish.ts +0 -64
  35. package/src/cli/cmd/scan.ts +0 -78
  36. package/src/cli/cmd/search.ts +0 -35
  37. package/src/cli/cmd/setup.ts +0 -622
  38. package/src/cli/cmd/tui.ts +0 -20
  39. package/src/cli/cmd/uninstall.ts +0 -281
  40. package/src/cli/cmd/update.ts +0 -123
  41. package/src/cli/cmd/vote.ts +0 -50
  42. package/src/cli/cmd/whoami.ts +0 -18
  43. package/src/cli/mcp-print.ts +0 -6
  44. package/src/cli/ui.ts +0 -357
  45. package/src/config/index.ts +0 -92
  46. package/src/flag/index.ts +0 -23
  47. package/src/global/index.ts +0 -38
  48. package/src/id/index.ts +0 -20
  49. package/src/index.ts +0 -203
  50. package/src/mcp/__tests__/client.test.ts +0 -149
  51. package/src/mcp/__tests__/e2e.ts +0 -331
  52. package/src/mcp/__tests__/integration.ts +0 -148
  53. package/src/mcp/client.ts +0 -118
  54. package/src/server/index.ts +0 -48
  55. package/src/storage/chat.ts +0 -73
  56. package/src/storage/db.ts +0 -85
  57. package/src/storage/schema.sql.ts +0 -39
  58. package/src/storage/schema.ts +0 -1
  59. package/src/tui/__tests__/input-intent.test.ts +0 -27
  60. package/src/tui/__tests__/stream-assembler.test.ts +0 -33
  61. package/src/tui/ai-stream.ts +0 -28
  62. package/src/tui/app.tsx +0 -210
  63. package/src/tui/commands.ts +0 -220
  64. package/src/tui/context/exit.tsx +0 -15
  65. package/src/tui/context/helper.tsx +0 -25
  66. package/src/tui/context/route.tsx +0 -24
  67. package/src/tui/context/theme.tsx +0 -471
  68. package/src/tui/input-intent.ts +0 -26
  69. package/src/tui/routes/home.tsx +0 -1060
  70. package/src/tui/routes/model.tsx +0 -210
  71. package/src/tui/routes/notifications.tsx +0 -87
  72. package/src/tui/routes/post.tsx +0 -102
  73. package/src/tui/routes/search.tsx +0 -105
  74. package/src/tui/routes/setup.tsx +0 -267
  75. package/src/tui/routes/trending.tsx +0 -107
  76. package/src/tui/stream-assembler.ts +0 -49
  77. package/src/util/__tests__/context.test.ts +0 -31
  78. package/src/util/__tests__/lazy.test.ts +0 -37
  79. package/src/util/context.ts +0 -23
  80. package/src/util/error.ts +0 -46
  81. package/src/util/lazy.ts +0 -18
  82. package/src/util/log.ts +0 -144
  83. package/tsconfig.json +0 -11
package/src/util/log.ts DELETED
@@ -1,144 +0,0 @@
1
- import path from "path"
2
- import fs from "fs/promises"
3
- import { Global } from "../global"
4
- import z from "zod"
5
-
6
- export namespace Log {
7
- export const Level = z.enum(["DEBUG", "INFO", "WARN", "ERROR"]).meta({ ref: "LogLevel", description: "Log level" })
8
- export type Level = z.infer<typeof Level>
9
-
10
- const levelPriority: Record<Level, number> = {
11
- DEBUG: 0,
12
- INFO: 1,
13
- WARN: 2,
14
- ERROR: 3,
15
- }
16
-
17
- let level: Level = "INFO"
18
-
19
- function shouldLog(input: Level): boolean {
20
- return levelPriority[input] >= levelPriority[level]
21
- }
22
-
23
- export type Logger = {
24
- debug(message?: any, extra?: Record<string, any>): void
25
- info(message?: any, extra?: Record<string, any>): void
26
- error(message?: any, extra?: Record<string, any>): void
27
- warn(message?: any, extra?: Record<string, any>): void
28
- tag(key: string, value: string): Logger
29
- clone(): Logger
30
- }
31
-
32
- const loggers = new Map<string, Logger>()
33
-
34
- export const Default = create({ service: "default" })
35
-
36
- export interface Options {
37
- print: boolean
38
- dev?: boolean
39
- level?: Level
40
- }
41
-
42
- let logpath = ""
43
- export function file() {
44
- return logpath
45
- }
46
- let write = (msg: any) => {
47
- process.stderr.write(msg)
48
- return msg.length
49
- }
50
-
51
- export async function init(options: Options) {
52
- if (options.level) level = options.level
53
- cleanup(Global.Path.log)
54
- if (options.print) return
55
- const isoNow = new Date().toISOString()
56
- const timestampBase = isoNow.split(".")[0] ?? isoNow
57
- logpath = path.join(
58
- Global.Path.log,
59
- options.dev ? "dev.log" : `${timestampBase.replace(/:/g, "")}.log`,
60
- )
61
- const logfile = Bun.file(logpath)
62
- await fs.truncate(logpath).catch(() => {})
63
- const writer = logfile.writer()
64
- write = async (msg: any) => {
65
- const num = writer.write(msg)
66
- writer.flush()
67
- return num
68
- }
69
- }
70
-
71
- async function cleanup(dir: string) {
72
- const glob = new Bun.Glob("????-??-??T??????.log")
73
- const files = await Array.fromAsync(
74
- glob.scan({
75
- cwd: dir,
76
- absolute: true,
77
- }),
78
- )
79
- if (files.length <= 5) return
80
- const filesToDelete = files.slice(0, -10)
81
- await Promise.all(filesToDelete.map((file) => fs.unlink(file).catch(() => {})))
82
- }
83
-
84
- function formatError(error: Error, depth = 0): string {
85
- const result = error.message
86
- return error.cause instanceof Error && depth < 10
87
- ? result + " Caused by: " + formatError(error.cause, depth + 1)
88
- : result
89
- }
90
-
91
- let last = Date.now()
92
- export function create(tags?: Record<string, any>) {
93
- tags = tags || {}
94
-
95
- const service = tags["service"]
96
- if (service && typeof service === "string") {
97
- const cached = loggers.get(service)
98
- if (cached) return cached
99
- }
100
-
101
- function build(message: any, extra?: Record<string, any>) {
102
- const prefix = Object.entries({
103
- ...tags,
104
- ...extra,
105
- })
106
- .filter(([_, value]) => value !== undefined && value !== null)
107
- .map(([key, value]) => {
108
- const prefix = `${key}=`
109
- if (value instanceof Error) return prefix + formatError(value)
110
- if (typeof value === "object") return prefix + JSON.stringify(value)
111
- return prefix + value
112
- })
113
- .join(" ")
114
- const next = new Date()
115
- const diff = next.getTime() - last
116
- last = next.getTime()
117
- return [next.toISOString().split(".")[0], "+" + diff + "ms", prefix, message].filter(Boolean).join(" ") + "\n"
118
- }
119
- const result: Logger = {
120
- debug(message?: any, extra?: Record<string, any>) {
121
- if (shouldLog("DEBUG")) write("DEBUG " + build(message, extra))
122
- },
123
- info(message?: any, extra?: Record<string, any>) {
124
- if (shouldLog("INFO")) write("INFO " + build(message, extra))
125
- },
126
- error(message?: any, extra?: Record<string, any>) {
127
- if (shouldLog("ERROR")) write("ERROR " + build(message, extra))
128
- },
129
- warn(message?: any, extra?: Record<string, any>) {
130
- if (shouldLog("WARN")) write("WARN " + build(message, extra))
131
- },
132
- tag(key: string, value: string) {
133
- if (tags) tags[key] = value
134
- return result
135
- },
136
- clone() {
137
- return Log.create({ ...tags })
138
- },
139
- }
140
-
141
- if (service && typeof service === "string") loggers.set(service, result)
142
- return result
143
- }
144
- }
package/tsconfig.json DELETED
@@ -1,11 +0,0 @@
1
- {
2
- "$schema": "https://json.schemastore.org/tsconfig",
3
- "extends": "@tsconfig/bun/tsconfig.json",
4
- "compilerOptions": {
5
- "jsx": "preserve",
6
- "jsxImportSource": "@opentui/solid",
7
- "paths": {
8
- "@/*": ["./src/*"]
9
- }
10
- }
11
- }