@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.
- package/.build-stamp +1 -1
- package/{TunnelShare-sbsaggmb.js → TunnelShare-r5tc2qk5.js} +2 -2
- package/{agent.command-7357vxd8.js → agent.command-bhwsc2aj.js} +1 -1
- package/{application.command-pc8mdn3w.js → application.command-436y543n.js} +1 -11
- package/{cloud.command-cawrd5nq.js → cloud.command-3xn0xpz8.js} +4 -17
- package/{cloud.script-1bmptvw0.js → cloud.script-0a76c2g8.js} +4 -5
- package/commandManifest.json +1 -1
- package/{context.command-982b6kdp.js → context.command-hxh96cc3.js} +4 -6
- package/{devTui-hmteztv3.js → devTui-4ted58a6.js} +1 -1
- package/{devTuiView-40jvjnyz.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-ay8wj00x.js → index-8tcj5wk8.js} +6 -19
- package/index-9fbk3dbh.js +234 -0
- package/{index-3pvkjza8.js → index-fad0hhty.js} +3 -3
- package/{index-jcekapz4.js → index-gm76f0qb.js} +1 -1
- package/{index-bw2marpf.js → index-myj01w9r.js} +18 -19
- package/{index-kbsach1y.js → index-r73ha1rf.js} +1 -1
- package/{index-r8bd61d9.js → index-sg1bgdhe.js} +65 -68
- package/{index-8tfmh0v6.js → index-tt6kzwj5.js} +5 -15
- package/index.js +14 -14
- package/{localRegistry.command-rx758ajg.js → localRegistry.command-4cbgz63s.js} +3 -4
- package/{module.command-c2eve036.js → module.command-ew0484va.js} +4 -7
- package/package.json +2 -5
- package/{primitive.command-c44f7z1s.js → primitive.command-50ecfzg4.js} +2 -5
- package/{quality.command-5evdd263.js → quality.command-a2jytczs.js} +63 -3
- package/{scalar.command-xyzerygj.js → scalar.command-bptz6aj6.js} +3 -6
- package/{subspace.command-ebfwzypw.js → subspace.command-kmemx1vm.js} +2 -2
- package/{tunnel.command-v6a7at16.js → tunnel.command-67q8vsg5.js} +2 -2
- package/{workflow.command-t174m6sy.js → workflow.command-2ze5y2xp.js} +4 -7
- package/{workspace.command-bg3eveth.js → workspace.command-2n385jkt.js} +9 -10
- package/abstractCompactor-bqh31fk5.js +0 -102
- package/guideline.command-jn0vwszx.js +0 -360
- package/index-ceph7zqj.js +0 -229
- package/index-fr2x3qvv.js +0 -841
- package/index-meh558jy.js +0 -65
- package/index-yc1keaer.js +0 -338
|
@@ -1,360 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import {
|
|
3
|
-
Workspace,
|
|
4
|
-
runner,
|
|
5
|
-
script,
|
|
6
|
-
command
|
|
7
|
-
} from "./index-b3ae16mg.js";
|
|
8
|
-
import {
|
|
9
|
-
FileSys
|
|
10
|
-
} from "./index-q0y2jq9j.js";
|
|
11
|
-
import"./index-5nyznra1.js";
|
|
12
|
-
import {
|
|
13
|
-
getDirname2
|
|
14
|
-
} from "./index-6wwzs1bc.js";
|
|
15
|
-
import {
|
|
16
|
-
Prompter
|
|
17
|
-
} from "./index-h7yw2z9n.js";
|
|
18
|
-
import"./index-bw2marpf.js";
|
|
19
|
-
import {
|
|
20
|
-
AiSession
|
|
21
|
-
} from "./index-yc1keaer.js";
|
|
22
|
-
|
|
23
|
-
// pkgs/@akanjs/cli/guideline/guideline.script.ts
|
|
24
|
-
import { Logger } from "akanjs/common";
|
|
25
|
-
|
|
26
|
-
// pkgs/@akanjs/cli/guideline/guideline.prompt.ts
|
|
27
|
-
import { randomPicks } from "akanjs/common";
|
|
28
|
-
|
|
29
|
-
class GuidelinePrompt extends Prompter {
|
|
30
|
-
workspace;
|
|
31
|
-
name;
|
|
32
|
-
constructor(workspace, name) {
|
|
33
|
-
super();
|
|
34
|
-
this.workspace = workspace;
|
|
35
|
-
this.name = name;
|
|
36
|
-
}
|
|
37
|
-
#resolveDocsPagePath(page) {
|
|
38
|
-
if (page.startsWith("apps/"))
|
|
39
|
-
return page;
|
|
40
|
-
if (page.endsWith(".tsx"))
|
|
41
|
-
return page;
|
|
42
|
-
return `apps/akan/page${page}`;
|
|
43
|
-
}
|
|
44
|
-
async#getScanFilePaths(matchPattern, { avoidDirs = ["node_modules", ".next"], filterText } = {}) {
|
|
45
|
-
const glob = new Bun.Glob(matchPattern);
|
|
46
|
-
const paths = [];
|
|
47
|
-
for await (const path of glob.scan({ cwd: this.workspace.workspaceRoot, absolute: true })) {
|
|
48
|
-
if (avoidDirs.some((dir) => path.includes(dir)))
|
|
49
|
-
continue;
|
|
50
|
-
const fileContent = await FileSys.readText(path);
|
|
51
|
-
const textFilter = filterText ? new RegExp(filterText) : null;
|
|
52
|
-
if (filterText && !textFilter?.test(fileContent))
|
|
53
|
-
continue;
|
|
54
|
-
paths.push(path);
|
|
55
|
-
}
|
|
56
|
-
return paths;
|
|
57
|
-
}
|
|
58
|
-
async requestCreateInstruction() {
|
|
59
|
-
const guideJson = await Prompter.getGuideJson(this.name);
|
|
60
|
-
const scanFiles = [];
|
|
61
|
-
for (const scan of guideJson.scans) {
|
|
62
|
-
const scanFilePaths = await this.#getScanFilePaths(scan.path, { filterText: scan.filterText });
|
|
63
|
-
const targetFilePaths = scan.sample ? randomPicks(scanFilePaths, scan.sample) : scanFilePaths;
|
|
64
|
-
const scanResult = await Promise.all(targetFilePaths.map(async (filePath) => ({ ...scan, ...await this.workspace.getLocalFile(filePath) })));
|
|
65
|
-
scanFiles.push(...scanResult);
|
|
66
|
-
}
|
|
67
|
-
const resultPath = `${getDirname2(import.meta.url)}/../guidelines/${this.name}/${guideJson.update.filePath}`;
|
|
68
|
-
const writePath = `${this.workspace.workspaceRoot}/pkgs/@akanjs/cli/guidelines/${this.name}/${guideJson.update.filePath}`;
|
|
69
|
-
const isResultExists = await this.workspace.exists(writePath);
|
|
70
|
-
const existingResult = isResultExists ? await this.workspace.readFile(resultPath) : null;
|
|
71
|
-
const request = `
|
|
72
|
-
I am a developer of akanjs framework, a full-stack framework for building web applications.
|
|
73
|
-
I want to generate a ${guideJson.update.filePath} file for ${guideJson.description}.
|
|
74
|
-
This file is a programming guideline for Akan.js framwork users.
|
|
75
|
-
|
|
76
|
-
# ${guideJson.title} Workflow
|
|
77
|
-
- 1. Explore target files in ${guideJson.scans.map((scan) => scan.path).join(", ")}.
|
|
78
|
-
- 2. Read already-written ${guideJson.update.filePath} file if exists. There can be some outdated information, so you need to update the file and add new information, make it more accurate and more detailed.
|
|
79
|
-
- 3. Write the updated file content of the ${guideJson.update.filePath}. It should include the contents of ${guideJson.update.contents.join(",")}, and any other helpful information and contents for guiding. Also, you can rearrange the contents if you think it's more helpful.
|
|
80
|
-
|
|
81
|
-
## 1. Explore target files in ${guideJson.scans.map((scan) => scan.path).join(", ")}.
|
|
82
|
-
${scanFiles.map(({ type, description, filePath, content, sample }) => `
|
|
83
|
-
\`\`\`${filePath.endsWith(".tsx") ? "tsx" : "typescript"}
|
|
84
|
-
// File: ${filePath}
|
|
85
|
-
// Type: ${type}${sample ? " (sample)" : ""}
|
|
86
|
-
// Desc: ${description}
|
|
87
|
-
${content}
|
|
88
|
-
\`\`\`
|
|
89
|
-
`).join(`
|
|
90
|
-
`)}
|
|
91
|
-
|
|
92
|
-
## 2. Read already-written ${guideJson.update.filePath} file if exists. There can be some outdated information, so you need to update the file and add new information, make it more accurate and more detailed.
|
|
93
|
-
${existingResult ? `\`\`\`markdown
|
|
94
|
-
${existingResult}
|
|
95
|
-
\`\`\`` : "- No existing guideline file."}
|
|
96
|
-
|
|
97
|
-
## 3. Write the updated file content of the ${guideJson.update.filePath}. It should include the contents of ${guideJson.update.contents.join(",")}, and any other helpful information and contents for guiding. Also, you can rearrange the contents if you think it's more helpful.
|
|
98
|
-
|
|
99
|
-
Here's the last rules for writing the file content:
|
|
100
|
-
${guideJson.update.rules.map((rule) => `- ${rule}`).join(`
|
|
101
|
-
`)}
|
|
102
|
-
|
|
103
|
-
=> Now, you need to write the file content here. Let's go.
|
|
104
|
-
`;
|
|
105
|
-
return { guideJson, request, writePath };
|
|
106
|
-
}
|
|
107
|
-
async requestUpdateInstruction(updateRequest) {
|
|
108
|
-
const guideJson = await Prompter.getGuideJson(this.name);
|
|
109
|
-
const resultPath = `${getDirname2(import.meta.url)}/../guidelines/${this.name}/${guideJson.update.filePath}`;
|
|
110
|
-
const writePath = `${this.workspace.workspaceRoot}/pkgs/@akanjs/cli/guidelines/${this.name}/${guideJson.update.filePath}`;
|
|
111
|
-
const isResultExists = await this.workspace.exists(writePath);
|
|
112
|
-
if (!isResultExists)
|
|
113
|
-
throw new Error(`${guideJson.update.filePath} file does not exist. Please create it first.`);
|
|
114
|
-
const existingResult = await this.workspace.readFile(resultPath);
|
|
115
|
-
const request = `
|
|
116
|
-
I am a developer of akanjs framework, a full-stack framework for building web applications.
|
|
117
|
-
I want to update a ${guideJson.update.filePath} file for ${guideJson.description}.
|
|
118
|
-
This file is a programming guideline for Akan.js framwork users.
|
|
119
|
-
|
|
120
|
-
# ${guideJson.title} Workflow
|
|
121
|
-
- 1. Read already-written ${guideJson.update.filePath} file.
|
|
122
|
-
- 2. Write the updated file content of the ${guideJson.update.filePath} with the update request.
|
|
123
|
-
|
|
124
|
-
## 1. Read already-written ${guideJson.update.filePath} file.
|
|
125
|
-
\`\`\`markdown
|
|
126
|
-
${existingResult}
|
|
127
|
-
\`\`\`
|
|
128
|
-
|
|
129
|
-
## 2. Write the updated file content of the ${guideJson.update.filePath} with the update request.
|
|
130
|
-
Request: ${updateRequest}
|
|
131
|
-
|
|
132
|
-
=> Now, you need to write the file content here. Let's go.
|
|
133
|
-
`;
|
|
134
|
-
return { guideJson, request, writePath };
|
|
135
|
-
}
|
|
136
|
-
async requestCreateDocumentPage(page) {
|
|
137
|
-
const writePath = this.#resolveDocsPagePath(page);
|
|
138
|
-
if (!await this.workspace.exists(writePath))
|
|
139
|
-
await this.workspace.writeFile(writePath, `import { page } from "akanjs/client";
|
|
140
|
-
|
|
141
|
-
export default page().render(() => {
|
|
142
|
-
return <div>No Content</div>;
|
|
143
|
-
});
|
|
144
|
-
`);
|
|
145
|
-
const instruction = await Prompter.getInstruction(this.name);
|
|
146
|
-
const pageContent = await this.workspace.getLocalFile(writePath);
|
|
147
|
-
const request = `
|
|
148
|
-
I'm creating a documentation website for the Akan.js framework.
|
|
149
|
-
|
|
150
|
-
1. Overview of the Akan.js framework
|
|
151
|
-
${await this.getDocumentation("framework")}
|
|
152
|
-
|
|
153
|
-
2. Documentation page writing method
|
|
154
|
-
${await this.getDocumentation("docPageRule")}
|
|
155
|
-
|
|
156
|
-
3. CSS rule with TailwindCSS and akanjs/ui primitives (semantic tokens; no daisyui)
|
|
157
|
-
${await this.getDocumentation("cssRule")}
|
|
158
|
-
|
|
159
|
-
I want to update the Next.js server-side page located at ${writePath}.
|
|
160
|
-
Below is the content of the currently written page.
|
|
161
|
-
\`\`\`tsx
|
|
162
|
-
// File: ${writePath}
|
|
163
|
-
${pageContent.content}
|
|
164
|
-
\`\`\`
|
|
165
|
-
|
|
166
|
-
Please update this page with the latest content below. A great design application is needed.
|
|
167
|
-
${instruction}
|
|
168
|
-
|
|
169
|
-
Please follow these CSS rules when writing:
|
|
170
|
-
- Use tailwindcss with the semantic design tokens (bg-background, text-foreground, bg-primary, text-muted-foreground, border-border, \u2026)
|
|
171
|
-
- Use akanjs/ui primitives (Button, Badge, Input, Field, \u2026) instead of raw daisyui classes; do not use daisyui
|
|
172
|
-
|
|
173
|
-
Please return only the file result in the following format for easy parsing.
|
|
174
|
-
\`\`\`tsx
|
|
175
|
-
// File: ${writePath}
|
|
176
|
-
...pageContent
|
|
177
|
-
\`\`\`
|
|
178
|
-
`;
|
|
179
|
-
return { request, writePath };
|
|
180
|
-
}
|
|
181
|
-
async requestUpdateDocumentPage(page, updateRequest) {
|
|
182
|
-
const writePath = this.#resolveDocsPagePath(page);
|
|
183
|
-
if (!await this.workspace.exists(writePath))
|
|
184
|
-
await this.workspace.writeFile(writePath, `import { page } from "akanjs/client";
|
|
185
|
-
|
|
186
|
-
export default page().render(() => {
|
|
187
|
-
return <div>No Content</div>;
|
|
188
|
-
});
|
|
189
|
-
`);
|
|
190
|
-
const instruction = await Prompter.getInstruction(this.name);
|
|
191
|
-
const pageContent = await this.workspace.getLocalFile(writePath);
|
|
192
|
-
const request = `
|
|
193
|
-
I'm updating a documentation website for the Akan.js framework.
|
|
194
|
-
|
|
195
|
-
I want to update the Next.js server-side page located at ${writePath}.
|
|
196
|
-
Below is the content of the currently written page. You should update stale infos and preserve the existing content.
|
|
197
|
-
\`\`\`tsx
|
|
198
|
-
// File: ${writePath}
|
|
199
|
-
${pageContent.content}
|
|
200
|
-
\`\`\`
|
|
201
|
-
|
|
202
|
-
The existing instruction is below.
|
|
203
|
-
\`\`\`markdown
|
|
204
|
-
${instruction}
|
|
205
|
-
\`\`\`
|
|
206
|
-
|
|
207
|
-
Please update this page with the request below.
|
|
208
|
-
${updateRequest}
|
|
209
|
-
|
|
210
|
-
Please return only the file result in the following format for easy parsing.
|
|
211
|
-
\`\`\`tsx
|
|
212
|
-
// File: ${writePath}
|
|
213
|
-
...pageContent
|
|
214
|
-
\`\`\`
|
|
215
|
-
`;
|
|
216
|
-
return { request, writePath };
|
|
217
|
-
}
|
|
218
|
-
async requestReapplyInstruction(filePath) {
|
|
219
|
-
const guideJson = await Prompter.getGuideJson(this.name);
|
|
220
|
-
const writePath = `${this.workspace.workspaceRoot}/pkgs/@akanjs/cli/guidelines/${this.name}/${guideJson.update.filePath}`;
|
|
221
|
-
if (!guideJson.page)
|
|
222
|
-
throw new Error(`${this.name} does not have a page.`);
|
|
223
|
-
const pagePath = this.#resolveDocsPagePath(guideJson.page);
|
|
224
|
-
const pageFile = await this.workspace.getLocalFile(pagePath);
|
|
225
|
-
const request = `
|
|
226
|
-
I want to apply information in the Next.js page to markdown instruction file.
|
|
227
|
-
|
|
228
|
-
Here's the newest information in the Next.js page.
|
|
229
|
-
\`\`\`tsx
|
|
230
|
-
// File: ${pagePath}
|
|
231
|
-
${pageFile.content}
|
|
232
|
-
\`\`\`
|
|
233
|
-
|
|
234
|
-
Here's the existing instruction file.
|
|
235
|
-
\`\`\`markdown
|
|
236
|
-
${await Prompter.getInstruction(this.name)}
|
|
237
|
-
\`\`\`
|
|
238
|
-
|
|
239
|
-
Please update the instruction file with the information in the Next.js page.
|
|
240
|
-
`;
|
|
241
|
-
return { request, writePath };
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
// pkgs/@akanjs/cli/guideline/guideline.runner.ts
|
|
246
|
-
class GuidelineRunner extends runner("guideline") {
|
|
247
|
-
async generateInstruction(workspace, guideName) {
|
|
248
|
-
const session = new AiSession("generateInstruction", { workspace, cacheKey: guideName });
|
|
249
|
-
const prompt = new GuidelinePrompt(workspace, guideName);
|
|
250
|
-
const { guideJson, request, writePath } = await prompt.requestCreateInstruction();
|
|
251
|
-
const guidelineContent = await session.editMarkdown(request);
|
|
252
|
-
await workspace.writeFile(writePath, guidelineContent);
|
|
253
|
-
return { guideJson, session };
|
|
254
|
-
}
|
|
255
|
-
async updateInstruction(workspace, guideName, { updateRequest }) {
|
|
256
|
-
const session = new AiSession("updateInstruction", { workspace, cacheKey: guideName });
|
|
257
|
-
const prompt = new GuidelinePrompt(workspace, guideName);
|
|
258
|
-
const { guideJson, request, writePath } = await prompt.requestUpdateInstruction(updateRequest);
|
|
259
|
-
const guidelineContent = await session.editMarkdown(request);
|
|
260
|
-
await workspace.writeFile(writePath, guidelineContent);
|
|
261
|
-
return { guideJson, session };
|
|
262
|
-
}
|
|
263
|
-
async generateDocument(workspace, guideName) {
|
|
264
|
-
const session = new AiSession("deployDocPages", { workspace, cacheKey: guideName });
|
|
265
|
-
const guideJson = await Prompter.getGuideJson(guideName);
|
|
266
|
-
const prompt = new GuidelinePrompt(workspace, guideName);
|
|
267
|
-
if (!guideJson.page)
|
|
268
|
-
return Promise.resolve({});
|
|
269
|
-
const { request } = await prompt.requestCreateDocumentPage(guideJson.page);
|
|
270
|
-
await session.writeTypescripts(request, workspace);
|
|
271
|
-
}
|
|
272
|
-
async updateDocument(workspace, guideName, { updateRequest, session }) {
|
|
273
|
-
const guideJson = await Prompter.getGuideJson(guideName);
|
|
274
|
-
if (!guideJson.page)
|
|
275
|
-
throw new Error(`${guideName} does not have a page.`);
|
|
276
|
-
const prompt = new GuidelinePrompt(workspace, guideName);
|
|
277
|
-
const { request, writePath } = await prompt.requestUpdateDocumentPage(guideJson.page, updateRequest);
|
|
278
|
-
const guidelineContent = await session.editMarkdown(request);
|
|
279
|
-
await workspace.writeFile(writePath, guidelineContent);
|
|
280
|
-
}
|
|
281
|
-
async reapplyInstruction(workspace, guideName) {
|
|
282
|
-
const session = new AiSession("reapplyInstruction", { workspace, cacheKey: guideName });
|
|
283
|
-
const guideJson = await Prompter.getGuideJson(guideName);
|
|
284
|
-
const prompt = new GuidelinePrompt(workspace, guideName);
|
|
285
|
-
const { request, writePath } = await prompt.requestReapplyInstruction(guideJson.update.filePath);
|
|
286
|
-
const guidelineContent = await session.editMarkdown(request);
|
|
287
|
-
await workspace.writeFile(writePath, guidelineContent);
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
// pkgs/@akanjs/cli/guideline/guideline.script.ts
|
|
292
|
-
class GuidelineScript extends script("guideline", [GuidelineRunner]) {
|
|
293
|
-
async guideline(action, name = null, format = "markdown") {
|
|
294
|
-
if (action === "list") {
|
|
295
|
-
const guidelines = await Prompter.listGuidelines();
|
|
296
|
-
Logger.rawLog(format === "json" ? JSON.stringify({ guidelines }, null, 2) : guidelines.join(`
|
|
297
|
-
`));
|
|
298
|
-
return;
|
|
299
|
-
}
|
|
300
|
-
if (action === "show") {
|
|
301
|
-
if (!name)
|
|
302
|
-
throw new Error("Guideline name is required. Example: akan guideline show framework");
|
|
303
|
-
const [instruction, guideJson] = await Promise.all([Prompter.getInstruction(name), Prompter.getGuideJson(name)]);
|
|
304
|
-
Logger.rawLog(format === "json" ? JSON.stringify({ name, instruction, guideJson }, null, 2) : instruction);
|
|
305
|
-
return;
|
|
306
|
-
}
|
|
307
|
-
throw new Error(`Unknown guideline action: ${action}. Use "list" or "show".`);
|
|
308
|
-
}
|
|
309
|
-
async generateInstruction(workspace, name = null) {
|
|
310
|
-
const guideName = name ?? await Prompter.selectGuideline();
|
|
311
|
-
await this.guidelineRunner.generateInstruction(workspace, guideName);
|
|
312
|
-
}
|
|
313
|
-
async updateInstruction(workspace, name = null, updateRequest) {
|
|
314
|
-
const guideName = name ?? await Prompter.selectGuideline();
|
|
315
|
-
const { guideJson, session } = await this.guidelineRunner.updateInstruction(workspace, guideName, {
|
|
316
|
-
updateRequest
|
|
317
|
-
});
|
|
318
|
-
if (guideJson.page)
|
|
319
|
-
await this.updateDocument(workspace, guideName, { updateRequest, session });
|
|
320
|
-
}
|
|
321
|
-
async generateDocument(workspace, name = null) {
|
|
322
|
-
const guideName = name ?? await Prompter.selectGuideline();
|
|
323
|
-
await this.guidelineRunner.generateDocument(workspace, guideName);
|
|
324
|
-
}
|
|
325
|
-
async updateDocument(workspace, name = null, { updateRequest, session }) {
|
|
326
|
-
const guideName = name ?? await Prompter.selectGuideline();
|
|
327
|
-
await this.guidelineRunner.updateDocument(workspace, guideName, { updateRequest, session });
|
|
328
|
-
}
|
|
329
|
-
async reapplyInstruction(workspace, name = null) {
|
|
330
|
-
const guideName = name ?? await Prompter.selectGuideline();
|
|
331
|
-
await this.guidelineRunner.reapplyInstruction(workspace, guideName);
|
|
332
|
-
}
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
// pkgs/@akanjs/cli/guideline/guideline.command.ts
|
|
336
|
-
class GuidelineCommand extends command("guideline", [GuidelineScript], ({ public: target }) => ({
|
|
337
|
-
guideline: target({ desc: "List or show Akan AI guideline instructions" }).arg("action", String, { desc: "list or show" }).arg("name", String, { desc: "guideline name for show", nullable: true }).option("format", String, {
|
|
338
|
-
desc: "output format",
|
|
339
|
-
default: "markdown",
|
|
340
|
-
enum: ["markdown", "json"]
|
|
341
|
-
}).exec(async function(action, name, format) {
|
|
342
|
-
await this.guidelineScript.guideline(action, name, format);
|
|
343
|
-
}),
|
|
344
|
-
generateInstruction: target({ devOnly: true, desc: "Generate AI development guideline/instruction for your project" }).arg("name", String, { ask: "name of the instruction", nullable: true }).with(Workspace).exec(async function(name, workspace) {
|
|
345
|
-
await this.guidelineScript.generateInstruction(workspace, name);
|
|
346
|
-
}),
|
|
347
|
-
updateInstruction: target({ devOnly: true, desc: "Update existing AI guideline/instruction" }).arg("name", String, { ask: "name of the instruction", nullable: true }).option("request", String, { ask: "What do you want to update?" }).with(Workspace).exec(async function(name, request, workspace) {
|
|
348
|
-
await this.guidelineScript.updateInstruction(workspace, name, request);
|
|
349
|
-
}),
|
|
350
|
-
generateDocument: target({ devOnly: true, desc: "Generate documentation from guideline/instruction" }).arg("name", String, { ask: "name of the instruction", nullable: true }).with(Workspace).exec(async function(name, workspace) {
|
|
351
|
-
await this.guidelineScript.generateDocument(workspace, name);
|
|
352
|
-
}),
|
|
353
|
-
reapplyInstruction: target({ devOnly: true, desc: "Re-apply guideline/instruction to codebase" }).arg("name", String, { ask: "name of the instruction", nullable: true }).with(Workspace).exec(async function(name, workspace) {
|
|
354
|
-
await this.guidelineScript.reapplyInstruction(workspace, name);
|
|
355
|
-
})
|
|
356
|
-
})) {
|
|
357
|
-
}
|
|
358
|
-
export {
|
|
359
|
-
GuidelineCommand
|
|
360
|
-
};
|
package/index-ceph7zqj.js
DELETED
|
@@ -1,229 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import {
|
|
3
|
-
runner,
|
|
4
|
-
script
|
|
5
|
-
} from "./index-b3ae16mg.js";
|
|
6
|
-
import {
|
|
7
|
-
generatedFilesForSync,
|
|
8
|
-
createPassedPrimitiveReport,
|
|
9
|
-
scalarChangedFiles
|
|
10
|
-
} from "./index-jwjaf9fy.js";
|
|
11
|
-
import {
|
|
12
|
-
AiSession
|
|
13
|
-
} from "./index-yc1keaer.js";
|
|
14
|
-
import {
|
|
15
|
-
Prompter
|
|
16
|
-
} from "./index-h7yw2z9n.js";
|
|
17
|
-
import {
|
|
18
|
-
pluralizeName
|
|
19
|
-
} from "./index-nz8prx9g.js";
|
|
20
|
-
|
|
21
|
-
// pkgs/@akanjs/cli/scalar/scalar.prompt.ts
|
|
22
|
-
import { input } from "@inquirer/prompts";
|
|
23
|
-
class ScalarPrompt extends Prompter {
|
|
24
|
-
sys;
|
|
25
|
-
name;
|
|
26
|
-
constructor(sys, name) {
|
|
27
|
-
super();
|
|
28
|
-
this.sys = sys;
|
|
29
|
-
this.name = name;
|
|
30
|
-
}
|
|
31
|
-
async requestUpdateConstant() {
|
|
32
|
-
const request = await input({ message: `What do you want to change?` });
|
|
33
|
-
return { request, validate: undefined };
|
|
34
|
-
}
|
|
35
|
-
async requestCreateConstant() {
|
|
36
|
-
const constantFiles = await this.sys.getConstantFilesWithLibs();
|
|
37
|
-
const description = await input({ message: "description of scalar" });
|
|
38
|
-
const schemaDescription = await input({ message: "schema description of scalar" });
|
|
39
|
-
await this.sys.applyTemplate({
|
|
40
|
-
basePath: "./lib/__scalar",
|
|
41
|
-
template: "__scalar",
|
|
42
|
-
dict: { model: this.name, models: pluralizeName(this.name), sysName: this.sys.name }
|
|
43
|
-
});
|
|
44
|
-
const boilerplate = await this.sys.readFile(`lib/__scalar/${this.name}/${this.name}.constant.ts`);
|
|
45
|
-
return await this.#requestConstant({
|
|
46
|
-
modelDesc: description,
|
|
47
|
-
modelSchemaDesign: schemaDescription,
|
|
48
|
-
boilerplate,
|
|
49
|
-
constantFiles
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
async#requestConstant({
|
|
53
|
-
modelDesc,
|
|
54
|
-
modelSchemaDesign,
|
|
55
|
-
boilerplate,
|
|
56
|
-
constantFiles
|
|
57
|
-
}) {
|
|
58
|
-
const scanInfo = await this.sys.scan();
|
|
59
|
-
const guideJson = await Prompter.getGuideJson("scalarConstant");
|
|
60
|
-
const request = await this.makeTsFileUpdatePrompt({
|
|
61
|
-
context: `
|
|
62
|
-
1. Overview of __scalar/<model>/<model>.constant.ts file
|
|
63
|
-
${await this.getDocumentation("scalarConstant")}
|
|
64
|
-
|
|
65
|
-
2. How to write Enums in __scalar/<model>/<model>.constant.ts file
|
|
66
|
-
${await this.getDocumentation("enumConstant")}
|
|
67
|
-
|
|
68
|
-
3. How to write Fields in __scalar/<model>/<model>.constant.ts file
|
|
69
|
-
${await this.getDocumentation("fieldRule")}
|
|
70
|
-
|
|
71
|
-
4. List of constant.ts files in other libraries connected to current ${this.sys.name} ${this.sys.type === "app" ? "Application" : "Library"} ${scanInfo.getLibs().map((lib) => lib).join(", ")}
|
|
72
|
-
Please understand the content and file patterns below, and feel free to reuse any constants or enums if available.
|
|
73
|
-
${constantFiles.map((constant) => `
|
|
74
|
-
\`\`\`typescript
|
|
75
|
-
// File: ${constant.filePath}
|
|
76
|
-
${constant.content}
|
|
77
|
-
\`\`\`
|
|
78
|
-
`).join(`
|
|
79
|
-
`)}
|
|
80
|
-
`,
|
|
81
|
-
request: `
|
|
82
|
-
Based on the above content, please organize it according to the boilerplate below for easy parsing
|
|
83
|
-
|
|
84
|
-
Application name: ${this.sys.name} (${this.sys.type === "app" ? "Application" : "Library"})
|
|
85
|
-
Model name: ${this.name}
|
|
86
|
-
Model description: ${modelDesc}
|
|
87
|
-
Model schema design: ${modelSchemaDesign}
|
|
88
|
-
Model filename(You can create another connected scalar model file if needed): ${this.name}.constant.ts
|
|
89
|
-
\`\`\`typescript
|
|
90
|
-
// File: lib/__scalar/${this.name}/${this.name}.constant.ts
|
|
91
|
-
${boilerplate}
|
|
92
|
-
\`\`\`
|
|
93
|
-
|
|
94
|
-
If additional connected scalar models need to be written besides ${this.name}.constant.ts file, please write them in the following format
|
|
95
|
-
\`\`\`typescript
|
|
96
|
-
// File: lib/__scalar/otherModel/otherModel.constant.ts
|
|
97
|
-
...file content
|
|
98
|
-
\`\`\`
|
|
99
|
-
|
|
100
|
-
Please provide only the file results without any other content.`
|
|
101
|
-
});
|
|
102
|
-
return { request, validate: guideJson.update.rules };
|
|
103
|
-
}
|
|
104
|
-
async requestUpdateDictonaryWithInstruction() {
|
|
105
|
-
const constant = await this.sys.readFile(`lib/__scalar/${this.name}/${this.name}.constant.ts`);
|
|
106
|
-
const boilerplate = await this.sys.readFile(`lib/__scalar/${this.name}/${this.name}.dictionary.ts`);
|
|
107
|
-
const guideJson = await Prompter.getGuideJson("scalarDictionary");
|
|
108
|
-
const request = `\uB2E4\uC74C ${this.name}.dictionary.ts \uD30C\uC77C\uB3C4 \uC644\uC131\uB41C ${this.name}.constant.ts \uD30C\uC77C\uC744 \uAE30\uBC18\uC73C\uB85C \uC791\uC131\uD574\uC918.
|
|
109
|
-
1. Dictionary \uC791\uC131\uBC95
|
|
110
|
-
${await this.getDocumentation("scalarDictionary")}
|
|
111
|
-
|
|
112
|
-
Model constant file
|
|
113
|
-
\`\`\`typescript
|
|
114
|
-
// File: lib/__scalar/${this.name}/${this.name}.constant.ts
|
|
115
|
-
${constant}
|
|
116
|
-
\`\`\`
|
|
117
|
-
|
|
118
|
-
Model filename: ${this.name}.dictionary.ts
|
|
119
|
-
\`\`\`typescript
|
|
120
|
-
// File: lib/__scalar/${this.name}/${this.name}.dictionary.ts
|
|
121
|
-
${boilerplate}
|
|
122
|
-
\`\`\`
|
|
123
|
-
`;
|
|
124
|
-
return { request, validate: guideJson.update.rules };
|
|
125
|
-
}
|
|
126
|
-
async requestUpdateDictonaryWithFollowing() {
|
|
127
|
-
const [constant, boilerplate] = await Promise.all([
|
|
128
|
-
this.sys.readFile(`lib/__scalar/${this.name}/${this.name}.constant.ts`),
|
|
129
|
-
this.sys.readFile(`lib/__scalar/${this.name}/${this.name}.dictionary.ts`)
|
|
130
|
-
]);
|
|
131
|
-
const request = `\uB2E4\uC74C ${this.name}.dictionary.ts \uD30C\uC77C\uB3C4 \uC644\uC131\uB41C ${this.name}.constant.ts \uD30C\uC77C\uC744 \uAE30\uBC18\uC73C\uB85C \uC791\uC131\uD574\uC918.
|
|
132
|
-
Model constant file
|
|
133
|
-
\`\`\`typescript
|
|
134
|
-
// File: lib/__scalar/${this.name}/${this.name}.constant.ts
|
|
135
|
-
${constant}
|
|
136
|
-
\`\`\`
|
|
137
|
-
|
|
138
|
-
Model filename: ${this.name}.dictionary.ts
|
|
139
|
-
\`\`\`typescript
|
|
140
|
-
// File: lib/__scalar/${this.name}/${this.name}.dictionary.ts
|
|
141
|
-
${boilerplate}
|
|
142
|
-
\`\`\`
|
|
143
|
-
`;
|
|
144
|
-
return { request, validate: [] };
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
// pkgs/@akanjs/cli/scalar/scalar.runner.ts
|
|
149
|
-
class ScalarRunner extends runner("scalar") {
|
|
150
|
-
async applyScalarTemplate(sys, scalarName) {
|
|
151
|
-
await sys.applyTemplate({
|
|
152
|
-
basePath: "./lib/__scalar",
|
|
153
|
-
template: "__scalar",
|
|
154
|
-
dict: { model: scalarName, models: pluralizeName(scalarName), sysName: sys.name },
|
|
155
|
-
overwrite: false
|
|
156
|
-
});
|
|
157
|
-
return {
|
|
158
|
-
abstract: {
|
|
159
|
-
filename: `${scalarName}.abstract.md`,
|
|
160
|
-
content: await sys.readFile(`lib/__scalar/${scalarName}/${scalarName}.abstract.md`)
|
|
161
|
-
},
|
|
162
|
-
constant: {
|
|
163
|
-
filename: `${scalarName}.constant.ts`,
|
|
164
|
-
content: await sys.readFile(`lib/__scalar/${scalarName}/${scalarName}.constant.ts`)
|
|
165
|
-
},
|
|
166
|
-
dictionary: {
|
|
167
|
-
filename: `${scalarName}.dictionary.ts`,
|
|
168
|
-
content: await sys.readFile(`lib/__scalar/${scalarName}/${scalarName}.dictionary.ts`)
|
|
169
|
-
},
|
|
170
|
-
document: {
|
|
171
|
-
filename: `${scalarName}.document.ts`,
|
|
172
|
-
content: await sys.readFile(`lib/__scalar/${scalarName}/${scalarName}.document.ts`)
|
|
173
|
-
}
|
|
174
|
-
};
|
|
175
|
-
}
|
|
176
|
-
async createScalarConstant(sys, scalarName) {
|
|
177
|
-
const isContinued = await sys.exists(`lib/__scalar/${scalarName}/${scalarName}.constant.ts`);
|
|
178
|
-
const prompt = new ScalarPrompt(sys, scalarName);
|
|
179
|
-
const session = new AiSession("createScalar", { workspace: sys.workspace, cacheKey: scalarName, isContinued });
|
|
180
|
-
const { request, validate } = session.isCacheLoaded ? await prompt.requestUpdateConstant() : await prompt.requestCreateConstant();
|
|
181
|
-
const writes = await session.writeTypescripts(request, sys, { validate });
|
|
182
|
-
const scalarNames = writes.map(({ filePath }) => filePath.split("/").at(-2)).filter((name) => !!name);
|
|
183
|
-
if (!scalarNames.includes(scalarName))
|
|
184
|
-
scalarNames.unshift(scalarName);
|
|
185
|
-
for (const name of scalarNames)
|
|
186
|
-
await this.applyScalarTemplate(sys, name);
|
|
187
|
-
return { session, scalarNames, writes, prompt };
|
|
188
|
-
}
|
|
189
|
-
async updateScalarDictionaries(sys, scalarNames, { session }) {
|
|
190
|
-
const [firstScalarName, ...followingScalarNames] = scalarNames;
|
|
191
|
-
const prompt = new ScalarPrompt(sys, firstScalarName);
|
|
192
|
-
const { request, validate } = await prompt.requestUpdateDictonaryWithInstruction();
|
|
193
|
-
await session.writeTypescripts(request, sys, { validate });
|
|
194
|
-
for (const scalarName of followingScalarNames) {
|
|
195
|
-
const prompt = new ScalarPrompt(sys, scalarName);
|
|
196
|
-
const { request, validate } = await prompt.requestUpdateDictonaryWithFollowing();
|
|
197
|
-
await session.writeTypescripts(request, sys, { validate });
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
// pkgs/@akanjs/cli/scalar/scalar.script.ts
|
|
203
|
-
class ScalarScript extends script("scalar", [ScalarRunner]) {
|
|
204
|
-
async createScalar(sys, scalarName) {
|
|
205
|
-
const files = await this.scalarRunner.applyScalarTemplate(sys, scalarName);
|
|
206
|
-
return createPassedPrimitiveReport({
|
|
207
|
-
command: "create-scalar",
|
|
208
|
-
changedFiles: scalarChangedFiles(sys, scalarName, files),
|
|
209
|
-
generatedFiles: generatedFilesForSync(sys),
|
|
210
|
-
target: sys.name
|
|
211
|
-
});
|
|
212
|
-
}
|
|
213
|
-
async createScalarWithAi(sys, scalarName) {
|
|
214
|
-
const { session, scalarNames } = await this.scalarRunner.createScalarConstant(sys, scalarName);
|
|
215
|
-
await this.scalarRunner.updateScalarDictionaries(sys, scalarNames, { session });
|
|
216
|
-
const fileMaps = await Promise.all(scalarNames.map(async (name) => ({ name, files: await this.scalarRunner.applyScalarTemplate(sys, name) })));
|
|
217
|
-
return createPassedPrimitiveReport({
|
|
218
|
-
command: "create-scalar",
|
|
219
|
-
changedFiles: fileMaps.flatMap(({ name, files }) => scalarChangedFiles(sys, name, files)),
|
|
220
|
-
generatedFiles: generatedFilesForSync(sys),
|
|
221
|
-
target: sys.name
|
|
222
|
-
});
|
|
223
|
-
}
|
|
224
|
-
async removeScalar(sys, scalarName) {
|
|
225
|
-
await sys.removeDir(`lib/__scalar/${scalarName}`);
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
export { ScalarScript };
|