codeep 2.5.0 → 2.5.1
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.
|
@@ -126,6 +126,74 @@ export function saveProjectIntelligence(projectPath, intelligence) {
|
|
|
126
126
|
return false;
|
|
127
127
|
}
|
|
128
128
|
}
|
|
129
|
+
/**
|
|
130
|
+
* Complete default intelligence skeleton — every nested section is present so
|
|
131
|
+
* consumers (e.g. generateContextFromIntelligence) never dereference an
|
|
132
|
+
* undefined section. Used as the merge base when normalizing a loaded file.
|
|
133
|
+
*/
|
|
134
|
+
function createBaseIntelligence(projectPath) {
|
|
135
|
+
return {
|
|
136
|
+
version: INTELLIGENCE_VERSION,
|
|
137
|
+
scannedAt: new Date().toISOString(),
|
|
138
|
+
projectPath,
|
|
139
|
+
name: basename(projectPath),
|
|
140
|
+
type: 'Unknown',
|
|
141
|
+
description: '',
|
|
142
|
+
structure: {
|
|
143
|
+
totalFiles: 0,
|
|
144
|
+
totalDirectories: 0,
|
|
145
|
+
languages: {},
|
|
146
|
+
topDirectories: [],
|
|
147
|
+
},
|
|
148
|
+
dependencies: {
|
|
149
|
+
runtime: [],
|
|
150
|
+
dev: [],
|
|
151
|
+
frameworks: [],
|
|
152
|
+
},
|
|
153
|
+
keyFiles: [],
|
|
154
|
+
entryPoints: [],
|
|
155
|
+
scripts: {},
|
|
156
|
+
architecture: {
|
|
157
|
+
patterns: [],
|
|
158
|
+
mainModules: [],
|
|
159
|
+
ciSystem: null,
|
|
160
|
+
containerization: [],
|
|
161
|
+
monorepoTool: null,
|
|
162
|
+
},
|
|
163
|
+
conventions: {
|
|
164
|
+
indentation: 'spaces',
|
|
165
|
+
quotes: 'single',
|
|
166
|
+
semicolons: true,
|
|
167
|
+
namingStyle: 'camelCase',
|
|
168
|
+
},
|
|
169
|
+
testing: {
|
|
170
|
+
framework: null,
|
|
171
|
+
testDirectory: null,
|
|
172
|
+
hasTests: false,
|
|
173
|
+
},
|
|
174
|
+
notes: [],
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Merge a loaded (possibly partial or older-schema) intelligence object over
|
|
179
|
+
* the complete default skeleton so every nested section is guaranteed present.
|
|
180
|
+
* An interrupted scan or an older CLI can write a file that is missing whole
|
|
181
|
+
* sections (e.g. `conventions`); without this, reading `conventions.indentation`
|
|
182
|
+
* downstream throws "Cannot read properties of undefined". Nested objects are
|
|
183
|
+
* merged per-section so partial sub-objects are also backfilled.
|
|
184
|
+
*/
|
|
185
|
+
function normalizeIntelligence(data, projectPath) {
|
|
186
|
+
const base = createBaseIntelligence(projectPath);
|
|
187
|
+
return {
|
|
188
|
+
...base,
|
|
189
|
+
...data,
|
|
190
|
+
structure: { ...base.structure, ...data.structure },
|
|
191
|
+
dependencies: { ...base.dependencies, ...data.dependencies },
|
|
192
|
+
architecture: { ...base.architecture, ...data.architecture },
|
|
193
|
+
conventions: { ...base.conventions, ...data.conventions },
|
|
194
|
+
testing: { ...base.testing, ...data.testing },
|
|
195
|
+
};
|
|
196
|
+
}
|
|
129
197
|
/**
|
|
130
198
|
* Load intelligence from .codeep/intelligence.json
|
|
131
199
|
*/
|
|
@@ -135,9 +203,13 @@ export function loadProjectIntelligence(projectPath) {
|
|
|
135
203
|
if (!existsSync(filePath))
|
|
136
204
|
return null;
|
|
137
205
|
const data = JSON.parse(readFileSync(filePath, 'utf-8'));
|
|
206
|
+
if (!data || typeof data !== 'object')
|
|
207
|
+
return null;
|
|
138
208
|
if (data.version !== INTELLIGENCE_VERSION)
|
|
139
209
|
return null;
|
|
140
|
-
|
|
210
|
+
// Backfill any missing sections so a partial/interrupted file can't crash
|
|
211
|
+
// downstream consumers that assume a complete shape.
|
|
212
|
+
return normalizeIntelligence(data, projectPath);
|
|
141
213
|
}
|
|
142
214
|
catch {
|
|
143
215
|
return null;
|
|
@@ -159,6 +231,10 @@ export function isIntelligenceFresh(projectPath, maxAgeHours = 24) {
|
|
|
159
231
|
* Generate AI-friendly context from intelligence
|
|
160
232
|
*/
|
|
161
233
|
export function generateContextFromIntelligence(intelligence) {
|
|
234
|
+
// Defensive: backfill any missing sections so a partial object (e.g. from an
|
|
235
|
+
// older/interrupted scan, or an external SDK caller) can't crash the
|
|
236
|
+
// formatter on a nested dereference like `conventions.indentation`.
|
|
237
|
+
intelligence = normalizeIntelligence((intelligence ?? {}), intelligence?.projectPath ?? '');
|
|
162
238
|
const lines = [];
|
|
163
239
|
lines.push(`# Project: ${intelligence.name}`);
|
|
164
240
|
lines.push(`Type: ${intelligence.type}`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "codeep",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.1",
|
|
4
4
|
"description": "AI-powered coding assistant built for the terminal. Multiple LLM providers, project-aware context, and a seamless development workflow.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|