scai 0.1.42 → 0.1.43

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.
@@ -67,10 +67,12 @@ export async function runAskCommand(query) {
67
67
  console.log('⚠️ No similar files found. Asking the model using question only...');
68
68
  }
69
69
  // 🧠 Step 3: Build metadata for prompt
70
- const relatedFiles = combinedResults.slice(0, MAX_RELATED_FILES).map(file => ({
70
+ const relatedFiles = combinedResults.slice(0, MAX_RELATED_FILES).map((file, index) => ({
71
71
  path: file.path,
72
- summary: file.summary || '(No summary available)',
72
+ summary: file.summary || '(No summary available)', // Ensure summary is included
73
73
  }));
74
+ // Get the top-ranked file (the first one in the sorted results)
75
+ const topRankedFile = combinedResults[0]; // The most relevant file
74
76
  let fileTree = '';
75
77
  try {
76
78
  fileTree = generateFileTree(INDEX_DIR, 2); // Limit depth
@@ -78,17 +80,18 @@ export async function runAskCommand(query) {
78
80
  catch (e) {
79
81
  console.warn('⚠️ Failed to generate file tree:', e);
80
82
  }
81
- const prompt = buildContextualPrompt({
83
+ // Now we can build the prompt with summaries included for each file
84
+ const promptContent = buildContextualPrompt({
82
85
  baseInstruction: query,
83
86
  code: '', // No specific code selected
84
- relatedFiles,
87
+ relatedFiles, // This now includes both path and summary for each file
85
88
  projectFileTree: fileTree || undefined,
86
89
  });
87
90
  // 🧠 Step 4: Log prompt to file
88
91
  try {
89
92
  if (!fs.existsSync(SCAI_HOME))
90
93
  fs.mkdirSync(SCAI_HOME, { recursive: true });
91
- fs.writeFileSync(PROMPT_LOG_PATH, prompt, 'utf-8');
94
+ fs.writeFileSync(PROMPT_LOG_PATH, promptContent, 'utf-8');
92
95
  log(`📝 Prompt saved to ${PROMPT_LOG_PATH}`);
93
96
  }
94
97
  catch (err) {
@@ -97,9 +100,15 @@ export async function runAskCommand(query) {
97
100
  // 🧠 Step 5: Call the model
98
101
  try {
99
102
  console.log('🤖 Asking the model...');
103
+ // Create a more structured PromptInput object
100
104
  const input = {
101
- content: prompt,
102
- filepath: '',
105
+ content: query, // Main instruction (the query)
106
+ filepath: topRankedFile?.path || '', // Include the path of the top-ranked file
107
+ metadata: {
108
+ summary: topRankedFile?.summary || '', // Add summary of the top-ranked file
109
+ relatedFiles: relatedFiles, // Pass related files as part of metadata
110
+ },
111
+ projectFileTree: fileTree || '' // Include file structure in metadata
103
112
  };
104
113
  const modelResponse = await generate(input, 'llama3');
105
114
  console.log(`\n📝 Model response:\n${modelResponse.content}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "scai",
3
- "version": "0.1.42",
3
+ "version": "0.1.43",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "scai": "./dist/index.js"