@vibe-forge/core 0.7.4 → 0.8.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.
Files changed (40) hide show
  1. package/package.json +4 -46
  2. package/src/env.ts +5 -25
  3. package/src/index.ts +0 -5
  4. package/src/types.ts +12 -72
  5. package/src/ws.ts +3 -12
  6. package/src/adapter/index.ts +0 -6
  7. package/src/adapter/loader.ts +0 -11
  8. package/src/adapter/type.ts +0 -112
  9. package/src/config/load.ts +0 -122
  10. package/src/config/types.ts +0 -289
  11. package/src/config.ts +0 -2
  12. package/src/controllers/benchmark/discover.ts +0 -89
  13. package/src/controllers/benchmark/index.ts +0 -24
  14. package/src/controllers/benchmark/result-store.ts +0 -46
  15. package/src/controllers/benchmark/runner.ts +0 -415
  16. package/src/controllers/benchmark/schema.ts +0 -60
  17. package/src/controllers/benchmark/types.ts +0 -80
  18. package/src/controllers/benchmark/utils.ts +0 -144
  19. package/src/controllers/benchmark/workspace.ts +0 -179
  20. package/src/controllers/config/index.ts +0 -214
  21. package/src/controllers/system/assets/completed.mp3 +0 -0
  22. package/src/controllers/system/assets/mcp.png +0 -0
  23. package/src/controllers/system/index.ts +0 -102
  24. package/src/controllers/task/generate-adapter-query-options.ts +0 -218
  25. package/src/controllers/task/index.ts +0 -2
  26. package/src/controllers/task/prepare.ts +0 -68
  27. package/src/controllers/task/run.ts +0 -191
  28. package/src/controllers/task/schema.ts +0 -131
  29. package/src/controllers/task/type.ts +0 -6
  30. package/src/hooks/call.ts +0 -74
  31. package/src/hooks/index.ts +0 -39
  32. package/src/hooks/loader.ts +0 -75
  33. package/src/hooks/runtime.ts +0 -139
  34. package/src/hooks/type.ts +0 -120
  35. package/src/utils/cache.ts +0 -58
  36. package/src/utils/create-logger.ts +0 -89
  37. package/src/utils/definition-loader.ts +0 -530
  38. package/src/utils/filter.ts +0 -26
  39. package/src/utils/string-transform.ts +0 -37
  40. package/src/utils/uuid.ts +0 -6
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vibe-forge/core",
3
- "version": "0.7.4",
3
+ "version": "0.8.0",
4
4
  "imports": {
5
5
  "#~/*.js": {
6
6
  "__vibe-forge__": {
@@ -22,15 +22,6 @@
22
22
  "require": "./dist/index.js"
23
23
  }
24
24
  },
25
- "./adapter": {
26
- "__vibe-forge__": {
27
- "default": "./src/adapter/index.ts"
28
- },
29
- "default": {
30
- "import": "./dist/adapter.mjs",
31
- "require": "./dist/adapter.js"
32
- }
33
- },
34
25
  "./channel": {
35
26
  "__vibe-forge__": {
36
27
  "default": "./src/channel.ts"
@@ -49,44 +40,11 @@
49
40
  "require": "./dist/schema.js"
50
41
  }
51
42
  },
52
- "./hooks": {
53
- "__vibe-forge__": {
54
- "default": "./src/hooks/index.ts"
55
- },
56
- "default": {
57
- "import": "./dist/hooks/index.mjs",
58
- "require": "./dist/hooks/index.js"
59
- }
60
- },
61
- "./utils/*": {
62
- "__vibe-forge__": {
63
- "default": "./src/utils/*.ts"
64
- },
65
- "default": {
66
- "import": "./dist/utils/*.mjs",
67
- "require": "./dist/utils/*.js"
68
- }
69
- },
70
- "./controllers/*": {
71
- "__vibe-forge__": {
72
- "default": "./src/controllers/*/index.ts"
73
- },
74
- "default": {
75
- "import": "./dist/controllers/*/index.mjs",
76
- "require": "./dist/controllers/*/index.js"
77
- }
78
- },
79
43
  "./package.json": "./package.json"
80
44
  },
81
45
  "dependencies": {
82
- "fast-glob": "^3.3.3",
83
- "front-matter": "^4.0.2",
84
- "js-yaml": "^4.1.1",
85
- "node-notifier": "^10.0.1",
86
- "zod": "^3.24.1"
87
- },
88
- "devDependencies": {
89
- "@types/js-yaml": "^4.0.9",
90
- "@types/node-notifier": "^8.0.5"
46
+ "zod": "^3.24.1",
47
+ "@vibe-forge/types": "^0.8.0",
48
+ "@vibe-forge/utils": "^0.8.0"
91
49
  }
92
50
  }
package/src/env.ts CHANGED
@@ -1,6 +1,10 @@
1
1
  import { env as processEnv } from 'node:process'
2
2
 
3
- export type LogLevel = 'debug' | 'info' | 'warn' | 'error'
3
+ import type { LogLevel } from '@vibe-forge/utils/log-level'
4
+ import { normalizeLogLevel } from '@vibe-forge/utils/log-level'
5
+
6
+ export type { LogLevel } from '@vibe-forge/utils/log-level'
7
+ export { normalizeLogLevel, resolveServerLogLevel } from '@vibe-forge/utils/log-level'
4
8
 
5
9
  export interface ServerEnv {
6
10
  __VF_PROJECT_AI_SERVER_HOST__: string
@@ -16,30 +20,6 @@ export interface ServerEnv {
16
20
  __VF_PROJECT_AI_CLIENT_DIST_PATH__?: string
17
21
  }
18
22
 
19
- const LOG_LEVELS = ['debug', 'info', 'warn', 'error'] as const satisfies readonly LogLevel[]
20
-
21
- export function normalizeLogLevel(value: unknown): LogLevel | undefined {
22
- if (typeof value !== 'string') return undefined
23
- const normalized = value.trim().toLowerCase()
24
- return LOG_LEVELS.includes(normalized as LogLevel)
25
- ? normalized as LogLevel
26
- : undefined
27
- }
28
-
29
- export function resolveServerLogLevel(
30
- env: {
31
- __VF_PROJECT_AI_SERVER_LOG_LEVEL__?: unknown
32
- __VF_PROJECT_AI_SERVER_DEBUG__?: unknown
33
- },
34
- fallback: LogLevel = 'info'
35
- ): LogLevel {
36
- if (env.__VF_PROJECT_AI_SERVER_DEBUG__ === true || env.__VF_PROJECT_AI_SERVER_DEBUG__ === 'true') {
37
- return 'debug'
38
- }
39
-
40
- return normalizeLogLevel(env.__VF_PROJECT_AI_SERVER_LOG_LEVEL__) ?? fallback
41
- }
42
-
43
23
  export function loadEnv(): ServerEnv {
44
24
  const {
45
25
  __VF_PROJECT_AI_SERVER_HOST__ = 'localhost',
package/src/index.ts CHANGED
@@ -1,9 +1,4 @@
1
- export * from './config'
2
- export * from './controllers/benchmark'
3
- export * from './controllers/config'
4
- export * from './controllers/system'
5
1
  export * from './env'
6
- export * from './hooks'
7
2
  export * from './schema'
8
3
  export * from './tools'
9
4
  export * from './types'
package/src/types.ts CHANGED
@@ -1,72 +1,12 @@
1
- import type { z } from 'zod'
2
- import type { AskUserQuestionParamsSchema, InteractionOptionSchema } from './schema.js'
3
-
4
- export interface Project {
5
- id: string
6
- name: string
7
- path: string
8
- }
9
-
10
- export type SessionStatus = 'running' | 'completed' | 'failed' | 'terminated' | 'waiting_input'
11
-
12
- export type SessionPermissionMode = 'default' | 'acceptEdits' | 'plan' | 'dontAsk' | 'bypassPermissions'
13
-
14
- export interface Session {
15
- id: string
16
- parentSessionId?: string
17
- title?: string
18
- createdAt: number
19
- messageCount?: number
20
- lastMessage?: string
21
- lastUserMessage?: string
22
- isStarred?: boolean
23
- isArchived?: boolean
24
- tags?: string[]
25
- status?: SessionStatus
26
- model?: string
27
- adapter?: string
28
- permissionMode?: SessionPermissionMode
29
- }
30
-
31
- export type ChatMessageContent =
32
- | { type: 'text'; text: string }
33
- | { type: 'image'; url: string; name?: string; size?: number; mimeType?: string }
34
- | { type: 'tool_use'; id: string; name: string; input: any }
35
- | { type: 'tool_result'; tool_use_id: string; content: any; is_error?: boolean }
36
-
37
- export interface ChatMessage {
38
- id: string
39
- role: 'user' | 'assistant' | 'system'
40
- content: string | ChatMessageContent[]
41
- model?: string
42
- usage?: {
43
- input_tokens: number
44
- output_tokens: number
45
- cache_read_input_tokens?: number
46
- cache_creation_input_tokens?: number
47
- }
48
- toolCall?: {
49
- id?: string
50
- name: string
51
- args: Record<string, unknown>
52
- status?: 'pending' | 'success' | 'error'
53
- output?: unknown
54
- }
55
- createdAt: number
56
- }
57
-
58
- export type InteractionOption = z.infer<typeof InteractionOptionSchema>
59
- export type AskUserQuestionParams = z.infer<typeof AskUserQuestionParamsSchema>
60
-
61
- export interface TaskDetail {
62
- ctxId: string
63
- sessionId: string
64
- status: 'pending' | 'running' | 'completed' | 'failed' | 'stopped'
65
- pid?: number
66
- startTime: number
67
- endTime?: number
68
- description?: string
69
- adapterType?: string
70
- model?: string
71
- exitCode?: number
72
- }
1
+ export type {
2
+ AskUserQuestionParams,
3
+ ChatMessage,
4
+ ChatMessageContent,
5
+ ConfigSource,
6
+ Project,
7
+ Session,
8
+ SessionPermissionMode,
9
+ SessionStatus,
10
+ TaskDetail,
11
+ TaskRuntime
12
+ } from '@vibe-forge/types'
package/src/ws.ts CHANGED
@@ -1,13 +1,4 @@
1
- import type { AdapterErrorData, SessionInfo } from './adapter/index.js'
2
- import type { AskUserQuestionParams, ChatMessage } from './types.js'
1
+ import type { AskUserQuestionParams, WSEvent as SharedWSEvent, AdapterErrorData, SessionInfo } from '@vibe-forge/types'
3
2
 
4
- export type WSEvent =
5
- | { type: 'error'; data: AdapterErrorData; message?: string }
6
- | { type: 'message'; message: ChatMessage }
7
- | { type: 'session_info'; info: SessionInfo }
8
- | { type: 'tool_result'; toolCallId: string; output: any; isError: boolean }
9
- | { type: 'adapter_result'; result: any; usage?: any }
10
- | { type: 'adapter_event'; data: any }
11
- | { type: 'session_updated'; session: any }
12
- | { type: 'interaction_request'; id: string; payload: AskUserQuestionParams }
13
- | { type: 'interaction_response'; id: string; data: string | string[] }
3
+
4
+ export type WSEvent = SharedWSEvent<AdapterErrorData, SessionInfo, any, AskUserQuestionParams>
@@ -1,6 +0,0 @@
1
- import type { Adapter } from './type'
2
-
3
- export * from './loader'
4
- export * from './type'
5
-
6
- export const defineAdapter = <T extends Adapter>(adapter: T): Adapter => adapter
@@ -1,11 +0,0 @@
1
- import type { Adapter } from './type'
2
-
3
- const resolveAdapterPackageName = (type: string) => (
4
- type.startsWith('@') ? type : `@vibe-forge/adapter-${type}`
5
- )
6
-
7
- export const loadAdapter = async (type: string) =>
8
- (
9
- // eslint-disable-next-line ts/no-require-imports
10
- require(resolveAdapterPackageName(type))
11
- ).default as Adapter
@@ -1,112 +0,0 @@
1
- import type { Cache, Config } from '@vibe-forge/core'
2
-
3
- import type { Logger } from '#~/utils/create-logger.js'
4
-
5
- import type { ChatMessage, ChatMessageContent } from '../types'
6
-
7
- export type AdapterMessageContent = ChatMessageContent
8
-
9
- export interface AdapterErrorData {
10
- message: string
11
- code?: string
12
- details?: unknown
13
- fatal?: boolean
14
- }
15
-
16
- export type AdapterOutputEvent =
17
- | { type: 'init'; data: SessionInitInfo }
18
- | { type: 'summary'; data: SessionSummaryInfo }
19
- | { type: 'message'; data: ChatMessage }
20
- | { type: 'error'; data: AdapterErrorData }
21
- | { type: 'exit'; data: { exitCode?: number; stderr?: string } }
22
- | { type: 'stop'; data?: ChatMessage }
23
-
24
- export type SessionInfo =
25
- | ({ type: 'init' } & SessionInitInfo)
26
- | ({ type: 'summary' } & SessionSummaryInfo)
27
-
28
- export interface SessionInitInfo {
29
- uuid: string
30
- model: string
31
- adapter?: string
32
- version: string
33
- tools: string[]
34
- slashCommands: string[]
35
- cwd: string
36
- agents: string[]
37
- title?: string
38
- }
39
-
40
- export interface SessionSummaryInfo {
41
- summary: string
42
- leafUuid: string
43
- }
44
-
45
- export type AdapterEvent =
46
- | { type: 'message'; content: AdapterMessageContent[]; parentUuid?: string }
47
- | { type: 'interrupt' }
48
- | { type: 'stop' }
49
-
50
- export interface AdapterCtx {
51
- ctxId: string
52
-
53
- cwd: string
54
- env: Record<string, string | null | undefined>
55
-
56
- cache: {
57
- set: <K extends keyof Cache>(key: K, value: Cache[K]) => Promise<{
58
- cachePath: string
59
- }>
60
- get: <K extends keyof Cache>(key: K) => Promise<Cache[K] | undefined>
61
- }
62
- logger: Logger
63
-
64
- configs: [Config?, Config?]
65
- }
66
-
67
- export interface AdapterQueryOptions {
68
- description?: string
69
-
70
- type: 'create' | 'resume'
71
- runtime: 'server' | 'cli' | 'mcp'
72
- sessionId: string
73
- model?: string
74
- mode?: 'stream' | 'direct'
75
-
76
- systemPrompt?: string
77
- appendSystemPrompt?: boolean
78
- permissionMode?: 'default' | 'acceptEdits' | 'plan' | 'dontAsk' | 'bypassPermissions'
79
-
80
- mcpServers?: {
81
- include?: string[]
82
- exclude?: string[]
83
- }
84
- tools?: {
85
- include?: string[]
86
- exclude?: string[]
87
- }
88
- skills?: {
89
- include?: string[]
90
- exclude?: string[]
91
- }
92
-
93
- extraOptions?: string[]
94
-
95
- onEvent: (event: AdapterOutputEvent) => void
96
- }
97
-
98
- export interface AdapterSession {
99
- kill: () => void
100
- emit: (event: AdapterEvent) => void
101
- pid?: number
102
- }
103
-
104
- export interface Adapter {
105
- init?: (
106
- ctx: AdapterCtx
107
- ) => Promise<void>
108
- query: (
109
- ctx: AdapterCtx,
110
- options: AdapterQueryOptions
111
- ) => Promise<AdapterSession>
112
- }
@@ -1,122 +0,0 @@
1
- import { existsSync } from 'node:fs'
2
- import { readFile } from 'node:fs/promises'
3
- import { resolve } from 'node:path'
4
- import process from 'node:process'
5
-
6
- import { load } from 'js-yaml'
7
-
8
- import type { AdapterMap, Config } from './types'
9
-
10
- const loadJSConfig = async (paths: string[]) => {
11
- for (const path of paths) {
12
- try {
13
- const configPath = resolve(process.cwd(), path)
14
- if (!existsSync(configPath)) {
15
- continue
16
- }
17
- // eslint-disable-next-line ts/no-require-imports
18
- return (require(configPath)?.default ?? {}) as Config
19
- } catch (e) {
20
- console.error(`Failed to load config file ${path}: ${e}`)
21
- }
22
- }
23
- }
24
-
25
- const loadJSONConfig = async (paths: string[], jsonVariables: Record<string, string | null | undefined>) => {
26
- for (const path of paths) {
27
- try {
28
- const configPath = resolve(process.cwd(), path)
29
- if (!existsSync(configPath)) {
30
- continue
31
- }
32
- const configContent = await readFile(configPath, 'utf-8')
33
- const configResolvedContent = configContent
34
- .replace(/\$\{(\w+)\}/g, (_, key) => jsonVariables[key] ?? `$\{${key}}`)
35
- return JSON.parse(configResolvedContent) as Config
36
- } catch (e) {
37
- console.error(`Failed to load config file ${path}: ${e}`)
38
- }
39
- }
40
- }
41
-
42
- const loadYAMLConfig = async (paths: string[], jsonVariables: Record<string, string | null | undefined>) => {
43
- for (const path of paths) {
44
- try {
45
- const configPath = resolve(process.cwd(), path)
46
- if (!existsSync(configPath)) {
47
- continue
48
- }
49
- const configContent = await readFile(configPath, 'utf-8')
50
- const configResolvedContent = configContent
51
- .replace(/\$\{(\w+)\}/g, (_, key) => jsonVariables[key] ?? `$\{${key}}`)
52
- return load(configResolvedContent) as Config
53
- } catch (e) {
54
- console.error(`Failed to load config file ${path}: ${e}`)
55
- }
56
- }
57
- }
58
-
59
- let configCache: Promise<readonly [Config | undefined, Config | undefined]> | null = null
60
-
61
- export const resetConfigCache = () => {
62
- configCache = null
63
- }
64
-
65
- export const loadConfig = (options: {
66
- jsonVariables?: Record<string, string | null | undefined>
67
- }) => {
68
- if (configCache) {
69
- return configCache
70
- }
71
-
72
- configCache = (async () =>
73
- [
74
- await loadJSONConfig(
75
- [
76
- './.ai.config.json',
77
- './infra/.ai.config.json'
78
- ],
79
- options.jsonVariables ?? {}
80
- ) ??
81
- await loadYAMLConfig(
82
- [
83
- './.ai.config.yaml',
84
- './.ai.config.yml',
85
- './infra/.ai.config.yaml',
86
- './infra/.ai.config.yml'
87
- ],
88
- options.jsonVariables ?? {}
89
- ),
90
- await loadJSONConfig(
91
- [
92
- './.ai.dev.config.json',
93
- './infra/.ai.dev.config.json'
94
- ],
95
- options.jsonVariables ?? {}
96
- ) ??
97
- await loadYAMLConfig(
98
- [
99
- './.ai.dev.config.yaml',
100
- './.ai.dev.config.yml',
101
- './infra/.ai.dev.config.yaml',
102
- './infra/.ai.dev.config.yml'
103
- ],
104
- options.jsonVariables ?? {}
105
- )
106
- ] as const)()
107
- return configCache
108
- }
109
-
110
- export const loadAdapterConfig = async <
111
- K extends keyof AdapterMap,
112
- >(
113
- name: K,
114
- options: { jsonVariables?: Record<string, string> }
115
- ) => {
116
- const [projectConfig, userConfig] = await loadConfig(options)
117
- return {
118
- ...(projectConfig?.adapters?.[name] ?? {}),
119
- ...(userConfig?.adapters?.[name] ?? {})
120
- } as unknown as NonNullable<Config['adapters']>[K]
121
- }
122
-