fleetbo-cockpit-cli 1.0.25 → 1.0.26
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/cli.js +73 -0
- package/package.json +1 -1
package/cli.js
CHANGED
|
@@ -17,6 +17,7 @@ const IOS_BUILD_URL = "https://fiosbuild-jqycakhlxa-uc.a.run.app";
|
|
|
17
17
|
const UPDATE_NETWORK_URL = 'https://updatedevelopernetwork-jqycakhlxa-uc.a.run.app';
|
|
18
18
|
const ALEX_ENGINE_URL = "https://generatenativemodule-jqycakhlxa-uc.a.run.app";
|
|
19
19
|
const INJECT_DEPS_URL = "https://savegeneratedfile-jqycakhlxa-uc.a.run.app";
|
|
20
|
+
const CACHE_URL = "https://getmodulecache-jqycakhlxa-uc.a.run.app";
|
|
20
21
|
const PORT = 3000;
|
|
21
22
|
|
|
22
23
|
let uplinkProcess = null;
|
|
@@ -143,6 +144,38 @@ const showEnergyTransfer = async () => {
|
|
|
143
144
|
process.stdout.write('\n');
|
|
144
145
|
};
|
|
145
146
|
|
|
147
|
+
const promptContainsModification = (text) => {
|
|
148
|
+
const keywords = ['modifier', 'update', 'change', 'corrige', 'fix', 'ajoute', 'edit', 'refactor'];
|
|
149
|
+
const lower = text.toLowerCase();
|
|
150
|
+
return keywords.some(k => lower.includes(k));
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
const extractModuleName = (text) => {
|
|
154
|
+
const matchExplicit = text.match(/(?:module|mod)\s+([A-Z][a-zA-Z0-9_]*)/i);
|
|
155
|
+
if (matchExplicit) return matchExplicit[1];
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
const words = text.split(' ');
|
|
159
|
+
for (let i = 1; i < words.length; i++) {
|
|
160
|
+
const w = words[i].replace(/[^a-zA-Z0-9]/g, '');
|
|
161
|
+
if (/^[A-Z][a-z0-9]+/.test(w) && w.length > 3) return w;
|
|
162
|
+
}
|
|
163
|
+
return null;
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
const getModuleCache = async ({ projectId, moduleName }) => {
|
|
167
|
+
try {
|
|
168
|
+
if (!moduleName) return { found: false };
|
|
169
|
+
const res = await axios.post(CACHE_URL, { projectId, moduleName });
|
|
170
|
+
if (res.data && res.data.found) {
|
|
171
|
+
return { found: true, module: res.data.module };
|
|
172
|
+
}
|
|
173
|
+
return { found: false };
|
|
174
|
+
} catch (e) {
|
|
175
|
+
return { found: false };
|
|
176
|
+
}
|
|
177
|
+
};
|
|
178
|
+
|
|
146
179
|
// ============================================
|
|
147
180
|
// COMMAND: alex
|
|
148
181
|
// ============================================
|
|
@@ -160,10 +193,50 @@ if (command === 'alex') {
|
|
|
160
193
|
console.log('\x1b[33m🧠 Alex is thinking...\x1b[0m');
|
|
161
194
|
|
|
162
195
|
try {
|
|
196
|
+
// --- DÉBUT MODIFICATION : SYSTÈME DE MÉMOIRE (CACHE) ---
|
|
197
|
+
let contextInjection = "";
|
|
198
|
+
|
|
199
|
+
// 1. On détecte si c'est une update
|
|
200
|
+
if (promptContainsModification(prompt)) {
|
|
201
|
+
const moduleName = extractModuleName(prompt);
|
|
202
|
+
|
|
203
|
+
if (moduleName) {
|
|
204
|
+
process.stdout.write(` \x1b[90m🔍 Searching cache for ${moduleName}...\x1b[0m`);
|
|
205
|
+
const cache = await getModuleCache({ projectId, moduleName });
|
|
206
|
+
|
|
207
|
+
if (cache.found) {
|
|
208
|
+
process.stdout.write(` \x1b[32mFOUND\x1b[0m\n`);
|
|
209
|
+
// On prépare le contexte pour Alex
|
|
210
|
+
contextInjection = `
|
|
211
|
+
|
|
212
|
+
--- CONTEXTE : CODE EXISTANT (${moduleName}) ---
|
|
213
|
+
L'utilisateur veut modifier ce module existant.
|
|
214
|
+
Tu DOIS te baser sur ce code et appliquer les changements demandés.
|
|
215
|
+
|
|
216
|
+
[EXISTING KOTLIN]
|
|
217
|
+
${cache.module.code}
|
|
218
|
+
|
|
219
|
+
[EXISTING MOCK]
|
|
220
|
+
${cache.module.mockCode}
|
|
221
|
+
|
|
222
|
+
--- FIN DU CONTEXTE ---
|
|
223
|
+
`;
|
|
224
|
+
|
|
225
|
+
// On injecte le contexte AVANT la demande pour qu'il soit traité comme une base de travail
|
|
226
|
+
prompt = contextInjection + "\n\n[INSTRUCTION PILOTE]\n" + prompt;
|
|
227
|
+
} else {
|
|
228
|
+
process.stdout.write(` \x1b[31mNOT FOUND (Creating new)\x1b[0m\n`);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
// --- FIN MODIFICATION ---
|
|
233
|
+
|
|
163
234
|
const result = await axios.post(ALEX_ENGINE_URL, { prompt, projectType: 'android' }, {
|
|
164
235
|
headers: { 'x-project-id': projectId }
|
|
165
236
|
});
|
|
237
|
+
|
|
166
238
|
let aiData = result.data;
|
|
239
|
+
|
|
167
240
|
if (typeof aiData === 'string') {
|
|
168
241
|
try { aiData = JSON.parse(aiData); } catch (_) {}
|
|
169
242
|
}
|