@polka-codes/cli 0.5.3 → 0.5.4
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/dist/index.js +74 -4
- package/package.json +1 -1
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.5.
|
|
24632
|
+
var version = "0.5.4";
|
|
24633
24633
|
|
|
24634
24634
|
// ../../node_modules/@anthropic-ai/sdk/version.mjs
|
|
24635
24635
|
var VERSION = "0.36.2";
|
|
@@ -46803,8 +46803,77 @@ ${result.response}`);
|
|
|
46803
46803
|
}
|
|
46804
46804
|
});
|
|
46805
46805
|
|
|
46806
|
+
// src/commands/create.ts
|
|
46807
|
+
import { existsSync as existsSync2 } from "node:fs";
|
|
46808
|
+
import { mkdir as mkdir2, stat } from "node:fs/promises";
|
|
46809
|
+
import { join as join4 } from "node:path";
|
|
46810
|
+
var askForPath = async (projectName) => {
|
|
46811
|
+
let targetPath = join4(process.cwd(), projectName);
|
|
46812
|
+
while (true) {
|
|
46813
|
+
const confirmPath = await esm_default2({
|
|
46814
|
+
message: `Do you want to create project at ${targetPath}?`,
|
|
46815
|
+
default: true
|
|
46816
|
+
});
|
|
46817
|
+
if (confirmPath) {
|
|
46818
|
+
if (existsSync2(targetPath)) {
|
|
46819
|
+
const targetStat = await stat(targetPath);
|
|
46820
|
+
if (targetStat.isDirectory()) {
|
|
46821
|
+
const confirmPath2 = await esm_default2({
|
|
46822
|
+
message: `Directory ${targetPath} already exists. Do you want to overwrite it?`,
|
|
46823
|
+
default: true
|
|
46824
|
+
});
|
|
46825
|
+
if (!confirmPath2) {
|
|
46826
|
+
return targetPath;
|
|
46827
|
+
}
|
|
46828
|
+
} else {
|
|
46829
|
+
console.error("Target path is not a directory");
|
|
46830
|
+
}
|
|
46831
|
+
} else {
|
|
46832
|
+
return targetPath;
|
|
46833
|
+
}
|
|
46834
|
+
}
|
|
46835
|
+
const inputPath = await esm_default3({ message: "Please provide a new path:", default: targetPath });
|
|
46836
|
+
targetPath = inputPath.trim();
|
|
46837
|
+
}
|
|
46838
|
+
};
|
|
46839
|
+
var createCommand2 = new Command("create").description("Create a new project").argument("[name]", "Project name").action(async (name2, options, command) => {
|
|
46840
|
+
const cmdOptions = command.parent?.opts() ?? {};
|
|
46841
|
+
const { config, providerConfig, maxMessageCount, verbose, budget } = parseOptions(cmdOptions);
|
|
46842
|
+
let { provider: provider2, model, apiKey } = providerConfig.getConfigForAgent("architect") ?? {};
|
|
46843
|
+
if (!provider2) {
|
|
46844
|
+
const newConfig = await configPrompt({ provider: provider2, model, apiKey });
|
|
46845
|
+
provider2 = newConfig.provider;
|
|
46846
|
+
model = newConfig.model;
|
|
46847
|
+
apiKey = newConfig.apiKey;
|
|
46848
|
+
}
|
|
46849
|
+
let projectName = name2;
|
|
46850
|
+
if (!projectName) {
|
|
46851
|
+
const inputName = await esm_default3({ message: "What would you like to name your project?" });
|
|
46852
|
+
projectName = inputName.trim();
|
|
46853
|
+
}
|
|
46854
|
+
const targetPath = await askForPath(projectName);
|
|
46855
|
+
try {
|
|
46856
|
+
await mkdir2(targetPath, { recursive: true });
|
|
46857
|
+
} catch (error) {
|
|
46858
|
+
console.error(`Failed to create directory: ${targetPath}`, error);
|
|
46859
|
+
process.exit(1);
|
|
46860
|
+
}
|
|
46861
|
+
process.chdir(targetPath);
|
|
46862
|
+
const runner = new Runner({
|
|
46863
|
+
providerConfig: new ApiProviderConfig({ defaultProvider: provider2, defaultModel: model, providers: { [provider2]: { apiKey } } }),
|
|
46864
|
+
config: {},
|
|
46865
|
+
maxMessageCount,
|
|
46866
|
+
budget,
|
|
46867
|
+
interactive: true,
|
|
46868
|
+
eventCallback: printEvent(verbose),
|
|
46869
|
+
enableCache: true,
|
|
46870
|
+
availableAgents: [architectAgentInfo, coderAgentInfo]
|
|
46871
|
+
});
|
|
46872
|
+
await createNewProject(runner.multiAgent, projectName);
|
|
46873
|
+
});
|
|
46874
|
+
|
|
46806
46875
|
// src/commands/init.ts
|
|
46807
|
-
import { existsSync as
|
|
46876
|
+
import { existsSync as existsSync3, mkdirSync, readFileSync as readFileSync2, writeFileSync } from "node:fs";
|
|
46808
46877
|
import { dirname as dirname2 } from "node:path";
|
|
46809
46878
|
var import_lodash3 = __toESM(require_lodash(), 1);
|
|
46810
46879
|
var initCommand = new Command("init").description("Initialize polkacodes configuration").option("-g, --global", "Use global config");
|
|
@@ -46814,7 +46883,7 @@ initCommand.action(async (options, command) => {
|
|
|
46814
46883
|
let gloabl = options.global;
|
|
46815
46884
|
let configPath = gloabl ? globalConfigPath : localConfigFileName;
|
|
46816
46885
|
try {
|
|
46817
|
-
if (
|
|
46886
|
+
if (existsSync3(configPath)) {
|
|
46818
46887
|
const proceed = await esm_default2({
|
|
46819
46888
|
message: `Found existing config at ${configPath}. Do you want to proceed? This will overwrite the existing config.`,
|
|
46820
46889
|
default: false
|
|
@@ -46895,7 +46964,7 @@ initCommand.action(async (options, command) => {
|
|
|
46895
46964
|
}
|
|
46896
46965
|
case 3: {
|
|
46897
46966
|
let envFileContent;
|
|
46898
|
-
if (
|
|
46967
|
+
if (existsSync3(".env")) {
|
|
46899
46968
|
envFileContent = readFileSync2(".env", "utf8");
|
|
46900
46969
|
envFileContent += `
|
|
46901
46970
|
${newConfig.provider.toUpperCase()}_API_KEY=${newConfig.apiKey}`;
|
|
@@ -47102,6 +47171,7 @@ program2.command("chat").description("Start an interactive chat session").action
|
|
|
47102
47171
|
program2.addCommand(initCommand);
|
|
47103
47172
|
program2.addCommand(commitCommand);
|
|
47104
47173
|
program2.addCommand(prCommand);
|
|
47174
|
+
program2.addCommand(createCommand2);
|
|
47105
47175
|
addSharedOptions(program2);
|
|
47106
47176
|
program2.parse();
|
|
47107
47177
|
process.on("uncaughtException", (error) => {
|