@akanjs/cli 3.0.0-beta.12 → 3.0.0-beta.14

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 (43) hide show
  1. package/.build-stamp +1 -1
  2. package/{TunnelShare-sbsaggmb.js → TunnelShare-r5tc2qk5.js} +2 -2
  3. package/{agent.command-7357vxd8.js → agent.command-bhwsc2aj.js} +1 -1
  4. package/{application.command-pc8mdn3w.js → application.command-436y543n.js} +1 -11
  5. package/{cloud.command-cawrd5nq.js → cloud.command-3xn0xpz8.js} +4 -17
  6. package/{cloud.script-1bmptvw0.js → cloud.script-0a76c2g8.js} +4 -5
  7. package/commandManifest.json +1 -1
  8. package/{context.command-982b6kdp.js → context.command-hxh96cc3.js} +4 -6
  9. package/{devTui-hmteztv3.js → devTui-4ted58a6.js} +1 -1
  10. package/{devTuiView-40jvjnyz.js → devTuiView-1dj2yq7t.js} +1 -1
  11. package/guideline.command-cyw8c0m0.js +48 -0
  12. package/guidelines/agentRule/agentRule.instruction.md +24 -13
  13. package/guidelines/conventions/conventions.instruction.md +6 -3
  14. package/guidelines/moduleCodegen/moduleCodegen.instruction.md +1 -1
  15. package/guidelines/workspaceRecipes/workspaceRecipes.generate.json +1 -0
  16. package/guidelines/workspaceRecipes/workspaceRecipes.instruction.md +62 -0
  17. package/index-1mrmve4s.js +61 -0
  18. package/{index-s3fvrydw.js → index-31hmq4ys.js} +1 -1
  19. package/{index-ay8wj00x.js → index-8tcj5wk8.js} +6 -19
  20. package/index-9fbk3dbh.js +234 -0
  21. package/{index-3pvkjza8.js → index-fad0hhty.js} +3 -3
  22. package/{index-jcekapz4.js → index-gm76f0qb.js} +1 -1
  23. package/{index-bw2marpf.js → index-myj01w9r.js} +18 -19
  24. package/{index-kbsach1y.js → index-r73ha1rf.js} +1 -1
  25. package/{index-r8bd61d9.js → index-sg1bgdhe.js} +65 -68
  26. package/{index-8tfmh0v6.js → index-tt6kzwj5.js} +5 -15
  27. package/index.js +14 -14
  28. package/{localRegistry.command-rx758ajg.js → localRegistry.command-4cbgz63s.js} +3 -4
  29. package/{module.command-c2eve036.js → module.command-ew0484va.js} +4 -7
  30. package/package.json +2 -5
  31. package/{primitive.command-c44f7z1s.js → primitive.command-50ecfzg4.js} +2 -5
  32. package/{quality.command-5evdd263.js → quality.command-a2jytczs.js} +63 -3
  33. package/{scalar.command-xyzerygj.js → scalar.command-bptz6aj6.js} +3 -6
  34. package/{subspace.command-ebfwzypw.js → subspace.command-kmemx1vm.js} +2 -2
  35. package/{tunnel.command-v6a7at16.js → tunnel.command-67q8vsg5.js} +2 -2
  36. package/{workflow.command-t174m6sy.js → workflow.command-2ze5y2xp.js} +4 -7
  37. package/{workspace.command-bg3eveth.js → workspace.command-2n385jkt.js} +9 -10
  38. package/abstractCompactor-bqh31fk5.js +0 -102
  39. package/guideline.command-jn0vwszx.js +0 -360
  40. package/index-ceph7zqj.js +0 -229
  41. package/index-fr2x3qvv.js +0 -841
  42. package/index-meh558jy.js +0 -65
  43. package/index-yc1keaer.js +0 -338
package/index.js CHANGED
@@ -14,24 +14,24 @@ import path from "path";
14
14
 
15
15
  // pkgs/@akanjs/cli/commandModules.ts
16
16
  var commandModules = {
17
- workspace: async () => (await import("./workspace.command-bg3eveth.js")).WorkspaceCommand,
18
- agent: async () => (await import("./agent.command-7357vxd8.js")).AgentCommand,
19
- application: async () => (await import("./application.command-pc8mdn3w.js")).ApplicationCommand,
17
+ workspace: async () => (await import("./workspace.command-2n385jkt.js")).WorkspaceCommand,
18
+ agent: async () => (await import("./agent.command-bhwsc2aj.js")).AgentCommand,
19
+ application: async () => (await import("./application.command-436y543n.js")).ApplicationCommand,
20
20
  library: async () => (await import("./library.command-1f9h2ex6.js")).LibraryCommand,
21
- localRegistry: async () => (await import("./localRegistry.command-rx758ajg.js")).LocalRegistryCommand,
21
+ localRegistry: async () => (await import("./localRegistry.command-4cbgz63s.js")).LocalRegistryCommand,
22
22
  package: async () => (await import("./package.command-y2rh4np7.js")).PackageCommand,
23
- module: async () => (await import("./module.command-c2eve036.js")).ModuleCommand,
23
+ module: async () => (await import("./module.command-ew0484va.js")).ModuleCommand,
24
24
  page: async () => (await import("./page.command-e5h29fyt.js")).PageCommand,
25
- context: async () => (await import("./context.command-982b6kdp.js")).ContextCommand,
26
- cloud: async () => (await import("./cloud.command-cawrd5nq.js")).CloudCommand,
27
- subspace: async () => (await import("./subspace.command-ebfwzypw.js")).SubspaceCommand,
28
- guideline: async () => (await import("./guideline.command-jn0vwszx.js")).GuidelineCommand,
29
- scalar: async () => (await import("./scalar.command-xyzerygj.js")).ScalarCommand,
30
- primitive: async () => (await import("./primitive.command-c44f7z1s.js")).PrimitiveCommand,
31
- quality: async () => (await import("./quality.command-5evdd263.js")).QualityCommand,
25
+ context: async () => (await import("./context.command-hxh96cc3.js")).ContextCommand,
26
+ cloud: async () => (await import("./cloud.command-3xn0xpz8.js")).CloudCommand,
27
+ subspace: async () => (await import("./subspace.command-kmemx1vm.js")).SubspaceCommand,
28
+ guideline: async () => (await import("./guideline.command-cyw8c0m0.js")).GuidelineCommand,
29
+ scalar: async () => (await import("./scalar.command-bptz6aj6.js")).ScalarCommand,
30
+ primitive: async () => (await import("./primitive.command-50ecfzg4.js")).PrimitiveCommand,
31
+ quality: async () => (await import("./quality.command-a2jytczs.js")).QualityCommand,
32
32
  repair: async () => (await import("./repair.command-c2amvt74.js")).RepairCommand,
33
- workflow: async () => (await import("./workflow.command-t174m6sy.js")).WorkflowCommand,
34
- tunnel: async () => (await import("./tunnel.command-v6a7at16.js")).TunnelCommand
33
+ workflow: async () => (await import("./workflow.command-2ze5y2xp.js")).WorkflowCommand,
34
+ tunnel: async () => (await import("./tunnel.command-67q8vsg5.js")).TunnelCommand
35
35
  };
36
36
  var commandModuleIds = Object.keys(commandModules);
37
37
 
@@ -12,15 +12,14 @@ import {
12
12
  import"./index-6wwzs1bc.js";
13
13
  import {
14
14
  ApplicationScript
15
- } from "./index-r8bd61d9.js";
15
+ } from "./index-sg1bgdhe.js";
16
16
  import"./index-1nwxbr2y.js";
17
17
  import"./index-hwkygn9s.js";
18
- import"./index-bw2marpf.js";
19
- import"./index-yc1keaer.js";
18
+ import"./index-myj01w9r.js";
20
19
  import {
21
20
  getNpmRegistryUrl,
22
21
  CloudRunner
23
- } from "./index-8tfmh0v6.js";
22
+ } from "./index-tt6kzwj5.js";
24
23
  import"./index-kcxmv48c.js";
25
24
  import {
26
25
  PackageScript
@@ -10,20 +10,17 @@ import"./index-6wwzs1bc.js";
10
10
  import {
11
11
  renderPrimitiveReport
12
12
  } from "./index-jwjaf9fy.js";
13
- import"./index-bw2marpf.js";
14
- import"./index-yc1keaer.js";
13
+ import"./index-sh88vtye.js";
15
14
  import {
16
15
  ModuleScript
17
- } from "./index-fr2x3qvv.js";
18
- import"./index-sh88vtye.js";
19
- import"./index-h7yw2z9n.js";
16
+ } from "./index-9fbk3dbh.js";
20
17
 
21
18
  // pkgs/@akanjs/cli/module/module.command.ts
22
19
  import { Logger, lowerlize } from "akanjs/common";
23
20
  class ModuleCommand extends command("module", [ModuleScript], ({ public: target }) => ({
24
- createModule: target({ desc: "Create a new domain module (constant, service, signal, store, UI)" }).arg("moduleName", String, { desc: "name of module" }).with(Sys).option("page", Boolean, { desc: "create page", default: false }).option("ai", Boolean, { desc: "use ai to create module constant and dictionary", default: false }).option("format", String, { flag: "o", desc: "output format", default: "markdown", enum: ["markdown", "json"] }).exec(async function(moduleName, sys, page, ai, format) {
21
+ createModule: target({ desc: "Create a new domain module (constant, service, signal, store, UI)" }).arg("moduleName", String, { desc: "name of module" }).with(Sys).option("page", Boolean, { desc: "create page", default: false }).option("format", String, { flag: "o", desc: "output format", default: "markdown", enum: ["markdown", "json"] }).exec(async function(moduleName, sys, page, format) {
25
22
  const name = lowerlize(moduleName.replace(/ /g, ""));
26
- const report = ai ? await this.moduleScript.createModule(sys, name, { page }) : await this.moduleScript.createModuleTemplate(sys, name, { page });
23
+ const report = await this.moduleScript.createModuleTemplate(sys, name, { page });
27
24
  Logger.rawLog(renderPrimitiveReport(report, format));
28
25
  }),
29
26
  removeModule: target({ desc: "Remove a module from an app or library" }).with(Module).exec(async function(module) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@akanjs/cli",
3
- "version": "3.0.0-beta.12",
3
+ "version": "3.0.0-beta.14",
4
4
  "sourceType": "module",
5
5
  "type": "module",
6
6
  "publishConfig": {
@@ -28,12 +28,9 @@
28
28
  },
29
29
  "dependencies": {
30
30
  "@inquirer/prompts": "^8.4.3",
31
- "@langchain/core": "^1.1.47",
32
- "@langchain/deepseek": "^1.0.26",
33
- "@langchain/openai": "^1.4.6",
34
31
  "@tailwindcss/node": "^4.3.0",
35
32
  "@trapezedev/project": "^7.1.4",
36
- "akanjs": "3.0.0-beta.12",
33
+ "akanjs": "3.0.0-beta.14",
37
34
  "chalk": "^5.6.2",
38
35
  "commander": "^14.0.3",
39
36
  "dayjs": "^1.11.20",
@@ -9,14 +9,11 @@ import"./index-6wwzs1bc.js";
9
9
  import {
10
10
  renderPrimitiveReport
11
11
  } from "./index-jwjaf9fy.js";
12
- import"./index-bw2marpf.js";
13
- import"./index-yc1keaer.js";
14
- import"./index-fr2x3qvv.js";
15
12
  import"./index-sh88vtye.js";
16
- import"./index-h7yw2z9n.js";
13
+ import"./index-9fbk3dbh.js";
17
14
  import {
18
15
  PrimitiveScript
19
- } from "./index-kbsach1y.js";
16
+ } from "./index-r73ha1rf.js";
20
17
 
21
18
  // pkgs/@akanjs/cli/primitive/primitive.command.ts
22
19
  import { Logger } from "akanjs/common";
@@ -12,9 +12,6 @@ import {
12
12
  isAllowedLibFacetRootFile
13
13
  } from "./index-5nyznra1.js";
14
14
  import"./index-6wwzs1bc.js";
15
- import {
16
- AbstractDoc
17
- } from "./index-meh558jy.js";
18
15
 
19
16
  // pkgs/@akanjs/devkit/qualityScanner.ts
20
17
  import { createHash } from "crypto";
@@ -24,6 +21,69 @@ import { RESERVED_ROUTE_CONFIG_EXPORTS } from "akanjs/common";
24
21
  import ignore from "ignore";
25
22
  import ts3 from "typescript";
26
23
 
24
+ // pkgs/@akanjs/devkit/abstractDoc.ts
25
+ class AbstractDoc {
26
+ path;
27
+ content;
28
+ siblingFiles;
29
+ static suffix = ".abstract.md";
30
+ static maxLines = 300;
31
+ static compactMinLines = 40;
32
+ static #facetRoots = "{lib,ui,webkit,srvkit,common,plugin}";
33
+ static isAbstractPath(filePath) {
34
+ return filePath.endsWith(AbstractDoc.suffix);
35
+ }
36
+ static lineCountOf(content) {
37
+ return content.split(/\r?\n/).length;
38
+ }
39
+ static kindOf(filePath) {
40
+ const [root, folder, ...rest] = filePath.split("/");
41
+ if (root !== "lib" || !folder)
42
+ return "other";
43
+ if (folder === "__scalar")
44
+ return rest.length === 2 ? "scalar" : "other";
45
+ if (rest.length !== 1)
46
+ return "other";
47
+ return folder.startsWith("_") ? "service" : "domain";
48
+ }
49
+ static async findAll(sys, { module } = {}) {
50
+ const filePaths = (await sys.getAllFiles(`${AbstractDoc.#facetRoots}/**/*${AbstractDoc.suffix}`)).sort();
51
+ const docs = await Promise.all(filePaths.map((filePath) => AbstractDoc.read(sys, filePath)));
52
+ if (!module)
53
+ return docs;
54
+ return docs.filter((doc) => doc.moduleName === module || doc.folderName === module);
55
+ }
56
+ static async read(sys, filePath) {
57
+ const dirPath = filePath.split("/").slice(0, -1).join("/");
58
+ const [content, folderFiles] = await Promise.all([sys.readFile(filePath), sys.readdir(dirPath)]);
59
+ return new AbstractDoc(filePath, content, folderFiles.filter((fileName) => !AbstractDoc.isAbstractPath(fileName)));
60
+ }
61
+ constructor(path, content, siblingFiles) {
62
+ this.path = path;
63
+ this.content = content;
64
+ this.siblingFiles = siblingFiles;
65
+ }
66
+ get kind() {
67
+ return AbstractDoc.kindOf(this.path);
68
+ }
69
+ get folderName() {
70
+ return this.path.split("/").at(-2) ?? "";
71
+ }
72
+ get moduleName() {
73
+ return (this.path.split("/").at(-1) ?? "").slice(0, -AbstractDoc.suffix.length);
74
+ }
75
+ get lineCount() {
76
+ return AbstractDoc.lineCountOf(this.content);
77
+ }
78
+ canReplaceWith(candidate) {
79
+ const next = candidate.trim();
80
+ if (!next.startsWith("#"))
81
+ return false;
82
+ const lineCount = AbstractDoc.lineCountOf(next);
83
+ return lineCount >= 3 && lineCount < this.lineCount;
84
+ }
85
+ }
86
+
27
87
  // pkgs/@akanjs/devkit/formSetterScanner.ts
28
88
  import ts from "typescript";
29
89
 
@@ -9,19 +9,16 @@ import"./index-6wwzs1bc.js";
9
9
  import {
10
10
  renderPrimitiveReport
11
11
  } from "./index-jwjaf9fy.js";
12
- import"./index-bw2marpf.js";
13
- import"./index-yc1keaer.js";
14
- import"./index-h7yw2z9n.js";
15
12
  import {
16
13
  ScalarScript
17
- } from "./index-ceph7zqj.js";
14
+ } from "./index-1mrmve4s.js";
18
15
 
19
16
  // pkgs/@akanjs/cli/scalar/scalar.command.ts
20
17
  import { Logger, lowerlize } from "akanjs/common";
21
18
  class ScalarCommand extends command("scalar", [ScalarScript], ({ public: target }) => ({
22
- createScalar: target({ desc: "Create a new scalar type (simple data model without DB)" }).arg("scalarName", String, { desc: "name of scalar" }).with(Sys).option("ai", Boolean, { default: false, desc: "use ai to create scalar" }).option("format", String, { flag: "o", desc: "output format", default: "markdown", enum: ["markdown", "json"] }).exec(async function(scalarName, sys, ai, format) {
19
+ createScalar: target({ desc: "Create a new scalar type (simple data model without DB)" }).arg("scalarName", String, { desc: "name of scalar" }).with(Sys).option("format", String, { flag: "o", desc: "output format", default: "markdown", enum: ["markdown", "json"] }).exec(async function(scalarName, sys, format) {
23
20
  const name = lowerlize(scalarName.replace(/ /g, ""));
24
- const report = ai ? await this.scalarScript.createScalarWithAi(sys, name) : await this.scalarScript.createScalar(sys, name);
21
+ const report = await this.scalarScript.createScalar(sys, name);
25
22
  Logger.rawLog(renderPrimitiveReport(report, format));
26
23
  }),
27
24
  removeScalar: target({ desc: "Remove a scalar type from an app or library" }).arg("scalarName", String, { desc: "name of scalar" }).with(Sys).exec(async function(scalarName, sys) {
@@ -4,7 +4,7 @@ import {
4
4
  } from "./index-q0y2jq9j.js";
5
5
  import {
6
6
  GlobalConfig
7
- } from "./index-bw2marpf.js";
7
+ } from "./index-myj01w9r.js";
8
8
  import {
9
9
  Workspace,
10
10
  CommandContainer,
@@ -725,7 +725,7 @@ class SubspaceRunner extends runner("subspace") {
725
725
  if (!asked)
726
726
  return { name: subspace.name, workspaceId, host, apps, libs: [], outcome: "cancelled", files: [] };
727
727
  const { libs } = await subspace.slice();
728
- const { CloudScript } = await import("./cloud.script-1bmptvw0.js");
728
+ const { CloudScript } = await import("./cloud.script-0a76c2g8.js");
729
729
  const { files } = await CommandContainer.get(CloudScript).uploadEnv(workspace, {
730
730
  host,
731
731
  workspaceId,
@@ -3,7 +3,7 @@ import"./index-q0y2jq9j.js";
3
3
  import {
4
4
  GlobalConfig,
5
5
  CloudApi
6
- } from "./index-bw2marpf.js";
6
+ } from "./index-myj01w9r.js";
7
7
  import {
8
8
  Workspace,
9
9
  runner,
@@ -16,7 +16,7 @@ import {
16
16
  import"./index-6wwzs1bc.js";
17
17
  import {
18
18
  TunnelShare2
19
- } from "./index-jcekapz4.js";
19
+ } from "./index-gm76f0qb.js";
20
20
  import {
21
21
  writeClipboard
22
22
  } from "./index-p6pbz9n5.js";
@@ -10,19 +10,16 @@ import"./index-6wwzs1bc.js";
10
10
  import {
11
11
  createWorkflowStepRegistry
12
12
  } from "./index-jwjaf9fy.js";
13
- import"./index-bw2marpf.js";
14
- import"./index-yc1keaer.js";
13
+ import"./index-sh88vtye.js";
15
14
  import {
16
15
  ModuleScript
17
- } from "./index-fr2x3qvv.js";
18
- import"./index-sh88vtye.js";
19
- import"./index-h7yw2z9n.js";
16
+ } from "./index-9fbk3dbh.js";
20
17
  import {
21
18
  PrimitiveScript
22
- } from "./index-kbsach1y.js";
19
+ } from "./index-r73ha1rf.js";
23
20
  import {
24
21
  ScalarScript
25
- } from "./index-ceph7zqj.js";
22
+ } from "./index-1mrmve4s.js";
26
23
  import"./index-by5gpp8x.js";
27
24
  import"./index-15r9a10e.js";
28
25
  import {
@@ -4,7 +4,7 @@ import {
4
4
  } from "./index-q0y2jq9j.js";
5
5
  import {
6
6
  GlobalConfig
7
- } from "./index-bw2marpf.js";
7
+ } from "./index-myj01w9r.js";
8
8
  import {
9
9
  Exec,
10
10
  Workspace,
@@ -37,15 +37,14 @@ import"./index-15r9a10e.js";
37
37
  import"./index-h7yw2z9n.js";
38
38
  import {
39
39
  AgentScript
40
- } from "./index-s3fvrydw.js";
40
+ } from "./index-31hmq4ys.js";
41
41
  import {
42
42
  ApplicationScript
43
- } from "./index-r8bd61d9.js";
43
+ } from "./index-sg1bgdhe.js";
44
44
  import {
45
45
  LibraryScript
46
46
  } from "./index-1nwxbr2y.js";
47
47
  import"./index-hwkygn9s.js";
48
- import"./index-yc1keaer.js";
49
48
  import"./index-kcxmv48c.js";
50
49
  import {
51
50
  PackageScript
@@ -53,20 +52,20 @@ import {
53
52
  import {
54
53
  getNpmRegistryUrl,
55
54
  getLatestPackageVersion
56
- } from "./index-8tfmh0v6.js";
55
+ } from "./index-tt6kzwj5.js";
57
56
  import {
58
57
  CloudScript2
59
- } from "./index-ay8wj00x.js";
58
+ } from "./index-8tcj5wk8.js";
60
59
  import {
61
60
  ContextScript
62
- } from "./index-3pvkjza8.js";
61
+ } from "./index-fad0hhty.js";
63
62
  import"./index-7f4dsf9v.js";
64
63
  import"./index-em4swemt.js";
65
64
  import"./index-8pkvrcv1.js";
66
- import"./index-fr2x3qvv.js";
67
65
  import"./index-sh88vtye.js";
68
- import"./index-kbsach1y.js";
69
- import"./index-ceph7zqj.js";
66
+ import"./index-9fbk3dbh.js";
67
+ import"./index-r73ha1rf.js";
68
+ import"./index-1mrmve4s.js";
70
69
  import"./index-ys7dvdb3.js";
71
70
 
72
71
  // pkgs/@akanjs/cli/workspace/workspace.runner.ts
@@ -1,102 +0,0 @@
1
- // @bun
2
- import"./index-q0y2jq9j.js";
3
- import"./index-bw2marpf.js";
4
- import {
5
- AiSession
6
- } from "./index-yc1keaer.js";
7
- import {
8
- AbstractDoc
9
- } from "./index-meh558jy.js";
10
-
11
- // pkgs/@akanjs/devkit/abstractCompactor.ts
12
- import { Logger } from "akanjs/common";
13
- import chalk from "chalk";
14
- class AbstractCompactor {
15
- static #reviewRequest = `Review the compacted file you just wrote against the original.
16
- - Did you drop an invariant, a security reason, or a workflow step that the source files cannot show by themselves? Restore it.
17
- - Did you keep anything that only restates code, scaffold wording, or history? Remove it.
18
- - Is it in the same language as the original, within the line budget, and one short line per bullet?
19
- Respond with exactly one \`\`\`markdown code block holding the corrected file and nothing else. If nothing needs to change, repeat the file unchanged.`;
20
- #sys;
21
- #minLines;
22
- #interactive;
23
- constructor(sys, { minLines = AbstractDoc.compactMinLines, interactive = false } = {}) {
24
- this.#sys = sys;
25
- this.#minLines = minLines;
26
- this.#interactive = interactive;
27
- }
28
- async compactAll({ module } = {}) {
29
- const docs = await AbstractDoc.findAll(this.#sys, { module });
30
- const targets = docs.filter((doc) => doc.lineCount > this.#minLines);
31
- const reports = [];
32
- for (const doc of targets)
33
- reports.push(await this.compact(doc));
34
- return { scanned: docs.length, reports };
35
- }
36
- async compact(doc) {
37
- const session = new AiSession("compactAbstract", {
38
- workspace: this.#sys.workspace,
39
- cacheKey: `${this.#sys.name}-${doc.moduleName}`
40
- });
41
- const approve = !this.#interactive;
42
- const compacted = await session.editMarkdown(this.#request(doc), { approve });
43
- const reviewed = await session.editMarkdown(AbstractCompactor.#reviewRequest, { approve });
44
- const next = [reviewed, compacted].map((candidate) => candidate.trim()).find((candidate) => doc.canReplaceWith(candidate));
45
- const beforeLines = doc.lineCount;
46
- if (!next) {
47
- Logger.rawLog(chalk.yellow(`${doc.path}: the editor returned no shorter abstract, keeping the current file`));
48
- return { path: doc.path, beforeLines, afterLines: beforeLines, status: "failed" };
49
- }
50
- if (next === doc.content.trim())
51
- return { path: doc.path, beforeLines, afterLines: beforeLines, status: "unchanged" };
52
- const content = `${next}
53
- `;
54
- await this.#sys.writeFile(doc.path, content);
55
- return { path: doc.path, beforeLines, afterLines: AbstractDoc.lineCountOf(content), status: "compacted" };
56
- }
57
- #targetShape(kind) {
58
- if (kind === "other")
59
- return " - keep the headings that still carry information and drop the rest; do not impose a new structure";
60
- return [
61
- " - `# <name> Abstract` title line",
62
- " - one declarative sentence naming what this module owns",
63
- " - `## Rules` \u2014 two to five bullets, each an invariant the code cannot show by itself",
64
- " - optional `## Workflow` \u2014 the lifecycle as an arrow chain (`draft -> signed -> active`) or a few bullets"
65
- ].join(`
66
- `);
67
- }
68
- #request(doc) {
69
- return `You are compacting an Akan.js abstract file.
70
-
71
- An abstract is the summary a coding agent reads before changing a module. Repeated edits have made this one
72
- bloated, and it has to shrink back to what the source files cannot show by themselves.
73
-
74
- # Target file
75
- ${this.#sys.type}s/${this.#sys.name}/${doc.path} (${doc.kind} module "${doc.moduleName}", ${doc.lineCount} lines)
76
-
77
- # Source files in the same folder
78
- ${doc.siblingFiles.join(", ") || "none"}
79
-
80
- # Current content
81
- \`\`\`markdown
82
- ${doc.content}
83
- \`\`\`
84
-
85
- # Rules for the compacted file
86
- - Write it in the SAME language as the current content. Never translate.
87
- - Keep every invariant, constraint, security reason, and workflow step that the source files cannot show by
88
- themselves. Merge duplicates instead of dropping either one.
89
- - Delete what the code already states: field lists, types, labels, signatures, file lists, and imports.
90
- - Delete scaffold and placeholder wording, changelog or migration history, TODOs, and any instruction about
91
- reading or updating this file.
92
- - Never invent a rule that the current content does not state.
93
- - Keep every bullet to one short line, and stay under ${AbstractDoc.compactMinLines} lines in total.
94
- - Shape:
95
- ${this.#targetShape(doc.kind)}
96
-
97
- Respond with exactly one \`\`\`markdown code block holding the whole new file and nothing else.`;
98
- }
99
- }
100
- export {
101
- AbstractCompactor
102
- };