lism-cli 0.0.1 → 0.3.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.
- package/LICENSE +21 -0
- package/README.md +16 -16
- package/dist/chunk-3PSCUHIC.js +620 -0
- package/dist/index.js +130 -81
- package/dist/lib.d.ts +430 -1
- package/dist/lib.js +9 -3
- package/package.json +28 -10
- package/dist/chunk-4TQG5MGT.js +0 -137
package/dist/index.js
CHANGED
|
@@ -9,8 +9,11 @@ import {
|
|
|
9
9
|
UI_HELPER_PATH,
|
|
10
10
|
UI_REGISTRY_INDEX_PATH,
|
|
11
11
|
createCommand,
|
|
12
|
-
logger
|
|
13
|
-
|
|
12
|
+
logger,
|
|
13
|
+
preScanLang,
|
|
14
|
+
setLang,
|
|
15
|
+
t
|
|
16
|
+
} from "./chunk-3PSCUHIC.js";
|
|
14
17
|
|
|
15
18
|
// src/createProgram.ts
|
|
16
19
|
import { Command as Command3 } from "commander";
|
|
@@ -27,6 +30,45 @@ import { confirm, select as select2 } from "@inquirer/prompts";
|
|
|
27
30
|
import fs from "fs";
|
|
28
31
|
import path from "path";
|
|
29
32
|
import { createJiti } from "jiti";
|
|
33
|
+
|
|
34
|
+
// src/invokeCommand.ts
|
|
35
|
+
function getInvokeCommand() {
|
|
36
|
+
const scriptPath = process.argv[1] ?? "";
|
|
37
|
+
const userAgent = process.env.npm_config_user_agent ?? "";
|
|
38
|
+
const normalizedScriptPath = normalizePath(scriptPath);
|
|
39
|
+
const inDlxCache = /\/_npx\//.test(normalizedScriptPath) || /\/pnpm(?:-cache)?\/(?:[^/]+\/)*dlx-[^/]+\//.test(normalizedScriptPath) || /\/\.yarn\/berry\/cache\//.test(normalizedScriptPath) || /\/\.bun\/install\/cache\//.test(normalizedScriptPath);
|
|
40
|
+
const inLocalDependency = isInProjectNodeModules(normalizedScriptPath) && (/\/node_modules\/\.bin\/lism(?:\.(?:cmd|ps1))?$/.test(normalizedScriptPath) || /\/node_modules\/lism-cli\/bin\/lism\.mjs$/.test(normalizedScriptPath));
|
|
41
|
+
if (inDlxCache) return getDlxInvokeCommand(userAgent);
|
|
42
|
+
if (inLocalDependency) return getLocalInvokeCommand(userAgent);
|
|
43
|
+
return "lism";
|
|
44
|
+
}
|
|
45
|
+
function getDlxInvokeCommand(userAgent) {
|
|
46
|
+
if (userAgent.startsWith("pnpm/")) return "pnpm dlx lism-cli";
|
|
47
|
+
if (userAgent.startsWith("yarn/")) return "yarn dlx lism-cli";
|
|
48
|
+
if (userAgent.startsWith("bun/")) return "bunx lism-cli";
|
|
49
|
+
return "npx lism-cli";
|
|
50
|
+
}
|
|
51
|
+
function getLocalInvokeCommand(userAgent) {
|
|
52
|
+
if (userAgent.startsWith("pnpm/")) return "pnpm exec lism";
|
|
53
|
+
if (userAgent.startsWith("yarn/")) return "yarn lism";
|
|
54
|
+
if (userAgent.startsWith("bun/")) return "bun run lism";
|
|
55
|
+
return "npx lism-cli";
|
|
56
|
+
}
|
|
57
|
+
function isInProjectNodeModules(scriptPath) {
|
|
58
|
+
let dir = normalizePath(process.cwd());
|
|
59
|
+
while (dir) {
|
|
60
|
+
if (scriptPath.startsWith(`${dir}/node_modules/`)) return true;
|
|
61
|
+
const parent = dir.slice(0, dir.lastIndexOf("/"));
|
|
62
|
+
if (parent === dir) break;
|
|
63
|
+
dir = parent;
|
|
64
|
+
}
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
function normalizePath(value) {
|
|
68
|
+
return value.replaceAll("\\", "/").replace(/\/+$/, "");
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// src/config.ts
|
|
30
72
|
var LEGACY_CONFIG_FILE = "lism-ui.json";
|
|
31
73
|
var CONFIG_SEARCH = ["lism.config.js", "lism.config.mjs"];
|
|
32
74
|
function resolvePath(filename) {
|
|
@@ -51,10 +93,10 @@ function getDefaultConfigPath() {
|
|
|
51
93
|
async function readConfig() {
|
|
52
94
|
const found = findConfigFile();
|
|
53
95
|
if (!found) {
|
|
54
|
-
throw new Error("
|
|
96
|
+
throw new Error(t("config.notFound"));
|
|
55
97
|
}
|
|
56
98
|
if (found.kind === "legacy-json") {
|
|
57
|
-
logger.warn(
|
|
99
|
+
logger.warn(t("config.legacyWarning", { filename: LEGACY_CONFIG_FILE, invoke: getInvokeCommand() }));
|
|
58
100
|
const raw = fs.readFileSync(found.path, "utf-8");
|
|
59
101
|
const parsed = JSON.parse(raw);
|
|
60
102
|
return parsed;
|
|
@@ -63,7 +105,7 @@ async function readConfig() {
|
|
|
63
105
|
const mod = await jiti.import(found.path);
|
|
64
106
|
const cli = mod?.cli ?? mod;
|
|
65
107
|
if (!cli || typeof cli !== "object") {
|
|
66
|
-
throw new Error(
|
|
108
|
+
throw new Error(t("config.cliSectionMissing", { filename: found.filename }));
|
|
67
109
|
}
|
|
68
110
|
validateCliConfig(cli);
|
|
69
111
|
return cli;
|
|
@@ -71,13 +113,13 @@ async function readConfig() {
|
|
|
71
113
|
function validateCliConfig(cli) {
|
|
72
114
|
const c = cli;
|
|
73
115
|
if (c.framework !== "react" && c.framework !== "astro") {
|
|
74
|
-
throw new Error(
|
|
116
|
+
throw new Error(t("config.invalidFramework"));
|
|
75
117
|
}
|
|
76
118
|
if (typeof c.componentsDir !== "string" || !c.componentsDir) {
|
|
77
|
-
throw new Error("
|
|
119
|
+
throw new Error(t("config.invalidComponentsDir"));
|
|
78
120
|
}
|
|
79
121
|
if (typeof c.helperDir !== "string" || !c.helperDir) {
|
|
80
|
-
throw new Error("
|
|
122
|
+
throw new Error(t("config.invalidHelperDir"));
|
|
81
123
|
}
|
|
82
124
|
}
|
|
83
125
|
function writeFreshConfig(cli) {
|
|
@@ -92,7 +134,7 @@ async function hasCliSection(filePath) {
|
|
|
92
134
|
const mod = await jiti.import(filePath);
|
|
93
135
|
return !!mod?.cli;
|
|
94
136
|
} catch (err) {
|
|
95
|
-
throw new Error(
|
|
137
|
+
throw new Error(t("config.loadFailed", { path: filePath, reason: String(err) }));
|
|
96
138
|
}
|
|
97
139
|
}
|
|
98
140
|
async function patchConfigWithCli(cli, targetPath, options = {}) {
|
|
@@ -361,18 +403,18 @@ async function fetchHelper(name, options = {}) {
|
|
|
361
403
|
import { select, input } from "@inquirer/prompts";
|
|
362
404
|
async function runInit(options = {}) {
|
|
363
405
|
const framework = options.framework ?? await select({
|
|
364
|
-
message: "
|
|
406
|
+
message: t("ui.init.promptFramework"),
|
|
365
407
|
choices: [
|
|
366
408
|
{ name: "React", value: "react" },
|
|
367
409
|
{ name: "Astro", value: "astro" }
|
|
368
410
|
]
|
|
369
411
|
});
|
|
370
412
|
const componentsDir = options.componentsDir ?? await input({
|
|
371
|
-
message: "
|
|
413
|
+
message: t("ui.init.promptComponentsDir"),
|
|
372
414
|
default: "src/components/ui"
|
|
373
415
|
});
|
|
374
416
|
const helperDir = options.helperDir ?? await input({
|
|
375
|
-
message: "
|
|
417
|
+
message: t("ui.init.promptHelperDir"),
|
|
376
418
|
default: `${componentsDir}/_helper`
|
|
377
419
|
});
|
|
378
420
|
const config = { framework, componentsDir, helperDir };
|
|
@@ -383,13 +425,13 @@ async function runInit(options = {}) {
|
|
|
383
425
|
existingCli: options.existingCli
|
|
384
426
|
});
|
|
385
427
|
if (patched) {
|
|
386
|
-
logger.success(
|
|
428
|
+
logger.success(t(options.force ? "ui.init.patchedUpdate" : "ui.init.patchedAdd", { path: outPath }));
|
|
387
429
|
} else {
|
|
388
|
-
logger.warn(
|
|
430
|
+
logger.warn(t("ui.init.notPatched", { path: outPath }));
|
|
389
431
|
}
|
|
390
432
|
} else {
|
|
391
433
|
const outPath = writeFreshConfig(config);
|
|
392
|
-
logger.success(
|
|
434
|
+
logger.success(t("ui.init.created", { path: outPath }));
|
|
393
435
|
}
|
|
394
436
|
return config;
|
|
395
437
|
}
|
|
@@ -397,7 +439,7 @@ async function initCommand(options) {
|
|
|
397
439
|
const found = findConfigFile();
|
|
398
440
|
let existingCli = false;
|
|
399
441
|
if (found?.kind === "legacy-json") {
|
|
400
|
-
logger.warn(
|
|
442
|
+
logger.warn(t("ui.init.legacyDetected", { filename: found.filename }));
|
|
401
443
|
} else if (found?.kind === "module") {
|
|
402
444
|
try {
|
|
403
445
|
existingCli = await hasCliSection(found.path);
|
|
@@ -407,10 +449,10 @@ async function initCommand(options) {
|
|
|
407
449
|
}
|
|
408
450
|
if (existingCli) {
|
|
409
451
|
if (!options.force) {
|
|
410
|
-
logger.warn(
|
|
452
|
+
logger.warn(t("ui.init.alreadyExists", { filename: found.filename }));
|
|
411
453
|
return;
|
|
412
454
|
}
|
|
413
|
-
logger.warn(
|
|
455
|
+
logger.warn(t("ui.init.willOverwrite", { filename: found.filename }));
|
|
414
456
|
}
|
|
415
457
|
}
|
|
416
458
|
await runInit({ ...options, existingCli });
|
|
@@ -425,7 +467,7 @@ async function addCommand(names, options) {
|
|
|
425
467
|
if (configExists()) {
|
|
426
468
|
config = await readConfig();
|
|
427
469
|
} else {
|
|
428
|
-
logger.info("
|
|
470
|
+
logger.info(t("ui.add.noConfig"));
|
|
429
471
|
config = await runInit();
|
|
430
472
|
console.log();
|
|
431
473
|
}
|
|
@@ -436,15 +478,15 @@ async function addCommand(names, options) {
|
|
|
436
478
|
} catch (err) {
|
|
437
479
|
const refInfo = options.ref ? ` (ref: ${options.ref})` : "";
|
|
438
480
|
const reason = err instanceof Error ? err.message : String(err);
|
|
439
|
-
logger.error(
|
|
481
|
+
logger.error(t("ui.catalogFailed", { refInfo, reason }));
|
|
440
482
|
process.exit(1);
|
|
441
483
|
}
|
|
442
484
|
if (options.all) {
|
|
443
485
|
names = catalog.components.map((c) => c.name);
|
|
444
|
-
logger.info(
|
|
486
|
+
logger.info(t("ui.add.addingAll", { count: names.length }));
|
|
445
487
|
}
|
|
446
488
|
if (names.length === 0) {
|
|
447
|
-
logger.error("
|
|
489
|
+
logger.error(t("ui.add.specifyName"));
|
|
448
490
|
process.exit(1);
|
|
449
491
|
}
|
|
450
492
|
const resolvedNames = [];
|
|
@@ -456,7 +498,7 @@ async function addCommand(names, options) {
|
|
|
456
498
|
else notFound.push(input2);
|
|
457
499
|
}
|
|
458
500
|
if (notFound.length > 0) {
|
|
459
|
-
logger.error(
|
|
501
|
+
logger.error(t("ui.add.notFound", { list: notFound.join(", ") }));
|
|
460
502
|
process.exit(1);
|
|
461
503
|
}
|
|
462
504
|
const excludeRootFiles = new Set(catalog.excludeComponentFiles);
|
|
@@ -471,7 +513,7 @@ async function addCommand(names, options) {
|
|
|
471
513
|
for (let i = 0; i < resolvedNames.length; i++) {
|
|
472
514
|
const result = results[i];
|
|
473
515
|
if (result.status === "rejected") {
|
|
474
|
-
logger.error(
|
|
516
|
+
logger.error(t("ui.add.componentFetchFailed", { name: resolvedNames[i], reason: String(result.reason) }));
|
|
475
517
|
hasFailure = true;
|
|
476
518
|
continue;
|
|
477
519
|
}
|
|
@@ -479,31 +521,31 @@ async function addCommand(names, options) {
|
|
|
479
521
|
if (helperFailed) hasFailure = true;
|
|
480
522
|
}
|
|
481
523
|
if (hasFailure) {
|
|
482
|
-
logger.error("
|
|
524
|
+
logger.error(t("ui.add.someFailed"));
|
|
483
525
|
process.exit(1);
|
|
484
526
|
}
|
|
485
|
-
logger.success("
|
|
527
|
+
logger.success(t("common.done"));
|
|
486
528
|
}
|
|
487
529
|
async function askOverwritePolicy() {
|
|
488
530
|
return select2({
|
|
489
|
-
message: "
|
|
531
|
+
message: t("ui.add.promptOverwritePolicy"),
|
|
490
532
|
choices: [
|
|
491
|
-
{ name: "
|
|
492
|
-
{ name: "
|
|
493
|
-
{ name: "
|
|
533
|
+
{ name: t("ui.add.policyAll"), value: "all" },
|
|
534
|
+
{ name: t("ui.add.policyNone"), value: "none" },
|
|
535
|
+
{ name: t("ui.add.policyPerComponent"), value: "per-component" }
|
|
494
536
|
]
|
|
495
537
|
});
|
|
496
538
|
}
|
|
497
539
|
function writeFile(filePath, content) {
|
|
498
540
|
fs3.mkdirSync(path4.dirname(filePath), { recursive: true });
|
|
499
541
|
fs3.writeFileSync(filePath, content);
|
|
500
|
-
logger.log(
|
|
542
|
+
logger.log(t("ui.add.created", { path: path4.relative(process.cwd(), filePath) }));
|
|
501
543
|
}
|
|
502
544
|
function hasExistingFiles(files, baseDir) {
|
|
503
545
|
return files.some((f) => fs3.existsSync(path4.join(baseDir, f.path)));
|
|
504
546
|
}
|
|
505
547
|
async function writeComponent(component, config, overwriteAll, policy, installedHelpers, fetchOpts) {
|
|
506
|
-
logger.info(
|
|
548
|
+
logger.info(t("ui.add.deploying", { name: component.name }));
|
|
507
549
|
const filesToWrite = [...component.files.shared, ...component.files[config.framework]];
|
|
508
550
|
const componentDirName = component.name;
|
|
509
551
|
const componentDir = path4.resolve(process.cwd(), config.componentsDir, componentDirName);
|
|
@@ -518,14 +560,14 @@ async function writeComponent(component, config, overwriteAll, policy, installed
|
|
|
518
560
|
shouldWrite = false;
|
|
519
561
|
} else if (policy === "per-component") {
|
|
520
562
|
shouldWrite = await confirm({
|
|
521
|
-
message:
|
|
563
|
+
message: t("ui.add.confirmOverwriteComponent", { name: componentDirName }),
|
|
522
564
|
default: false
|
|
523
565
|
});
|
|
524
566
|
} else {
|
|
525
567
|
shouldWrite = true;
|
|
526
568
|
}
|
|
527
569
|
if (!shouldWrite) {
|
|
528
|
-
logger.log(
|
|
570
|
+
logger.log(t("ui.add.skippedComponent", { name: componentDirName }));
|
|
529
571
|
} else {
|
|
530
572
|
for (const file of filesToWrite) {
|
|
531
573
|
const filePath = path4.join(componentDir, file.path);
|
|
@@ -541,7 +583,7 @@ async function writeComponent(component, config, overwriteAll, policy, installed
|
|
|
541
583
|
for (let i = 0; i < helpersToInstall.length; i++) {
|
|
542
584
|
const result = helperResults[i];
|
|
543
585
|
if (result.status === "rejected") {
|
|
544
|
-
logger.error(
|
|
586
|
+
logger.error(t("ui.add.helperFetchFailed", { name: helpersToInstall[i], reason: String(result.reason) }));
|
|
545
587
|
helperFailed = true;
|
|
546
588
|
continue;
|
|
547
589
|
}
|
|
@@ -549,16 +591,16 @@ async function writeComponent(component, config, overwriteAll, policy, installed
|
|
|
549
591
|
const filePath = path4.join(helperDir, file.path);
|
|
550
592
|
if (fs3.existsSync(filePath) && !overwriteAll) {
|
|
551
593
|
if (policy === "none") {
|
|
552
|
-
logger.log(
|
|
594
|
+
logger.log(t("ui.add.skippedFile", { path: file.path }));
|
|
553
595
|
continue;
|
|
554
596
|
}
|
|
555
597
|
if (policy === "per-component") {
|
|
556
598
|
const shouldOverwrite = await confirm({
|
|
557
|
-
message:
|
|
599
|
+
message: t("ui.add.confirmOverwriteFile", { path: path4.relative(process.cwd(), filePath) }),
|
|
558
600
|
default: false
|
|
559
601
|
});
|
|
560
602
|
if (!shouldOverwrite) {
|
|
561
|
-
logger.log(
|
|
603
|
+
logger.log(t("ui.add.skippedFile", { path: file.path }));
|
|
562
604
|
continue;
|
|
563
605
|
}
|
|
564
606
|
}
|
|
@@ -572,7 +614,7 @@ async function writeComponent(component, config, overwriteAll, policy, installed
|
|
|
572
614
|
|
|
573
615
|
// src/commands/ui/list.ts
|
|
574
616
|
async function listCommand(options = {}) {
|
|
575
|
-
logger.info("
|
|
617
|
+
logger.info(t("ui.list.fetching"));
|
|
576
618
|
const fetchOpts = { ref: options.ref };
|
|
577
619
|
let catalog;
|
|
578
620
|
try {
|
|
@@ -580,27 +622,27 @@ async function listCommand(options = {}) {
|
|
|
580
622
|
} catch (err) {
|
|
581
623
|
const refInfo = options.ref ? ` (ref: ${options.ref})` : "";
|
|
582
624
|
const reason = err instanceof Error ? err.message : String(err);
|
|
583
|
-
logger.error(
|
|
625
|
+
logger.error(t("ui.catalogFailed", { refInfo, reason }));
|
|
584
626
|
process.exit(1);
|
|
585
627
|
}
|
|
586
628
|
logger.log(`
|
|
587
629
|
Lism UI v${catalog.version}
|
|
588
630
|
`);
|
|
589
|
-
logger.log("
|
|
631
|
+
logger.log(t("ui.list.header"));
|
|
590
632
|
for (const component of catalog.components) {
|
|
591
633
|
const helpers = component.helpers.length > 0 ? ` (helpers: ${component.helpers.join(", ")})` : "";
|
|
592
634
|
logger.log(` - ${component.name}${helpers}`);
|
|
593
635
|
}
|
|
594
636
|
logger.log(`
|
|
595
|
-
|
|
637
|
+
${t("ui.list.total", { count: catalog.components.length })}`);
|
|
596
638
|
}
|
|
597
639
|
|
|
598
640
|
// src/commands/ui/index.ts
|
|
599
641
|
function createUiCommand() {
|
|
600
|
-
const ui = new Command("ui").description("
|
|
601
|
-
ui.command("init").description("
|
|
602
|
-
ui.command("add").description("
|
|
603
|
-
ui.command("list").description("
|
|
642
|
+
const ui = new Command("ui").description(t("cli.ui.description"));
|
|
643
|
+
ui.command("init").description(t("cli.ui.init.description")).addOption(new Option("--framework <name>", t("cli.ui.init.opt.framework")).choices(["react", "astro"])).option("--components-dir <path>", t("cli.ui.init.opt.componentsDir")).option("--helper-dir <path>", t("cli.ui.init.opt.helperDir")).option("-f, --force", t("cli.ui.init.opt.force"), false).action(initCommand);
|
|
644
|
+
ui.command("add").description(t("cli.ui.add.description")).argument("[names...]", t("cli.ui.add.arg.names")).option("-o, --overwrite", t("cli.ui.add.opt.overwrite"), false).option("-a, --all", t("cli.ui.add.opt.all"), false).option("--ref <ref>", t("cli.ui.opt.ref")).action(addCommand);
|
|
645
|
+
ui.command("list").description(t("cli.ui.list.description")).option("--ref <ref>", t("cli.ui.opt.ref")).action(listCommand);
|
|
604
646
|
return ui;
|
|
605
647
|
}
|
|
606
648
|
|
|
@@ -717,7 +759,7 @@ function copyDirRecursive(src, dest) {
|
|
|
717
759
|
// src/commands/skill/add.ts
|
|
718
760
|
function resolveExplicitTools(options) {
|
|
719
761
|
if (options.all) return [...ALL_SKILL_TOOLS];
|
|
720
|
-
const explicit = ALL_SKILL_TOOLS.filter((
|
|
762
|
+
const explicit = ALL_SKILL_TOOLS.filter((t2) => options[t2]);
|
|
721
763
|
return explicit;
|
|
722
764
|
}
|
|
723
765
|
function autoDetectTools(cwd) {
|
|
@@ -729,29 +771,29 @@ async function skillAddCommand(options) {
|
|
|
729
771
|
if (targets.length === 0) {
|
|
730
772
|
const detected = autoDetectTools(cwd);
|
|
731
773
|
if (detected.length > 0) {
|
|
732
|
-
logger.info(
|
|
774
|
+
logger.info(t("skill.add.detected", { list: detected.join(", ") }));
|
|
733
775
|
}
|
|
734
776
|
targets = await checkbox({
|
|
735
|
-
message: "
|
|
736
|
-
choices: ALL_SKILL_TOOLS.map((
|
|
737
|
-
name: `${
|
|
738
|
-
value:
|
|
739
|
-
checked: detected.includes(
|
|
777
|
+
message: t("skill.add.promptTools"),
|
|
778
|
+
choices: ALL_SKILL_TOOLS.map((tool) => ({
|
|
779
|
+
name: `${tool} \u2192 ${SKILL_PATHS[tool]}`,
|
|
780
|
+
value: tool,
|
|
781
|
+
checked: detected.includes(tool)
|
|
740
782
|
}))
|
|
741
783
|
});
|
|
742
784
|
}
|
|
743
785
|
if (targets.length === 0) {
|
|
744
|
-
logger.warn("
|
|
786
|
+
logger.warn(t("skill.add.noTargets"));
|
|
745
787
|
return;
|
|
746
788
|
}
|
|
747
789
|
const ref = options.ref ?? DEFAULT_SKILL_REF;
|
|
748
|
-
logger.info(
|
|
790
|
+
logger.info(t("skill.add.fetching", { ref }));
|
|
749
791
|
const { dir: srcDir } = await fetchSkillSource(ref);
|
|
750
792
|
try {
|
|
751
793
|
for (const tool of targets) {
|
|
752
794
|
await deploySkillTo(srcDir, tool, options);
|
|
753
795
|
}
|
|
754
|
-
logger.success("
|
|
796
|
+
logger.success(t("common.done"));
|
|
755
797
|
} finally {
|
|
756
798
|
cleanupTempDir(srcDir);
|
|
757
799
|
}
|
|
@@ -763,29 +805,29 @@ async function deploySkillTo(srcDir, tool, options) {
|
|
|
763
805
|
const diff = compareSkillDirs(destDir, srcDir);
|
|
764
806
|
const label = `${tool} (${SKILL_PATHS[tool]})`;
|
|
765
807
|
if (!hasDiff(diff)) {
|
|
766
|
-
logger.log(
|
|
808
|
+
logger.log(t("skill.add.skippedSame", { label }));
|
|
767
809
|
return;
|
|
768
810
|
}
|
|
769
811
|
logger.log("");
|
|
770
|
-
logger.log(
|
|
771
|
-
if (diff.modified.length > 0) logger.log(
|
|
772
|
-
if (diff.added.length > 0) logger.log(
|
|
812
|
+
logger.log(t("skill.add.hasDiff", { label }));
|
|
813
|
+
if (diff.modified.length > 0) logger.log(t("skill.add.modifiedFiles", { count: diff.modified.length }));
|
|
814
|
+
if (diff.added.length > 0) logger.log(t("skill.add.addedFiles", { count: diff.added.length }));
|
|
773
815
|
if (diff.localOnly.length > 0) {
|
|
774
|
-
logger.log(
|
|
816
|
+
logger.log(t("skill.add.localOnlyFiles", { count: diff.localOnly.length }));
|
|
775
817
|
for (const rel of diff.localOnly) logger.log(` - ${rel}`);
|
|
776
818
|
}
|
|
777
819
|
const go = await confirm2({
|
|
778
|
-
message:
|
|
820
|
+
message: t("skill.add.confirmOverwrite", { path: SKILL_PATHS[tool] }),
|
|
779
821
|
default: false
|
|
780
822
|
});
|
|
781
823
|
if (!go) {
|
|
782
|
-
logger.log(
|
|
824
|
+
logger.log(t("skill.add.skippedTool", { tool }));
|
|
783
825
|
return;
|
|
784
826
|
}
|
|
785
827
|
}
|
|
786
828
|
if (existing) fs5.rmSync(destDir, { recursive: true, force: true });
|
|
787
829
|
copyDirRecursive(srcDir, destDir);
|
|
788
|
-
logger.log(
|
|
830
|
+
logger.log(t("skill.add.deployed", { tool, path: path6.relative(process.cwd(), destDir) }));
|
|
789
831
|
}
|
|
790
832
|
|
|
791
833
|
// src/commands/skill/check.ts
|
|
@@ -795,11 +837,11 @@ async function skillCheckCommand(options = {}) {
|
|
|
795
837
|
const cwd = process.cwd();
|
|
796
838
|
const installed = ALL_SKILL_TOOLS.filter((tool) => fs6.existsSync(path7.join(cwd, SKILL_PATHS[tool], "SKILL.md")));
|
|
797
839
|
if (installed.length === 0) {
|
|
798
|
-
logger.info("
|
|
840
|
+
logger.info(t("skill.check.noneInstalled", { invoke: getInvokeCommand() }));
|
|
799
841
|
return;
|
|
800
842
|
}
|
|
801
843
|
const ref = options.ref ?? DEFAULT_SKILL_REF;
|
|
802
|
-
logger.info(
|
|
844
|
+
logger.info(t("skill.check.fetching", { ref }));
|
|
803
845
|
const { dir: remoteDir } = await fetchSkillSource(ref);
|
|
804
846
|
try {
|
|
805
847
|
let outdatedCount = 0;
|
|
@@ -808,7 +850,7 @@ async function skillCheckCommand(options = {}) {
|
|
|
808
850
|
const diff = compareSkillDirs(localDir, remoteDir);
|
|
809
851
|
const label = `${tool.padEnd(9)} ${SKILL_PATHS[tool]}`;
|
|
810
852
|
if (!hasDiff(diff)) {
|
|
811
|
-
logger.log(
|
|
853
|
+
logger.log(t("skill.check.upToDate", { label }));
|
|
812
854
|
continue;
|
|
813
855
|
}
|
|
814
856
|
outdatedCount += 1;
|
|
@@ -818,9 +860,9 @@ async function skillCheckCommand(options = {}) {
|
|
|
818
860
|
}
|
|
819
861
|
logger.log("");
|
|
820
862
|
if (outdatedCount === 0) {
|
|
821
|
-
logger.success("
|
|
863
|
+
logger.success(t("skill.check.allLatest"));
|
|
822
864
|
} else {
|
|
823
|
-
logger.info(
|
|
865
|
+
logger.info(t("skill.check.outdated", { count: outdatedCount, invoke: getInvokeCommand() }));
|
|
824
866
|
}
|
|
825
867
|
} finally {
|
|
826
868
|
cleanupTempDir(remoteDir);
|
|
@@ -828,9 +870,9 @@ async function skillCheckCommand(options = {}) {
|
|
|
828
870
|
}
|
|
829
871
|
function formatDiffSummary(diff) {
|
|
830
872
|
const parts = [];
|
|
831
|
-
if (diff.modified.length > 0) parts.push(
|
|
832
|
-
if (diff.added.length > 0) parts.push(
|
|
833
|
-
if (diff.localOnly.length > 0) parts.push(
|
|
873
|
+
if (diff.modified.length > 0) parts.push(t("skill.check.diffModified", { count: diff.modified.length }));
|
|
874
|
+
if (diff.added.length > 0) parts.push(t("skill.check.diffAdded", { count: diff.added.length }));
|
|
875
|
+
if (diff.localOnly.length > 0) parts.push(t("skill.check.diffDeleted", { count: diff.localOnly.length }));
|
|
834
876
|
return ` ${parts.join(" / ")}`;
|
|
835
877
|
}
|
|
836
878
|
function formatDiffDetails(diff) {
|
|
@@ -848,28 +890,35 @@ async function skillUpdateCommand(options) {
|
|
|
848
890
|
|
|
849
891
|
// src/commands/skill/index.ts
|
|
850
892
|
function createSkillCommand() {
|
|
851
|
-
const skill = new Command2("skill").description("
|
|
852
|
-
const
|
|
893
|
+
const skill = new Command2("skill").description(t("cli.skill.description"));
|
|
894
|
+
const toolOptDescription = (tool) => t("cli.skill.opt.toolPath", { path: SKILL_PATHS[tool] });
|
|
895
|
+
const toolFlags = (cmd) => cmd.option("--all", t("cli.skill.opt.all")).option("--claude", toolOptDescription("claude")).option("--codex", toolOptDescription("codex")).option("--cursor", toolOptDescription("cursor")).option("--windsurf", toolOptDescription("windsurf")).option("--cline", toolOptDescription("cline")).option("--copilot", toolOptDescription("copilot")).option("--gemini", toolOptDescription("gemini")).option("--junie", toolOptDescription("junie"));
|
|
853
896
|
toolFlags(
|
|
854
|
-
skill.command("add").description("
|
|
897
|
+
skill.command("add").description(t("cli.skill.add.description")).option("-o, --overwrite", t("cli.skill.add.opt.overwrite"), false).option("--ref <ref>", t("cli.skill.opt.ref"))
|
|
855
898
|
).action(skillAddCommand);
|
|
856
|
-
skill.command("check").description("
|
|
857
|
-
toolFlags(
|
|
858
|
-
|
|
859
|
-
)
|
|
899
|
+
skill.command("check").description(t("cli.skill.check.description")).option("--ref <ref>", t("cli.skill.opt.ref")).option("-v, --verbose", t("cli.skill.check.opt.verbose")).action(skillCheckCommand);
|
|
900
|
+
toolFlags(skill.command("update").description(t("cli.skill.update.description")).option("--ref <ref>", t("cli.skill.opt.ref"))).action(
|
|
901
|
+
skillUpdateCommand
|
|
902
|
+
);
|
|
860
903
|
return skill;
|
|
861
904
|
}
|
|
862
905
|
|
|
863
906
|
// src/createProgram.ts
|
|
864
907
|
function createLismProgram() {
|
|
865
908
|
const program2 = new Command3();
|
|
866
|
-
program2.name("lism").description("
|
|
867
|
-
program2.
|
|
909
|
+
program2.name("lism").description(t("cli.description")).version(CLI_VERSION).option("--lang <code>", t("cli.opt.lang"));
|
|
910
|
+
program2.hook("preAction", (thisCommand) => {
|
|
911
|
+
const opts = thisCommand.optsWithGlobals();
|
|
912
|
+
const lang = opts.lang;
|
|
913
|
+
if (typeof lang === "string") setLang(lang);
|
|
914
|
+
});
|
|
915
|
+
program2.command("create").description(t("cli.create.description")).argument("[targetDir]", t("cli.create.arg.targetDir")).option("-t, --template <name>", t("cli.create.opt.template")).option("-f, --force", t("cli.create.opt.force"), false).action(createCommand);
|
|
868
916
|
program2.addCommand(createUiCommand());
|
|
869
917
|
program2.addCommand(createSkillCommand());
|
|
870
918
|
return program2;
|
|
871
919
|
}
|
|
872
920
|
|
|
873
921
|
// src/index.ts
|
|
922
|
+
preScanLang(process.argv.slice(2));
|
|
874
923
|
var program = createLismProgram();
|
|
875
924
|
program.parse();
|