kyawthiha-nextjs-agent-cli 1.0.0
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/README.md +188 -0
- package/dist/agent/agent.js +340 -0
- package/dist/agent/index.js +6 -0
- package/dist/agent/prompts/agent-prompt.js +527 -0
- package/dist/agent/summarizer.js +97 -0
- package/dist/agent/tools/ast-tools.js +601 -0
- package/dist/agent/tools/code-tools.js +1059 -0
- package/dist/agent/tools/file-tools.js +199 -0
- package/dist/agent/tools/index.js +25 -0
- package/dist/agent/tools/search-tools.js +404 -0
- package/dist/agent/tools/shell-tools.js +334 -0
- package/dist/agent/types.js +4 -0
- package/dist/cli/commands/config.js +61 -0
- package/dist/cli/commands/start.js +236 -0
- package/dist/cli/index.js +12 -0
- package/dist/utils/cred-store.js +70 -0
- package/dist/utils/logger.js +9 -0
- package/package.json +52 -0
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import fs from 'fs/promises';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import os from 'os';
|
|
4
|
+
const CONFIG_DIR_NAME = '.nextjs-agent-cli';
|
|
5
|
+
const CRED_FILE_NAME = 'cred.json';
|
|
6
|
+
/**
|
|
7
|
+
* Get the path to the config directory
|
|
8
|
+
*/
|
|
9
|
+
export function getConfigDir() {
|
|
10
|
+
return path.join(os.homedir(), CONFIG_DIR_NAME);
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Get the path to the credentials file
|
|
14
|
+
*/
|
|
15
|
+
export function getCredPath() {
|
|
16
|
+
return path.join(getConfigDir(), CRED_FILE_NAME);
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Ensure the config directory exists
|
|
20
|
+
*/
|
|
21
|
+
async function ensureConfigDir() {
|
|
22
|
+
const configDir = getConfigDir();
|
|
23
|
+
try {
|
|
24
|
+
await fs.mkdir(configDir, { recursive: true });
|
|
25
|
+
}
|
|
26
|
+
catch (error) {
|
|
27
|
+
if (error.code !== 'EEXIST') {
|
|
28
|
+
throw error;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Load credentials from the store
|
|
34
|
+
*/
|
|
35
|
+
export async function loadCredentials() {
|
|
36
|
+
try {
|
|
37
|
+
const credPath = getCredPath();
|
|
38
|
+
const content = await fs.readFile(credPath, 'utf-8');
|
|
39
|
+
return JSON.parse(content);
|
|
40
|
+
}
|
|
41
|
+
catch (error) {
|
|
42
|
+
if (error.code === 'ENOENT') {
|
|
43
|
+
return {};
|
|
44
|
+
}
|
|
45
|
+
throw error;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Save credentials to the store
|
|
50
|
+
*/
|
|
51
|
+
export async function saveCredentials(creds) {
|
|
52
|
+
await ensureConfigDir();
|
|
53
|
+
const credPath = getCredPath();
|
|
54
|
+
await fs.writeFile(credPath, JSON.stringify(creds, null, 2), 'utf-8');
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Get the Gemini API key from the credential store
|
|
58
|
+
*/
|
|
59
|
+
export async function getGeminiApiKey() {
|
|
60
|
+
const creds = await loadCredentials();
|
|
61
|
+
return creds.geminiApiKey;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Set the Gemini API key in the credential store
|
|
65
|
+
*/
|
|
66
|
+
export async function setGeminiApiKey(key) {
|
|
67
|
+
const creds = await loadCredentials();
|
|
68
|
+
creds.geminiApiKey = key;
|
|
69
|
+
await saveCredentials(creds);
|
|
70
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import chalk from 'chalk';
|
|
2
|
+
export const logger = {
|
|
3
|
+
info: (msg) => console.log(chalk.blue('ℹ'), msg),
|
|
4
|
+
success: (msg) => console.log(chalk.green('✔'), msg),
|
|
5
|
+
warn: (msg) => console.log(chalk.yellow('⚠'), msg),
|
|
6
|
+
error: (msg) => console.log(chalk.red('✖'), msg),
|
|
7
|
+
step: (msg) => console.log(chalk.cyan('➜'), msg),
|
|
8
|
+
dim: (msg) => console.log(chalk.dim(msg)),
|
|
9
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "kyawthiha-nextjs-agent-cli",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Next.js Fullstack Agent CLI",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"nextjs",
|
|
7
|
+
"agent",
|
|
8
|
+
"ai",
|
|
9
|
+
"cli",
|
|
10
|
+
"fullstack"
|
|
11
|
+
],
|
|
12
|
+
"type": "module",
|
|
13
|
+
"main": "dist/cli/index.js",
|
|
14
|
+
"bin": {
|
|
15
|
+
"next-agent": "dist/cli/index.js"
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"dist",
|
|
19
|
+
"README.md"
|
|
20
|
+
],
|
|
21
|
+
"scripts": {
|
|
22
|
+
"build": "npx rimraf dist && tsc",
|
|
23
|
+
"dev": "npx rimraf dist && tsc && node dist/cli/index.js start",
|
|
24
|
+
"start": "node dist/cli/index.js start",
|
|
25
|
+
"prepublishOnly": "npm run build"
|
|
26
|
+
},
|
|
27
|
+
"engines": {
|
|
28
|
+
"node": ">=18.0.0"
|
|
29
|
+
},
|
|
30
|
+
"author": "",
|
|
31
|
+
"license": "MIT",
|
|
32
|
+
"repository": {
|
|
33
|
+
"type": "git",
|
|
34
|
+
"url": ""
|
|
35
|
+
},
|
|
36
|
+
"dependencies": {
|
|
37
|
+
"@google/genai": "^1.34.0",
|
|
38
|
+
"chalk": "^5.0.0",
|
|
39
|
+
"commander": "^12.0.0",
|
|
40
|
+
"dotenv": "^16.0.0",
|
|
41
|
+
"inquirer": "^13.2.1",
|
|
42
|
+
"ora": "^8.2.0",
|
|
43
|
+
"zod": "^4.3.5",
|
|
44
|
+
"zod-to-json-schema": "^3.25.1"
|
|
45
|
+
},
|
|
46
|
+
"devDependencies": {
|
|
47
|
+
"@types/node": "^20.0.0",
|
|
48
|
+
"tsx": "^4.0.0",
|
|
49
|
+
"typescript": "^5.0.0"
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|