@akanjs/cli 3.0.0-beta.13 → 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.
- package/.build-stamp +1 -1
- package/{TunnelShare-2kwqb1j6.js → TunnelShare-r5tc2qk5.js} +2 -2
- package/{agent.command-7357vxd8.js → agent.command-bhwsc2aj.js} +1 -1
- package/{application.command-8s8ns95d.js → application.command-436y543n.js} +1 -11
- package/{cloud.command-p5dnhft9.js → cloud.command-3xn0xpz8.js} +4 -17
- package/{cloud.script-gxpbhras.js → cloud.script-0a76c2g8.js} +4 -5
- package/commandManifest.json +1 -1
- package/{context.command-wsjt98c1.js → context.command-hxh96cc3.js} +4 -6
- package/{devTui-myg3pqeg.js → devTui-4ted58a6.js} +1 -1
- package/{devTuiView-gz2fbf4v.js → devTuiView-1dj2yq7t.js} +1 -1
- package/guideline.command-cyw8c0m0.js +48 -0
- package/guidelines/agentRule/agentRule.instruction.md +24 -13
- package/guidelines/conventions/conventions.instruction.md +6 -3
- package/guidelines/moduleCodegen/moduleCodegen.instruction.md +1 -1
- package/guidelines/workspaceRecipes/workspaceRecipes.generate.json +1 -0
- package/guidelines/workspaceRecipes/workspaceRecipes.instruction.md +62 -0
- package/index-1mrmve4s.js +61 -0
- package/{index-s3fvrydw.js → index-31hmq4ys.js} +1 -1
- package/{index-t3c045et.js → index-8tcj5wk8.js} +6 -19
- package/index-9fbk3dbh.js +234 -0
- package/{index-j7rwsd23.js → index-fad0hhty.js} +3 -3
- package/{index-wmb05v4q.js → index-gm76f0qb.js} +1 -1
- package/{index-649svkyt.js → index-myj01w9r.js} +8 -15
- package/{index-h3g1152j.js → index-r73ha1rf.js} +1 -1
- package/{index-cnzm1wn5.js → index-sg1bgdhe.js} +65 -68
- package/{index-bz10w9t2.js → index-tt6kzwj5.js} +5 -15
- package/index.js +14 -14
- package/{localRegistry.command-w6w35j4r.js → localRegistry.command-4cbgz63s.js} +3 -4
- package/{module.command-8zkq0q9q.js → module.command-ew0484va.js} +4 -7
- package/package.json +2 -5
- package/{primitive.command-qm7tybpn.js → primitive.command-50ecfzg4.js} +2 -5
- package/{quality.command-5evdd263.js → quality.command-a2jytczs.js} +63 -3
- package/{scalar.command-a1ewkmab.js → scalar.command-bptz6aj6.js} +3 -6
- package/{subspace.command-3w5x13a1.js → subspace.command-kmemx1vm.js} +2 -2
- package/{tunnel.command-09n8h4s1.js → tunnel.command-67q8vsg5.js} +2 -2
- package/{workflow.command-y3fct1rq.js → workflow.command-2ze5y2xp.js} +4 -7
- package/{workspace.command-p6td4qad.js → workspace.command-2n385jkt.js} +9 -10
- package/abstractCompactor-g04vqcff.js +0 -102
- package/guideline.command-snqzfyt0.js +0 -360
- package/index-5tw8t1ts.js +0 -338
- package/index-j1tajctp.js +0 -229
- package/index-kpnp2e10.js +0 -841
- package/index-meh558jy.js +0 -65
|
@@ -12,15 +12,14 @@ import {
|
|
|
12
12
|
import"./index-6wwzs1bc.js";
|
|
13
13
|
import {
|
|
14
14
|
ApplicationScript
|
|
15
|
-
} from "./index-
|
|
15
|
+
} from "./index-sg1bgdhe.js";
|
|
16
16
|
import"./index-1nwxbr2y.js";
|
|
17
17
|
import"./index-hwkygn9s.js";
|
|
18
|
-
import"./index-
|
|
19
|
-
import"./index-5tw8t1ts.js";
|
|
18
|
+
import"./index-myj01w9r.js";
|
|
20
19
|
import {
|
|
21
20
|
getNpmRegistryUrl,
|
|
22
21
|
CloudRunner
|
|
23
|
-
} from "./index-
|
|
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-
|
|
14
|
-
import"./index-5tw8t1ts.js";
|
|
13
|
+
import"./index-sh88vtye.js";
|
|
15
14
|
import {
|
|
16
15
|
ModuleScript
|
|
17
|
-
} from "./index-
|
|
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("
|
|
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 =
|
|
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.
|
|
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.
|
|
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-649svkyt.js";
|
|
13
|
-
import"./index-5tw8t1ts.js";
|
|
14
|
-
import"./index-kpnp2e10.js";
|
|
15
12
|
import"./index-sh88vtye.js";
|
|
16
|
-
import"./index-
|
|
13
|
+
import"./index-9fbk3dbh.js";
|
|
17
14
|
import {
|
|
18
15
|
PrimitiveScript
|
|
19
|
-
} from "./index-
|
|
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-649svkyt.js";
|
|
13
|
-
import"./index-5tw8t1ts.js";
|
|
14
|
-
import"./index-h7yw2z9n.js";
|
|
15
12
|
import {
|
|
16
13
|
ScalarScript
|
|
17
|
-
} from "./index-
|
|
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("
|
|
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 =
|
|
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-
|
|
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-
|
|
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-
|
|
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-
|
|
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-
|
|
14
|
-
import"./index-5tw8t1ts.js";
|
|
13
|
+
import"./index-sh88vtye.js";
|
|
15
14
|
import {
|
|
16
15
|
ModuleScript
|
|
17
|
-
} from "./index-
|
|
18
|
-
import"./index-sh88vtye.js";
|
|
19
|
-
import"./index-h7yw2z9n.js";
|
|
16
|
+
} from "./index-9fbk3dbh.js";
|
|
20
17
|
import {
|
|
21
18
|
PrimitiveScript
|
|
22
|
-
} from "./index-
|
|
19
|
+
} from "./index-r73ha1rf.js";
|
|
23
20
|
import {
|
|
24
21
|
ScalarScript
|
|
25
|
-
} from "./index-
|
|
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-
|
|
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-
|
|
40
|
+
} from "./index-31hmq4ys.js";
|
|
41
41
|
import {
|
|
42
42
|
ApplicationScript
|
|
43
|
-
} from "./index-
|
|
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-5tw8t1ts.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-
|
|
55
|
+
} from "./index-tt6kzwj5.js";
|
|
57
56
|
import {
|
|
58
57
|
CloudScript2
|
|
59
|
-
} from "./index-
|
|
58
|
+
} from "./index-8tcj5wk8.js";
|
|
60
59
|
import {
|
|
61
60
|
ContextScript
|
|
62
|
-
} from "./index-
|
|
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-kpnp2e10.js";
|
|
67
65
|
import"./index-sh88vtye.js";
|
|
68
|
-
import"./index-
|
|
69
|
-
import"./index-
|
|
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-649svkyt.js";
|
|
4
|
-
import {
|
|
5
|
-
AiSession
|
|
6
|
-
} from "./index-5tw8t1ts.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
|
-
};
|