@vibe-forge/core 0.7.5 → 0.8.3

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 (43) 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 +13 -72
  5. package/src/ws.ts +2 -12
  6. package/src/adapter/index.ts +0 -6
  7. package/src/adapter/loader.ts +0 -11
  8. package/src/adapter/type.ts +0 -117
  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 -25
  25. package/src/controllers/task/index.ts +0 -2
  26. package/src/controllers/task/prepare.ts +0 -74
  27. package/src/controllers/task/run.ts +0 -231
  28. package/src/controllers/task/schema.ts +0 -131
  29. package/src/controllers/task/type.ts +0 -6
  30. package/src/hooks/bridge.ts +0 -368
  31. package/src/hooks/call.ts +0 -74
  32. package/src/hooks/index.ts +0 -41
  33. package/src/hooks/loader.ts +0 -79
  34. package/src/hooks/native.ts +0 -116
  35. package/src/hooks/runtime.ts +0 -139
  36. package/src/hooks/type.ts +0 -145
  37. package/src/utils/cache.ts +0 -58
  38. package/src/utils/create-logger.ts +0 -89
  39. package/src/utils/definition-loader.ts +0 -530
  40. package/src/utils/filter.ts +0 -26
  41. package/src/utils/string-transform.ts +0 -37
  42. package/src/utils/uuid.ts +0 -6
  43. package/src/utils/workspace-assets.ts +0 -919
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vibe-forge/core",
3
- "version": "0.7.5",
3
+ "version": "0.8.3",
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.3",
48
+ "@vibe-forge/utils": "^0.8.3"
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,13 @@
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
+ EffortLevel,
7
+ Project,
8
+ Session,
9
+ SessionPermissionMode,
10
+ SessionStatus,
11
+ TaskDetail,
12
+ TaskRuntime
13
+ } from '@vibe-forge/types'
package/src/ws.ts CHANGED
@@ -1,13 +1,3 @@
1
- import type { AdapterErrorData, SessionInfo } from './adapter/index.js'
2
- import type { AskUserQuestionParams, ChatMessage } from './types.js'
1
+ import type { AdapterErrorData, AskUserQuestionParams, SessionInfo, WSEvent as SharedWSEvent } 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
+ 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,117 +0,0 @@
1
- import type { Cache, Config } from '@vibe-forge/core'
2
-
3
- import type { Logger } from '#~/utils/create-logger.js'
4
- import type { AdapterAssetPlan, AssetDiagnostic, WorkspaceAssetBundle } from '#~/utils/workspace-assets.js'
5
-
6
- import type { ChatMessage, ChatMessageContent } from '../types'
7
-
8
- export type AdapterMessageContent = ChatMessageContent
9
-
10
- export interface AdapterErrorData {
11
- message: string
12
- code?: string
13
- details?: unknown
14
- fatal?: boolean
15
- }
16
-
17
- export type AdapterOutputEvent =
18
- | { type: 'init'; data: SessionInitInfo }
19
- | { type: 'summary'; data: SessionSummaryInfo }
20
- | { type: 'message'; data: ChatMessage }
21
- | { type: 'error'; data: AdapterErrorData }
22
- | { type: 'exit'; data: { exitCode?: number; stderr?: string } }
23
- | { type: 'stop'; data?: ChatMessage }
24
-
25
- export type SessionInfo =
26
- | ({ type: 'init' } & SessionInitInfo)
27
- | ({ type: 'summary' } & SessionSummaryInfo)
28
-
29
- export interface SessionInitInfo {
30
- uuid: string
31
- model: string
32
- adapter?: string
33
- version: string
34
- tools: string[]
35
- slashCommands: string[]
36
- cwd: string
37
- agents: string[]
38
- title?: string
39
- assetDiagnostics?: AssetDiagnostic[]
40
- }
41
-
42
- export interface SessionSummaryInfo {
43
- summary: string
44
- leafUuid: string
45
- }
46
-
47
- export type AdapterEvent =
48
- | { type: 'message'; content: AdapterMessageContent[]; parentUuid?: string }
49
- | { type: 'interrupt' }
50
- | { type: 'stop' }
51
-
52
- export interface AdapterCtx {
53
- ctxId: string
54
-
55
- cwd: string
56
- env: Record<string, string | null | undefined>
57
-
58
- cache: {
59
- set: <K extends keyof Cache>(key: K, value: Cache[K]) => Promise<{
60
- cachePath: string
61
- }>
62
- get: <K extends keyof Cache>(key: K) => Promise<Cache[K] | undefined>
63
- }
64
- logger: Logger
65
-
66
- configs: [Config?, Config?]
67
- assets?: WorkspaceAssetBundle
68
- }
69
-
70
- export interface AdapterQueryOptions {
71
- description?: string
72
-
73
- type: 'create' | 'resume'
74
- runtime: 'server' | 'cli' | 'mcp'
75
- sessionId: string
76
- model?: string
77
- mode?: 'stream' | 'direct'
78
-
79
- systemPrompt?: string
80
- appendSystemPrompt?: boolean
81
- permissionMode?: 'default' | 'acceptEdits' | 'plan' | 'dontAsk' | 'bypassPermissions'
82
-
83
- mcpServers?: {
84
- include?: string[]
85
- exclude?: string[]
86
- }
87
- tools?: {
88
- include?: string[]
89
- exclude?: string[]
90
- }
91
- skills?: {
92
- include?: string[]
93
- exclude?: string[]
94
- }
95
-
96
- extraOptions?: string[]
97
- promptAssetIds?: string[]
98
- assetPlan?: AdapterAssetPlan
99
-
100
- onEvent: (event: AdapterOutputEvent) => void
101
- }
102
-
103
- export interface AdapterSession {
104
- kill: () => void
105
- emit: (event: AdapterEvent) => void
106
- pid?: number
107
- }
108
-
109
- export interface Adapter {
110
- init?: (
111
- ctx: AdapterCtx
112
- ) => Promise<void>
113
- query: (
114
- ctx: AdapterCtx,
115
- options: AdapterQueryOptions
116
- ) => Promise<AdapterSession>
117
- }
@@ -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
-