@akanjs/cli 0.0.142 → 0.0.143

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/README.md CHANGED
@@ -64,11 +64,13 @@ Complete workspace and project management:
64
64
  Full-stack application development and deployment:
65
65
 
66
66
  - **🔧 Application Management**
67
+
67
68
  - `create-application` - Scaffold new applications with templates
68
69
  - `remove-application` - Clean application removal
69
70
  - `sync-application` - Synchronize application dependencies
70
71
 
71
72
  - **🏗️ Build System**
73
+
72
74
  - `build` - Complete application build
73
75
  - `build-backend` - Server-side build optimization
74
76
  - `build-frontend` - Client-side build with Next.js
@@ -77,6 +79,7 @@ Full-stack application development and deployment:
77
79
  - `build-android` - Android native app compilation
78
80
 
79
81
  - **🚀 Development Server**
82
+
80
83
  - `start` - Full-stack development server
81
84
  - `start-backend` - GraphQL backend server
82
85
  - `start-frontend` - Next.js frontend server with Turbo support
@@ -85,6 +88,7 @@ Full-stack application development and deployment:
85
88
  - `start-android` - Android emulator with live reload
86
89
 
87
90
  - **📦 Release Management**
91
+
88
92
  - `release-ios` - iOS App Store deployment
89
93
  - `release-android` - Google Play deployment
90
94
  - `release-source` - Source code release with versioning
@@ -100,6 +104,7 @@ Full-stack application development and deployment:
100
104
  Modular library system for code reusability:
101
105
 
102
106
  - **📦 Library Operations**
107
+
103
108
  - `create-library` - Create new shared libraries
104
109
  - `remove-library` - Clean library removal
105
110
  - `sync-library` - Synchronize library dependencies
@@ -114,6 +119,7 @@ Modular library system for code reusability:
114
119
  AI-powered module generation and management:
115
120
 
116
121
  - **🤖 Smart Module Creation**
122
+
117
123
  - `create-module` - Generate modules with AI assistance
118
124
  - `create-scalar` - Create scalar data models
119
125
  - `remove-module` - Module cleanup with dependency checks
@@ -135,10 +141,12 @@ Dynamic page scaffolding:
135
141
  Seamless cloud services and AI integration:
136
142
 
137
143
  - **🔐 Authentication**
144
+
138
145
  - `login` / `logout` - Cloud service authentication
139
146
  - User session and credential management
140
147
 
141
148
  - **🤖 AI Development Assistant**
149
+
142
150
  - `set-llm` / `reset-llm` - Configure AI language models
143
151
  - `ask` - Interactive AI development assistance
144
152
 
package/cjs/index.js CHANGED
@@ -980,6 +980,7 @@ var execEmoji = {
980
980
  lib: "\u{1F527}",
981
981
  pkg: "\u{1F4E6}",
982
982
  dist: "\u{1F4BF}",
983
+ module: "\u2699\uFE0F",
983
984
  default: "\u2708\uFE0F"
984
985
  // for sys executor
985
986
  };
@@ -1754,6 +1755,17 @@ var PkgExecutor = class _PkgExecutor extends Executor {
1754
1755
  return pkgScanResult;
1755
1756
  }
1756
1757
  };
1758
+ var ModuleExecutor = class _ModuleExecutor extends Executor {
1759
+ sys;
1760
+ emoji = execEmoji.module;
1761
+ constructor({ sys: sys2, name }) {
1762
+ super(name, `${sys2.workspace.workspaceRoot}/${sys2.type}s/${sys2.name}/lib/${name}`);
1763
+ this.sys = sys2;
1764
+ }
1765
+ static from(sysExecutor, name) {
1766
+ return new _ModuleExecutor({ sys: sysExecutor, name });
1767
+ }
1768
+ };
1757
1769
 
1758
1770
  // pkgs/@akanjs/devkit/src/constants.ts
1759
1771
  var import_os = require("os");
@@ -2104,6 +2116,7 @@ var Lib = createArgMetaDecorator("Lib");
2104
2116
  var Sys = createArgMetaDecorator("Sys");
2105
2117
  var Exec = createArgMetaDecorator("Exec");
2106
2118
  var Pkg = createArgMetaDecorator("Pkg");
2119
+ var Module = createArgMetaDecorator("Module");
2107
2120
  var Workspace = createArgMetaDecorator("Workspace");
2108
2121
 
2109
2122
  // pkgs/@akanjs/devkit/src/commandDecorators/commandMeta.ts
@@ -2284,6 +2297,38 @@ var getInternalArgumentValue = async (argMeta, value, workspace) => {
2284
2297
  return PkgExecutor.from(workspace, value);
2285
2298
  const pkgName = await (0, import_prompts3.select)({ message: `Select the ${sysType} name`, choices: pkgs });
2286
2299
  return PkgExecutor.from(workspace, pkgName);
2300
+ } else if (sysType === "module") {
2301
+ if (value) {
2302
+ const [sysName, moduleName2] = value.split(":");
2303
+ if (appNames.includes(sysName)) {
2304
+ const app = AppExecutor.from(workspace, sysName);
2305
+ const modules2 = await app.getModules();
2306
+ if (modules2.includes(moduleName2))
2307
+ return ModuleExecutor.from(app, moduleName2);
2308
+ else
2309
+ throw new Error(`Invalid module name: ${moduleName2}`);
2310
+ } else if (libNames.includes(sysName)) {
2311
+ const lib = LibExecutor.from(workspace, sysName);
2312
+ const modules2 = await lib.getModules();
2313
+ if (modules2.includes(moduleName2))
2314
+ return ModuleExecutor.from(lib, moduleName2);
2315
+ } else
2316
+ throw new Error(`Invalid system name: ${sysName}`);
2317
+ }
2318
+ const { type, name } = await (0, import_prompts3.select)({
2319
+ message: `select the App or Lib name`,
2320
+ choices: [
2321
+ ...appNames.map((name2) => ({ name: name2, value: { type: "app", name: name2 } })),
2322
+ ...libNames.map((name2) => ({ name: name2, value: { type: "lib", name: name2 } }))
2323
+ ]
2324
+ });
2325
+ const executor = type === "app" ? AppExecutor.from(workspace, name) : LibExecutor.from(workspace, name);
2326
+ const modules = await executor.getModules();
2327
+ const moduleName = await (0, import_prompts3.select)({
2328
+ message: `Select the module name`,
2329
+ choices: modules.map((name2) => ({ name: `${executor.name}:${name2}`, value: name2 }))
2330
+ });
2331
+ return ModuleExecutor.from(executor, moduleName);
2287
2332
  } else
2288
2333
  throw new Error(`Invalid system type: ${argMeta.type}`);
2289
2334
  };
@@ -2315,11 +2360,18 @@ var runCommands = async (...commands) => {
2315
2360
  programCommand = handleArgument(programCommand, argMeta);
2316
2361
  else if (argMeta.type === "Workspace")
2317
2362
  continue;
2318
- const sysType = argMeta.type.toLowerCase();
2319
- programCommand = programCommand.argument(
2320
- `[${sysType}]`,
2321
- `${sysType} in this workspace ${sysType}s/<${sysType}Name>`
2322
- );
2363
+ else if (argMeta.type === "Module") {
2364
+ programCommand = programCommand.argument(
2365
+ `[sys-name:module-name]`,
2366
+ `${argMeta.type} in this workspace (apps|libs)/<sys-name>/lib/<module-name>`
2367
+ );
2368
+ } else {
2369
+ const sysType = argMeta.type.toLowerCase();
2370
+ programCommand = programCommand.argument(
2371
+ `[${sysType}]`,
2372
+ `${sysType} in this workspace ${sysType}s/<${sysType}Name>`
2373
+ );
2374
+ }
2323
2375
  }
2324
2376
  programCommand = programCommand.option(`-v, --verbose [boolean]`, `verbose output`);
2325
2377
  programCommand.action(async (...args) => {
@@ -2437,8 +2489,10 @@ var AiSession = class _AiSession {
2437
2489
  Logger.raw(chunk);
2438
2490
  }
2439
2491
  } = {}) {
2440
- if (!_AiSession.#chat)
2492
+ if (!_AiSession.#chat) {
2493
+ Logger.rawLog(import_chalk3.default.yellow("\u{1F916}akan-editor is not initialized. LLM configuration should be set first."));
2441
2494
  await _AiSession.init();
2495
+ }
2442
2496
  if (!_AiSession.#chat)
2443
2497
  throw new Error("Failed to initialize the AI session");
2444
2498
  const loader = new Spinner(`${_AiSession.#chat.model} is thinking...`, {
@@ -5524,7 +5578,6 @@ var CloudScript = class {
5524
5578
  this.#runner.resetLlm();
5525
5579
  }
5526
5580
  async ask(question, workspace) {
5527
- await AiSession.init();
5528
5581
  const session = new AiSession();
5529
5582
  await session.ask(question);
5530
5583
  }
@@ -5656,9 +5709,6 @@ LibraryCommand = __decorateClass([
5656
5709
  Commands()
5657
5710
  ], LibraryCommand);
5658
5711
 
5659
- // pkgs/@akanjs/cli/src/module/module.command.ts
5660
- var import_prompts8 = require("@inquirer/prompts");
5661
-
5662
5712
  // pkgs/@akanjs/cli/src/module/module.script.ts
5663
5713
  var import_fs10 = __toESM(require("fs"));
5664
5714
 
@@ -5973,8 +6023,8 @@ var requestUnit = ({
5973
6023
  var ModuleRunner = class {
5974
6024
  async createModule(workspace, sysType, sysName, moduleName, description) {
5975
6025
  }
5976
- removeModule(sys2, name) {
5977
- sys2.removeDir(`${sys2.cwdPath}/lib/${name}`);
6026
+ removeModule(module2) {
6027
+ module2.sys.removeDir(`lib/${module2.name}`);
5978
6028
  }
5979
6029
  async createScalarTemplate(sys2, name) {
5980
6030
  const akanConfig = await sys2.getConfig();
@@ -6016,20 +6066,20 @@ var ModuleRunner = class {
6016
6066
  dictionary: { filename: `${name}.dictionary.ts`, content: sys2.readFile(`lib/${name}/${name}.dictionary.ts`) }
6017
6067
  };
6018
6068
  }
6019
- async createComponentTemplate(sys2, name, type) {
6020
- const akanConfig = await sys2.getConfig();
6021
- const scanResult = await sys2.scan({ akanConfig });
6022
- await sys2.applyTemplate({
6023
- basePath: `./lib/${name}`,
6024
- template: `module/__Model__.${capitalize(type)}.ts`,
6069
+ async createComponentTemplate(module2, type) {
6070
+ const akanConfig = await module2.sys.getConfig();
6071
+ const scanResult = await module2.sys.scan({ akanConfig });
6072
+ await module2.sys.applyTemplate({
6073
+ basePath: `./lib/${module2.name}`,
6074
+ template: `module/${capitalize(module2.name)}.${capitalize(type)}.ts`,
6025
6075
  scanResult,
6026
- dict: { model: name, Model: capitalize(name), appName: sys2.name }
6076
+ dict: { model: module2.name, Model: capitalize(module2.name), appName: module2.sys.name }
6027
6077
  });
6028
- await sys2.scan({ akanConfig });
6078
+ await module2.sys.scan({ akanConfig });
6029
6079
  return {
6030
6080
  component: {
6031
- filename: `${name}.${capitalize(type)}.tsx`,
6032
- content: sys2.readFile(`lib/${name}/${capitalize(name)}.${capitalize(type)}.tsx`)
6081
+ filename: `${module2.name}.${capitalize(type)}.tsx`,
6082
+ content: module2.sys.readFile(`lib/${module2.name}/${capitalize(module2.name)}.${capitalize(type)}.tsx`)
6033
6083
  }
6034
6084
  // constant: {
6035
6085
  // filename: `${name}.constant.ts`,
@@ -6041,65 +6091,68 @@ var ModuleRunner = class {
6041
6091
  // },
6042
6092
  };
6043
6093
  }
6044
- async createModuleTemplate(sys2, name) {
6045
- const akanConfig = await sys2.getConfig();
6046
- const scanResult = await sys2.scan({ akanConfig });
6047
- const names = (0, import_pluralize.default)(name);
6048
- await sys2.applyTemplate({
6049
- basePath: `./lib/${name}`,
6094
+ async createModuleTemplate(module2) {
6095
+ const akanConfig = await module2.sys.getConfig();
6096
+ const scanResult = await module2.sys.scan({ akanConfig });
6097
+ const names = (0, import_pluralize.default)(module2.name);
6098
+ await module2.applyTemplate({
6099
+ basePath: `.`,
6050
6100
  template: "module",
6051
6101
  scanResult,
6052
6102
  dict: {
6053
- model: name,
6054
- Model: capitalize(name),
6103
+ model: module2.name,
6104
+ Model: capitalize(module2.name),
6055
6105
  models: names,
6056
6106
  Models: capitalize(names),
6057
- sysName: sys2.name,
6058
- SysName: capitalize(sys2.name)
6107
+ sysName: module2.sys.name,
6108
+ SysName: capitalize(module2.sys.name)
6059
6109
  }
6060
6110
  });
6061
- await sys2.scan({ akanConfig });
6111
+ await module2.sys.scan({ akanConfig });
6062
6112
  return {
6063
- constant: { filename: `${name}.constant.ts`, content: sys2.readFile(`lib/${name}/${name}.constant.ts`) },
6113
+ constant: {
6114
+ filename: `${module2.name}.constant.ts`,
6115
+ content: module2.readFile(`${module2.name}.constant.ts`)
6116
+ },
6064
6117
  dictionary: {
6065
- filename: `${name}.dictionary.ts`,
6066
- content: sys2.readFile(`lib/${name}/${name}.dictionary.ts`)
6118
+ filename: `${module2.name}.dictionary.ts`,
6119
+ content: module2.readFile(`${module2.name}.dictionary.ts`)
6067
6120
  },
6068
6121
  service: {
6069
- filename: `${name}.service.ts`,
6070
- content: sys2.readFile(`lib/${name}/${name}.service.ts`)
6122
+ filename: `${module2.name}.service.ts`,
6123
+ content: module2.readFile(`${module2.name}.service.ts`)
6071
6124
  },
6072
6125
  store: {
6073
- filename: `${name}.store.ts`,
6074
- content: sys2.readFile(`lib/${name}/${name}.store.ts`)
6126
+ filename: `${module2.name}.store.ts`,
6127
+ content: module2.readFile(`${module2.name}.store.ts`)
6075
6128
  },
6076
6129
  signal: {
6077
- filename: `${name}.signal.ts`,
6078
- content: sys2.readFile(`lib/${name}/${name}.signal.spec.ts`)
6130
+ filename: `${module2.name}.signal.ts`,
6131
+ content: module2.readFile(`${module2.name}.signal.spec.ts`)
6079
6132
  },
6080
6133
  test: {
6081
- filename: `${name}.test.ts`,
6082
- content: sys2.readFile(`lib/${name}/${name}.signal.test.ts`)
6134
+ filename: `${module2.name}.test.ts`,
6135
+ content: module2.readFile(`${module2.name}.signal.test.ts`)
6083
6136
  },
6084
6137
  unit: {
6085
- filename: `${name}.Unit.tsx`,
6086
- content: sys2.readFile(`lib/${name}/${name}.Unit.tsx`)
6138
+ filename: `${module2.name}.Unit.tsx`,
6139
+ content: module2.readFile(`${module2.name}.Unit.tsx`)
6087
6140
  },
6088
6141
  view: {
6089
- filename: `${name}.View.tsx`,
6090
- content: sys2.readFile(`lib/${name}/${name}.View.tsx`)
6142
+ filename: `${module2.name}.View.tsx`,
6143
+ content: module2.readFile(`${module2.name}.View.tsx`)
6091
6144
  },
6092
6145
  template: {
6093
- filename: `${name}.Template.tsx`,
6094
- content: sys2.readFile(`lib/${name}/${name}.Template.tsx`)
6146
+ filename: `${module2.name}.Template.tsx`,
6147
+ content: module2.readFile(`${module2.name}.Template.tsx`)
6095
6148
  },
6096
6149
  zone: {
6097
- filename: `${name}.Zone.tsx`,
6098
- content: sys2.readFile(`lib/${name}/${name}.Zone.tsx`)
6150
+ filename: `${module2.name}.Zone.tsx`,
6151
+ content: module2.readFile(`${module2.name}.Zone.tsx`)
6099
6152
  },
6100
6153
  util: {
6101
- filename: `${name}.Util.tsx`,
6102
- content: sys2.readFile(`lib/${name}/${name}.Util.tsx`)
6154
+ filename: `${module2.name}.Util.tsx`,
6155
+ content: module2.readFile(`${module2.name}.Util.tsx`)
6103
6156
  }
6104
6157
  };
6105
6158
  }
@@ -6108,17 +6161,17 @@ var ModuleRunner = class {
6108
6161
  // pkgs/@akanjs/cli/src/module/module.script.ts
6109
6162
  var ModuleScript = class {
6110
6163
  #runner = new ModuleRunner();
6111
- //! .command arg에 병합 필요.
6112
- async createModuleTemplate(sys2, name, description) {
6113
- await this.#runner.createModuleTemplate(sys2, name);
6164
+ async createModuleTemplate(sys2, name) {
6165
+ const executor = ModuleExecutor.from(sys2, name);
6166
+ await this.#runner.createModuleTemplate(executor);
6114
6167
  }
6115
6168
  async createModule(sys2, name, description, schemaDescription) {
6116
- await AiSession.init();
6117
6169
  const session = new AiSession();
6118
6170
  const [appNames, libNames] = await sys2.workspace.getSyss();
6119
6171
  const moduleConstantExampleFiles = await sys2.workspace.getConstantFiles();
6120
6172
  const moduleDictionaryExampleFiles = await sys2.workspace.getDictionaryFiles();
6121
- const { constant, dictionary } = await this.#runner.createModuleTemplate(sys2, name);
6173
+ const executor = ModuleExecutor.from(sys2, name);
6174
+ const { constant, dictionary } = await this.#runner.createModuleTemplate(executor);
6122
6175
  sys2.log(`Module ${name} created in ${sys2.type}s/${sys2.name}/lib/${name}`);
6123
6176
  const constantContent = await session.editTypescript(
6124
6177
  requestConstant({
@@ -6143,28 +6196,27 @@ var ModuleScript = class {
6143
6196
  })
6144
6197
  );
6145
6198
  sys2.writeFile(`lib/${name}/${name}.dictionary.ts`, dictionaryContent);
6146
- await this.createView(sys2, name);
6147
- await this.createUnit(sys2, name);
6148
- await this.createTemplate(sys2, name);
6199
+ await this.createView(executor);
6200
+ await this.createUnit(executor);
6201
+ await this.createTemplate(executor);
6149
6202
  sys2.log(`Module ${name} created in ${sys2.type}s/${sys2.name}/lib/${name}`);
6150
6203
  }
6151
6204
  async createModule_(sys2, name, description, schemaDescription) {
6152
- await AiSession.init();
6153
6205
  const session = new AiSession();
6154
6206
  const [appNames, libNames] = await sys2.workspace.getSyss();
6155
6207
  const moduleConstantExampleFiles = await sys2.workspace.getConstantFiles();
6156
6208
  const moduleDictionaryExampleFiles = await sys2.workspace.getDictionaryFiles();
6209
+ const executor = ModuleExecutor.from(sys2, name);
6157
6210
  sys2.log(`Module ${name} created in ${sys2.type}s/${sys2.name}/lib/${name}`);
6158
- await this.createView(sys2, name);
6159
- await this.createUnit(sys2, name);
6160
- await this.createTemplate(sys2, name);
6211
+ await this.createView(executor);
6212
+ await this.createUnit(executor);
6213
+ await this.createTemplate(executor);
6161
6214
  sys2.log(`Module ${name} created in ${sys2.type}s/${sys2.name}/lib/${name}`);
6162
6215
  }
6163
- removeModule(sys2, name) {
6164
- this.#runner.removeModule(sys2, name);
6216
+ removeModule(module2) {
6217
+ this.#runner.removeModule(module2);
6165
6218
  }
6166
6219
  async createScalar(sys2, name, description, schemaDescription) {
6167
- await AiSession.init();
6168
6220
  const scalarConstantExampleFiles = await sys2.workspace.getScalarConstantFiles();
6169
6221
  const { constant, dictionary } = await this.#runner.createScalarTemplate(sys2, name);
6170
6222
  const session = new AiSession();
@@ -6184,19 +6236,18 @@ var ModuleScript = class {
6184
6236
  }
6185
6237
  async createTest(workspace, name) {
6186
6238
  }
6187
- async createTemplate(sys2, name) {
6188
- await AiSession.init();
6189
- const { component: template } = await this.#runner.createComponentTemplate(sys2, name, "template");
6190
- const templateExampleFiles = (await sys2.getTemplatesSourceCode()).filter(
6191
- (f) => !f.filepath.includes(`${name}.Template.tsx`)
6239
+ async createTemplate(module2) {
6240
+ const { component: template } = await this.#runner.createComponentTemplate(module2, "template");
6241
+ const templateExampleFiles = (await module2.sys.getTemplatesSourceCode()).filter(
6242
+ (f) => !f.filepath.includes(`${module2.name}.Template.tsx`)
6192
6243
  );
6193
- const Name = capitalize(name);
6194
- const relatedCnsts = getRelatedCnsts(`${sys2.cwdPath}/lib/${name}/${name}.constant.ts`);
6195
- const constant = import_fs10.default.readFileSync(`${sys2.cwdPath}/lib/${name}/${name}.constant.ts`, "utf-8");
6244
+ const Name = capitalize(module2.name);
6245
+ const relatedCnsts = getRelatedCnsts(`${module2.sys.cwdPath}/lib/${module2.name}/${module2.name}.constant.ts`);
6246
+ const constant = import_fs10.default.readFileSync(`${module2.sys.cwdPath}/lib/${module2.name}/${module2.name}.constant.ts`, "utf-8");
6196
6247
  const session = new AiSession();
6197
6248
  const promptRst = requestTemplate({
6198
- sysName: sys2.name,
6199
- modelName: name,
6249
+ sysName: module2.sys.name,
6250
+ modelName: module2.name,
6200
6251
  ModelName: Name,
6201
6252
  constant,
6202
6253
  boilerplate: template.content,
@@ -6204,19 +6255,20 @@ var ModuleScript = class {
6204
6255
  exampleFiles: randomPicks(templateExampleFiles, Math.min(20, templateExampleFiles.length))
6205
6256
  });
6206
6257
  const content = await session.editTypescript(promptRst);
6207
- sys2.writeFile(`lib/${name}/${Name}.Template.tsx`, content);
6208
- }
6209
- async createUnit(sys2, name) {
6210
- await AiSession.init();
6211
- const { component: unit } = await this.#runner.createComponentTemplate(sys2, name, "unit");
6212
- const Name = capitalize(name);
6213
- const unitExampleFiles = (await sys2.getUnitsSourceCode()).filter((f) => !f.filepath.includes(`${name}.Unit.tsx`));
6214
- const relatedCnsts = getRelatedCnsts(`${sys2.cwdPath}/lib/${name}/${name}.constant.ts`);
6215
- const constant = import_fs10.default.readFileSync(`${sys2.cwdPath}/lib/${name}/${name}.constant.ts`, "utf-8");
6258
+ module2.writeFile(`${Name}.Template.tsx`, content);
6259
+ }
6260
+ async createUnit(module2) {
6261
+ const { component: unit } = await this.#runner.createComponentTemplate(module2, "unit");
6262
+ const Name = capitalize(module2.name);
6263
+ const unitExampleFiles = (await module2.sys.getUnitsSourceCode()).filter(
6264
+ (f) => !f.filepath.includes(`${module2.name}.Unit.tsx`)
6265
+ );
6266
+ const relatedCnsts = getRelatedCnsts(`${module2.sys.cwdPath}/lib/${module2.name}/${module2.name}.constant.ts`);
6267
+ const constant = import_fs10.default.readFileSync(`${module2.sys.cwdPath}/lib/${module2.name}/${module2.name}.constant.ts`, "utf-8");
6216
6268
  const session = new AiSession();
6217
6269
  const promptRst = requestUnit({
6218
- sysName: sys2.name,
6219
- modelName: name,
6270
+ sysName: module2.sys.name,
6271
+ modelName: module2.name,
6220
6272
  ModelName: Name,
6221
6273
  constant,
6222
6274
  properties: relatedCnsts.map((r) => ({ key: r.key, source: r.source })),
@@ -6224,19 +6276,20 @@ var ModuleScript = class {
6224
6276
  boilerplate: unit.content
6225
6277
  });
6226
6278
  const content = await session.editTypescript(promptRst);
6227
- sys2.writeFile(`lib/${name}/${Name}.Unit.tsx`, content);
6228
- }
6229
- async createView(sys2, name) {
6230
- await AiSession.init();
6231
- const { component: view } = await this.#runner.createComponentTemplate(sys2, name, "view");
6232
- const viewExampleFiles = (await sys2.getViewsSourceCode()).filter((f) => !f.filepath.includes(`${name}.View.tsx`));
6233
- const Name = capitalize(name);
6234
- const relatedCnsts = getRelatedCnsts(`${sys2.cwdPath}/lib/${name}/${name}.constant.ts`);
6235
- const constant = import_fs10.default.readFileSync(`${sys2.cwdPath}/lib/${name}/${name}.constant.ts`, "utf-8");
6279
+ module2.writeFile(`${Name}.Unit.tsx`, content);
6280
+ }
6281
+ async createView(module2) {
6282
+ const { component: view } = await this.#runner.createComponentTemplate(module2, "view");
6283
+ const viewExampleFiles = (await module2.sys.getViewsSourceCode()).filter(
6284
+ (f) => !f.filepath.includes(`${module2.name}.View.tsx`)
6285
+ );
6286
+ const Name = capitalize(module2.name);
6287
+ const relatedCnsts = getRelatedCnsts(`${module2.sys.cwdPath}/lib/${module2.name}/${module2.name}.constant.ts`);
6288
+ const constant = import_fs10.default.readFileSync(`${module2.sys.cwdPath}/lib/${module2.name}/${module2.name}.constant.ts`, "utf-8");
6236
6289
  const session = new AiSession();
6237
6290
  const promptRst = requestView({
6238
- sysName: sys2.name,
6239
- modelName: name,
6291
+ sysName: module2.sys.name,
6292
+ modelName: module2.name,
6240
6293
  ModelName: Name,
6241
6294
  constant,
6242
6295
  boilerplate: view.content,
@@ -6244,25 +6297,14 @@ var ModuleScript = class {
6244
6297
  exampleFiles: randomPicks(viewExampleFiles, Math.min(20, viewExampleFiles.length))
6245
6298
  });
6246
6299
  const content = await session.editTypescript(promptRst);
6247
- sys2.writeFile(`lib/${name}/${Name}.View.tsx`, content);
6300
+ module2.writeFile(`${Name}.View.tsx`, content);
6248
6301
  }
6249
6302
  };
6250
6303
 
6251
6304
  // pkgs/@akanjs/cli/src/module/module.command.ts
6252
6305
  var ModuleCommand = class {
6253
6306
  moduleScript = new ModuleScript();
6254
- async selectLib(sys2) {
6255
- const libs = await sys2.getModules();
6256
- const lib = await (0, import_prompts8.select)({
6257
- message: "Select the lib",
6258
- choices: libs.map((l) => `${sys2.name}/${l}`)
6259
- }).catch((e) => {
6260
- Logger.error("canceled");
6261
- return null;
6262
- });
6263
- return lib?.split("/").pop();
6264
- }
6265
- async createModule(sys2, moduleName, description, schemaDescription, ai, workspace) {
6307
+ async createModule(sys2, moduleName, description, schemaDescription, ai) {
6266
6308
  const name = lowerlize(moduleName.replace(/ /g, ""));
6267
6309
  if (ai) {
6268
6310
  await this.moduleScript.createModule(sys2, name, description, schemaDescription);
@@ -6270,32 +6312,20 @@ var ModuleCommand = class {
6270
6312
  await this.moduleScript.createModuleTemplate(sys2, name);
6271
6313
  }
6272
6314
  }
6273
- async removeModule(sys2, workspace) {
6274
- const name = await this.selectLib(sys2);
6275
- if (!name)
6276
- return;
6277
- this.moduleScript.removeModule(sys2, name);
6315
+ removeModule(module2) {
6316
+ this.moduleScript.removeModule(module2);
6278
6317
  }
6279
- async createScalar(sys2, scalarName, description, schemaDescription, workspace) {
6318
+ async createScalar(sys2, scalarName, description, schemaDescription) {
6280
6319
  await this.moduleScript.createScalar(sys2, lowerlize(scalarName.replace(/ /g, "")), description, schemaDescription);
6281
6320
  }
6282
- async createView(sys2, workspace) {
6283
- const name = await this.selectLib(sys2);
6284
- if (!name)
6285
- return;
6286
- await this.moduleScript.createView(sys2, name);
6321
+ async createView(module2) {
6322
+ await this.moduleScript.createView(module2);
6287
6323
  }
6288
- async createUnit(sys2, workspace) {
6289
- const name = await this.selectLib(sys2);
6290
- if (!name)
6291
- return;
6292
- await this.moduleScript.createUnit(sys2, name);
6324
+ async createUnit(module2) {
6325
+ await this.moduleScript.createUnit(module2);
6293
6326
  }
6294
- async createTemplate(sys2, workspace) {
6295
- const name = await this.selectLib(sys2);
6296
- if (!name)
6297
- return;
6298
- await this.moduleScript.createTemplate(sys2, name);
6327
+ async createTemplate(module2) {
6328
+ await this.moduleScript.createTemplate(module2);
6299
6329
  }
6300
6330
  };
6301
6331
  __decorateClass([
@@ -6304,36 +6334,30 @@ __decorateClass([
6304
6334
  __decorateParam(1, Argument("moduleName", { desc: "name of module" })),
6305
6335
  __decorateParam(2, Option("description", { desc: "description of module" })),
6306
6336
  __decorateParam(3, Option("schemaDescription", { desc: "schema description of module" })),
6307
- __decorateParam(4, Option("ai", { type: "boolean", default: false, desc: "use ai to create module" })),
6308
- __decorateParam(5, Workspace())
6337
+ __decorateParam(4, Option("ai", { type: "boolean", default: false, desc: "use ai to create module" }))
6309
6338
  ], ModuleCommand.prototype, "createModule", 1);
6310
6339
  __decorateClass([
6311
6340
  Target.Public(),
6312
- __decorateParam(0, Sys()),
6313
- __decorateParam(1, Workspace())
6341
+ __decorateParam(0, Module())
6314
6342
  ], ModuleCommand.prototype, "removeModule", 1);
6315
6343
  __decorateClass([
6316
6344
  Target.Public(),
6317
6345
  __decorateParam(0, Sys()),
6318
6346
  __decorateParam(1, Argument("scalarName", { desc: "name of scalar module" })),
6319
6347
  __decorateParam(2, Option("description", { desc: "description of scalar module" })),
6320
- __decorateParam(3, Option("schemaDescription", { desc: "schema description of scalar module" })),
6321
- __decorateParam(4, Workspace())
6348
+ __decorateParam(3, Option("schemaDescription", { desc: "schema description of scalar module" }))
6322
6349
  ], ModuleCommand.prototype, "createScalar", 1);
6323
6350
  __decorateClass([
6324
6351
  Target.Public(),
6325
- __decorateParam(0, Sys()),
6326
- __decorateParam(1, Workspace())
6352
+ __decorateParam(0, Module())
6327
6353
  ], ModuleCommand.prototype, "createView", 1);
6328
6354
  __decorateClass([
6329
6355
  Target.Public(),
6330
- __decorateParam(0, Sys()),
6331
- __decorateParam(1, Workspace())
6356
+ __decorateParam(0, Module())
6332
6357
  ], ModuleCommand.prototype, "createUnit", 1);
6333
6358
  __decorateClass([
6334
6359
  Target.Public(),
6335
- __decorateParam(0, Sys()),
6336
- __decorateParam(1, Workspace())
6360
+ __decorateParam(0, Module())
6337
6361
  ], ModuleCommand.prototype, "createTemplate", 1);
6338
6362
  ModuleCommand = __decorateClass([
6339
6363
  Commands()
package/esm/index.js CHANGED
@@ -967,6 +967,7 @@ var execEmoji = {
967
967
  lib: "\u{1F527}",
968
968
  pkg: "\u{1F4E6}",
969
969
  dist: "\u{1F4BF}",
970
+ module: "\u2699\uFE0F",
970
971
  default: "\u2708\uFE0F"
971
972
  // for sys executor
972
973
  };
@@ -1741,6 +1742,17 @@ var PkgExecutor = class _PkgExecutor extends Executor {
1741
1742
  return pkgScanResult;
1742
1743
  }
1743
1744
  };
1745
+ var ModuleExecutor = class _ModuleExecutor extends Executor {
1746
+ sys;
1747
+ emoji = execEmoji.module;
1748
+ constructor({ sys: sys2, name }) {
1749
+ super(name, `${sys2.workspace.workspaceRoot}/${sys2.type}s/${sys2.name}/lib/${name}`);
1750
+ this.sys = sys2;
1751
+ }
1752
+ static from(sysExecutor, name) {
1753
+ return new _ModuleExecutor({ sys: sysExecutor, name });
1754
+ }
1755
+ };
1744
1756
 
1745
1757
  // pkgs/@akanjs/devkit/src/constants.ts
1746
1758
  import { homedir } from "os";
@@ -2091,6 +2103,7 @@ var Lib = createArgMetaDecorator("Lib");
2091
2103
  var Sys = createArgMetaDecorator("Sys");
2092
2104
  var Exec = createArgMetaDecorator("Exec");
2093
2105
  var Pkg = createArgMetaDecorator("Pkg");
2106
+ var Module = createArgMetaDecorator("Module");
2094
2107
  var Workspace = createArgMetaDecorator("Workspace");
2095
2108
 
2096
2109
  // pkgs/@akanjs/devkit/src/commandDecorators/commandMeta.ts
@@ -2271,6 +2284,38 @@ var getInternalArgumentValue = async (argMeta, value, workspace) => {
2271
2284
  return PkgExecutor.from(workspace, value);
2272
2285
  const pkgName = await select2({ message: `Select the ${sysType} name`, choices: pkgs });
2273
2286
  return PkgExecutor.from(workspace, pkgName);
2287
+ } else if (sysType === "module") {
2288
+ if (value) {
2289
+ const [sysName, moduleName2] = value.split(":");
2290
+ if (appNames.includes(sysName)) {
2291
+ const app = AppExecutor.from(workspace, sysName);
2292
+ const modules2 = await app.getModules();
2293
+ if (modules2.includes(moduleName2))
2294
+ return ModuleExecutor.from(app, moduleName2);
2295
+ else
2296
+ throw new Error(`Invalid module name: ${moduleName2}`);
2297
+ } else if (libNames.includes(sysName)) {
2298
+ const lib = LibExecutor.from(workspace, sysName);
2299
+ const modules2 = await lib.getModules();
2300
+ if (modules2.includes(moduleName2))
2301
+ return ModuleExecutor.from(lib, moduleName2);
2302
+ } else
2303
+ throw new Error(`Invalid system name: ${sysName}`);
2304
+ }
2305
+ const { type, name } = await select2({
2306
+ message: `select the App or Lib name`,
2307
+ choices: [
2308
+ ...appNames.map((name2) => ({ name: name2, value: { type: "app", name: name2 } })),
2309
+ ...libNames.map((name2) => ({ name: name2, value: { type: "lib", name: name2 } }))
2310
+ ]
2311
+ });
2312
+ const executor = type === "app" ? AppExecutor.from(workspace, name) : LibExecutor.from(workspace, name);
2313
+ const modules = await executor.getModules();
2314
+ const moduleName = await select2({
2315
+ message: `Select the module name`,
2316
+ choices: modules.map((name2) => ({ name: `${executor.name}:${name2}`, value: name2 }))
2317
+ });
2318
+ return ModuleExecutor.from(executor, moduleName);
2274
2319
  } else
2275
2320
  throw new Error(`Invalid system type: ${argMeta.type}`);
2276
2321
  };
@@ -2302,11 +2347,18 @@ var runCommands = async (...commands) => {
2302
2347
  programCommand = handleArgument(programCommand, argMeta);
2303
2348
  else if (argMeta.type === "Workspace")
2304
2349
  continue;
2305
- const sysType = argMeta.type.toLowerCase();
2306
- programCommand = programCommand.argument(
2307
- `[${sysType}]`,
2308
- `${sysType} in this workspace ${sysType}s/<${sysType}Name>`
2309
- );
2350
+ else if (argMeta.type === "Module") {
2351
+ programCommand = programCommand.argument(
2352
+ `[sys-name:module-name]`,
2353
+ `${argMeta.type} in this workspace (apps|libs)/<sys-name>/lib/<module-name>`
2354
+ );
2355
+ } else {
2356
+ const sysType = argMeta.type.toLowerCase();
2357
+ programCommand = programCommand.argument(
2358
+ `[${sysType}]`,
2359
+ `${sysType} in this workspace ${sysType}s/<${sysType}Name>`
2360
+ );
2361
+ }
2310
2362
  }
2311
2363
  programCommand = programCommand.option(`-v, --verbose [boolean]`, `verbose output`);
2312
2364
  programCommand.action(async (...args) => {
@@ -2424,8 +2476,10 @@ var AiSession = class _AiSession {
2424
2476
  Logger.raw(chunk);
2425
2477
  }
2426
2478
  } = {}) {
2427
- if (!_AiSession.#chat)
2479
+ if (!_AiSession.#chat) {
2480
+ Logger.rawLog(chalk3.yellow("\u{1F916}akan-editor is not initialized. LLM configuration should be set first."));
2428
2481
  await _AiSession.init();
2482
+ }
2429
2483
  if (!_AiSession.#chat)
2430
2484
  throw new Error("Failed to initialize the AI session");
2431
2485
  const loader = new Spinner(`${_AiSession.#chat.model} is thinking...`, {
@@ -5511,7 +5565,6 @@ var CloudScript = class {
5511
5565
  this.#runner.resetLlm();
5512
5566
  }
5513
5567
  async ask(question, workspace) {
5514
- await AiSession.init();
5515
5568
  const session = new AiSession();
5516
5569
  await session.ask(question);
5517
5570
  }
@@ -5643,9 +5696,6 @@ LibraryCommand = __decorateClass([
5643
5696
  Commands()
5644
5697
  ], LibraryCommand);
5645
5698
 
5646
- // pkgs/@akanjs/cli/src/module/module.command.ts
5647
- import { select as select4 } from "@inquirer/prompts";
5648
-
5649
5699
  // pkgs/@akanjs/cli/src/module/module.script.ts
5650
5700
  import fs12 from "fs";
5651
5701
 
@@ -5960,8 +6010,8 @@ var requestUnit = ({
5960
6010
  var ModuleRunner = class {
5961
6011
  async createModule(workspace, sysType, sysName, moduleName, description) {
5962
6012
  }
5963
- removeModule(sys2, name) {
5964
- sys2.removeDir(`${sys2.cwdPath}/lib/${name}`);
6013
+ removeModule(module) {
6014
+ module.sys.removeDir(`lib/${module.name}`);
5965
6015
  }
5966
6016
  async createScalarTemplate(sys2, name) {
5967
6017
  const akanConfig = await sys2.getConfig();
@@ -6003,20 +6053,20 @@ var ModuleRunner = class {
6003
6053
  dictionary: { filename: `${name}.dictionary.ts`, content: sys2.readFile(`lib/${name}/${name}.dictionary.ts`) }
6004
6054
  };
6005
6055
  }
6006
- async createComponentTemplate(sys2, name, type) {
6007
- const akanConfig = await sys2.getConfig();
6008
- const scanResult = await sys2.scan({ akanConfig });
6009
- await sys2.applyTemplate({
6010
- basePath: `./lib/${name}`,
6011
- template: `module/__Model__.${capitalize(type)}.ts`,
6056
+ async createComponentTemplate(module, type) {
6057
+ const akanConfig = await module.sys.getConfig();
6058
+ const scanResult = await module.sys.scan({ akanConfig });
6059
+ await module.sys.applyTemplate({
6060
+ basePath: `./lib/${module.name}`,
6061
+ template: `module/${capitalize(module.name)}.${capitalize(type)}.ts`,
6012
6062
  scanResult,
6013
- dict: { model: name, Model: capitalize(name), appName: sys2.name }
6063
+ dict: { model: module.name, Model: capitalize(module.name), appName: module.sys.name }
6014
6064
  });
6015
- await sys2.scan({ akanConfig });
6065
+ await module.sys.scan({ akanConfig });
6016
6066
  return {
6017
6067
  component: {
6018
- filename: `${name}.${capitalize(type)}.tsx`,
6019
- content: sys2.readFile(`lib/${name}/${capitalize(name)}.${capitalize(type)}.tsx`)
6068
+ filename: `${module.name}.${capitalize(type)}.tsx`,
6069
+ content: module.sys.readFile(`lib/${module.name}/${capitalize(module.name)}.${capitalize(type)}.tsx`)
6020
6070
  }
6021
6071
  // constant: {
6022
6072
  // filename: `${name}.constant.ts`,
@@ -6028,65 +6078,68 @@ var ModuleRunner = class {
6028
6078
  // },
6029
6079
  };
6030
6080
  }
6031
- async createModuleTemplate(sys2, name) {
6032
- const akanConfig = await sys2.getConfig();
6033
- const scanResult = await sys2.scan({ akanConfig });
6034
- const names = pluralize(name);
6035
- await sys2.applyTemplate({
6036
- basePath: `./lib/${name}`,
6081
+ async createModuleTemplate(module) {
6082
+ const akanConfig = await module.sys.getConfig();
6083
+ const scanResult = await module.sys.scan({ akanConfig });
6084
+ const names = pluralize(module.name);
6085
+ await module.applyTemplate({
6086
+ basePath: `.`,
6037
6087
  template: "module",
6038
6088
  scanResult,
6039
6089
  dict: {
6040
- model: name,
6041
- Model: capitalize(name),
6090
+ model: module.name,
6091
+ Model: capitalize(module.name),
6042
6092
  models: names,
6043
6093
  Models: capitalize(names),
6044
- sysName: sys2.name,
6045
- SysName: capitalize(sys2.name)
6094
+ sysName: module.sys.name,
6095
+ SysName: capitalize(module.sys.name)
6046
6096
  }
6047
6097
  });
6048
- await sys2.scan({ akanConfig });
6098
+ await module.sys.scan({ akanConfig });
6049
6099
  return {
6050
- constant: { filename: `${name}.constant.ts`, content: sys2.readFile(`lib/${name}/${name}.constant.ts`) },
6100
+ constant: {
6101
+ filename: `${module.name}.constant.ts`,
6102
+ content: module.readFile(`${module.name}.constant.ts`)
6103
+ },
6051
6104
  dictionary: {
6052
- filename: `${name}.dictionary.ts`,
6053
- content: sys2.readFile(`lib/${name}/${name}.dictionary.ts`)
6105
+ filename: `${module.name}.dictionary.ts`,
6106
+ content: module.readFile(`${module.name}.dictionary.ts`)
6054
6107
  },
6055
6108
  service: {
6056
- filename: `${name}.service.ts`,
6057
- content: sys2.readFile(`lib/${name}/${name}.service.ts`)
6109
+ filename: `${module.name}.service.ts`,
6110
+ content: module.readFile(`${module.name}.service.ts`)
6058
6111
  },
6059
6112
  store: {
6060
- filename: `${name}.store.ts`,
6061
- content: sys2.readFile(`lib/${name}/${name}.store.ts`)
6113
+ filename: `${module.name}.store.ts`,
6114
+ content: module.readFile(`${module.name}.store.ts`)
6062
6115
  },
6063
6116
  signal: {
6064
- filename: `${name}.signal.ts`,
6065
- content: sys2.readFile(`lib/${name}/${name}.signal.spec.ts`)
6117
+ filename: `${module.name}.signal.ts`,
6118
+ content: module.readFile(`${module.name}.signal.spec.ts`)
6066
6119
  },
6067
6120
  test: {
6068
- filename: `${name}.test.ts`,
6069
- content: sys2.readFile(`lib/${name}/${name}.signal.test.ts`)
6121
+ filename: `${module.name}.test.ts`,
6122
+ content: module.readFile(`${module.name}.signal.test.ts`)
6070
6123
  },
6071
6124
  unit: {
6072
- filename: `${name}.Unit.tsx`,
6073
- content: sys2.readFile(`lib/${name}/${name}.Unit.tsx`)
6125
+ filename: `${module.name}.Unit.tsx`,
6126
+ content: module.readFile(`${module.name}.Unit.tsx`)
6074
6127
  },
6075
6128
  view: {
6076
- filename: `${name}.View.tsx`,
6077
- content: sys2.readFile(`lib/${name}/${name}.View.tsx`)
6129
+ filename: `${module.name}.View.tsx`,
6130
+ content: module.readFile(`${module.name}.View.tsx`)
6078
6131
  },
6079
6132
  template: {
6080
- filename: `${name}.Template.tsx`,
6081
- content: sys2.readFile(`lib/${name}/${name}.Template.tsx`)
6133
+ filename: `${module.name}.Template.tsx`,
6134
+ content: module.readFile(`${module.name}.Template.tsx`)
6082
6135
  },
6083
6136
  zone: {
6084
- filename: `${name}.Zone.tsx`,
6085
- content: sys2.readFile(`lib/${name}/${name}.Zone.tsx`)
6137
+ filename: `${module.name}.Zone.tsx`,
6138
+ content: module.readFile(`${module.name}.Zone.tsx`)
6086
6139
  },
6087
6140
  util: {
6088
- filename: `${name}.Util.tsx`,
6089
- content: sys2.readFile(`lib/${name}/${name}.Util.tsx`)
6141
+ filename: `${module.name}.Util.tsx`,
6142
+ content: module.readFile(`${module.name}.Util.tsx`)
6090
6143
  }
6091
6144
  };
6092
6145
  }
@@ -6095,17 +6148,17 @@ var ModuleRunner = class {
6095
6148
  // pkgs/@akanjs/cli/src/module/module.script.ts
6096
6149
  var ModuleScript = class {
6097
6150
  #runner = new ModuleRunner();
6098
- //! .command arg에 병합 필요.
6099
- async createModuleTemplate(sys2, name, description) {
6100
- await this.#runner.createModuleTemplate(sys2, name);
6151
+ async createModuleTemplate(sys2, name) {
6152
+ const executor = ModuleExecutor.from(sys2, name);
6153
+ await this.#runner.createModuleTemplate(executor);
6101
6154
  }
6102
6155
  async createModule(sys2, name, description, schemaDescription) {
6103
- await AiSession.init();
6104
6156
  const session = new AiSession();
6105
6157
  const [appNames, libNames] = await sys2.workspace.getSyss();
6106
6158
  const moduleConstantExampleFiles = await sys2.workspace.getConstantFiles();
6107
6159
  const moduleDictionaryExampleFiles = await sys2.workspace.getDictionaryFiles();
6108
- const { constant, dictionary } = await this.#runner.createModuleTemplate(sys2, name);
6160
+ const executor = ModuleExecutor.from(sys2, name);
6161
+ const { constant, dictionary } = await this.#runner.createModuleTemplate(executor);
6109
6162
  sys2.log(`Module ${name} created in ${sys2.type}s/${sys2.name}/lib/${name}`);
6110
6163
  const constantContent = await session.editTypescript(
6111
6164
  requestConstant({
@@ -6130,28 +6183,27 @@ var ModuleScript = class {
6130
6183
  })
6131
6184
  );
6132
6185
  sys2.writeFile(`lib/${name}/${name}.dictionary.ts`, dictionaryContent);
6133
- await this.createView(sys2, name);
6134
- await this.createUnit(sys2, name);
6135
- await this.createTemplate(sys2, name);
6186
+ await this.createView(executor);
6187
+ await this.createUnit(executor);
6188
+ await this.createTemplate(executor);
6136
6189
  sys2.log(`Module ${name} created in ${sys2.type}s/${sys2.name}/lib/${name}`);
6137
6190
  }
6138
6191
  async createModule_(sys2, name, description, schemaDescription) {
6139
- await AiSession.init();
6140
6192
  const session = new AiSession();
6141
6193
  const [appNames, libNames] = await sys2.workspace.getSyss();
6142
6194
  const moduleConstantExampleFiles = await sys2.workspace.getConstantFiles();
6143
6195
  const moduleDictionaryExampleFiles = await sys2.workspace.getDictionaryFiles();
6196
+ const executor = ModuleExecutor.from(sys2, name);
6144
6197
  sys2.log(`Module ${name} created in ${sys2.type}s/${sys2.name}/lib/${name}`);
6145
- await this.createView(sys2, name);
6146
- await this.createUnit(sys2, name);
6147
- await this.createTemplate(sys2, name);
6198
+ await this.createView(executor);
6199
+ await this.createUnit(executor);
6200
+ await this.createTemplate(executor);
6148
6201
  sys2.log(`Module ${name} created in ${sys2.type}s/${sys2.name}/lib/${name}`);
6149
6202
  }
6150
- removeModule(sys2, name) {
6151
- this.#runner.removeModule(sys2, name);
6203
+ removeModule(module) {
6204
+ this.#runner.removeModule(module);
6152
6205
  }
6153
6206
  async createScalar(sys2, name, description, schemaDescription) {
6154
- await AiSession.init();
6155
6207
  const scalarConstantExampleFiles = await sys2.workspace.getScalarConstantFiles();
6156
6208
  const { constant, dictionary } = await this.#runner.createScalarTemplate(sys2, name);
6157
6209
  const session = new AiSession();
@@ -6171,19 +6223,18 @@ var ModuleScript = class {
6171
6223
  }
6172
6224
  async createTest(workspace, name) {
6173
6225
  }
6174
- async createTemplate(sys2, name) {
6175
- await AiSession.init();
6176
- const { component: template } = await this.#runner.createComponentTemplate(sys2, name, "template");
6177
- const templateExampleFiles = (await sys2.getTemplatesSourceCode()).filter(
6178
- (f) => !f.filepath.includes(`${name}.Template.tsx`)
6226
+ async createTemplate(module) {
6227
+ const { component: template } = await this.#runner.createComponentTemplate(module, "template");
6228
+ const templateExampleFiles = (await module.sys.getTemplatesSourceCode()).filter(
6229
+ (f) => !f.filepath.includes(`${module.name}.Template.tsx`)
6179
6230
  );
6180
- const Name = capitalize(name);
6181
- const relatedCnsts = getRelatedCnsts(`${sys2.cwdPath}/lib/${name}/${name}.constant.ts`);
6182
- const constant = fs12.readFileSync(`${sys2.cwdPath}/lib/${name}/${name}.constant.ts`, "utf-8");
6231
+ const Name = capitalize(module.name);
6232
+ const relatedCnsts = getRelatedCnsts(`${module.sys.cwdPath}/lib/${module.name}/${module.name}.constant.ts`);
6233
+ const constant = fs12.readFileSync(`${module.sys.cwdPath}/lib/${module.name}/${module.name}.constant.ts`, "utf-8");
6183
6234
  const session = new AiSession();
6184
6235
  const promptRst = requestTemplate({
6185
- sysName: sys2.name,
6186
- modelName: name,
6236
+ sysName: module.sys.name,
6237
+ modelName: module.name,
6187
6238
  ModelName: Name,
6188
6239
  constant,
6189
6240
  boilerplate: template.content,
@@ -6191,19 +6242,20 @@ var ModuleScript = class {
6191
6242
  exampleFiles: randomPicks(templateExampleFiles, Math.min(20, templateExampleFiles.length))
6192
6243
  });
6193
6244
  const content = await session.editTypescript(promptRst);
6194
- sys2.writeFile(`lib/${name}/${Name}.Template.tsx`, content);
6195
- }
6196
- async createUnit(sys2, name) {
6197
- await AiSession.init();
6198
- const { component: unit } = await this.#runner.createComponentTemplate(sys2, name, "unit");
6199
- const Name = capitalize(name);
6200
- const unitExampleFiles = (await sys2.getUnitsSourceCode()).filter((f) => !f.filepath.includes(`${name}.Unit.tsx`));
6201
- const relatedCnsts = getRelatedCnsts(`${sys2.cwdPath}/lib/${name}/${name}.constant.ts`);
6202
- const constant = fs12.readFileSync(`${sys2.cwdPath}/lib/${name}/${name}.constant.ts`, "utf-8");
6245
+ module.writeFile(`${Name}.Template.tsx`, content);
6246
+ }
6247
+ async createUnit(module) {
6248
+ const { component: unit } = await this.#runner.createComponentTemplate(module, "unit");
6249
+ const Name = capitalize(module.name);
6250
+ const unitExampleFiles = (await module.sys.getUnitsSourceCode()).filter(
6251
+ (f) => !f.filepath.includes(`${module.name}.Unit.tsx`)
6252
+ );
6253
+ const relatedCnsts = getRelatedCnsts(`${module.sys.cwdPath}/lib/${module.name}/${module.name}.constant.ts`);
6254
+ const constant = fs12.readFileSync(`${module.sys.cwdPath}/lib/${module.name}/${module.name}.constant.ts`, "utf-8");
6203
6255
  const session = new AiSession();
6204
6256
  const promptRst = requestUnit({
6205
- sysName: sys2.name,
6206
- modelName: name,
6257
+ sysName: module.sys.name,
6258
+ modelName: module.name,
6207
6259
  ModelName: Name,
6208
6260
  constant,
6209
6261
  properties: relatedCnsts.map((r) => ({ key: r.key, source: r.source })),
@@ -6211,19 +6263,20 @@ var ModuleScript = class {
6211
6263
  boilerplate: unit.content
6212
6264
  });
6213
6265
  const content = await session.editTypescript(promptRst);
6214
- sys2.writeFile(`lib/${name}/${Name}.Unit.tsx`, content);
6215
- }
6216
- async createView(sys2, name) {
6217
- await AiSession.init();
6218
- const { component: view } = await this.#runner.createComponentTemplate(sys2, name, "view");
6219
- const viewExampleFiles = (await sys2.getViewsSourceCode()).filter((f) => !f.filepath.includes(`${name}.View.tsx`));
6220
- const Name = capitalize(name);
6221
- const relatedCnsts = getRelatedCnsts(`${sys2.cwdPath}/lib/${name}/${name}.constant.ts`);
6222
- const constant = fs12.readFileSync(`${sys2.cwdPath}/lib/${name}/${name}.constant.ts`, "utf-8");
6266
+ module.writeFile(`${Name}.Unit.tsx`, content);
6267
+ }
6268
+ async createView(module) {
6269
+ const { component: view } = await this.#runner.createComponentTemplate(module, "view");
6270
+ const viewExampleFiles = (await module.sys.getViewsSourceCode()).filter(
6271
+ (f) => !f.filepath.includes(`${module.name}.View.tsx`)
6272
+ );
6273
+ const Name = capitalize(module.name);
6274
+ const relatedCnsts = getRelatedCnsts(`${module.sys.cwdPath}/lib/${module.name}/${module.name}.constant.ts`);
6275
+ const constant = fs12.readFileSync(`${module.sys.cwdPath}/lib/${module.name}/${module.name}.constant.ts`, "utf-8");
6223
6276
  const session = new AiSession();
6224
6277
  const promptRst = requestView({
6225
- sysName: sys2.name,
6226
- modelName: name,
6278
+ sysName: module.sys.name,
6279
+ modelName: module.name,
6227
6280
  ModelName: Name,
6228
6281
  constant,
6229
6282
  boilerplate: view.content,
@@ -6231,25 +6284,14 @@ var ModuleScript = class {
6231
6284
  exampleFiles: randomPicks(viewExampleFiles, Math.min(20, viewExampleFiles.length))
6232
6285
  });
6233
6286
  const content = await session.editTypescript(promptRst);
6234
- sys2.writeFile(`lib/${name}/${Name}.View.tsx`, content);
6287
+ module.writeFile(`${Name}.View.tsx`, content);
6235
6288
  }
6236
6289
  };
6237
6290
 
6238
6291
  // pkgs/@akanjs/cli/src/module/module.command.ts
6239
6292
  var ModuleCommand = class {
6240
6293
  moduleScript = new ModuleScript();
6241
- async selectLib(sys2) {
6242
- const libs = await sys2.getModules();
6243
- const lib = await select4({
6244
- message: "Select the lib",
6245
- choices: libs.map((l) => `${sys2.name}/${l}`)
6246
- }).catch((e) => {
6247
- Logger.error("canceled");
6248
- return null;
6249
- });
6250
- return lib?.split("/").pop();
6251
- }
6252
- async createModule(sys2, moduleName, description, schemaDescription, ai, workspace) {
6294
+ async createModule(sys2, moduleName, description, schemaDescription, ai) {
6253
6295
  const name = lowerlize(moduleName.replace(/ /g, ""));
6254
6296
  if (ai) {
6255
6297
  await this.moduleScript.createModule(sys2, name, description, schemaDescription);
@@ -6257,32 +6299,20 @@ var ModuleCommand = class {
6257
6299
  await this.moduleScript.createModuleTemplate(sys2, name);
6258
6300
  }
6259
6301
  }
6260
- async removeModule(sys2, workspace) {
6261
- const name = await this.selectLib(sys2);
6262
- if (!name)
6263
- return;
6264
- this.moduleScript.removeModule(sys2, name);
6302
+ removeModule(module) {
6303
+ this.moduleScript.removeModule(module);
6265
6304
  }
6266
- async createScalar(sys2, scalarName, description, schemaDescription, workspace) {
6305
+ async createScalar(sys2, scalarName, description, schemaDescription) {
6267
6306
  await this.moduleScript.createScalar(sys2, lowerlize(scalarName.replace(/ /g, "")), description, schemaDescription);
6268
6307
  }
6269
- async createView(sys2, workspace) {
6270
- const name = await this.selectLib(sys2);
6271
- if (!name)
6272
- return;
6273
- await this.moduleScript.createView(sys2, name);
6308
+ async createView(module) {
6309
+ await this.moduleScript.createView(module);
6274
6310
  }
6275
- async createUnit(sys2, workspace) {
6276
- const name = await this.selectLib(sys2);
6277
- if (!name)
6278
- return;
6279
- await this.moduleScript.createUnit(sys2, name);
6311
+ async createUnit(module) {
6312
+ await this.moduleScript.createUnit(module);
6280
6313
  }
6281
- async createTemplate(sys2, workspace) {
6282
- const name = await this.selectLib(sys2);
6283
- if (!name)
6284
- return;
6285
- await this.moduleScript.createTemplate(sys2, name);
6314
+ async createTemplate(module) {
6315
+ await this.moduleScript.createTemplate(module);
6286
6316
  }
6287
6317
  };
6288
6318
  __decorateClass([
@@ -6291,36 +6321,30 @@ __decorateClass([
6291
6321
  __decorateParam(1, Argument("moduleName", { desc: "name of module" })),
6292
6322
  __decorateParam(2, Option("description", { desc: "description of module" })),
6293
6323
  __decorateParam(3, Option("schemaDescription", { desc: "schema description of module" })),
6294
- __decorateParam(4, Option("ai", { type: "boolean", default: false, desc: "use ai to create module" })),
6295
- __decorateParam(5, Workspace())
6324
+ __decorateParam(4, Option("ai", { type: "boolean", default: false, desc: "use ai to create module" }))
6296
6325
  ], ModuleCommand.prototype, "createModule", 1);
6297
6326
  __decorateClass([
6298
6327
  Target.Public(),
6299
- __decorateParam(0, Sys()),
6300
- __decorateParam(1, Workspace())
6328
+ __decorateParam(0, Module())
6301
6329
  ], ModuleCommand.prototype, "removeModule", 1);
6302
6330
  __decorateClass([
6303
6331
  Target.Public(),
6304
6332
  __decorateParam(0, Sys()),
6305
6333
  __decorateParam(1, Argument("scalarName", { desc: "name of scalar module" })),
6306
6334
  __decorateParam(2, Option("description", { desc: "description of scalar module" })),
6307
- __decorateParam(3, Option("schemaDescription", { desc: "schema description of scalar module" })),
6308
- __decorateParam(4, Workspace())
6335
+ __decorateParam(3, Option("schemaDescription", { desc: "schema description of scalar module" }))
6309
6336
  ], ModuleCommand.prototype, "createScalar", 1);
6310
6337
  __decorateClass([
6311
6338
  Target.Public(),
6312
- __decorateParam(0, Sys()),
6313
- __decorateParam(1, Workspace())
6339
+ __decorateParam(0, Module())
6314
6340
  ], ModuleCommand.prototype, "createView", 1);
6315
6341
  __decorateClass([
6316
6342
  Target.Public(),
6317
- __decorateParam(0, Sys()),
6318
- __decorateParam(1, Workspace())
6343
+ __decorateParam(0, Module())
6319
6344
  ], ModuleCommand.prototype, "createUnit", 1);
6320
6345
  __decorateClass([
6321
6346
  Target.Public(),
6322
- __decorateParam(0, Sys()),
6323
- __decorateParam(1, Workspace())
6347
+ __decorateParam(0, Module())
6324
6348
  ], ModuleCommand.prototype, "createTemplate", 1);
6325
6349
  ModuleCommand = __decorateClass([
6326
6350
  Commands()
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "sourceType": "module",
3
3
  "name": "@akanjs/cli",
4
- "version": "0.0.142",
4
+ "version": "0.0.143",
5
5
  "bin": {
6
6
  "akan": "cjs/index.js"
7
7
  },
@@ -1,12 +1,11 @@
1
- import { Sys, Workspace } from "@akanjs/devkit";
1
+ import { Module, Sys } from "@akanjs/devkit";
2
2
  import { ModuleScript } from "./module.script";
3
3
  export declare class ModuleCommand {
4
4
  moduleScript: ModuleScript;
5
- private selectLib;
6
- createModule(sys: Sys, moduleName: string, description: string, schemaDescription: string, ai: boolean, workspace: Workspace): Promise<void>;
7
- removeModule(sys: Sys, workspace: Workspace): Promise<void>;
8
- createScalar(sys: Sys, scalarName: string, description: string, schemaDescription: string, workspace: Workspace): Promise<void>;
9
- createView(sys: Sys, workspace: Workspace): Promise<void>;
10
- createUnit(sys: Sys, workspace: Workspace): Promise<void>;
11
- createTemplate(sys: Sys, workspace: Workspace): Promise<void>;
5
+ createModule(sys: Sys, moduleName: string, description: string, schemaDescription: string, ai: boolean): Promise<void>;
6
+ removeModule(module: Module): void;
7
+ createScalar(sys: Sys, scalarName: string, description: string, schemaDescription: string): Promise<void>;
8
+ createView(module: Module): Promise<void>;
9
+ createUnit(module: Module): Promise<void>;
10
+ createTemplate(module: Module): Promise<void>;
12
11
  }
@@ -1,7 +1,7 @@
1
- import { type Sys, Workspace } from "@akanjs/devkit";
1
+ import { type Module, type Sys, Workspace } from "@akanjs/devkit";
2
2
  export declare class ModuleRunner {
3
3
  createModule(workspace: Workspace, sysType: "app" | "lib", sysName: string, moduleName: string, description: string): Promise<void>;
4
- removeModule(sys: Sys, name: string): void;
4
+ removeModule(module: Module): void;
5
5
  createScalarTemplate(sys: Sys, name: string): Promise<{
6
6
  constant: {
7
7
  filename: string;
@@ -18,13 +18,13 @@ export declare class ModuleRunner {
18
18
  content: string;
19
19
  };
20
20
  }>;
21
- createComponentTemplate(sys: Sys, name: string, type: "unit" | "view" | "template" | "zone" | "util"): Promise<{
21
+ createComponentTemplate(module: Module, type: "unit" | "view" | "template" | "zone" | "util"): Promise<{
22
22
  component: {
23
23
  filename: string;
24
24
  content: string;
25
25
  };
26
26
  }>;
27
- createModuleTemplate(sys: Sys, name: string): Promise<{
27
+ createModuleTemplate(module: Module): Promise<{
28
28
  constant: {
29
29
  filename: string;
30
30
  content: string;
@@ -1,14 +1,14 @@
1
- import { type Sys, Workspace } from "@akanjs/devkit";
1
+ import { type Module, type Sys, Workspace } from "@akanjs/devkit";
2
2
  export declare class ModuleScript {
3
3
  #private;
4
- createModuleTemplate(sys: Sys, name: string, description?: string): Promise<void>;
4
+ createModuleTemplate(sys: Sys, name: string): Promise<void>;
5
5
  createModule(sys: Sys, name: string, description?: string, schemaDescription?: string): Promise<void>;
6
6
  createModule_(sys: Sys, name: string, description: string, schemaDescription: string): Promise<void>;
7
- removeModule(sys: Sys, name: string): void;
7
+ removeModule(module: Module): void;
8
8
  createScalar(sys: Sys, name: string, description: string, schemaDescription: string): Promise<void>;
9
9
  createService(workspace: Workspace, name: string): Promise<void>;
10
10
  createTest(workspace: Workspace, name: string): Promise<void>;
11
- createTemplate(sys: Sys, name: string): Promise<void>;
12
- createUnit(sys: Sys, name: string): Promise<void>;
13
- createView(sys: Sys, name: string): Promise<void>;
11
+ createTemplate(module: Module): Promise<void>;
12
+ createUnit(module: Module): Promise<void>;
13
+ createView(module: Module): Promise<void>;
14
14
  }