@intend-it/cli 1.1.2 → 1.1.3
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/dist/index.js +50 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -137,6 +137,7 @@ function printHelp() {
|
|
|
137
137
|
console.log(` ${cmd("--config")} ${dim("<path>")} Path to config file`);
|
|
138
138
|
console.log(` ${cmd("--output")} ${dim("<dir>")} Output directory`);
|
|
139
139
|
console.log(` ${cmd("--provider")} ${dim("<name>")} AI provider ${dim("(gemini | ollama)")}`);
|
|
140
|
+
console.log(` ${cmd("--model")} ${dim("<name>")} AI model name`);
|
|
140
141
|
console.log(` ${cmd("--api-key")} ${dim("<key>")} Gemini API key`);
|
|
141
142
|
console.log(` ${cmd("--force")} Force regeneration (skip cache)`);
|
|
142
143
|
console.log(` ${cmd("--help")} Show this help`);
|
|
@@ -227,7 +228,8 @@ out/
|
|
|
227
228
|
// src/commands/build.ts
|
|
228
229
|
import { existsSync as existsSync3, mkdirSync as mkdirSync2, writeFileSync as writeFileSync3, readFileSync as readFileSync2 } from "fs";
|
|
229
230
|
import { join as join3, resolve as resolve3, basename } from "path";
|
|
230
|
-
import { AICodeGenerator, FileSystemCAS, computeHash } from "@intend-it/core";
|
|
231
|
+
import { AICodeGenerator, FileSystemCAS, computeHash, OllamaProvider } from "@intend-it/core";
|
|
232
|
+
import * as readline from "readline";
|
|
231
233
|
import { parseToAST } from "@intend-it/parser";
|
|
232
234
|
import { readdirSync, statSync } from "fs";
|
|
233
235
|
function findIntentFiles(dir, fileList = []) {
|
|
@@ -255,6 +257,13 @@ async function buildCommand(options) {
|
|
|
255
257
|
config.gemini.apiKey = options.apiKey;
|
|
256
258
|
if (options.provider)
|
|
257
259
|
config.provider = options.provider;
|
|
260
|
+
if (options.model) {
|
|
261
|
+
if (config.provider === "ollama" && config.ollama) {
|
|
262
|
+
config.ollama.model = options.model;
|
|
263
|
+
} else if (config.gemini) {
|
|
264
|
+
config.gemini.model = options.model;
|
|
265
|
+
}
|
|
266
|
+
}
|
|
258
267
|
const sourceDir = resolve3(process.cwd(), config.sourceDir);
|
|
259
268
|
const outDir = resolve3(process.cwd(), config.outDir);
|
|
260
269
|
const providerName = config.provider || "gemini";
|
|
@@ -325,6 +334,42 @@ async function buildCommand(options) {
|
|
|
325
334
|
connectSpinner.fail(error(`Connection failed: ${error2.message}`));
|
|
326
335
|
process.exit(1);
|
|
327
336
|
}
|
|
337
|
+
const provider = generator.getProvider();
|
|
338
|
+
if (provider instanceof OllamaProvider) {
|
|
339
|
+
const ollama = provider;
|
|
340
|
+
if (typeof ollama.checkModelExists === "function") {
|
|
341
|
+
const exists = await ollama.checkModelExists();
|
|
342
|
+
if (!exists) {
|
|
343
|
+
const modelName = config.ollama?.model || "llama3";
|
|
344
|
+
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
345
|
+
console.log();
|
|
346
|
+
const answer = await new Promise((resolve4) => {
|
|
347
|
+
rl.question(` ${icons.info} Model '${accent(modelName)}' is not found locally.
|
|
348
|
+
${dim("Do you want to pull it now? [Y/n]")} `, resolve4);
|
|
349
|
+
});
|
|
350
|
+
rl.close();
|
|
351
|
+
if (answer.toLowerCase() === "n") {
|
|
352
|
+
printError("Model missing, cannot proceed.");
|
|
353
|
+
process.exit(1);
|
|
354
|
+
}
|
|
355
|
+
const pullSpinner = spinner(`Pulling ${modelName}...`).start();
|
|
356
|
+
try {
|
|
357
|
+
await ollama.pullModel((status, completed, total) => {
|
|
358
|
+
if (completed && total) {
|
|
359
|
+
const percent = Math.round(completed / total * 100);
|
|
360
|
+
pullSpinner.text = `Pulling ${modelName}: ${status} ${percent}%`;
|
|
361
|
+
} else {
|
|
362
|
+
pullSpinner.text = `Pulling ${modelName}: ${status}`;
|
|
363
|
+
}
|
|
364
|
+
});
|
|
365
|
+
pullSpinner.succeed(`${modelName} ready`);
|
|
366
|
+
} catch (e) {
|
|
367
|
+
pullSpinner.fail(`Failed to pull model: ${e.message}`);
|
|
368
|
+
process.exit(1);
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
}
|
|
328
373
|
const casDir = resolve3(process.cwd(), ".intend", "store");
|
|
329
374
|
const cas = new FileSystemCAS(casDir);
|
|
330
375
|
let successCount = 0;
|
|
@@ -456,6 +501,8 @@ async function handleBuild(args2) {
|
|
|
456
501
|
options.apiKey = args2[i + 1];
|
|
457
502
|
if (args2[i] === "--provider")
|
|
458
503
|
options.provider = args2[i + 1];
|
|
504
|
+
if (args2[i] === "--model")
|
|
505
|
+
options.model = args2[i + 1];
|
|
459
506
|
if (args2[i] === "--watch")
|
|
460
507
|
options.watch = true;
|
|
461
508
|
if (args2[i] === "--force")
|
|
@@ -480,6 +527,8 @@ async function handleWatch(args2) {
|
|
|
480
527
|
options.apiKey = args2[i + 1];
|
|
481
528
|
if (args2[i] === "--provider")
|
|
482
529
|
options.provider = args2[i + 1];
|
|
530
|
+
if (args2[i] === "--model")
|
|
531
|
+
options.model = args2[i + 1];
|
|
483
532
|
}
|
|
484
533
|
await watchCommand(options);
|
|
485
534
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intend-it/cli",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.3",
|
|
4
4
|
"description": "CLI for the Intend programming language",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
],
|
|
30
30
|
"license": "MIT",
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@intend-it/parser": "^1.1.
|
|
33
|
-
"@intend-it/core": "^2.0.
|
|
32
|
+
"@intend-it/parser": "^1.1.3",
|
|
33
|
+
"@intend-it/core": "^2.0.3",
|
|
34
34
|
"picocolors": "^1.1.1",
|
|
35
35
|
"ora": "^8.1.1"
|
|
36
36
|
},
|