[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-110862":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":10,"language":11,"languages":10,"totalLinesOfCode":10,"stars":12,"forks":13,"watchers":14,"openIssues":15,"contributorsCount":16,"subscribersCount":16,"size":16,"stars1d":17,"stars7d":18,"stars30d":19,"stars90d":16,"forks30d":16,"starsTrendScore":18,"compositeScore":20,"rankGlobal":10,"rankLanguage":10,"license":21,"archived":22,"fork":22,"defaultBranch":23,"hasWiki":22,"hasPages":24,"topics":25,"createdAt":10,"pushedAt":36,"updatedAt":37,"readmeContent":38,"aiSummary":39,"trendingCount":16,"starSnapshotCount":16,"syncStatus":40,"lastSyncTime":41,"discoverSource":42},110862,"kgdiff","iiwish\u002Fkgdiff","iiwish","git diff for knowledge graphs: semantic, visual diff and review for RDF, OBO and JSON graphs","https:\u002F\u002Fiiwish.github.io\u002Fkgdiff\u002F",null,"TypeScript",64,8,52,9,0,1,3,11,47.46,"MIT License",false,"main",true,[26,27,28,29,30,31,32,33,34,35],"code-review","diff","graph-visualization","graphrag","knowledge-graph","obo","ontology","owl","rdf","typescript","2026-11-22 06:54:17","2026-11-23 12:11:40","\u003Cp align=\"center\">\n  \u003Ca href=\"https:\u002F\u002Fiiwish.github.io\u002Fkgdiff\u002Fplayground.html\">\u003Cimg src=\"docs\u002Fimages\u002Freplay-en.webp\" alt=\"The kgdiff viewer replaying the changes between two versions of a schema.org-style vocabulary, one hunk at a time\" width=\"880\">\u003C\u002Fa>\n\u003C\u002Fp>\n\n\u003Cp align=\"center\">\n  \u003Cb>git diff for knowledge graphs.\u003C\u002Fb>\u003Cbr>\n  See what changed between two versions of a graph — and review it like a pull request.\n\u003C\u002Fp>\n\n\u003Cp align=\"center\">\n  \u003Ca href=\"https:\u002F\u002Fiiwish.github.io\u002Fkgdiff\u002Fplayground.html\">\u003Cb>Try it in your browser\u003C\u002Fb>\u003C\u002Fa> ·\n  \u003Ca href=\"https:\u002F\u002Fiiwish.github.io\u002Fkgdiff\u002F\">Website\u003C\u002Fa> ·\n  \u003Ca href=\"https:\u002F\u002Fiiwish.github.io\u002Fkgdiff\u002Fdocs\u002F\">Docs\u003C\u002Fa>\n\u003C\u002Fp>\n\n\u003Cp align=\"center\">\n  \u003Ca href=\"README.zh-CN.md\">中文\u003C\u002Fa> ·\n  \u003Ca href=\"docs\u002Farchitecture.md\">Architecture\u003C\u002Fa> ·\n  \u003Ca href=\"docs\u002Fcli.md\">CLI\u003C\u002Fa> ·\n  \u003Ca href=\"docs\u002Fvisual-language.md\">Visual language\u003C\u002Fa> ·\n  \u003Ca href=\"docs\u002Fdelta-format.md\">Delta format\u003C\u002Fa>\n\u003C\u002Fp>\n\n---\n\nAI systems now write and rewrite knowledge graphs: GraphRAG pipelines, agent memories, ontology\nassistants, semantic layers. Someone has to review those changes. Text diffs show triples\nappearing and disappearing; most visual tools recolor nodes on a fresh force layout so\neverything jumps. **kgdiff shows what actually happened**: a merge, a rename, a class moved under\na new parent, a relation that now points somewhere else — on one stable map, in a viewer built\nfor review.\n\n```sh\nnpx @kgdiff\u002Fcli before.ttl after.ttl -o report.html --open\n```\n\nOr install nothing: the [playground](https:\u002F\u002Fiiwish.github.io\u002Fkgdiff\u002Fplayground.html) diffs the\nexample datasets, or two files of your own, in your browser. Nothing is uploaded.\n\n## Four ideas\n\n|                             |                                                                                                                                                                                                                                                                                                                        |\n| --------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| **Semantic, not syntactic** | Nodes are matched across versions (by id, by replacement hints, or by label\u002Fneighbourhood similarity when ids are meaningless, e.g. two LLM extractions). Changes are classified: rename, rekey, types, aliases, attributes, deprecation, replacement links, hierarchy move, merge, split, retarget, predicate change. |\n| **One mental map**          | Both versions share one deterministic, label-aware layout. Nothing moves unless it changed. Removed things stay where they were, as hollow ghosts.                                                                                                                                                                     |\n| **Color is meaning**        | Five families and nothing else: added, removed, content, structure, identity — plus gray for context. Every color has a non-color cue too, and a color-blind-safe palette ships built in.                                                                                                                              |\n| **Review is a workflow**    | Changes are grouped into hunks in dependency order. Step through them, replay the before → after morph, mark them reviewed, export the invertible delta.                                                                                                                                                               |\n\n## What you get\n\n- **`\u003Ckgdiff-viewer>`**: a framework-agnostic web component with three ways to compare —\n  _Overlay_, _Swipe_ (drag a divider between before and after) and _Replay_ (the old graph morphs\n  into the new one, hunk by hunk) — each with or without _Changes only_ (on by default for large\n  graphs), plus a searchable, filterable change\n  list, a detail panel with character-level diffs, review progress, deep links, keyboard\n  shortcuts, light\u002Fdark themes, English and Chinese.\n- **`kgdiff` CLI**: colored terminal summaries, `--stat`, `--name-status`, `--json`, `--delta`,\n  GitHub-flavoured `--markdown` for PR comments, `--exit-code` for CI, `apply` for deltas, and\n  single-file offline HTML reports (`-o report.html`, byte-identical with `--reproducible`).\n- **Libraries**: a zero-dependency diff engine, parsers (RDF through `n3`), a stable layout\n  engine, a renderer-agnostic visual model, a Canvas renderer and an AntV G6 adapter.\n\n## Quick start\n\n### Terminal and CI\n\n```sh\nnpx @kgdiff\u002Fcli v12.json v13.json                 # colored summary\nnpx @kgdiff\u002Fcli old.obo new.obo --stat            # diffstat\nnpx @kgdiff\u002Fcli a.ttl b.ttl --markdown >> \"$GITHUB_STEP_SUMMARY\"\nnpx @kgdiff\u002Fcli a.ttl b.ttl --exit-code -q        # exit 1 when the graphs differ\n```\n\n`npx` needs Node.js ≥ 22; kgdiff itself is a native program for macOS, Linux and Windows, also\non crates.io (`cargo install kgdiff`).\n\n\u003Cp align=\"center\">\n  \u003Cimg src=\"docs\u002Fimages\u002Fterminal-en.webp\" alt=\"kgdiff's terminal summary of an OBO ontology release: merges, moves, a split, renames and additions, colored by kind of change\" width=\"720\">\n\u003C\u002Fp>\n\nSee [docs\u002Fcli.md](docs\u002Fcli.md) and [packages\u002Fcli\u002FREADME.md](packages\u002Fcli\u002FREADME.md).\n\n### On pull requests (GitHub Actions)\n\n```yaml\njobs:\n  kgdiff:\n    runs-on: ubuntu-latest\n    permissions:\n      contents: read\n      pull-requests: write # the comment\n    steps:\n      - uses: actions\u002Fcheckout@v7\n      - uses: iiwish\u002Fkgdiff@v0\n        with:\n          files: ontology\u002F*.ttl\n```\n\nThe action compares each file with its version on the base branch, writes the summary into the\njob summary and a pull request comment that later pushes update in place, and uploads the\ninteractive report as an artifact. Pull requests from forks get the job summary and the report.\nOptions, several graphs, failing the check: [docs\u002Fguide\u002Fci.md](docs\u002Fguide\u002Fci.md).\n\n### In a web page\n\n```html\n\u003Ckgdiff-viewer theme=\"auto\" locale=\"en\" style=\"height: 640px\">\u003C\u002Fkgdiff-viewer>\n\u003Cscript type=\"module\">\n  import '@kgdiff\u002Fviewer';\n  const viewer = document.querySelector('kgdiff-viewer');\n  await viewer.load({\n    before: { text: await (await fetch('v1.ttl')).text(), filename: 'v1.ttl' },\n    after: { text: await (await fetch('v2.ttl')).text(), filename: 'v2.ttl' },\n  });\n\u003C\u002Fscript>\n```\n\nEvents: `kgdiff-ready`, `kgdiff-select`, `kgdiff-mode`, `kgdiff-review`, `kgdiff-error`, `kgdiff-replay-end`.\nBehaviour: [docs\u002Finteraction.md](docs\u002Finteraction.md).\n\n\u003Cp align=\"center\">\n  \u003Cimg src=\"docs\u002Fimages\u002Fviewer-en.webp\" alt=\"The kgdiff viewer: both versions on one map, changes colored by kind, and the list of changes to review\" width=\"880\">\n\u003C\u002Fp>\n\n### As a library\n\n```ts\nimport { diff, formatHunk, applyDelta, invertDelta } from '@kgdiff\u002Fcore';\nimport { parseGraph } from '@kgdiff\u002Fformats';\n\nconst before = parseGraph(beforeText, { filename: 'v1.obo' }).graph;\nconst after = parseGraph(afterText, { filename: 'v2.obo' }).graph;\nconst result = diff(before, after);\n\nfor (const hunk of result.hunks) console.log(formatHunk(hunk, result, 'en').title);\n\u002F\u002F Merged “juvenile diabetes” and “insulin-dependent diabetes mellitus” into “type 1 diabetes mellitus”\n\u002F\u002F Merged “heart attack” into “myocardial infarction”\n\u002F\u002F …\n```\n\n## Formats\n\n| Family | Formats                                                                                                                                                                                                                                                                                |\n| ------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| RDF    | Turtle, N-Triples, N-Quads, TriG, RDF\u002FXML (`.rdf`, `.owl` from Protégé \u002F ROBOT), JSON-LD 1.1 (inline contexts; nothing is fetched) — labels by language preference, OWL existential restrictions as edges, blank nodes identified by content and context, statement annotations folded |\n| OBO    | OBO 1.4 — synonyms, `is_a`, relationships, obsoletion with `replaced_by`, `alt_id`                                                                                                                                                                                                     |\n| JSON   | kgdiff native, d3 \u002F NetworkX node-link, Cytoscape.js, AntV G6 v5, graphology, vis-network                                                                                                                                                                                              |\n\nThe same graph in different serializations diffs as identical. Mapping conventions:\n[docs\u002Farchitecture.md](docs\u002Farchitecture.md#formats-mapping-conventions).\n\n## Packages\n\n**Which one to install.** Most people need one package; it depends only on what you want to do:\n\n| You want to…                                      | Install                                                               |\n| ------------------------------------------------- | --------------------------------------------------------------------- |\n| Compare graph files in the terminal or in CI      | `@kgdiff\u002Fcli` (`npx @kgdiff\u002Fcli a.ttl b.ttl`), or the GitHub Action   |\n| Show a diff in a web page, without rendering code | `@kgdiff\u002Fviewer` (the `\u003Ckgdiff-viewer>` web component)                |\n| Compute diffs in your code, draw them yourself    | `@kgdiff\u002Fcore`, plus `formats`, `layout`, `scene` or `g6` as you need |\n\n`@kgdiff\u002Fcli` runs a native binary: npm installs the one for your machine with it\n(`@kgdiff\u002Fcli-darwin-arm64`, `@kgdiff\u002Fcli-linux-x64-gnu`, …). Never install those yourself.\n\nAll packages:\n\n| Package                                 |                                                                                          |\n| --------------------------------------- | ---------------------------------------------------------------------------------------- |\n| [`@kgdiff\u002Fcore`](packages\u002Fcore)         | Diff engine: normalize → match → classify → hunks → invertible delta. Zero dependencies. |\n| [`@kgdiff\u002Fformats`](packages\u002Fformats)   | RDF \u002F OBO \u002F JSON parsers.                                                                |\n| [`@kgdiff\u002Flayout`](packages\u002Flayout)     | Deterministic, label-aware union layout; anchored and changes-only modes.                |\n| [`@kgdiff\u002Fscene`](packages\u002Fscene)       | Diff semantics → visual primitives: design tokens, encodings, replay timeline, focus.    |\n| [`@kgdiff\u002Frenderer`](packages\u002Frenderer) | Canvas 2D engine: smooth camera, LOD, label placement, picking, swipe, minimap.          |\n| [`@kgdiff\u002Fviewer`](packages\u002Fviewer)     | The `\u003Ckgdiff-viewer>` web component.                                                     |\n| [`@kgdiff\u002Fg6`](packages\u002Fg6)             | Render kgdiff scenes inside AntV G6 v5 graphs.                                           |\n| [`@kgdiff\u002Fcli`](packages\u002Fcli)           | The command-line tool.                                                                   |\n| [`action.yml`](action.yml)              | The GitHub Action (`uses: iiwish\u002Fkgdiff@v0`): graph diffs on pull requests.              |\n| [`apps\u002Fsite`](apps\u002Fsite)                | Landing page and playground.                                                             |\n\n## Correctness and performance\n\n- **Deterministic**: the same inputs give byte-identical diffs, layouts and reports.\n- **Invertible**: `apply(A, diff(A, B).delta) ≅ B` and the inverse delta restores `A`;\n  applying hunks one by one in review order always succeeds. Property-tested with fast-check.\n- **Tested**: ~2,200 tests across packages, including acceptance tests that run every example\n  dataset through the whole pipeline.\n- **Measured** (M-class laptop, `pnpm bench`): diff of 10k nodes \u002F 30k edges ≈ 0.1 s; 50k RDF\n  triples parsed in ≈ 0.1 s; layout of a 10k-node diff (changes scope) ≈ 1.1 s; per-frame visual\n  resolution \u003C 1 ms for 5k nodes; standalone viewer ≈ 116 kB gzip.\n\n## Examples\n\n[`examples\u002Fdatasets`](examples\u002Fdatasets) holds six realistic before\u002Fafter pairs with the exact\nchanges kgdiff should report: an enterprise credit KG ontology (in Chinese and in English), an OBO disease\nontology release, two LLM extraction runs with random ids, a dbt-style lineage DAG, and a\nschema.org-like Turtle vocabulary. `scripts\u002Fgen-synthetic.ts` generates large synthetic pairs.\n\n## Development\n\n```sh\npnpm install                    # Node.js ≥ 22, pnpm 11\npnpm check                      # lint + typecheck + tests\npnpm bench                      # performance budgets\npnpm dev:site                   # landing page and playground\npnpm dev:docs                   # documentation site (docs\u002F)\npnpm build:viewer-assets        # the viewer bundles kgdiff's HTML reports embed\ncargo run -p kgdiff -- examples\u002Fdatasets\u002Fenterprise-kg-en\u002Fbefore.json \\\n  examples\u002Fdatasets\u002Fenterprise-kg-en\u002Fafter.json\n```\n\nStart with [docs\u002Farchitecture.md](docs\u002Farchitecture.md) and [CONTRIBUTING.md](CONTRIBUTING.md).\n\n## Roadmap\n\n0.11: `@kgdiff\u002Fcompute` replaces the TypeScript compute modules in the browser\n([RFC 0002](docs\u002Frfcs\u002F0002-rust-compute-core.md), phase 5), with the typed graph input of\n[RFC 0003](docs\u002Frfcs\u002F0003-embedding-hosts.md) for embedding hosts. 1.0: 0.11 after two stable\nweeks, with no new code. After 1.0: KGCL and RDF Patch export ·\nthree-way merge with conflict visualization · Web Worker pipeline and a WebGL renderer for very large graphs ·\nCytoscape.js and Sigma.js adapters · Python bindings.\n\n## License\n\n[MIT](LICENSE). Example datasets are CC0.\n","kgdiff 是一个面向知识图谱的语义化差异比对与评审工具，专为 RDF、OBO 和 JSON 格式知识图谱设计。它不依赖简单三元组增删的文本 diff，而是通过节点语义匹配（ID、标签、邻域相似性）识别重命名、类继承关系变更、属性调整、层级移动、谓词变更等高层语义变化，并在稳定、共享的可视化布局中呈现差异，支持逐块审查（类似 Pull Request）。适用于本体演进管理、LLM 生成图谱的变更审核、GraphRAG 流水线质量控制及语义层版本对比等场景。",2,"2026-11-24 04:39:48","CREATED_QUERY"]