From ee56795461eda6468fb95426219bedaf1c69a81a Mon Sep 17 00:00:00 2001 From: abearxiong Date: Thu, 5 Feb 2026 19:37:55 +0800 Subject: [PATCH] temp --- bun.config.ts | 28 ++++------------------------ package.json | 3 ++- src/cnb-core.ts | 8 ++++++++ src/repo/index.ts | 4 ++-- src/user/index.ts | 8 ++++---- 5 files changed, 20 insertions(+), 31 deletions(-) diff --git a/bun.config.ts b/bun.config.ts index 7de5637..20e6750 100644 --- a/bun.config.ts +++ b/bun.config.ts @@ -1,24 +1,4 @@ -import { resolvePath } from '@kevisual/use-config'; -import { execSync } from 'node:child_process'; - -const buildFn = async (opts: { entry?: string, naming?: string }) => { - const entry = opts.entry || 'agent/opencode.ts'; - const naming = opts.naming || 'opencode'; - const external: string[] = ["bun", "ws"]; - await Bun.build({ - target: 'node', - format: 'esm', - entrypoints: [resolvePath(entry, { meta: import.meta })], - outdir: resolvePath('./dist', { meta: import.meta }), - naming: { - entry: `${naming}.js`, - }, - external, - }); - const cmd = `dts -i ${entry} -o ${naming}.d.ts`; - execSync(cmd); -}; - -await buildFn({ naming: 'opencode', entry: 'agent/opencode.ts' }); -await buildFn({ naming: 'keep', entry: 'src/keep.ts' }); -await buildFn({ naming: 'routes', entry: 'agent/index.ts' }); \ No newline at end of file +import { buildWithBun } from '@kevisual/code-builder' +await buildWithBun({ naming: 'opencode', entry: 'agent/opencode.ts', dts: true }); +await buildWithBun({ naming: 'keep', entry: 'src/keep.ts', dts: true }); +await buildWithBun({ naming: 'routes', entry: 'agent/index.ts', dts: true }); \ No newline at end of file diff --git a/package.json b/package.json index b64be1d..bcbdf20 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@kevisual/cnb", - "version": "0.0.13", + "version": "0.0.14", "description": "", "main": "index.js", "scripts": { @@ -19,6 +19,7 @@ "type": "module", "devDependencies": { "@kevisual/ai": "^0.0.24", + "@kevisual/code-builder": "^0.0.6", "@kevisual/context": "^0.0.4", "@kevisual/types": "^0.0.12", "@opencode-ai/plugin": "^1.1.44", diff --git a/src/cnb-core.ts b/src/cnb-core.ts index be15f2e..c239187 100644 --- a/src/cnb-core.ts +++ b/src/cnb-core.ts @@ -5,6 +5,9 @@ export type CNBCoreOptions = { */ cookie?: string; cnb?: CNBCore; + cors?: { + baseUrl?: string + } } & T; export type RequestOptions = { @@ -19,6 +22,7 @@ export type RequestOptions = { }; export class CNBCore { baseURL = 'https://api.cnb.cool'; + hackURL = 'https://cnb.cool' public token: string; public cookie?: string; constructor(options: CNBCoreOptions) { @@ -32,6 +36,10 @@ export class CNBCore { this.cookie = options.cnb.cookie; } } + if (options?.cors?.baseUrl) { + this.baseURL = options.cors.baseUrl + '/' + this.baseURL; + this.hackURL = options.cors.baseUrl + '/' + this.hackURL; + } } async request({ url, method = 'GET', data, params, headers, body, useCookie, useOrigin }: RequestOptions): Promise { diff --git a/src/repo/index.ts b/src/repo/index.ts index 1ad90fc..4bd17a7 100644 --- a/src/repo/index.ts +++ b/src/repo/index.ts @@ -23,7 +23,7 @@ export class Repo extends CNBCore { return this.post({ url, data: postData }); } deleteRepo(name: string): Promise { - const url = `https://cnb.cool/${name}`; + const url = `${this.hackURL}/${name}`; return this.delete({ url, useCookie: true }); } async createCommit(repo: string, data: CreateCommitData): Promise { @@ -38,7 +38,7 @@ export class Repo extends CNBCore { if (!data.parent_commit_sha && preCommitSha) { data.parent_commit_sha = preCommitSha; } - const url = `https://cnb.cool/${repo}/-/git/commits`; + const url = `${this.hackURL}/${repo}/-/git/commits`; const postData: CreateCommitData = { ...data, base_branch: data.base_branch || 'refs/heads/main', diff --git a/src/user/index.ts b/src/user/index.ts index 892e1cd..f325c7e 100644 --- a/src/user/index.ts +++ b/src/user/index.ts @@ -10,7 +10,7 @@ export class User extends CNBCore { * @returns */ getCurrentUser(): Promise> { - const url = `https://cnb.cool/user`; + const url = `${this.hackURL}/user`; return this.get({ url, useCookie: true, @@ -26,7 +26,7 @@ export class User extends CNBCore { } createAccessToken(data?: { description?: string, scope?: string }): Promise { const scope = data?.scope || 'mission-manage:rw,mission-delete:rw,group-delete:rw,group-manage:rw,group-resource:rw,account-engage:rw,account-email:r,account-profile:rw,registry-delete:rw,registry-manage:rw,registry-package-delete:rw,registry-package:rw,repo-security:r,repo-delete:rw,repo-manage:rw,repo-basic-info:r,repo-cnb-detail:rw,repo-cnb-history:r,repo-cnb-trigger:rw,repo-commit-status:rw,repo-contents:rw,repo-notes:rw,repo-issue:rw,repo-pr:rw,repo-code:rw' - const url = 'https://cnb.cool/user/personal_access_tokens' + const url = `${this.hackURL}/user/personal_access_tokens` return this.post({ url, useCookie: true, @@ -37,7 +37,7 @@ export class User extends CNBCore { }) } getAccessTokens(params?: { page?: number, page_size?: number }): Promise { - const url = 'https://cnb.cool/user/personal_access_tokens' + const url = `${this.hackURL}/user/personal_access_tokens` return this.get({ url, useCookie: true, @@ -49,7 +49,7 @@ export class User extends CNBCore { }) } deleteAccessToken(tokenId: string): Promise { - const url = `https://cnb.cool/user/personal_access_tokens/${tokenId}` + const url = `${this.hackURL}/user/personal_access_tokens/${tokenId}` return this.delete({ url, useCookie: true,