send-context 0.1.1 → 0.1.2

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.
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.geminiAvailable = geminiAvailable;
4
4
  exports.distillSession = distillSession;
5
+ const jsonrepair_1 = require("jsonrepair");
5
6
  /**
6
7
  * Optional Gemini pass that distills a raw session into the structured
7
8
  * Context Handoff sections, so the sender ships a dense brief instead of
@@ -70,13 +71,43 @@ function parseSections(content) {
70
71
  }
71
72
  function extractJson(content) {
72
73
  const fenced = content.match(/```(?:json)?\s*([\s\S]*?)```/);
73
- if (fenced)
74
- return fenced[1].trim();
75
- const start = content.indexOf("{");
76
- const end = content.lastIndexOf("}");
77
- if (start !== -1 && end > start)
78
- return content.slice(start, end + 1);
79
- return content;
74
+ const body = fenced ? fenced[1].trim() : content;
75
+ // Isolate the JSON from any surrounding prose, then let jsonrepair fix the
76
+ // common ways models still mangle it: trailing commas, single quotes,
77
+ // unquoted keys, truncation (missing closing brackets), and so on.
78
+ const start = body.indexOf("{");
79
+ const candidate = start === -1 ? body : (firstBalancedObject(body) ?? body.slice(start));
80
+ return (0, jsonrepair_1.jsonrepair)(candidate);
81
+ }
82
+ // Return the first brace-balanced JSON object, ignoring any prose or extra
83
+ // objects the model appends after it (thinking models often do). Tracks string
84
+ // literals and escapes so braces inside strings don't throw off the depth count.
85
+ function firstBalancedObject(text) {
86
+ const start = text.indexOf("{");
87
+ if (start === -1)
88
+ return null;
89
+ let depth = 0;
90
+ let inString = false;
91
+ let escaped = false;
92
+ for (let i = start; i < text.length; i++) {
93
+ const ch = text[i];
94
+ if (inString) {
95
+ if (escaped)
96
+ escaped = false;
97
+ else if (ch === "\\")
98
+ escaped = true;
99
+ else if (ch === '"')
100
+ inString = false;
101
+ continue;
102
+ }
103
+ if (ch === '"')
104
+ inString = true;
105
+ else if (ch === "{")
106
+ depth++;
107
+ else if (ch === "}" && --depth === 0)
108
+ return text.slice(start, i + 1);
109
+ }
110
+ return null;
80
111
  }
81
112
  function str(v) {
82
113
  return typeof v === "string" ? v.trim() : "";
package/dist/index.js CHANGED
@@ -5,10 +5,12 @@ const commander_1 = require("commander");
5
5
  const export_js_1 = require("./commands/export.js");
6
6
  const receive_js_1 = require("./commands/receive.js");
7
7
  const program = new commander_1.Command();
8
+ // Single source of truth: read the version release-it bumps in package.json.
9
+ const { version } = require("../package.json");
8
10
  program
9
11
  .name("send-context")
10
12
  .description("Relay AI coding-agent session context between developers via an encrypted, ephemeral link.")
11
- .version("0.1.0")
13
+ .version(version)
12
14
  .enablePositionalOptions();
13
15
  program
14
16
  .command("export")
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "send-context",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "Agent-agnostic CLI to relay AI coding-agent session context between developers via an encrypted, ephemeral edge link.",
5
5
  "license": "MIT",
6
6
  "type": "commonjs",
@@ -43,7 +43,8 @@
43
43
  },
44
44
  "dependencies": {
45
45
  "@clack/prompts": "^0.7.0",
46
- "commander": "^12.1.0"
46
+ "commander": "^12.1.0",
47
+ "jsonrepair": "^3.14.0"
47
48
  },
48
49
  "devDependencies": {
49
50
  "@types/node": "^22.0.0",