@ycodium-ai/plugin-session-import 0.2.3369 → 0.2.3377

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.js +25 -7
  2. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -197,6 +197,7 @@ var NUMBER_PATTERN = /^-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?$/u;
197
197
  var OversizedRecordParser = class {
198
198
  #fields;
199
199
  #budget;
200
+ #options;
200
201
  #retained = 0;
201
202
  #malformed = false;
202
203
  #done = false;
@@ -210,6 +211,7 @@ var OversizedRecordParser = class {
210
211
  #unicodeValue = 0;
211
212
  #bare = "";
212
213
  // 当前字符串的保留规则与累积。
214
+ #strObserver;
213
215
  #strRetain = false;
214
216
  #strCap = void 0;
215
217
  #strHead = "";
@@ -222,9 +224,10 @@ var OversizedRecordParser = class {
222
224
  #expectColon = false;
223
225
  #expectComma = false;
224
226
  #expectValue = true;
225
- constructor(fields, maxRetainedChars = DEFAULT_MAX_RETAINED_CHARS) {
227
+ constructor(fields, maxRetainedChars = DEFAULT_MAX_RETAINED_CHARS, options) {
226
228
  this.#fields = fields;
227
229
  this.#budget = maxRetainedChars;
230
+ this.#options = options;
228
231
  }
229
232
  write(chunk) {
230
233
  if (this.#malformed) return;
@@ -371,7 +374,10 @@ var OversizedRecordParser = class {
371
374
  this.#expectKey = false;
372
375
  this.#expectColon = false;
373
376
  this.#expectComma = true;
374
- this.#store(top.target ?? SKIPPED);
377
+ const empty = top.target !== null && Object.keys(top.target).length === 0;
378
+ this.#store(
379
+ this.#options?.pruneEmpty && top.mode === "descend" && empty && this.#stack.length > 0 ? SKIPPED : top.target ?? SKIPPED
380
+ );
375
381
  }
376
382
  #comma() {
377
383
  const top = this.#top();
@@ -433,8 +439,11 @@ var OversizedRecordParser = class {
433
439
  this.#strCap = void 0;
434
440
  return;
435
441
  }
436
- const { mode, cap } = this.#childMode(false);
437
- this.#strRetain = mode === "keep";
442
+ const { mode, cap, path } = this.#childMode(false);
443
+ this.#strObserver = this.#fields.find(
444
+ (field) => field.path.length === path.length && matchesPrefix(field.path, path, path.length)
445
+ );
446
+ this.#strRetain = mode === "keep" && this.#strObserver?.onChunk === void 0;
438
447
  this.#strCap = cap;
439
448
  }
440
449
  /** 字符串里的一个解码后片段;按保留规则累积。 */
@@ -450,6 +459,7 @@ var OversizedRecordParser = class {
450
459
  return;
451
460
  }
452
461
  this.#strLength += text.length;
462
+ this.#strObserver?.onChunk?.(text);
453
463
  if (!this.#strRetain) return;
454
464
  const cap = this.#strCap;
455
465
  if (cap === void 0) {
@@ -546,6 +556,8 @@ var OversizedRecordParser = class {
546
556
  this.#expectColon = true;
547
557
  return;
548
558
  }
559
+ this.#strObserver?.onEnd?.(this.#strLength);
560
+ this.#strObserver = void 0;
549
561
  if (!this.#strRetain) {
550
562
  this.#store(SKIPPED);
551
563
  return;
@@ -574,14 +586,20 @@ ${tail}`;
574
586
  #finishBare() {
575
587
  const text = this.#bare;
576
588
  this.#bare = "";
577
- const { mode } = this.#childMode(false);
589
+ const { mode, path } = this.#childMode(false);
578
590
  let value;
579
591
  if (text === "true") value = true;
580
592
  else if (text === "false") value = false;
581
593
  else if (text === "null") value = null;
582
594
  else if (NUMBER_PATTERN.test(text)) value = Number(text);
583
595
  else this.#fail();
584
- this.#store(mode === "keep" ? value : SKIPPED);
596
+ const observer = this.#fields.find(
597
+ (field) => field.path.length === path.length && matchesPrefix(field.path, path, path.length)
598
+ );
599
+ if (observer?.onScalar !== void 0) {
600
+ observer.onScalar(value);
601
+ this.#store(SKIPPED);
602
+ } else this.#store(mode === "keep" ? value : SKIPPED);
585
603
  }
586
604
  };
587
605
  var SKIPPED = /* @__PURE__ */ Symbol("skipped");
@@ -2692,7 +2710,7 @@ var NativeSessionTail = class {
2692
2710
  // src/index.ts
2693
2711
  var index_default = definePlugin({
2694
2712
  id: "session-import",
2695
- apiVersion: 35,
2713
+ apiVersion: 36,
2696
2714
  activate: (ctx) => {
2697
2715
  ctx.command({
2698
2716
  name: "scan",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ycodium-ai/plugin-session-import",
3
- "version": "0.2.3369",
3
+ "version": "0.2.3377",
4
4
  "description": "Brings a session you started in a terminal into Ycodium.",
5
5
  "keywords": [
6
6
  "session-import",
@@ -20,8 +20,8 @@
20
20
  "effect": "4.0.0-beta.103",
21
21
  "esbuild": "0.28.1",
22
22
  "vite-plus": "0.2.2",
23
- "ycodium-jsonl-stream": "0.0.0",
24
- "@ycodium-ai/plugin-api": "0.2.3369"
23
+ "@ycodium-ai/plugin-api": "0.2.3377",
24
+ "ycodium-jsonl-stream": "0.0.0"
25
25
  },
26
26
  "ycodium": {
27
27
  "plugin": "./dist/index.js",