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.
Files changed (193) hide show
  1. package/README.md +781 -0
  2. package/bin/dev.cmd +4 -0
  3. package/bin/dev.js +7 -0
  4. package/bin/run.cmd +4 -0
  5. package/bin/run.js +7 -0
  6. package/dist/commands/add.d.ts +60 -0
  7. package/dist/commands/add.js +230 -0
  8. package/dist/commands/clear.d.ts +13 -0
  9. package/dist/commands/clear.js +57 -0
  10. package/dist/commands/complete.d.ts +108 -0
  11. package/dist/commands/complete.js +340 -0
  12. package/dist/commands/gen-rules.d.ts +26 -0
  13. package/dist/commands/gen-rules.js +89 -0
  14. package/dist/commands/init.d.ts +24 -0
  15. package/dist/commands/init.js +135 -0
  16. package/dist/commands/login.d.ts +22 -0
  17. package/dist/commands/login.js +103 -0
  18. package/dist/commands/push.d.ts +33 -0
  19. package/dist/commands/push.js +150 -0
  20. package/dist/commands/retrieve.d.ts +26 -0
  21. package/dist/commands/retrieve.js +101 -0
  22. package/dist/commands/space/list.d.ts +22 -0
  23. package/dist/commands/space/list.js +105 -0
  24. package/dist/commands/space/switch.d.ts +20 -0
  25. package/dist/commands/space/switch.js +110 -0
  26. package/dist/commands/status.d.ts +22 -0
  27. package/dist/commands/status.js +116 -0
  28. package/dist/config/auth.config.d.ts +32 -0
  29. package/dist/config/auth.config.js +35 -0
  30. package/dist/config/environment.d.ts +35 -0
  31. package/dist/config/environment.js +39 -0
  32. package/dist/constants.d.ts +11 -0
  33. package/dist/constants.js +12 -0
  34. package/dist/core/domain/entities/agent.d.ts +5 -0
  35. package/dist/core/domain/entities/agent.js +23 -0
  36. package/dist/core/domain/entities/auth-token.d.ts +43 -0
  37. package/dist/core/domain/entities/auth-token.js +70 -0
  38. package/dist/core/domain/entities/br-config.d.ts +25 -0
  39. package/dist/core/domain/entities/br-config.js +58 -0
  40. package/dist/core/domain/entities/bullet.d.ts +51 -0
  41. package/dist/core/domain/entities/bullet.js +94 -0
  42. package/dist/core/domain/entities/curator-output.d.ts +14 -0
  43. package/dist/core/domain/entities/curator-output.js +23 -0
  44. package/dist/core/domain/entities/delta-batch.d.ts +30 -0
  45. package/dist/core/domain/entities/delta-batch.js +52 -0
  46. package/dist/core/domain/entities/delta-operation.d.ts +31 -0
  47. package/dist/core/domain/entities/delta-operation.js +50 -0
  48. package/dist/core/domain/entities/event.d.ts +8 -0
  49. package/dist/core/domain/entities/event.js +15 -0
  50. package/dist/core/domain/entities/executor-output.d.ts +27 -0
  51. package/dist/core/domain/entities/executor-output.js +33 -0
  52. package/dist/core/domain/entities/memory.d.ts +55 -0
  53. package/dist/core/domain/entities/memory.js +90 -0
  54. package/dist/core/domain/entities/oauth-token-data.d.ts +13 -0
  55. package/dist/core/domain/entities/oauth-token-data.js +20 -0
  56. package/dist/core/domain/entities/playbook.d.ts +97 -0
  57. package/dist/core/domain/entities/playbook.js +275 -0
  58. package/dist/core/domain/entities/presigned-url.d.ts +9 -0
  59. package/dist/core/domain/entities/presigned-url.js +18 -0
  60. package/dist/core/domain/entities/presigned-urls-response.d.ts +10 -0
  61. package/dist/core/domain/entities/presigned-urls-response.js +18 -0
  62. package/dist/core/domain/entities/reflector-output.d.ts +38 -0
  63. package/dist/core/domain/entities/reflector-output.js +44 -0
  64. package/dist/core/domain/entities/retrieve-result.d.ts +35 -0
  65. package/dist/core/domain/entities/retrieve-result.js +35 -0
  66. package/dist/core/domain/entities/space.d.ts +24 -0
  67. package/dist/core/domain/entities/space.js +52 -0
  68. package/dist/core/domain/entities/team.d.ts +42 -0
  69. package/dist/core/domain/entities/team.js +89 -0
  70. package/dist/core/domain/entities/user.d.ts +20 -0
  71. package/dist/core/domain/entities/user.js +32 -0
  72. package/dist/core/domain/errors/ace-error.d.ts +34 -0
  73. package/dist/core/domain/errors/ace-error.js +53 -0
  74. package/dist/core/domain/errors/auth-error.d.ts +10 -0
  75. package/dist/core/domain/errors/auth-error.js +20 -0
  76. package/dist/core/domain/errors/discovery-error.d.ts +21 -0
  77. package/dist/core/domain/errors/discovery-error.js +33 -0
  78. package/dist/core/domain/errors/rule-error.d.ts +6 -0
  79. package/dist/core/domain/errors/rule-error.js +12 -0
  80. package/dist/core/interfaces/i-ace-prompt-builder.d.ts +48 -0
  81. package/dist/core/interfaces/i-ace-prompt-builder.js +1 -0
  82. package/dist/core/interfaces/i-auth-service.d.ts +35 -0
  83. package/dist/core/interfaces/i-auth-service.js +1 -0
  84. package/dist/core/interfaces/i-browser-launcher.d.ts +11 -0
  85. package/dist/core/interfaces/i-browser-launcher.js +1 -0
  86. package/dist/core/interfaces/i-bullet-content-store.d.ts +36 -0
  87. package/dist/core/interfaces/i-bullet-content-store.js +1 -0
  88. package/dist/core/interfaces/i-callback-handler.d.ts +35 -0
  89. package/dist/core/interfaces/i-callback-handler.js +1 -0
  90. package/dist/core/interfaces/i-delta-store.d.ts +15 -0
  91. package/dist/core/interfaces/i-delta-store.js +1 -0
  92. package/dist/core/interfaces/i-executor-output-store.d.ts +14 -0
  93. package/dist/core/interfaces/i-executor-output-store.js +1 -0
  94. package/dist/core/interfaces/i-file-service.d.ts +34 -0
  95. package/dist/core/interfaces/i-file-service.js +1 -0
  96. package/dist/core/interfaces/i-http-client.d.ts +33 -0
  97. package/dist/core/interfaces/i-http-client.js +1 -0
  98. package/dist/core/interfaces/i-memory-retrieval-service.d.ts +40 -0
  99. package/dist/core/interfaces/i-memory-retrieval-service.js +1 -0
  100. package/dist/core/interfaces/i-memory-storage-service.d.ts +55 -0
  101. package/dist/core/interfaces/i-memory-storage-service.js +1 -0
  102. package/dist/core/interfaces/i-oidc-discovery-service.d.ts +20 -0
  103. package/dist/core/interfaces/i-oidc-discovery-service.js +1 -0
  104. package/dist/core/interfaces/i-playbook-service.d.ts +69 -0
  105. package/dist/core/interfaces/i-playbook-service.js +1 -0
  106. package/dist/core/interfaces/i-playbook-store.d.ts +38 -0
  107. package/dist/core/interfaces/i-playbook-store.js +1 -0
  108. package/dist/core/interfaces/i-project-config-store.d.ts +26 -0
  109. package/dist/core/interfaces/i-project-config-store.js +1 -0
  110. package/dist/core/interfaces/i-reflection-store.d.ts +21 -0
  111. package/dist/core/interfaces/i-reflection-store.js +1 -0
  112. package/dist/core/interfaces/i-rule-template-service.d.ts +17 -0
  113. package/dist/core/interfaces/i-rule-template-service.js +4 -0
  114. package/dist/core/interfaces/i-rule-writer-service.d.ts +13 -0
  115. package/dist/core/interfaces/i-rule-writer-service.js +1 -0
  116. package/dist/core/interfaces/i-space-service.d.ts +28 -0
  117. package/dist/core/interfaces/i-space-service.js +1 -0
  118. package/dist/core/interfaces/i-team-service.d.ts +29 -0
  119. package/dist/core/interfaces/i-team-service.js +1 -0
  120. package/dist/core/interfaces/i-template-loader.d.ts +29 -0
  121. package/dist/core/interfaces/i-template-loader.js +1 -0
  122. package/dist/core/interfaces/i-token-store.d.ts +22 -0
  123. package/dist/core/interfaces/i-token-store.js +1 -0
  124. package/dist/core/interfaces/i-tracking-service.d.ts +21 -0
  125. package/dist/core/interfaces/i-tracking-service.js +1 -0
  126. package/dist/core/interfaces/i-user-service.d.ts +14 -0
  127. package/dist/core/interfaces/i-user-service.js +1 -0
  128. package/dist/index.d.ts +1 -0
  129. package/dist/index.js +1 -0
  130. package/dist/infra/ace/ace-file-utils.d.ts +46 -0
  131. package/dist/infra/ace/ace-file-utils.js +83 -0
  132. package/dist/infra/ace/ace-prompt-templates.d.ts +13 -0
  133. package/dist/infra/ace/ace-prompt-templates.js +177 -0
  134. package/dist/infra/ace/file-bullet-content-store.d.ts +27 -0
  135. package/dist/infra/ace/file-bullet-content-store.js +89 -0
  136. package/dist/infra/ace/file-delta-store.d.ts +9 -0
  137. package/dist/infra/ace/file-delta-store.js +26 -0
  138. package/dist/infra/ace/file-executor-output-store.d.ts +9 -0
  139. package/dist/infra/ace/file-executor-output-store.js +26 -0
  140. package/dist/infra/ace/file-playbook-store.d.ts +29 -0
  141. package/dist/infra/ace/file-playbook-store.js +107 -0
  142. package/dist/infra/ace/file-reflection-store.d.ts +10 -0
  143. package/dist/infra/ace/file-reflection-store.js +55 -0
  144. package/dist/infra/auth/oauth-service.d.ts +49 -0
  145. package/dist/infra/auth/oauth-service.js +126 -0
  146. package/dist/infra/auth/oidc-discovery-service.d.ts +51 -0
  147. package/dist/infra/auth/oidc-discovery-service.js +145 -0
  148. package/dist/infra/browser/system-browser-launcher.d.ts +10 -0
  149. package/dist/infra/browser/system-browser-launcher.js +18 -0
  150. package/dist/infra/config/file-config-store.d.ts +21 -0
  151. package/dist/infra/config/file-config-store.js +57 -0
  152. package/dist/infra/file/fs-file-service.d.ts +28 -0
  153. package/dist/infra/file/fs-file-service.js +57 -0
  154. package/dist/infra/http/authenticated-http-client.d.ts +46 -0
  155. package/dist/infra/http/authenticated-http-client.js +99 -0
  156. package/dist/infra/http/callback-handler.d.ts +13 -0
  157. package/dist/infra/http/callback-handler.js +24 -0
  158. package/dist/infra/http/callback-server.d.ts +18 -0
  159. package/dist/infra/http/callback-server.js +93 -0
  160. package/dist/infra/memory/http-memory-retrieval-service.d.ts +18 -0
  161. package/dist/infra/memory/http-memory-retrieval-service.js +63 -0
  162. package/dist/infra/memory/http-memory-storage-service.d.ts +18 -0
  163. package/dist/infra/memory/http-memory-storage-service.js +67 -0
  164. package/dist/infra/memory/memory-to-playbook-mapper.d.ts +33 -0
  165. package/dist/infra/memory/memory-to-playbook-mapper.js +51 -0
  166. package/dist/infra/playbook/file-playbook-service.d.ts +43 -0
  167. package/dist/infra/playbook/file-playbook-service.js +133 -0
  168. package/dist/infra/rule/agent-rule-config.d.ts +19 -0
  169. package/dist/infra/rule/agent-rule-config.js +77 -0
  170. package/dist/infra/rule/rule-template-service.d.ts +18 -0
  171. package/dist/infra/rule/rule-template-service.js +80 -0
  172. package/dist/infra/rule/rule-writer-service.d.ts +19 -0
  173. package/dist/infra/rule/rule-writer-service.js +43 -0
  174. package/dist/infra/space/http-space-service.d.ts +20 -0
  175. package/dist/infra/space/http-space-service.js +67 -0
  176. package/dist/infra/storage/keychain-token-store.d.ts +10 -0
  177. package/dist/infra/storage/keychain-token-store.js +40 -0
  178. package/dist/infra/team/http-team-service.d.ts +21 -0
  179. package/dist/infra/team/http-team-service.js +71 -0
  180. package/dist/infra/template/fs-template-loader.d.ts +33 -0
  181. package/dist/infra/template/fs-template-loader.js +62 -0
  182. package/dist/infra/tracking/mixpanel-tracking-service.d.ts +14 -0
  183. package/dist/infra/tracking/mixpanel-tracking-service.js +44 -0
  184. package/dist/infra/user/http-user-service.d.ts +12 -0
  185. package/dist/infra/user/http-user-service.js +26 -0
  186. package/dist/templates/README.md +103 -0
  187. package/dist/templates/base.md +3 -0
  188. package/dist/templates/sections/command-reference.md +141 -0
  189. package/dist/templates/sections/workflow.md +46 -0
  190. package/dist/utils/file-helpers.d.ts +15 -0
  191. package/dist/utils/file-helpers.js +45 -0
  192. package/oclif.manifest.json +476 -0
  193. package/package.json +82 -0
package/bin/dev.cmd ADDED
@@ -0,0 +1,4 @@
1
+ @echo off
2
+
3
+ set BR_ENV=development
4
+ node --loader ts-node/esm --no-warnings=ExperimentalWarning "%~dp0\dev" %*
package/bin/dev.js ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env -S node --loader ts-node/esm --disable-warning=ExperimentalWarning
2
+
3
+ process.env.BR_ENV = 'development'
4
+
5
+ import {execute} from '@oclif/core'
6
+
7
+ await execute({development: true, dir: import.meta.url})
package/bin/run.cmd ADDED
@@ -0,0 +1,4 @@
1
+ @echo off
2
+
3
+ set BR_ENV=production
4
+ node "%~dp0\run" %*
package/bin/run.js ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env node
2
+
3
+ process.env.BR_ENV = 'production'
4
+
5
+ import {execute} from '@oclif/core'
6
+
7
+ await execute({dir: import.meta.url})
@@ -0,0 +1,60 @@
1
+ import { Command } from '@oclif/core';
2
+ import type { Bullet } from '../core/domain/entities/bullet.js';
3
+ import type { IPlaybookService } from '../core/interfaces/i-playbook-service.js';
4
+ import type { IPlaybookStore } from '../core/interfaces/i-playbook-store.js';
5
+ import type { ITrackingService } from '../core/interfaces/i-tracking-service.js';
6
+ type UserAction = 'add' | 'update';
7
+ interface SectionPromptOptions {
8
+ readonly existingSections: readonly string[];
9
+ readonly suggestedSections: readonly string[];
10
+ }
11
+ interface ContentPromptContext {
12
+ readonly action: UserAction;
13
+ readonly existingContent?: string;
14
+ readonly section: string;
15
+ }
16
+ export default class Add extends Command {
17
+ static description: string;
18
+ static examples: string[];
19
+ static flags: {
20
+ 'bullet-id': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
21
+ content: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
22
+ interactive: import("@oclif/core/interfaces").BooleanFlag<boolean>;
23
+ section: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
24
+ };
25
+ protected createServices(): {
26
+ playbookService: IPlaybookService;
27
+ playbookStore: IPlaybookStore;
28
+ trackingService: ITrackingService;
29
+ };
30
+ /**
31
+ * Prompt user to choose between adding a new bullet or updating an existing one
32
+ */
33
+ protected promptForAction(): Promise<UserAction>;
34
+ /**
35
+ * Prompt user to select a bullet to update
36
+ */
37
+ protected promptForBullet(bullets: Bullet[]): Promise<string>;
38
+ /**
39
+ * Prompt user to enter bullet content
40
+ */
41
+ protected promptForContent(context: ContentPromptContext): Promise<string>;
42
+ /**
43
+ * Prompt user to select or create a section name
44
+ */
45
+ protected promptForSection(options: SectionPromptOptions): Promise<string>;
46
+ run(): Promise<void>;
47
+ /**
48
+ * Display success message after adding or updating a bullet
49
+ */
50
+ private displaySuccess;
51
+ /**
52
+ * Run in flag-based mode (non-interactive)
53
+ */
54
+ private runFlagBased;
55
+ /**
56
+ * Run in interactive mode
57
+ */
58
+ private runInteractive;
59
+ }
60
+ export {};
@@ -0,0 +1,230 @@
1
+ import { input, search, select } from '@inquirer/prompts';
2
+ import { Command, Flags } from '@oclif/core';
3
+ import { Playbook } from '../core/domain/entities/playbook.js';
4
+ import { FilePlaybookStore } from '../infra/ace/file-playbook-store.js';
5
+ import { FilePlaybookService } from '../infra/playbook/file-playbook-service.js';
6
+ import { KeychainTokenStore } from '../infra/storage/keychain-token-store.js';
7
+ import { MixpanelTrackingService } from '../infra/tracking/mixpanel-tracking-service.js';
8
+ // Constants
9
+ const SUGGESTED_SECTIONS = [
10
+ 'Common Errors',
11
+ 'Best Practices',
12
+ 'Strategies',
13
+ 'Lessons Learned',
14
+ 'Architecture',
15
+ 'Testing',
16
+ ];
17
+ const validateContent = (content) => content.trim().length > 0;
18
+ export default class Add extends Command {
19
+ static description = 'Add or update a bullet in the playbook (bypasses ACE workflow for direct agent usage)';
20
+ static examples = [
21
+ '<%= config.bin %> <%= command.id %> --interactive',
22
+ '<%= config.bin %> <%= command.id %> -i',
23
+ '<%= config.bin %> <%= command.id %> --section "Common Errors" --content "Authentication fails when token expires"',
24
+ '<%= config.bin %> <%= command.id %> --section "Common Errors" --bullet-id "common-00001" --content "Updated: Auth fails when token expires"',
25
+ '<%= config.bin %> <%= command.id %> -s "Best Practices" -c "Always validate user input before processing"',
26
+ ];
27
+ static flags = {
28
+ 'bullet-id': Flags.string({
29
+ char: 'b',
30
+ description: 'Bullet ID to update (if not provided, a new bullet will be created)',
31
+ required: false,
32
+ }),
33
+ content: Flags.string({
34
+ char: 'c',
35
+ description: 'Content of the bullet',
36
+ required: false,
37
+ }),
38
+ interactive: Flags.boolean({
39
+ char: 'i',
40
+ default: false,
41
+ description: 'Run in interactive mode',
42
+ }),
43
+ section: Flags.string({
44
+ char: 's',
45
+ description: 'Section name for the bullet',
46
+ required: false,
47
+ }),
48
+ };
49
+ createServices() {
50
+ return {
51
+ playbookService: new FilePlaybookService(),
52
+ playbookStore: new FilePlaybookStore(),
53
+ trackingService: new MixpanelTrackingService(new KeychainTokenStore()),
54
+ };
55
+ }
56
+ /**
57
+ * Prompt user to choose between adding a new bullet or updating an existing one
58
+ */
59
+ async promptForAction() {
60
+ const action = await select({
61
+ choices: [
62
+ { name: 'Add a new bullet', value: 'add' },
63
+ { name: 'Update an existing bullet', value: 'update' },
64
+ ],
65
+ message: 'What would you like to do?',
66
+ });
67
+ return action;
68
+ }
69
+ /**
70
+ * Prompt user to select a bullet to update
71
+ */
72
+ async promptForBullet(bullets) {
73
+ const displayBullets = bullets.map((bullet) => ({
74
+ contentPreview: bullet.content.length > 60 ? `${bullet.content.slice(0, 60)}...` : bullet.content,
75
+ id: bullet.id,
76
+ section: bullet.section,
77
+ tags: bullet.metadata.tags,
78
+ timestamp: new Date(bullet.metadata.timestamp).toLocaleDateString(),
79
+ }));
80
+ const bulletId = await search({
81
+ message: 'Select a bullet to update:',
82
+ async source(input) {
83
+ const filtered = input
84
+ ? displayBullets.filter((b) => b.section.toLowerCase().includes(input.toLowerCase()) ||
85
+ b.contentPreview.toLowerCase().includes(input.toLowerCase()) ||
86
+ b.id.toLowerCase().includes(input.toLowerCase()))
87
+ : displayBullets;
88
+ return filtered.map((b) => ({
89
+ description: `Tags: ${b.tags.join(', ')} | Date: ${b.timestamp}`,
90
+ name: `[${b.id}] ${b.section}: ${b.contentPreview}`,
91
+ value: b.id,
92
+ }));
93
+ },
94
+ });
95
+ return bulletId;
96
+ }
97
+ /**
98
+ * Prompt user to enter bullet content
99
+ */
100
+ async promptForContent(context) {
101
+ const message = context.action === 'update'
102
+ ? `Enter new content for bullet in "${context.section}":`
103
+ : `Enter content for new bullet in "${context.section}":`;
104
+ const content = await input({
105
+ default: context.existingContent,
106
+ message,
107
+ validate(value) {
108
+ if (!validateContent(value)) {
109
+ return 'Content cannot be empty';
110
+ }
111
+ return true;
112
+ },
113
+ });
114
+ return content;
115
+ }
116
+ /**
117
+ * Prompt user to select or create a section name
118
+ */
119
+ async promptForSection(options) {
120
+ const allSections = [...new Set([...options.existingSections, ...options.suggestedSections])];
121
+ const section = await search({
122
+ message: 'Select or type a section name:',
123
+ async source(input) {
124
+ if (!input) {
125
+ return allSections.map((s) => ({ name: s, value: s }));
126
+ }
127
+ const filtered = allSections.filter((s) => s.toLowerCase().includes(input.toLowerCase()));
128
+ // Allow creating new section
129
+ if (filtered.length === 0 || !filtered.includes(input)) {
130
+ filtered.unshift(input);
131
+ }
132
+ return filtered.map((s) => ({ name: s, value: s }));
133
+ },
134
+ });
135
+ return section;
136
+ }
137
+ async run() {
138
+ const { flags } = await this.parse(Add);
139
+ return flags.interactive ? this.runInteractive() : this.runFlagBased(flags);
140
+ }
141
+ /**
142
+ * Display success message after adding or updating a bullet
143
+ */
144
+ displaySuccess(bullet, action) {
145
+ const actionText = action === 'update' ? 'Updated' : 'Added';
146
+ this.log(`\n✓ ${actionText} bullet successfully!`);
147
+ this.log(` ID: ${bullet.id}`);
148
+ this.log(` Section: ${bullet.section}`);
149
+ this.log(` Content: ${bullet.content}`);
150
+ if (bullet.metadata.tags.length > 0) {
151
+ this.log(` Tags: ${bullet.metadata.tags.join(', ')}`);
152
+ }
153
+ }
154
+ /**
155
+ * Run in flag-based mode (non-interactive)
156
+ */
157
+ async runFlagBased(flags) {
158
+ const { playbookService, trackingService } = this.createServices();
159
+ try {
160
+ // Validate required flags
161
+ if (!flags.section || !flags.content) {
162
+ this.error('--section and --content are required in non-interactive mode');
163
+ }
164
+ // Warn if section is not a standard ACE section
165
+ if (!SUGGESTED_SECTIONS.includes(flags.section)) {
166
+ this.warn(`Section "${flags.section}" is not a standard ACE section.\n` +
167
+ ` Suggested sections: ${SUGGESTED_SECTIONS.join(', ')}\n` +
168
+ ` You can still proceed, but consider using a standard section for consistency.`);
169
+ }
170
+ await trackingService.track('ace:add_bullet');
171
+ const bullet = await playbookService.addOrUpdateBullet({
172
+ bulletId: flags['bullet-id'],
173
+ content: flags.content,
174
+ section: flags.section,
175
+ });
176
+ this.displaySuccess(bullet, flags['bullet-id'] ? 'update' : 'add');
177
+ }
178
+ catch (error) {
179
+ this.error(error instanceof Error ? error.message : 'Unexpected error occurred');
180
+ }
181
+ }
182
+ /**
183
+ * Run in interactive mode
184
+ */
185
+ async runInteractive() {
186
+ const { playbookService, playbookStore, trackingService } = this.createServices();
187
+ try {
188
+ // Load existing playbook or create new one
189
+ let playbook = await playbookStore.load();
190
+ if (!playbook) {
191
+ playbook = new Playbook();
192
+ }
193
+ const action = await this.promptForAction();
194
+ const sectionOptions = {
195
+ existingSections: playbook.getSections(),
196
+ suggestedSections: SUGGESTED_SECTIONS,
197
+ };
198
+ const section = await this.promptForSection(sectionOptions);
199
+ let bulletId;
200
+ let existingContent;
201
+ if (action === 'update') {
202
+ const bullets = playbook.getBullets();
203
+ if (bullets.length === 0) {
204
+ this.warn('No bullets available to update. Creating new bullet instead.');
205
+ }
206
+ else {
207
+ bulletId = await this.promptForBullet(bullets);
208
+ const bullet = playbook.getBullet(bulletId);
209
+ existingContent = bullet?.content;
210
+ }
211
+ }
212
+ const contentContext = {
213
+ action: bulletId ? 'update' : 'add',
214
+ existingContent,
215
+ section,
216
+ };
217
+ const content = await this.promptForContent(contentContext);
218
+ const bullet = await playbookService.addOrUpdateBullet({
219
+ bulletId,
220
+ content,
221
+ section,
222
+ });
223
+ await trackingService.track('ace:add_bullet');
224
+ this.displaySuccess(bullet, bulletId ? 'update' : 'add');
225
+ }
226
+ catch (error) {
227
+ this.error(error instanceof Error ? error.message : 'Unexpected error occurred');
228
+ }
229
+ }
230
+ }
@@ -0,0 +1,13 @@
1
+ import { Command } from '@oclif/core';
2
+ export default class Clear extends Command {
3
+ static args: {
4
+ directory: import("@oclif/core/interfaces").Arg<string | undefined, Record<string, unknown>>;
5
+ };
6
+ static description: string;
7
+ static examples: string[];
8
+ static flags: {
9
+ yes: import("@oclif/core/interfaces").BooleanFlag<boolean>;
10
+ };
11
+ protected confirmClear(): Promise<boolean>;
12
+ run(): Promise<void>;
13
+ }
@@ -0,0 +1,57 @@
1
+ import { confirm } from '@inquirer/prompts';
2
+ import { Args, Command, Flags } from '@oclif/core';
3
+ import { Playbook } from '../core/domain/entities/playbook.js';
4
+ import { FilePlaybookStore } from '../infra/ace/file-playbook-store.js';
5
+ export default class Clear extends Command {
6
+ static args = {
7
+ directory: Args.string({ description: 'Project directory (defaults to current directory)', required: false }),
8
+ };
9
+ static description = 'Clear local ACE context (playbook) managed by ByteRover CLI';
10
+ static examples = [
11
+ '<%= config.bin %> <%= command.id %>',
12
+ '<%= config.bin %> <%= command.id %> --yes',
13
+ '<%= config.bin %> <%= command.id %> /path/to/project',
14
+ ];
15
+ static flags = {
16
+ yes: Flags.boolean({
17
+ char: 'y',
18
+ default: false,
19
+ description: 'Skip confirmation prompt',
20
+ }),
21
+ };
22
+ // Protected method for testability - can be overridden in tests
23
+ async confirmClear() {
24
+ return confirm({
25
+ default: false,
26
+ message: 'Are you sure you want to clear the playbook? This action cannot be undone.',
27
+ });
28
+ }
29
+ async run() {
30
+ const { args, flags } = await this.parse(Clear);
31
+ try {
32
+ // Setup dependencies
33
+ const playbookStore = new FilePlaybookStore();
34
+ // Check if playbook exists
35
+ const exists = await playbookStore.exists(args.directory);
36
+ if (!exists) {
37
+ this.log('No playbook found. Nothing to clear.');
38
+ return;
39
+ }
40
+ // Confirmation prompt (unless --yes flag is used)
41
+ if (!flags.yes) {
42
+ const confirmed = await this.confirmClear();
43
+ if (!confirmed) {
44
+ this.log('Cancelled. Playbook was not cleared.');
45
+ return;
46
+ }
47
+ }
48
+ // Reset the playbook to empty structure
49
+ const emptyPlaybook = new Playbook();
50
+ await playbookStore.save(emptyPlaybook, args.directory);
51
+ this.log('✓ Playbook cleared successfully.');
52
+ }
53
+ catch (error) {
54
+ this.error(error instanceof Error ? error.message : 'Failed to clear playbook');
55
+ }
56
+ }
57
+ }
@@ -0,0 +1,108 @@
1
+ import { Command } from '@oclif/core';
2
+ import type { IAcePromptBuilder } from '../core/interfaces/i-ace-prompt-builder.js';
3
+ import type { IDeltaStore } from '../core/interfaces/i-delta-store.js';
4
+ import type { IExecutorOutputStore } from '../core/interfaces/i-executor-output-store.js';
5
+ import type { IPlaybookService } from '../core/interfaces/i-playbook-service.js';
6
+ import type { IReflectionStore } from '../core/interfaces/i-reflection-store.js';
7
+ export default class Complete extends Command {
8
+ static args: {
9
+ hint: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
10
+ reasoning: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
11
+ finalAnswer: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
12
+ };
13
+ static description: string;
14
+ static examples: string[];
15
+ static flags: {
16
+ 'bullet-ids': import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
17
+ feedback: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
18
+ 'tool-usage': import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
19
+ 'update-bullet': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
20
+ };
21
+ protected createServices(): {
22
+ deltaStore: IDeltaStore;
23
+ executorOutputStore: IExecutorOutputStore;
24
+ playbookService: IPlaybookService;
25
+ promptBuilder: IAcePromptBuilder;
26
+ reflectionStore: IReflectionStore;
27
+ };
28
+ run(): Promise<void>;
29
+ /**
30
+ * Displays a formatted summary of the completed ACE workflow.
31
+ * Shows file paths, delta operations breakdown, and success confirmation.
32
+ *
33
+ * @param summary - Summary data containing all workflow outputs
34
+ * @param summary.curatorOutput - The curator output containing delta operations
35
+ * @param summary.deltaFilePath - Path to the saved delta file
36
+ * @param summary.executorPath - Path to the saved executor output file
37
+ * @param summary.hint - The hint used for naming output files
38
+ * @param summary.reflectionFilePath - Path to the saved reflection file
39
+ * @param summary.tagsApplied - Number of tags applied to the playbook
40
+ */
41
+ private displayFinalSummary;
42
+ /**
43
+ * Extracts file paths from tool usage strings and formats them with project name prefix.
44
+ * Converts tool usage entries like "Read:src/file.ts" to "projectName/src/file.ts".
45
+ * Filters out non-file-like arguments (e.g., "Bash:npm test" is excluded).
46
+ *
47
+ * @param toolUsage - Array of tool usage strings (e.g., ["Read:src/file.ts", "Edit:src/other.ts"])
48
+ * @returns Array of formatted file paths with project name prefix
49
+ */
50
+ private extractFilePaths;
51
+ /**
52
+ * Phase 3: Generates curation and applies delta operations to the playbook.
53
+ * Creates delta operations (ADD or UPDATE) based on reflection insights and applies them to the playbook.
54
+ *
55
+ * @param services - The service instances
56
+ * @param services.deltaStore - Delta store for persisting deltas
57
+ * @param services.playbookService - Playbook service for applying deltas
58
+ * @param services.promptBuilder - Prompt builder for curation prompts
59
+ * @param reflection - The reflection output from Phase 2
60
+ * @param executorOutput - The executor output from Phase 1
61
+ * @param flags - Command flags containing optional update-bullet ID
62
+ * @returns Object containing curator output and delta file path
63
+ */
64
+ private generateCurationAndApplyDelta;
65
+ /**
66
+ * Phase 2: Generates reflection based on executor output and applies tags to the playbook.
67
+ * Auto-generates reflection analysis from feedback and applies bullet tags to relevant playbook sections.
68
+ *
69
+ * @param services - The service instances
70
+ * @param services.playbookService - Playbook service for applying reflection tags
71
+ * @param services.promptBuilder - Prompt builder for reflection prompts
72
+ * @param services.reflectionStore - Reflection store for persisting reflections
73
+ * @param executorOutput - The executor output from Phase 1
74
+ * @param feedback - Environment feedback about task execution (e.g., "Tests passed", "Build failed")
75
+ * @returns Object containing reflection output, file path, and number of tags applied
76
+ */
77
+ private generateReflectionAndApplyTags;
78
+ /**
79
+ * Parses comma-separated bullet IDs string into an array of trimmed IDs.
80
+ * Empty strings and whitespace-only entries are filtered out.
81
+ *
82
+ * @param bulletIdsStr - Comma-separated string of bullet IDs (e.g., "bullet-1, bullet-2")
83
+ * @returns Array of trimmed bullet ID strings (empty array if input is empty string)
84
+ */
85
+ private parseBulletIds;
86
+ /**
87
+ * Parses comma-separated tool usage string into an array of trimmed entries.
88
+ * Empty strings and whitespace-only entries are filtered out.
89
+ *
90
+ * @param toolUsageStr - Comma-separated string of tool usage (e.g., "Read:file.ts, Edit:other.ts")
91
+ * @returns Array of trimmed tool usage strings
92
+ */
93
+ private parseToolUsage;
94
+ /**
95
+ * Phase 1: Saves executor output to a file.
96
+ * Creates an ExecutorOutput entity from command arguments and persists it using the executor output store service.
97
+ *
98
+ * @param executorOutputStore - The executor output store service
99
+ * @param args - Command arguments
100
+ * @param args.hint - Short hint for naming output files
101
+ * @param args.reasoning - Detailed reasoning and approach for completing the task
102
+ * @param args.finalAnswer - The final answer/solution to the task
103
+ * @param bulletIds - Array of playbook bullet IDs referenced during task execution
104
+ * @param toolUsage - Array of tool usage strings (e.g., ["Read:src/file.ts", "Bash:npm test"])
105
+ * @returns Object containing the executor output entity and file path where it was saved
106
+ */
107
+ private saveExecutorOutput;
108
+ }