sam-coder-cli 2.0.4 → 2.0.7

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.
@@ -1,217 +0,0 @@
1
- /**
2
- * Finish Brainstorm Module - Complete a Brainstorm Session
3
- *
4
- * Finalizes a brainstorm session, generates mutual summaries,
5
- * and marks the session as completed.
6
- * Ported from Python to JavaScript.
7
- */
8
-
9
- const fs = require('fs').promises;
10
- const path = require('path');
11
- const { BrainstormSession, SessionResult } = require('./models');
12
-
13
- /**
14
- * Complete a brainstorm session
15
- *
16
- * @param {Object} options
17
- * @param {string} options.sessionDir - Directory containing the session
18
- * @param {string} options.summary - Summary of what was accomplished
19
- * @param {string} options.actor - Who is completing the session
20
- * @param {string[]} options.nextSteps - Optional list of next steps
21
- * @returns {Promise<SessionResult>}
22
- */
23
- async function finishBrainstorm({ sessionDir, summary, actor = 'CLAUDE-1', nextSteps = [] }) {
24
- const sessionFile = path.join(sessionDir, 'SESSION.json');
25
-
26
- // Check if session exists
27
- try {
28
- await fs.access(sessionFile);
29
- } catch {
30
- return new SessionResult({
31
- success: false,
32
- sessionId: '',
33
- status: 'FAILED',
34
- summary: 'Session file not found',
35
- errors: ['SESSION.json not found in the specified directory']
36
- });
37
- }
38
-
39
- // Load session
40
- const session = await BrainstormSession.load(sessionFile);
41
-
42
- // Check if already completed
43
- if (session.status === 'COMPLETED') {
44
- return new SessionResult({
45
- success: false,
46
- sessionId: session.id,
47
- status: 'ALREADY_COMPLETED',
48
- summary: 'Session was already completed',
49
- errors: ['Session is already in COMPLETED status']
50
- });
51
- }
52
-
53
- // Generate mutual summary
54
- const mutualSummary = generateMutualSummary({ session, summary, actor, nextSteps });
55
-
56
- // Update PROGRESS_REPORT.md with completion info
57
- await updateProgressReport({ session, mutualSummary, actor });
58
-
59
- // Update SECONDARY-AI-CHAT.md if it exists
60
- const secondaryChatPath = path.join(session.outputDirectory, 'SECONDARY-AI-CHAT.md');
61
- try {
62
- await fs.access(secondaryChatPath);
63
- await updateSecondaryChat({ session, summary, actor });
64
- } catch { }
65
-
66
- // Mark session as completed
67
- session.status = 'COMPLETED';
68
- session.mutualSummary = summary;
69
-
70
- // Add completion event
71
- session.addEvent({
72
- eventType: 'COMPLETED',
73
- actor,
74
- description: `Session completed: ${summary}`,
75
- affectedFiles: Object.keys(session.fileVersions)
76
- });
77
-
78
- // Save updated session
79
- await session.save();
80
-
81
- return new SessionResult({
82
- success: true,
83
- sessionId: session.id,
84
- status: 'COMPLETED',
85
- summary,
86
- filesGenerated: Object.keys(session.fileVersions)
87
- });
88
- }
89
-
90
- /**
91
- * Generate the mutual summary text
92
- */
93
- function generateMutualSummary({ session, summary, actor, nextSteps }) {
94
- const timestamp = new Date().toISOString();
95
-
96
- let result = `
97
- ## 🏁 MUTUAL SUMMARY
98
-
99
- **Session ID**: ${session.id}
100
- **Completed At**: ${timestamp}
101
- **Completed By**: ${actor}
102
-
103
- ### What Was Accomplished:
104
- ${summary}
105
-
106
- `;
107
-
108
- if (nextSteps && nextSteps.length > 0) {
109
- result += '### Next Steps:\n';
110
- nextSteps.forEach((step, i) => {
111
- result += `${i + 1}. ${step}\n`;
112
- });
113
- result += '\n';
114
- }
115
-
116
- // Add history summary (last 5 events)
117
- result += '### Session History:\n';
118
- const recentEvents = session.history.slice(-5);
119
- recentEvents.forEach(event => {
120
- result += `- [${event.eventType}] ${event.description} (${event.actor})\n`;
121
- });
122
-
123
- return result;
124
- }
125
-
126
- /**
127
- * Update PROGRESS_REPORT.md with completion information
128
- */
129
- async function updateProgressReport({ session, mutualSummary, actor }) {
130
- const progressFile = path.join(session.outputDirectory, 'PROGRESS_REPORT.md');
131
-
132
- try {
133
- await fs.access(progressFile);
134
- } catch {
135
- return; // File doesn't exist
136
- }
137
-
138
- // Read current content
139
- let content = await fs.readFile(progressFile, 'utf-8');
140
-
141
- // Add completion block
142
- const completionBlock = `
143
-
144
- ---
145
-
146
- ${mutualSummary}
147
-
148
- ---
149
-
150
- **Final Status**: COMPLETED
151
- **Last Updated**: ${new Date().toISOString().replace('T', ' ').split('.')[0]} by ${actor}
152
- `;
153
-
154
- content += completionBlock;
155
- await fs.writeFile(progressFile, content, 'utf-8');
156
-
157
- // Increment version
158
- session.incrementFileVersion('PROGRESS_REPORT.md');
159
- }
160
-
161
- /**
162
- * Update SECONDARY-AI-CHAT.md with completion log
163
- */
164
- async function updateSecondaryChat({ session, summary, actor }) {
165
- const chatFile = path.join(session.outputDirectory, 'SECONDARY-AI-CHAT.md');
166
-
167
- try {
168
- await fs.access(chatFile);
169
- } catch {
170
- return; // File doesn't exist
171
- }
172
-
173
- // Read current content
174
- let content = await fs.readFile(chatFile, 'utf-8');
175
-
176
- // Add completion entry
177
- const completionEntry = `
178
- ---
179
-
180
- [${actor}] COMPLETED: Session completed
181
- Timestamp: ${new Date().toISOString()}
182
- Summary: ${summary}
183
- Status: SUCCESS ✅
184
- Notes: All brainstorm files finalized. Session ready for execution phase.
185
-
186
- ---
187
- `;
188
-
189
- content += completionEntry;
190
- await fs.writeFile(chatFile, content, 'utf-8');
191
-
192
- // Increment version
193
- session.incrementFileVersion('SECONDARY-AI-CHAT.md');
194
- }
195
-
196
- /**
197
- * Get the current status of a session
198
- *
199
- * @param {string} sessionDir - Directory containing the session
200
- * @returns {Promise<string>}
201
- */
202
- async function getStatus(sessionDir) {
203
- const sessionFile = path.join(sessionDir, 'SESSION.json');
204
-
205
- try {
206
- await fs.access(sessionFile);
207
- const session = await BrainstormSession.load(sessionFile);
208
- return session.status;
209
- } catch {
210
- return 'NOT_FOUND';
211
- }
212
- }
213
-
214
- module.exports = {
215
- finishBrainstorm,
216
- getStatus
217
- };
package/bin/core/index.js DELETED
@@ -1,37 +0,0 @@
1
- /**
2
- * Brainstorm Core - Main Entry Point
3
- *
4
- * Exports all brainstorm modules for use in the CLI.
5
- */
6
-
7
- const models = require('./models');
8
- const brainstorm = require('./brainstorm');
9
- const finishBrainstorm = require('./finish_brainstorm');
10
- const editFinishedBrainstorm = require('./edit_finished_brainstorm');
11
- const templates = require('./templates');
12
-
13
- module.exports = {
14
- // Models
15
- ...models,
16
-
17
- // Brainstorm
18
- startBrainstorm: brainstorm.startBrainstorm,
19
- getSession: brainstorm.getSession,
20
- listFiles: brainstorm.listFiles,
21
- quickStart: brainstorm.quickStart,
22
-
23
- // Finish
24
- finishBrainstorm: finishBrainstorm.finishBrainstorm,
25
- getStatus: finishBrainstorm.getStatus,
26
-
27
- // Edit
28
- editBrainstormFile: editFinishedBrainstorm.editBrainstormFile,
29
- getHistory: editFinishedBrainstorm.getHistory,
30
- getVersions: editFinishedBrainstorm.getVersions,
31
- restoreVersion: editFinishedBrainstorm.restoreVersion,
32
- listBackups: editFinishedBrainstorm.listBackups,
33
- EditResult: editFinishedBrainstorm.EditResult,
34
-
35
- // Templates (for custom usage)
36
- templates
37
- };
@@ -1,290 +0,0 @@
1
- /**
2
- * Brainstorm Core - Models
3
- *
4
- * Data models for project configuration, agent configuration, and session state.
5
- * Ported from Python to JavaScript.
6
- */
7
-
8
- const fs = require('fs').promises;
9
- const path = require('path');
10
-
11
- /**
12
- * Agent configuration - defines an individual AI agent
13
- */
14
- class AgentConfig {
15
- constructor({
16
- id,
17
- name,
18
- description,
19
- priority = 'MEDIUM',
20
- inputs = [],
21
- outputs = [],
22
- technologies = [],
23
- validationRules = [],
24
- territory = []
25
- }) {
26
- this.id = id;
27
- this.name = name;
28
- this.description = description;
29
- this.priority = priority; // 'LOW', 'MEDIUM', 'HIGH'
30
- this.inputs = inputs;
31
- this.outputs = outputs;
32
- this.technologies = technologies;
33
- this.validationRules = validationRules;
34
- this.territory = territory;
35
- }
36
-
37
- toJSON() {
38
- return {
39
- id: this.id,
40
- name: this.name,
41
- description: this.description,
42
- priority: this.priority,
43
- inputs: this.inputs,
44
- outputs: this.outputs,
45
- technologies: this.technologies,
46
- validationRules: this.validationRules,
47
- territory: this.territory
48
- };
49
- }
50
-
51
- static fromJSON(data) {
52
- return new AgentConfig(data);
53
- }
54
- }
55
-
56
- /**
57
- * Project configuration - defines project-level details
58
- */
59
- class ProjectConfig {
60
- constructor({
61
- name,
62
- description,
63
- version = '1.0',
64
- agents = [],
65
- dataModel = {},
66
- technologyStack = [],
67
- governanceRules = [],
68
- successCriteria = [],
69
- directoryStructure = {},
70
- inputFiles = []
71
- }) {
72
- this.name = name;
73
- this.description = description;
74
- this.version = version;
75
- this.agents = agents.map(a => a instanceof AgentConfig ? a : new AgentConfig(a));
76
- this.dataModel = dataModel;
77
- this.technologyStack = technologyStack;
78
- this.governanceRules = governanceRules;
79
- this.successCriteria = successCriteria;
80
- this.directoryStructure = directoryStructure;
81
- this.inputFiles = inputFiles;
82
- }
83
-
84
- getAgent(id) {
85
- return this.agents.find(a => a.id === id);
86
- }
87
-
88
- toJSON() {
89
- return {
90
- name: this.name,
91
- description: this.description,
92
- version: this.version,
93
- agents: this.agents.map(a => a.toJSON()),
94
- dataModel: this.dataModel,
95
- technologyStack: this.technologyStack,
96
- governanceRules: this.governanceRules,
97
- successCriteria: this.successCriteria,
98
- directoryStructure: this.directoryStructure,
99
- inputFiles: this.inputFiles
100
- };
101
- }
102
-
103
- static fromJSON(data) {
104
- return new ProjectConfig({
105
- ...data,
106
- agents: (data.agents || []).map(a => AgentConfig.fromJSON(a))
107
- });
108
- }
109
- }
110
-
111
- /**
112
- * Session event - logs individual events within a session
113
- */
114
- class SessionEvent {
115
- constructor({
116
- timestamp = new Date().toISOString(),
117
- eventType,
118
- actor,
119
- description,
120
- affectedFiles = []
121
- }) {
122
- this.timestamp = timestamp;
123
- this.eventType = eventType; // 'CREATED', 'UPDATED', 'EDITED', 'COMPLETED'
124
- this.actor = actor;
125
- this.description = description;
126
- this.affectedFiles = affectedFiles;
127
- }
128
-
129
- toJSON() {
130
- return {
131
- timestamp: this.timestamp,
132
- eventType: this.eventType,
133
- actor: this.actor,
134
- description: this.description,
135
- affectedFiles: this.affectedFiles
136
- };
137
- }
138
-
139
- static fromJSON(data) {
140
- return new SessionEvent(data);
141
- }
142
- }
143
-
144
- /**
145
- * Brainstorm session - manages session state
146
- */
147
- class BrainstormSession {
148
- constructor({
149
- id,
150
- project,
151
- createdAt = new Date().toISOString(),
152
- updatedAt = new Date().toISOString(),
153
- status = 'ACTIVE',
154
- agentsParticipating = [],
155
- outputDirectory,
156
- history = [],
157
- fileVersions = {},
158
- mutualSummary = null
159
- }) {
160
- this.id = id;
161
- this.project = project instanceof ProjectConfig ? project : ProjectConfig.fromJSON(project);
162
- this.createdAt = createdAt;
163
- this.updatedAt = updatedAt;
164
- this.status = status; // 'ACTIVE', 'COMPLETED', 'ARCHIVED'
165
- this.agentsParticipating = agentsParticipating;
166
- this.outputDirectory = outputDirectory;
167
- this.history = history.map(e => e instanceof SessionEvent ? e : SessionEvent.fromJSON(e));
168
- this.fileVersions = fileVersions;
169
- this.mutualSummary = mutualSummary;
170
- }
171
-
172
- static create({ project, outputDirectory, agents = ['CLAUDE-1'] }) {
173
- const session = new BrainstormSession({
174
- id: `session-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`,
175
- project,
176
- outputDirectory,
177
- agentsParticipating: agents
178
- });
179
-
180
- session.addEvent({
181
- eventType: 'CREATED',
182
- actor: 'BRAINSTORM',
183
- description: `Brainstorm session created for project '${project.name}'`
184
- });
185
-
186
- return session;
187
- }
188
-
189
- addEvent({ eventType, actor, description, affectedFiles = [] }) {
190
- this.history.push(new SessionEvent({
191
- eventType,
192
- actor,
193
- description,
194
- affectedFiles
195
- }));
196
- this.updatedAt = new Date().toISOString();
197
- }
198
-
199
- getFileVersion(fileName) {
200
- return this.fileVersions[fileName] || 0;
201
- }
202
-
203
- incrementFileVersion(fileName) {
204
- this.fileVersions[fileName] = (this.fileVersions[fileName] || 0) + 1;
205
- return this.fileVersions[fileName];
206
- }
207
-
208
- toJSON() {
209
- return {
210
- id: this.id,
211
- project: this.project.toJSON(),
212
- createdAt: this.createdAt,
213
- updatedAt: this.updatedAt,
214
- status: this.status,
215
- agentsParticipating: this.agentsParticipating,
216
- outputDirectory: this.outputDirectory,
217
- history: this.history.map(e => e.toJSON()),
218
- fileVersions: this.fileVersions,
219
- mutualSummary: this.mutualSummary
220
- };
221
- }
222
-
223
- static fromJSON(data) {
224
- return new BrainstormSession(data);
225
- }
226
-
227
- async save(filePath = null) {
228
- const savePath = filePath || path.join(this.outputDirectory, 'SESSION.json');
229
- await fs.writeFile(savePath, JSON.stringify(this.toJSON(), null, 2), 'utf-8');
230
- return savePath;
231
- }
232
-
233
- static async load(filePath) {
234
- const content = await fs.readFile(filePath, 'utf-8');
235
- return BrainstormSession.fromJSON(JSON.parse(content));
236
- }
237
- }
238
-
239
- /**
240
- * Session result - encapsulates outcome of operations
241
- */
242
- class SessionResult {
243
- constructor({
244
- success,
245
- sessionId,
246
- status,
247
- summary,
248
- filesGenerated = [],
249
- errors = []
250
- }) {
251
- this.success = success;
252
- this.sessionId = sessionId;
253
- this.status = status;
254
- this.summary = summary;
255
- this.filesGenerated = filesGenerated;
256
- this.errors = errors;
257
- }
258
- }
259
-
260
- /**
261
- * Edit info - tracks edits made to completed files
262
- */
263
- class EditInfo {
264
- constructor({
265
- timestamp = new Date().toISOString(),
266
- filePath,
267
- editor,
268
- description,
269
- versionBefore,
270
- versionAfter,
271
- backupPath = null
272
- }) {
273
- this.timestamp = timestamp;
274
- this.filePath = filePath;
275
- this.editor = editor;
276
- this.description = description;
277
- this.versionBefore = versionBefore;
278
- this.versionAfter = versionAfter;
279
- this.backupPath = backupPath;
280
- }
281
- }
282
-
283
- module.exports = {
284
- AgentConfig,
285
- ProjectConfig,
286
- SessionEvent,
287
- BrainstormSession,
288
- SessionResult,
289
- EditInfo
290
- };