@jive-ai/cli 0.0.9 → 0.0.11

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.
Files changed (2) hide show
  1. package/dist/index.mjs +65 -68
  2. package/package.json +1 -1
package/dist/index.mjs CHANGED
@@ -34,13 +34,20 @@ async function ensureDir(filePath) {
34
34
  }
35
35
  }
36
36
  async function getCredentials() {
37
- try {
38
- const data = await fs.readFile(CREDENTIALS_PATH, "utf-8");
39
- return JSON.parse(data);
40
- } catch (error) {
41
- if (error.code === "ENOENT") return null;
42
- throw error;
43
- }
37
+ const fileCredentials = await (async () => {
38
+ try {
39
+ const data = await fs.readFile(CREDENTIALS_PATH, "utf-8");
40
+ return JSON.parse(data);
41
+ } catch (error) {
42
+ if (error.code === "ENOENT") return null;
43
+ throw error;
44
+ }
45
+ })();
46
+ if (fileCredentials) return {
47
+ ...fileCredentials,
48
+ ...process.env.JIVE_API_KEY ? { token: process.env.JIVE_API_KEY } : {}
49
+ };
50
+ return null;
44
51
  }
45
52
  async function saveCredentials(credentials) {
46
53
  await ensureDir(CREDENTIALS_PATH);
@@ -98,13 +105,17 @@ async function isProjectInitialized() {
98
105
  return await getProjectConfig() !== null;
99
106
  }
100
107
 
108
+ //#endregion
109
+ //#region src/constants.ts
110
+ const API_URL = process.env.JIVE_API_URL || "https://next.getjive.app";
111
+
101
112
  //#endregion
102
113
  //#region src/lib/api-client.ts
103
114
  var ApiClient = class {
104
115
  client;
105
116
  baseURL;
106
- constructor(baseURL) {
107
- this.baseURL = baseURL || process.env.JIVE_API_URL || "https://next.getjive.app";
117
+ constructor(baseURL = API_URL) {
118
+ this.baseURL = baseURL;
108
119
  this.client = axios.create({
109
120
  baseURL: this.baseURL,
110
121
  timeout: 3e4,
@@ -610,8 +621,7 @@ async function initCommand() {
610
621
  await requireAuth();
611
622
  let teamId;
612
623
  const apiClient$1 = getApiClient();
613
- const credentials = await getCredentials();
614
- if (!credentials) {
624
+ if (!await getCredentials()) {
615
625
  console.error(chalk.red("Not authenticated"));
616
626
  process.exit(1);
617
627
  }
@@ -708,13 +718,7 @@ async function initCommand() {
708
718
  }
709
719
  }
710
720
  spinner.text = "Adding Jive server to .mcp.json...";
711
- await addMcpServer("jive-mcp", {
712
- command: "jive mcp start",
713
- env: {
714
- JIVE_TEAM_ID: teamId,
715
- JIVE_AUTH_TOKEN: credentials.token
716
- }
717
- });
721
+ await addMcpServer("jive-mcp", { command: "jive mcp start" });
718
722
  spinner.text = "Removing uploaded MCP servers from local .mcp.json...";
719
723
  if (mcpConfig?.mcpServers) {
720
724
  const serversToRemove = [...uploadedServers.map((server) => server.name), ...skippedServers.map((server) => server.name)];
@@ -773,47 +777,42 @@ async function detachCommand() {
773
777
  const projectConfig = await getProjectConfig();
774
778
  await requireAuth();
775
779
  const apiClient$1 = getApiClient();
776
- if (projectConfig) {
777
- const teamId = projectConfig.activeTeamId || projectConfig.teamId;
778
- spinner.text = "Pulling subagents from platform...";
779
- try {
780
- const subagents$1 = await apiClient$1.getSubagents(teamId);
781
- for (const subagent of subagents$1) {
782
- await saveSubagentFile({
783
- name: subagent.name,
784
- description: subagent.description,
785
- prompt: subagent.prompt
786
- });
787
- pulledSubagents++;
788
- }
789
- } catch (error) {
790
- console.warn(chalk.yellow(`\n⚠️ Could not pull subagents: ${error.message}`));
791
- }
792
- spinner.text = "Pulling MCP servers from platform...";
793
- try {
794
- const servers = await apiClient$1.getMcpServers(teamId);
795
- for (const server of servers) {
796
- if (server.name === "jive-mcp") continue;
797
- await addMcpServer(server.name, server.config);
798
- pulledMcpServers++;
799
- }
800
- } catch (error) {
801
- console.warn(chalk.yellow(`\n⚠️ Could not pull MCP servers: ${error.message}`));
780
+ const teamId = projectConfig?.activeTeamId || projectConfig?.teamId;
781
+ if (!teamId) {
782
+ console.error(chalk.red("No team ID found, select one with `jive team switch`"));
783
+ process.exit(1);
784
+ return;
785
+ }
786
+ spinner.text = "Pulling subagents from platform...";
787
+ try {
788
+ const subagents$1 = await apiClient$1.getSubagents(teamId);
789
+ for (const subagent of subagents$1) {
790
+ await saveSubagentFile({
791
+ name: subagent.name,
792
+ description: subagent.description,
793
+ prompt: subagent.prompt
794
+ });
795
+ pulledSubagents++;
802
796
  }
797
+ } catch (error) {
798
+ console.warn(chalk.yellow(`\n⚠️ Could not pull subagents: ${error.message}`));
803
799
  }
804
- spinner.text = "Removing Jive server from .mcp.json...";
805
- if ((await getMcpConfig())?.mcpServers?.["jive-mcp"]) await removeMcpServer("jive-mcp");
806
- spinner.text = "Removing telemetry plugin...";
807
- const pluginPath = path.join(process.cwd(), ".claude", "plugins", "jive-mcp-telemetry");
800
+ spinner.text = "Pulling MCP servers from platform...";
808
801
  try {
809
- await fs.access(pluginPath);
810
- await fs.rm(pluginPath, {
811
- recursive: true,
812
- force: true
813
- });
802
+ const servers$1 = await apiClient$1.getMcpServers(teamId);
803
+ for (const server of servers$1) {
804
+ if (server.name === "jive-mcp") continue;
805
+ await addMcpServer(server.name, server.config);
806
+ pulledMcpServers++;
807
+ }
814
808
  } catch (error) {
815
- if (error.code !== "ENOENT") throw error;
809
+ console.warn(chalk.yellow(`\n⚠️ Could not pull MCP servers: ${error.message}`));
816
810
  }
811
+ spinner.text = "Removing Jive server from .mcp.json...";
812
+ if ((await getMcpConfig())?.mcpServers?.["jive-mcp"]) await removeMcpServer("jive-mcp");
813
+ spinner.text = "Restoring MCP server config...";
814
+ const servers = await apiClient$1.getMcpServers(teamId);
815
+ for (const server of servers) await addMcpServer(server.name, server.config);
817
816
  spinner.text = "Removing subagent-runner...";
818
817
  const runnerPath = path.join(process.cwd(), ".claude", "agents", "subagent-runner.md");
819
818
  try {
@@ -835,11 +834,7 @@ async function detachCommand() {
835
834
  const gitignorePath = path.join(process.cwd(), ".gitignore");
836
835
  try {
837
836
  let content = await fs.readFile(gitignorePath, "utf-8");
838
- const linesToRemove = [
839
- ".jive/config.json",
840
- ".jive/sync.json",
841
- ".claude/plugins/"
842
- ];
837
+ const linesToRemove = [".jive"];
843
838
  const lines = content.split("\n");
844
839
  const filteredLines = lines.filter((line) => !linesToRemove.includes(line.trim()));
845
840
  if (filteredLines.length !== lines.length) await fs.writeFile(gitignorePath, filteredLines.join("\n"));
@@ -851,7 +846,7 @@ async function detachCommand() {
851
846
  if (pulledSubagents > 0) console.log(chalk.green(` ✓ Pulled ${pulledSubagents} subagent(s) from platform`));
852
847
  if (pulledMcpServers > 0) console.log(chalk.green(` ✓ Pulled ${pulledMcpServers} MCP server(s) from platform`));
853
848
  console.log(chalk.green(" ✓ Removed Jive server from .mcp.json"));
854
- console.log(chalk.green(" ✓ Removed telemetry plugin"));
849
+ console.log(chalk.green(" ✓ Restored MCP server config"));
855
850
  console.log(chalk.green(" ✓ Removed subagent-runner"));
856
851
  console.log(chalk.green(" ✓ Removed .jive directory"));
857
852
  console.log(chalk.green(" ✓ Cleaned up .gitignore"));
@@ -1349,17 +1344,19 @@ function log(...args) {
1349
1344
  */
1350
1345
  async function startMcpServer() {
1351
1346
  log("=== Jive Server Starting ===");
1352
- const apiKey = process.env.JIVE_API_KEY;
1353
- const apiUrl = process.env.JIVE_API_URL || "http://localhost:5173";
1354
- if (!apiKey) {
1355
- log("Error: JIVE_API_KEY environment variable is required");
1356
- log("Usage: JIVE_API_KEY=jive_xxx npm run mcp");
1347
+ const projectConfig = await getProjectConfig();
1348
+ if (!(projectConfig?.activeTeamId || projectConfig?.teamId)) {
1349
+ log("Error: No team ID found, select one with `jive team switch`");
1357
1350
  process.exit(1);
1351
+ return;
1358
1352
  }
1359
- if (!apiKey.startsWith("jive_")) {
1360
- log("Error: JIVE_API_KEY must start with \"jive_\"");
1353
+ const apiKey = (await getCredentials())?.token;
1354
+ if (!apiKey) {
1355
+ log("Error: No API key found, please login with `jive login`");
1361
1356
  process.exit(1);
1357
+ return;
1362
1358
  }
1359
+ const apiUrl = API_URL;
1363
1360
  log(`Jive server connecting to ${apiUrl}`);
1364
1361
  const connectionManager = new McpConnectionManager();
1365
1362
  try {
@@ -2067,7 +2064,7 @@ async function checkTeamMembership() {
2067
2064
 
2068
2065
  //#endregion
2069
2066
  //#region package.json
2070
- var version = "0.0.9";
2067
+ var version = "0.0.11";
2071
2068
 
2072
2069
  //#endregion
2073
2070
  //#region src/index.ts
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@jive-ai/cli",
4
- "version": "0.0.9",
4
+ "version": "0.0.11",
5
5
  "main": "index.js",
6
6
  "files": [
7
7
  "dist",