@kevisual/cnb 0.0.56 → 0.0.58
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.
- package/agent/routes/call/index.ts +5 -4
- package/agent/routes/cnb-env/env.ts +3 -2
- package/agent/routes/cnb-env/vscode.ts +9 -8
- package/agent/routes/index.ts +1 -0
- package/agent/routes/issues/comments.ts +18 -17
- package/agent/routes/issues/issue.ts +11 -10
- package/agent/routes/issues/list.ts +11 -10
- package/agent/routes/knowledge/ai.ts +6 -5
- package/agent/routes/labels/issue-label.ts +17 -16
- package/agent/routes/org/index.ts +2 -0
- package/agent/routes/org/list.ts +137 -0
- package/agent/routes/org/org.ts +241 -0
- package/agent/routes/package/index.ts +2 -0
- package/agent/routes/package/package.ts +255 -0
- package/agent/routes/package/registry.ts +107 -0
- package/agent/routes/repo/list.ts +6 -5
- package/agent/routes/repo/repo-label.ts +17 -16
- package/agent/routes/repo/repo.ts +18 -17
- package/agent/routes/workspace/build.ts +7 -6
- package/agent/routes/workspace/index.ts +17 -17
- package/agent/routes/workspace/keep.ts +5 -5
- package/agent/routes/workspace/rerun.ts +6 -1
- package/agent/routes/workspace/skills.ts +2 -2
- package/dist/cli.js +764 -207
- package/dist/npc.js +764 -207
- package/dist/opencode.js +772 -215
- package/dist/routes.d.ts +643 -3
- package/dist/routes.js +764 -207
- package/package.json +1 -1
- package/src/index.ts +21 -1
- package/src/issue/index.ts +5 -2
- package/src/knowledge/index.ts +92 -5
- package/src/org/index.ts +574 -0
- package/src/package/index.ts +2 -0
- package/src/package/package.ts +134 -0
- package/src/package/registry.ts +145 -0
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -8,6 +8,8 @@ import { Issue } from "./issue/index.ts";
|
|
|
8
8
|
import { Mission } from "./mission/index.ts";
|
|
9
9
|
import { AiBase } from "./ai/index.ts";
|
|
10
10
|
import { RepoLabel, IssueLabel } from "./labels/index.ts";
|
|
11
|
+
import { RegistryPackage, PackageManagement } from "./package/index.ts";
|
|
12
|
+
import { Organization } from "./org/index.ts";
|
|
11
13
|
|
|
12
14
|
type CNBOptions = CNBCoreOptions<{
|
|
13
15
|
}>;
|
|
@@ -25,6 +27,11 @@ export class CNB extends CNBCore {
|
|
|
25
27
|
repoLabel: RepoLabel;
|
|
26
28
|
issueLabel: IssueLabel;
|
|
27
29
|
};
|
|
30
|
+
packages!: {
|
|
31
|
+
registry: RegistryPackage;
|
|
32
|
+
package: PackageManagement;
|
|
33
|
+
};
|
|
34
|
+
org!: Organization;
|
|
28
35
|
constructor(options: CNBOptions) {
|
|
29
36
|
super({ ...options, token: options.token, cookie: options.cookie, cnb: options.cnb });
|
|
30
37
|
this.init(options);
|
|
@@ -47,6 +54,11 @@ export class CNB extends CNBCore {
|
|
|
47
54
|
repoLabel: new RepoLabel(options),
|
|
48
55
|
issueLabel: new IssueLabel(options),
|
|
49
56
|
};
|
|
57
|
+
this.packages = {
|
|
58
|
+
registry: new RegistryPackage(options),
|
|
59
|
+
package: new PackageManagement(options),
|
|
60
|
+
};
|
|
61
|
+
this.org = new Organization(options);
|
|
50
62
|
}
|
|
51
63
|
setToken(token: string) {
|
|
52
64
|
this.token = token;
|
|
@@ -58,6 +70,9 @@ export class CNB extends CNBCore {
|
|
|
58
70
|
this.mission.token = token;
|
|
59
71
|
this.labels.repoLabel.token = token;
|
|
60
72
|
this.labels.issueLabel.token = token;
|
|
73
|
+
this.packages.registry.token = token;
|
|
74
|
+
this.packages.package.token = token;
|
|
75
|
+
this.org.token = token;
|
|
61
76
|
}
|
|
62
77
|
setCookie(cookie: string) {
|
|
63
78
|
this.cookie = cookie;
|
|
@@ -69,6 +84,9 @@ export class CNB extends CNBCore {
|
|
|
69
84
|
this.mission.cookie = cookie;
|
|
70
85
|
this.labels.repoLabel.cookie = cookie;
|
|
71
86
|
this.labels.issueLabel.cookie = cookie;
|
|
87
|
+
this.packages.registry.cookie = cookie;
|
|
88
|
+
this.packages.package.cookie = cookie;
|
|
89
|
+
this.org.cookie = cookie;
|
|
72
90
|
}
|
|
73
91
|
getCNBVersion = getCNBVersion
|
|
74
92
|
}
|
|
@@ -95,4 +113,6 @@ type VersionInfo = {
|
|
|
95
113
|
}
|
|
96
114
|
|
|
97
115
|
export * from './issue/npc/env.ts'
|
|
98
|
-
export * from './labels/index.ts'
|
|
116
|
+
export * from './labels/index.ts'
|
|
117
|
+
export * from './package/index.ts'
|
|
118
|
+
export * from './org/index.ts'
|
package/src/issue/index.ts
CHANGED
|
@@ -63,8 +63,11 @@ export type IssueItem = {
|
|
|
63
63
|
number: string;
|
|
64
64
|
priority: string;
|
|
65
65
|
started_at: string;
|
|
66
|
-
state:
|
|
67
|
-
|
|
66
|
+
state: 'open' | 'closed';
|
|
67
|
+
/**
|
|
68
|
+
* state_reason must be one of completed, not_planned, reopened
|
|
69
|
+
*/
|
|
70
|
+
state_reason: 'completed' | 'not_planned' | 'reopened';
|
|
68
71
|
title: string;
|
|
69
72
|
updated_at: string;
|
|
70
73
|
};
|
package/src/knowledge/index.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { CNBCore, CNBCoreOptions, Result } from "../cnb-core.ts";
|
|
2
2
|
|
|
3
|
+
// https://cnb.cool/cnb/plugins/cnbcool/knowledge-base/-/blob/main/src/api.py
|
|
3
4
|
export class KnowledgeBase extends CNBCore {
|
|
4
5
|
constructor(options: CNBCoreOptions) {
|
|
5
6
|
super(options);
|
|
@@ -12,10 +13,7 @@ export class KnowledgeBase extends CNBCore {
|
|
|
12
13
|
metadata_filtering_conditions?: MetadataFilteringConditions
|
|
13
14
|
}): Promise<Result<QueryRag[]>> {
|
|
14
15
|
const url = `/${repo}/-/knowledge/base/query`;
|
|
15
|
-
|
|
16
|
-
query: data.query,
|
|
17
|
-
};
|
|
18
|
-
return this.post({ url, data: postData });
|
|
16
|
+
return this.post({ url, data });
|
|
19
17
|
}
|
|
20
18
|
getEmbeddingModels(repo: string): Promise<Result<Array<{ name: string, dimensions: number }>>> {
|
|
21
19
|
const url = `/${repo}/-/knowledge/embedding/models`;
|
|
@@ -31,6 +29,95 @@ export class KnowledgeBase extends CNBCore {
|
|
|
31
29
|
const url = `/${repo}/-/knowledge/base`;
|
|
32
30
|
return this.request({ url, method: 'DELETE' });
|
|
33
31
|
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* 未暴露
|
|
35
|
+
* @param repo
|
|
36
|
+
* @param data
|
|
37
|
+
* @returns
|
|
38
|
+
*/
|
|
39
|
+
createKnowledgeBase(repo: string, data: {
|
|
40
|
+
embedding_model_name: string;
|
|
41
|
+
include: string;
|
|
42
|
+
exclude: string;
|
|
43
|
+
issue_sync_enabled?: boolean;
|
|
44
|
+
processing?: {
|
|
45
|
+
chunk_size: number;
|
|
46
|
+
chunk_overlap: number;
|
|
47
|
+
text_separator: string;
|
|
48
|
+
};
|
|
49
|
+
issue?: {
|
|
50
|
+
labels: string;
|
|
51
|
+
state: string;
|
|
52
|
+
};
|
|
53
|
+
}): Promise<Result<any>> {
|
|
54
|
+
const url = `/${repo}/-/knowledge/base`;
|
|
55
|
+
return this.post({ url, data });
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* 未暴露
|
|
59
|
+
* @param repo
|
|
60
|
+
* @param data
|
|
61
|
+
* @returns
|
|
62
|
+
*/
|
|
63
|
+
updateKnowledgeBase(repo: string, data: {
|
|
64
|
+
last_commit_sha?: string;
|
|
65
|
+
issue_last_sync_time?: string;
|
|
66
|
+
}): Promise<Result<any>> {
|
|
67
|
+
const url = `/${repo}/-/knowledge/base`;
|
|
68
|
+
return this.put({ url, data });
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* 未暴露
|
|
73
|
+
* @param repo
|
|
74
|
+
* @param text
|
|
75
|
+
* @returns
|
|
76
|
+
*/
|
|
77
|
+
getEmbedding(repo: string, text: string): Promise<Result<{ embedding: number[] }>> {
|
|
78
|
+
const url = `/${repo}/-/knowledge/embedding`;
|
|
79
|
+
return this.post({ url, data: { text } });
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* 未暴露
|
|
83
|
+
* @param repo
|
|
84
|
+
* @param chunksData
|
|
85
|
+
* @returns
|
|
86
|
+
*/
|
|
87
|
+
addDocument(repo: string, chunksData: {
|
|
88
|
+
path: string;
|
|
89
|
+
chunks: Array<{
|
|
90
|
+
content: string;
|
|
91
|
+
hash: string;
|
|
92
|
+
offset: number;
|
|
93
|
+
size: number;
|
|
94
|
+
}>;
|
|
95
|
+
}): Promise<Result<any>> {
|
|
96
|
+
const url = `/${repo}/-/knowledge/documents/upsert-document-with-chunks`;
|
|
97
|
+
return this.post({ url, data: chunksData });
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* 未暴露
|
|
101
|
+
* @param repo
|
|
102
|
+
* @param paths
|
|
103
|
+
* @returns
|
|
104
|
+
*/
|
|
105
|
+
|
|
106
|
+
deleteDocument(repo: string, paths: string[]): Promise<Result<any>> {
|
|
107
|
+
const url = `/${repo}/-/knowledge/documents`;
|
|
108
|
+
return this.delete({ url, data: { paths } });
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* 未暴露
|
|
112
|
+
* @param repo
|
|
113
|
+
* @param page
|
|
114
|
+
* @param page_size
|
|
115
|
+
* @returns
|
|
116
|
+
*/
|
|
117
|
+
listDocument(repo: string, page: number = 1, page_size: number = 50): Promise<Result<any[]>> {
|
|
118
|
+
const url = `/${repo}/-/knowledge/documents`;
|
|
119
|
+
return this.get({ url, params: { page, page_size } });
|
|
120
|
+
}
|
|
34
121
|
}
|
|
35
122
|
|
|
36
123
|
type MetadataFilteringConditions = {
|
|
@@ -42,7 +129,7 @@ type MetadataFilteringConditions = {
|
|
|
42
129
|
*/
|
|
43
130
|
value?: string
|
|
44
131
|
}>
|
|
45
|
-
logical_operator?: '
|
|
132
|
+
logical_operator?: 'and' | 'or'
|
|
46
133
|
}
|
|
47
134
|
|
|
48
135
|
type QueryRag = {
|