byterover-cli 0.1.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.
- package/README.md +781 -0
- package/bin/dev.cmd +4 -0
- package/bin/dev.js +7 -0
- package/bin/run.cmd +4 -0
- package/bin/run.js +7 -0
- package/dist/commands/add.d.ts +60 -0
- package/dist/commands/add.js +230 -0
- package/dist/commands/clear.d.ts +13 -0
- package/dist/commands/clear.js +57 -0
- package/dist/commands/complete.d.ts +108 -0
- package/dist/commands/complete.js +340 -0
- package/dist/commands/gen-rules.d.ts +26 -0
- package/dist/commands/gen-rules.js +89 -0
- package/dist/commands/init.d.ts +24 -0
- package/dist/commands/init.js +135 -0
- package/dist/commands/login.d.ts +22 -0
- package/dist/commands/login.js +103 -0
- package/dist/commands/push.d.ts +33 -0
- package/dist/commands/push.js +150 -0
- package/dist/commands/retrieve.d.ts +26 -0
- package/dist/commands/retrieve.js +101 -0
- package/dist/commands/space/list.d.ts +22 -0
- package/dist/commands/space/list.js +105 -0
- package/dist/commands/space/switch.d.ts +20 -0
- package/dist/commands/space/switch.js +110 -0
- package/dist/commands/status.d.ts +22 -0
- package/dist/commands/status.js +116 -0
- package/dist/config/auth.config.d.ts +32 -0
- package/dist/config/auth.config.js +35 -0
- package/dist/config/environment.d.ts +35 -0
- package/dist/config/environment.js +39 -0
- package/dist/constants.d.ts +11 -0
- package/dist/constants.js +12 -0
- package/dist/core/domain/entities/agent.d.ts +5 -0
- package/dist/core/domain/entities/agent.js +23 -0
- package/dist/core/domain/entities/auth-token.d.ts +43 -0
- package/dist/core/domain/entities/auth-token.js +70 -0
- package/dist/core/domain/entities/br-config.d.ts +25 -0
- package/dist/core/domain/entities/br-config.js +58 -0
- package/dist/core/domain/entities/bullet.d.ts +51 -0
- package/dist/core/domain/entities/bullet.js +94 -0
- package/dist/core/domain/entities/curator-output.d.ts +14 -0
- package/dist/core/domain/entities/curator-output.js +23 -0
- package/dist/core/domain/entities/delta-batch.d.ts +30 -0
- package/dist/core/domain/entities/delta-batch.js +52 -0
- package/dist/core/domain/entities/delta-operation.d.ts +31 -0
- package/dist/core/domain/entities/delta-operation.js +50 -0
- package/dist/core/domain/entities/event.d.ts +8 -0
- package/dist/core/domain/entities/event.js +15 -0
- package/dist/core/domain/entities/executor-output.d.ts +27 -0
- package/dist/core/domain/entities/executor-output.js +33 -0
- package/dist/core/domain/entities/memory.d.ts +55 -0
- package/dist/core/domain/entities/memory.js +90 -0
- package/dist/core/domain/entities/oauth-token-data.d.ts +13 -0
- package/dist/core/domain/entities/oauth-token-data.js +20 -0
- package/dist/core/domain/entities/playbook.d.ts +97 -0
- package/dist/core/domain/entities/playbook.js +275 -0
- package/dist/core/domain/entities/presigned-url.d.ts +9 -0
- package/dist/core/domain/entities/presigned-url.js +18 -0
- package/dist/core/domain/entities/presigned-urls-response.d.ts +10 -0
- package/dist/core/domain/entities/presigned-urls-response.js +18 -0
- package/dist/core/domain/entities/reflector-output.d.ts +38 -0
- package/dist/core/domain/entities/reflector-output.js +44 -0
- package/dist/core/domain/entities/retrieve-result.d.ts +35 -0
- package/dist/core/domain/entities/retrieve-result.js +35 -0
- package/dist/core/domain/entities/space.d.ts +24 -0
- package/dist/core/domain/entities/space.js +52 -0
- package/dist/core/domain/entities/team.d.ts +42 -0
- package/dist/core/domain/entities/team.js +89 -0
- package/dist/core/domain/entities/user.d.ts +20 -0
- package/dist/core/domain/entities/user.js +32 -0
- package/dist/core/domain/errors/ace-error.d.ts +34 -0
- package/dist/core/domain/errors/ace-error.js +53 -0
- package/dist/core/domain/errors/auth-error.d.ts +10 -0
- package/dist/core/domain/errors/auth-error.js +20 -0
- package/dist/core/domain/errors/discovery-error.d.ts +21 -0
- package/dist/core/domain/errors/discovery-error.js +33 -0
- package/dist/core/domain/errors/rule-error.d.ts +6 -0
- package/dist/core/domain/errors/rule-error.js +12 -0
- package/dist/core/interfaces/i-ace-prompt-builder.d.ts +48 -0
- package/dist/core/interfaces/i-ace-prompt-builder.js +1 -0
- package/dist/core/interfaces/i-auth-service.d.ts +35 -0
- package/dist/core/interfaces/i-auth-service.js +1 -0
- package/dist/core/interfaces/i-browser-launcher.d.ts +11 -0
- package/dist/core/interfaces/i-browser-launcher.js +1 -0
- package/dist/core/interfaces/i-bullet-content-store.d.ts +36 -0
- package/dist/core/interfaces/i-bullet-content-store.js +1 -0
- package/dist/core/interfaces/i-callback-handler.d.ts +35 -0
- package/dist/core/interfaces/i-callback-handler.js +1 -0
- package/dist/core/interfaces/i-delta-store.d.ts +15 -0
- package/dist/core/interfaces/i-delta-store.js +1 -0
- package/dist/core/interfaces/i-executor-output-store.d.ts +14 -0
- package/dist/core/interfaces/i-executor-output-store.js +1 -0
- package/dist/core/interfaces/i-file-service.d.ts +34 -0
- package/dist/core/interfaces/i-file-service.js +1 -0
- package/dist/core/interfaces/i-http-client.d.ts +33 -0
- package/dist/core/interfaces/i-http-client.js +1 -0
- package/dist/core/interfaces/i-memory-retrieval-service.d.ts +40 -0
- package/dist/core/interfaces/i-memory-retrieval-service.js +1 -0
- package/dist/core/interfaces/i-memory-storage-service.d.ts +55 -0
- package/dist/core/interfaces/i-memory-storage-service.js +1 -0
- package/dist/core/interfaces/i-oidc-discovery-service.d.ts +20 -0
- package/dist/core/interfaces/i-oidc-discovery-service.js +1 -0
- package/dist/core/interfaces/i-playbook-service.d.ts +69 -0
- package/dist/core/interfaces/i-playbook-service.js +1 -0
- package/dist/core/interfaces/i-playbook-store.d.ts +38 -0
- package/dist/core/interfaces/i-playbook-store.js +1 -0
- package/dist/core/interfaces/i-project-config-store.d.ts +26 -0
- package/dist/core/interfaces/i-project-config-store.js +1 -0
- package/dist/core/interfaces/i-reflection-store.d.ts +21 -0
- package/dist/core/interfaces/i-reflection-store.js +1 -0
- package/dist/core/interfaces/i-rule-template-service.d.ts +17 -0
- package/dist/core/interfaces/i-rule-template-service.js +4 -0
- package/dist/core/interfaces/i-rule-writer-service.d.ts +13 -0
- package/dist/core/interfaces/i-rule-writer-service.js +1 -0
- package/dist/core/interfaces/i-space-service.d.ts +28 -0
- package/dist/core/interfaces/i-space-service.js +1 -0
- package/dist/core/interfaces/i-team-service.d.ts +29 -0
- package/dist/core/interfaces/i-team-service.js +1 -0
- package/dist/core/interfaces/i-template-loader.d.ts +29 -0
- package/dist/core/interfaces/i-template-loader.js +1 -0
- package/dist/core/interfaces/i-token-store.d.ts +22 -0
- package/dist/core/interfaces/i-token-store.js +1 -0
- package/dist/core/interfaces/i-tracking-service.d.ts +21 -0
- package/dist/core/interfaces/i-tracking-service.js +1 -0
- package/dist/core/interfaces/i-user-service.d.ts +14 -0
- package/dist/core/interfaces/i-user-service.js +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/infra/ace/ace-file-utils.d.ts +46 -0
- package/dist/infra/ace/ace-file-utils.js +83 -0
- package/dist/infra/ace/ace-prompt-templates.d.ts +13 -0
- package/dist/infra/ace/ace-prompt-templates.js +177 -0
- package/dist/infra/ace/file-bullet-content-store.d.ts +27 -0
- package/dist/infra/ace/file-bullet-content-store.js +89 -0
- package/dist/infra/ace/file-delta-store.d.ts +9 -0
- package/dist/infra/ace/file-delta-store.js +26 -0
- package/dist/infra/ace/file-executor-output-store.d.ts +9 -0
- package/dist/infra/ace/file-executor-output-store.js +26 -0
- package/dist/infra/ace/file-playbook-store.d.ts +29 -0
- package/dist/infra/ace/file-playbook-store.js +107 -0
- package/dist/infra/ace/file-reflection-store.d.ts +10 -0
- package/dist/infra/ace/file-reflection-store.js +55 -0
- package/dist/infra/auth/oauth-service.d.ts +49 -0
- package/dist/infra/auth/oauth-service.js +126 -0
- package/dist/infra/auth/oidc-discovery-service.d.ts +51 -0
- package/dist/infra/auth/oidc-discovery-service.js +145 -0
- package/dist/infra/browser/system-browser-launcher.d.ts +10 -0
- package/dist/infra/browser/system-browser-launcher.js +18 -0
- package/dist/infra/config/file-config-store.d.ts +21 -0
- package/dist/infra/config/file-config-store.js +57 -0
- package/dist/infra/file/fs-file-service.d.ts +28 -0
- package/dist/infra/file/fs-file-service.js +57 -0
- package/dist/infra/http/authenticated-http-client.d.ts +46 -0
- package/dist/infra/http/authenticated-http-client.js +99 -0
- package/dist/infra/http/callback-handler.d.ts +13 -0
- package/dist/infra/http/callback-handler.js +24 -0
- package/dist/infra/http/callback-server.d.ts +18 -0
- package/dist/infra/http/callback-server.js +93 -0
- package/dist/infra/memory/http-memory-retrieval-service.d.ts +18 -0
- package/dist/infra/memory/http-memory-retrieval-service.js +63 -0
- package/dist/infra/memory/http-memory-storage-service.d.ts +18 -0
- package/dist/infra/memory/http-memory-storage-service.js +67 -0
- package/dist/infra/memory/memory-to-playbook-mapper.d.ts +33 -0
- package/dist/infra/memory/memory-to-playbook-mapper.js +51 -0
- package/dist/infra/playbook/file-playbook-service.d.ts +43 -0
- package/dist/infra/playbook/file-playbook-service.js +133 -0
- package/dist/infra/rule/agent-rule-config.d.ts +19 -0
- package/dist/infra/rule/agent-rule-config.js +77 -0
- package/dist/infra/rule/rule-template-service.d.ts +18 -0
- package/dist/infra/rule/rule-template-service.js +80 -0
- package/dist/infra/rule/rule-writer-service.d.ts +19 -0
- package/dist/infra/rule/rule-writer-service.js +43 -0
- package/dist/infra/space/http-space-service.d.ts +20 -0
- package/dist/infra/space/http-space-service.js +67 -0
- package/dist/infra/storage/keychain-token-store.d.ts +10 -0
- package/dist/infra/storage/keychain-token-store.js +40 -0
- package/dist/infra/team/http-team-service.d.ts +21 -0
- package/dist/infra/team/http-team-service.js +71 -0
- package/dist/infra/template/fs-template-loader.d.ts +33 -0
- package/dist/infra/template/fs-template-loader.js +62 -0
- package/dist/infra/tracking/mixpanel-tracking-service.d.ts +14 -0
- package/dist/infra/tracking/mixpanel-tracking-service.js +44 -0
- package/dist/infra/user/http-user-service.d.ts +12 -0
- package/dist/infra/user/http-user-service.js +26 -0
- package/dist/templates/README.md +103 -0
- package/dist/templates/base.md +3 -0
- package/dist/templates/sections/command-reference.md +141 -0
- package/dist/templates/sections/workflow.md +46 -0
- package/dist/utils/file-helpers.d.ts +15 -0
- package/dist/utils/file-helpers.js +45 -0
- package/oclif.manifest.json +476 -0
- package/package.json +82 -0
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Represents metadata associated with a bullet point
|
|
3
|
+
*/
|
|
4
|
+
export interface BulletMetadata {
|
|
5
|
+
relatedFiles: string[];
|
|
6
|
+
tags: string[];
|
|
7
|
+
timestamp: string;
|
|
8
|
+
}
|
|
9
|
+
export interface BulletJson {
|
|
10
|
+
content?: string;
|
|
11
|
+
id: string;
|
|
12
|
+
memoryId?: string;
|
|
13
|
+
metadata: {
|
|
14
|
+
relatedFiles: string[];
|
|
15
|
+
tags: string[];
|
|
16
|
+
timestamp: string;
|
|
17
|
+
};
|
|
18
|
+
section: string;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Represents a single knowledge entry in the playbook.
|
|
22
|
+
* Bullets contain reusable insights, strategies, or lessons learned.
|
|
23
|
+
*/
|
|
24
|
+
export declare class Bullet {
|
|
25
|
+
readonly content: string;
|
|
26
|
+
readonly id: string;
|
|
27
|
+
readonly memoryId?: string;
|
|
28
|
+
readonly metadata: BulletMetadata;
|
|
29
|
+
readonly section: string;
|
|
30
|
+
constructor(id: string, section: string, content: string, metadata: BulletMetadata, memoryId?: string);
|
|
31
|
+
/**
|
|
32
|
+
* Creates a Bullet instance from a JSON object.
|
|
33
|
+
* The content parameter must be provided separately when content is stored in files.
|
|
34
|
+
* @param json The JSON object containing bullet metadata
|
|
35
|
+
* @param content Optional content string (required if json.content is undefined)
|
|
36
|
+
*/
|
|
37
|
+
static fromJson(json: BulletJson, content?: string): Bullet;
|
|
38
|
+
/**
|
|
39
|
+
* Formats the bullet for display in a playbook
|
|
40
|
+
*/
|
|
41
|
+
toDisplayString(): string;
|
|
42
|
+
/**
|
|
43
|
+
* Converts the bullet to a JSON object
|
|
44
|
+
* @param includeContent If false, content field is omitted (for file-based storage)
|
|
45
|
+
*/
|
|
46
|
+
toJson(includeContent?: boolean): BulletJson;
|
|
47
|
+
/**
|
|
48
|
+
* Creates a new bullet with updated content
|
|
49
|
+
*/
|
|
50
|
+
withUpdatedContent(content: string): Bullet;
|
|
51
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Represents a single knowledge entry in the playbook.
|
|
3
|
+
* Bullets contain reusable insights, strategies, or lessons learned.
|
|
4
|
+
*/
|
|
5
|
+
export class Bullet {
|
|
6
|
+
content;
|
|
7
|
+
id;
|
|
8
|
+
memoryId;
|
|
9
|
+
metadata;
|
|
10
|
+
section;
|
|
11
|
+
// eslint-disable-next-line max-params
|
|
12
|
+
constructor(id, section, content, metadata, memoryId) {
|
|
13
|
+
if (id.trim().length === 0) {
|
|
14
|
+
throw new Error('Bullet ID cannot be empty');
|
|
15
|
+
}
|
|
16
|
+
if (section.trim().length === 0) {
|
|
17
|
+
throw new Error('Bullet section cannot be empty');
|
|
18
|
+
}
|
|
19
|
+
if (content.trim().length === 0) {
|
|
20
|
+
throw new Error('Bullet content cannot be empty');
|
|
21
|
+
}
|
|
22
|
+
if (!metadata.timestamp || metadata.timestamp.trim().length === 0) {
|
|
23
|
+
throw new Error('Bullet metadata timestamp cannot be empty');
|
|
24
|
+
}
|
|
25
|
+
if (!metadata.relatedFiles || !Array.isArray(metadata.relatedFiles)) {
|
|
26
|
+
throw new Error('Bullet metadata relatedFiles must be an array');
|
|
27
|
+
}
|
|
28
|
+
if (!metadata.tags || metadata.tags.length === 0) {
|
|
29
|
+
throw new Error('Bullet metadata tags cannot be empty');
|
|
30
|
+
}
|
|
31
|
+
this.id = id;
|
|
32
|
+
this.section = section;
|
|
33
|
+
this.content = content;
|
|
34
|
+
this.metadata = metadata;
|
|
35
|
+
this.memoryId = memoryId;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Creates a Bullet instance from a JSON object.
|
|
39
|
+
* The content parameter must be provided separately when content is stored in files.
|
|
40
|
+
* @param json The JSON object containing bullet metadata
|
|
41
|
+
* @param content Optional content string (required if json.content is undefined)
|
|
42
|
+
*/
|
|
43
|
+
static fromJson(json, content) {
|
|
44
|
+
const bulletContent = json.content ?? content;
|
|
45
|
+
if (!bulletContent) {
|
|
46
|
+
throw new Error(`Bullet content is required for bullet ${json.id}`);
|
|
47
|
+
}
|
|
48
|
+
return new Bullet(json.id, json.section, bulletContent, {
|
|
49
|
+
relatedFiles: json.metadata.relatedFiles,
|
|
50
|
+
tags: json.metadata.tags,
|
|
51
|
+
timestamp: json.metadata.timestamp,
|
|
52
|
+
}, json.memoryId);
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Formats the bullet for display in a playbook
|
|
56
|
+
*/
|
|
57
|
+
toDisplayString() {
|
|
58
|
+
const tags = this.metadata.tags.join(', ');
|
|
59
|
+
const tagDisplay = `[Tags: ${tags}]`;
|
|
60
|
+
const filesDisplay = this.metadata.relatedFiles.length > 0 ? `[Files: ${this.metadata.relatedFiles.join(', ')}]` : '[Files: none]';
|
|
61
|
+
const timestampDisplay = `[Updated: ${this.metadata.timestamp}]`;
|
|
62
|
+
const metadataDisplay = [tagDisplay, filesDisplay, timestampDisplay].join(' ');
|
|
63
|
+
return `- [${this.id}] ${this.content}\n ${this.section}\n ${metadataDisplay}`;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Converts the bullet to a JSON object
|
|
67
|
+
* @param includeContent If false, content field is omitted (for file-based storage)
|
|
68
|
+
*/
|
|
69
|
+
toJson(includeContent = true) {
|
|
70
|
+
const json = {
|
|
71
|
+
id: this.id,
|
|
72
|
+
memoryId: this.memoryId,
|
|
73
|
+
metadata: {
|
|
74
|
+
relatedFiles: this.metadata.relatedFiles,
|
|
75
|
+
tags: this.metadata.tags,
|
|
76
|
+
timestamp: this.metadata.timestamp,
|
|
77
|
+
},
|
|
78
|
+
section: this.section,
|
|
79
|
+
};
|
|
80
|
+
if (includeContent) {
|
|
81
|
+
json.content = this.content;
|
|
82
|
+
}
|
|
83
|
+
return json;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Creates a new bullet with updated content
|
|
87
|
+
*/
|
|
88
|
+
withUpdatedContent(content) {
|
|
89
|
+
return new Bullet(this.id, this.section, content, {
|
|
90
|
+
...this.metadata,
|
|
91
|
+
timestamp: new Date().toISOString(),
|
|
92
|
+
}, this.memoryId);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { DeltaBatch, type DeltaBatchJson } from './delta-batch.js';
|
|
2
|
+
/**
|
|
3
|
+
* Output from the curator phase.
|
|
4
|
+
* Contains the delta operations to apply to the playbook.
|
|
5
|
+
*/
|
|
6
|
+
export declare class CuratorOutput {
|
|
7
|
+
readonly delta: DeltaBatch;
|
|
8
|
+
constructor(delta: DeltaBatch);
|
|
9
|
+
/**
|
|
10
|
+
* Creates a CuratorOutput instance from a JSON object
|
|
11
|
+
*/
|
|
12
|
+
static fromJson(json: DeltaBatchJson): CuratorOutput;
|
|
13
|
+
toJson(): DeltaBatchJson;
|
|
14
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { DeltaBatch } from './delta-batch.js';
|
|
2
|
+
/**
|
|
3
|
+
* Output from the curator phase.
|
|
4
|
+
* Contains the delta operations to apply to the playbook.
|
|
5
|
+
*/
|
|
6
|
+
export class CuratorOutput {
|
|
7
|
+
delta;
|
|
8
|
+
constructor(delta) {
|
|
9
|
+
this.delta = delta;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Creates a CuratorOutput instance from a JSON object
|
|
13
|
+
*/
|
|
14
|
+
static fromJson(json) {
|
|
15
|
+
const delta = DeltaBatch.fromJson(json);
|
|
16
|
+
return new CuratorOutput(delta);
|
|
17
|
+
}
|
|
18
|
+
toJson() {
|
|
19
|
+
return {
|
|
20
|
+
...this.delta.toJson()
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { DeltaOperation, type DeltaOperationJson, type OperationType } from './delta-operation.js';
|
|
2
|
+
export interface DeltaBatchJson {
|
|
3
|
+
operations: DeltaOperationJson[];
|
|
4
|
+
reasoning: string;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Represents a batch of delta operations with curator reasoning.
|
|
8
|
+
*/
|
|
9
|
+
export declare class DeltaBatch {
|
|
10
|
+
readonly operations: DeltaOperation[];
|
|
11
|
+
readonly reasoning: string;
|
|
12
|
+
constructor(reasoning: string, operations: DeltaOperation[]);
|
|
13
|
+
/**
|
|
14
|
+
* Creates a DeltaBatch instance from a JSON object
|
|
15
|
+
*/
|
|
16
|
+
static fromJson(json: DeltaBatchJson): DeltaBatch;
|
|
17
|
+
/**
|
|
18
|
+
* Returns the count of operations
|
|
19
|
+
*/
|
|
20
|
+
getOperationCount(): number;
|
|
21
|
+
/**
|
|
22
|
+
* Returns operations grouped by type
|
|
23
|
+
*/
|
|
24
|
+
getOperationsByType(): Record<OperationType, DeltaOperation[]>;
|
|
25
|
+
/**
|
|
26
|
+
* Returns true if the batch has no operations
|
|
27
|
+
*/
|
|
28
|
+
isEmpty(): boolean;
|
|
29
|
+
toJson(): DeltaBatchJson;
|
|
30
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { DeltaOperation } from './delta-operation.js';
|
|
2
|
+
/**
|
|
3
|
+
* Represents a batch of delta operations with curator reasoning.
|
|
4
|
+
*/
|
|
5
|
+
export class DeltaBatch {
|
|
6
|
+
operations;
|
|
7
|
+
reasoning;
|
|
8
|
+
constructor(reasoning, operations) {
|
|
9
|
+
if (reasoning.trim().length === 0) {
|
|
10
|
+
throw new Error('Delta batch reasoning cannot be empty');
|
|
11
|
+
}
|
|
12
|
+
this.reasoning = reasoning;
|
|
13
|
+
this.operations = [...operations];
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Creates a DeltaBatch instance from a JSON object
|
|
17
|
+
*/
|
|
18
|
+
static fromJson(json) {
|
|
19
|
+
const operations = (json.operations ?? []).map((op) => DeltaOperation.fromJson(op));
|
|
20
|
+
return new DeltaBatch(json.reasoning, operations);
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Returns the count of operations
|
|
24
|
+
*/
|
|
25
|
+
getOperationCount() {
|
|
26
|
+
return this.operations.length;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Returns operations grouped by type
|
|
30
|
+
*/
|
|
31
|
+
getOperationsByType() {
|
|
32
|
+
const result = {};
|
|
33
|
+
for (const op of this.operations) {
|
|
34
|
+
if (!result[op.type])
|
|
35
|
+
result[op.type] = [];
|
|
36
|
+
result[op.type].push(op);
|
|
37
|
+
}
|
|
38
|
+
return result;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Returns true if the batch has no operations
|
|
42
|
+
*/
|
|
43
|
+
isEmpty() {
|
|
44
|
+
return this.operations.length === 0;
|
|
45
|
+
}
|
|
46
|
+
toJson() {
|
|
47
|
+
return {
|
|
48
|
+
operations: this.operations.map((op) => op.toJson()),
|
|
49
|
+
reasoning: this.reasoning,
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { BulletMetadata } from './bullet.js';
|
|
2
|
+
export type OperationType = 'ADD' | 'REMOVE' | 'UPDATE';
|
|
3
|
+
interface DeltaOperationOptions {
|
|
4
|
+
bulletId?: string;
|
|
5
|
+
content?: string;
|
|
6
|
+
metadata?: BulletMetadata;
|
|
7
|
+
}
|
|
8
|
+
export interface DeltaOperationJson {
|
|
9
|
+
bulletId?: string;
|
|
10
|
+
content?: string;
|
|
11
|
+
metadata?: BulletMetadata;
|
|
12
|
+
section: string;
|
|
13
|
+
type: OperationType;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Represents a single change operation to apply to a playbook.
|
|
17
|
+
*/
|
|
18
|
+
export declare class DeltaOperation {
|
|
19
|
+
readonly bulletId?: string;
|
|
20
|
+
readonly content?: string;
|
|
21
|
+
readonly metadata?: BulletMetadata;
|
|
22
|
+
readonly section: string;
|
|
23
|
+
readonly type: OperationType;
|
|
24
|
+
constructor(type: OperationType, section: string, options?: DeltaOperationOptions);
|
|
25
|
+
/**
|
|
26
|
+
* Creates a DeltaOperation instance from a JSON object
|
|
27
|
+
*/
|
|
28
|
+
static fromJson(json: DeltaOperationJson): DeltaOperation;
|
|
29
|
+
toJson(): DeltaOperationJson;
|
|
30
|
+
}
|
|
31
|
+
export {};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Represents a single change operation to apply to a playbook.
|
|
3
|
+
*/
|
|
4
|
+
export class DeltaOperation {
|
|
5
|
+
bulletId;
|
|
6
|
+
content;
|
|
7
|
+
metadata;
|
|
8
|
+
section;
|
|
9
|
+
type;
|
|
10
|
+
constructor(type, section, options = {}) {
|
|
11
|
+
const { bulletId, content, metadata } = options;
|
|
12
|
+
if (type === 'ADD' && !content) {
|
|
13
|
+
throw new Error('ADD operation requires content');
|
|
14
|
+
}
|
|
15
|
+
if (type === 'UPDATE' && !bulletId) {
|
|
16
|
+
throw new Error('UPDATE operation requires bulletId');
|
|
17
|
+
}
|
|
18
|
+
if (type === 'REMOVE' && !bulletId) {
|
|
19
|
+
throw new Error('REMOVE operation requires bulletId');
|
|
20
|
+
}
|
|
21
|
+
this.type = type;
|
|
22
|
+
this.section = section;
|
|
23
|
+
this.content = content;
|
|
24
|
+
this.bulletId = bulletId;
|
|
25
|
+
this.metadata = metadata;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Creates a DeltaOperation instance from a JSON object
|
|
29
|
+
*/
|
|
30
|
+
static fromJson(json) {
|
|
31
|
+
return new DeltaOperation(json.type, json.section, {
|
|
32
|
+
bulletId: json.bulletId,
|
|
33
|
+
content: json.content,
|
|
34
|
+
metadata: json.metadata,
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
toJson() {
|
|
38
|
+
const result = {
|
|
39
|
+
section: this.section,
|
|
40
|
+
type: this.type,
|
|
41
|
+
};
|
|
42
|
+
if (this.content !== undefined)
|
|
43
|
+
result.content = this.content;
|
|
44
|
+
if (this.bulletId !== undefined)
|
|
45
|
+
result.bulletId = this.bulletId;
|
|
46
|
+
if (this.metadata !== undefined)
|
|
47
|
+
result.metadata = this.metadata;
|
|
48
|
+
return result;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Array of all supported Events.
|
|
3
|
+
*/
|
|
4
|
+
export declare const EVENT_VALUES: readonly ["auth:signed_in", "space:init", "space:changed", "rule:generate", "ace:add_bullet", "ace:update_bullet", "ace:remove_bullet", "ace:view_status", "mem:push", "mem:retrieve"];
|
|
5
|
+
export type EventName = (typeof EVENT_VALUES)[number];
|
|
6
|
+
export interface PropertyDict {
|
|
7
|
+
[key: string]: any;
|
|
8
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Array of all supported Events.
|
|
3
|
+
*/
|
|
4
|
+
export const EVENT_VALUES = [
|
|
5
|
+
'auth:signed_in',
|
|
6
|
+
'space:init',
|
|
7
|
+
'space:changed',
|
|
8
|
+
'rule:generate',
|
|
9
|
+
'ace:add_bullet',
|
|
10
|
+
'ace:update_bullet',
|
|
11
|
+
'ace:remove_bullet',
|
|
12
|
+
'ace:view_status',
|
|
13
|
+
'mem:push',
|
|
14
|
+
'mem:retrieve',
|
|
15
|
+
];
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export interface ExecutorOutputJson {
|
|
2
|
+
bulletIds: string[];
|
|
3
|
+
finalAnswer: string;
|
|
4
|
+
hint: string;
|
|
5
|
+
reasoning: string;
|
|
6
|
+
toolUsage: string[];
|
|
7
|
+
}
|
|
8
|
+
export interface ExecutorOutputOptions {
|
|
9
|
+
bulletIds?: string[];
|
|
10
|
+
finalAnswer: string;
|
|
11
|
+
hint: string;
|
|
12
|
+
reasoning: string;
|
|
13
|
+
toolUsage?: string[];
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Output from the executor (the coding agent) phase.
|
|
17
|
+
* Contains reasoning, final answer, and bullets referenced.
|
|
18
|
+
*/
|
|
19
|
+
export declare class ExecutorOutput {
|
|
20
|
+
readonly bulletIds: string[];
|
|
21
|
+
readonly finalAnswer: string;
|
|
22
|
+
readonly hint: string;
|
|
23
|
+
readonly reasoning: string;
|
|
24
|
+
readonly toolUsage: string[];
|
|
25
|
+
constructor(options: ExecutorOutputOptions);
|
|
26
|
+
toJson(): ExecutorOutputJson;
|
|
27
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Output from the executor (the coding agent) phase.
|
|
3
|
+
* Contains reasoning, final answer, and bullets referenced.
|
|
4
|
+
*/
|
|
5
|
+
export class ExecutorOutput {
|
|
6
|
+
bulletIds;
|
|
7
|
+
finalAnswer;
|
|
8
|
+
hint;
|
|
9
|
+
reasoning;
|
|
10
|
+
toolUsage;
|
|
11
|
+
constructor(options) {
|
|
12
|
+
if (options.reasoning.trim().length === 0) {
|
|
13
|
+
throw new Error('Executor reasoning cannot be empty');
|
|
14
|
+
}
|
|
15
|
+
if (options.finalAnswer.trim().length === 0) {
|
|
16
|
+
throw new Error('Executor final answer cannot be empty');
|
|
17
|
+
}
|
|
18
|
+
this.hint = options.hint;
|
|
19
|
+
this.reasoning = options.reasoning;
|
|
20
|
+
this.finalAnswer = options.finalAnswer;
|
|
21
|
+
this.bulletIds = [...(options.bulletIds ?? [])];
|
|
22
|
+
this.toolUsage = [...(options.toolUsage ?? [])];
|
|
23
|
+
}
|
|
24
|
+
toJson() {
|
|
25
|
+
return {
|
|
26
|
+
bulletIds: this.bulletIds,
|
|
27
|
+
finalAnswer: this.finalAnswer,
|
|
28
|
+
hint: this.hint,
|
|
29
|
+
reasoning: this.reasoning,
|
|
30
|
+
toolUsage: this.toolUsage,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parameters for creating a Memory instance.
|
|
3
|
+
*
|
|
4
|
+
* Note: score, parentIds, and childrenIds are optional.
|
|
5
|
+
* These fields are present in primary memories (from the `memories` array)
|
|
6
|
+
* but absent in related memories (from the `related_memories` array).
|
|
7
|
+
*/
|
|
8
|
+
export type MemoryParams = {
|
|
9
|
+
bulletId: string;
|
|
10
|
+
childrenIds?: string[];
|
|
11
|
+
content: string;
|
|
12
|
+
id: string;
|
|
13
|
+
metadataType: string;
|
|
14
|
+
nodeKeys: string[];
|
|
15
|
+
parentIds?: string[];
|
|
16
|
+
score?: number;
|
|
17
|
+
section: string;
|
|
18
|
+
tags: string[];
|
|
19
|
+
timestamp: string;
|
|
20
|
+
title: string;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Represents a memory retrieved from the ByteRover Memora service.
|
|
24
|
+
* Memories are hierarchical knowledge fragments that can have parent and child relationships.
|
|
25
|
+
*
|
|
26
|
+
* Note: score, parentIds, and childrenIds are optional fields.
|
|
27
|
+
* - Primary memories (from API `memories` array) have these fields
|
|
28
|
+
* - Related memories (from API `related_memories` array) don't have these fields
|
|
29
|
+
*/
|
|
30
|
+
export declare class Memory {
|
|
31
|
+
readonly bulletId: string;
|
|
32
|
+
readonly childrenIds?: readonly string[];
|
|
33
|
+
readonly content: string;
|
|
34
|
+
readonly id: string;
|
|
35
|
+
readonly metadataType: string;
|
|
36
|
+
readonly nodeKeys: readonly string[];
|
|
37
|
+
readonly parentIds?: readonly string[];
|
|
38
|
+
readonly score?: number;
|
|
39
|
+
readonly section: string;
|
|
40
|
+
readonly tags: readonly string[];
|
|
41
|
+
readonly timestamp: string;
|
|
42
|
+
readonly title: string;
|
|
43
|
+
constructor(params: MemoryParams);
|
|
44
|
+
/**
|
|
45
|
+
* Creates a Memory instance from a JSON object.
|
|
46
|
+
* @param json JSON object representing the Memory
|
|
47
|
+
* @returns An instance of Memory
|
|
48
|
+
*/
|
|
49
|
+
static fromJson(json: MemoryParams): Memory;
|
|
50
|
+
/**
|
|
51
|
+
* Converts the Memory instance to a JSON object.
|
|
52
|
+
* @returns A JSON object representing the Memory
|
|
53
|
+
*/
|
|
54
|
+
toJson(): MemoryParams;
|
|
55
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Represents a memory retrieved from the ByteRover Memora service.
|
|
3
|
+
* Memories are hierarchical knowledge fragments that can have parent and child relationships.
|
|
4
|
+
*
|
|
5
|
+
* Note: score, parentIds, and childrenIds are optional fields.
|
|
6
|
+
* - Primary memories (from API `memories` array) have these fields
|
|
7
|
+
* - Related memories (from API `related_memories` array) don't have these fields
|
|
8
|
+
*/
|
|
9
|
+
export class Memory {
|
|
10
|
+
bulletId;
|
|
11
|
+
childrenIds;
|
|
12
|
+
content;
|
|
13
|
+
id;
|
|
14
|
+
metadataType;
|
|
15
|
+
nodeKeys;
|
|
16
|
+
parentIds;
|
|
17
|
+
score;
|
|
18
|
+
section;
|
|
19
|
+
tags;
|
|
20
|
+
timestamp;
|
|
21
|
+
title;
|
|
22
|
+
constructor(params) {
|
|
23
|
+
if (params.id.trim().length === 0) {
|
|
24
|
+
throw new Error('Memory ID cannot be empty');
|
|
25
|
+
}
|
|
26
|
+
if (params.bulletId.trim().length === 0) {
|
|
27
|
+
throw new Error('Memory bulletId cannot be empty');
|
|
28
|
+
}
|
|
29
|
+
if (params.title.trim().length === 0) {
|
|
30
|
+
throw new Error('Memory title cannot be empty');
|
|
31
|
+
}
|
|
32
|
+
if (params.content.trim().length === 0) {
|
|
33
|
+
throw new Error('Memory content cannot be empty');
|
|
34
|
+
}
|
|
35
|
+
if (params.section.trim().length === 0) {
|
|
36
|
+
throw new Error('Memory section cannot be empty');
|
|
37
|
+
}
|
|
38
|
+
if (params.timestamp.trim().length === 0) {
|
|
39
|
+
throw new Error('Memory timestamp cannot be empty');
|
|
40
|
+
}
|
|
41
|
+
if (params.metadataType.trim().length === 0) {
|
|
42
|
+
throw new Error('Memory metadataType cannot be empty');
|
|
43
|
+
}
|
|
44
|
+
// Only validate score if it's provided (primary memories have score, related memories don't)
|
|
45
|
+
if (params.score !== undefined && (params.score < 0 || params.score > 1)) {
|
|
46
|
+
throw new Error('Memory score must be between 0.0 and 1.0');
|
|
47
|
+
}
|
|
48
|
+
this.id = params.id;
|
|
49
|
+
this.bulletId = params.bulletId;
|
|
50
|
+
this.title = params.title;
|
|
51
|
+
this.content = params.content;
|
|
52
|
+
this.score = params.score;
|
|
53
|
+
this.section = params.section;
|
|
54
|
+
this.metadataType = params.metadataType;
|
|
55
|
+
this.timestamp = params.timestamp;
|
|
56
|
+
// Defensive copy to prevent external mutation
|
|
57
|
+
this.nodeKeys = [...params.nodeKeys];
|
|
58
|
+
this.parentIds = params.parentIds ? [...params.parentIds] : undefined;
|
|
59
|
+
this.childrenIds = params.childrenIds ? [...params.childrenIds] : undefined;
|
|
60
|
+
this.tags = [...params.tags];
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Creates a Memory instance from a JSON object.
|
|
64
|
+
* @param json JSON object representing the Memory
|
|
65
|
+
* @returns An instance of Memory
|
|
66
|
+
*/
|
|
67
|
+
static fromJson(json) {
|
|
68
|
+
return new Memory(json);
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Converts the Memory instance to a JSON object.
|
|
72
|
+
* @returns A JSON object representing the Memory
|
|
73
|
+
*/
|
|
74
|
+
toJson() {
|
|
75
|
+
return {
|
|
76
|
+
bulletId: this.bulletId,
|
|
77
|
+
...(this.childrenIds !== undefined && { childrenIds: [...this.childrenIds] }),
|
|
78
|
+
content: this.content,
|
|
79
|
+
id: this.id,
|
|
80
|
+
metadataType: this.metadataType,
|
|
81
|
+
nodeKeys: [...this.nodeKeys],
|
|
82
|
+
...(this.parentIds !== undefined && { parentIds: [...this.parentIds] }),
|
|
83
|
+
...(this.score !== undefined && { score: this.score }),
|
|
84
|
+
section: this.section,
|
|
85
|
+
tags: [...this.tags],
|
|
86
|
+
timestamp: this.timestamp,
|
|
87
|
+
title: this.title,
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Represents OAuth token data returned from the authorization server.
|
|
3
|
+
* This is an intermediate type that does not include user information.
|
|
4
|
+
* The login command will combine this with user data to create a complete AuthToken.
|
|
5
|
+
*/
|
|
6
|
+
export declare class OAuthTokenData {
|
|
7
|
+
readonly accessToken: string;
|
|
8
|
+
readonly expiresAt: Date;
|
|
9
|
+
readonly refreshToken: string;
|
|
10
|
+
readonly sessionKey: string;
|
|
11
|
+
readonly tokenType: string;
|
|
12
|
+
constructor(accessToken: string, expiresAt: Date, refreshToken: string, sessionKey: string, tokenType?: string);
|
|
13
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Represents OAuth token data returned from the authorization server.
|
|
3
|
+
* This is an intermediate type that does not include user information.
|
|
4
|
+
* The login command will combine this with user data to create a complete AuthToken.
|
|
5
|
+
*/
|
|
6
|
+
export class OAuthTokenData {
|
|
7
|
+
accessToken;
|
|
8
|
+
expiresAt;
|
|
9
|
+
refreshToken;
|
|
10
|
+
sessionKey;
|
|
11
|
+
tokenType;
|
|
12
|
+
// eslint-disable-next-line max-params
|
|
13
|
+
constructor(accessToken, expiresAt, refreshToken, sessionKey, tokenType = 'Bearer') {
|
|
14
|
+
this.accessToken = accessToken;
|
|
15
|
+
this.expiresAt = expiresAt;
|
|
16
|
+
this.refreshToken = refreshToken;
|
|
17
|
+
this.sessionKey = sessionKey;
|
|
18
|
+
this.tokenType = tokenType;
|
|
19
|
+
}
|
|
20
|
+
}
|