@akanjs/cli 0.0.136 → 0.0.137

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/cjs/index.js CHANGED
@@ -1076,7 +1076,7 @@ var Executor = class {
1076
1076
  `${dirname}/${filename}`
1077
1077
  );
1078
1078
  this.logger.verbose(`Apply template ${templatePath} to ${convertedTargetPath}`);
1079
- this.writeFile(convertedTargetPath, content);
1079
+ this.writeFile(convertedTargetPath, content, { overwrite });
1080
1080
  } else if (targetPath.endsWith(".template")) {
1081
1081
  const content = await import_promises.default.readFile(templatePath, "utf8");
1082
1082
  const convertedTargetPath = Object.entries(dict).reduce(
@@ -1088,7 +1088,7 @@ var Executor = class {
1088
1088
  content
1089
1089
  );
1090
1090
  this.logger.verbose(`Apply template ${templatePath} to ${convertedTargetPath}`);
1091
- this.writeFile(convertedTargetPath, convertedContent);
1091
+ this.writeFile(convertedTargetPath, convertedContent, { overwrite });
1092
1092
  }
1093
1093
  }
1094
1094
  async applyTemplate({
@@ -2174,6 +2174,7 @@ var runCommands = async (...commands) => {
2174
2174
 
2175
2175
  // pkgs/@akanjs/devkit/src/aiEditor.ts
2176
2176
  var import_prompts4 = require("@inquirer/prompts");
2177
+ var import_ora2 = __toESM(require("ora"));
2177
2178
  var import_messages = require("@langchain/core/messages");
2178
2179
  var import_openai2 = require("@langchain/openai");
2179
2180
  var import_chalk3 = __toESM(require("chalk"));
@@ -2247,23 +2248,28 @@ var AiSession = class _AiSession {
2247
2248
  await _AiSession.init();
2248
2249
  if (!_AiSession.#chat)
2249
2250
  throw new Error("Failed to initialize the AI session");
2251
+ const loader = (0, import_ora2.default)(`${_AiSession.#chat.model} is thinking...`).start();
2250
2252
  try {
2251
2253
  const humanMessage = new import_messages.HumanMessage(question);
2252
2254
  this.messageHistory.push(humanMessage);
2253
2255
  const stream = await _AiSession.#chat.stream(this.messageHistory);
2254
- let fullResponse = "";
2256
+ let fullResponse = "", tokenIdx = 0;
2255
2257
  for await (const chunk of stream) {
2258
+ if (loader.isSpinning)
2259
+ loader.succeed(`${_AiSession.#chat.model} responded`);
2256
2260
  const content = chunk.content;
2257
2261
  if (typeof content === "string") {
2258
2262
  fullResponse += content;
2259
2263
  onChunk(content);
2260
2264
  }
2265
+ tokenIdx++;
2261
2266
  }
2262
2267
  fullResponse += "\n";
2263
2268
  onChunk("\n");
2264
2269
  this.messageHistory.push(new import_messages.AIMessage(fullResponse));
2265
2270
  return { content: fullResponse, messageHistory: this.messageHistory };
2266
2271
  } catch (error) {
2272
+ loader.fail(`${_AiSession.#chat.model} failed to respond`);
2267
2273
  throw new Error("Failed to stream response");
2268
2274
  }
2269
2275
  }
@@ -2517,7 +2523,7 @@ var import_fs9 = __toESM(require("fs"));
2517
2523
  var import_promises2 = __toESM(require("fs/promises"));
2518
2524
  var import_js_yaml2 = __toESM(require("js-yaml"));
2519
2525
  var import_open = __toESM(require("open"));
2520
- var import_ora2 = __toESM(require("ora"));
2526
+ var import_ora3 = __toESM(require("ora"));
2521
2527
  var import_path4 = __toESM(require("path"));
2522
2528
  var vite = __toESM(require("vite"));
2523
2529
  var import_vite_plugin_commonjs = __toESM(require("vite-plugin-commonjs"));
@@ -4860,7 +4866,7 @@ var ApplicationRunner = class {
4860
4866
  const chatModel = new import_openai3.ChatOpenAI({ modelName: "gpt-4o", openAIApiKey });
4861
4867
  const projectName = await (0, import_prompts5.input)({ message: "please enter project name." });
4862
4868
  const projectDesc = await (0, import_prompts5.input)({ message: "please enter project description. (40 ~ 60 characters)" });
4863
- const spinner = (0, import_ora2.default)("Gerating project files...");
4869
+ const spinner = (0, import_ora3.default)("Gerating project files...");
4864
4870
  const mainPrompt = import_prompts6.PromptTemplate.fromTemplate(requestApplication());
4865
4871
  const chain = import_runnables2.RunnableSequence.from([mainPrompt, chatModel, new import_output_parsers.StringOutputParser()]);
4866
4872
  const resultOne = await chain.invoke({ projectName, projectDesc });
@@ -5036,7 +5042,7 @@ var ApplicationScript = class {
5036
5042
  var ApplicationCommand = class {
5037
5043
  applicationScript = new ApplicationScript();
5038
5044
  async createApplication(name, start, workspace) {
5039
- await this.applicationScript.createApplication(name, workspace, { start });
5045
+ await this.applicationScript.createApplication(name.toLowerCase().replace(/ /g, "-"), workspace, { start });
5040
5046
  }
5041
5047
  async removeApplication(app) {
5042
5048
  await this.applicationScript.removeApplication(app);
@@ -5535,7 +5541,7 @@ CloudCommand = __decorateClass([
5535
5541
  var LibraryCommand = class {
5536
5542
  libraryScript = new LibraryScript();
5537
5543
  async createLibrary(name, workspace) {
5538
- await this.libraryScript.createLibrary(name, workspace);
5544
+ await this.libraryScript.createLibrary(name.toLowerCase().replace(/ /g, "-"), workspace);
5539
5545
  }
5540
5546
  async removeLibrary(lib) {
5541
5547
  await this.libraryScript.removeLibrary(lib);
@@ -5944,7 +5950,7 @@ var PackageCommand = class {
5944
5950
  await this.packageScript.version(workspace);
5945
5951
  }
5946
5952
  async createPackage(name, workspace) {
5947
- await this.packageScript.createPackage(workspace, name);
5953
+ await this.packageScript.createPackage(workspace, name.toLowerCase().replace(/ /g, "-"));
5948
5954
  }
5949
5955
  async removePackage(pkg) {
5950
5956
  await this.packageScript.removePackage(pkg);
@@ -6154,7 +6160,7 @@ var WorkspaceScript = class {
6154
6160
  var WorkspaceCommand = class {
6155
6161
  workspaceScript = new WorkspaceScript();
6156
6162
  async createWorkspace(name, app, dir) {
6157
- await this.workspaceScript.createWorkspace(name, app, dir);
6163
+ await this.workspaceScript.createWorkspace(name, app.toLowerCase().replace(/ /g, "-"), dir);
6158
6164
  }
6159
6165
  async generateMongo(workspace) {
6160
6166
  await this.workspaceScript.generateMongo(workspace);
package/esm/index.js CHANGED
@@ -1063,7 +1063,7 @@ var Executor = class {
1063
1063
  `${dirname}/${filename}`
1064
1064
  );
1065
1065
  this.logger.verbose(`Apply template ${templatePath} to ${convertedTargetPath}`);
1066
- this.writeFile(convertedTargetPath, content);
1066
+ this.writeFile(convertedTargetPath, content, { overwrite });
1067
1067
  } else if (targetPath.endsWith(".template")) {
1068
1068
  const content = await fsPromise.readFile(templatePath, "utf8");
1069
1069
  const convertedTargetPath = Object.entries(dict).reduce(
@@ -1075,7 +1075,7 @@ var Executor = class {
1075
1075
  content
1076
1076
  );
1077
1077
  this.logger.verbose(`Apply template ${templatePath} to ${convertedTargetPath}`);
1078
- this.writeFile(convertedTargetPath, convertedContent);
1078
+ this.writeFile(convertedTargetPath, convertedContent, { overwrite });
1079
1079
  }
1080
1080
  }
1081
1081
  async applyTemplate({
@@ -2161,6 +2161,7 @@ var runCommands = async (...commands) => {
2161
2161
 
2162
2162
  // pkgs/@akanjs/devkit/src/aiEditor.ts
2163
2163
  import { input as input2, select as select3 } from "@inquirer/prompts";
2164
+ import ora2 from "ora";
2164
2165
  import { AIMessage, HumanMessage } from "@langchain/core/messages";
2165
2166
  import { ChatOpenAI as ChatOpenAI2 } from "@langchain/openai";
2166
2167
  import chalk3 from "chalk";
@@ -2234,23 +2235,28 @@ var AiSession = class _AiSession {
2234
2235
  await _AiSession.init();
2235
2236
  if (!_AiSession.#chat)
2236
2237
  throw new Error("Failed to initialize the AI session");
2238
+ const loader = ora2(`${_AiSession.#chat.model} is thinking...`).start();
2237
2239
  try {
2238
2240
  const humanMessage = new HumanMessage(question);
2239
2241
  this.messageHistory.push(humanMessage);
2240
2242
  const stream = await _AiSession.#chat.stream(this.messageHistory);
2241
- let fullResponse = "";
2243
+ let fullResponse = "", tokenIdx = 0;
2242
2244
  for await (const chunk of stream) {
2245
+ if (loader.isSpinning)
2246
+ loader.succeed(`${_AiSession.#chat.model} responded`);
2243
2247
  const content = chunk.content;
2244
2248
  if (typeof content === "string") {
2245
2249
  fullResponse += content;
2246
2250
  onChunk(content);
2247
2251
  }
2252
+ tokenIdx++;
2248
2253
  }
2249
2254
  fullResponse += "\n";
2250
2255
  onChunk("\n");
2251
2256
  this.messageHistory.push(new AIMessage(fullResponse));
2252
2257
  return { content: fullResponse, messageHistory: this.messageHistory };
2253
2258
  } catch (error) {
2259
+ loader.fail(`${_AiSession.#chat.model} failed to respond`);
2254
2260
  throw new Error("Failed to stream response");
2255
2261
  }
2256
2262
  }
@@ -2504,7 +2510,7 @@ import fs11 from "fs";
2504
2510
  import fsPromise2 from "fs/promises";
2505
2511
  import yaml2 from "js-yaml";
2506
2512
  import openBrowser from "open";
2507
- import ora2 from "ora";
2513
+ import ora3 from "ora";
2508
2514
  import path5 from "path";
2509
2515
  import * as vite from "vite";
2510
2516
  import commonjs from "vite-plugin-commonjs";
@@ -4847,7 +4853,7 @@ var ApplicationRunner = class {
4847
4853
  const chatModel = new ChatOpenAI3({ modelName: "gpt-4o", openAIApiKey });
4848
4854
  const projectName = await input3({ message: "please enter project name." });
4849
4855
  const projectDesc = await input3({ message: "please enter project description. (40 ~ 60 characters)" });
4850
- const spinner = ora2("Gerating project files...");
4856
+ const spinner = ora3("Gerating project files...");
4851
4857
  const mainPrompt = PromptTemplate2.fromTemplate(requestApplication());
4852
4858
  const chain = RunnableSequence2.from([mainPrompt, chatModel, new StringOutputParser()]);
4853
4859
  const resultOne = await chain.invoke({ projectName, projectDesc });
@@ -5023,7 +5029,7 @@ var ApplicationScript = class {
5023
5029
  var ApplicationCommand = class {
5024
5030
  applicationScript = new ApplicationScript();
5025
5031
  async createApplication(name, start, workspace) {
5026
- await this.applicationScript.createApplication(name, workspace, { start });
5032
+ await this.applicationScript.createApplication(name.toLowerCase().replace(/ /g, "-"), workspace, { start });
5027
5033
  }
5028
5034
  async removeApplication(app) {
5029
5035
  await this.applicationScript.removeApplication(app);
@@ -5522,7 +5528,7 @@ CloudCommand = __decorateClass([
5522
5528
  var LibraryCommand = class {
5523
5529
  libraryScript = new LibraryScript();
5524
5530
  async createLibrary(name, workspace) {
5525
- await this.libraryScript.createLibrary(name, workspace);
5531
+ await this.libraryScript.createLibrary(name.toLowerCase().replace(/ /g, "-"), workspace);
5526
5532
  }
5527
5533
  async removeLibrary(lib) {
5528
5534
  await this.libraryScript.removeLibrary(lib);
@@ -5931,7 +5937,7 @@ var PackageCommand = class {
5931
5937
  await this.packageScript.version(workspace);
5932
5938
  }
5933
5939
  async createPackage(name, workspace) {
5934
- await this.packageScript.createPackage(workspace, name);
5940
+ await this.packageScript.createPackage(workspace, name.toLowerCase().replace(/ /g, "-"));
5935
5941
  }
5936
5942
  async removePackage(pkg) {
5937
5943
  await this.packageScript.removePackage(pkg);
@@ -6141,7 +6147,7 @@ var WorkspaceScript = class {
6141
6147
  var WorkspaceCommand = class {
6142
6148
  workspaceScript = new WorkspaceScript();
6143
6149
  async createWorkspace(name, app, dir) {
6144
- await this.workspaceScript.createWorkspace(name, app, dir);
6150
+ await this.workspaceScript.createWorkspace(name, app.toLowerCase().replace(/ /g, "-"), dir);
6145
6151
  }
6146
6152
  async generateMongo(workspace) {
6147
6153
  await this.workspaceScript.generateMongo(workspace);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "sourceType": "module",
3
3
  "name": "@akanjs/cli",
4
- "version": "0.0.136",
4
+ "version": "0.0.137",
5
5
  "bin": {
6
6
  "akan": "cjs/index.js"
7
7
  },