@akanjs/devkit 0.0.88 → 0.0.90
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/index.js +21 -1
- package/index.mjs +1 -0
- package/package.json +5 -4
- package/src/aiEditor.d.ts +14 -0
- package/src/aiEditor.js +110 -21
- package/src/aiEditor.mjs +124 -0
- package/src/auth.js +48 -18
- package/src/auth.mjs +42 -0
- package/src/capacitorApp.js +42 -9
- package/src/{capacitorApp.cjs → capacitorApp.mjs} +9 -42
- package/src/commandDecorators/argMeta.js +34 -3
- package/src/commandDecorators/{argMeta.cjs → argMeta.mjs} +3 -34
- package/src/commandDecorators/command.js +68 -35
- package/src/commandDecorators/{command.cjs → command.mjs} +35 -68
- package/src/commandDecorators/commandMeta.js +25 -2
- package/src/commandDecorators/commandMeta.mjs +7 -0
- package/src/commandDecorators/index.js +29 -5
- package/src/commandDecorators/index.mjs +5 -0
- package/src/commandDecorators/targetMeta.js +26 -2
- package/src/commandDecorators/targetMeta.mjs +33 -0
- package/src/commandDecorators/types.js +15 -0
- package/src/commandDecorators/types.mjs +0 -0
- package/src/constants.d.ts +8 -1
- package/src/constants.js +34 -5
- package/src/constants.mjs +18 -0
- package/src/createTunnel.js +27 -4
- package/src/createTunnel.mjs +26 -0
- package/src/dependencyScanner.js +38 -5
- package/src/{dependencyScanner.cjs → dependencyScanner.mjs} +5 -38
- package/src/executors.d.ts +24 -31
- package/src/executors.js +180 -131
- package/src/{executors.cjs → executors.mjs} +146 -168
- package/src/extractDeps.js +25 -2
- package/src/{extractDeps.cjs → extractDeps.mjs} +2 -25
- package/src/getCredentials.js +39 -6
- package/src/getCredentials.mjs +11 -0
- package/src/getModelFileData.js +39 -6
- package/src/getModelFileData.mjs +33 -0
- package/src/getRelatedCnsts.d.ts +52 -8
- package/src/getRelatedCnsts.js +205 -54
- package/src/getRelatedCnsts.mjs +221 -0
- package/src/index.d.ts +0 -1
- package/src/index.js +51 -17
- package/src/index.mjs +16 -0
- package/src/selectModel.js +39 -6
- package/src/selectModel.mjs +13 -0
- package/src/streamAi.js +30 -7
- package/src/streamAi.mjs +39 -0
- package/src/types.js +15 -0
- package/src/types.mjs +0 -0
- package/src/uploadRelease.js +48 -15
- package/src/uploadRelease.mjs +52 -0
- package/index.cjs +0 -21
- package/src/aiEditor.cjs +0 -92
- package/src/auth.cjs +0 -72
- package/src/commandDecorators/commandMeta.cjs +0 -30
- package/src/commandDecorators/index.cjs +0 -29
- package/src/commandDecorators/targetMeta.cjs +0 -57
- package/src/commandDecorators/types.cjs +0 -15
- package/src/constants.cjs +0 -47
- package/src/createTunnel.cjs +0 -49
- package/src/getCredentials.cjs +0 -44
- package/src/getModelFileData.cjs +0 -66
- package/src/getRelatedCnsts.cjs +0 -142
- package/src/index.cjs +0 -53
- package/src/installExternalLib.cjs +0 -33
- package/src/installExternalLib.d.ts +0 -2
- package/src/installExternalLib.js +0 -10
- package/src/selectModel.cjs +0 -46
- package/src/streamAi.cjs +0 -62
- package/src/types.cjs +0 -15
- package/src/uploadRelease.cjs +0 -85
package/index.js
CHANGED
|
@@ -1 +1,21 @@
|
|
|
1
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __copyProps = (to, from, except, desc) => {
|
|
6
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
7
|
+
for (let key of __getOwnPropNames(from))
|
|
8
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
9
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
10
|
+
}
|
|
11
|
+
return to;
|
|
12
|
+
};
|
|
13
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
var devkit_exports = {};
|
|
16
|
+
module.exports = __toCommonJS(devkit_exports);
|
|
17
|
+
__reExport(devkit_exports, require("./src"), module.exports);
|
|
18
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
19
|
+
0 && (module.exports = {
|
|
20
|
+
...require("./src")
|
|
21
|
+
});
|
package/index.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./src";
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@akanjs/devkit",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"type": "
|
|
3
|
+
"version": "0.0.90",
|
|
4
|
+
"type": "commonjs",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
"@langchain/openai": "^0.5.10",
|
|
21
21
|
"@trapezedev/project": "^7.1.3",
|
|
22
22
|
"axios": "^1.7.9",
|
|
23
|
+
"chalk": "^5.4.1",
|
|
23
24
|
"commander": "^13.1.0",
|
|
24
25
|
"dotenv": "^16.4.7",
|
|
25
26
|
"form-data": "^4.0.1",
|
|
@@ -31,8 +32,8 @@
|
|
|
31
32
|
},
|
|
32
33
|
"exports": {
|
|
33
34
|
".": {
|
|
34
|
-
"require": "./index.
|
|
35
|
-
"import": "./index.
|
|
35
|
+
"require": "./index.js",
|
|
36
|
+
"import": "./index.mjs"
|
|
36
37
|
}
|
|
37
38
|
}
|
|
38
39
|
}
|
package/src/aiEditor.d.ts
CHANGED
|
@@ -1,10 +1,24 @@
|
|
|
1
1
|
import { BaseMessage } from "@langchain/core/messages";
|
|
2
|
+
export declare const supportedLlmModels: readonly ["deepseek-chat", "deepseek-reasoner"];
|
|
3
|
+
export type SupportedLlmModel = (typeof supportedLlmModels)[number];
|
|
2
4
|
interface EditOptions {
|
|
3
5
|
onChunk?: (chunk: string) => void;
|
|
4
6
|
maxTry?: number;
|
|
5
7
|
}
|
|
6
8
|
export declare class AiSession {
|
|
7
9
|
#private;
|
|
10
|
+
static init({ temperature, useExisting }?: {
|
|
11
|
+
temperature?: number;
|
|
12
|
+
useExisting?: boolean;
|
|
13
|
+
}): Promise<typeof AiSession>;
|
|
14
|
+
static getLlmConfig(): {
|
|
15
|
+
model: SupportedLlmModel;
|
|
16
|
+
apiKey: string;
|
|
17
|
+
} | null;
|
|
18
|
+
static setLlmConfig(llmConfig: {
|
|
19
|
+
model: SupportedLlmModel;
|
|
20
|
+
apiKey: string;
|
|
21
|
+
} | null): typeof AiSession;
|
|
8
22
|
readonly messageHistory: BaseMessage[];
|
|
9
23
|
constructor(messageHistory?: BaseMessage[]);
|
|
10
24
|
ask(question: string, { onChunk, }?: EditOptions): Promise<{
|
package/src/aiEditor.js
CHANGED
|
@@ -1,27 +1,112 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
var aiEditor_exports = {};
|
|
29
|
+
__export(aiEditor_exports, {
|
|
30
|
+
AiSession: () => AiSession,
|
|
31
|
+
supportedLlmModels: () => supportedLlmModels
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(aiEditor_exports);
|
|
34
|
+
var import_common = require("@akanjs/common");
|
|
35
|
+
var import_prompts = require("@inquirer/prompts");
|
|
36
|
+
var import_messages = require("@langchain/core/messages");
|
|
37
|
+
var import_openai = require("@langchain/openai");
|
|
38
|
+
var import_chalk = __toESM(require("chalk"));
|
|
39
|
+
var import_auth = require("./auth");
|
|
5
40
|
const MAX_ASK_TRY = 300;
|
|
41
|
+
const supportedLlmModels = ["deepseek-chat", "deepseek-reasoner"];
|
|
6
42
|
class AiSession {
|
|
7
|
-
static #chat =
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
43
|
+
static #chat = null;
|
|
44
|
+
static async init({ temperature = 0.7, useExisting = true } = {}) {
|
|
45
|
+
if (useExisting) {
|
|
46
|
+
const llmConfig2 = this.getLlmConfig();
|
|
47
|
+
if (llmConfig2)
|
|
48
|
+
return this.#setChatModel(llmConfig2.model, llmConfig2.apiKey);
|
|
49
|
+
}
|
|
50
|
+
const llmConfig = await this.#requestLlmConfig();
|
|
51
|
+
const { model, apiKey } = llmConfig;
|
|
52
|
+
await this.#validateApiKey(model, apiKey);
|
|
53
|
+
return this.#setChatModel(model, apiKey, { temperature }).setLlmConfig({ model, apiKey });
|
|
54
|
+
}
|
|
55
|
+
static #setChatModel(model, apiKey, { temperature = 0.7 } = {}) {
|
|
56
|
+
this.#chat = new import_openai.ChatOpenAI({
|
|
57
|
+
modelName: model,
|
|
58
|
+
temperature,
|
|
59
|
+
streaming: true,
|
|
60
|
+
configuration: { baseURL: "https://api.deepseek.com/v1", apiKey }
|
|
61
|
+
});
|
|
62
|
+
return this;
|
|
63
|
+
}
|
|
64
|
+
static getLlmConfig() {
|
|
65
|
+
const akanConfig = (0, import_auth.getAkanGlobalConfig)();
|
|
66
|
+
return akanConfig.llm ?? null;
|
|
67
|
+
}
|
|
68
|
+
static setLlmConfig(llmConfig) {
|
|
69
|
+
const akanConfig = (0, import_auth.getAkanGlobalConfig)();
|
|
70
|
+
akanConfig.llm = llmConfig;
|
|
71
|
+
(0, import_auth.setAkanGlobalConfig)(akanConfig);
|
|
72
|
+
return this;
|
|
73
|
+
}
|
|
74
|
+
static async #requestLlmConfig() {
|
|
75
|
+
const model = await (0, import_prompts.select)({ message: "Select a LLM model", choices: supportedLlmModels });
|
|
76
|
+
const apiKey = await (0, import_prompts.input)({ message: "Enter your API key" });
|
|
77
|
+
return { model, apiKey };
|
|
78
|
+
}
|
|
79
|
+
static async #validateApiKey(modelName, apiKey) {
|
|
80
|
+
const chat = new import_openai.ChatOpenAI({
|
|
81
|
+
modelName,
|
|
82
|
+
temperature: 0,
|
|
83
|
+
configuration: { baseURL: "https://api.deepseek.com/v1", apiKey }
|
|
84
|
+
});
|
|
85
|
+
try {
|
|
86
|
+
await chat.invoke("Hi, and just say 'ok'");
|
|
87
|
+
return true;
|
|
88
|
+
} catch (error) {
|
|
89
|
+
import_common.Logger.rawLog(
|
|
90
|
+
import_chalk.default.red(
|
|
91
|
+
`LLM API key is invalid. Please check your API key and try again. You can set it again by running "akan set-llm" or reset by running "akan reset-llm"`
|
|
92
|
+
)
|
|
93
|
+
);
|
|
94
|
+
throw error;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
14
97
|
messageHistory = [];
|
|
15
98
|
constructor(messageHistory = []) {
|
|
16
99
|
this.messageHistory = messageHistory;
|
|
17
100
|
}
|
|
18
101
|
async ask(question, {
|
|
19
102
|
onChunk = (chunk) => {
|
|
20
|
-
Logger.raw(chunk);
|
|
103
|
+
import_common.Logger.raw(chunk);
|
|
21
104
|
}
|
|
22
105
|
} = {}) {
|
|
106
|
+
if (!AiSession.#chat)
|
|
107
|
+
throw new Error("Please initialize the AI session first");
|
|
23
108
|
try {
|
|
24
|
-
const humanMessage = new HumanMessage(question);
|
|
109
|
+
const humanMessage = new import_messages.HumanMessage(question);
|
|
25
110
|
this.messageHistory.push(humanMessage);
|
|
26
111
|
const stream = await AiSession.#chat.stream(this.messageHistory);
|
|
27
112
|
let fullResponse = "";
|
|
@@ -32,7 +117,9 @@ class AiSession {
|
|
|
32
117
|
onChunk(content);
|
|
33
118
|
}
|
|
34
119
|
}
|
|
35
|
-
|
|
120
|
+
fullResponse += "\n";
|
|
121
|
+
onChunk("\n");
|
|
122
|
+
this.messageHistory.push(new import_messages.AIMessage(fullResponse));
|
|
36
123
|
return { content: fullResponse, messageHistory: this.messageHistory };
|
|
37
124
|
} catch (error) {
|
|
38
125
|
throw new Error("Failed to stream response");
|
|
@@ -41,7 +128,7 @@ class AiSession {
|
|
|
41
128
|
async edit(question, { onChunk, maxTry = MAX_ASK_TRY } = {}) {
|
|
42
129
|
for (let tryCount = 0; tryCount < maxTry; tryCount++) {
|
|
43
130
|
const response = await this.ask(question, { onChunk });
|
|
44
|
-
const isConfirmed = await select({
|
|
131
|
+
const isConfirmed = await (0, import_prompts.select)({
|
|
45
132
|
message: "Do you want to edit the response?",
|
|
46
133
|
choices: [
|
|
47
134
|
{ name: "\u2705 Yes, confirm and apply this result", value: true },
|
|
@@ -50,7 +137,7 @@ class AiSession {
|
|
|
50
137
|
});
|
|
51
138
|
if (isConfirmed)
|
|
52
139
|
return response.content;
|
|
53
|
-
question = await input({ message: "What do you want to change?" });
|
|
140
|
+
question = await (0, import_prompts.input)({ message: "What do you want to change?" });
|
|
54
141
|
tryCount++;
|
|
55
142
|
}
|
|
56
143
|
throw new Error("Failed to edit");
|
|
@@ -60,10 +147,12 @@ class AiSession {
|
|
|
60
147
|
return this.#getTypescriptCode(content);
|
|
61
148
|
}
|
|
62
149
|
#getTypescriptCode(content) {
|
|
63
|
-
const code = /```typescript([\s\S]*?)```/.exec(content);
|
|
64
|
-
return code ? code[
|
|
150
|
+
const code = /```(typescript|tsx)([\s\S]*?)```/.exec(content);
|
|
151
|
+
return code ? code[2] : content;
|
|
65
152
|
}
|
|
66
153
|
}
|
|
67
|
-
export
|
|
68
|
-
|
|
69
|
-
|
|
154
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
155
|
+
0 && (module.exports = {
|
|
156
|
+
AiSession,
|
|
157
|
+
supportedLlmModels
|
|
158
|
+
});
|
package/src/aiEditor.mjs
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { Logger } from "@akanjs/common";
|
|
2
|
+
import { input, select } from "@inquirer/prompts";
|
|
3
|
+
import { AIMessage, HumanMessage } from "@langchain/core/messages";
|
|
4
|
+
import { ChatOpenAI } from "@langchain/openai";
|
|
5
|
+
import chalk from "chalk";
|
|
6
|
+
import { getAkanGlobalConfig, setAkanGlobalConfig } from "./auth";
|
|
7
|
+
const MAX_ASK_TRY = 300;
|
|
8
|
+
const supportedLlmModels = ["deepseek-chat", "deepseek-reasoner"];
|
|
9
|
+
class AiSession {
|
|
10
|
+
static #chat = null;
|
|
11
|
+
static async init({ temperature = 0.7, useExisting = true } = {}) {
|
|
12
|
+
if (useExisting) {
|
|
13
|
+
const llmConfig2 = this.getLlmConfig();
|
|
14
|
+
if (llmConfig2)
|
|
15
|
+
return this.#setChatModel(llmConfig2.model, llmConfig2.apiKey);
|
|
16
|
+
}
|
|
17
|
+
const llmConfig = await this.#requestLlmConfig();
|
|
18
|
+
const { model, apiKey } = llmConfig;
|
|
19
|
+
await this.#validateApiKey(model, apiKey);
|
|
20
|
+
return this.#setChatModel(model, apiKey, { temperature }).setLlmConfig({ model, apiKey });
|
|
21
|
+
}
|
|
22
|
+
static #setChatModel(model, apiKey, { temperature = 0.7 } = {}) {
|
|
23
|
+
this.#chat = new ChatOpenAI({
|
|
24
|
+
modelName: model,
|
|
25
|
+
temperature,
|
|
26
|
+
streaming: true,
|
|
27
|
+
configuration: { baseURL: "https://api.deepseek.com/v1", apiKey }
|
|
28
|
+
});
|
|
29
|
+
return this;
|
|
30
|
+
}
|
|
31
|
+
static getLlmConfig() {
|
|
32
|
+
const akanConfig = getAkanGlobalConfig();
|
|
33
|
+
return akanConfig.llm ?? null;
|
|
34
|
+
}
|
|
35
|
+
static setLlmConfig(llmConfig) {
|
|
36
|
+
const akanConfig = getAkanGlobalConfig();
|
|
37
|
+
akanConfig.llm = llmConfig;
|
|
38
|
+
setAkanGlobalConfig(akanConfig);
|
|
39
|
+
return this;
|
|
40
|
+
}
|
|
41
|
+
static async #requestLlmConfig() {
|
|
42
|
+
const model = await select({ message: "Select a LLM model", choices: supportedLlmModels });
|
|
43
|
+
const apiKey = await input({ message: "Enter your API key" });
|
|
44
|
+
return { model, apiKey };
|
|
45
|
+
}
|
|
46
|
+
static async #validateApiKey(modelName, apiKey) {
|
|
47
|
+
const chat = new ChatOpenAI({
|
|
48
|
+
modelName,
|
|
49
|
+
temperature: 0,
|
|
50
|
+
configuration: { baseURL: "https://api.deepseek.com/v1", apiKey }
|
|
51
|
+
});
|
|
52
|
+
try {
|
|
53
|
+
await chat.invoke("Hi, and just say 'ok'");
|
|
54
|
+
return true;
|
|
55
|
+
} catch (error) {
|
|
56
|
+
Logger.rawLog(
|
|
57
|
+
chalk.red(
|
|
58
|
+
`LLM API key is invalid. Please check your API key and try again. You can set it again by running "akan set-llm" or reset by running "akan reset-llm"`
|
|
59
|
+
)
|
|
60
|
+
);
|
|
61
|
+
throw error;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
messageHistory = [];
|
|
65
|
+
constructor(messageHistory = []) {
|
|
66
|
+
this.messageHistory = messageHistory;
|
|
67
|
+
}
|
|
68
|
+
async ask(question, {
|
|
69
|
+
onChunk = (chunk) => {
|
|
70
|
+
Logger.raw(chunk);
|
|
71
|
+
}
|
|
72
|
+
} = {}) {
|
|
73
|
+
if (!AiSession.#chat)
|
|
74
|
+
throw new Error("Please initialize the AI session first");
|
|
75
|
+
try {
|
|
76
|
+
const humanMessage = new HumanMessage(question);
|
|
77
|
+
this.messageHistory.push(humanMessage);
|
|
78
|
+
const stream = await AiSession.#chat.stream(this.messageHistory);
|
|
79
|
+
let fullResponse = "";
|
|
80
|
+
for await (const chunk of stream) {
|
|
81
|
+
const content = chunk.content;
|
|
82
|
+
if (typeof content === "string") {
|
|
83
|
+
fullResponse += content;
|
|
84
|
+
onChunk(content);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
fullResponse += "\n";
|
|
88
|
+
onChunk("\n");
|
|
89
|
+
this.messageHistory.push(new AIMessage(fullResponse));
|
|
90
|
+
return { content: fullResponse, messageHistory: this.messageHistory };
|
|
91
|
+
} catch (error) {
|
|
92
|
+
throw new Error("Failed to stream response");
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
async edit(question, { onChunk, maxTry = MAX_ASK_TRY } = {}) {
|
|
96
|
+
for (let tryCount = 0; tryCount < maxTry; tryCount++) {
|
|
97
|
+
const response = await this.ask(question, { onChunk });
|
|
98
|
+
const isConfirmed = await select({
|
|
99
|
+
message: "Do you want to edit the response?",
|
|
100
|
+
choices: [
|
|
101
|
+
{ name: "\u2705 Yes, confirm and apply this result", value: true },
|
|
102
|
+
{ name: "\u{1F504} No, I want to edit it more", value: false }
|
|
103
|
+
]
|
|
104
|
+
});
|
|
105
|
+
if (isConfirmed)
|
|
106
|
+
return response.content;
|
|
107
|
+
question = await input({ message: "What do you want to change?" });
|
|
108
|
+
tryCount++;
|
|
109
|
+
}
|
|
110
|
+
throw new Error("Failed to edit");
|
|
111
|
+
}
|
|
112
|
+
async editTypescript(question, options = {}) {
|
|
113
|
+
const content = await this.edit(question, options);
|
|
114
|
+
return this.#getTypescriptCode(content);
|
|
115
|
+
}
|
|
116
|
+
#getTypescriptCode(content) {
|
|
117
|
+
const code = /```(typescript|tsx)([\s\S]*?)```/.exec(content);
|
|
118
|
+
return code ? code[2] : content;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
export {
|
|
122
|
+
AiSession,
|
|
123
|
+
supportedLlmModels
|
|
124
|
+
};
|
package/src/auth.js
CHANGED
|
@@ -1,42 +1,72 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
var auth_exports = {};
|
|
29
|
+
__export(auth_exports, {
|
|
30
|
+
getAkanGlobalConfig: () => getAkanGlobalConfig,
|
|
31
|
+
getHostConfig: () => getHostConfig,
|
|
32
|
+
getSelf: () => getSelf,
|
|
33
|
+
setAkanGlobalConfig: () => setAkanGlobalConfig,
|
|
34
|
+
setHostConfig: () => setHostConfig
|
|
35
|
+
});
|
|
36
|
+
module.exports = __toCommonJS(auth_exports);
|
|
37
|
+
var import_fs = __toESM(require("fs"));
|
|
38
|
+
var import_constants = require("./constants");
|
|
10
39
|
const getAkanGlobalConfig = () => {
|
|
11
|
-
const akanConfig =
|
|
40
|
+
const akanConfig = import_fs.default.existsSync(import_constants.configPath) ? JSON.parse(import_fs.default.readFileSync(import_constants.configPath, "utf8")) : import_constants.defaultAkanGlobalConfig;
|
|
12
41
|
return akanConfig;
|
|
13
42
|
};
|
|
14
43
|
const setAkanGlobalConfig = (akanConfig) => {
|
|
15
|
-
|
|
16
|
-
|
|
44
|
+
import_fs.default.mkdirSync(import_constants.basePath, { recursive: true });
|
|
45
|
+
import_fs.default.writeFileSync(import_constants.configPath, JSON.stringify(akanConfig, null, 2));
|
|
17
46
|
};
|
|
18
|
-
const getHostConfig = (host = akanCloudHost) => {
|
|
47
|
+
const getHostConfig = (host = import_constants.akanCloudHost) => {
|
|
19
48
|
const akanConfig = getAkanGlobalConfig();
|
|
20
|
-
return akanConfig[host] ?? defaultHostConfig;
|
|
49
|
+
return akanConfig.cloudHost[host] ?? import_constants.defaultHostConfig;
|
|
21
50
|
};
|
|
22
|
-
const setHostConfig = (host = akanCloudHost, config = {}) => {
|
|
51
|
+
const setHostConfig = (host = import_constants.akanCloudHost, config = {}) => {
|
|
23
52
|
const akanConfig = getAkanGlobalConfig();
|
|
24
53
|
akanConfig[host] = config;
|
|
25
54
|
setAkanGlobalConfig(akanConfig);
|
|
26
55
|
};
|
|
27
56
|
const getSelf = async (token) => {
|
|
28
57
|
try {
|
|
29
|
-
const res = await fetch(`${akanCloudBackendUrl}/user/getSelf`, { headers: { Authorization: `Bearer ${token}` } });
|
|
58
|
+
const res = await fetch(`${import_constants.akanCloudBackendUrl}/user/getSelf`, { headers: { Authorization: `Bearer ${token}` } });
|
|
30
59
|
const user = await res.json();
|
|
31
60
|
return user;
|
|
32
61
|
} catch (e) {
|
|
33
62
|
return null;
|
|
34
63
|
}
|
|
35
64
|
};
|
|
36
|
-
export
|
|
65
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
66
|
+
0 && (module.exports = {
|
|
37
67
|
getAkanGlobalConfig,
|
|
38
68
|
getHostConfig,
|
|
39
69
|
getSelf,
|
|
40
70
|
setAkanGlobalConfig,
|
|
41
71
|
setHostConfig
|
|
42
|
-
};
|
|
72
|
+
});
|
package/src/auth.mjs
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import {
|
|
3
|
+
akanCloudBackendUrl,
|
|
4
|
+
akanCloudHost,
|
|
5
|
+
basePath,
|
|
6
|
+
configPath,
|
|
7
|
+
defaultAkanGlobalConfig,
|
|
8
|
+
defaultHostConfig
|
|
9
|
+
} from "./constants";
|
|
10
|
+
const getAkanGlobalConfig = () => {
|
|
11
|
+
const akanConfig = fs.existsSync(configPath) ? JSON.parse(fs.readFileSync(configPath, "utf8")) : defaultAkanGlobalConfig;
|
|
12
|
+
return akanConfig;
|
|
13
|
+
};
|
|
14
|
+
const setAkanGlobalConfig = (akanConfig) => {
|
|
15
|
+
fs.mkdirSync(basePath, { recursive: true });
|
|
16
|
+
fs.writeFileSync(configPath, JSON.stringify(akanConfig, null, 2));
|
|
17
|
+
};
|
|
18
|
+
const getHostConfig = (host = akanCloudHost) => {
|
|
19
|
+
const akanConfig = getAkanGlobalConfig();
|
|
20
|
+
return akanConfig.cloudHost[host] ?? defaultHostConfig;
|
|
21
|
+
};
|
|
22
|
+
const setHostConfig = (host = akanCloudHost, config = {}) => {
|
|
23
|
+
const akanConfig = getAkanGlobalConfig();
|
|
24
|
+
akanConfig[host] = config;
|
|
25
|
+
setAkanGlobalConfig(akanConfig);
|
|
26
|
+
};
|
|
27
|
+
const getSelf = async (token) => {
|
|
28
|
+
try {
|
|
29
|
+
const res = await fetch(`${akanCloudBackendUrl}/user/getSelf`, { headers: { Authorization: `Bearer ${token}` } });
|
|
30
|
+
const user = await res.json();
|
|
31
|
+
return user;
|
|
32
|
+
} catch (e) {
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
export {
|
|
37
|
+
getAkanGlobalConfig,
|
|
38
|
+
getHostConfig,
|
|
39
|
+
getSelf,
|
|
40
|
+
setAkanGlobalConfig,
|
|
41
|
+
setHostConfig
|
|
42
|
+
};
|
package/src/capacitorApp.js
CHANGED
|
@@ -1,6 +1,38 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
var capacitorApp_exports = {};
|
|
29
|
+
__export(capacitorApp_exports, {
|
|
30
|
+
CapacitorApp: () => CapacitorApp
|
|
31
|
+
});
|
|
32
|
+
module.exports = __toCommonJS(capacitorApp_exports);
|
|
33
|
+
var import_common = require("@akanjs/common");
|
|
34
|
+
var import_project = require("@trapezedev/project");
|
|
35
|
+
var import_fs = __toESM(require("fs"));
|
|
4
36
|
class CapacitorApp {
|
|
5
37
|
constructor(app) {
|
|
6
38
|
this.app = app;
|
|
@@ -8,7 +40,7 @@ class CapacitorApp {
|
|
|
8
40
|
project;
|
|
9
41
|
iosTargetName = "App";
|
|
10
42
|
async init() {
|
|
11
|
-
const project = new MobileProject(this.app.cwdPath, {
|
|
43
|
+
const project = new import_project.MobileProject(this.app.cwdPath, {
|
|
12
44
|
android: { path: "android" },
|
|
13
45
|
ios: { path: "ios/App" }
|
|
14
46
|
});
|
|
@@ -26,7 +58,7 @@ class CapacitorApp {
|
|
|
26
58
|
await this.project.commit();
|
|
27
59
|
}
|
|
28
60
|
async releaseIos() {
|
|
29
|
-
const isAdded =
|
|
61
|
+
const isAdded = import_fs.default.existsSync(`${this.app.cwdPath}/ios/App/Podfile`);
|
|
30
62
|
if (!isAdded) {
|
|
31
63
|
await this.app.spawn("npx cap add ios");
|
|
32
64
|
await this.app.spawn("npx @capacitor/assets generate");
|
|
@@ -35,7 +67,7 @@ class CapacitorApp {
|
|
|
35
67
|
await this.app.spawn("cross-env", ["APP_OPERATION_MODE=release", "npx", "cap", "sync", "ios"]);
|
|
36
68
|
}
|
|
37
69
|
async releaseAndroid() {
|
|
38
|
-
const isAdded =
|
|
70
|
+
const isAdded = import_fs.default.existsSync(`${this.app.cwdPath}/android/app/build.gradle`);
|
|
39
71
|
if (!isAdded) {
|
|
40
72
|
await this.app.spawn("npx cap add android");
|
|
41
73
|
await this.app.spawn("npx @capacitor/assets generate");
|
|
@@ -67,7 +99,7 @@ class CapacitorApp {
|
|
|
67
99
|
}
|
|
68
100
|
async #setPermissionInIos(permissions) {
|
|
69
101
|
const updateNs = Object.fromEntries(
|
|
70
|
-
Object.entries(permissions).map(([key, value]) => [`NS${capitalize(key)}`, value])
|
|
102
|
+
Object.entries(permissions).map(([key, value]) => [`NS${(0, import_common.capitalize)(key)}`, value])
|
|
71
103
|
);
|
|
72
104
|
await Promise.all([
|
|
73
105
|
this.project.ios.updateInfoPlist(this.iosTargetName, "Debug", updateNs),
|
|
@@ -119,6 +151,7 @@ class CapacitorApp {
|
|
|
119
151
|
return this.#getPermissionsInAndroid().includes(permission);
|
|
120
152
|
}
|
|
121
153
|
}
|
|
122
|
-
export
|
|
154
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
155
|
+
0 && (module.exports = {
|
|
123
156
|
CapacitorApp
|
|
124
|
-
};
|
|
157
|
+
});
|