create-snipara 1.3.26 → 1.3.27
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 +61 -9
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -13,7 +13,7 @@ import { homedir } from "os";
|
|
|
13
13
|
// package.json
|
|
14
14
|
var package_default = {
|
|
15
15
|
name: "create-snipara",
|
|
16
|
-
version: "1.3.
|
|
16
|
+
version: "1.3.27",
|
|
17
17
|
description: "Onboard Snipara Hosted MCP Context + Memory with auth, companion workflows, and optional Snipara Sandbox",
|
|
18
18
|
main: "dist/index.js",
|
|
19
19
|
type: "module",
|
|
@@ -286,6 +286,7 @@ async function runInit(options) {
|
|
|
286
286
|
if (answers.profile !== "runtime-only" || answers.installRuntime) {
|
|
287
287
|
await createMcpConfig(answers);
|
|
288
288
|
}
|
|
289
|
+
await createProjectBinding(answers);
|
|
289
290
|
await createAgentTemplates(answers);
|
|
290
291
|
if (answers.installHooks && answers.aiClient === "claude-code") {
|
|
291
292
|
await installClaudeCodeHooks(answers);
|
|
@@ -331,6 +332,7 @@ async function runRepair(options) {
|
|
|
331
332
|
await installNodeCompanion(true);
|
|
332
333
|
}
|
|
333
334
|
await createMcpConfig(answers);
|
|
335
|
+
await createProjectBinding(answers);
|
|
334
336
|
await createAgentTemplates(answers);
|
|
335
337
|
await updateEnvFiles(answers);
|
|
336
338
|
await createCompanionConfig(answers);
|
|
@@ -361,6 +363,7 @@ async function runUpgrade(options) {
|
|
|
361
363
|
if (options.withMcp || options.withRuntime || detection.files.mcpConfig) {
|
|
362
364
|
await createMcpConfig(upgradedAnswers);
|
|
363
365
|
}
|
|
366
|
+
await createProjectBinding(upgradedAnswers);
|
|
364
367
|
await createAgentTemplates(upgradedAnswers);
|
|
365
368
|
await createCompanionConfig(upgradedAnswers);
|
|
366
369
|
if (options.withHooks || answers.installHooks) {
|
|
@@ -1083,6 +1086,19 @@ async function createMcpConfig(answers) {
|
|
|
1083
1086
|
await createClaudeDesktopConfig(answers);
|
|
1084
1087
|
}
|
|
1085
1088
|
}
|
|
1089
|
+
async function createProjectBinding(answers) {
|
|
1090
|
+
if (answers.profile === "runtime-only") {
|
|
1091
|
+
return;
|
|
1092
|
+
}
|
|
1093
|
+
const sniparaDir = path.join(process.cwd(), ".snipara");
|
|
1094
|
+
const projectBindingPath = path.join(sniparaDir, "project");
|
|
1095
|
+
const projectBinding = `${answers.projectSlug}
|
|
1096
|
+
`;
|
|
1097
|
+
const action = fs.existsSync(projectBindingPath) ? "Updated" : "Created";
|
|
1098
|
+
fs.mkdirSync(sniparaDir, { recursive: true });
|
|
1099
|
+
fs.writeFileSync(projectBindingPath, projectBinding);
|
|
1100
|
+
console.log(chalk.green(` \u2713 ${action} .snipara/project`));
|
|
1101
|
+
}
|
|
1086
1102
|
async function createAgentTemplates(answers) {
|
|
1087
1103
|
if (answers.profile === "runtime-only") {
|
|
1088
1104
|
return;
|
|
@@ -1618,20 +1634,44 @@ async function createCompanionConfig(answers) {
|
|
|
1618
1634
|
}
|
|
1619
1635
|
const configDir = path.join(process.cwd(), ".snipara", "companion");
|
|
1620
1636
|
const configPath = path.join(configDir, "config.json");
|
|
1637
|
+
const globalConfigPath = getGlobalCompanionConfigPath();
|
|
1621
1638
|
fs.mkdirSync(configDir, { recursive: true });
|
|
1622
|
-
|
|
1639
|
+
fs.mkdirSync(path.dirname(globalConfigPath), { recursive: true });
|
|
1640
|
+
const existingGlobalConfig = readCompanionConfigFile(globalConfigPath);
|
|
1641
|
+
const existingWorkspaceConfig = readCompanionConfigFile(configPath);
|
|
1642
|
+
const globalConfig = {
|
|
1643
|
+
...existingGlobalConfig,
|
|
1623
1644
|
apiKey: answers.apiKey,
|
|
1624
|
-
|
|
1625
|
-
apiUrl: API_URL,
|
|
1626
|
-
sessionId: `sess_${Date.now()}_${Math.random().toString(36).slice(2, 8)}`
|
|
1645
|
+
apiUrl: API_URL
|
|
1627
1646
|
};
|
|
1628
|
-
|
|
1647
|
+
const workspaceConfig = {
|
|
1648
|
+
...existingWorkspaceConfig,
|
|
1649
|
+
projectId: answers.projectId || (typeof existingWorkspaceConfig.projectId === "string" && existingWorkspaceConfig.projectId ? existingWorkspaceConfig.projectId : answers.projectSlug),
|
|
1650
|
+
sessionId: typeof existingWorkspaceConfig.sessionId === "string" && existingWorkspaceConfig.sessionId ? existingWorkspaceConfig.sessionId : `sess_${Date.now()}_${Math.random().toString(36).slice(2, 8)}`
|
|
1651
|
+
};
|
|
1652
|
+
fs.writeFileSync(globalConfigPath, JSON.stringify(globalConfig, null, 2) + "\n");
|
|
1653
|
+
fs.writeFileSync(configPath, JSON.stringify(workspaceConfig, null, 2) + "\n");
|
|
1629
1654
|
ensureGitignoreEntry(
|
|
1630
1655
|
".snipara/companion/config.json",
|
|
1631
|
-
"# Snipara local companion config
|
|
1656
|
+
"# Snipara local companion workspace config"
|
|
1632
1657
|
);
|
|
1658
|
+
console.log(chalk.green(" \u2713 Configured global companion auth"));
|
|
1633
1659
|
console.log(chalk.green(" \u2713 Configured local companion workspace"));
|
|
1634
1660
|
}
|
|
1661
|
+
function getGlobalCompanionConfigPath() {
|
|
1662
|
+
return path.join(homedir(), ".rlmsaas", "config.json");
|
|
1663
|
+
}
|
|
1664
|
+
function readCompanionConfigFile(filePath) {
|
|
1665
|
+
if (!fs.existsSync(filePath)) {
|
|
1666
|
+
return {};
|
|
1667
|
+
}
|
|
1668
|
+
try {
|
|
1669
|
+
const parsed = JSON.parse(fs.readFileSync(filePath, "utf-8"));
|
|
1670
|
+
return typeof parsed === "object" && parsed !== null ? parsed : {};
|
|
1671
|
+
} catch {
|
|
1672
|
+
return {};
|
|
1673
|
+
}
|
|
1674
|
+
}
|
|
1635
1675
|
function getClientGuidance(client) {
|
|
1636
1676
|
if (client === "claude-code") {
|
|
1637
1677
|
return [
|
|
@@ -3026,19 +3066,31 @@ function getExistingConfig() {
|
|
|
3026
3066
|
const runtimeServer = config.mcpServers?.[SANDBOX_SERVER_NAME] || config.mcpServers?.[LEGACY_RUNTIME_SERVER_NAME];
|
|
3027
3067
|
return {
|
|
3028
3068
|
slug: extractSlugFromMcpEndpoint(sniparaServer?.url) || void 0,
|
|
3029
|
-
projectId:
|
|
3069
|
+
projectId: readExistingCompanionProjectId(),
|
|
3030
3070
|
hasSniparaServer: Boolean(sniparaServer),
|
|
3031
3071
|
hasRuntimeServer: Boolean(runtimeServer)
|
|
3032
3072
|
};
|
|
3033
3073
|
} catch {
|
|
3034
3074
|
return {
|
|
3035
3075
|
slug: void 0,
|
|
3036
|
-
projectId:
|
|
3076
|
+
projectId: readExistingCompanionProjectId(),
|
|
3037
3077
|
hasSniparaServer: false,
|
|
3038
3078
|
hasRuntimeServer: false
|
|
3039
3079
|
};
|
|
3040
3080
|
}
|
|
3041
3081
|
}
|
|
3082
|
+
function readExistingCompanionProjectId() {
|
|
3083
|
+
const configPath = path.join(process.cwd(), ".snipara", "companion", "config.json");
|
|
3084
|
+
if (!fs.existsSync(configPath)) {
|
|
3085
|
+
return void 0;
|
|
3086
|
+
}
|
|
3087
|
+
try {
|
|
3088
|
+
const parsed = JSON.parse(fs.readFileSync(configPath, "utf-8"));
|
|
3089
|
+
return typeof parsed.projectId === "string" && parsed.projectId ? parsed.projectId : void 0;
|
|
3090
|
+
} catch {
|
|
3091
|
+
return void 0;
|
|
3092
|
+
}
|
|
3093
|
+
}
|
|
3042
3094
|
main().catch((error) => {
|
|
3043
3095
|
console.error(chalk.red("Error:"), error.message);
|
|
3044
3096
|
process.exit(1);
|
package/package.json
CHANGED