@react-grab/cli 0.1.15 → 0.1.16
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/cli.cjs +69 -112
- package/dist/cli.js +49 -112
- package/package.json +4 -2
package/dist/cli.cjs
CHANGED
|
@@ -11,10 +11,30 @@ var ni = require('@antfu/ni');
|
|
|
11
11
|
var ignore = require('ignore');
|
|
12
12
|
var os = require('os');
|
|
13
13
|
var process2 = require('process');
|
|
14
|
+
var jsonc = require('jsonc-parser');
|
|
15
|
+
var TOML = require('smol-toml');
|
|
14
16
|
var ora = require('ora');
|
|
15
17
|
|
|
16
18
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
17
19
|
|
|
20
|
+
function _interopNamespace(e) {
|
|
21
|
+
if (e && e.__esModule) return e;
|
|
22
|
+
var n = Object.create(null);
|
|
23
|
+
if (e) {
|
|
24
|
+
Object.keys(e).forEach(function (k) {
|
|
25
|
+
if (k !== 'default') {
|
|
26
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
27
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
28
|
+
enumerable: true,
|
|
29
|
+
get: function () { return e[k]; }
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
n.default = e;
|
|
35
|
+
return Object.freeze(n);
|
|
36
|
+
}
|
|
37
|
+
|
|
18
38
|
var pc__default = /*#__PURE__*/_interopDefault(pc);
|
|
19
39
|
var basePrompts__default = /*#__PURE__*/_interopDefault(basePrompts);
|
|
20
40
|
var fs__default = /*#__PURE__*/_interopDefault(fs);
|
|
@@ -22,17 +42,22 @@ var path__default = /*#__PURE__*/_interopDefault(path);
|
|
|
22
42
|
var ignore__default = /*#__PURE__*/_interopDefault(ignore);
|
|
23
43
|
var os__default = /*#__PURE__*/_interopDefault(os);
|
|
24
44
|
var process2__default = /*#__PURE__*/_interopDefault(process2);
|
|
45
|
+
var jsonc__namespace = /*#__PURE__*/_interopNamespace(jsonc);
|
|
46
|
+
var TOML__namespace = /*#__PURE__*/_interopNamespace(TOML);
|
|
25
47
|
var ora__default = /*#__PURE__*/_interopDefault(ora);
|
|
26
48
|
|
|
27
49
|
// src/utils/is-non-interactive.ts
|
|
28
|
-
var
|
|
50
|
+
var AGENT_ENVIRONMENT_VARIABLES = [
|
|
29
51
|
"CI",
|
|
30
52
|
"CLAUDECODE",
|
|
53
|
+
"CURSOR_AGENT",
|
|
54
|
+
"CODEX_CI",
|
|
55
|
+
"OPENCODE",
|
|
56
|
+
"AMP_HOME",
|
|
31
57
|
"AMI"
|
|
32
58
|
];
|
|
33
|
-
var
|
|
34
|
-
|
|
35
|
-
) || !process.stdin.isTTY;
|
|
59
|
+
var isEnvironmentVariableSet = (variable) => Boolean(process.env[variable]);
|
|
60
|
+
var detectNonInteractive = (yesFlag) => yesFlag || AGENT_ENVIRONMENT_VARIABLES.some(isEnvironmentVariableSet) || !process.stdin.isTTY;
|
|
36
61
|
var highlighter = {
|
|
37
62
|
error: pc__default.default.red,
|
|
38
63
|
warn: pc__default.default.yellow,
|
|
@@ -390,6 +415,8 @@ var AGENT_PACKAGES = [
|
|
|
390
415
|
"@react-grab/gemini",
|
|
391
416
|
"@react-grab/amp",
|
|
392
417
|
"@react-grab/ami",
|
|
418
|
+
"@react-grab/droid",
|
|
419
|
+
"@react-grab/copilot",
|
|
393
420
|
"@react-grab/mcp"
|
|
394
421
|
];
|
|
395
422
|
var detectUnsupportedFramework = (projectRoot) => {
|
|
@@ -717,113 +744,39 @@ var ensureDirectory = (filePath) => {
|
|
|
717
744
|
fs__default.default.mkdirSync(directory, { recursive: true });
|
|
718
745
|
}
|
|
719
746
|
};
|
|
720
|
-
var
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
747
|
+
var JSONC_FORMAT_OPTIONS = {
|
|
748
|
+
tabSize: 2,
|
|
749
|
+
insertSpaces: true
|
|
750
|
+
};
|
|
751
|
+
var upsertIntoJsonc = (filePath, content, configKey, serverName, serverConfig) => {
|
|
752
|
+
const edits = jsonc__namespace.modify(
|
|
753
|
+
content,
|
|
754
|
+
[configKey, serverName],
|
|
755
|
+
serverConfig,
|
|
756
|
+
{ formattingOptions: JSONC_FORMAT_OPTIONS }
|
|
726
757
|
);
|
|
727
|
-
|
|
728
|
-
const keyPattern = new RegExp(`"${escapedConfigKey}"\\s*:\\s*\\{`);
|
|
729
|
-
const keyMatch = keyPattern.exec(content);
|
|
730
|
-
if (keyMatch) {
|
|
731
|
-
const insertPosition = keyMatch.index + keyMatch[0].length;
|
|
732
|
-
const entry = `
|
|
733
|
-
"${serverName}": ${serverJson},`;
|
|
734
|
-
fs__default.default.writeFileSync(
|
|
735
|
-
filePath,
|
|
736
|
-
content.slice(0, insertPosition) + entry + content.slice(insertPosition)
|
|
737
|
-
);
|
|
738
|
-
return;
|
|
739
|
-
}
|
|
740
|
-
const lastBrace = content.lastIndexOf("}");
|
|
741
|
-
if (lastBrace === -1) return;
|
|
742
|
-
const beforeBrace = content.slice(0, lastBrace).trimEnd();
|
|
743
|
-
const withoutComments = beforeBrace.replace(/\/\/.*$/, "").trimEnd();
|
|
744
|
-
const lastChar = withoutComments[withoutComments.length - 1];
|
|
745
|
-
const needsComma = lastChar !== void 0 && lastChar !== "{" && lastChar !== ",";
|
|
746
|
-
const section = `${needsComma ? "," : ""}
|
|
747
|
-
"${configKey}": {
|
|
748
|
-
"${serverName}": ${serverJson}
|
|
749
|
-
}`;
|
|
750
|
-
fs__default.default.writeFileSync(filePath, beforeBrace + section + "\n}\n");
|
|
758
|
+
fs__default.default.writeFileSync(filePath, jsonc__namespace.applyEdits(content, edits));
|
|
751
759
|
};
|
|
752
760
|
var installJsonClient = (client) => {
|
|
753
761
|
ensureDirectory(client.configPath);
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
try {
|
|
763
|
-
const config = JSON.parse(content);
|
|
764
|
-
const servers = config[client.configKey] ?? {};
|
|
765
|
-
servers[SERVER_NAME] = client.serverConfig;
|
|
766
|
-
config[client.configKey] = servers;
|
|
767
|
-
fs__default.default.writeFileSync(client.configPath, JSON.stringify(config, null, 2) + "\n");
|
|
768
|
-
} catch {
|
|
769
|
-
insertIntoJsonc(
|
|
770
|
-
client.configPath,
|
|
771
|
-
content,
|
|
772
|
-
client.configKey,
|
|
773
|
-
SERVER_NAME,
|
|
774
|
-
client.serverConfig
|
|
775
|
-
);
|
|
776
|
-
}
|
|
777
|
-
};
|
|
778
|
-
var buildTomlSection = (configKey, serverConfig) => {
|
|
779
|
-
const lines = [`[${configKey}.${SERVER_NAME}]`];
|
|
780
|
-
for (const [key, value] of Object.entries(serverConfig)) {
|
|
781
|
-
if (typeof value === "string") {
|
|
782
|
-
lines.push(`${key} = "${value}"`);
|
|
783
|
-
} else if (Array.isArray(value)) {
|
|
784
|
-
const items = value.map((item) => `"${item}"`).join(", ");
|
|
785
|
-
lines.push(`${key} = [${items}]`);
|
|
786
|
-
}
|
|
787
|
-
}
|
|
788
|
-
return lines.join("\n");
|
|
762
|
+
const content = fs__default.default.existsSync(client.configPath) ? fs__default.default.readFileSync(client.configPath, "utf8") : "{}";
|
|
763
|
+
upsertIntoJsonc(
|
|
764
|
+
client.configPath,
|
|
765
|
+
content,
|
|
766
|
+
client.configKey,
|
|
767
|
+
SERVER_NAME,
|
|
768
|
+
client.serverConfig
|
|
769
|
+
);
|
|
789
770
|
};
|
|
790
771
|
var installTomlClient = (client) => {
|
|
791
772
|
ensureDirectory(client.configPath);
|
|
792
|
-
const
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
if (!content.includes(sectionHeader)) {
|
|
800
|
-
fs__default.default.writeFileSync(
|
|
801
|
-
client.configPath,
|
|
802
|
-
content.trimEnd() + "\n\n" + newSection + "\n"
|
|
803
|
-
);
|
|
804
|
-
return;
|
|
805
|
-
}
|
|
806
|
-
const lines = content.split("\n");
|
|
807
|
-
const resultLines = [];
|
|
808
|
-
let isInsideOurSection = false;
|
|
809
|
-
let didInsertReplacement = false;
|
|
810
|
-
for (const line of lines) {
|
|
811
|
-
if (line.trim() === sectionHeader) {
|
|
812
|
-
isInsideOurSection = true;
|
|
813
|
-
if (!didInsertReplacement) {
|
|
814
|
-
resultLines.push(newSection);
|
|
815
|
-
didInsertReplacement = true;
|
|
816
|
-
}
|
|
817
|
-
continue;
|
|
818
|
-
}
|
|
819
|
-
if (isInsideOurSection && line.startsWith("[")) {
|
|
820
|
-
isInsideOurSection = false;
|
|
821
|
-
}
|
|
822
|
-
if (!isInsideOurSection) {
|
|
823
|
-
resultLines.push(line);
|
|
824
|
-
}
|
|
825
|
-
}
|
|
826
|
-
fs__default.default.writeFileSync(client.configPath, resultLines.join("\n"));
|
|
773
|
+
const existingConfig = fs__default.default.existsSync(
|
|
774
|
+
client.configPath
|
|
775
|
+
) ? TOML__namespace.parse(fs__default.default.readFileSync(client.configPath, "utf8")) : {};
|
|
776
|
+
const serverSection = existingConfig[client.configKey] ?? {};
|
|
777
|
+
serverSection[SERVER_NAME] = client.serverConfig;
|
|
778
|
+
existingConfig[client.configKey] = serverSection;
|
|
779
|
+
fs__default.default.writeFileSync(client.configPath, TOML__namespace.stringify(existingConfig));
|
|
827
780
|
};
|
|
828
781
|
var getMcpClientNames = () => getClients().map((client) => client.name);
|
|
829
782
|
var installMcpServers = (selectedClients) => {
|
|
@@ -925,7 +878,8 @@ var AGENTS = [
|
|
|
925
878
|
"gemini",
|
|
926
879
|
"amp",
|
|
927
880
|
"ami",
|
|
928
|
-
"droid"
|
|
881
|
+
"droid",
|
|
882
|
+
"copilot"
|
|
929
883
|
];
|
|
930
884
|
var AGENT_NAMES = {
|
|
931
885
|
"claude-code": "Claude Code",
|
|
@@ -935,7 +889,8 @@ var AGENT_NAMES = {
|
|
|
935
889
|
gemini: "Gemini",
|
|
936
890
|
amp: "Amp",
|
|
937
891
|
ami: "Ami",
|
|
938
|
-
droid: "Droid"
|
|
892
|
+
droid: "Droid",
|
|
893
|
+
copilot: "Copilot"
|
|
939
894
|
};
|
|
940
895
|
var getAgentDisplayName = (agent) => {
|
|
941
896
|
if (agent === "mcp") return "MCP";
|
|
@@ -1670,7 +1625,9 @@ var AGENT_PACKAGES2 = {
|
|
|
1670
1625
|
opencode: "@react-grab/opencode@latest",
|
|
1671
1626
|
codex: "@react-grab/codex@latest",
|
|
1672
1627
|
gemini: "@react-grab/gemini@latest",
|
|
1673
|
-
amp: "@react-grab/amp@latest"
|
|
1628
|
+
amp: "@react-grab/amp@latest",
|
|
1629
|
+
droid: "@react-grab/droid@latest",
|
|
1630
|
+
copilot: "@react-grab/copilot@latest"
|
|
1674
1631
|
};
|
|
1675
1632
|
var getAgentPrefix = (agent, packageManager) => {
|
|
1676
1633
|
const agentPackage = AGENT_PACKAGES2[agent];
|
|
@@ -2266,7 +2223,7 @@ var previewCdnTransform = (projectRoot, framework, nextRouterType, targetCdnDoma
|
|
|
2266
2223
|
};
|
|
2267
2224
|
|
|
2268
2225
|
// src/commands/add.ts
|
|
2269
|
-
var VERSION = "0.1.
|
|
2226
|
+
var VERSION = "0.1.16";
|
|
2270
2227
|
var formatInstalledAgentNames = (agents) => agents.map((agent) => AGENT_NAMES[agent] || agent).join(", ");
|
|
2271
2228
|
var add = new commander.Command().name("add").alias("install").description("connect React Grab to your agent").argument("[agent]", `agent to connect (${AGENTS.join(", ")}, mcp)`).option("-y, --yes", "skip confirmation prompts", false).option(
|
|
2272
2229
|
"-c, --cwd <cwd>",
|
|
@@ -2627,7 +2584,7 @@ var MAX_KEY_HOLD_DURATION_MS = 2e3;
|
|
|
2627
2584
|
var MAX_CONTEXT_LINES = 50;
|
|
2628
2585
|
|
|
2629
2586
|
// src/commands/configure.ts
|
|
2630
|
-
var VERSION2 = "0.1.
|
|
2587
|
+
var VERSION2 = "0.1.16";
|
|
2631
2588
|
var isMac = process.platform === "darwin";
|
|
2632
2589
|
var META_LABEL = isMac ? "Cmd" : "Win";
|
|
2633
2590
|
var ALT_LABEL = isMac ? "Option" : "Alt";
|
|
@@ -3183,7 +3140,7 @@ var uninstallPackagesWithFeedback = (packages, packageManager, projectRoot) => {
|
|
|
3183
3140
|
};
|
|
3184
3141
|
|
|
3185
3142
|
// src/commands/init.ts
|
|
3186
|
-
var VERSION3 = "0.1.
|
|
3143
|
+
var VERSION3 = "0.1.16";
|
|
3187
3144
|
var REPORT_URL = "https://react-grab.com/api/report-cli";
|
|
3188
3145
|
var DOCS_URL = "https://github.com/aidenybai/react-grab";
|
|
3189
3146
|
var reportToCli = (type, config, error) => {
|
|
@@ -4041,7 +3998,7 @@ var init = new commander.Command().name("init").description("initialize React Gr
|
|
|
4041
3998
|
reportToCli("error", void 0, error);
|
|
4042
3999
|
}
|
|
4043
4000
|
});
|
|
4044
|
-
var VERSION4 = "0.1.
|
|
4001
|
+
var VERSION4 = "0.1.16";
|
|
4045
4002
|
var remove = new commander.Command().name("remove").description("disconnect React Grab from your agent").argument("[agent]", `agent to disconnect (${AGENTS.join(", ")}, mcp)`).option("-y, --yes", "skip confirmation prompts", false).option(
|
|
4046
4003
|
"-c, --cwd <cwd>",
|
|
4047
4004
|
"working directory (defaults to current directory)",
|
|
@@ -4217,7 +4174,7 @@ var remove = new commander.Command().name("remove").description("disconnect Reac
|
|
|
4217
4174
|
});
|
|
4218
4175
|
|
|
4219
4176
|
// src/cli.ts
|
|
4220
|
-
var VERSION5 = "0.1.
|
|
4177
|
+
var VERSION5 = "0.1.16";
|
|
4221
4178
|
var VERSION_API_URL = "https://www.react-grab.com/api/version";
|
|
4222
4179
|
process.on("SIGINT", () => process.exit(0));
|
|
4223
4180
|
process.on("SIGTERM", () => process.exit(0));
|
package/dist/cli.js
CHANGED
|
@@ -9,17 +9,22 @@ import { detect } from '@antfu/ni';
|
|
|
9
9
|
import ignore from 'ignore';
|
|
10
10
|
import os from 'os';
|
|
11
11
|
import process2 from 'process';
|
|
12
|
+
import * as jsonc from 'jsonc-parser';
|
|
13
|
+
import * as TOML from 'smol-toml';
|
|
12
14
|
import ora from 'ora';
|
|
13
15
|
|
|
14
16
|
// src/utils/is-non-interactive.ts
|
|
15
|
-
var
|
|
17
|
+
var AGENT_ENVIRONMENT_VARIABLES = [
|
|
16
18
|
"CI",
|
|
17
19
|
"CLAUDECODE",
|
|
20
|
+
"CURSOR_AGENT",
|
|
21
|
+
"CODEX_CI",
|
|
22
|
+
"OPENCODE",
|
|
23
|
+
"AMP_HOME",
|
|
18
24
|
"AMI"
|
|
19
25
|
];
|
|
20
|
-
var
|
|
21
|
-
|
|
22
|
-
) || !process.stdin.isTTY;
|
|
26
|
+
var isEnvironmentVariableSet = (variable) => Boolean(process.env[variable]);
|
|
27
|
+
var detectNonInteractive = (yesFlag) => yesFlag || AGENT_ENVIRONMENT_VARIABLES.some(isEnvironmentVariableSet) || !process.stdin.isTTY;
|
|
23
28
|
var highlighter = {
|
|
24
29
|
error: pc.red,
|
|
25
30
|
warn: pc.yellow,
|
|
@@ -377,6 +382,8 @@ var AGENT_PACKAGES = [
|
|
|
377
382
|
"@react-grab/gemini",
|
|
378
383
|
"@react-grab/amp",
|
|
379
384
|
"@react-grab/ami",
|
|
385
|
+
"@react-grab/droid",
|
|
386
|
+
"@react-grab/copilot",
|
|
380
387
|
"@react-grab/mcp"
|
|
381
388
|
];
|
|
382
389
|
var detectUnsupportedFramework = (projectRoot) => {
|
|
@@ -704,113 +711,39 @@ var ensureDirectory = (filePath) => {
|
|
|
704
711
|
fs.mkdirSync(directory, { recursive: true });
|
|
705
712
|
}
|
|
706
713
|
};
|
|
707
|
-
var
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
714
|
+
var JSONC_FORMAT_OPTIONS = {
|
|
715
|
+
tabSize: 2,
|
|
716
|
+
insertSpaces: true
|
|
717
|
+
};
|
|
718
|
+
var upsertIntoJsonc = (filePath, content, configKey, serverName, serverConfig) => {
|
|
719
|
+
const edits = jsonc.modify(
|
|
720
|
+
content,
|
|
721
|
+
[configKey, serverName],
|
|
722
|
+
serverConfig,
|
|
723
|
+
{ formattingOptions: JSONC_FORMAT_OPTIONS }
|
|
713
724
|
);
|
|
714
|
-
|
|
715
|
-
const keyPattern = new RegExp(`"${escapedConfigKey}"\\s*:\\s*\\{`);
|
|
716
|
-
const keyMatch = keyPattern.exec(content);
|
|
717
|
-
if (keyMatch) {
|
|
718
|
-
const insertPosition = keyMatch.index + keyMatch[0].length;
|
|
719
|
-
const entry = `
|
|
720
|
-
"${serverName}": ${serverJson},`;
|
|
721
|
-
fs.writeFileSync(
|
|
722
|
-
filePath,
|
|
723
|
-
content.slice(0, insertPosition) + entry + content.slice(insertPosition)
|
|
724
|
-
);
|
|
725
|
-
return;
|
|
726
|
-
}
|
|
727
|
-
const lastBrace = content.lastIndexOf("}");
|
|
728
|
-
if (lastBrace === -1) return;
|
|
729
|
-
const beforeBrace = content.slice(0, lastBrace).trimEnd();
|
|
730
|
-
const withoutComments = beforeBrace.replace(/\/\/.*$/, "").trimEnd();
|
|
731
|
-
const lastChar = withoutComments[withoutComments.length - 1];
|
|
732
|
-
const needsComma = lastChar !== void 0 && lastChar !== "{" && lastChar !== ",";
|
|
733
|
-
const section = `${needsComma ? "," : ""}
|
|
734
|
-
"${configKey}": {
|
|
735
|
-
"${serverName}": ${serverJson}
|
|
736
|
-
}`;
|
|
737
|
-
fs.writeFileSync(filePath, beforeBrace + section + "\n}\n");
|
|
725
|
+
fs.writeFileSync(filePath, jsonc.applyEdits(content, edits));
|
|
738
726
|
};
|
|
739
727
|
var installJsonClient = (client) => {
|
|
740
728
|
ensureDirectory(client.configPath);
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
try {
|
|
750
|
-
const config = JSON.parse(content);
|
|
751
|
-
const servers = config[client.configKey] ?? {};
|
|
752
|
-
servers[SERVER_NAME] = client.serverConfig;
|
|
753
|
-
config[client.configKey] = servers;
|
|
754
|
-
fs.writeFileSync(client.configPath, JSON.stringify(config, null, 2) + "\n");
|
|
755
|
-
} catch {
|
|
756
|
-
insertIntoJsonc(
|
|
757
|
-
client.configPath,
|
|
758
|
-
content,
|
|
759
|
-
client.configKey,
|
|
760
|
-
SERVER_NAME,
|
|
761
|
-
client.serverConfig
|
|
762
|
-
);
|
|
763
|
-
}
|
|
764
|
-
};
|
|
765
|
-
var buildTomlSection = (configKey, serverConfig) => {
|
|
766
|
-
const lines = [`[${configKey}.${SERVER_NAME}]`];
|
|
767
|
-
for (const [key, value] of Object.entries(serverConfig)) {
|
|
768
|
-
if (typeof value === "string") {
|
|
769
|
-
lines.push(`${key} = "${value}"`);
|
|
770
|
-
} else if (Array.isArray(value)) {
|
|
771
|
-
const items = value.map((item) => `"${item}"`).join(", ");
|
|
772
|
-
lines.push(`${key} = [${items}]`);
|
|
773
|
-
}
|
|
774
|
-
}
|
|
775
|
-
return lines.join("\n");
|
|
729
|
+
const content = fs.existsSync(client.configPath) ? fs.readFileSync(client.configPath, "utf8") : "{}";
|
|
730
|
+
upsertIntoJsonc(
|
|
731
|
+
client.configPath,
|
|
732
|
+
content,
|
|
733
|
+
client.configKey,
|
|
734
|
+
SERVER_NAME,
|
|
735
|
+
client.serverConfig
|
|
736
|
+
);
|
|
776
737
|
};
|
|
777
738
|
var installTomlClient = (client) => {
|
|
778
739
|
ensureDirectory(client.configPath);
|
|
779
|
-
const
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
if (!content.includes(sectionHeader)) {
|
|
787
|
-
fs.writeFileSync(
|
|
788
|
-
client.configPath,
|
|
789
|
-
content.trimEnd() + "\n\n" + newSection + "\n"
|
|
790
|
-
);
|
|
791
|
-
return;
|
|
792
|
-
}
|
|
793
|
-
const lines = content.split("\n");
|
|
794
|
-
const resultLines = [];
|
|
795
|
-
let isInsideOurSection = false;
|
|
796
|
-
let didInsertReplacement = false;
|
|
797
|
-
for (const line of lines) {
|
|
798
|
-
if (line.trim() === sectionHeader) {
|
|
799
|
-
isInsideOurSection = true;
|
|
800
|
-
if (!didInsertReplacement) {
|
|
801
|
-
resultLines.push(newSection);
|
|
802
|
-
didInsertReplacement = true;
|
|
803
|
-
}
|
|
804
|
-
continue;
|
|
805
|
-
}
|
|
806
|
-
if (isInsideOurSection && line.startsWith("[")) {
|
|
807
|
-
isInsideOurSection = false;
|
|
808
|
-
}
|
|
809
|
-
if (!isInsideOurSection) {
|
|
810
|
-
resultLines.push(line);
|
|
811
|
-
}
|
|
812
|
-
}
|
|
813
|
-
fs.writeFileSync(client.configPath, resultLines.join("\n"));
|
|
740
|
+
const existingConfig = fs.existsSync(
|
|
741
|
+
client.configPath
|
|
742
|
+
) ? TOML.parse(fs.readFileSync(client.configPath, "utf8")) : {};
|
|
743
|
+
const serverSection = existingConfig[client.configKey] ?? {};
|
|
744
|
+
serverSection[SERVER_NAME] = client.serverConfig;
|
|
745
|
+
existingConfig[client.configKey] = serverSection;
|
|
746
|
+
fs.writeFileSync(client.configPath, TOML.stringify(existingConfig));
|
|
814
747
|
};
|
|
815
748
|
var getMcpClientNames = () => getClients().map((client) => client.name);
|
|
816
749
|
var installMcpServers = (selectedClients) => {
|
|
@@ -912,7 +845,8 @@ var AGENTS = [
|
|
|
912
845
|
"gemini",
|
|
913
846
|
"amp",
|
|
914
847
|
"ami",
|
|
915
|
-
"droid"
|
|
848
|
+
"droid",
|
|
849
|
+
"copilot"
|
|
916
850
|
];
|
|
917
851
|
var AGENT_NAMES = {
|
|
918
852
|
"claude-code": "Claude Code",
|
|
@@ -922,7 +856,8 @@ var AGENT_NAMES = {
|
|
|
922
856
|
gemini: "Gemini",
|
|
923
857
|
amp: "Amp",
|
|
924
858
|
ami: "Ami",
|
|
925
|
-
droid: "Droid"
|
|
859
|
+
droid: "Droid",
|
|
860
|
+
copilot: "Copilot"
|
|
926
861
|
};
|
|
927
862
|
var getAgentDisplayName = (agent) => {
|
|
928
863
|
if (agent === "mcp") return "MCP";
|
|
@@ -1657,7 +1592,9 @@ var AGENT_PACKAGES2 = {
|
|
|
1657
1592
|
opencode: "@react-grab/opencode@latest",
|
|
1658
1593
|
codex: "@react-grab/codex@latest",
|
|
1659
1594
|
gemini: "@react-grab/gemini@latest",
|
|
1660
|
-
amp: "@react-grab/amp@latest"
|
|
1595
|
+
amp: "@react-grab/amp@latest",
|
|
1596
|
+
droid: "@react-grab/droid@latest",
|
|
1597
|
+
copilot: "@react-grab/copilot@latest"
|
|
1661
1598
|
};
|
|
1662
1599
|
var getAgentPrefix = (agent, packageManager) => {
|
|
1663
1600
|
const agentPackage = AGENT_PACKAGES2[agent];
|
|
@@ -2253,7 +2190,7 @@ var previewCdnTransform = (projectRoot, framework, nextRouterType, targetCdnDoma
|
|
|
2253
2190
|
};
|
|
2254
2191
|
|
|
2255
2192
|
// src/commands/add.ts
|
|
2256
|
-
var VERSION = "0.1.
|
|
2193
|
+
var VERSION = "0.1.16";
|
|
2257
2194
|
var formatInstalledAgentNames = (agents) => agents.map((agent) => AGENT_NAMES[agent] || agent).join(", ");
|
|
2258
2195
|
var add = new Command().name("add").alias("install").description("connect React Grab to your agent").argument("[agent]", `agent to connect (${AGENTS.join(", ")}, mcp)`).option("-y, --yes", "skip confirmation prompts", false).option(
|
|
2259
2196
|
"-c, --cwd <cwd>",
|
|
@@ -2614,7 +2551,7 @@ var MAX_KEY_HOLD_DURATION_MS = 2e3;
|
|
|
2614
2551
|
var MAX_CONTEXT_LINES = 50;
|
|
2615
2552
|
|
|
2616
2553
|
// src/commands/configure.ts
|
|
2617
|
-
var VERSION2 = "0.1.
|
|
2554
|
+
var VERSION2 = "0.1.16";
|
|
2618
2555
|
var isMac = process.platform === "darwin";
|
|
2619
2556
|
var META_LABEL = isMac ? "Cmd" : "Win";
|
|
2620
2557
|
var ALT_LABEL = isMac ? "Option" : "Alt";
|
|
@@ -3170,7 +3107,7 @@ var uninstallPackagesWithFeedback = (packages, packageManager, projectRoot) => {
|
|
|
3170
3107
|
};
|
|
3171
3108
|
|
|
3172
3109
|
// src/commands/init.ts
|
|
3173
|
-
var VERSION3 = "0.1.
|
|
3110
|
+
var VERSION3 = "0.1.16";
|
|
3174
3111
|
var REPORT_URL = "https://react-grab.com/api/report-cli";
|
|
3175
3112
|
var DOCS_URL = "https://github.com/aidenybai/react-grab";
|
|
3176
3113
|
var reportToCli = (type, config, error) => {
|
|
@@ -4028,7 +3965,7 @@ var init = new Command().name("init").description("initialize React Grab in your
|
|
|
4028
3965
|
reportToCli("error", void 0, error);
|
|
4029
3966
|
}
|
|
4030
3967
|
});
|
|
4031
|
-
var VERSION4 = "0.1.
|
|
3968
|
+
var VERSION4 = "0.1.16";
|
|
4032
3969
|
var remove = new Command().name("remove").description("disconnect React Grab from your agent").argument("[agent]", `agent to disconnect (${AGENTS.join(", ")}, mcp)`).option("-y, --yes", "skip confirmation prompts", false).option(
|
|
4033
3970
|
"-c, --cwd <cwd>",
|
|
4034
3971
|
"working directory (defaults to current directory)",
|
|
@@ -4204,7 +4141,7 @@ var remove = new Command().name("remove").description("disconnect React Grab fro
|
|
|
4204
4141
|
});
|
|
4205
4142
|
|
|
4206
4143
|
// src/cli.ts
|
|
4207
|
-
var VERSION5 = "0.1.
|
|
4144
|
+
var VERSION5 = "0.1.16";
|
|
4208
4145
|
var VERSION_API_URL = "https://www.react-grab.com/api/version";
|
|
4209
4146
|
process.on("SIGINT", () => process.exit(0));
|
|
4210
4147
|
process.on("SIGTERM", () => process.exit(0));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-grab/cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.16",
|
|
4
4
|
"bin": {
|
|
5
5
|
"react-grab": "./dist/cli.js"
|
|
6
6
|
},
|
|
@@ -19,9 +19,11 @@
|
|
|
19
19
|
"@antfu/ni": "^0.23.0",
|
|
20
20
|
"commander": "^14.0.0",
|
|
21
21
|
"ignore": "^7.0.5",
|
|
22
|
+
"jsonc-parser": "^3.3.1",
|
|
22
23
|
"ora": "^8.2.0",
|
|
23
24
|
"picocolors": "^1.1.1",
|
|
24
|
-
"prompts": "^2.4.2"
|
|
25
|
+
"prompts": "^2.4.2",
|
|
26
|
+
"smol-toml": "^1.6.0"
|
|
25
27
|
},
|
|
26
28
|
"devDependencies": {
|
|
27
29
|
"@types/prompts": "^2.4.9",
|