lokuma-cli 1.4.3 → 1.4.5
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 +43 -5
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -80,8 +80,13 @@ function resolvePath(p) {
|
|
|
80
80
|
if (p.startsWith("~/")) return join(homedir(), p.slice(2));
|
|
81
81
|
return p;
|
|
82
82
|
}
|
|
83
|
-
function buildSkillMd(scriptPath) {
|
|
84
|
-
|
|
83
|
+
function buildSkillMd(scriptPath, apiKey) {
|
|
84
|
+
const keyLine = apiKey ? `LOKUMA_API_KEY = ${apiKey}
|
|
85
|
+
|
|
86
|
+
` : "";
|
|
87
|
+
return `${keyLine}> \u26A0\uFE0F Fetching the design style takes ~30 seconds. You MUST wait for the full design recommendation before generating any code!
|
|
88
|
+
|
|
89
|
+
---
|
|
85
90
|
name: frontend-designer
|
|
86
91
|
description: >
|
|
87
92
|
Lokuma design intelligence. Use this skill whenever building or modifying UI:
|
|
@@ -239,7 +244,8 @@ async function initCommand(options) {
|
|
|
239
244
|
}
|
|
240
245
|
await mkdir(dirname(paths.skillMd), { recursive: true });
|
|
241
246
|
await mkdir(dirname(paths.scriptPy), { recursive: true });
|
|
242
|
-
|
|
247
|
+
const apiKey = process.env.LOKUMA_API_KEY ?? "";
|
|
248
|
+
await writeFile(paths.skillMd, buildSkillMd(paths.scriptPy, apiKey), "utf-8");
|
|
243
249
|
await writeFile(paths.scriptPy, DESIGN_PY, "utf-8");
|
|
244
250
|
installed.push({ name: AI_DISPLAY_NAMES[t], skillMd: paths.skillMd, scriptPy: paths.scriptPy });
|
|
245
251
|
}
|
|
@@ -274,8 +280,36 @@ async function initCommand(options) {
|
|
|
274
280
|
// src/commands/auth.ts
|
|
275
281
|
import { writeFileSync, readFileSync as readFileSync2, existsSync, mkdirSync } from "node:fs";
|
|
276
282
|
import { dirname as dirname2, join as join2 } from "node:path";
|
|
283
|
+
import { homedir as homedir2 } from "node:os";
|
|
277
284
|
import { createInterface } from "node:readline";
|
|
278
285
|
import chalk2 from "chalk";
|
|
286
|
+
function resolvePath2(p) {
|
|
287
|
+
if (p.startsWith("~/")) return join2(homedir2(), p.slice(2));
|
|
288
|
+
return p;
|
|
289
|
+
}
|
|
290
|
+
function updateSkillMdKey(skillMdPath, key) {
|
|
291
|
+
if (!existsSync(skillMdPath)) return false;
|
|
292
|
+
let content = readFileSync2(skillMdPath, "utf-8");
|
|
293
|
+
if (content.startsWith("LOKUMA_API_KEY =")) {
|
|
294
|
+
content = content.replace(/^LOKUMA_API_KEY = .+\n\n?/, `LOKUMA_API_KEY = ${key}
|
|
295
|
+
|
|
296
|
+
`);
|
|
297
|
+
} else {
|
|
298
|
+
content = `LOKUMA_API_KEY = ${key}
|
|
299
|
+
|
|
300
|
+
` + content;
|
|
301
|
+
}
|
|
302
|
+
writeFileSync(skillMdPath, content, "utf-8");
|
|
303
|
+
return true;
|
|
304
|
+
}
|
|
305
|
+
function updateAllSkillMds(key) {
|
|
306
|
+
const updated = [];
|
|
307
|
+
for (const t of AI_TYPES.filter((t2) => t2 !== "all")) {
|
|
308
|
+
const p = resolvePath2(AI_SKILL_PATHS[t].skillMd);
|
|
309
|
+
if (updateSkillMdKey(p, key)) updated.push(p);
|
|
310
|
+
}
|
|
311
|
+
return updated;
|
|
312
|
+
}
|
|
279
313
|
function detectShellRc() {
|
|
280
314
|
const shell = process.env.SHELL ?? "";
|
|
281
315
|
const home = process.env.HOME ?? "";
|
|
@@ -336,7 +370,7 @@ async function prompt(question, hidden = false) {
|
|
|
336
370
|
async function authLoginCommand() {
|
|
337
371
|
console.log();
|
|
338
372
|
console.log(chalk2.bold(" Lokuma \u2014 API Key Setup"));
|
|
339
|
-
console.log(chalk2.dim(" Get your key at https://lokuma.ai"));
|
|
373
|
+
console.log(chalk2.dim(" Get your key at https://agent.lokuma.ai"));
|
|
340
374
|
console.log();
|
|
341
375
|
const existing = process.env.LOKUMA_API_KEY;
|
|
342
376
|
if (existing) {
|
|
@@ -357,14 +391,18 @@ async function authLoginCommand() {
|
|
|
357
391
|
}
|
|
358
392
|
if (!key.startsWith("lokuma_")) {
|
|
359
393
|
console.log(chalk2.red(" \u2717 Invalid key format (should start with lokuma_)"));
|
|
360
|
-
console.log(chalk2.dim(" Visit https://lokuma.ai to get a valid key."));
|
|
394
|
+
console.log(chalk2.dim(" Visit https://agent.lokuma.ai to get a valid key."));
|
|
361
395
|
console.log();
|
|
362
396
|
process.exit(1);
|
|
363
397
|
}
|
|
364
398
|
const rc = persistKey(key);
|
|
399
|
+
const updated = updateAllSkillMds(key);
|
|
365
400
|
console.log();
|
|
366
401
|
console.log(chalk2.green(" \u2713 API key saved!"));
|
|
367
402
|
console.log(chalk2.dim(` Written to: ${rc}`));
|
|
403
|
+
if (updated.length > 0) {
|
|
404
|
+
console.log(chalk2.dim(` Updated ${updated.length} SKILL.md file(s) with new key.`));
|
|
405
|
+
}
|
|
368
406
|
console.log();
|
|
369
407
|
console.log(chalk2.dim(" Reload your shell to apply:"));
|
|
370
408
|
console.log(chalk2.cyan(` source ${rc}`));
|