komodo-cli 0.1.0 → 0.2.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.
Files changed (2) hide show
  1. package/dist/index.js +303 -56
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -42676,10 +42676,46 @@ var import_commander = require("commander");
42676
42676
  var import_chalk = __toESM(require("chalk"));
42677
42677
  var import_ora = __toESM(require("ora"));
42678
42678
  var import_boxen = __toESM(require("boxen"));
42679
+ var readline = __toESM(require("readline"));
42679
42680
  init_dist();
42680
42681
  var komodo3 = new Komodo();
42681
42682
  var program = new import_commander.Command();
42682
42683
  program.name("komodo").description("The simple way to set up your project").version("0.1.0");
42684
+ var gradientColors = [
42685
+ "#ffffff",
42686
+ "#f0fff0",
42687
+ "#e1ffe1",
42688
+ "#d2ffd2",
42689
+ "#c3ffc3",
42690
+ "#b4ffb4",
42691
+ "#a5ffa5",
42692
+ "#96ff96",
42693
+ "#87ff87",
42694
+ "#78ff78",
42695
+ "#69ff69",
42696
+ "#5aff5a",
42697
+ "#4bff4b",
42698
+ "#3cff3c",
42699
+ "#2dff2d"
42700
+ ];
42701
+ var bannerLines = [
42702
+ "\u2588\u2588\u2557 \u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2557 ",
42703
+ "\u2588\u2588\u2551 \u2588\u2588\u2554\u255D\u2588\u2588\u2554\u2550\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2551\u2588\u2588\u2554\u2550\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2554\u2550\u2550\u2550\u2588\u2588\u2557",
42704
+ "\u2588\u2588\u2588\u2588\u2588\u2554\u255D \u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2554\u2588\u2588\u2588\u2588\u2554\u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2551",
42705
+ "\u2588\u2588\u2554\u2550\u2588\u2588\u2557 \u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2551\u255A\u2588\u2588\u2554\u255D\u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2551",
42706
+ "\u2588\u2588\u2551 \u2588\u2588\u2557\u255A\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D\u2588\u2588\u2551 \u255A\u2550\u255D \u2588\u2588\u2551\u255A\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D\u255A\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D",
42707
+ "\u255A\u2550\u255D \u255A\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u255D \u255A\u2550\u255D \u255A\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u255D "
42708
+ ];
42709
+ function printBanner() {
42710
+ console.log();
42711
+ bannerLines.forEach((line, i) => {
42712
+ console.log(import_chalk.default.hex(gradientColors[i])(line));
42713
+ });
42714
+ console.log();
42715
+ console.log(import_chalk.default.hex("#a5ffa5")(" The simple way to set up your project"));
42716
+ console.log(import_chalk.default.hex("#78ff78").dim(" Just say what you want to build."));
42717
+ console.log();
42718
+ }
42683
42719
  function formatOs(os3) {
42684
42720
  const names = { darwin: "Mac", linux: "Linux", windows: "Windows" };
42685
42721
  return names[os3] ?? os3;
@@ -42694,9 +42730,273 @@ function formatGpu(hardware) {
42694
42730
  }
42695
42731
  return "CPU";
42696
42732
  }
42697
- program.argument("[intent]", "What you want to build").option("-p, --path <path>", "Project folder", process.cwd()).option("--preview", "See what will be set up without making changes").action(async (intent, options) => {
42698
- if (!intent) {
42699
- await showStatus(options.path);
42733
+ async function startInteractiveMode(projectPath) {
42734
+ printBanner();
42735
+ const hardware = komodo3.getHardware();
42736
+ console.log(import_chalk.default.hex("#b4ffb4").dim(` ${formatOs(hardware.os)} \xB7 ${formatGpu(hardware)} \xB7 ${hardware.totalMemoryGb}GB memory`));
42737
+ console.log();
42738
+ console.log(import_chalk.default.hex("#96ff96").dim(" Commands: ") + import_chalk.default.hex("#d2ffd2")("undo") + import_chalk.default.dim(" \xB7 ") + import_chalk.default.hex("#d2ffd2")("list") + import_chalk.default.dim(" \xB7 ") + import_chalk.default.hex("#d2ffd2")("check") + import_chalk.default.dim(" \xB7 ") + import_chalk.default.hex("#d2ffd2")("ui") + import_chalk.default.dim(" \xB7 ") + import_chalk.default.hex("#d2ffd2")("exit"));
42739
+ console.log();
42740
+ const rl = readline.createInterface({
42741
+ input: process.stdin,
42742
+ output: process.stdout
42743
+ });
42744
+ const prompt = () => {
42745
+ rl.question(import_chalk.default.hex("#5aff5a")("\u276F "), async (input) => {
42746
+ const trimmed = input.trim();
42747
+ if (!trimmed) {
42748
+ prompt();
42749
+ return;
42750
+ }
42751
+ if (trimmed === "exit" || trimmed === "quit" || trimmed === "q") {
42752
+ console.log();
42753
+ console.log(import_chalk.default.hex("#a5ffa5")(" See you next time! \u{1F98E}"));
42754
+ console.log();
42755
+ rl.close();
42756
+ process.exit(0);
42757
+ }
42758
+ if (trimmed === "clear" || trimmed === "cls") {
42759
+ console.clear();
42760
+ printBanner();
42761
+ prompt();
42762
+ return;
42763
+ }
42764
+ if (trimmed === "help" || trimmed === "?") {
42765
+ console.log();
42766
+ console.log(import_chalk.default.hex("#a5ffa5")(" Just type what you want to build:"));
42767
+ console.log(import_chalk.default.dim(' "build a website"'));
42768
+ console.log(import_chalk.default.dim(' "train an AI model"'));
42769
+ console.log(import_chalk.default.dim(' "analyze some data"'));
42770
+ console.log();
42771
+ console.log(import_chalk.default.hex("#a5ffa5")(" Commands:"));
42772
+ console.log(` ${import_chalk.default.hex("#d2ffd2")("undo")} Undo last change`);
42773
+ console.log(` ${import_chalk.default.hex("#d2ffd2")("list")} See what's installed`);
42774
+ console.log(` ${import_chalk.default.hex("#d2ffd2")("check")} Check for problems`);
42775
+ console.log(` ${import_chalk.default.hex("#d2ffd2")("ui")} Open visual dashboard`);
42776
+ console.log(` ${import_chalk.default.hex("#d2ffd2")("history")} See past changes`);
42777
+ console.log(` ${import_chalk.default.hex("#d2ffd2")("clear")} Clear screen`);
42778
+ console.log(` ${import_chalk.default.hex("#d2ffd2")("exit")} Exit Komodo`);
42779
+ console.log();
42780
+ prompt();
42781
+ return;
42782
+ }
42783
+ if (trimmed === "undo") {
42784
+ await handleUndo(projectPath);
42785
+ prompt();
42786
+ return;
42787
+ }
42788
+ if (trimmed === "list" || trimmed === "ls") {
42789
+ await handleList(projectPath);
42790
+ prompt();
42791
+ return;
42792
+ }
42793
+ if (trimmed === "check") {
42794
+ await handleCheck(projectPath);
42795
+ prompt();
42796
+ return;
42797
+ }
42798
+ if (trimmed === "history") {
42799
+ await handleHistory(projectPath);
42800
+ prompt();
42801
+ return;
42802
+ }
42803
+ if (trimmed === "ui") {
42804
+ await handleUI(projectPath);
42805
+ prompt();
42806
+ return;
42807
+ }
42808
+ await handleInstall(trimmed, projectPath);
42809
+ prompt();
42810
+ });
42811
+ };
42812
+ prompt();
42813
+ }
42814
+ async function handleInstall(intent, projectPath) {
42815
+ const spinner = (0, import_ora.default)();
42816
+ console.log();
42817
+ const explanations = [];
42818
+ const warnings = [];
42819
+ const result = await komodo3.install({
42820
+ intent,
42821
+ path: projectPath,
42822
+ dryRun: false,
42823
+ onProgress: (message) => {
42824
+ const friendly = friendlyMessage(message);
42825
+ if (spinner.isSpinning) {
42826
+ spinner.succeed();
42827
+ }
42828
+ spinner.start(import_chalk.default.hex("#b4ffb4")(friendly));
42829
+ },
42830
+ onExplanation: (explanation) => {
42831
+ explanations.push(friendlyExplanation(explanation));
42832
+ },
42833
+ onWarning: (warning) => {
42834
+ warnings.push(friendlyWarning(warning));
42835
+ }
42836
+ });
42837
+ if (spinner.isSpinning) {
42838
+ spinner.succeed();
42839
+ }
42840
+ console.log();
42841
+ if (result.success) {
42842
+ if (result.resolution && result.resolution.packages.length > 0) {
42843
+ console.log(import_chalk.default.hex("#a5ffa5")(" Set up:"));
42844
+ result.resolution.packages.forEach((pkg) => {
42845
+ console.log(import_chalk.default.hex("#5aff5a")(` \u2713 ${friendlyPackageName(pkg.name)}`));
42846
+ });
42847
+ console.log();
42848
+ }
42849
+ if (explanations.length > 0) {
42850
+ console.log(import_chalk.default.hex("#b4ffb4").dim(" Good to know:"));
42851
+ explanations.forEach((e) => {
42852
+ console.log(import_chalk.default.dim(` \u2022 ${e}`));
42853
+ });
42854
+ console.log();
42855
+ }
42856
+ if (warnings.length > 0) {
42857
+ console.log(import_chalk.default.yellow(" Heads up:"));
42858
+ warnings.forEach((w) => {
42859
+ console.log(import_chalk.default.yellow(` \u2022 ${w}`));
42860
+ });
42861
+ console.log();
42862
+ }
42863
+ console.log(import_chalk.default.hex("#5aff5a")(" \u2713 All set! ") + import_chalk.default.dim("Type 'undo' to revert."));
42864
+ console.log();
42865
+ } else {
42866
+ console.log(import_chalk.default.red(" \u2717 Couldn't set that up"));
42867
+ console.log(import_chalk.default.dim(` ${result.error ?? "Try being more specific about what you want to build."}`));
42868
+ console.log();
42869
+ }
42870
+ }
42871
+ async function handleUndo(projectPath) {
42872
+ const spinner = (0, import_ora.default)(import_chalk.default.hex("#b4ffb4")("Undoing...")).start();
42873
+ const result = await komodo3.rollback(projectPath);
42874
+ if (result.success) {
42875
+ spinner.succeed(import_chalk.default.hex("#5aff5a")("Done! Restored to how it was before."));
42876
+ } else {
42877
+ spinner.fail(import_chalk.default.red(friendlyError(result.error ?? "Nothing to undo")));
42878
+ }
42879
+ console.log();
42880
+ }
42881
+ async function handleList(projectPath) {
42882
+ const state = await loadState(projectPath);
42883
+ console.log();
42884
+ if (!state.activeEnvironmentId) {
42885
+ console.log(import_chalk.default.dim(" Nothing installed yet"));
42886
+ console.log();
42887
+ return;
42888
+ }
42889
+ const activeEnv = state.environments.find((e) => e.id === state.activeEnvironmentId);
42890
+ if (!activeEnv) {
42891
+ console.log(import_chalk.default.dim(" Nothing installed yet"));
42892
+ console.log();
42893
+ return;
42894
+ }
42895
+ const installed = await getInstalledPackages(projectPath, activeEnv.runtime);
42896
+ const conflicts = detectConflicts(installed);
42897
+ if (installed.length === 0) {
42898
+ console.log(import_chalk.default.dim(" Nothing installed yet"));
42899
+ } else {
42900
+ console.log(import_chalk.default.hex("#a5ffa5")(" Installed:"));
42901
+ installed.forEach((pkg) => {
42902
+ const hasConflict = conflicts.some(
42903
+ (c) => c.package1 === pkg.name || c.package2 === pkg.name
42904
+ );
42905
+ const status = hasConflict ? import_chalk.default.yellow("\u26A0") : import_chalk.default.hex("#5aff5a")("\u2713");
42906
+ console.log(` ${status} ${friendlyPackageName(pkg.name)} ${import_chalk.default.dim(pkg.version)}`);
42907
+ });
42908
+ }
42909
+ console.log();
42910
+ if (conflicts.length > 0) {
42911
+ console.log(import_chalk.default.yellow(" Things to check:"));
42912
+ conflicts.forEach((c) => {
42913
+ console.log(import_chalk.default.dim(` \u2022 ${c.package1} and ${c.package2}: ${c.reason}`));
42914
+ });
42915
+ console.log();
42916
+ }
42917
+ }
42918
+ async function handleCheck(projectPath) {
42919
+ const spinner = (0, import_ora.default)(import_chalk.default.hex("#b4ffb4")("Checking...")).start();
42920
+ const state = await loadState(projectPath);
42921
+ if (!state.activeEnvironmentId) {
42922
+ spinner.succeed(import_chalk.default.dim("Nothing to check - no project set up yet"));
42923
+ return;
42924
+ }
42925
+ const activeEnv = state.environments.find((e) => e.id === state.activeEnvironmentId);
42926
+ if (!activeEnv) {
42927
+ spinner.succeed(import_chalk.default.dim("Nothing to check"));
42928
+ return;
42929
+ }
42930
+ const installed = await getInstalledPackages(projectPath, activeEnv.runtime);
42931
+ const conflicts = detectConflicts(installed);
42932
+ const health = analyzeHealth(installed, conflicts);
42933
+ spinner.stop();
42934
+ console.log();
42935
+ if (health.healthy) {
42936
+ console.log(import_chalk.default.hex("#5aff5a")(" \u2713 Everything looks good!"));
42937
+ console.log(import_chalk.default.dim(` ${installed.length} items installed, no issues found`));
42938
+ } else {
42939
+ console.log(import_chalk.default.yellow(` Found ${health.issues.length} thing${health.issues.length > 1 ? "s" : ""} to check:`));
42940
+ console.log();
42941
+ health.issues.forEach((issue) => {
42942
+ const icon = issue.severity === "error" ? import_chalk.default.red("\u2717") : import_chalk.default.yellow("\u26A0");
42943
+ console.log(` ${icon} ${issue.title}`);
42944
+ console.log(import_chalk.default.dim(` ${issue.description}`));
42945
+ if (issue.fix) {
42946
+ console.log(import_chalk.default.hex("#87ff87")(` Tip: ${issue.fix}`));
42947
+ }
42948
+ });
42949
+ }
42950
+ console.log();
42951
+ }
42952
+ async function handleHistory(projectPath) {
42953
+ const snapshots = await komodo3.listSnapshots(projectPath);
42954
+ console.log();
42955
+ if (snapshots.length === 0) {
42956
+ console.log(import_chalk.default.dim(" No history yet"));
42957
+ console.log();
42958
+ return;
42959
+ }
42960
+ console.log(import_chalk.default.hex("#a5ffa5")(" History:"));
42961
+ const sorted = [...snapshots].sort(
42962
+ (a, b) => new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime()
42963
+ );
42964
+ sorted.forEach((s, i) => {
42965
+ const date = new Date(s.createdAt);
42966
+ const timeAgo = formatTimeAgo(date);
42967
+ const isCurrent = i === 0;
42968
+ console.log(
42969
+ ` ${isCurrent ? import_chalk.default.hex("#5aff5a")("\u25CF") : import_chalk.default.dim("\u25CB")} ${s.description} ${import_chalk.default.dim(`(${timeAgo})`)}`
42970
+ );
42971
+ console.log(import_chalk.default.dim(` ${s.packages.length} items`));
42972
+ });
42973
+ console.log();
42974
+ console.log(import_chalk.default.dim(" Type 'undo' to go back to the previous state"));
42975
+ console.log();
42976
+ }
42977
+ async function handleUI(projectPath) {
42978
+ const port = 3333;
42979
+ const url = `http://localhost:${port}`;
42980
+ console.log();
42981
+ console.log(import_chalk.default.hex("#b4ffb4").dim(" Starting dashboard..."));
42982
+ try {
42983
+ const { startServer: startServer2 } = await Promise.resolve().then(() => (init_server(), server_exports));
42984
+ await startServer2(projectPath, port);
42985
+ console.log(import_chalk.default.hex("#5aff5a")(` \u2713 Dashboard ready at ${import_chalk.default.bold(url)}`));
42986
+ console.log();
42987
+ const open = await import("open").then((m) => m.default).catch(() => null);
42988
+ if (open) {
42989
+ await open(url);
42990
+ }
42991
+ } catch (error) {
42992
+ console.log(import_chalk.default.red(" Couldn't start dashboard"));
42993
+ console.log(import_chalk.default.dim(` ${error instanceof Error ? error.message : "Unknown error"}`));
42994
+ console.log();
42995
+ }
42996
+ }
42997
+ program.argument("[intent]", "What you want to build").option("-p, --path <path>", "Project folder", process.cwd()).option("--preview", "See what will be set up without making changes").option("-i, --interactive", "Enter interactive mode").action(async (intent, options) => {
42998
+ if (options.interactive || !intent) {
42999
+ await startInteractiveMode(options.path);
42700
43000
  return;
42701
43001
  }
42702
43002
  const spinner = (0, import_ora.default)();
@@ -42781,59 +43081,6 @@ program.argument("[intent]", "What you want to build").option("-p, --path <path>
42781
43081
  process.exit(1);
42782
43082
  }
42783
43083
  });
42784
- async function showStatus(path3) {
42785
- const hardware = komodo3.getHardware();
42786
- const state = await loadState(path3);
42787
- console.log();
42788
- console.log(import_chalk.default.bold("\u{1F98E} Komodo"));
42789
- console.log();
42790
- console.log(import_chalk.default.dim(" Your computer:"));
42791
- console.log(` ${formatOs(hardware.os)} \xB7 ${formatGpu(hardware)} \xB7 ${hardware.totalMemoryGb}GB memory`);
42792
- console.log();
42793
- if (state.activeEnvironmentId) {
42794
- const activeEnv = state.environments.find((e) => e.id === state.activeEnvironmentId);
42795
- if (activeEnv) {
42796
- const installed = await getInstalledPackages(path3, activeEnv.runtime);
42797
- const conflicts = detectConflicts(installed);
42798
- const health = analyzeHealth(installed, conflicts);
42799
- console.log(import_chalk.default.dim(" Installed:"));
42800
- if (installed.length === 0) {
42801
- console.log(import_chalk.default.dim(" Nothing yet"));
42802
- } else {
42803
- const displayCount = Math.min(installed.length, 8);
42804
- installed.slice(0, displayCount).forEach((pkg) => {
42805
- console.log(` ${friendlyPackageName(pkg.name)} ${import_chalk.default.dim(pkg.version)}`);
42806
- });
42807
- if (installed.length > displayCount) {
42808
- console.log(import_chalk.default.dim(` ...and ${installed.length - displayCount} more`));
42809
- }
42810
- }
42811
- console.log();
42812
- if (health.healthy) {
42813
- console.log(import_chalk.default.green(" \u2713 Everything looks good"));
42814
- } else {
42815
- console.log(import_chalk.default.yellow(` \u26A0 ${health.issues.length} thing${health.issues.length > 1 ? "s" : ""} to check`));
42816
- health.issues.slice(0, 3).forEach((issue) => {
42817
- console.log(import_chalk.default.dim(` \u2022 ${issue.title}`));
42818
- });
42819
- }
42820
- console.log();
42821
- }
42822
- } else {
42823
- console.log(import_chalk.default.dim(" Nothing installed yet."));
42824
- console.log();
42825
- console.log(import_chalk.default.dim(" Try:"));
42826
- console.log(` komodo "build a website"`);
42827
- console.log(` komodo "analyze some data"`);
42828
- console.log(` komodo "create a chatbot"`);
42829
- console.log();
42830
- }
42831
- console.log(import_chalk.default.dim(" Commands:"));
42832
- console.log(` komodo "what you want to build" ${import_chalk.default.dim("Set things up")}`);
42833
- console.log(` komodo undo ${import_chalk.default.dim("Undo last change")}`);
42834
- console.log(` komodo ui ${import_chalk.default.dim("Open visual dashboard")}`);
42835
- console.log();
42836
- }
42837
43084
  program.command("undo").description("Undo your last change").option("-p, --path <path>", "Project folder", process.cwd()).action(async (options) => {
42838
43085
  const spinner = (0, import_ora.default)("Undoing...").start();
42839
43086
  const result = await komodo3.rollback(options.path);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "komodo-cli",
3
- "version": "0.1.0",
3
+ "version": "0.2.1",
4
4
  "description": "The simple way to set up your project. Just say what you want to build.",
5
5
  "bin": {
6
6
  "komodo": "./dist/index.js"