@remnic/core 9.66.12 → 9.67.0

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 (46) hide show
  1. package/dist/access-admin-ops-surface.d.ts +1 -1
  2. package/dist/access-authorization-probe.d.ts +1 -1
  3. package/dist/access-boundary.d.ts +1 -1
  4. package/dist/access-cli.js +1 -1
  5. package/dist/access-extraction-force-flush.d.ts +1 -1
  6. package/dist/access-http-lcm-compaction.d.ts +1 -1
  7. package/dist/access-http-lifecycle-flush.d.ts +1 -1
  8. package/dist/access-http-offline-stream.d.ts +1 -1
  9. package/dist/access-http.d.ts +2 -2
  10. package/dist/access-lcm-surface.d.ts +1 -1
  11. package/dist/access-mcp.d.ts +1 -1
  12. package/dist/access-observe-write-surface.d.ts +1 -1
  13. package/dist/access-operations.d.ts +6 -6
  14. package/dist/access-recall-concurrency.d.ts +1 -1
  15. package/dist/access-recall-response.d.ts +1 -1
  16. package/dist/access-recall-surface.d.ts +1 -1
  17. package/dist/access-schema.d.ts +89 -89
  18. package/dist/access-service-helpers.d.ts +1 -1
  19. package/dist/access-service.d.ts +1 -1
  20. package/dist/access-surface-catalog.d.ts +1 -1
  21. package/dist/{chunk-GHSJBVVQ.js → chunk-QJLTAH5X.js} +114 -7
  22. package/dist/chunk-QJLTAH5X.js.map +1 -0
  23. package/dist/{cli-Bvy4jdBu.d.ts → cli-CFpMhqz5.d.ts} +1 -1
  24. package/dist/cli.d.ts +2 -2
  25. package/dist/external-wiki-access.d.ts +1 -1
  26. package/dist/external-wiki-mcp-tools.d.ts +1 -1
  27. package/dist/index.d.ts +694 -685
  28. package/dist/index.js +1 -1
  29. package/dist/mcp-memory-inspector-app.d.ts +1 -1
  30. package/dist/memory-subject-cli.d.ts +1 -1
  31. package/dist/memory-subject.d.ts +1 -1
  32. package/dist/orchestrator.js +1 -1
  33. package/dist/{public-http-2MyshWxl.d.ts → public-http-C9-CHc40.d.ts} +1 -1
  34. package/dist/schemas.d.ts +176 -176
  35. package/dist/shared-context/manager.d.ts +6 -6
  36. package/dist/support-passport/index.d.ts +4 -4
  37. package/dist/transfer/types.d.ts +78 -78
  38. package/dist/who-knows-cli.d.ts +1 -1
  39. package/dist/who-knows.d.ts +1 -1
  40. package/package.json +2 -2
  41. package/src/activity/index.ts +1 -0
  42. package/src/activity/journal-section.ts +1 -1
  43. package/src/activity/journal-strip.test.ts +126 -0
  44. package/src/activity/journal-strip.ts +115 -0
  45. package/dist/chunk-GHSJBVVQ.js.map +0 -1
  46. package/dist/{access-service-LbwWl05g.d.ts → access-service-DcfM0Vf0.d.ts} +64 -64
@@ -0,0 +1,115 @@
1
+ /**
2
+ * Strip Remnic-owned regions from a vault journal section (issue #1987).
3
+ *
4
+ * Loop prevention for vault journals: before daily-note text is treated
5
+ * as journal text, every managed marker region and every configured
6
+ * owned heading section is removed, so published output can never
7
+ * re-enter the journal. An unterminated start marker fails closed and
8
+ * strips to the end of the section. Pure string-in/string-out. No
9
+ * filesystem. Heading lines parse through the SAME exported ATX
10
+ * parser the journal-section reader uses, so a heading the reader
11
+ * recognizes is always a heading this stripper strips.
12
+ */
13
+
14
+ import { parseAtxHeading } from "./journal-section.js";
15
+
16
+ const MARKER_OPEN = "<!-- remnic:";
17
+ const MARKER_CLOSE = "-->";
18
+ const START_SUFFIX = ":start";
19
+ const END_SUFFIX = ":end";
20
+
21
+ type RegionMarker = { kind: "start" | "end"; name: string };
22
+
23
+ export function stripRemnicOwnedRegions(
24
+ sectionText: string,
25
+ ownedHeadings: readonly string[],
26
+ ): string {
27
+ return stripOwnedHeadings(stripMarkerRegions(sectionText), ownedHeadings);
28
+ }
29
+
30
+ function stripMarkerRegions(text: string): string {
31
+ const lines = text.split("\n");
32
+ const keep = lines.map(() => true);
33
+ let openName: string | null = null;
34
+ for (let i = 0; i < lines.length; i++) {
35
+ const marker = parseRegionMarker(lines[i]!);
36
+ if (openName !== null) {
37
+ keep[i] = false;
38
+ if (marker && marker.kind === "end" && marker.name === openName) openName = null;
39
+ continue;
40
+ }
41
+ if (marker) {
42
+ keep[i] = false;
43
+ if (marker.kind === "start") openName = marker.name;
44
+ }
45
+ }
46
+ return emitKeptLines(lines, keep);
47
+ }
48
+
49
+ function stripOwnedHeadings(text: string, ownedHeadings: readonly string[]): string {
50
+ const wanted = ownedHeadingSet(ownedHeadings);
51
+ if (wanted.size === 0 || text.length === 0) return text;
52
+ const lines = text.split("\n");
53
+ const keep = lines.map(() => true);
54
+ for (let i = 0; i < lines.length; i++) {
55
+ if (!keep[i]) continue;
56
+ const heading = parseAtxHeading(lines[i]!);
57
+ if (!heading || !wanted.has(heading.text)) continue;
58
+ keep[i] = false;
59
+ for (let j = i + 1; j < lines.length; j++) {
60
+ const next = parseAtxHeading(lines[j]!);
61
+ if (next && next.level <= heading.level) break;
62
+ keep[j] = false;
63
+ }
64
+ }
65
+ return emitKeptLines(lines, keep);
66
+ }
67
+
68
+ /**
69
+ * Emit kept lines, collapsing the one blank line each removal would
70
+ * otherwise double. Text outside removals is preserved byte-for-byte.
71
+ */
72
+ function emitKeptLines(lines: readonly string[], keep: readonly boolean[]): string {
73
+ const out: string[] = [];
74
+ let dropped = false;
75
+ for (let i = 0; i < lines.length; i++) {
76
+ if (!keep[i]) {
77
+ dropped = true;
78
+ continue;
79
+ }
80
+ const line = lines[i]!;
81
+ const previous = out.length > 0 ? out[out.length - 1]! : null;
82
+ if (dropped && previous !== null && previous.trim().length === 0 && line.trim().length === 0) {
83
+ dropped = false;
84
+ continue;
85
+ }
86
+ out.push(line);
87
+ dropped = false;
88
+ }
89
+ return out.join("\n");
90
+ }
91
+
92
+ function parseRegionMarker(line: string): RegionMarker | null {
93
+ const trimmed = line.trim();
94
+ if (!trimmed.startsWith(MARKER_OPEN) || !trimmed.endsWith(MARKER_CLOSE)) return null;
95
+ const inner = trimmed.slice(MARKER_OPEN.length, trimmed.length - MARKER_CLOSE.length).trim();
96
+ if (inner.endsWith(START_SUFFIX)) {
97
+ const name = inner.slice(0, -START_SUFFIX.length);
98
+ return name.length > 0 ? { kind: "start", name } : null;
99
+ }
100
+ if (inner.endsWith(END_SUFFIX)) {
101
+ const name = inner.slice(0, -END_SUFFIX.length);
102
+ return name.length > 0 ? { kind: "end", name } : null;
103
+ }
104
+ return null;
105
+ }
106
+
107
+ function ownedHeadingSet(ownedHeadings: readonly string[]): Set<string> {
108
+ const wanted = new Set<string>();
109
+ for (const entry of ownedHeadings) {
110
+ if (typeof entry !== "string") continue;
111
+ const trimmed = entry.trim();
112
+ if (trimmed.length > 0) wanted.add(trimmed);
113
+ }
114
+ return wanted;
115
+ }