create-snipara 2.0.13 → 2.0.14

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 (3) hide show
  1. package/README.md +10 -1
  2. package/dist/index.js +37 -4
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -122,6 +122,9 @@ That distinction matters:
122
122
  - creates `AGENTS.md` and `CLAUDE.md` when missing, or appends a marked Snipara section when those files already exist
123
123
  - creates `.cursor/rules/snipara.mdc` and `.codex/config.toml` when those files do not already exist
124
124
  - validates Codex config against Hosted MCP plus `bearer_token_env_var = "SNIPARA_API_KEY"` and tells users to restart Codex after MCP config changes
125
+ - generates one opaque correlation session ID and reuses it in `.mcp.json`,
126
+ Companion, Codex, and Kimi configuration so served context can be joined to
127
+ later project outcomes without treating the ID as authentication
125
128
  - installs local code overlay Git hooks only for explicit companion/full-stack
126
129
  setups unless `--skip-hooks` is passed
127
130
  - runs a real hosted MCP `tools/list` check and warns if the server still advertises legacy `rlm_*` duplicate tools
@@ -200,6 +203,10 @@ that is expected. Use `snipara_help(query=...)` for routed guidance and
200
203
  `snipara-companion task-commit` as the reliable local fallback when the simple
201
204
  hosted tools are not callable.
202
205
 
206
+ Codex also receives a static `X-Snipara-Session-Id` HTTP header. This value is
207
+ opaque, non-secret telemetry generated per workspace; `repair` and `upgrade`
208
+ reuse it when valid. It does not replace the bearer token or grant access.
209
+
203
210
  Existing root `AGENTS.md` and `CLAUDE.md` files are not replaced. The installer
204
211
  adds or refreshes a marked Snipara section so project-specific instructions stay
205
212
  intact.
@@ -430,7 +437,9 @@ npx -y snipara-companion@latest automations install --client kimi
430
437
  ```
431
438
 
432
439
  Export `SNIPARA_API_KEY` before starting Kimi. The generated
433
- `.kimi-code/mcp.json` stores only `bearerTokenEnvVar`, never the raw key. Kimi
440
+ `.kimi-code/mcp.json` stores only `bearerTokenEnvVar`, never the raw key. It
441
+ also carries the same non-secret `X-Snipara-Session-Id` used by the project MCP
442
+ and Companion configuration so Outcome Loop telemetry remains joinable. Kimi
434
443
  installs plugins per user, so the generated handler is project-neutral and
435
444
  no-ops outside workspaces carrying a Snipara project or Companion marker.
436
445
  For Mistral, request hooks from LangChain are documented as `ChatMistralAI`
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: "2.0.13",
16
+ version: "2.0.14",
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",
@@ -2180,7 +2180,10 @@ function createKimiMcpConfig(answers) {
2180
2180
  ...existingServers,
2181
2181
  snipara: {
2182
2182
  url: buildHostedMcpEndpoint(answers),
2183
- bearerTokenEnvVar: "SNIPARA_API_KEY"
2183
+ bearerTokenEnvVar: "SNIPARA_API_KEY",
2184
+ headers: {
2185
+ "X-Snipara-Session-Id": getCorrelationSessionId(answers)
2186
+ }
2184
2187
  }
2185
2188
  }
2186
2189
  };
@@ -2195,10 +2198,39 @@ function buildHostedMcpServer(answers) {
2195
2198
  type: "http",
2196
2199
  url: buildHostedMcpEndpoint(answers),
2197
2200
  headers: {
2198
- "X-API-Key": answers.apiKey || "YOUR_API_KEY_HERE"
2201
+ "X-API-Key": answers.apiKey || "YOUR_API_KEY_HERE",
2202
+ "X-Snipara-Session-Id": getCorrelationSessionId(answers)
2199
2203
  }
2200
2204
  };
2201
2205
  }
2206
+ var CORRELATION_SESSION_ID_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._~:/@+-]{0,127}$/;
2207
+ function normalizeCorrelationSessionId(value) {
2208
+ if (typeof value !== "string") {
2209
+ return null;
2210
+ }
2211
+ const normalized = value.trim();
2212
+ return CORRELATION_SESSION_ID_PATTERN.test(normalized) ? normalized : null;
2213
+ }
2214
+ function readExistingCorrelationSessionId() {
2215
+ const companionConfig = readCompanionConfigFile(
2216
+ path.join(process.cwd(), ".snipara", "companion", "config.json")
2217
+ );
2218
+ const projectMcpConfig = asObjectRecord(readJsonFile(path.join(process.cwd(), ".mcp.json")));
2219
+ const projectMcpServer = asObjectRecord(asObjectRecord(projectMcpConfig.mcpServers).snipara);
2220
+ const projectMcpHeaders = asObjectRecord(projectMcpServer.headers);
2221
+ const kimiConfig = asObjectRecord(
2222
+ readJsonFile(path.join(process.cwd(), ".kimi-code", "mcp.json"))
2223
+ );
2224
+ const kimiServer = asObjectRecord(asObjectRecord(kimiConfig.mcpServers).snipara);
2225
+ const kimiHeaders = asObjectRecord(kimiServer.headers);
2226
+ return normalizeCorrelationSessionId(companionConfig.sessionId) || normalizeCorrelationSessionId(projectMcpHeaders["X-Snipara-Session-Id"]) || normalizeCorrelationSessionId(kimiHeaders["X-Snipara-Session-Id"]);
2227
+ }
2228
+ function getCorrelationSessionId(answers) {
2229
+ const existing = normalizeCorrelationSessionId(answers.correlationSessionId) || readExistingCorrelationSessionId();
2230
+ const sessionId = existing || `sess_${Date.now()}_${Math.random().toString(36).slice(2, 8)}`;
2231
+ answers.correlationSessionId = sessionId;
2232
+ return sessionId;
2233
+ }
2202
2234
  function asObjectRecord(value) {
2203
2235
  return value && typeof value === "object" && !Array.isArray(value) ? value : {};
2204
2236
  }
@@ -2813,6 +2845,7 @@ function buildCodexConfigTemplate(answers) {
2813
2845
  type = "streamable_http"
2814
2846
  url = "${buildHostedMcpEndpoint(answers)}"
2815
2847
  bearer_token_env_var = "SNIPARA_API_KEY"
2848
+ http_headers = { "X-Snipara-Session-Id" = "${getCorrelationSessionId(answers)}" }
2816
2849
  `;
2817
2850
  }
2818
2851
  function buildChatGptMcpTemplate(answers) {
@@ -3354,7 +3387,7 @@ async function createCompanionConfig(answers) {
3354
3387
  apiKey: answers.apiKey,
3355
3388
  apiUrl: API_URL,
3356
3389
  projectId: answers.projectId || answers.projectSlug,
3357
- sessionId: typeof existingWorkspaceConfig.sessionId === "string" && existingWorkspaceConfig.sessionId ? existingWorkspaceConfig.sessionId : `sess_${Date.now()}_${Math.random().toString(36).slice(2, 8)}`,
3390
+ sessionId: getCorrelationSessionId(answers),
3358
3391
  client: getAutomationClientId(answers.aiClient)
3359
3392
  };
3360
3393
  fs.writeFileSync(configPath, JSON.stringify(workspaceConfig, null, 2) + "\n");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-snipara",
3
- "version": "2.0.13",
3
+ "version": "2.0.14",
4
4
  "description": "Onboard Snipara Hosted MCP Context + Memory with auth, companion workflows, and optional Snipara Sandbox",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",