create-snipara 1.3.18 → 1.3.19
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 +47 -14
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -9,7 +9,7 @@ import fs from "fs";
|
|
|
9
9
|
import path from "path";
|
|
10
10
|
import { execSync, spawn } from "child_process";
|
|
11
11
|
import { homedir } from "os";
|
|
12
|
-
var VERSION = "1.3.
|
|
12
|
+
var VERSION = "1.3.19";
|
|
13
13
|
var BASE_URL = "https://www.snipara.com";
|
|
14
14
|
var API_URL = "https://api.snipara.com";
|
|
15
15
|
var COMPANION_PACKAGE_NAME = "snipara-companion";
|
|
@@ -204,6 +204,7 @@ async function runInit(options) {
|
|
|
204
204
|
await installClaudeCodeHooks(answers);
|
|
205
205
|
}
|
|
206
206
|
await updateEnvFiles(answers);
|
|
207
|
+
await createCompanionConfig(answers);
|
|
207
208
|
await createCompanionPack(answers);
|
|
208
209
|
const validationReport = await runValidation(answers, !options.skipTest);
|
|
209
210
|
writeDoctorReport(validationReport);
|
|
@@ -237,6 +238,7 @@ async function runRepair(options) {
|
|
|
237
238
|
await createMcpConfig(answers);
|
|
238
239
|
await createAgentTemplates(answers);
|
|
239
240
|
await updateEnvFiles(answers);
|
|
241
|
+
await createCompanionConfig(answers);
|
|
240
242
|
await createCompanionPack(answers);
|
|
241
243
|
if (answers.installHooks && answers.aiClient === "claude-code") {
|
|
242
244
|
await installClaudeCodeHooks(answers);
|
|
@@ -265,6 +267,7 @@ async function runUpgrade(options) {
|
|
|
265
267
|
await createMcpConfig(upgradedAnswers);
|
|
266
268
|
}
|
|
267
269
|
await createAgentTemplates(upgradedAnswers);
|
|
270
|
+
await createCompanionConfig(upgradedAnswers);
|
|
268
271
|
if (options.withHooks || answers.installHooks) {
|
|
269
272
|
await installClaudeCodeHooks({ ...answers, installHooks: true });
|
|
270
273
|
}
|
|
@@ -1179,11 +1182,10 @@ async function createClaudeDesktopConfig(answers) {
|
|
|
1179
1182
|
}
|
|
1180
1183
|
config.mcpServers = config.mcpServers || {};
|
|
1181
1184
|
config.mcpServers.snipara = {
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
SNIPARA_PROJECT_SLUG: answers.projectSlug
|
|
1185
|
+
type: "http",
|
|
1186
|
+
url: buildHostedMcpEndpoint(answers),
|
|
1187
|
+
headers: {
|
|
1188
|
+
"X-API-Key": answers.apiKey
|
|
1187
1189
|
}
|
|
1188
1190
|
};
|
|
1189
1191
|
if (answers.installRuntime) {
|
|
@@ -1376,12 +1378,19 @@ async function updateEnvFiles(answers) {
|
|
|
1376
1378
|
const envLocalPath = path.join(process.cwd(), ".env.local");
|
|
1377
1379
|
const envPath = path.join(process.cwd(), ".env");
|
|
1378
1380
|
let envVars = "";
|
|
1381
|
+
let envExampleVars = "";
|
|
1379
1382
|
if (answers.apiKeyType !== "none") {
|
|
1380
1383
|
envVars += `
|
|
1381
1384
|
# Snipara Configuration
|
|
1382
1385
|
SNIPARA_API_KEY=${answers.apiKey.includes("YOUR_") ? "your_api_key_here" : answers.apiKey}
|
|
1383
1386
|
SNIPARA_PROJECT_SLUG=${answers.projectSlug}
|
|
1384
1387
|
${answers.projectId ? `SNIPARA_PROJECT_ID=${answers.projectId}` : ""}
|
|
1388
|
+
`.trim();
|
|
1389
|
+
envExampleVars += `
|
|
1390
|
+
# Snipara Configuration
|
|
1391
|
+
SNIPARA_API_KEY=your_api_key_here
|
|
1392
|
+
SNIPARA_PROJECT_SLUG=${answers.projectSlug || "your_project_slug"}
|
|
1393
|
+
${answers.projectId ? `SNIPARA_PROJECT_ID=${answers.projectId}` : "SNIPARA_PROJECT_ID=your_project_id"}
|
|
1385
1394
|
`.trim();
|
|
1386
1395
|
}
|
|
1387
1396
|
if (answers.llmProvider && answers.llmProvider !== "none" && answers.llmApiKey) {
|
|
@@ -1390,23 +1399,28 @@ ${answers.projectId ? `SNIPARA_PROJECT_ID=${answers.projectId}` : ""}
|
|
|
1390
1399
|
|
|
1391
1400
|
# Snipara Sandbox LLM Provider (for snipara-sandbox run/agent CLI)
|
|
1392
1401
|
${llmVarName}=${answers.llmApiKey}`;
|
|
1402
|
+
envExampleVars += `
|
|
1403
|
+
|
|
1404
|
+
# Snipara Sandbox LLM Provider (for snipara-sandbox run/agent CLI)
|
|
1405
|
+
${llmVarName}=your_${answers.llmProvider}_api_key_here`;
|
|
1393
1406
|
}
|
|
1394
1407
|
envVars = envVars.trim();
|
|
1395
|
-
|
|
1408
|
+
envExampleVars = envExampleVars.trim();
|
|
1409
|
+
if (!envVars && !envExampleVars) {
|
|
1396
1410
|
console.log(chalk.dim(" No environment variables to save"));
|
|
1397
1411
|
return;
|
|
1398
1412
|
}
|
|
1399
|
-
if (fs.existsSync(envExamplePath)) {
|
|
1413
|
+
if (envExampleVars && fs.existsSync(envExamplePath)) {
|
|
1400
1414
|
const content = fs.readFileSync(envExamplePath, "utf-8");
|
|
1401
1415
|
if (!content.includes("SNIPARA_API_KEY") && !content.includes("SNIPARA_PROJECT_SLUG")) {
|
|
1402
1416
|
fs.appendFileSync(envExamplePath, `
|
|
1403
1417
|
|
|
1404
|
-
${
|
|
1418
|
+
${envExampleVars}
|
|
1405
1419
|
`);
|
|
1406
1420
|
console.log(chalk.green(" \u2713 Updated .env.example"));
|
|
1407
1421
|
}
|
|
1408
|
-
} else {
|
|
1409
|
-
fs.writeFileSync(envExamplePath,
|
|
1422
|
+
} else if (envExampleVars) {
|
|
1423
|
+
fs.writeFileSync(envExamplePath, envExampleVars + "\n");
|
|
1410
1424
|
console.log(chalk.green(" \u2713 Created .env.example"));
|
|
1411
1425
|
}
|
|
1412
1426
|
const targetEnvPath = fs.existsSync(envLocalPath) ? envLocalPath : envPath;
|
|
@@ -1426,6 +1440,26 @@ ${envVars}
|
|
|
1426
1440
|
console.log(chalk.green(` \u2713 Created ${path.basename(targetEnvPath)}`));
|
|
1427
1441
|
}
|
|
1428
1442
|
}
|
|
1443
|
+
async function createCompanionConfig(answers) {
|
|
1444
|
+
if (!answers.installCompanion || answers.apiKeyType === "none" || !answers.apiKey || answers.apiKey.includes("YOUR_")) {
|
|
1445
|
+
return;
|
|
1446
|
+
}
|
|
1447
|
+
const configDir = path.join(process.cwd(), ".snipara", "companion");
|
|
1448
|
+
const configPath = path.join(configDir, "config.json");
|
|
1449
|
+
fs.mkdirSync(configDir, { recursive: true });
|
|
1450
|
+
const config = {
|
|
1451
|
+
apiKey: answers.apiKey,
|
|
1452
|
+
projectId: answers.projectId || answers.projectSlug,
|
|
1453
|
+
apiUrl: API_URL,
|
|
1454
|
+
sessionId: `sess_${Date.now()}_${Math.random().toString(36).slice(2, 8)}`
|
|
1455
|
+
};
|
|
1456
|
+
fs.writeFileSync(configPath, JSON.stringify(config, null, 2) + "\n");
|
|
1457
|
+
ensureGitignoreEntry(
|
|
1458
|
+
".snipara/companion/config.json",
|
|
1459
|
+
"# Snipara local companion config (contains API key)"
|
|
1460
|
+
);
|
|
1461
|
+
console.log(chalk.green(" \u2713 Configured local companion workspace"));
|
|
1462
|
+
}
|
|
1429
1463
|
function getClientGuidance(client) {
|
|
1430
1464
|
if (client === "claude-code") {
|
|
1431
1465
|
return [
|
|
@@ -1488,7 +1522,6 @@ function getClientGuidance(client) {
|
|
|
1488
1522
|
}
|
|
1489
1523
|
function getCompanionCommands(answers) {
|
|
1490
1524
|
const projectIdFlag = answers.projectId ? ` --project-id ${answers.projectId}` : "";
|
|
1491
|
-
const apiKeyFlag = " --api-key <snipara-key>";
|
|
1492
1525
|
const clientFlag = getCompanionInitClientFlag(answers.aiClient);
|
|
1493
1526
|
const businessOnboardingCommands = answers.installCompanion ? [
|
|
1494
1527
|
{
|
|
@@ -1520,8 +1553,8 @@ function getCompanionCommands(answers) {
|
|
|
1520
1553
|
return [
|
|
1521
1554
|
{
|
|
1522
1555
|
title: "Bootstrap local companion",
|
|
1523
|
-
command: `${COMPANION_COMMAND_NAME} init${clientFlag}${projectIdFlag}
|
|
1524
|
-
purpose: "
|
|
1556
|
+
command: `${COMPANION_COMMAND_NAME} init${clientFlag}${projectIdFlag}`,
|
|
1557
|
+
purpose: "Re-run local companion setup if this workstation needs to refresh browser login or project selection."
|
|
1525
1558
|
},
|
|
1526
1559
|
{
|
|
1527
1560
|
title: "Run doctor for this project",
|
package/package.json
CHANGED