fuli-context 0.3.0 → 0.5.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 (95) hide show
  1. package/README.en.md +336 -0
  2. package/README.md +220 -174
  3. package/dist/web/assets/ConnectionsPage-CCKWm-6p.js +1 -0
  4. package/dist/web/assets/KnowledgeInspector-BZkB2wJn.js +1 -0
  5. package/dist/web/assets/KnowledgeInspector-CrGYxEob.css +1 -0
  6. package/dist/web/assets/KnowledgeOrganizerPage-CZAF_OlN.css +1 -0
  7. package/dist/web/assets/KnowledgeOrganizerPage-DlvcLwlL.js +1 -0
  8. package/dist/web/assets/KnowledgePage-CNQXd15y.js +1 -0
  9. package/dist/web/assets/KnowledgeWorkspace-CXPE4GCD.js +4 -0
  10. package/dist/web/assets/OverviewPage-ul7g7HXh.js +1 -0
  11. package/dist/web/assets/PersonalProfilePage-CC40Pw2L.js +1 -0
  12. package/dist/web/assets/PersonalProfilePage-S8ZcG2LU.css +1 -0
  13. package/dist/web/assets/PersonalProjectsPage-CPIEcShD.js +1 -0
  14. package/dist/web/assets/PublicProjectsPage-C700sR7z.js +1 -0
  15. package/dist/web/assets/ReviewPage-7MDDUDgA.js +1 -0
  16. package/dist/web/assets/console-B_Ena2DS.js +5 -0
  17. package/dist/web/assets/identity-CjBwYSMX.js +1 -0
  18. package/dist/web/assets/{index-Devf7glZ.css → index-CpLDx3of.css} +1 -1
  19. package/dist/web/assets/index-DAzeFJSc.js +2 -0
  20. package/dist/web/assets/model-C-5RVIJ2.js +1 -0
  21. package/dist/web/assets/{paths-B790iniO.js → paths-BkULqmGI.js} +1 -1
  22. package/dist/web/assets/{vue-router-BYTAoWT3.js → vue-router-DnD3hUm7.js} +1 -1
  23. package/dist/web/index.html +5 -6
  24. package/graph-provider/fuli_graph/app.py +48 -0
  25. package/graph-provider/fuli_graph/common_knowledge.py +443 -0
  26. package/graph-provider/fuli_graph/common_knowledge_models.py +54 -0
  27. package/graph-provider/fuli_graph/graph_models.py +9 -0
  28. package/graph-provider/fuli_graph/graph_query.py +25 -0
  29. package/graph-provider/fuli_graph/knowledge_audit.py +211 -0
  30. package/graph-provider/fuli_graph/knowledge_feedback_models.py +69 -0
  31. package/graph-provider/fuli_graph/knowledge_management.py +37 -0
  32. package/graph-provider/fuli_graph/knowledge_search.py +24 -2
  33. package/graph-provider/fuli_graph/models.py +69 -0
  34. package/graph-provider/fuli_graph/search_projection.py +59 -0
  35. package/graph-provider/fuli_graph/store_knowledge.py +2 -0
  36. package/graph-provider/pyproject.toml +1 -1
  37. package/npm-shrinkwrap.json +97 -2
  38. package/package.json +3 -1
  39. package/skills/capturing-session-knowledge/SKILL.md +83 -13
  40. package/src/agent-tools/graph-definitions.js +181 -13
  41. package/src/agent-tools/graph-handlers.js +19 -0
  42. package/src/cli/command-registry.js +3 -58
  43. package/src/cli/local-runtime-command.js +16 -2
  44. package/src/cli/local-runtime-options.js +6 -2
  45. package/src/cli.js +2 -37
  46. package/src/graphiti/agent-knowledge-workflows.js +543 -0
  47. package/src/graphiti/federated-application.js +85 -104
  48. package/src/graphiti/knowledge-provider-mapping.js +91 -0
  49. package/src/graphiti/provider-client.js +15 -0
  50. package/src/graphiti/source-uri.js +29 -0
  51. package/src/http/request-policy.js +37 -2
  52. package/src/local-runtime/lifecycle.js +11 -1
  53. package/src/mcp/common-knowledge-preview-tokens.js +67 -0
  54. package/src/mcp/create-mcp-server.js +43 -7
  55. package/src/mcp/instructions.js +6 -7
  56. package/src/mcp/lifecycle-audit.js +27 -0
  57. package/src/mcp/task-context-registry.js +93 -0
  58. package/src/mcp/tool-annotations.js +16 -1
  59. package/src/mcp/tool-result.js +24 -0
  60. package/src/runtime-options.js +7 -8
  61. package/src/server/lan-access.js +52 -0
  62. package/src/server.js +67 -8
  63. package/src/setup/agent-installation-status.js +14 -2
  64. package/src/setup/agents.js +12 -1
  65. package/src/setup/claude-code-config.js +194 -0
  66. package/src/setup/config-backup.js +20 -5
  67. package/src/setup/graph-runtime.js +78 -9
  68. package/dist/web/assets/ConnectionsPage-CY6H_mJJ.js +0 -1
  69. package/dist/web/assets/KnowledgeInspector-BSpz5Sfm.js +0 -1
  70. package/dist/web/assets/KnowledgeInspector-CHbB_0rC.css +0 -1
  71. package/dist/web/assets/KnowledgeOrganizerPage-BlEvhPrv.css +0 -1
  72. package/dist/web/assets/KnowledgeOrganizerPage-CvjGPlUc.js +0 -1
  73. package/dist/web/assets/KnowledgePage-Khuo3cNs.js +0 -1
  74. package/dist/web/assets/KnowledgeWorkspace-DVZusvem.js +0 -4
  75. package/dist/web/assets/OverviewPage-DC4C4Fhn.js +0 -1
  76. package/dist/web/assets/PersonalProfilePage-CSV9Mtgz.js +0 -1
  77. package/dist/web/assets/PersonalProfilePage-CVJ3TcRi.css +0 -1
  78. package/dist/web/assets/PersonalProjectsPage-A50EaseQ.js +0 -1
  79. package/dist/web/assets/PublicProjectsPage-BAdO_bae.js +0 -1
  80. package/dist/web/assets/ReviewPage-Dztk2jDG.js +0 -1
  81. package/dist/web/assets/console-tbvTUi6p.js +0 -1
  82. package/dist/web/assets/identity-B3s5CXhv.js +0 -1
  83. package/dist/web/assets/index-DwUDhQKc.js +0 -6
  84. package/dist/web/assets/model-DVT8sjy9.js +0 -1
  85. package/dist/web/assets/runtime-dom.esm-bundler-DttsK21F.js +0 -1
  86. package/src/cli/commands/candidates.js +0 -17
  87. package/src/cli/commands/ingestion.js +0 -32
  88. package/src/cli/commands/reads.js +0 -50
  89. package/src/cli/commands/spaces.js +0 -20
  90. package/src/cli/invocation.js +0 -47
  91. package/src/cli/migrate-command.js +0 -71
  92. package/src/cli/migration-destination.js +0 -117
  93. package/src/storage/import-json.js +0 -70
  94. package/src/storage/legacy-record-validation.js +0 -152
  95. package/src/storage/legacy-snapshot-validation.js +0 -32
package/README.en.md ADDED
@@ -0,0 +1,336 @@
1
+ # Fuli
2
+
3
+ [中文](README.md)
4
+
5
+ Fuli is a local-first collaboration context graph for AI agents. It turns reusable knowledge,
6
+ experience, decision rationale, and preferences from human–AI project work into assets with
7
+ provenance, scope, authority, and temporal history. Codex, Claude Code, and Cursor can then reuse
8
+ those assets in later tasks instead of relearning the same context.
9
+
10
+ Fuli is not a transcript archive, and it is not an attempt to build a personality model that
11
+ replaces human judgment. AI retrieves, summarizes, warns, and executes; humans retain final
12
+ authority.
13
+
14
+ The npm package is the personal edition: personal knowledge, the graph database, and the
15
+ management UI run locally. A team-shared Provider is a separate deployment unit. Personal taste,
16
+ personality, and judgment preferences are never published into the shared layer.
17
+
18
+ ## Philosophy
19
+
20
+ ### 1. Measure reuse value, not knowledge volume
21
+
22
+ Fuli is built around one question:
23
+
24
+ > Without Fuli, would the agent have to relearn information that is confirmed, still valid, and
25
+ > relevant to the current task?
26
+
27
+ Node count, transcript count, and graph size are not success metrics. The product succeeds when a
28
+ past collaboration asset is reused within the correct project, time, provenance, and authority
29
+ boundaries—and reduces repeated explanation, correction, or rework.
30
+
31
+ ### 2. Review every task; do not retain every task
32
+
33
+ A task may produce:
34
+
35
+ - reusable knowledge such as API conventions, runbooks, release procedures, or constraints;
36
+ - experience explaining why an approach worked or failed;
37
+ - a decision trace with options, a human choice, rationale, and later validation;
38
+ - judgment aids such as preferences, principles, taste, or personality tendencies.
39
+
40
+ It may also produce only disposable output, a guess, or a one-off choice. In that case,
41
+ `retain_nothing` is the correct result. Every task should perform a knowledge-value checkpoint, but
42
+ not every task must become stored knowledge.
43
+
44
+ ### 3. Human authority outranks agent repetition
45
+
46
+ An agent may discover candidates, surface conflicts, recommend promotion, or resolve a deferred
47
+ conflict when explicitly authorized. It may not turn semantic similarity, repetition, or its own
48
+ judgment into human confirmation. Shared-knowledge promotion and sensitive project mutations use a
49
+ preview followed by an explicit, one-time, atomic action.
50
+
51
+ ### 4. Assemble context, then retrieve evidence on demand
52
+
53
+ Fuli does not inject the complete history at session start. The entry step loads only effective
54
+ personal-global preferences and preferences from one exactly matched project. The agent retrieves
55
+ detailed knowledge when the task needs it. Retrieval alone is not usage; a usage event is recorded
56
+ only when an item materially affects an answer, implementation, or decision.
57
+
58
+ ### 5. Preserve evolution instead of overwriting history
59
+
60
+ An old approach may have been correct under earlier conditions and later replaced. Fuli preserves
61
+ provenance, confirmation authority, time, rationale, revisions, supersession, and negative evidence
62
+ so an agent can explain both what applies now and why the past was different. Negative feedback may
63
+ lower rank or trigger review, but it never silently erases history.
64
+
65
+ ### 6. Put shared knowledge in the parent; keep differences in each child
66
+
67
+ For example, hotel and flight projects can keep their own PRDs, configuration, and domain rules,
68
+ while a parent activity-platform project owns shared local-run, mock, test, and deployment runbooks:
69
+
70
+ ```text
71
+ Activity platform (parent: shared runbooks)
72
+ ├── Hotel project (child: hotel PRD / configuration / overrides)
73
+ └── Flight project (child: flight PRD / configuration / overrides)
74
+ ```
75
+
76
+ When an agent works in the hotel project, it searches hotel-local knowledge first, then follows
77
+ explicit outgoing `PART_OF` or `USES_KNOWLEDGE_FROM` relationships to authorized sources, up to two
78
+ hops. A child item with the same stable key overrides an inherited item. Generic `RELATED_TO`
79
+ relationships do not expand scope, and project-scoped personal preferences are not inherited.
80
+
81
+ Similar items from multiple children create only a common-knowledge candidate. Current clustering
82
+ is a lexical heuristic, not proof of semantic equivalence. A human must select the canonical item,
83
+ duplicates, parent project, and rationale before an atomic promotion can occur.
84
+
85
+ ### 7. Local first; no personal model in the shared layer
86
+
87
+ The personal graph stays local by default. Fuli stores structured reusable knowledge, not raw
88
+ transcripts, credentials, temporary logs, or command output. The team-shared layer contains only
89
+ confirmed project or domain knowledge with context and provenance—not personal taste, personality,
90
+ or judgment preferences.
91
+
92
+ ## Agent interaction sequence
93
+
94
+ This is the simplified lifecycle for a normal task. The Chinese
95
+ [detailed sequence diagram](acceptance/智能体调用时序图.md) also covers inheritance, usage counting,
96
+ write previews, and source markers.
97
+
98
+ ```mermaid
99
+ sequenceDiagram
100
+ autonumber
101
+ actor U as User
102
+ participant A as Agent
103
+ participant L as Lifecycle integration
104
+ participant F as Fuli MCP
105
+ participant G as Local graph
106
+
107
+ U->>A: Submit a task in the current project
108
+ alt Claude Code (hook-enforced)
109
+ L->>F: UserPromptSubmit → begin_task_context
110
+ F-->>A: Effective preferences, project, and task token
111
+ else Codex / Cursor (prompt fallback)
112
+ A->>F: get_collaboration_preferences(projectPath)
113
+ F-->>A: Effective preferences and exact project
114
+ end
115
+
116
+ opt The task depends on historical knowledge
117
+ A->>F: search_current_project_knowledge
118
+ F->>G: Search child first, then authorized parents
119
+ G-->>A: Bounded content, status, provenance, and history
120
+ opt Knowledge materially affects the result
121
+ A->>F: record_knowledge_usage
122
+ end
123
+ end
124
+
125
+ A->>A: Complete the implementation, validation, or answer
126
+ opt The task creates a decision, contradiction, or stale signal
127
+ A->>F: Record rationale or knowledge feedback
128
+ end
129
+ A->>F: checkpoint_task_knowledge
130
+ alt A small durable candidate batch exists
131
+ F->>G: capture_candidates
132
+ else Nothing should be retained
133
+ F-->>A: retain_nothing
134
+ end
135
+
136
+ alt Claude Code Stop hook
137
+ L->>F: verify_task_checkpoint
138
+ F-->>L: Allow stop only after review
139
+ else Prompt-fallback agent
140
+ Note over A,F: Same contract, but the host cannot deterministically block a missed review
141
+ end
142
+ A-->>U: Return the result and any Fuli sources actually used
143
+ ```
144
+
145
+ ## Current capabilities and evidence boundaries
146
+
147
+ Core mechanisms covered by implementation and automated tests include:
148
+
149
+ - a local personal space, exact project scope, and selective parent inheritance;
150
+ - preference confirmation, deferred conflict resolution, revision history, and source markers;
151
+ - task entry and completion checkpoints, plus Claude Code entry and Stop hooks;
152
+ - decision options, rationale, and validation results supplied during initial capture;
153
+ - knowledge-usage events, negative feedback, and content-generation isolation;
154
+ - common-knowledge discovery and preview-token-protected atomic promotion.
155
+
156
+ The following must not be presented as already proven:
157
+
158
+ - the A/B thresholds in `FULI_ALIGNMENT_BENCHMARK.md` are acceptance conventions; claims that Fuli
159
+ reduces explanation or rework require a sufficiently large set of controlled, real paired tasks;
160
+ - benchmark projects and conversations are explicitly labeled **MOCK / synthetic data**, not user or
161
+ production data;
162
+ - the decision tool can include validation during initial capture, but it does not yet expose a
163
+ dedicated operation for appending immutable validation results to an existing `Decision`;
164
+ - Claude Code has deterministic lifecycle hooks; Codex and Cursor currently use prompt fallback and
165
+ must not be described as equally enforced.
166
+
167
+ ## Installation
168
+
169
+ Requirements:
170
+
171
+ - Node.js 24.12 or later;
172
+ - Docker Compose v2 through Docker Desktop, Rancher Desktop, or another compatible runtime;
173
+ - approximately 4 GB of memory available to the containers.
174
+
175
+ Install globally and initialize:
176
+
177
+ ```bash
178
+ npm install --global fuli-context
179
+ fuli setup
180
+ ```
181
+
182
+ `fuli setup` first shows its plan and asks for confirmation. It then checks the container runtime,
183
+ initializes local Graphiti / Neo4j, creates a personal space, installs the companion Agent Skills,
184
+ and registers the `fuli` MCP with detected agents. The default setup connects only the personal
185
+ Provider; it does not simulate a team-shared service.
186
+
187
+ Open the management UI after setup:
188
+
189
+ ```bash
190
+ fuli open
191
+ ```
192
+
193
+ The default URL is `http://127.0.0.1:2727`.
194
+
195
+ ## CLI
196
+
197
+ The global package provides two equivalent commands: `fuli` and the short alias `fl`.
198
+
199
+ | Command | Purpose |
200
+ | --- | --- |
201
+ | `fuli setup [options]` | Initialize the Provider, UI, agent integrations, and Skills; safe to rerun |
202
+ | `fuli start [options]` | Start local services |
203
+ | `fuli stop [--data-dir DIR]` | Stop services without deleting data |
204
+ | `fuli restart [options]` | Restart local services |
205
+ | `fuli status [--json]` | Show service status |
206
+ | `fuli open` | Open the management UI |
207
+ | `fuli update [setup options]` | Update the npm package and refresh local integrations |
208
+ | `fuli uninstall [--yes]` | Remove agent integrations and services while preserving knowledge data |
209
+
210
+ Common commands:
211
+
212
+ ```bash
213
+ fuli --version
214
+ fuli status
215
+ fuli restart --rebuild
216
+ fuli start --lan
217
+ fuli stop
218
+ ```
219
+
220
+ `start`, `restart`, and `setup` accept options such as `--data-dir DIR`,
221
+ `--personal-space NAME`, and `--port PORT`. `start` and `restart` also accept the explicit
222
+ `--lan` flag. LAN mode listens on private IPv4 addresses and prints the reachable URLs, the
223
+ `fuli` username, and a temporary access code generated for that start. The default remains
224
+ loopback-only; internal Providers and Neo4j ports are never exposed by `--lan`. LAN mode uses
225
+ HTTP Basic Auth and is intended only for trusted home or office Wi-Fi, not public deployment.
226
+
227
+ Additional setup options include:
228
+
229
+ | Option | Purpose |
230
+ | --- | --- |
231
+ | `--yes` | Skip confirmation for unattended setup |
232
+ | `--codex-only` | Configure Codex only |
233
+ | `--skip-agents` | Do not change agent configuration or Skills |
234
+ | `--no-start` | Initialize the Provider without starting the UI |
235
+ | `--personal-only` | Use only the personal Provider; this is the default |
236
+ | `--with-dev-public` | Start a development shared Provider for local integration work only |
237
+
238
+ Update:
239
+
240
+ ```bash
241
+ fuli update
242
+ ```
243
+
244
+ The update flow verifies that it will not downgrade the installation, stops the old services,
245
+ installs `fuli-context@latest`, and refreshes agent integrations. Existing knowledge, configuration
246
+ backups, and Neo4j volumes remain intact. Reuse any custom setup options during updates.
247
+
248
+ Uninstall:
249
+
250
+ ```bash
251
+ fuli uninstall
252
+ npm uninstall --global fuli-context
253
+ ```
254
+
255
+ Automated uninstall does not permanently delete the personal graph, which allows a later install to
256
+ reuse the same data.
257
+
258
+ ## Agent integrations and primary tools
259
+
260
+ Fuli installs the `capturing-session-knowledge` and `grilling-project` Skills for supported agents.
261
+ Claude Code uses `UserPromptSubmit` and `Stop` hooks for the task lifecycle. Codex's user-level
262
+ `AGENTS.md` and Cursor instructions use prompt fallback. Preference content remains in local Fuli as
263
+ the single source of truth and is not copied into agent configuration.
264
+
265
+ | Tool | Purpose |
266
+ | --- | --- |
267
+ | `begin_task_context` | Hook entry: create a task token and return effective context |
268
+ | `get_collaboration_preferences` | Fallback entry: read global and exact-project preferences |
269
+ | `search_current_project_knowledge` | Search the child first, then authorized knowledge sources |
270
+ | `search_knowledge_graph` | Run a general query within an explicit bounded scope |
271
+ | `record_knowledge_usage` | Record a citation or application that materially affected the result |
272
+ | `record_knowledge_feedback` | Preserve rejection, failed validation, contradiction, or stale evidence |
273
+ | `record_decision_trace` | Store options, rejected alternatives, rationale, and optional initial validation |
274
+ | `capture_session_knowledge` | Store a small structured batch of durable candidates |
275
+ | `checkpoint_task_knowledge` | Complete review with `capture_candidates` or `retain_nothing` |
276
+ | `discover_common_knowledge_candidates` | Read-only discovery of possible parent-project knowledge |
277
+ | `preview_common_knowledge_promotion` | Preview a human-confirmed promotion |
278
+ | `apply_common_knowledge_promotion` | Apply the preview atomically with a one-time token |
279
+ | `resolve_deferred_preference_conflict` | Resolve an AI-deferred conflict only when a task needs it |
280
+
281
+ ## Privacy and safety boundaries
282
+
283
+ - Personal knowledge is written to the local Provider.
284
+ - Agents distill structured knowledge instead of storing raw transcripts.
285
+ - Tokens, cookies, private keys, credentials, private contact details, temporary logs, and raw command
286
+ output must not enter the graph.
287
+ - Graphiti's remote-LLM path is disabled; embeddings are currently computed locally.
288
+ - Searches are bounded by personal space and project scope instead of mixing every project.
289
+ - Shared promotion requires auditable human confirmation. Agent usage evidence can promote an item
290
+ only as far as `agent_confirmed`.
291
+ - Fuli is not a real-time monitoring or Git service; current state must be read from the relevant
292
+ source system.
293
+
294
+ ## Local services
295
+
296
+ | Service | Default address |
297
+ | --- | --- |
298
+ | Personal Neo4j Browser / Bolt | `127.0.0.1:7474` / `127.0.0.1:7687` |
299
+ | Personal Provider | `127.0.0.1:8787` |
300
+ | Fuli management UI | `127.0.0.1:2727` |
301
+
302
+ To access the UI from another device on the same Wi-Fi, run `fuli start --lan`. Starting LAN mode
303
+ from a loopback-only runtime safely restarts only the management UI and preserves Provider and
304
+ graph data. Run `fuli restart` to return to loopback-only mode. Starting LAN mode again rotates
305
+ the temporary access code.
306
+
307
+ If a port is occupied, Docker Compose is unavailable, or the container runtime is not running,
308
+ setup stops before modifying agent configuration and reports the cause.
309
+
310
+ ## Acceptance and development
311
+
312
+ - [Alignment Benchmark](FULI_ALIGNMENT_BENCHMARK.md)
313
+ - [Chinese acceptance index](acceptance/README.md)
314
+ - [Knowledge retrieval and confirmation diagrams](acceptance/知识检索与确认流程图.md)
315
+
316
+ ```bash
317
+ npm install
318
+ npm test
319
+ npm run test:package
320
+ ```
321
+
322
+ Provider validation:
323
+
324
+ ```bash
325
+ python3 -m compileall -q graph-provider/fuli_graph
326
+ python3 -m pytest -q graph-provider/tests
327
+ docker compose -f compose.graphiti.yml config --quiet
328
+ ```
329
+
330
+ `npm run test:package` builds the web UI, creates a real npm tarball, installs it into an isolated
331
+ global prefix, and verifies `fuli` / `fl`, version output, help output, and the packaged UI. Tests,
332
+ QA screenshots, and internal design documents are excluded from the npm package.
333
+
334
+ ## License
335
+
336
+ [Apache-2.0](LICENSE)