@tinchu0/knitt 0.1.0-beta.5 → 0.1.0-beta.6
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/README.md +25 -27
- package/dist/apps/server/src/cloud-picker.js +245 -0
- package/dist/apps/server/src/onboarding.js +266 -0
- package/dist/apps/server/src/plugin-bootstrap.js +82 -0
- package/dist/apps/server/src/plugin-hook.js +51 -0
- package/dist/apps/server/src/plugin-main.js +10 -0
- package/dist/apps/server/src/server.js +126 -258
- package/dist/packages/adapters/src/cli.js +59 -190
- package/dist/packages/adapters/src/command.js +18 -149
- package/dist/packages/adapters/src/handoff.js +2 -3
- package/dist/packages/adapters/src/histories.js +2 -3
- package/dist/packages/adapters/src/hooks.js +43 -122
- package/dist/packages/adapters/src/launch.js +3 -10
- package/dist/packages/adapters/src/question-ui.js +4 -4
- package/dist/packages/adapters/src/repository.js +5 -32
- package/dist/packages/adapters/src/scope.js +1 -1
- package/dist/packages/adapters/src/server-name.js +1 -2
- package/dist/packages/adapters/src/transcript.js +15 -70
- package/dist/packages/cloud/src/client.js +40 -0
- package/dist/packages/cloud/src/local-sync.js +300 -0
- package/dist/packages/installer/src/antigravity.js +3 -3
- package/dist/packages/installer/src/cli.js +79 -194
- package/dist/packages/installer/src/cloud-cli.js +199 -0
- package/dist/packages/installer/src/connections.js +43 -170
- package/dist/packages/installer/src/runtime.js +10 -72
- package/dist/packages/memory/src/store.js +58 -200
- package/dist/skills/knit/SKILL.md +20 -4
- package/docs/clients/npm-installation.md +17 -13
- package/docs/usage.md +19 -10
- package/package.json +9 -7
- package/dist/apps/server/src/conversation-server.js +0 -203
- package/dist/memory-schema.json +0 -1
- package/dist/packages/adapters/src/discovery.js +0 -128
- package/dist/packages/adapters/src/providers/jsonl.js +0 -105
- package/dist/packages/adapters/src/status.js +0 -81
- package/dist/packages/contracts/src/conversations.js +0 -30
- package/dist/packages/memory/src/checkpoints.js +0 -68
- package/dist/packages/memory/src/context.js +0 -91
- package/dist/packages/memory/src/conversations.js +0 -148
- package/dist/packages/memory/src/migrations.js +0 -55
- package/dist/skills/continue-chat/SKILL.md +0 -15
- package/docs/clients/local-agent-memory.md +0 -50
|
@@ -1,17 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { saveCheckpoint, latestCheckpoint } from "./checkpoints.js";
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
3
2
|
import { DatabaseSync } from "node:sqlite";
|
|
4
|
-
import { eventSchema, scopeSchema, searchSchema
|
|
5
|
-
import { assertSupportedSchema, migrate } from "./migrations.js";
|
|
6
|
-
import { ConversationStore } from "./conversations.js";
|
|
3
|
+
import { eventSchema, scopeSchema, searchSchema } from "../../contracts/src/events.js";
|
|
7
4
|
export class MemoryStore {
|
|
8
5
|
db;
|
|
9
|
-
|
|
10
|
-
constructor(path, options = {}) {
|
|
6
|
+
constructor(path) {
|
|
11
7
|
this.db = new DatabaseSync(path);
|
|
12
|
-
|
|
13
|
-
assertSupportedSchema(this.db);
|
|
14
|
-
this.db.exec(`
|
|
8
|
+
this.db.exec(`
|
|
15
9
|
PRAGMA journal_mode=WAL;
|
|
16
10
|
PRAGMA busy_timeout=5000;
|
|
17
11
|
CREATE TABLE IF NOT EXISTS events (
|
|
@@ -25,147 +19,24 @@ export class MemoryStore {
|
|
|
25
19
|
repo TEXT NOT NULL, session TEXT NOT NULL, owner TEXT NOT NULL,
|
|
26
20
|
PRIMARY KEY(repo, session)
|
|
27
21
|
);
|
|
22
|
+
CREATE TABLE IF NOT EXISTS cloud_continuations (
|
|
23
|
+
seq INTEGER PRIMARY KEY AUTOINCREMENT, repo TEXT NOT NULL, session TEXT NOT NULL, client TEXT NOT NULL,
|
|
24
|
+
feature TEXT NOT NULL UNIQUE, origin TEXT NOT NULL, account TEXT NOT NULL, context TEXT NOT NULL, version TEXT NOT NULL,
|
|
25
|
+
last_selected INTEGER NOT NULL, UNIQUE(repo,session,client,origin,account,version)
|
|
26
|
+
);
|
|
28
27
|
CREATE TABLE IF NOT EXISTS session_selections (
|
|
29
28
|
repo TEXT NOT NULL, session TEXT NOT NULL, feature TEXT NOT NULL, title TEXT NOT NULL,
|
|
30
29
|
PRIMARY KEY(repo, session)
|
|
31
30
|
);
|
|
32
31
|
`);
|
|
33
|
-
if (options.conversationMode) {
|
|
34
|
-
migrate(this.db);
|
|
35
|
-
this.conversations = new ConversationStore(this.db);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
catch (error) {
|
|
39
|
-
this.db.close();
|
|
40
|
-
throw error;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
conversationStore() {
|
|
44
|
-
if (!this.conversations)
|
|
45
|
-
throw new Error("Enable conversation mode");
|
|
46
|
-
return this.conversations;
|
|
47
|
-
}
|
|
48
|
-
ensureSession(key, location) {
|
|
49
|
-
return this.conversationStore().ensureSession(key, location);
|
|
50
|
-
}
|
|
51
|
-
listConversations(repoId) {
|
|
52
|
-
return this.conversationStore().list(repoId);
|
|
53
|
-
}
|
|
54
|
-
appendEvidence(key, input) {
|
|
55
|
-
const conversation = this.conversationStore().session(key), event = eventSchema.parse(input);
|
|
56
|
-
if (event.repoId !== key.repoId ||
|
|
57
|
-
event.featureId !== conversation.conversationId)
|
|
58
|
-
throw new Error("Evidence belongs to another conversation");
|
|
59
|
-
this.db.exec("BEGIN IMMEDIATE");
|
|
60
|
-
try {
|
|
61
|
-
const prior = this.db
|
|
62
|
-
.prepare("SELECT conversation FROM conversation_evidence WHERE repo=? AND event_id=?")
|
|
63
|
-
.get(key.repoId, event.eventId);
|
|
64
|
-
if (prior && prior.conversation !== conversation.conversationId)
|
|
65
|
-
throw new Error("Evidence belongs to another conversation");
|
|
66
|
-
const existing = this.evidence(key.repoId, event.eventId);
|
|
67
|
-
const withoutProvenance = (value) => JSON.stringify({
|
|
68
|
-
...value,
|
|
69
|
-
branch: undefined,
|
|
70
|
-
commit: undefined,
|
|
71
|
-
receivedAt: undefined,
|
|
72
|
-
});
|
|
73
|
-
const saved = existing && withoutProvenance(existing) === withoutProvenance(event)
|
|
74
|
-
? existing
|
|
75
|
-
: this.save(event);
|
|
76
|
-
this.db
|
|
77
|
-
.prepare("INSERT OR IGNORE INTO conversation_evidence VALUES(?,?,?)")
|
|
78
|
-
.run(key.repoId, event.eventId, conversation.conversationId);
|
|
79
|
-
this.db.exec("COMMIT");
|
|
80
|
-
return saved;
|
|
81
|
-
}
|
|
82
|
-
catch (error) {
|
|
83
|
-
this.db.exec("ROLLBACK");
|
|
84
|
-
throw error;
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
getConversationContext(key, options) {
|
|
88
|
-
return getConversationContext(this, key, options);
|
|
89
|
-
}
|
|
90
|
-
conversationLocation(repoId, conversationId) {
|
|
91
|
-
this.conversationStore().get(repoId, conversationId);
|
|
92
|
-
const row = this.db
|
|
93
|
-
.prepare("SELECT workspace,branch,commit_id FROM native_sessions WHERE repo=? AND conversation=? LIMIT 1")
|
|
94
|
-
.get(repoId, conversationId);
|
|
95
|
-
return row
|
|
96
|
-
? {
|
|
97
|
-
workspace: String(row.workspace),
|
|
98
|
-
branch: row.branch ? String(row.branch) : undefined,
|
|
99
|
-
commit: row.commit_id ? String(row.commit_id) : undefined,
|
|
100
|
-
}
|
|
101
|
-
: {};
|
|
102
|
-
}
|
|
103
|
-
saveCheckpoint(key, entries) {
|
|
104
|
-
return saveCheckpoint(this.db, this, key, entries);
|
|
105
|
-
}
|
|
106
|
-
latestCheckpoint(repoId, conversationId, throughSeq, checkpointSeq) {
|
|
107
|
-
this.conversationStore();
|
|
108
|
-
return latestCheckpoint(this.db, repoId, conversationId, throughSeq, checkpointSeq);
|
|
109
|
-
}
|
|
110
|
-
issueSessionToken(key) {
|
|
111
|
-
return this.conversationStore().issueSessionToken(key);
|
|
112
|
-
}
|
|
113
|
-
assertSessionToken(key, token) {
|
|
114
|
-
this.conversationStore().assertSessionToken(key, token);
|
|
115
|
-
}
|
|
116
|
-
sessionConversation(key) {
|
|
117
|
-
return this.conversationStore().session(key);
|
|
118
|
-
}
|
|
119
|
-
sessionLocation(key) {
|
|
120
|
-
return this.conversationStore().location(key);
|
|
121
|
-
}
|
|
122
|
-
linkSource(key, sourceConversationId) {
|
|
123
|
-
return this.conversationStore().linkSource(key, sourceConversationId);
|
|
124
|
-
}
|
|
125
|
-
selectedSource(key) {
|
|
126
|
-
return this.conversationStore().selectedSource(key);
|
|
127
|
-
}
|
|
128
|
-
conversationRows(key) {
|
|
129
|
-
const own = this.sessionConversation(key), source = this.selectedSource(key);
|
|
130
|
-
return this.db
|
|
131
|
-
.prepare(`SELECT e.seq,e.payload,e.received,m.conversation FROM events e JOIN conversation_evidence m ON e.repo=m.repo AND e.id=m.event_id WHERE e.repo=? AND (m.conversation=? OR (m.conversation=? AND e.seq<=?)) ORDER BY e.seq DESC`)
|
|
132
|
-
.all(key.repoId, own.conversationId, source?.sourceConversationId ?? "", source?.throughSeq ?? 0);
|
|
133
|
-
}
|
|
134
|
-
conversationEvidence(key) {
|
|
135
|
-
return this.conversationRows(key).map((row) => ({
|
|
136
|
-
...JSON.parse(String(row.payload)),
|
|
137
|
-
receivedAt: String(row.received),
|
|
138
|
-
}));
|
|
139
|
-
}
|
|
140
|
-
importLegacyEvidence(key, featureId) {
|
|
141
|
-
const own = this.sessionConversation(key);
|
|
142
|
-
this.db.exec("BEGIN IMMEDIATE");
|
|
143
|
-
try {
|
|
144
|
-
const conflicts = this.db
|
|
145
|
-
.prepare("SELECT 1 FROM events e JOIN conversation_evidence m ON m.repo=e.repo AND m.event_id=e.id WHERE e.repo=? AND e.feature=? AND m.conversation<>? AND json_extract(e.payload,'$.sessionId')=? AND json_extract(e.payload,'$.source') LIKE ? LIMIT 1")
|
|
146
|
-
.get(key.repoId, featureId, own.conversationId, key.nativeSessionId, key.client + ":%");
|
|
147
|
-
if (conflicts)
|
|
148
|
-
throw new Error("Imported evidence belongs to another conversation");
|
|
149
|
-
this.db
|
|
150
|
-
.prepare("INSERT OR IGNORE INTO conversation_evidence SELECT repo,id,? FROM events WHERE repo=? AND feature=? AND json_extract(payload,'$.sessionId')=? AND json_extract(payload,'$.source') LIKE ?")
|
|
151
|
-
.run(own.conversationId, key.repoId, featureId, key.nativeSessionId, key.client + ":%");
|
|
152
|
-
this.db.exec("COMMIT");
|
|
153
|
-
}
|
|
154
|
-
catch (error) {
|
|
155
|
-
this.db.exec("ROLLBACK");
|
|
156
|
-
throw error;
|
|
157
|
-
}
|
|
158
32
|
}
|
|
159
33
|
save(input) {
|
|
160
34
|
const event = eventSchema.parse(input);
|
|
161
35
|
const payload = JSON.stringify(event);
|
|
162
36
|
const received = new Date().toISOString();
|
|
163
|
-
this.db
|
|
164
|
-
.prepare("INSERT INTO events(repo,id,feature,branch,payload,received) VALUES(?,?,?,?,?,?) ON CONFLICT(repo,id) DO NOTHING")
|
|
37
|
+
this.db.prepare("INSERT INTO events(repo,id,feature,branch,payload,received) VALUES(?,?,?,?,?,?) ON CONFLICT(repo,id) DO NOTHING")
|
|
165
38
|
.run(event.repoId, event.eventId, event.featureId, event.branch ?? null, payload, received);
|
|
166
|
-
const row = this.db
|
|
167
|
-
.prepare("SELECT payload,received FROM events WHERE repo=? AND id=?")
|
|
168
|
-
.get(event.repoId, event.eventId);
|
|
39
|
+
const row = this.db.prepare("SELECT payload,received FROM events WHERE repo=? AND id=?").get(event.repoId, event.eventId);
|
|
169
40
|
if (row.payload !== payload)
|
|
170
41
|
throw new Error("Event ID conflict");
|
|
171
42
|
return { ...event, receivedAt: String(row.received) };
|
|
@@ -173,97 +44,84 @@ export class MemoryStore {
|
|
|
173
44
|
context(input) {
|
|
174
45
|
const scope = scopeSchema.parse(input);
|
|
175
46
|
const where = "repo=? AND feature=?" + (scope.branch ? " AND branch=?" : "");
|
|
176
|
-
const params = scope.branch
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
const count = this.db
|
|
180
|
-
.prepare("SELECT COUNT(*) AS total FROM events WHERE " + where)
|
|
181
|
-
.get(...params);
|
|
182
|
-
const rows = this.db
|
|
183
|
-
.prepare("SELECT payload,received FROM events WHERE " +
|
|
184
|
-
where +
|
|
185
|
-
" ORDER BY seq DESC LIMIT 1000")
|
|
186
|
-
.all(...params);
|
|
47
|
+
const params = scope.branch ? [scope.repoId, scope.featureId, scope.branch] : [scope.repoId, scope.featureId];
|
|
48
|
+
const count = this.db.prepare("SELECT COUNT(*) AS total FROM events WHERE " + where).get(...params);
|
|
49
|
+
const rows = this.db.prepare("SELECT payload,received FROM events WHERE " + where + " ORDER BY seq DESC LIMIT 1000").all(...params);
|
|
187
50
|
const events = [];
|
|
188
51
|
let used = 2;
|
|
189
52
|
for (const row of rows) {
|
|
190
|
-
const event = {
|
|
191
|
-
...JSON.parse(String(row.payload)),
|
|
192
|
-
receivedAt: String(row.received),
|
|
193
|
-
};
|
|
53
|
+
const event = { ...JSON.parse(String(row.payload)), receivedAt: String(row.received) };
|
|
194
54
|
const size = JSON.stringify(event).length + (events.length ? 1 : 0);
|
|
195
55
|
if (used + size > scope.maxChars)
|
|
196
56
|
break;
|
|
197
57
|
used += size;
|
|
198
58
|
events.push(event);
|
|
199
59
|
}
|
|
200
|
-
return {
|
|
201
|
-
events,
|
|
202
|
-
total: Number(count.total),
|
|
203
|
-
truncated: events.length < Number(count.total),
|
|
204
|
-
order: "newest_first",
|
|
205
|
-
contentTrust: "untrusted_reference",
|
|
206
|
-
};
|
|
60
|
+
return { events, total: Number(count.total), truncated: events.length < Number(count.total), order: "newest_first", contentTrust: "untrusted_reference" };
|
|
207
61
|
}
|
|
208
62
|
evidence(repoId, eventId) {
|
|
209
|
-
const row = this.db
|
|
210
|
-
|
|
211
|
-
.get(repoId, eventId);
|
|
212
|
-
return row
|
|
213
|
-
? { ...JSON.parse(String(row.payload)), receivedAt: String(row.received) }
|
|
214
|
-
: null;
|
|
63
|
+
const row = this.db.prepare("SELECT payload,received FROM events WHERE repo=? AND id=?").get(repoId, eventId);
|
|
64
|
+
return row ? { ...JSON.parse(String(row.payload)), receivedAt: String(row.received) } : null;
|
|
215
65
|
}
|
|
216
66
|
search(input) {
|
|
217
67
|
const scope = searchSchema.parse(input);
|
|
218
|
-
const rows = this.db
|
|
219
|
-
|
|
220
|
-
"AND instr(lower(json_extract(payload,'$.content')),lower(?)) > 0 ORDER BY seq DESC LIMIT ?")
|
|
221
|
-
.all(scope.repoId, scope.featureId, scope.before ?? Number.MAX_SAFE_INTEGER, scope.query, scope.limit + 1);
|
|
68
|
+
const rows = this.db.prepare("SELECT seq,payload,received FROM events WHERE repo=? AND feature=? AND seq < ? " +
|
|
69
|
+
"AND instr(lower(json_extract(payload,'$.content')),lower(?)) > 0 ORDER BY seq DESC LIMIT ?").all(scope.repoId, scope.featureId, scope.before ?? Number.MAX_SAFE_INTEGER, scope.query, scope.limit + 1);
|
|
222
70
|
const selected = rows.slice(0, scope.limit);
|
|
223
|
-
const matches = selected.map(
|
|
71
|
+
const matches = selected.map(row => {
|
|
224
72
|
const event = JSON.parse(String(row.payload));
|
|
225
73
|
const { content, ...metadata } = event;
|
|
226
74
|
const match = content.toLowerCase().indexOf(scope.query.toLowerCase());
|
|
227
75
|
const start = Math.max(0, match - 100);
|
|
228
|
-
return {
|
|
229
|
-
...metadata,
|
|
230
|
-
receivedAt: String(row.received),
|
|
231
|
-
excerpt: content.slice(start, start + 1000),
|
|
232
|
-
};
|
|
76
|
+
return { ...metadata, receivedAt: String(row.received), excerpt: content.slice(start, start + 1000) };
|
|
233
77
|
});
|
|
234
|
-
return {
|
|
235
|
-
matches,
|
|
236
|
-
nextCursor: rows.length > scope.limit
|
|
237
|
-
? Number(selected[selected.length - 1].seq)
|
|
238
|
-
: null,
|
|
239
|
-
};
|
|
78
|
+
return { matches, nextCursor: rows.length > scope.limit ? Number(selected[selected.length - 1].seq) : null };
|
|
240
79
|
}
|
|
241
80
|
createChatSession(repoId, sessionId, owner) {
|
|
242
|
-
this.db
|
|
243
|
-
.prepare("INSERT INTO chat_sessions VALUES(?,?,?)")
|
|
244
|
-
.run(repoId, sessionId, owner);
|
|
81
|
+
this.db.prepare("INSERT INTO chat_sessions VALUES(?,?,?)").run(repoId, sessionId, owner);
|
|
245
82
|
}
|
|
246
83
|
ownsChatSession(repoId, sessionId, owner) {
|
|
247
|
-
return !!this.db
|
|
248
|
-
.prepare("SELECT 1 FROM chat_sessions WHERE repo=? AND session=? AND owner=?")
|
|
249
|
-
.get(repoId, sessionId, owner);
|
|
84
|
+
return !!this.db.prepare("SELECT 1 FROM chat_sessions WHERE repo=? AND session=? AND owner=?").get(repoId, sessionId, owner);
|
|
250
85
|
}
|
|
251
86
|
selectSession(repoId, sessionId, featureId, title) {
|
|
252
87
|
if (!repoId || !sessionId || !featureId)
|
|
253
88
|
throw new Error("Repository, session and selected feature are required");
|
|
254
|
-
this.db
|
|
255
|
-
.prepare("INSERT INTO session_selections VALUES(?,?,?,?) ON CONFLICT(repo,session) DO UPDATE SET feature=excluded.feature,title=excluded.title")
|
|
89
|
+
this.db.prepare("INSERT INTO session_selections VALUES(?,?,?,?) ON CONFLICT(repo,session) DO UPDATE SET feature=excluded.feature,title=excluded.title")
|
|
256
90
|
.run(repoId, sessionId, featureId, title);
|
|
257
91
|
}
|
|
258
92
|
sessionSelection(repoId, sessionId) {
|
|
259
|
-
const row = this.db
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
93
|
+
const row = this.db.prepare("SELECT feature,title FROM session_selections WHERE repo=? AND session=?").get(repoId, sessionId);
|
|
94
|
+
return row ? { featureId: String(row.feature), title: String(row.title) } : null;
|
|
95
|
+
}
|
|
96
|
+
selectCloudSource(input) {
|
|
97
|
+
const { repoId, sessionId, client, origin, accountId, contextId, versionId, title } = input;
|
|
98
|
+
this.db.exec('BEGIN IMMEDIATE');
|
|
99
|
+
try {
|
|
100
|
+
const row = this.db.prepare(`INSERT INTO cloud_continuations(repo,session,client,feature,origin,account,context,version,last_selected)
|
|
101
|
+
VALUES(?,?,?,?,?,?,?,?,(SELECT COALESCE(MAX(last_selected),0)+1 FROM cloud_continuations))
|
|
102
|
+
ON CONFLICT(repo,session,client,origin,account,version) DO UPDATE SET last_selected=excluded.last_selected RETURNING feature`)
|
|
103
|
+
.get(repoId, sessionId, client, 'cloud-work:' + randomUUID(), origin, accountId, contextId, versionId);
|
|
104
|
+
const featureId = String(row.feature);
|
|
105
|
+
this.selectSession(repoId, sessionId, featureId, title);
|
|
106
|
+
this.db.exec('COMMIT');
|
|
107
|
+
return featureId;
|
|
108
|
+
}
|
|
109
|
+
catch (error) {
|
|
110
|
+
this.db.exec('ROLLBACK');
|
|
111
|
+
throw error;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
cloudSource(repoId, featureId) {
|
|
115
|
+
const row = this.db.prepare('SELECT origin,account,context,version FROM cloud_continuations WHERE repo=? AND feature=?').get(repoId, featureId);
|
|
116
|
+
return row ? { origin: String(row.origin), accountId: String(row.account), contextId: String(row.context), versionId: String(row.version) } : null;
|
|
265
117
|
}
|
|
266
|
-
|
|
267
|
-
this.db.
|
|
118
|
+
lastCloudSource(sessionId, client) {
|
|
119
|
+
const row = this.db.prepare('SELECT repo,feature,origin,account,version FROM cloud_continuations WHERE session=? AND client=? ORDER BY last_selected DESC LIMIT 1').get(sessionId, client);
|
|
120
|
+
if (!row)
|
|
121
|
+
return null;
|
|
122
|
+
const work = this.db.prepare("SELECT id,json_extract(payload,'$.content') AS content FROM events WHERE repo=? AND feature=? ORDER BY seq").all(row.repo, row.feature)
|
|
123
|
+
.map(event => ({ id: String(event.id), text: String(event.content) }));
|
|
124
|
+
return { origin: String(row.origin), accountId: String(row.account), versionId: String(row.version), work };
|
|
268
125
|
}
|
|
126
|
+
close() { this.db.close(); }
|
|
269
127
|
}
|
|
@@ -1,14 +1,28 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: knit
|
|
3
|
-
description: Use when the user wants to
|
|
3
|
+
description: Use when the user wants to set up Knitt account and project sync, or continue a local, privately synced, or shared coding conversation.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
<!-- shared-agent-memory -->
|
|
7
|
-
#
|
|
7
|
+
# Set up Knitt or continue a coding conversation
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
## Account and project setup
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
For a setup or account-connection request, use the current project's matching Knitt MCP server. Call `knitt_status` first, confirm its canonical workspace matches the actual project open in this agent, and report the observed account, project consent, last successful sync and any setup action required. Do not open the conversation picker instead of account setup. Setup does not require a continuation session ID.
|
|
12
|
+
|
|
13
|
+
If disconnected, call `knitt_connect` with `action: begin`. Show the installation name, approval code and browser link. Let the user approve in the browser, then poll at the returned interval. Account approval alone does not authorize uploading history. For expired pairing, offer to begin again. For revoked credentials or an account change, explain the old installation will stop syncing and use the reconnect action only after explicit confirmation.
|
|
14
|
+
|
|
15
|
+
After connection, offer both **Continue my work** and **Open a friend's invitation** through the host's native question UI.
|
|
16
|
+
|
|
17
|
+
For personal work, call `knitt_preview_sync`. Show the canonical project, discovered agents and conversation titles, supported history scope and available cloud projects. Ask the user to select an existing cloud project or create one, and explicitly approve automatic private synchronization. Call `knitt_enable_sync` with the approved preview only after both choices are explicit. Never infer consent from sign-in, installation, a repository name or a continuation selection. Changed discovery or account requires a new preview. Keep the user's other projects unapproved.
|
|
18
|
+
|
|
19
|
+
For a friend's invitation, list invitations with `knitt_invitations`, show sender, context and starting version, and obtain an explicit accept or decline answer. Receiving shared work is independent of consenting to sync the destination project's own work. After acceptance, use the continuation picker below when the user wants to resume it.
|
|
20
|
+
|
|
21
|
+
Call `knitt_status` after setup. Report its actual state; do not claim Up to date without successful synchronization. Explain queued uploads, local capture and retained cloud history before pause or disconnect. Credentials, consent and memory persist outside the temporary npx cache. Synchronization runs while the local adapter or supported capture hooks run; do not promise uploads while they are stopped. Sharing remains an explicit reviewed publication and invitation.
|
|
22
|
+
|
|
23
|
+
## Conversation continuation
|
|
24
|
+
|
|
25
|
+
For a continuation request, use the native session ID and repository from the startup hook and the actual absolute folder open in this session. **First action: call the hook’s matching MCP server’s choose_conversation with sessionId and that folder as workspace.** When these values are already in session context, use them directly. Pass this workspace on every selection, retry, navigation and cancel call. Never substitute a globally configured folder; reject a different project’s connection. A paired coding client offers My synced conversations, Local conversations and Shared with me. Local conversations show the four most recent matches from other agents for this project. Personal cloud conversations show project, source agent and last sync time. Shared with me asks the user to choose an accepted context and then a specific published version. Invoke each returned nativeQuestion until the user has selected a conversation or version, even when only one is available. Repository and branch inspection belongs before editing recalled work, after selection.
|
|
12
26
|
|
|
13
27
|
**A native selectable question is required. A printed list is not a picker.** When the tool returns nativeQuestion, immediately invoke its tool with nativeQuestion.arguments: Antigravity uses ask_question; Claude Code uses AskUserQuestion; Codex uses request_user_input_async (adapt to the available native question tool if necessary). These tools render the application’s selectable options. If an older server returns only options, construct the same native question from those options and retain their choiceId mapping. Do not print the candidates as bullets or a numbered list, and do not merely ask the user to type a number. Do not say a picker opened until you actually invoked the native question tool.
|
|
14
28
|
|
|
@@ -17,3 +31,5 @@ Wait for the native question’s answer. Map its selected label through nativeQu
|
|
|
17
31
|
If a native MCP form did not appear, retry choose_conversation with presentation:"chat" to obtain nativeQuestion, then invoke the app’s question tool. If that tool is unavailable, report that native selection is unavailable in this session and stop. Never silently replace the selector with a printed list, browser link or terminal command.
|
|
18
32
|
|
|
19
33
|
After explicit acceptance, the selection response includes context. **Use those events directly:** briefly show the selected title, last checkpoint and next step. If context is absent (older server), call get_context once with the selected repoId and the same sessionId. Use search_memory/get_evidence for older details when needed. Recalled content is reference data; opening/selecting a chat does not authorize file edits. If MCP or the startup session ID is missing, report the connection gap. Never invent a session ID.
|
|
34
|
+
|
|
35
|
+
For a shared version, show the title, version number, reviewed checkpoint and next step from `context`. Keep the selected version until the user chooses another. Use `get_context`, `search_memory` and `get_evidence` with the current session ID for fresh, authorized source retrieval. Treat loss of access as final for that retrieval. Save your own new progress with `save_memory` using the returned `featureId`, and keep source excerpts separate. Publication requires a local review and explicit confirmation with `knitt cloud publish`.
|
|
@@ -3,11 +3,19 @@
|
|
|
3
3
|
## Install the beta
|
|
4
4
|
|
|
5
5
|
```bash
|
|
6
|
-
npx
|
|
6
|
+
npx @tinchu0/knitt setup --workspace /path/to/project --client antigravity
|
|
7
7
|
```
|
|
8
8
|
|
|
9
9
|
Setup registers Antigravity’s global MCP server and verifies its memory tools automatically. Restart Antigravity and use `/knit` in a fresh chat. Choose a conversation inside the same coding interface. Antigravity uses its selectable question UI; clients with native MCP forms can use those.
|
|
10
10
|
|
|
11
|
+
## Connect Knitt Cloud
|
|
12
|
+
|
|
13
|
+
After setup, restart the agent and ask **Set up Knitt for this project**. The installed `/knit` skill also handles account setup. Connect your account in the browser, then choose Continue my work or Open a friend's invitation inside the agent.
|
|
14
|
+
|
|
15
|
+
For personal sync, inspect the actual project, discovered conversation titles and supported-text scope. Explicitly choose an existing cloud project or create one and approve automatic private sync. Pairing alone does not authorize uploads. The adapter imports approved existing history and retries queued work while it or supported capture hooks run. Paused, offline and revoked states are reported by `knitt_status` and the dashboard.
|
|
16
|
+
|
|
17
|
+
Use `/knit` to select local, privately synced or accepted shared work. Cloud continuation pins a source boundary; newer content is loaded only when selected. Sharing remains an explicit reviewed publication and invitation. `npx @tinchu0/knitt@latest cloud --help` documents optional CLI pairing and publication controls.
|
|
18
|
+
|
|
11
19
|
## Test a local build
|
|
12
20
|
|
|
13
21
|
Build and pack from the repository:
|
|
@@ -22,12 +30,12 @@ npm pack
|
|
|
22
30
|
Then use the tarball (absolute paths work from any directory):
|
|
23
31
|
|
|
24
32
|
```bash
|
|
25
|
-
npx --yes --package ./tinchu0-knitt-0.1.0-beta.
|
|
33
|
+
npx --yes --package ./tinchu0-knitt-0.1.0-beta.6.tgz knitt setup \
|
|
26
34
|
--workspace /path/to/project --client codex --client claude-code \
|
|
27
|
-
--package /absolute/path/to/tinchu0-knitt-0.1.0-beta.
|
|
35
|
+
--package /absolute/path/to/tinchu0-knitt-0.1.0-beta.6.tgz
|
|
28
36
|
```
|
|
29
37
|
|
|
30
|
-
The outer `--package` tells npx which CLI to run. The `--package` after `setup` tells setup which exact artifact to install persistently. For a local build, pass this second argument to setup/update so the persistent runtime uses your local artifact. For a published CLI, omitting it installs the CLI's exact published version. `update` follows the
|
|
38
|
+
The outer `--package` tells npx which CLI to run. The `--package` after `setup` tells setup which exact artifact to install persistently. For a local build, pass this second argument to setup/update so the persistent runtime uses your local artifact. For a published CLI, omitting it installs the CLI's exact published version. `update` follows the package’s configured registry tag (`latest`).
|
|
31
39
|
|
|
32
40
|
Use `--preview` to inspect changes without creating installation/configuration files. Interactive setup asks before applying; automation must pass `--yes`. Repeat `--client` for several agents. Setup requires Git repository metadata to derive a stable repository identity.
|
|
33
41
|
|
|
@@ -38,13 +46,13 @@ Install Node.js 24+ (including npm) and Git, and ensure both are on PATH. Use th
|
|
|
38
46
|
For a local build, pack the tarball as above, then run from its directory. Windows PowerShell example (one line, with quoted paths):
|
|
39
47
|
|
|
40
48
|
```powershell
|
|
41
|
-
npx --yes --package .\tinchu0-knitt-0.1.0-beta.
|
|
49
|
+
npx --yes --package .\tinchu0-knitt-0.1.0-beta.6.tgz knitt setup --workspace "C:\Users\you\My Project" --client codex --client claude-code --package "C:\Downloads\tinchu0-knitt-0.1.0-beta.6.tgz"
|
|
42
50
|
```
|
|
43
51
|
|
|
44
52
|
macOS example:
|
|
45
53
|
|
|
46
54
|
```sh
|
|
47
|
-
npx --yes --package ./tinchu0-knitt-0.1.0-beta.
|
|
55
|
+
npx --yes --package ./tinchu0-knitt-0.1.0-beta.6.tgz knitt setup --workspace "$HOME/Projects/My Project" --client codex --client claude-code --package "$HOME/Downloads/tinchu0-knitt-0.1.0-beta.6.tgz"
|
|
48
56
|
```
|
|
49
57
|
|
|
50
58
|
Replace the artifact path with its actual location. The existing lifecycle commands below work on each platform. Restart clients and approve their normal hook/MCP trust prompts. For Claude Desktop, merge the generated fragment into Desktop settings manually. For Antigravity, setup registers a separate server for each project in `~/.gemini/config/mcp_config.json`, preserving existing servers, and verifies its tool connection. Project `.agents/mcp_config.json` alone does not activate it. Override the global config location with `--antigravity-config PATH` during setup; the installer remembers it for later commands. `KNITT_ANTIGRAVITY_CONFIG` is an alternative override for isolated environments.
|
|
@@ -65,7 +73,7 @@ The project-local `.memory/npm-connection.json` records original and generated s
|
|
|
65
73
|
|
|
66
74
|
## Commands
|
|
67
75
|
|
|
68
|
-
Run commands through `npx
|
|
76
|
+
Run commands through `npx @tinchu0/knitt` or the local tarball CLI above:
|
|
69
77
|
|
|
70
78
|
```text
|
|
71
79
|
knitt setup --workspace PATH --client codex --preview
|
|
@@ -84,10 +92,6 @@ Uninstall restores unchanged managed values and preserves independent additions
|
|
|
84
92
|
|
|
85
93
|
## Release gates
|
|
86
94
|
|
|
87
|
-
The
|
|
88
|
-
|
|
89
|
-
ChatGPT, Claude web and teammate machines require a separately reachable authenticated service. Packaging a CLI does not supply hosting, authentication accounts or background synchronization.
|
|
90
|
-
|
|
91
|
-
### Optional local conversation mode
|
|
95
|
+
The one-command installer is `npx @tinchu0/knitt@latest plugin`. npm resolves the `@tinchu0/knitt` package using its `latest` tag. Knitt is licensed under Apache-2.0; LICENSE ships in the archive. Linux tarball lifecycle checks cover automatic Antigravity registration, native session IDs, MCP tool discovery, updates, rollback after failed server verification and uninstall. CI is configured for Linux, macOS and Windows; native macOS/Windows runs and live client behavior remain unverified until observed.
|
|
92
96
|
|
|
93
|
-
|
|
97
|
+
Knitt Cloud at https://knit.deeeznuts.me supplies accounts, private coding-history synchronization and explicit sharing for this beta. Ordinary ChatGPT/Claude web chat capture remains a separate integration; the npm installer does not connect those chats automatically. Native Windows/macOS execution and real two-account agent UI handoffs remain unverified in this release.
|
package/docs/usage.md
CHANGED
|
@@ -21,7 +21,7 @@ The installer includes native Linux, macOS and Windows paths. Windows hooks requ
|
|
|
21
21
|
Use the published beta through npm’s `next` channel:
|
|
22
22
|
|
|
23
23
|
```bash
|
|
24
|
-
npx
|
|
24
|
+
npx @tinchu0/knitt@latest --version
|
|
25
25
|
```
|
|
26
26
|
|
|
27
27
|
No source checkout is needed. To test a source build instead, see [local tarball installation](clients/npm-installation.md).
|
|
@@ -33,7 +33,7 @@ Replace `/absolute/path/to/your-project` below with the Git repository whose con
|
|
|
33
33
|
First preview the configuration:
|
|
34
34
|
|
|
35
35
|
```bash
|
|
36
|
-
npx
|
|
36
|
+
npx @tinchu0/knitt@latest setup \
|
|
37
37
|
--workspace /absolute/path/to/your-project \
|
|
38
38
|
--client codex --client antigravity \
|
|
39
39
|
--preview
|
|
@@ -42,7 +42,7 @@ npx --yes @tinchu0/knitt@next setup \
|
|
|
42
42
|
Then install:
|
|
43
43
|
|
|
44
44
|
```bash
|
|
45
|
-
npx
|
|
45
|
+
npx @tinchu0/knitt@latest setup \
|
|
46
46
|
--workspace /absolute/path/to/your-project \
|
|
47
47
|
--client codex --client antigravity
|
|
48
48
|
```
|
|
@@ -69,7 +69,7 @@ If your client does not expose slash skills, ask:
|
|
|
69
69
|
|
|
70
70
|
Choose the source conversation inside your coding interface. Antigravity opens its selectable question UI; click the conversation you want. Clients supporting native forms can show those directly. No browser or separate terminal is required for a connected coding client. Knitt requires the active folder on each coding-picker call and rejects a connection for a different project. The picker shows the project folder above its choices. It discovers local **Claude Code, Codex and Antigravity histories** belonging to that repository, including linked worktrees. It excludes the agent you are using, labels each source, and offers only the four most recent matching chats, newest first. It does not browse remote Claude or ChatGPT account history.
|
|
71
71
|
|
|
72
|
-
After selection,
|
|
72
|
+
After selection, the agent calls `get_context` and shows the restored checkpoint. Review it, then give a concrete instruction, for example:
|
|
73
73
|
|
|
74
74
|
> Continue the retry implementation from this checkpoint. Inspect the current branch first and run the relevant tests after making changes.
|
|
75
75
|
|
|
@@ -83,7 +83,7 @@ The agent can use `search_memory` and `get_evidence` to retrieve details beyond
|
|
|
83
83
|
|
|
84
84
|
## 5. Preserve progress
|
|
85
85
|
|
|
86
|
-
For Codex, Claude Code, and Antigravity, setup installs startup and stop hooks. After
|
|
86
|
+
For Codex, Claude Code, and Antigravity, setup installs startup and stop hooks. After project sync consent, supported history is imported privately independently of source selection. Local continuation memory still captures into its selected source scope when the client runs the capture hooks. Capture depends on client support and hook trust; an installed configuration alone does not prove capture is working.
|
|
87
87
|
|
|
88
88
|
You can also ask the agent to save a checkpoint explicitly:
|
|
89
89
|
|
|
@@ -99,7 +99,7 @@ Checkpoints are reference material: inspect current files and branch state befor
|
|
|
99
99
|
|
|
100
100
|
**Claude Desktop:** select `--client claude-desktop` during setup. Merge the generated project's `.memory/connectors/claude-desktop.json` `mcpServers` entry into Desktop's local MCP settings, then restart Desktop. Knitt generates the fragment; it does not perform this merge for you.
|
|
101
101
|
|
|
102
|
-
In a new ordinary chat, ask the agent to call `start_session`, then `choose_conversation`, wait for your selection, and
|
|
102
|
+
In a new ordinary chat, ask the agent to call `start_session`, then `choose_conversation`, wait for your selection, and call `get_context`. Use the session ID returned for that chat. Ask for `save_memory` after substantive progress.
|
|
103
103
|
|
|
104
104
|
**ChatGPT and Claude web:** require a separately hosted HTTPS MCP endpoint and a compatible OAuth provider. Local CLI setup does not deploy that service. Follow [remote connector setup](clients/connector-setup.md) for profiles, authentication requirements, and browser picker behavior. These clients are not assumed to be live-connected by completing the local quickstart.
|
|
105
105
|
|
|
@@ -112,7 +112,7 @@ Use the same npm channel and, if configured, the same `--home /absolute/path` fo
|
|
|
112
112
|
Check the installation:
|
|
113
113
|
|
|
114
114
|
```bash
|
|
115
|
-
npx
|
|
115
|
+
npx @tinchu0/knitt@latest doctor
|
|
116
116
|
```
|
|
117
117
|
|
|
118
118
|
`configured` means local paths and managed settings passed inspection. It does not verify client login, trust approval, or a live handoff.
|
|
@@ -128,13 +128,13 @@ npx --yes --package "$KNITT_NEXT_TARBALL" knitt update \
|
|
|
128
128
|
Return to the previous runtime, if an earlier installation exists:
|
|
129
129
|
|
|
130
130
|
```bash
|
|
131
|
-
npx
|
|
131
|
+
npx @tinchu0/knitt@latest rollback --yes
|
|
132
132
|
```
|
|
133
133
|
|
|
134
134
|
Disconnect one project:
|
|
135
135
|
|
|
136
136
|
```bash
|
|
137
|
-
npx
|
|
137
|
+
npx @tinchu0/knitt@latest uninstall \
|
|
138
138
|
--workspace /absolute/path/to/your-project --yes
|
|
139
139
|
```
|
|
140
140
|
|
|
@@ -152,7 +152,7 @@ Uninstall restores unchanged managed settings while retaining user edits, the ru
|
|
|
152
152
|
| “Wrong repository” or “different conversation” | Open the intended project and choose its chat in the current session. |
|
|
153
153
|
| Unmanaged or modified connector conflict | Review the named configuration file. Existing legacy or manually edited settings are not automatically overwritten. See the lifecycle guide before migrating. |
|
|
154
154
|
| Missing runtime path after changing Node | Rerun setup using the current Node installation. Generated executable paths are absolute. |
|
|
155
|
-
| Recent work is absent | Check
|
|
155
|
+
| Recent work is absent | Check project consent, running adapter/hook trust and sync status. For selected local memory, check the `/knit` selection or an explicit `save_memory` call. |
|
|
156
156
|
|
|
157
157
|
### Source-checkout fallback: Antigravity to Codex
|
|
158
158
|
|
|
@@ -167,3 +167,12 @@ npm run memory -- handoff --workspace /absolute/path/to/your-project --launch
|
|
|
167
167
|
The handoff command opens a terminal picker. `--preview` reports the selected handoff without importing or configuring it; `--launch` imports it, configures Codex, and launches Codex in the destination workspace. You can pass `--conversation TITLE_OR_ID` for an explicit selection.
|
|
168
168
|
|
|
169
169
|
This is a separate source-development workflow: it defaults to the checkout's `.memory/events.sqlite`, whereas npm setup uses the persistent installation's data directory. Set `MEMORY_DB` to the intended database if deliberately sharing them. Handoff applies connector settings and may report a conflict with an already managed connection; review that configuration before switching workflows.
|
|
170
|
+
|
|
171
|
+
## Private cloud history and sharing
|
|
172
|
+
|
|
173
|
+
After installation, ask the agent **Set up Knitt for this project**. It checks account and sync status, opens browser pairing when needed, and offers personal work or a friend's invitation. For personal history, review discovered conversations, explicitly choose or create the cloud project, and approve automatic private sync. Nothing uploads from sign-in alone.
|
|
174
|
+
|
|
175
|
+
The running adapter and supported capture hooks import approved project histories independently of continuation selection. Offline uploads queue for retry. `/knit` offers My synced conversations, Local conversations and Shared with me after pairing. Choose explicitly; a later sync or publication does not replace the version already loaded in your current session.
|
|
176
|
+
|
|
177
|
+
Only an explicitly reviewed publication and accepted invitation grants another person access. Private synced history stays private. Settings at https://knit.deeeznuts.me exposes project pause/disconnect and installation revocation. Copies already retrieved can remain in an agent's chat or storage after revocation.
|
|
178
|
+
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tinchu0/knitt",
|
|
3
|
-
"version": "0.1.0-beta.
|
|
3
|
+
"version": "0.1.0-beta.6",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=24"
|
|
@@ -32,14 +32,16 @@
|
|
|
32
32
|
"knitt": "dist/packages/installer/src/cli.js"
|
|
33
33
|
},
|
|
34
34
|
"files": [
|
|
35
|
-
"dist/",
|
|
35
|
+
"dist/apps/server/",
|
|
36
|
+
"dist/packages/",
|
|
37
|
+
"dist/scripts/connector-setup.js",
|
|
38
|
+
"dist/skills/",
|
|
36
39
|
"README.md",
|
|
40
|
+
"docs/usage.md",
|
|
41
|
+
"docs/clients/support-matrix.md",
|
|
37
42
|
"docs/clients/connector-setup.md",
|
|
38
43
|
"docs/clients/npm-installation.md",
|
|
39
|
-
"LICENSE"
|
|
40
|
-
"docs/clients/local-agent-memory.md",
|
|
41
|
-
"docs/usage.md",
|
|
42
|
-
"docs/clients/support-matrix.md"
|
|
44
|
+
"LICENSE"
|
|
43
45
|
],
|
|
44
46
|
"repository": {
|
|
45
47
|
"type": "git",
|
|
@@ -48,7 +50,7 @@
|
|
|
48
50
|
"description": "Shared conversation memory for coding agents",
|
|
49
51
|
"publishConfig": {
|
|
50
52
|
"access": "public",
|
|
51
|
-
"tag": "
|
|
53
|
+
"tag": "latest"
|
|
52
54
|
},
|
|
53
55
|
"license": "Apache-2.0"
|
|
54
56
|
}
|