@mneme-ai/core 1.72.0 → 1.74.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.
- package/dist/genesplice/genesplice.test.d.ts +5 -0
- package/dist/genesplice/genesplice.test.d.ts.map +1 -0
- package/dist/genesplice/genesplice.test.js +222 -0
- package/dist/genesplice/genesplice.test.js.map +1 -0
- package/dist/genesplice/genome_recombine.d.ts +61 -0
- package/dist/genesplice/genome_recombine.d.ts.map +1 -0
- package/dist/genesplice/genome_recombine.js +135 -0
- package/dist/genesplice/genome_recombine.js.map +1 -0
- package/dist/genesplice/gist_transmit.d.ts +57 -0
- package/dist/genesplice/gist_transmit.d.ts.map +1 -0
- package/dist/genesplice/gist_transmit.js +87 -0
- package/dist/genesplice/gist_transmit.js.map +1 -0
- package/dist/genesplice/index.d.ts +26 -0
- package/dist/genesplice/index.d.ts.map +1 -0
- package/dist/genesplice/index.js +26 -0
- package/dist/genesplice/index.js.map +1 -0
- package/dist/genesplice/phenotype.d.ts +33 -0
- package/dist/genesplice/phenotype.d.ts.map +1 -0
- package/dist/genesplice/phenotype.js +73 -0
- package/dist/genesplice/phenotype.js.map +1 -0
- package/dist/genesplice/soul_prompt.d.ts +87 -0
- package/dist/genesplice/soul_prompt.d.ts.map +1 -0
- package/dist/genesplice/soul_prompt.js +162 -0
- package/dist/genesplice/soul_prompt.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +23 -0
- package/dist/index.js.map +1 -1
- package/dist/permeate/bookmarklet_generator.d.ts +26 -0
- package/dist/permeate/bookmarklet_generator.d.ts.map +1 -0
- package/dist/permeate/bookmarklet_generator.js +56 -0
- package/dist/permeate/bookmarklet_generator.js.map +1 -0
- package/dist/permeate/editor_integration_map.d.ts +43 -0
- package/dist/permeate/editor_integration_map.d.ts.map +1 -0
- package/dist/permeate/editor_integration_map.js +180 -0
- package/dist/permeate/editor_integration_map.js.map +1 -0
- package/dist/permeate/index.d.ts +25 -0
- package/dist/permeate/index.d.ts.map +1 -0
- package/dist/permeate/index.js +25 -0
- package/dist/permeate/index.js.map +1 -0
- package/dist/permeate/permeate.test.d.ts +5 -0
- package/dist/permeate/permeate.test.d.ts.map +1 -0
- package/dist/permeate/permeate.test.js +141 -0
- package/dist/permeate/permeate.test.js.map +1 -0
- package/dist/permeate/transport_menu.d.ts +35 -0
- package/dist/permeate/transport_menu.d.ts.map +1 -0
- package/dist/permeate/transport_menu.js +96 -0
- package/dist/permeate/transport_menu.js.map +1 -0
- package/dist/permeate/userscript_generator.d.ts +42 -0
- package/dist/permeate/userscript_generator.d.ts.map +1 -0
- package/dist/permeate/userscript_generator.js +170 -0
- package/dist/permeate/userscript_generator.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"genesplice.test.d.ts","sourceRoot":"","sources":["../../src/genesplice/genesplice.test.ts"],"names":[],"mappings":"AAAA;;GAEG"}
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* v1.73.0 -- GENESPLICE PROTOCOL test suite.
|
|
3
|
+
*/
|
|
4
|
+
import { describe, it, expect, beforeEach, afterEach } from "vitest";
|
|
5
|
+
import { mkdtempSync, rmSync } from "node:fs";
|
|
6
|
+
import { tmpdir } from "node:os";
|
|
7
|
+
import { join } from "node:path";
|
|
8
|
+
import { compressToSoulPrompt, parseSoulPrompt } from "./soul_prompt.js";
|
|
9
|
+
import { recombineGenome, uniqueWisdom, consensusWisdom } from "./genome_recombine.js";
|
|
10
|
+
import { packageGist, parseGistUrl, extractSoulFromGist } from "./gist_transmit.js";
|
|
11
|
+
import { expressPhenotype, expressSoulForVendor } from "./phenotype.js";
|
|
12
|
+
import { saveCapsule } from "../diaspora/session_capsule.js";
|
|
13
|
+
function setup() { return mkdtempSync(join(tmpdir(), "mneme-gs-")); }
|
|
14
|
+
function cleanup(r) { try {
|
|
15
|
+
rmSync(r, { recursive: true, force: true });
|
|
16
|
+
}
|
|
17
|
+
catch { /* */ } }
|
|
18
|
+
const sampleCapsule = (vendor, extras = {}) => ({
|
|
19
|
+
id: `cap-${vendor}`,
|
|
20
|
+
capsuleVersion: 1,
|
|
21
|
+
createdAt: new Date().toISOString(),
|
|
22
|
+
originVendor: vendor,
|
|
23
|
+
repoFingerprint: "deadbeefcafefade",
|
|
24
|
+
contextSummary: extras.contextOverride ?? `${vendor} session: investigating auth bug; comparing bcrypt vs argon2`,
|
|
25
|
+
promptTrace: [
|
|
26
|
+
{ ts: new Date(Date.now() - 60000).toISOString(), role: "user", text: "why is login slow" },
|
|
27
|
+
{ ts: new Date(Date.now() - 50000).toISOString(), role: "assistant", text: "bcrypt at cost 12 is the bottleneck" },
|
|
28
|
+
],
|
|
29
|
+
reasoningTrace: [`${vendor} reasoned: hash cost dominates login latency`],
|
|
30
|
+
decisions: extras.decisions ?? ["explore argon2id", "benchmark before switching"],
|
|
31
|
+
hmac: "test-hmac",
|
|
32
|
+
});
|
|
33
|
+
// ─── G1 SOUL PROMPT ──────────────────────────────────────────────────
|
|
34
|
+
describe("v1.73 GeneSplice G1 · Soul Prompt", () => {
|
|
35
|
+
it("compresses to under 500 tokens by default", () => {
|
|
36
|
+
const cap = sampleCapsule("claude");
|
|
37
|
+
const soul = compressToSoulPrompt({ capsule: cap });
|
|
38
|
+
expect(soul.estTokens).toBeLessThanOrEqual(700);
|
|
39
|
+
expect(soul.text).toContain("MNEME SOUL PROMPT");
|
|
40
|
+
expect(soul.text).toContain("claude");
|
|
41
|
+
expect(soul.text).toContain("bcrypt");
|
|
42
|
+
});
|
|
43
|
+
it("HMAC included when secret provided", () => {
|
|
44
|
+
const cap = sampleCapsule("claude");
|
|
45
|
+
const soul = compressToSoulPrompt({ capsule: cap, secret: "test-secret" });
|
|
46
|
+
expect(soul.hmac).toMatch(/^[a-f0-9]{64}$/);
|
|
47
|
+
expect(soul.text).toContain("HMAC:");
|
|
48
|
+
});
|
|
49
|
+
it("parseSoulPrompt round-trips the structured fields", () => {
|
|
50
|
+
const cap = sampleCapsule("claude-opus-4-7", { decisions: ["use argon2id", "deprecate bcrypt"] });
|
|
51
|
+
const soul = compressToSoulPrompt({ capsule: cap, secret: "abc" });
|
|
52
|
+
const parsed = parseSoulPrompt(soul.text, "abc");
|
|
53
|
+
expect(parsed.originVendor).toBe("claude-opus-4-7");
|
|
54
|
+
expect(parsed.decisions.length).toBeGreaterThanOrEqual(1);
|
|
55
|
+
expect(parsed.recentTurns.length).toBeGreaterThanOrEqual(1);
|
|
56
|
+
expect(parsed.verdict).toBe("VALID");
|
|
57
|
+
});
|
|
58
|
+
it("detects tampered HMAC", () => {
|
|
59
|
+
const cap = sampleCapsule("claude");
|
|
60
|
+
const soul = compressToSoulPrompt({ capsule: cap, secret: "abc" });
|
|
61
|
+
const tampered = soul.text.replace("bcrypt", "argon2");
|
|
62
|
+
const parsed = parseSoulPrompt(tampered, "abc");
|
|
63
|
+
expect(parsed.verdict).toBe("INVALID_HMAC");
|
|
64
|
+
});
|
|
65
|
+
it("MALFORMED on random text", () => {
|
|
66
|
+
const parsed = parseSoulPrompt("just some random message");
|
|
67
|
+
expect(parsed.verdict).toBe("MALFORMED");
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
// ─── G2 GENOME RECOMBINATION ─────────────────────────────────────────
|
|
71
|
+
describe("v1.73 GeneSplice G2 · Genome Recombination", () => {
|
|
72
|
+
it("merges N capsules into a hybrid", () => {
|
|
73
|
+
const claude = sampleCapsule("claude", { decisions: ["use argon2id", "benchmark first"] });
|
|
74
|
+
const gemini = sampleCapsule("gemini", { decisions: ["use argon2id", "audit bcrypt callers"] });
|
|
75
|
+
const hybrid = recombineGenome({ capsules: [claude, gemini] });
|
|
76
|
+
expect(hybrid.sources.length).toBe(2);
|
|
77
|
+
expect(hybrid.decisions.length).toBeGreaterThan(0);
|
|
78
|
+
expect(hybrid.contextSummary).toContain("claude");
|
|
79
|
+
expect(hybrid.contextSummary).toContain("gemini");
|
|
80
|
+
});
|
|
81
|
+
it("consensusWisdom finds decisions multiple vendors agreed on", () => {
|
|
82
|
+
const claude = sampleCapsule("claude", { decisions: ["use argon2id is safer"] });
|
|
83
|
+
const gemini = sampleCapsule("gemini", { decisions: ["use argon2id safer choice"] });
|
|
84
|
+
const hybrid = recombineGenome({ capsules: [claude, gemini] });
|
|
85
|
+
const consensus = consensusWisdom(hybrid);
|
|
86
|
+
expect(consensus.length).toBeGreaterThanOrEqual(1);
|
|
87
|
+
expect(consensus[0].vendors.length).toBeGreaterThanOrEqual(2);
|
|
88
|
+
});
|
|
89
|
+
it("uniqueWisdom finds vendor-specific decisions", () => {
|
|
90
|
+
const claude = sampleCapsule("claude", { decisions: ["use argon2id", "add CSRF tokens"] });
|
|
91
|
+
const gemini = sampleCapsule("gemini", { decisions: ["use argon2id", "enable rate limiting"] });
|
|
92
|
+
const hybrid = recombineGenome({ capsules: [claude, gemini] });
|
|
93
|
+
const unique = uniqueWisdom(hybrid);
|
|
94
|
+
// Each vendor should have at least one unique decision
|
|
95
|
+
expect(unique["claude"] || unique["gemini"]).toBeDefined();
|
|
96
|
+
});
|
|
97
|
+
it("merges promptTrace chronologically", () => {
|
|
98
|
+
const claude = sampleCapsule("claude");
|
|
99
|
+
const gemini = sampleCapsule("gemini");
|
|
100
|
+
const hybrid = recombineGenome({ capsules: [claude, gemini] });
|
|
101
|
+
for (let i = 1; i < hybrid.promptTrace.length; i++) {
|
|
102
|
+
expect(hybrid.promptTrace[i - 1].ts <= hybrid.promptTrace[i].ts).toBe(true);
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
it("empty input returns empty hybrid", () => {
|
|
106
|
+
const hybrid = recombineGenome({ capsules: [] });
|
|
107
|
+
expect(hybrid.sources.length).toBe(0);
|
|
108
|
+
expect(hybrid.decisions.length).toBe(0);
|
|
109
|
+
});
|
|
110
|
+
});
|
|
111
|
+
// ─── G3 GIST BRAIN TRANSFER ──────────────────────────────────────────
|
|
112
|
+
describe("v1.73 GeneSplice G3 · Gist Brain Transfer", () => {
|
|
113
|
+
it("packageGist wraps soul prompt in gist-ready content", () => {
|
|
114
|
+
const cap = sampleCapsule("claude");
|
|
115
|
+
const pkg = packageGist({ capsule: cap });
|
|
116
|
+
expect(pkg.content).toContain("MNEME SOUL PROMPT");
|
|
117
|
+
expect(pkg.content).toContain("mneme://gist");
|
|
118
|
+
expect(pkg.filename).toMatch(/\.md$/);
|
|
119
|
+
expect(pkg.instructions.length).toBeGreaterThan(0);
|
|
120
|
+
});
|
|
121
|
+
it("extractSoulFromGist recovers the soul", () => {
|
|
122
|
+
const cap = sampleCapsule("claude");
|
|
123
|
+
const pkg = packageGist({ capsule: cap });
|
|
124
|
+
const recovered = extractSoulFromGist(pkg.content);
|
|
125
|
+
expect(recovered).not.toBeNull();
|
|
126
|
+
expect(recovered).toContain("MNEME SOUL PROMPT");
|
|
127
|
+
});
|
|
128
|
+
it("parseGistUrl handles raw + web variants", () => {
|
|
129
|
+
const raw = parseGistUrl("https://gist.githubusercontent.com/user/abc123def/raw/sha/file.md");
|
|
130
|
+
expect(raw.gistId).toBe("abc123def");
|
|
131
|
+
expect(raw.isRaw).toBe(true);
|
|
132
|
+
const web = parseGistUrl("https://gist.github.com/user/abc123def");
|
|
133
|
+
expect(web.gistId).toBe("abc123def");
|
|
134
|
+
expect(web.isRaw).toBe(false);
|
|
135
|
+
const bad = parseGistUrl("https://example.com");
|
|
136
|
+
expect(bad.gistId).toBeNull();
|
|
137
|
+
});
|
|
138
|
+
it("accepts a hybrid capsule via adapter", () => {
|
|
139
|
+
const claude = sampleCapsule("claude");
|
|
140
|
+
const gemini = sampleCapsule("gemini");
|
|
141
|
+
const hybrid = recombineGenome({ capsules: [claude, gemini] });
|
|
142
|
+
const pkg = packageGist({ capsule: hybrid });
|
|
143
|
+
expect(pkg.content).toContain("hybrid:claude+gemini");
|
|
144
|
+
});
|
|
145
|
+
});
|
|
146
|
+
// ─── G5 PHENOTYPE EXPRESSION ─────────────────────────────────────────
|
|
147
|
+
describe("v1.73 GeneSplice G5 · Phenotype Expression", () => {
|
|
148
|
+
it("expresses Gemini as structured", () => {
|
|
149
|
+
const ph = expressPhenotype("gemini-pro", "claude");
|
|
150
|
+
expect(ph.style).toBe("structured");
|
|
151
|
+
expect(ph.openingLine).toContain("Resumed");
|
|
152
|
+
});
|
|
153
|
+
it("expresses GPT as verbose", () => {
|
|
154
|
+
const ph = expressPhenotype("gpt-4", "claude");
|
|
155
|
+
expect(ph.style).toBe("verbose");
|
|
156
|
+
});
|
|
157
|
+
it("expresses Cursor/Codex as terse", () => {
|
|
158
|
+
expect(expressPhenotype("cursor", "claude").style).toBe("terse");
|
|
159
|
+
expect(expressPhenotype("codex", "claude").style).toBe("terse");
|
|
160
|
+
});
|
|
161
|
+
it("falls back to balanced for unknown vendor", () => {
|
|
162
|
+
const ph = expressPhenotype("some-unknown-vendor", "claude");
|
|
163
|
+
expect(ph.style).toBe("balanced");
|
|
164
|
+
});
|
|
165
|
+
it("expressSoulForVendor wraps soul prompt with phenotype", () => {
|
|
166
|
+
const cap = sampleCapsule("claude");
|
|
167
|
+
const soul = compressToSoulPrompt({ capsule: cap });
|
|
168
|
+
const expressed = expressSoulForVendor(soul.text, "gemini-pro", "claude");
|
|
169
|
+
expect(expressed).toContain("PHENOTYPE INSTRUCTIONS");
|
|
170
|
+
expect(expressed).toContain("structured");
|
|
171
|
+
});
|
|
172
|
+
});
|
|
173
|
+
// ─── End-to-end demo: claude session -> gemini paste ────────────────
|
|
174
|
+
describe("v1.73 GeneSplice · END-TO-END brain transfer (no install)", () => {
|
|
175
|
+
let r;
|
|
176
|
+
beforeEach(() => { r = setup(); });
|
|
177
|
+
afterEach(() => cleanup(r));
|
|
178
|
+
it("claude session -> soul prompt -> Gemini phenotype -> resume works", () => {
|
|
179
|
+
// Step 1: Vendor A (claude) saves a capsule
|
|
180
|
+
const cap = saveCapsule(r, {
|
|
181
|
+
vendor: "claude-opus-4-7",
|
|
182
|
+
contextSummary: "Investigating performance bug in auth.ts; user wants to compare bcrypt to argon2id",
|
|
183
|
+
promptTrace: [
|
|
184
|
+
{ ts: new Date().toISOString(), role: "user", text: "why is login slow?" },
|
|
185
|
+
{ ts: new Date().toISOString(), role: "assistant", text: "auth.ts uses bcrypt cost 12; argon2id is faster" },
|
|
186
|
+
],
|
|
187
|
+
decisions: ["benchmark argon2id before switching", "audit all bcrypt callers"],
|
|
188
|
+
reasoningTrace: ["hash function cost dominates login p95"],
|
|
189
|
+
});
|
|
190
|
+
// Step 2: Compress to soul prompt
|
|
191
|
+
const soul = compressToSoulPrompt({ capsule: cap, secret: "test-cluster-secret" });
|
|
192
|
+
expect(soul.estTokens).toBeLessThan(800);
|
|
193
|
+
// Step 3: Express for Gemini
|
|
194
|
+
const geminiSoul = expressSoulForVendor(soul.text, "gemini-pro", "claude-opus-4-7");
|
|
195
|
+
expect(geminiSoul).toContain("Resumed from claude-opus-4-7");
|
|
196
|
+
expect(geminiSoul).toContain("structured");
|
|
197
|
+
// Step 4: Simulate Gemini paste -> parse the soul
|
|
198
|
+
const parsed = parseSoulPrompt(geminiSoul, "test-cluster-secret");
|
|
199
|
+
expect(parsed.originVendor).toBe("claude-opus-4-7");
|
|
200
|
+
expect(parsed.decisions.length).toBeGreaterThan(0);
|
|
201
|
+
expect(parsed.verdict).toBe("VALID");
|
|
202
|
+
});
|
|
203
|
+
it("hybrid: claude + gemini -> super-genome with consensus + unique wisdom", () => {
|
|
204
|
+
const claudeCap = saveCapsule(r, {
|
|
205
|
+
vendor: "claude",
|
|
206
|
+
contextSummary: "auth refactor",
|
|
207
|
+
promptTrace: [],
|
|
208
|
+
decisions: ["use argon2id", "add CSRF protection"],
|
|
209
|
+
});
|
|
210
|
+
const geminiCap = saveCapsule(r, {
|
|
211
|
+
vendor: "gemini",
|
|
212
|
+
contextSummary: "auth refactor analysis",
|
|
213
|
+
promptTrace: [],
|
|
214
|
+
decisions: ["use argon2id", "enable rate limiting"],
|
|
215
|
+
});
|
|
216
|
+
const hybrid = recombineGenome({ capsules: [claudeCap, geminiCap] });
|
|
217
|
+
expect(hybrid.sources.length).toBe(2);
|
|
218
|
+
const consensus = consensusWisdom(hybrid);
|
|
219
|
+
expect(consensus.length).toBeGreaterThanOrEqual(1); // "use argon2id" was in both
|
|
220
|
+
});
|
|
221
|
+
});
|
|
222
|
+
//# sourceMappingURL=genesplice.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"genesplice.test.js","sourceRoot":"","sources":["../../src/genesplice/genesplice.test.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AACrE,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACzE,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACvF,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AACpF,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AACxE,OAAO,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAE7D,SAAS,KAAK,KAAa,OAAO,WAAW,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC;AAC7E,SAAS,OAAO,CAAC,CAAS,IAAI,IAAI,CAAC;IAAC,MAAM,CAAC,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAAC,C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
|
+
/**
|
|
2
|
+
* v1.73.0 -- GENESPLICE G2: GENOME RECOMBINATION.
|
|
3
|
+
*
|
|
4
|
+
* Take N capsules from N different vendors. Merge them into a single
|
|
5
|
+
* SUPER-GENOME that's smarter than any individual vendor history.
|
|
6
|
+
*
|
|
7
|
+
* Algorithm (CRDT-ish):
|
|
8
|
+
* 1. Concatenate decisions; dedup by lowercase prefix-similarity
|
|
9
|
+
* 2. Merge promptTrace by timestamp (chronological order across vendors)
|
|
10
|
+
* 3. Reasoning trace: union, attribute each step to its source vendor
|
|
11
|
+
* 4. ContextSummary: weighted concat (each vendor gets equal share)
|
|
12
|
+
* 5. New superGenome.originVendor = "hybrid:A+B+C"
|
|
13
|
+
*
|
|
14
|
+
* This is the "genetic engineering" the user asked for: gene-splicing
|
|
15
|
+
* AI brains across vendors so the result inherits each vendor's
|
|
16
|
+
* strengths.
|
|
17
|
+
*/
|
|
18
|
+
import type { SessionCapsule, CapsulePromptStep } from "../diaspora/session_capsule.js";
|
|
19
|
+
export interface RecombineInput {
|
|
20
|
+
capsules: SessionCapsule[];
|
|
21
|
+
/** How many recent turns to keep per vendor in the hybrid trace. */
|
|
22
|
+
turnsPerVendor?: number;
|
|
23
|
+
/** Cluster secret for verifying source capsules' HMAC (best-effort). */
|
|
24
|
+
verifySecret?: string;
|
|
25
|
+
}
|
|
26
|
+
export interface HybridCapsule {
|
|
27
|
+
id: string;
|
|
28
|
+
hybridVersion: 1;
|
|
29
|
+
/** Source vendor list. */
|
|
30
|
+
sources: Array<{
|
|
31
|
+
vendor: string;
|
|
32
|
+
capsuleId: string;
|
|
33
|
+
}>;
|
|
34
|
+
createdAt: string;
|
|
35
|
+
contextSummary: string;
|
|
36
|
+
decisions: string[];
|
|
37
|
+
promptTrace: Array<CapsulePromptStep & {
|
|
38
|
+
sourceVendor: string;
|
|
39
|
+
}>;
|
|
40
|
+
reasoningTrace: Array<{
|
|
41
|
+
text: string;
|
|
42
|
+
sourceVendor: string;
|
|
43
|
+
}>;
|
|
44
|
+
/** Number of agreement votes per fact (Chromosomal Crossover; G4). */
|
|
45
|
+
agreementMap: Record<string, {
|
|
46
|
+
vendors: string[];
|
|
47
|
+
count: number;
|
|
48
|
+
}>;
|
|
49
|
+
/** Plain-English headline. */
|
|
50
|
+
headline: string;
|
|
51
|
+
}
|
|
52
|
+
export declare function recombineGenome(input: RecombineInput): HybridCapsule;
|
|
53
|
+
/** Find decisions that ONLY one vendor made (unique-to-vendor wisdom).
|
|
54
|
+
* Useful for "what does Claude see that Gemini missed?" */
|
|
55
|
+
export declare function uniqueWisdom(hybrid: HybridCapsule): Record<string, string[]>;
|
|
56
|
+
/** Find decisions where MULTIPLE vendors agreed (high-trust facts). */
|
|
57
|
+
export declare function consensusWisdom(hybrid: HybridCapsule): Array<{
|
|
58
|
+
decision: string;
|
|
59
|
+
vendors: string[];
|
|
60
|
+
}>;
|
|
61
|
+
//# sourceMappingURL=genome_recombine.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"genome_recombine.d.ts","sourceRoot":"","sources":["../../src/genesplice/genome_recombine.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAGH,OAAO,KAAK,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AAExF,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE,cAAc,EAAE,CAAC;IAC3B,oEAAoE;IACpE,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,wEAAwE;IACxE,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,aAAa,EAAE,CAAC,CAAC;IACjB,0BAA0B;IAC1B,OAAO,EAAE,KAAK,CAAC;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACtD,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,MAAM,CAAC;IACvB,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,WAAW,EAAE,KAAK,CAAC,iBAAiB,GAAG;QAAE,YAAY,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACjE,cAAc,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,YAAY,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC9D,sEAAsE;IACtE,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE;QAAE,OAAO,EAAE,MAAM,EAAE,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACnE,8BAA8B;IAC9B,QAAQ,EAAE,MAAM,CAAC;CAClB;AA4BD,wBAAgB,eAAe,CAAC,KAAK,EAAE,cAAc,GAAG,aAAa,CAuEpE;AAED;4DAC4D;AAC5D,wBAAgB,YAAY,CAAC,MAAM,EAAE,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAU5E;AAED,uEAAuE;AACvE,wBAAgB,eAAe,CAAC,MAAM,EAAE,aAAa,GAAG,KAAK,CAAC;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC,CAMrG"}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* v1.73.0 -- GENESPLICE G2: GENOME RECOMBINATION.
|
|
3
|
+
*
|
|
4
|
+
* Take N capsules from N different vendors. Merge them into a single
|
|
5
|
+
* SUPER-GENOME that's smarter than any individual vendor history.
|
|
6
|
+
*
|
|
7
|
+
* Algorithm (CRDT-ish):
|
|
8
|
+
* 1. Concatenate decisions; dedup by lowercase prefix-similarity
|
|
9
|
+
* 2. Merge promptTrace by timestamp (chronological order across vendors)
|
|
10
|
+
* 3. Reasoning trace: union, attribute each step to its source vendor
|
|
11
|
+
* 4. ContextSummary: weighted concat (each vendor gets equal share)
|
|
12
|
+
* 5. New superGenome.originVendor = "hybrid:A+B+C"
|
|
13
|
+
*
|
|
14
|
+
* This is the "genetic engineering" the user asked for: gene-splicing
|
|
15
|
+
* AI brains across vendors so the result inherits each vendor's
|
|
16
|
+
* strengths.
|
|
17
|
+
*/
|
|
18
|
+
import { createHash } from "node:crypto";
|
|
19
|
+
function tokenize(s) {
|
|
20
|
+
return new Set((s.toLowerCase().match(/[a-z][a-z0-9_-]+/g) ?? []).filter((t) => t.length >= 3));
|
|
21
|
+
}
|
|
22
|
+
function jaccardSim(a, b) {
|
|
23
|
+
if (a.size === 0 || b.size === 0)
|
|
24
|
+
return 0;
|
|
25
|
+
let inter = 0;
|
|
26
|
+
for (const x of a)
|
|
27
|
+
if (b.has(x))
|
|
28
|
+
inter += 1;
|
|
29
|
+
return inter / (a.size + b.size - inter);
|
|
30
|
+
}
|
|
31
|
+
function dedupSimilar(items, threshold = 0.6) {
|
|
32
|
+
const groups = [];
|
|
33
|
+
for (const item of items) {
|
|
34
|
+
const tokens = tokenize(item.text);
|
|
35
|
+
const match = groups.find((g) => jaccardSim(g.tokens, tokens) >= threshold);
|
|
36
|
+
if (match) {
|
|
37
|
+
if (!match.vendors.includes(item.vendor))
|
|
38
|
+
match.vendors.push(item.vendor);
|
|
39
|
+
match.count += 1;
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
groups.push({ text: item.text, tokens, vendors: [item.vendor], count: 1 });
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return groups.map(({ text, vendors, count }) => ({ text, vendors, count }));
|
|
46
|
+
}
|
|
47
|
+
export function recombineGenome(input) {
|
|
48
|
+
const { capsules } = input;
|
|
49
|
+
const turnsPerVendor = input.turnsPerVendor ?? 5;
|
|
50
|
+
if (capsules.length === 0) {
|
|
51
|
+
return {
|
|
52
|
+
id: "empty",
|
|
53
|
+
hybridVersion: 1,
|
|
54
|
+
sources: [], createdAt: new Date().toISOString(),
|
|
55
|
+
contextSummary: "", decisions: [], promptTrace: [], reasoningTrace: [],
|
|
56
|
+
agreementMap: {},
|
|
57
|
+
headline: "No source capsules to recombine.",
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
const sources = capsules.map((c) => ({ vendor: c.originVendor, capsuleId: c.id }));
|
|
61
|
+
// 1. ContextSummary: equal-share concat.
|
|
62
|
+
const ctxParts = [];
|
|
63
|
+
for (const c of capsules) {
|
|
64
|
+
ctxParts.push(`[${c.originVendor}]: ${c.contextSummary}`);
|
|
65
|
+
}
|
|
66
|
+
const contextSummary = ctxParts.join("\n\n");
|
|
67
|
+
// 2. Decisions: dedup similar entries, keep agreement counts.
|
|
68
|
+
const allDecisionItems = [];
|
|
69
|
+
for (const c of capsules) {
|
|
70
|
+
for (const d of c.decisions ?? [])
|
|
71
|
+
allDecisionItems.push({ text: d, vendor: c.originVendor });
|
|
72
|
+
}
|
|
73
|
+
const dedupedDecisions = dedupSimilar(allDecisionItems);
|
|
74
|
+
const decisions = dedupedDecisions.map((d) => d.vendors.length > 1
|
|
75
|
+
? `${d.text} (${d.vendors.length} vendors: ${d.vendors.join(", ")})`
|
|
76
|
+
: `${d.text} (${d.vendors[0]})`);
|
|
77
|
+
const agreementMap = {};
|
|
78
|
+
for (const d of dedupedDecisions) {
|
|
79
|
+
agreementMap[d.text.slice(0, 60)] = { vendors: d.vendors, count: d.count };
|
|
80
|
+
}
|
|
81
|
+
// 3. PromptTrace: chronological merge, last N per vendor.
|
|
82
|
+
const tracePerVendor = new Map();
|
|
83
|
+
for (const c of capsules) {
|
|
84
|
+
tracePerVendor.set(c.originVendor, c.promptTrace.slice(-turnsPerVendor).map((s) => ({ ...s, sourceVendor: c.originVendor })));
|
|
85
|
+
}
|
|
86
|
+
const mergedTrace = [...tracePerVendor.values()].flat().sort((a, b) => a.ts.localeCompare(b.ts));
|
|
87
|
+
// 4. Reasoning trace: union, attribute.
|
|
88
|
+
const reasoning = [];
|
|
89
|
+
for (const c of capsules) {
|
|
90
|
+
for (const r of c.reasoningTrace ?? [])
|
|
91
|
+
reasoning.push({ text: r, sourceVendor: c.originVendor });
|
|
92
|
+
}
|
|
93
|
+
const ts = new Date().toISOString();
|
|
94
|
+
const hybridId = createHash("sha256")
|
|
95
|
+
.update(sources.map((s) => s.capsuleId).join("|"))
|
|
96
|
+
.update(ts)
|
|
97
|
+
.digest("hex").slice(0, 16);
|
|
98
|
+
const headline = `Hybrid genome from ${sources.length} vendor(s): ${sources.map((s) => s.vendor).join(" + ")}. ${decisions.length} decision(s), ${mergedTrace.length} turn(s).`;
|
|
99
|
+
return {
|
|
100
|
+
id: hybridId,
|
|
101
|
+
hybridVersion: 1,
|
|
102
|
+
sources,
|
|
103
|
+
createdAt: ts,
|
|
104
|
+
contextSummary,
|
|
105
|
+
decisions,
|
|
106
|
+
promptTrace: mergedTrace,
|
|
107
|
+
reasoningTrace: reasoning,
|
|
108
|
+
agreementMap,
|
|
109
|
+
headline,
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
/** Find decisions that ONLY one vendor made (unique-to-vendor wisdom).
|
|
113
|
+
* Useful for "what does Claude see that Gemini missed?" */
|
|
114
|
+
export function uniqueWisdom(hybrid) {
|
|
115
|
+
const out = {};
|
|
116
|
+
for (const [decision, agreement] of Object.entries(hybrid.agreementMap)) {
|
|
117
|
+
if (agreement.vendors.length === 1) {
|
|
118
|
+
const v = agreement.vendors[0];
|
|
119
|
+
if (!out[v])
|
|
120
|
+
out[v] = [];
|
|
121
|
+
out[v].push(decision);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
return out;
|
|
125
|
+
}
|
|
126
|
+
/** Find decisions where MULTIPLE vendors agreed (high-trust facts). */
|
|
127
|
+
export function consensusWisdom(hybrid) {
|
|
128
|
+
const out = [];
|
|
129
|
+
for (const [decision, agreement] of Object.entries(hybrid.agreementMap)) {
|
|
130
|
+
if (agreement.vendors.length >= 2)
|
|
131
|
+
out.push({ decision, vendors: agreement.vendors });
|
|
132
|
+
}
|
|
133
|
+
return out;
|
|
134
|
+
}
|
|
135
|
+
//# sourceMappingURL=genome_recombine.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"genome_recombine.js","sourceRoot":"","sources":["../../src/genesplice/genome_recombine.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AA2BzC,SAAS,QAAQ,CAAC,CAAS;IACzB,OAAO,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,mBAAmB,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,IAAI,CAAC,CAAC,CAAC,CAAC;AAClG,CAAC;AAED,SAAS,UAAU,CAAC,CAAc,EAAE,CAAc;IAChD,IAAI,CAAC,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,KAAK,CAAC;QAAE,OAAO,CAAC,CAAC;IAC3C,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,KAAK,MAAM,CAAC,IAAI,CAAC;QAAE,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;YAAE,KAAK,IAAI,CAAC,CAAC;IAC5C,OAAO,KAAK,GAAG,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,IAAI,GAAG,KAAK,CAAC,CAAC;AAC3C,CAAC;AAED,SAAS,YAAY,CAAC,KAA8C,EAAE,SAAS,GAAG,GAAG;IACnF,MAAM,MAAM,GAAmF,EAAE,CAAC;IAClG,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,MAAM,MAAM,GAAG,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACnC,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,IAAI,SAAS,CAAC,C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AAE,SAAS,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,EAAE,CAAC;QACxE,IAAI,SAAS,CAAC,OAAO,CAAC,MAAM,IAAI,CAAC;YAAE,GAAG,CAAC,IAAI,CAAC,EAAE,QAAQ,EAAE,OAAO,EAAE,SAAS,CAAC,OAAO,EAAE,CAAC,CAAC;IACxF,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* v1.73.0 -- GENESPLICE G3: GIST BRAIN TRANSFER.
|
|
3
|
+
*
|
|
4
|
+
* Wild idea: user uploads soul-prompt to their OWN GitHub Gist
|
|
5
|
+
* (private or public). The Gist URL becomes the user-owned "brain
|
|
6
|
+
* cloud" -- portable across any AI tool that can `fetch()` or
|
|
7
|
+
* accept a URL.
|
|
8
|
+
*
|
|
9
|
+
* Why this is paradigm-shifting:
|
|
10
|
+
* - NO Mneme cloud needed (user owns their data)
|
|
11
|
+
* - NO API key needed (user creates gist via web UI)
|
|
12
|
+
* - ANY AI that supports tool-use can `fetch()` the gist
|
|
13
|
+
* - HMAC-signed = tamper-evident
|
|
14
|
+
*
|
|
15
|
+
* This module:
|
|
16
|
+
* - PACKAGES a capsule into a single text blob suitable for
|
|
17
|
+
* pasting into a new GitHub Gist
|
|
18
|
+
* - Provides a uri scheme: `mneme://gist/<gistId>?key=<hmac>`
|
|
19
|
+
* that AI agents resolve via the OpenAPI bridge
|
|
20
|
+
* - Does NOT directly upload (we don't ask for user's GitHub
|
|
21
|
+
* token; user pastes via gist.github.com UI manually)
|
|
22
|
+
*/
|
|
23
|
+
import type { SessionCapsule } from "../diaspora/session_capsule.js";
|
|
24
|
+
import type { HybridCapsule } from "./genome_recombine.js";
|
|
25
|
+
export interface GistTransmitInput {
|
|
26
|
+
/** Either a raw capsule or a hybrid capsule. */
|
|
27
|
+
capsule: SessionCapsule | HybridCapsule;
|
|
28
|
+
secret?: string;
|
|
29
|
+
/** Gist filename. Default: mneme-soul-<id>.md */
|
|
30
|
+
filename?: string;
|
|
31
|
+
}
|
|
32
|
+
export interface GistPackage {
|
|
33
|
+
/** Text blob -- paste into gist.github.com. */
|
|
34
|
+
content: string;
|
|
35
|
+
/** Suggested filename. */
|
|
36
|
+
filename: string;
|
|
37
|
+
/** Soul prompt id. */
|
|
38
|
+
id: string;
|
|
39
|
+
/** Step-by-step instructions printed to user. */
|
|
40
|
+
instructions: string[];
|
|
41
|
+
/** mneme:// URI to embed in receiving AI agents (after gist is created
|
|
42
|
+
* the user replaces <gistId> with their actual gist id). */
|
|
43
|
+
mnemeUri: string;
|
|
44
|
+
}
|
|
45
|
+
export declare function packageGist(input: GistTransmitInput): GistPackage;
|
|
46
|
+
/** Parse a gist URL (raw.githubusercontent.com or gist.github.com/api).
|
|
47
|
+
* Returns the gist id + filename hint for clients that need to fetch. */
|
|
48
|
+
export interface ParsedGistUrl {
|
|
49
|
+
gistId: string | null;
|
|
50
|
+
rawUrl: string;
|
|
51
|
+
isRaw: boolean;
|
|
52
|
+
}
|
|
53
|
+
export declare function parseGistUrl(url: string): ParsedGistUrl;
|
|
54
|
+
/** Given raw gist content (the same text we packaged), extract the soul
|
|
55
|
+
* prompt body for re-ingestion in the receiving AI. */
|
|
56
|
+
export declare function extractSoulFromGist(gistContent: string): string | null;
|
|
57
|
+
//# sourceMappingURL=gist_transmit.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gist_transmit.d.ts","sourceRoot":"","sources":["../../src/genesplice/gist_transmit.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAIH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AACrE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAE3D,MAAM,WAAW,iBAAiB;IAChC,gDAAgD;IAChD,OAAO,EAAE,cAAc,GAAG,aAAa,CAAC;IACxC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,iDAAiD;IACjD,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,WAAW;IAC1B,+CAA+C;IAC/C,OAAO,EAAE,MAAM,CAAC;IAChB,0BAA0B;IAC1B,QAAQ,EAAE,MAAM,CAAC;IACjB,sBAAsB;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,iDAAiD;IACjD,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB;iEAC6D;IAC7D,QAAQ,EAAE,MAAM,CAAC;CAClB;AAqBD,wBAAgB,WAAW,CAAC,KAAK,EAAE,iBAAiB,GAAG,WAAW,CAyBjE;AAED;0EAC0E;AAC1E,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,OAAO,CAAC;CAChB;AACD,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,aAAa,CAQvD;AAED;wDACwD;AACxD,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAMtE"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* v1.73.0 -- GENESPLICE G3: GIST BRAIN TRANSFER.
|
|
3
|
+
*
|
|
4
|
+
* Wild idea: user uploads soul-prompt to their OWN GitHub Gist
|
|
5
|
+
* (private or public). The Gist URL becomes the user-owned "brain
|
|
6
|
+
* cloud" -- portable across any AI tool that can `fetch()` or
|
|
7
|
+
* accept a URL.
|
|
8
|
+
*
|
|
9
|
+
* Why this is paradigm-shifting:
|
|
10
|
+
* - NO Mneme cloud needed (user owns their data)
|
|
11
|
+
* - NO API key needed (user creates gist via web UI)
|
|
12
|
+
* - ANY AI that supports tool-use can `fetch()` the gist
|
|
13
|
+
* - HMAC-signed = tamper-evident
|
|
14
|
+
*
|
|
15
|
+
* This module:
|
|
16
|
+
* - PACKAGES a capsule into a single text blob suitable for
|
|
17
|
+
* pasting into a new GitHub Gist
|
|
18
|
+
* - Provides a uri scheme: `mneme://gist/<gistId>?key=<hmac>`
|
|
19
|
+
* that AI agents resolve via the OpenAPI bridge
|
|
20
|
+
* - Does NOT directly upload (we don't ask for user's GitHub
|
|
21
|
+
* token; user pastes via gist.github.com UI manually)
|
|
22
|
+
*/
|
|
23
|
+
import { compressToSoulPrompt } from "./soul_prompt.js";
|
|
24
|
+
function asSessionCapsule(c) {
|
|
25
|
+
// Hybrid -> session-shaped adapter
|
|
26
|
+
if ("hybridVersion" in c) {
|
|
27
|
+
return {
|
|
28
|
+
id: c.id,
|
|
29
|
+
capsuleVersion: 1,
|
|
30
|
+
createdAt: c.createdAt,
|
|
31
|
+
originVendor: `hybrid:${c.sources.map((s) => s.vendor).join("+")}`,
|
|
32
|
+
repoFingerprint: "hybrid",
|
|
33
|
+
contextSummary: c.contextSummary,
|
|
34
|
+
promptTrace: c.promptTrace.map((p) => ({ ts: p.ts, role: p.role, text: p.text })),
|
|
35
|
+
reasoningTrace: c.reasoningTrace.map((r) => r.text),
|
|
36
|
+
decisions: c.decisions,
|
|
37
|
+
hmac: "hybrid-no-hmac",
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
return c;
|
|
41
|
+
}
|
|
42
|
+
export function packageGist(input) {
|
|
43
|
+
const cap = asSessionCapsule(input.capsule);
|
|
44
|
+
const soul = compressToSoulPrompt({ capsule: cap, secret: input.secret });
|
|
45
|
+
const filename = input.filename ?? `mneme-soul-${soul.id}.md`;
|
|
46
|
+
const wrapper = [
|
|
47
|
+
`<!-- mneme://gist format-version=1 id=${soul.id} -->`,
|
|
48
|
+
"",
|
|
49
|
+
soul.text,
|
|
50
|
+
"",
|
|
51
|
+
"<!-- end mneme://gist -->",
|
|
52
|
+
].join("\n");
|
|
53
|
+
const instructions = [
|
|
54
|
+
"1. Open https://gist.github.com/new",
|
|
55
|
+
`2. Set filename: ${filename}`,
|
|
56
|
+
"3. Paste the content above",
|
|
57
|
+
"4. (Optional) Set visibility to 'secret' for private brain transfer",
|
|
58
|
+
"5. Click 'Create gist'",
|
|
59
|
+
"6. Copy the gist URL (raw URL works best for AI fetching)",
|
|
60
|
+
`7. Tell ANY AI in another chat: "Resume Mneme soul from this gist: <paste-url>"`,
|
|
61
|
+
];
|
|
62
|
+
const mnemeUri = `mneme://gist/<paste-gist-id-here>?soul=${soul.id}`;
|
|
63
|
+
return { content: wrapper, filename, id: soul.id, instructions, mnemeUri };
|
|
64
|
+
}
|
|
65
|
+
export function parseGistUrl(url) {
|
|
66
|
+
// raw.githubusercontent.com/<user>/<gistId>/raw/<sha>/<filename>
|
|
67
|
+
const rawMatch = url.match(/gist\.githubusercontent\.com\/[^/]+\/([a-f0-9]+)\//);
|
|
68
|
+
if (rawMatch)
|
|
69
|
+
return { gistId: rawMatch[1], rawUrl: url, isRaw: true };
|
|
70
|
+
// gist.github.com/<user>/<gistId>
|
|
71
|
+
const webMatch = url.match(/gist\.github\.com\/[^/]+\/([a-f0-9]+)/);
|
|
72
|
+
if (webMatch)
|
|
73
|
+
return { gistId: webMatch[1], rawUrl: url, isRaw: false };
|
|
74
|
+
return { gistId: null, rawUrl: url, isRaw: false };
|
|
75
|
+
}
|
|
76
|
+
/** Given raw gist content (the same text we packaged), extract the soul
|
|
77
|
+
* prompt body for re-ingestion in the receiving AI. */
|
|
78
|
+
export function extractSoulFromGist(gistContent) {
|
|
79
|
+
const m = gistContent.match(/<!-- mneme:\/\/gist[^>]*-->\s*([\s\S]*?)\s*<!-- end mneme:\/\/gist -->/);
|
|
80
|
+
if (m)
|
|
81
|
+
return m[1];
|
|
82
|
+
// Fallback: maybe user pasted just the soul prompt without wrappers
|
|
83
|
+
if (gistContent.includes("MNEME SOUL PROMPT"))
|
|
84
|
+
return gistContent;
|
|
85
|
+
return null;
|
|
86
|
+
}
|
|
87
|
+
//# sourceMappingURL=gist_transmit.js.map
|
|
@@ -0,0 +1 @@
|
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