@akanjs/cli 0.0.146 → 0.0.147

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 (28) hide show
  1. package/README.md +7 -26
  2. package/cjs/index.js +175 -18
  3. package/cjs/src/guidelines/cssRule/cssRule.instruction.md +1 -1
  4. package/cjs/src/guidelines/docPageRule/docPageRule.instruction.md +59 -52
  5. package/cjs/src/guidelines/modelConstant/modelConstant.instruction.md +335 -752
  6. package/cjs/src/guidelines/modelTemplate/modelTemplate.instruction.md +418 -391
  7. package/cjs/src/guidelines/modelUnit/modelUnit.instruction.md +0 -292
  8. package/cjs/src/guidelines/scalarModule/scalarModule.instruction.md +84 -0
  9. package/cjs/src/templates/app/main.js +1 -2
  10. package/esm/index.js +183 -26
  11. package/esm/src/guidelines/cssRule/cssRule.instruction.md +1 -1
  12. package/esm/src/guidelines/docPageRule/docPageRule.instruction.md +59 -52
  13. package/esm/src/guidelines/modelConstant/modelConstant.instruction.md +335 -752
  14. package/esm/src/guidelines/modelTemplate/modelTemplate.instruction.md +418 -391
  15. package/esm/src/guidelines/modelUnit/modelUnit.instruction.md +0 -292
  16. package/esm/src/guidelines/scalarModule/scalarModule.instruction.md +84 -0
  17. package/esm/src/templates/app/main.js +1 -2
  18. package/package.json +1 -1
  19. package/src/guideline/guideline.command.d.ts +3 -1
  20. package/src/guideline/guideline.prompt.d.ts +15 -1
  21. package/src/guideline/guideline.runner.d.ts +17 -3
  22. package/src/guideline/guideline.script.d.ts +8 -2
  23. package/src/guidelines/cssRule/cssRule.instruction.md +1 -1
  24. package/src/guidelines/docPageRule/docPageRule.instruction.md +59 -52
  25. package/src/guidelines/modelConstant/modelConstant.instruction.md +335 -752
  26. package/src/guidelines/modelTemplate/modelTemplate.instruction.md +418 -391
  27. package/src/guidelines/modelUnit/modelUnit.instruction.md +0 -292
  28. package/src/guidelines/scalarModule/scalarModule.instruction.md +84 -0
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
- # ⚡ AkanJS CLI
1
+ # ⚡ Akan.js CLI
2
2
 
3
- The official command-line interface for the AkanJS ecosystem, providing powerful development tools for creating, managing, and deploying modern web applications with ease.
3
+ The official command-line interface for the Akan.js ecosystem, providing powerful development tools for creating, managing, and deploying modern web applications with ease.
4
4
 
5
5
  ## 🚀 Get Started
6
6
 
@@ -42,7 +42,7 @@ akan set-llm
42
42
  # create module
43
43
  akan create-module
44
44
 
45
- # create scalar with ai (experimental)
45
+ # create scalar
46
46
  akan create-scalar
47
47
  ```
48
48
 
@@ -55,7 +55,7 @@ The `@akanjs/cli` is a comprehensive development toolkit that streamlines the en
55
55
  Complete workspace and project management:
56
56
 
57
57
  - **🚀 Project Initialization**
58
- - `create-workspace` - Create new AkanJS workspace with organization setup
58
+ - `create-workspace` - Create new Akan.js workspace with organization setup
59
59
  - `generate-mongo` - Generate MongoDB configuration and setup
60
60
  - `lint` / `lint-all` - Code linting with auto-fix capabilities
61
61
 
@@ -151,7 +151,7 @@ Seamless cloud services and AI integration:
151
151
  - `ask` - Interactive AI development assistance
152
152
 
153
153
  - **🚀 Deployment**
154
- - `deploy-akan` - Deploy to AkanJS cloud infrastructure
154
+ - `deploy-akan` - Deploy to Akan.js cloud infrastructure
155
155
  - `update` - Update CLI and cloud integrations
156
156
 
157
157
  ### 📦 **Package Operations** (`package`)
@@ -265,25 +265,6 @@ akan pull-database web-app --env debug --dump
265
265
  akan dbup
266
266
  ```
267
267
 
268
- ## 🏗️ Architecture
269
-
270
- The CLI follows a modular command structure:
271
-
272
- ```
273
- pkgs/@akanjs/cli/
274
- ├── src/
275
- │ ├── workspace/ # Workspace management commands
276
- │ ├── application/ # Application lifecycle commands
277
- │ ├── library/ # Library management commands
278
- │ ├── module/ # AI-powered module generation
279
- │ ├── page/ # Page scaffolding commands
280
- │ ├── package/ # NPM package operations
281
- │ ├── cloud/ # Cloud services integration
282
- │ └── templates/ # Code generation templates
283
- ├── index.ts # CLI entry point
284
- └── package.json # Dependencies and configuration
285
- ```
286
-
287
268
  ## 🤖 AI-Powered Development
288
269
 
289
270
  The CLI integrates advanced AI capabilities:
@@ -314,7 +295,7 @@ The CLI integrates advanced AI capabilities:
314
295
 
315
296
  ## 📄 License
316
297
 
317
- This project is part of the AkanJS ecosystem. See the main repository for license information.
298
+ This project is part of the Akan.js ecosystem. See the main repository for license information.
318
299
 
319
300
  ## 🔗 Related Packages
320
301
 
@@ -327,5 +308,5 @@ This project is part of the AkanJS ecosystem. See the main repository for licens
327
308
  ---
328
309
 
329
310
  <p align="center">
330
- <strong>Built with ❤️ by the AkanJS team</strong>
311
+ <strong>Built with ❤️ by the Akan.js team</strong>
331
312
  </p>
package/cjs/index.js CHANGED
@@ -1251,7 +1251,10 @@ ${errorMessages}`);
1251
1251
  ];
1252
1252
  const errors = diagnostics.filter((diagnostic) => diagnostic.category === ts3.DiagnosticCategory.Error);
1253
1253
  const warnings = diagnostics.filter((diagnostic) => diagnostic.category === ts3.DiagnosticCategory.Warning);
1254
- return { diagnostics, errors, warnings };
1254
+ const fileDiagnostics = diagnostics.filter((diagnostic) => diagnostic.file?.fileName === filePath);
1255
+ const fileErrors = fileDiagnostics.filter((diagnostic) => diagnostic.category === ts3.DiagnosticCategory.Error);
1256
+ const fileWarnings = fileDiagnostics.filter((diagnostic) => diagnostic.category === ts3.DiagnosticCategory.Warning);
1257
+ return { diagnostics, errors, warnings, fileDiagnostics, fileErrors, fileWarnings };
1255
1258
  }
1256
1259
  /**
1257
1260
  * Format diagnostics for console output
@@ -1678,9 +1681,9 @@ var Executor = class _Executor {
1678
1681
  typeCheck(filePath) {
1679
1682
  const path9 = this.getPath(filePath);
1680
1683
  const typeChecker = this.getTypeChecker();
1681
- const { diagnostics, errors, warnings } = typeChecker.check(path9);
1682
- const message = typeChecker.formatDiagnostics(diagnostics);
1683
- return { diagnostics, errors, warnings, message };
1684
+ const { fileDiagnostics, fileErrors, fileWarnings } = typeChecker.check(path9);
1685
+ const message = typeChecker.formatDiagnostics(fileDiagnostics);
1686
+ return { fileDiagnostics, fileErrors, fileWarnings, message };
1684
1687
  }
1685
1688
  getLinter() {
1686
1689
  this.linter ??= new Linter(this.cwdPath);
@@ -3105,7 +3108,7 @@ ${validate.map((v) => `- ${v}`).join("\n")}`;
3105
3108
  writes.map(async ({ filePath }) => {
3106
3109
  const typeCheckResult = executor.typeCheck(filePath);
3107
3110
  const lintResult = await executor.lint(filePath);
3108
- const needFix2 = !!typeCheckResult.errors.length || !!lintResult.errors.length;
3111
+ const needFix2 = !!typeCheckResult.fileErrors.length || !!lintResult.errors.length;
3109
3112
  return { filePath, typeCheckResult, lintResult, needFix: needFix2 };
3110
3113
  })
3111
3114
  );
@@ -3139,7 +3142,7 @@ ${fileCheck.lintResult.message}`
3139
3142
  throw new Error("Failed to create scalar");
3140
3143
  }
3141
3144
  #getTypescriptCodes(text) {
3142
- const codes = text.match(/```typescript([\s\S]*?)```/g);
3145
+ const codes = text.match(/```(typescript|tsx)([\s\S]*?)```/g);
3143
3146
  if (!codes)
3144
3147
  return [];
3145
3148
  const result = codes.map((code) => {
@@ -3264,6 +3267,9 @@ var Prompter = class {
3264
3267
  const content = await import_promises2.default.readFile(filePath, "utf-8");
3265
3268
  return content;
3266
3269
  }
3270
+ static async getUpdateRequest(guideName) {
3271
+ return await (0, import_prompts5.input)({ message: `What do you want to update in ${guideName}?` });
3272
+ }
3267
3273
  async makeTsFileUpdatePrompt({ context: context2, request }) {
3268
3274
  return `You are a senior developer writing TypeScript-based programs using Akan.js, an in-house framework. Here's an overview of the Akan.js framework:
3269
3275
  ${await this.getDocumentation("framework")}
@@ -5494,7 +5500,9 @@ var GuidelinePrompt = class extends Prompter {
5494
5500
  });
5495
5501
  const paths = [];
5496
5502
  for await (const path9 of matchingPaths) {
5497
- if (filterText && !import_fs12.default.readFileSync(path9, "utf-8").includes(filterText))
5503
+ const fileContent = import_fs12.default.readFileSync(path9, "utf-8");
5504
+ const textFilter = filterText ? new RegExp(filterText) : null;
5505
+ if (filterText && !textFilter?.test(fileContent))
5498
5506
  continue;
5499
5507
  paths.push(path9);
5500
5508
  }
@@ -5547,10 +5555,39 @@ ${guideJson.update.rules.map((rule) => `- ${rule}`).join("\n")}
5547
5555
 
5548
5556
  => Now, you need to write the file content here. Let's go.
5549
5557
  `;
5550
- return { request, writePath };
5558
+ return { guideJson, request, writePath };
5559
+ }
5560
+ async requestUpdateInstruction(updateRequest) {
5561
+ const guideJson = await Prompter.getGuideJson(this.name);
5562
+ const resultPath = `${__dirname}/src/guidelines/${this.name}/${guideJson.update.filePath}`;
5563
+ const writePath = `${this.workspace.workspaceRoot}/pkgs/@akanjs/cli/src/guidelines/${this.name}/${guideJson.update.filePath}`;
5564
+ const isResultExists = this.workspace.exists(writePath);
5565
+ if (!isResultExists)
5566
+ throw new Error(`${guideJson.update.filePath} file does not exist. Please create it first.`);
5567
+ const existingResult = this.workspace.readFile(resultPath);
5568
+ const request = `
5569
+ I am a developer of akanjs framework, a full-stack framework for building web applications.
5570
+ I want to update a ${guideJson.update.filePath} file for ${guideJson.description}.
5571
+ This file is a programming guideline for Akan.js framwork users.
5572
+
5573
+ # ${guideJson.title} Workflow
5574
+ - 1. Read already-written ${guideJson.update.filePath} file.
5575
+ - 2. Write the updated file content of the ${guideJson.update.filePath} with the update request.
5576
+
5577
+ ## 1. Read already-written ${guideJson.update.filePath} file.
5578
+ \`\`\`markdown
5579
+ ${existingResult}
5580
+ \`\`\`
5581
+
5582
+ ## 2. Write the updated file content of the ${guideJson.update.filePath} with the update request.
5583
+ Request: ${updateRequest}
5584
+
5585
+ => Now, you need to write the file content here. Let's go.
5586
+ `;
5587
+ return { guideJson, request, writePath };
5551
5588
  }
5552
- async requestUpdateDocumentPage(page) {
5553
- const writePath = `apps/angelo/app/${page}`;
5589
+ async requestCreateDocumentPage(page) {
5590
+ const writePath = `apps/angelo/app${page}`;
5554
5591
  if (!this.workspace.exists(writePath))
5555
5592
  this.workspace.writeFile(
5556
5593
  writePath,
@@ -5592,6 +5629,69 @@ Please return only the file result in the following format for easy parsing.
5592
5629
  // File: ${writePath}
5593
5630
  ...pageContent
5594
5631
  \`\`\`
5632
+ `;
5633
+ return { request, writePath };
5634
+ }
5635
+ async requestUpdateDocumentPage(page, updateRequest) {
5636
+ const writePath = `apps/angelo/app${page}`;
5637
+ if (!this.workspace.exists(writePath))
5638
+ this.workspace.writeFile(
5639
+ writePath,
5640
+ `export default function Page() {
5641
+ return <div>No Content</div>;
5642
+ }
5643
+ `
5644
+ );
5645
+ const instruction = await Prompter.getInstruction(this.name);
5646
+ const pageContent = this.workspace.getLocalFile(writePath);
5647
+ const request = `
5648
+ I'm updating a documentation website for the Akan.js framework.
5649
+
5650
+ I want to update the Next.js server-side page located at ${writePath}.
5651
+ Below is the content of the currently written page. You should update stale infos and preserve the existing content.
5652
+ \`\`\`tsx
5653
+ // File: ${writePath}
5654
+ ${pageContent.content}
5655
+ \`\`\`
5656
+
5657
+ The existing instruction is below.
5658
+ \`\`\`markdown
5659
+ ${instruction}
5660
+ \`\`\`
5661
+
5662
+ Please update this page with the request below.
5663
+ ${updateRequest}
5664
+
5665
+ Please return only the file result in the following format for easy parsing.
5666
+ \`\`\`tsx
5667
+ // File: ${writePath}
5668
+ ...pageContent
5669
+ \`\`\`
5670
+ `;
5671
+ return { request, writePath };
5672
+ }
5673
+ async requestReapplyInstruction(filePath) {
5674
+ const guideJson = await Prompter.getGuideJson(this.name);
5675
+ const writePath = `${this.workspace.workspaceRoot}/pkgs/@akanjs/cli/src/guidelines/${this.name}/${guideJson.update.filePath}`;
5676
+ if (!guideJson.page)
5677
+ throw new Error(`${this.name} does not have a page.`);
5678
+ const pagePath = `apps/angelo/app${guideJson.page}`;
5679
+ const pageFile = this.workspace.getLocalFile(pagePath);
5680
+ const request = `
5681
+ I want to apply information in the Next.js page to markdown instruction file.
5682
+
5683
+ Here's the newest information in the Next.js page.
5684
+ \`\`\`tsx
5685
+ // File: ${pagePath}
5686
+ ${pageFile.content}
5687
+ \`\`\`
5688
+
5689
+ Here's the existing instruction file.
5690
+ \`\`\`markdown
5691
+ ${await Prompter.getInstruction(this.name)}
5692
+ \`\`\`
5693
+
5694
+ Please update the instruction file with the information in the Next.js page.
5595
5695
  `;
5596
5696
  return { request, writePath };
5597
5697
  }
@@ -5602,19 +5702,45 @@ var GuidelineRunner = class {
5602
5702
  async generateInstruction(workspace, guideName) {
5603
5703
  const session = new AiSession("generateInstruction", { workspace, cacheKey: guideName });
5604
5704
  const prompt = new GuidelinePrompt(workspace, guideName);
5605
- const { request, writePath } = await prompt.requestCreateInstruction();
5705
+ const { guideJson, request, writePath } = await prompt.requestCreateInstruction();
5706
+ const guidelineContent = await session.editMarkdown(request);
5707
+ workspace.writeFile(writePath, guidelineContent);
5708
+ return { guideJson, session };
5709
+ }
5710
+ async updateInstruction(workspace, guideName, { updateRequest }) {
5711
+ const session = new AiSession("updateInstruction", { workspace, cacheKey: guideName });
5712
+ const prompt = new GuidelinePrompt(workspace, guideName);
5713
+ const { guideJson, request, writePath } = await prompt.requestUpdateInstruction(updateRequest);
5606
5714
  const guidelineContent = await session.editMarkdown(request);
5607
5715
  workspace.writeFile(writePath, guidelineContent);
5716
+ return { guideJson, session };
5608
5717
  }
5609
- async deployDocPage(workspace, guideName) {
5718
+ async generateDocument(workspace, guideName) {
5610
5719
  const session = new AiSession("deployDocPages", { workspace, cacheKey: guideName });
5611
5720
  const guideJson = await Prompter.getGuideJson(guideName);
5612
5721
  const prompt = new GuidelinePrompt(workspace, guideName);
5613
5722
  if (!guideJson.page)
5614
5723
  return Promise.resolve({});
5615
- const { request } = await prompt.requestUpdateDocumentPage(guideJson.page);
5724
+ const { request } = await prompt.requestCreateDocumentPage(guideJson.page);
5616
5725
  await session.writeTypescripts(request, workspace);
5617
5726
  }
5727
+ async updateDocument(workspace, guideName, { updateRequest, session }) {
5728
+ const guideJson = await Prompter.getGuideJson(guideName);
5729
+ if (!guideJson.page)
5730
+ throw new Error(`${guideName} does not have a page.`);
5731
+ const prompt = new GuidelinePrompt(workspace, guideName);
5732
+ const { request, writePath } = await prompt.requestUpdateDocumentPage(guideJson.page, updateRequest);
5733
+ const guidelineContent = await session.editMarkdown(request);
5734
+ workspace.writeFile(writePath, guidelineContent);
5735
+ }
5736
+ async reapplyInstruction(workspace, guideName) {
5737
+ const session = new AiSession("reapplyInstruction", { workspace, cacheKey: guideName });
5738
+ const guideJson = await Prompter.getGuideJson(guideName);
5739
+ const prompt = new GuidelinePrompt(workspace, guideName);
5740
+ const { request, writePath } = await prompt.requestReapplyInstruction(guideJson.update.filePath);
5741
+ const guidelineContent = await session.editMarkdown(request);
5742
+ workspace.writeFile(writePath, guidelineContent);
5743
+ }
5618
5744
  };
5619
5745
 
5620
5746
  // pkgs/@akanjs/cli/src/guideline/guideline.script.ts
@@ -5624,9 +5750,23 @@ var GuidelineScript = class {
5624
5750
  const guideName = name ?? await Prompter.selectGuideline();
5625
5751
  await this.#runner.generateInstruction(workspace, guideName);
5626
5752
  }
5627
- async deployDocPage(workspace, name = null) {
5753
+ async updateInstruction(workspace, name = null, updateRequest) {
5754
+ const guideName = name ?? await Prompter.selectGuideline();
5755
+ const { guideJson, session } = await this.#runner.updateInstruction(workspace, guideName, { updateRequest });
5756
+ if (guideJson.page)
5757
+ await this.updateDocument(workspace, guideName, { updateRequest, session });
5758
+ }
5759
+ async generateDocument(workspace, name = null) {
5760
+ const guideName = name ?? await Prompter.selectGuideline();
5761
+ await this.#runner.generateDocument(workspace, guideName);
5762
+ }
5763
+ async updateDocument(workspace, name = null, { updateRequest, session }) {
5628
5764
  const guideName = name ?? await Prompter.selectGuideline();
5629
- await this.#runner.deployDocPage(workspace, guideName);
5765
+ await this.#runner.updateDocument(workspace, guideName, { updateRequest, session });
5766
+ }
5767
+ async reapplyInstruction(workspace, name = null) {
5768
+ const guideName = name ?? await Prompter.selectGuideline();
5769
+ await this.#runner.reapplyInstruction(workspace, guideName);
5630
5770
  }
5631
5771
  };
5632
5772
 
@@ -5636,8 +5776,14 @@ var GuidelineCommand = class {
5636
5776
  async generateInstruction(name, workspace) {
5637
5777
  await this.guidelineScript.generateInstruction(workspace, name);
5638
5778
  }
5639
- async deployDoc(name, workspace) {
5640
- await this.guidelineScript.deployDocPage(workspace, name);
5779
+ async updateInstruction(name, request, workspace) {
5780
+ await this.guidelineScript.updateInstruction(workspace, name, request);
5781
+ }
5782
+ async generateDocument(name, workspace) {
5783
+ await this.guidelineScript.generateDocument(workspace, name);
5784
+ }
5785
+ async reapplyInstruction(name, workspace) {
5786
+ await this.guidelineScript.reapplyInstruction(workspace, name);
5641
5787
  }
5642
5788
  };
5643
5789
  __decorateClass([
@@ -5645,11 +5791,22 @@ __decorateClass([
5645
5791
  __decorateParam(0, Argument("name", { ask: "name of the instruction", nullable: true })),
5646
5792
  __decorateParam(1, Workspace())
5647
5793
  ], GuidelineCommand.prototype, "generateInstruction", 1);
5794
+ __decorateClass([
5795
+ Target.Public(),
5796
+ __decorateParam(0, Argument("name", { ask: "name of the instruction", nullable: true })),
5797
+ __decorateParam(1, Option("request", { ask: "What do you want to update?" })),
5798
+ __decorateParam(2, Workspace())
5799
+ ], GuidelineCommand.prototype, "updateInstruction", 1);
5800
+ __decorateClass([
5801
+ Target.Public(),
5802
+ __decorateParam(0, Argument("name", { ask: "name of the instruction", nullable: true })),
5803
+ __decorateParam(1, Workspace())
5804
+ ], GuidelineCommand.prototype, "generateDocument", 1);
5648
5805
  __decorateClass([
5649
5806
  Target.Public(),
5650
5807
  __decorateParam(0, Argument("name", { ask: "name of the instruction", nullable: true })),
5651
5808
  __decorateParam(1, Workspace())
5652
- ], GuidelineCommand.prototype, "deployDoc", 1);
5809
+ ], GuidelineCommand.prototype, "reapplyInstruction", 1);
5653
5810
  GuidelineCommand = __decorateClass([
5654
5811
  Commands()
5655
5812
  ], GuidelineCommand);
@@ -180,7 +180,7 @@ export const Card = ({ className, project, href }: ModelProps<"project", cnst.Li
180
180
  className={clsx(
181
181
  "border-base-300 bg-base-100 flex flex-col gap-3 rounded-lg border-2 p-4",
182
182
  "hover:border-primary transition-all hover:shadow-md",
183
- "focus:ring-primary focus:outline-hidden focus:ring-2",
183
+ "focus:ring-primary focus:ring-2 focus:outline-hidden",
184
184
  className
185
185
  )}
186
186
  >