@cosmicstack/mercury-agent 0.3.2 → 0.3.3
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 +37 -11
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -4667,6 +4667,14 @@ function appendToEnv(key, value) {
|
|
|
4667
4667
|
writeFileSync13(envPath, lines.join("\n") + "\n", "utf-8");
|
|
4668
4668
|
process.env[key] = value;
|
|
4669
4669
|
}
|
|
4670
|
+
function parseGithubRepo(input) {
|
|
4671
|
+
const trimmed = input.trim().replace(/\/+$/, "");
|
|
4672
|
+
const urlMatch = trimmed.match(/github\.com\/([^/]+)\/([^/]+)/);
|
|
4673
|
+
if (urlMatch) return { owner: urlMatch[1], repo: urlMatch[2] };
|
|
4674
|
+
const shortMatch = trimmed.match(/^([^/\s]+)\/([^/\s]+)$/);
|
|
4675
|
+
if (shortMatch) return { owner: shortMatch[1], repo: shortMatch[2] };
|
|
4676
|
+
return null;
|
|
4677
|
+
}
|
|
4670
4678
|
async function configure(existingConfig) {
|
|
4671
4679
|
const isReconfig = !!existingConfig;
|
|
4672
4680
|
const config = existingConfig ?? loadConfig();
|
|
@@ -4765,28 +4773,46 @@ async function configure(existingConfig) {
|
|
|
4765
4773
|
}
|
|
4766
4774
|
hr();
|
|
4767
4775
|
console.log("");
|
|
4768
|
-
console.log(chalk6.bold.white(" GitHub (optional)"));
|
|
4769
|
-
console.log(chalk6.dim(" Connect Mercury to GitHub
|
|
4776
|
+
console.log(chalk6.bold.white(" GitHub Integration (optional)"));
|
|
4777
|
+
console.log(chalk6.dim(" Connect Mercury to GitHub so it can create PRs, manage issues,"));
|
|
4778
|
+
console.log(chalk6.dim(" review code, and co-author commits on your behalf."));
|
|
4770
4779
|
console.log(chalk6.dim(" Leave empty to skip. You can add it later with mercury doctor."));
|
|
4771
4780
|
console.log("");
|
|
4772
4781
|
const ghUserCurrent = isReconfig && config.github.username ? ` [${config.github.username}]` : "";
|
|
4773
|
-
const ghUsername = await ask(chalk6.white(` GitHub username${ghUserCurrent}: `));
|
|
4782
|
+
const ghUsername = await ask(chalk6.white(` 1. Your GitHub username${ghUserCurrent}: `));
|
|
4774
4783
|
if (ghUsername) config.github.username = ghUsername;
|
|
4775
4784
|
const ghEmailCurrent = isReconfig && config.github.email ? ` [${config.github.email}]` : "";
|
|
4776
|
-
|
|
4785
|
+
console.log(chalk6.dim(" This appears in the Co-authored-by trailer on commits."));
|
|
4786
|
+
const ghEmail = await ask(chalk6.white(` 2. GitHub email (for co-author)${ghEmailCurrent}: `));
|
|
4777
4787
|
if (ghEmail) config.github.email = ghEmail;
|
|
4788
|
+
console.log("");
|
|
4789
|
+
console.log(chalk6.dim(" You need a Personal Access Token (PAT) with repo access."));
|
|
4790
|
+
console.log(chalk6.dim(" Fine-grained (recommended): github.com/settings/personal-access-tokens/new"));
|
|
4791
|
+
console.log(chalk6.dim(" \u2192 Permissions: Contents (R/W), Pull requests (R/W), Issues (R/W)"));
|
|
4792
|
+
console.log(chalk6.dim(" Classic: github.com/settings/tokens/new"));
|
|
4793
|
+
console.log(chalk6.dim(" \u2192 Scope: repo (full control)"));
|
|
4778
4794
|
const ghTokenCurrent = process.env.GITHUB_TOKEN ? ` [${maskKey(process.env.GITHUB_TOKEN)}]` : "";
|
|
4779
|
-
const ghToken = await ask(chalk6.white(` GitHub PAT
|
|
4795
|
+
const ghToken = await ask(chalk6.white(` 3. GitHub PAT${ghTokenCurrent}: `));
|
|
4780
4796
|
if (ghToken) {
|
|
4781
4797
|
appendToEnv("GITHUB_TOKEN", ghToken);
|
|
4782
4798
|
}
|
|
4783
4799
|
if (config.github.username || process.env.GITHUB_TOKEN) {
|
|
4784
|
-
|
|
4785
|
-
|
|
4786
|
-
|
|
4787
|
-
|
|
4788
|
-
|
|
4789
|
-
|
|
4800
|
+
console.log("");
|
|
4801
|
+
console.log(chalk6.dim(' Set a default repo so you can say "create an issue" without'));
|
|
4802
|
+
console.log(chalk6.dim(" specifying the repo every time. Enter owner/name or a full URL."));
|
|
4803
|
+
console.log(chalk6.dim(" Example: hotheadhacker/mercury-agent"));
|
|
4804
|
+
console.log(chalk6.dim(" Example: https://github.com/hotheadhacker/mercury-agent"));
|
|
4805
|
+
const ghOwnerCurrent = isReconfig && config.github.defaultOwner ? ` [${config.github.defaultOwner}/${config.github.defaultRepo}]` : "";
|
|
4806
|
+
const ghRepoInput = await ask(chalk6.white(` 4. Default repo${ghOwnerCurrent}: `));
|
|
4807
|
+
if (ghRepoInput) {
|
|
4808
|
+
const parsed = parseGithubRepo(ghRepoInput);
|
|
4809
|
+
if (parsed) {
|
|
4810
|
+
config.github.defaultOwner = parsed.owner;
|
|
4811
|
+
config.github.defaultRepo = parsed.repo;
|
|
4812
|
+
} else {
|
|
4813
|
+
console.log(chalk6.yellow(" Could not parse repo. Use format: owner/repo or a GitHub URL."));
|
|
4814
|
+
}
|
|
4815
|
+
}
|
|
4790
4816
|
}
|
|
4791
4817
|
hr();
|
|
4792
4818
|
console.log("");
|