graphlin 0.1.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 (60) hide show
  1. package/.claude-plugin/plugin.json +12 -0
  2. package/.codex-plugin/plugin.json +29 -0
  3. package/.mcp.json +9 -0
  4. package/LICENSE +21 -0
  5. package/README.md +71 -0
  6. package/adapters/README.md +32 -0
  7. package/adapters/claude/hooks.json +10 -0
  8. package/adapters/claude/profile.json +18 -0
  9. package/adapters/codex/hooks.json +9 -0
  10. package/adapters/codex/profile.json +22 -0
  11. package/adapters/kiro/profile.json +8 -0
  12. package/mcp.json +11 -0
  13. package/package.json +114 -0
  14. package/plugin.json +20 -0
  15. package/runtime/collector/index.mjs +23 -0
  16. package/runtime/core/candidates.mjs +300 -0
  17. package/runtime/core/common.mjs +69 -0
  18. package/runtime/core/evidence.mjs +150 -0
  19. package/runtime/core/graph.mjs +398 -0
  20. package/runtime/core/index.mjs +4 -0
  21. package/runtime/core/lexical.mjs +255 -0
  22. package/runtime/core/privacy.mjs +206 -0
  23. package/runtime/core/tool-discovery.mjs +122 -0
  24. package/runtime/daemon/auth.mjs +50 -0
  25. package/runtime/daemon/connection-info.mjs +249 -0
  26. package/runtime/daemon/demo.mjs +195 -0
  27. package/runtime/daemon/diagnostics.mjs +404 -0
  28. package/runtime/daemon/export.mjs +7 -0
  29. package/runtime/daemon/ipc.mjs +28 -0
  30. package/runtime/daemon/lock.mjs +137 -0
  31. package/runtime/daemon/manager.mjs +320 -0
  32. package/runtime/daemon/paths.mjs +108 -0
  33. package/runtime/daemon/persistence.mjs +64 -0
  34. package/runtime/daemon/server.mjs +292 -0
  35. package/runtime/daemon/settings.mjs +103 -0
  36. package/runtime/jev/fixture.mjs +99 -0
  37. package/runtime/jev/index.mjs +784 -0
  38. package/runtime/jev/questions.mjs +268 -0
  39. package/runtime/jev/wire.mjs +152 -0
  40. package/runtime/pipeline.mjs +1071 -0
  41. package/runtime/web/app.js +2596 -0
  42. package/runtime/web/index.html +265 -0
  43. package/runtime/web/layout.js +336 -0
  44. package/runtime/web/sidebar.js +525 -0
  45. package/runtime/web/sketch.js +347 -0
  46. package/runtime/web/style.css +593 -0
  47. package/schemas/bundle.schema.json +243 -0
  48. package/schemas/event.schema.json +108 -0
  49. package/schemas/graph.schema.json +449 -0
  50. package/schemas/patch.schema.json +111 -0
  51. package/scripts/arguments.mjs +37 -0
  52. package/scripts/build-packages.mjs +160 -0
  53. package/scripts/collect.sh +23 -0
  54. package/scripts/collector.mjs +11 -0
  55. package/scripts/control.mjs +80 -0
  56. package/scripts/daemon.mjs +28 -0
  57. package/scripts/graphlin.mjs +112 -0
  58. package/scripts/onboarding.mjs +413 -0
  59. package/scripts/validate-packages.mjs +118 -0
  60. package/skills/graphlin/SKILL.md +103 -0
@@ -0,0 +1,449 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "title": "Graphlin graph",
4
+ "type": "object",
5
+ "additionalProperties": false,
6
+ "properties": {
7
+ "schemaVersion": {
8
+ "const": 1
9
+ },
10
+ "revision": {
11
+ "type": "integer",
12
+ "minimum": 0,
13
+ "maximum": 9007199254740991
14
+ },
15
+ "nodes": {
16
+ "type": "array",
17
+ "items": {
18
+ "$ref": "#/$defs/node"
19
+ },
20
+ "minItems": 0,
21
+ "maxItems": 256
22
+ },
23
+ "edges": {
24
+ "type": "array",
25
+ "items": {
26
+ "$ref": "#/$defs/edge"
27
+ },
28
+ "minItems": 0,
29
+ "maxItems": 768
30
+ }
31
+ },
32
+ "required": [
33
+ "schemaVersion",
34
+ "revision",
35
+ "nodes",
36
+ "edges"
37
+ ],
38
+ "$defs": {
39
+ "sourceRef": {
40
+ "oneOf": [
41
+ {
42
+ "type": "object",
43
+ "additionalProperties": false,
44
+ "properties": {
45
+ "type": {
46
+ "const": "artifact"
47
+ },
48
+ "artifactId": {
49
+ "type": "string",
50
+ "pattern": "^(?:[a-z][a-z0-9_]{0,23}-)?[a-f0-9]{24,64}$"
51
+ },
52
+ "hash": {
53
+ "type": "string",
54
+ "pattern": "^[a-f0-9]{64}$"
55
+ },
56
+ "generation": {
57
+ "type": "integer",
58
+ "minimum": 1,
59
+ "maximum": 9007199254740991
60
+ }
61
+ },
62
+ "required": [
63
+ "type",
64
+ "artifactId",
65
+ "hash",
66
+ "generation"
67
+ ]
68
+ },
69
+ {
70
+ "type": "object",
71
+ "additionalProperties": false,
72
+ "properties": {
73
+ "type": {
74
+ "const": "message"
75
+ },
76
+ "messageId": {
77
+ "type": "string",
78
+ "pattern": "^(?:[a-z][a-z0-9_]{0,23}-)?[a-f0-9]{24,64}$"
79
+ },
80
+ "hash": {
81
+ "type": "string",
82
+ "pattern": "^[a-f0-9]{64}$"
83
+ },
84
+ "contentVersion": {
85
+ "type": "integer",
86
+ "minimum": 1,
87
+ "maximum": 9007199254740991
88
+ }
89
+ },
90
+ "required": [
91
+ "type",
92
+ "messageId",
93
+ "hash",
94
+ "contentVersion"
95
+ ]
96
+ }
97
+ ]
98
+ },
99
+ "reference": {
100
+ "type": "object",
101
+ "additionalProperties": false,
102
+ "properties": {
103
+ "artifactId": {
104
+ "type": "string",
105
+ "pattern": "^(?:[a-z][a-z0-9_]{0,23}-)?[a-f0-9]{24,64}$"
106
+ },
107
+ "hash": {
108
+ "type": "string",
109
+ "pattern": "^[a-f0-9]{64}$"
110
+ },
111
+ "generation": {
112
+ "type": "integer",
113
+ "minimum": 1,
114
+ "maximum": 9007199254740991
115
+ },
116
+ "eventId": {
117
+ "type": "string",
118
+ "pattern": "^(?:[a-z][a-z0-9_]{0,23}-)?[a-f0-9]{24,64}$"
119
+ },
120
+ "startLine": {
121
+ "type": "integer",
122
+ "minimum": 1,
123
+ "maximum": 10000000
124
+ },
125
+ "endLine": {
126
+ "type": "integer",
127
+ "minimum": 1,
128
+ "maximum": 10000000
129
+ },
130
+ "sourceClass": {
131
+ "enum": [
132
+ "source",
133
+ "public_intent"
134
+ ]
135
+ },
136
+ "basis": {
137
+ "const": "jev_interpretation"
138
+ },
139
+ "sourceRef": {
140
+ "oneOf": [
141
+ {
142
+ "type": "object",
143
+ "additionalProperties": false,
144
+ "properties": {
145
+ "type": {
146
+ "const": "artifact"
147
+ },
148
+ "artifactId": {
149
+ "type": "string",
150
+ "pattern": "^(?:[a-z][a-z0-9_]{0,23}-)?[a-f0-9]{24,64}$"
151
+ },
152
+ "hash": {
153
+ "type": "string",
154
+ "pattern": "^[a-f0-9]{64}$"
155
+ },
156
+ "generation": {
157
+ "type": "integer",
158
+ "minimum": 1,
159
+ "maximum": 9007199254740991
160
+ }
161
+ },
162
+ "required": [
163
+ "type",
164
+ "artifactId",
165
+ "hash",
166
+ "generation"
167
+ ]
168
+ },
169
+ {
170
+ "type": "object",
171
+ "additionalProperties": false,
172
+ "properties": {
173
+ "type": {
174
+ "const": "message"
175
+ },
176
+ "messageId": {
177
+ "type": "string",
178
+ "pattern": "^(?:[a-z][a-z0-9_]{0,23}-)?[a-f0-9]{24,64}$"
179
+ },
180
+ "hash": {
181
+ "type": "string",
182
+ "pattern": "^[a-f0-9]{64}$"
183
+ },
184
+ "contentVersion": {
185
+ "type": "integer",
186
+ "minimum": 1,
187
+ "maximum": 9007199254740991
188
+ }
189
+ },
190
+ "required": [
191
+ "type",
192
+ "messageId",
193
+ "hash",
194
+ "contentVersion"
195
+ ]
196
+ }
197
+ ]
198
+ },
199
+ "excerpt": {
200
+ "type": "string",
201
+ "minLength": 1,
202
+ "maxLength": 256
203
+ }
204
+ },
205
+ "required": [
206
+ "artifactId",
207
+ "hash",
208
+ "generation",
209
+ "eventId",
210
+ "startLine",
211
+ "endLine",
212
+ "sourceClass",
213
+ "basis"
214
+ ],
215
+ "allOf": [
216
+ {
217
+ "if": {
218
+ "properties": {
219
+ "sourceClass": {
220
+ "const": "public_intent"
221
+ }
222
+ }
223
+ },
224
+ "then": {
225
+ "required": [
226
+ "sourceRef"
227
+ ],
228
+ "properties": {
229
+ "sourceRef": {
230
+ "properties": {
231
+ "type": {
232
+ "const": "message"
233
+ }
234
+ }
235
+ }
236
+ }
237
+ }
238
+ }
239
+ ]
240
+ },
241
+ "node": {
242
+ "type": "object",
243
+ "additionalProperties": false,
244
+ "properties": {
245
+ "id": {
246
+ "type": "string",
247
+ "pattern": "^(?:[a-z][a-z0-9_]{0,23}-)?[a-f0-9]{24,64}$"
248
+ },
249
+ "evidenceState": {
250
+ "enum": [
251
+ "proposed",
252
+ "observed",
253
+ "verified",
254
+ "removed"
255
+ ]
256
+ },
257
+ "classification": {
258
+ "enum": [
259
+ "pending",
260
+ "accepted",
261
+ "tentative",
262
+ "abstained",
263
+ "stale"
264
+ ]
265
+ },
266
+ "validity": {
267
+ "enum": [
268
+ "current",
269
+ "stale",
270
+ "retracted"
271
+ ]
272
+ },
273
+ "sourceRefs": {
274
+ "type": "array",
275
+ "items": {
276
+ "$ref": "#/$defs/reference"
277
+ },
278
+ "minItems": 1,
279
+ "maxItems": 8
280
+ },
281
+ "confidence": {
282
+ "type": "number",
283
+ "minimum": 0,
284
+ "maximum": 1
285
+ },
286
+ "label": {
287
+ "type": "string",
288
+ "minLength": 1,
289
+ "maxLength": 80
290
+ },
291
+ "kind": {
292
+ "enum": [
293
+ "client",
294
+ "service",
295
+ "datastore",
296
+ "queue",
297
+ "external",
298
+ "module",
299
+ "function",
300
+ "class",
301
+ "interface",
302
+ "event",
303
+ "configuration",
304
+ "package"
305
+ ]
306
+ },
307
+ "shape": {
308
+ "enum": [
309
+ "rounded_rect",
310
+ "rect",
311
+ "cylinder",
312
+ "cloud",
313
+ "diamond",
314
+ "group",
315
+ "hexagon",
316
+ "class_box",
317
+ "interface_box",
318
+ "document",
319
+ "parallelogram",
320
+ "folder",
321
+ "browser",
322
+ "component",
323
+ "queue"
324
+ ]
325
+ },
326
+ "x": {
327
+ "type": "number",
328
+ "minimum": -100000,
329
+ "maximum": 100000
330
+ },
331
+ "y": {
332
+ "type": "number",
333
+ "minimum": -100000,
334
+ "maximum": 100000
335
+ },
336
+ "activityState": {
337
+ "enum": [
338
+ "idle",
339
+ "pending",
340
+ "running",
341
+ "failed",
342
+ "interrupted",
343
+ "unknown"
344
+ ]
345
+ }
346
+ },
347
+ "required": [
348
+ "id",
349
+ "evidenceState",
350
+ "classification",
351
+ "validity",
352
+ "sourceRefs",
353
+ "label",
354
+ "kind",
355
+ "shape",
356
+ "x",
357
+ "y",
358
+ "activityState"
359
+ ]
360
+ },
361
+ "edge": {
362
+ "type": "object",
363
+ "additionalProperties": false,
364
+ "properties": {
365
+ "id": {
366
+ "type": "string",
367
+ "pattern": "^(?:[a-z][a-z0-9_]{0,23}-)?[a-f0-9]{24,64}$"
368
+ },
369
+ "evidenceState": {
370
+ "enum": [
371
+ "proposed",
372
+ "observed",
373
+ "verified",
374
+ "removed"
375
+ ]
376
+ },
377
+ "classification": {
378
+ "enum": [
379
+ "pending",
380
+ "accepted",
381
+ "tentative",
382
+ "abstained",
383
+ "stale"
384
+ ]
385
+ },
386
+ "validity": {
387
+ "enum": [
388
+ "current",
389
+ "stale",
390
+ "retracted"
391
+ ]
392
+ },
393
+ "sourceRefs": {
394
+ "type": "array",
395
+ "items": {
396
+ "$ref": "#/$defs/reference"
397
+ },
398
+ "minItems": 1,
399
+ "maxItems": 8
400
+ },
401
+ "confidence": {
402
+ "type": "number",
403
+ "minimum": 0,
404
+ "maximum": 1
405
+ },
406
+ "source": {
407
+ "type": "string",
408
+ "pattern": "^(?:[a-z][a-z0-9_]{0,23}-)?[a-f0-9]{24,64}$"
409
+ },
410
+ "target": {
411
+ "type": "string",
412
+ "pattern": "^(?:[a-z][a-z0-9_]{0,23}-)?[a-f0-9]{24,64}$"
413
+ },
414
+ "relation": {
415
+ "enum": [
416
+ "calls",
417
+ "reads",
418
+ "writes",
419
+ "publishes",
420
+ "consumes",
421
+ "depends_on"
422
+ ]
423
+ },
424
+ "label": {
425
+ "enum": [
426
+ "calls",
427
+ "reads",
428
+ "writes",
429
+ "publishes",
430
+ "consumes",
431
+ "depends_on"
432
+ ]
433
+ }
434
+ },
435
+ "required": [
436
+ "id",
437
+ "evidenceState",
438
+ "classification",
439
+ "validity",
440
+ "sourceRefs",
441
+ "source",
442
+ "target",
443
+ "relation",
444
+ "label"
445
+ ]
446
+ }
447
+ },
448
+ "$comment": "Runtime additionally enforces canonical source versions, exact labels, provenance, unique IDs, endpoints, relation labels, secret/control filtering, source spans, public-intent state, and serialized UTF-8 size. New compiled graphs: 896 KiB; hard limit: 1 MiB. Invalidation has reserved headroom."
449
+ }
@@ -0,0 +1,111 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "title": "Graphlin patch",
4
+ "type": "object",
5
+ "additionalProperties": false,
6
+ "properties": {
7
+ "schemaVersion": {
8
+ "const": 1
9
+ },
10
+ "id": {
11
+ "anyOf": [
12
+ {
13
+ "type": "string",
14
+ "pattern": "^(?:[a-z][a-z0-9_]{0,23}-)?[a-f0-9]{24,64}$"
15
+ },
16
+ {
17
+ "const": "restore"
18
+ }
19
+ ]
20
+ },
21
+ "baseRevision": {
22
+ "type": "integer",
23
+ "minimum": 0,
24
+ "maximum": 9007199254740991
25
+ },
26
+ "revision": {
27
+ "type": "integer",
28
+ "minimum": 1,
29
+ "maximum": 9007199254740991
30
+ },
31
+ "causedBy": {
32
+ "type": "array",
33
+ "items": {
34
+ "type": "string",
35
+ "pattern": "^(?:[a-z][a-z0-9_]{0,23}-)?[a-f0-9]{24,64}$"
36
+ },
37
+ "minItems": 0,
38
+ "maxItems": 12
39
+ },
40
+ "operations": {
41
+ "type": "array",
42
+ "items": {
43
+ "oneOf": [
44
+ {
45
+ "type": "object",
46
+ "additionalProperties": false,
47
+ "properties": {
48
+ "op": {
49
+ "const": "node.upsert"
50
+ },
51
+ "node": {
52
+ "$ref": "graph.schema.json#/$defs/node"
53
+ }
54
+ },
55
+ "required": [
56
+ "op",
57
+ "node"
58
+ ]
59
+ },
60
+ {
61
+ "type": "object",
62
+ "additionalProperties": false,
63
+ "properties": {
64
+ "op": {
65
+ "const": "edge.upsert"
66
+ },
67
+ "edge": {
68
+ "$ref": "graph.schema.json#/$defs/edge"
69
+ }
70
+ },
71
+ "required": [
72
+ "op",
73
+ "edge"
74
+ ]
75
+ },
76
+ {
77
+ "type": "object",
78
+ "additionalProperties": false,
79
+ "properties": {
80
+ "op": {
81
+ "enum": [
82
+ "node.remove",
83
+ "edge.remove"
84
+ ]
85
+ },
86
+ "id": {
87
+ "type": "string",
88
+ "pattern": "^(?:[a-z][a-z0-9_]{0,23}-)?[a-f0-9]{24,64}$"
89
+ }
90
+ },
91
+ "required": [
92
+ "op",
93
+ "id"
94
+ ]
95
+ }
96
+ ]
97
+ },
98
+ "minItems": 1,
99
+ "maxItems": 1024
100
+ }
101
+ },
102
+ "required": [
103
+ "schemaVersion",
104
+ "id",
105
+ "baseRevision",
106
+ "revision",
107
+ "causedBy",
108
+ "operations"
109
+ ],
110
+ "$comment": "Runtime enforces revision=baseRevision+1, atomic final graph integrity, cascading node removal, and bounded in-process patch-ID replay history."
111
+ }
@@ -0,0 +1,37 @@
1
+ export function parseArguments(args, { worker = false } = {}) {
2
+ const guided = !worker && (!args.length || args[0].startsWith('-'));
3
+ args = [...args];
4
+ const values = { projectRoot: process.cwd(), allowSource: worker ? false : undefined,
5
+ persistEvidence: worker ? false : undefined, displayEvidence: worker ? true : undefined, background: false };
6
+ const command = worker ? null : args[0] && !args[0].startsWith('-') ? args.shift() : 'start';
7
+ const strings = new Map([['--project', 'projectRoot'], ['--data-dir', 'dataDir']]);
8
+ if (!worker && (command === 'init' || command === 'uninstall' || guided)) strings.set('--host', 'host');
9
+ if (!worker && command === 'logs') strings.set('--file', 'file');
10
+ if (worker) strings.set('--mode', 'mode');
11
+ const seen = new Set();
12
+ while (args.length) {
13
+ const argument = args.shift();
14
+ if (seen.has(argument)) throw new Error('duplicate_argument');
15
+ seen.add(argument);
16
+ if (strings.has(argument)) {
17
+ const value = args.shift();
18
+ if (!value || value.startsWith('--') || value.length > 4096) throw new Error('invalid_argument');
19
+ values[strings.get(argument)] = value;
20
+ } else if (argument === '--port') {
21
+ const value = args.shift();
22
+ if (!/^\d{1,5}$/.test(value ?? '') || Number(value) > 65535) throw new Error('invalid_port');
23
+ values.port = Number(value);
24
+ } else if (argument === '--allow-source' || argument === '--no-source' && !worker) {
25
+ if (seen.has(argument === '--allow-source' ? '--no-source' : '--allow-source')) throw new Error('conflicting_arguments');
26
+ values.allowSource = argument === '--allow-source';
27
+ }
28
+ else if (argument === '--persist-evidence') values.persistEvidence = true;
29
+ else if (argument === '--no-display-evidence') values.displayEvidence = false;
30
+ else if (argument === '--background' && !worker && ['start', 'demo'].includes(command)) values.background = true;
31
+ else if (argument === '--no-open' && !worker && ['start', 'demo', 'open'].includes(command)) values.openBrowser = false;
32
+ else if (argument === '--replace-key' && !worker && command === 'init') values.replaceKey = true;
33
+ else throw new Error('unknown_argument');
34
+ }
35
+ if (values.host !== undefined && !['claude', 'codex', 'both'].includes(values.host)) throw new Error('invalid_host');
36
+ return { command, ...(!worker ? { guided: Boolean(guided) } : {}), ...values };
37
+ }