@polka-codes/cli 0.5.4 → 0.6.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 +6 -6
- package/dist/index.js +31 -28
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -32,13 +32,13 @@ npx @polka-codes/cli
|
|
|
32
32
|
polka-codes
|
|
33
33
|
|
|
34
34
|
# Run specific task
|
|
35
|
-
|
|
35
|
+
pokla task "improve readme"
|
|
36
36
|
|
|
37
37
|
# Create config file
|
|
38
|
-
|
|
38
|
+
pokla config
|
|
39
39
|
|
|
40
40
|
# Generate commit message
|
|
41
|
-
|
|
41
|
+
pokla commit
|
|
42
42
|
```
|
|
43
43
|
|
|
44
44
|
### Commit Command
|
|
@@ -47,10 +47,10 @@ The `commit` subcommand helps generate meaningful commit messages based on your
|
|
|
47
47
|
|
|
48
48
|
```bash
|
|
49
49
|
# Generate commit message for staged changes
|
|
50
|
-
|
|
50
|
+
pokla commit
|
|
51
51
|
|
|
52
52
|
# Generate commit message with specific context
|
|
53
|
-
|
|
53
|
+
pokla commit "closes issue #123"
|
|
54
54
|
|
|
55
55
|
```
|
|
56
56
|
|
|
@@ -59,7 +59,7 @@ polka-codes commit "closes issue #123"
|
|
|
59
59
|
Create a GitHub pull request with AI-generated details:
|
|
60
60
|
|
|
61
61
|
```bash
|
|
62
|
-
|
|
62
|
+
pokla pr "optional message. e.g. closes #123"
|
|
63
63
|
```
|
|
64
64
|
|
|
65
65
|
### Configuration
|
package/dist/index.js
CHANGED
|
@@ -24629,7 +24629,7 @@ var {
|
|
|
24629
24629
|
Help
|
|
24630
24630
|
} = import__.default;
|
|
24631
24631
|
// package.json
|
|
24632
|
-
var version = "0.
|
|
24632
|
+
var version = "0.6.0";
|
|
24633
24633
|
|
|
24634
24634
|
// ../../node_modules/@anthropic-ai/sdk/version.mjs
|
|
24635
24635
|
var VERSION = "0.36.2";
|
|
@@ -35150,6 +35150,9 @@ class MultiAgent {
|
|
|
35150
35150
|
const exitReason = await this.#agents[this.#agents.length - 1].continueTask(userMessage);
|
|
35151
35151
|
return await this.#handleTaskResult(exitReason);
|
|
35152
35152
|
}
|
|
35153
|
+
get hasActiveAgent() {
|
|
35154
|
+
return this.#agents.length > 0;
|
|
35155
|
+
}
|
|
35153
35156
|
}
|
|
35154
35157
|
|
|
35155
35158
|
// ../core/src/Agent/index.ts
|
|
@@ -35180,7 +35183,7 @@ var prompt = `You are an AiTool designed to assist users in creating new project
|
|
|
35180
35183
|
- Based on the collected information, generate a .polkacodes.yml configuration file that includes:
|
|
35181
35184
|
- scripts section with common development commands (test, format, check, etc.)
|
|
35182
35185
|
- rules section reflecting project conventions and tools
|
|
35183
|
-
- excludeFiles section for sensitive
|
|
35186
|
+
- excludeFiles section for sensitive files only
|
|
35184
35187
|
- Example structure:
|
|
35185
35188
|
\`\`\`yaml
|
|
35186
35189
|
scripts:
|
|
@@ -35412,7 +35415,6 @@ var prompt4 = `You are an analyzer agent responsible for examining project files
|
|
|
35412
35415
|
- Code style tools and rules
|
|
35413
35416
|
- Project structure and conventions
|
|
35414
35417
|
- Common development workflows
|
|
35415
|
-
- .gitignore patterns and sensitive/generated files
|
|
35416
35418
|
|
|
35417
35419
|
2. Generate a YAML configuration that captures:
|
|
35418
35420
|
- scripts section based on package.json scripts and CI workflows. If applicable, generate following scripts:
|
|
@@ -35421,7 +35423,7 @@ var prompt4 = `You are an analyzer agent responsible for examining project files
|
|
|
35421
35423
|
- test: Run tests using a test runner tool
|
|
35422
35424
|
- include other relevant scripts based on project conventions, tools, and patterns
|
|
35423
35425
|
- rules section based on project conventions, tools, and patterns
|
|
35424
|
-
- excludeFiles section for
|
|
35426
|
+
- excludeFiles section for sensitive files
|
|
35425
35427
|
|
|
35426
35428
|
3. Use tool_attempt_completion to return the final configuration in this format:
|
|
35427
35429
|
|
|
@@ -35445,10 +35447,6 @@ excludeFiles:
|
|
|
35445
35447
|
- ".env"
|
|
35446
35448
|
- ".env.*"
|
|
35447
35449
|
- ".npmrc"
|
|
35448
|
-
# Generated files
|
|
35449
|
-
- "package-lock.json"
|
|
35450
|
-
- "yarn.lock"
|
|
35451
|
-
- "pnpm-lock.yaml"
|
|
35452
35450
|
</tool_parameter_result>
|
|
35453
35451
|
</tool_attempt_completion>
|
|
35454
35452
|
|
|
@@ -35476,7 +35474,7 @@ var generateProjectConfig_default = {
|
|
|
35476
35474
|
return "";
|
|
35477
35475
|
},
|
|
35478
35476
|
parseOutput: (output) => {
|
|
35479
|
-
return output
|
|
35477
|
+
return output;
|
|
35480
35478
|
},
|
|
35481
35479
|
agent: "analyzer"
|
|
35482
35480
|
};
|
|
@@ -41183,6 +41181,9 @@ ${fileList.join(`
|
|
|
41183
41181
|
async continueTask(message) {
|
|
41184
41182
|
return await this.multiAgent.continueTask(message);
|
|
41185
41183
|
}
|
|
41184
|
+
get hasActiveAgent() {
|
|
41185
|
+
return this.multiAgent.hasActiveAgent;
|
|
41186
|
+
}
|
|
41186
41187
|
get usage() {
|
|
41187
41188
|
return this.#usageMeter.usage;
|
|
41188
41189
|
}
|
|
@@ -45446,10 +45447,18 @@ var readConfig = (path4) => {
|
|
|
45446
45447
|
|
|
45447
45448
|
// src/options.ts
|
|
45448
45449
|
function addSharedOptions(command) {
|
|
45449
|
-
return command.option("-c --config <path>", "Path to config file").option("--api-provider <provider>", "API provider").option("--model <model>", "Model ID").option("--api-key <key>", "API key").option("--max-messages <iterations>", "Maximum number of messages to send. Default to 50", Number.parseInt, 50).option("--budget <budget>", "Budget for the AI service. Default to $1000", Number.parseFloat, 1000).option("-v --verbose", "Enable verbose output. Use -v for level 1, -vv for level 2", (value, prev) => prev + 1, 0);
|
|
45450
|
-
}
|
|
45451
|
-
function parseOptions(options,
|
|
45452
|
-
|
|
45450
|
+
return command.option("-c --config <path>", "Path to config file").option("--api-provider <provider>", "API provider").option("--model <model>", "Model ID").option("--api-key <key>", "API key").option("--max-messages <iterations>", "Maximum number of messages to send. Default to 50", Number.parseInt, 50).option("--budget <budget>", "Budget for the AI service. Default to $1000", Number.parseFloat, 1000).option("-v --verbose", "Enable verbose output. Use -v for level 1, -vv for level 2", (value, prev) => prev + 1, 0).option("-d --base-dir <path>", "Base directory to run commands in");
|
|
45451
|
+
}
|
|
45452
|
+
function parseOptions(options, cwdArg, home = os2.homedir()) {
|
|
45453
|
+
let cwd = cwdArg;
|
|
45454
|
+
if (options.baseDir) {
|
|
45455
|
+
process.chdir(options.baseDir);
|
|
45456
|
+
cwd = options.baseDir;
|
|
45457
|
+
console.log("Changed working directory to", cwd);
|
|
45458
|
+
} else {
|
|
45459
|
+
cwd = process.cwd();
|
|
45460
|
+
}
|
|
45461
|
+
const config = loadConfig(options.config, cwd, home) ?? {};
|
|
45453
45462
|
const defaultProvider = options.apiProvider || process.env.POLKA_API_PROVIDER || config.defaultProvider;
|
|
45454
45463
|
const defaultModel = options.model || process.env.POLKA_MODEL || config.defaultModel;
|
|
45455
45464
|
if (defaultProvider && defaultModel) {
|
|
@@ -46100,16 +46109,14 @@ var runChat = async (opts, command) => {
|
|
|
46100
46109
|
eventCallback: printEvent(verbose),
|
|
46101
46110
|
enableCache: true
|
|
46102
46111
|
});
|
|
46103
|
-
let started = false;
|
|
46104
46112
|
const chat2 = new Chat3({
|
|
46105
46113
|
onMessage: async (message) => {
|
|
46106
46114
|
let exitReason;
|
|
46107
|
-
if (
|
|
46115
|
+
if (runner.hasActiveAgent) {
|
|
46108
46116
|
const reason = await runner.continueTask(message);
|
|
46109
46117
|
exitReason = reason;
|
|
46110
46118
|
} else {
|
|
46111
46119
|
const reason = await runner.startTask(message);
|
|
46112
|
-
started = true;
|
|
46113
46120
|
exitReason = reason;
|
|
46114
46121
|
}
|
|
46115
46122
|
switch (exitReason.type) {
|
|
@@ -46752,7 +46759,7 @@ var commitCommand = new Command("commit").description("Create a commit with AI-g
|
|
|
46752
46759
|
console.log("Provider:", provider2);
|
|
46753
46760
|
console.log("Model:", model);
|
|
46754
46761
|
if (!provider2) {
|
|
46755
|
-
console.error('Error: No provider specified. Please run "
|
|
46762
|
+
console.error('Error: No provider specified. Please run "pokla config" to configure your AI provider.');
|
|
46756
46763
|
process.exit(1);
|
|
46757
46764
|
}
|
|
46758
46765
|
const usage = new UsageMeter;
|
|
@@ -46822,7 +46829,7 @@ var askForPath = async (projectName) => {
|
|
|
46822
46829
|
message: `Directory ${targetPath} already exists. Do you want to overwrite it?`,
|
|
46823
46830
|
default: true
|
|
46824
46831
|
});
|
|
46825
|
-
if (
|
|
46832
|
+
if (confirmPath2) {
|
|
46826
46833
|
return targetPath;
|
|
46827
46834
|
}
|
|
46828
46835
|
} else {
|
|
@@ -46879,6 +46886,8 @@ var import_lodash3 = __toESM(require_lodash(), 1);
|
|
|
46879
46886
|
var initCommand = new Command("init").description("Initialize polkacodes configuration").option("-g, --global", "Use global config");
|
|
46880
46887
|
initCommand.action(async (options, command) => {
|
|
46881
46888
|
const cmdOptions = command.parent?.opts() ?? {};
|
|
46889
|
+
parseOptions(cmdOptions);
|
|
46890
|
+
cmdOptions.baseDir = undefined;
|
|
46882
46891
|
const globalConfigPath = getGlobalConfigPath();
|
|
46883
46892
|
let gloabl = options.global;
|
|
46884
46893
|
let configPath = gloabl ? globalConfigPath : localConfigFileName;
|
|
@@ -46923,7 +46932,7 @@ initCommand.action(async (options, command) => {
|
|
|
46923
46932
|
process.exit(1);
|
|
46924
46933
|
}
|
|
46925
46934
|
}
|
|
46926
|
-
const {
|
|
46935
|
+
const { providerConfig, verbose, maxMessageCount, budget } = parseOptions(cmdOptions);
|
|
46927
46936
|
let { provider: provider2, model, apiKey } = providerConfig.getConfigForCommand("init") ?? {};
|
|
46928
46937
|
let newConfig;
|
|
46929
46938
|
if (!provider2) {
|
|
@@ -46995,7 +47004,7 @@ ${newConfig.provider.toUpperCase()}_API_KEY=${newConfig.apiKey}`;
|
|
|
46995
47004
|
availableAgents: [analyzerAgentInfo]
|
|
46996
47005
|
});
|
|
46997
47006
|
console.log("Analyzing project files...");
|
|
46998
|
-
const
|
|
47007
|
+
const response = await generateProjectConfig(runner.multiAgent, undefined);
|
|
46999
47008
|
generatedConfig = response ? $parse(response) : {};
|
|
47000
47009
|
}
|
|
47001
47010
|
const finalConfig = {
|
|
@@ -47009,12 +47018,6 @@ ${newConfig.provider.toUpperCase()}_API_KEY=${newConfig.apiKey}`;
|
|
|
47009
47018
|
import_lodash3.set(finalConfig, ["providers", newConfig.provider, "apiKey"], newConfig.apiKey);
|
|
47010
47019
|
}
|
|
47011
47020
|
}
|
|
47012
|
-
if (!finalConfig.defaultProvider) {
|
|
47013
|
-
finalConfig.defaultProvider = provider2;
|
|
47014
|
-
}
|
|
47015
|
-
if (!finalConfig.defaultModel) {
|
|
47016
|
-
finalConfig.defaultModel = model;
|
|
47017
|
-
}
|
|
47018
47021
|
mkdirSync(dirname2(configPath), { recursive: true });
|
|
47019
47022
|
writeFileSync(configPath, $stringify(finalConfig));
|
|
47020
47023
|
console.log(`Configuration saved to ${configPath}`);
|
|
@@ -47034,7 +47037,7 @@ var prCommand = new Command("pr").description("Create a GitHub pull request").ar
|
|
|
47034
47037
|
console.log("Provider:", provider2);
|
|
47035
47038
|
console.log("Model:", model);
|
|
47036
47039
|
if (!provider2) {
|
|
47037
|
-
console.error('Error: No provider specified. Please run "
|
|
47040
|
+
console.error('Error: No provider specified. Please run "pokla config" to configure your AI provider.');
|
|
47038
47041
|
process.exit(1);
|
|
47039
47042
|
}
|
|
47040
47043
|
try {
|
|
@@ -47133,7 +47136,7 @@ async function runTask(taskArg, _options, command) {
|
|
|
47133
47136
|
if (stdinInput) {
|
|
47134
47137
|
task = stdinInput;
|
|
47135
47138
|
} else {
|
|
47136
|
-
runChat(
|
|
47139
|
+
runChat(command.opts());
|
|
47137
47140
|
return;
|
|
47138
47141
|
}
|
|
47139
47142
|
} catch (error) {
|
package/package.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@polka-codes/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"license": "AGPL-3.0",
|
|
5
|
+
"author": "github@polka.codes",
|
|
5
6
|
"type": "module",
|
|
6
7
|
"bin": {
|
|
7
8
|
"polka-codes": "cli.mjs"
|
|
@@ -17,7 +18,7 @@
|
|
|
17
18
|
},
|
|
18
19
|
"dependencies": {
|
|
19
20
|
"@inquirer/prompts": "^7.2.3",
|
|
20
|
-
"@polka-codes/core": "0.5.
|
|
21
|
+
"@polka-codes/core": "0.5.4",
|
|
21
22
|
"@vscode/ripgrep": "^1.15.10",
|
|
22
23
|
"chalk": "^5.4.1",
|
|
23
24
|
"commander": "^13.0.0",
|