Skip to main content

Ingest GitHub issues, PRs, and review comments into DKG v10 Working Memory

Project description

github-dkg

CI PyPI Python License

Ingest GitHub issues, pull requests, and review comments into DKG v10 Working Memory as Knowledge Assets.

Every issue and PR becomes a queryable, attributable Knowledge Asset in your DKG v10 node. Key decisions can be promoted to Shared Working Memory — making your team's engineering knowledge accessible to agents.

Demo

  • Walkthrough notebook: demo.ipynb — runs end-to-end against a built-in mock of GitHub and the DKG node, no tokens required. Open in Colab.
  • Live recording script: examples/demo_video.py — drives all three demos against a real DKG node and the GitHub API; this is the script behind the bounty walkthrough video.

Install

pip install github-dkg

Quickstart

export DKG_TOKEN=your-dkg-token
export DKG_BASE_URL=http://localhost:9200
export DKG_CONTEXT_GRAPH=your-context-graph-id
export GITHUB_TOKEN=your-github-token

# Bulk-ingest all issues and PRs from a repository
github-dkg ingest owner/repo --context-graph $DKG_CONTEXT_GRAPH

# Ingest a single issue
github-dkg ingest-one owner/repo 42 --type issue --context-graph $DKG_CONTEXT_GRAPH

# Ingest a single PR
github-dkg ingest-one owner/repo 99 --type pr --context-graph $DKG_CONTEXT_GRAPH

# Search ingested knowledge
github-dkg search "authentication bug" --context-graph $DKG_CONTEXT_GRAPH

# Promote a Working Memory asset to Shared Working Memory (SHARE)
github-dkg promote dkg://wm/turn/abc123 --context-graph $DKG_CONTEXT_GRAPH

GitHub Action

Automatically ingest issues and PRs as they are created or updated. Add to .github/workflows/dkg-ingest.yml:

on:
  issues:
    types: [opened, edited, closed]
  pull_request:
    types: [opened, edited, closed]
  pull_request_review:
    types: [submitted]

jobs:
  ingest:
    runs-on: ubuntu-latest
    steps:
      - uses: haroldboom/github-dkg@v0.1.0
        id: ingest
        with:
          dkg-token: ${{ secrets.DKG_TOKEN }}
          dkg-base-url: ${{ secrets.DKG_BASE_URL }}
          dkg-context-graph: ${{ secrets.DKG_CONTEXT_GRAPH }}

See examples/workflow.yml for a complete example including automatic promotion of architecture-decision PRs to Shared Working Memory.

Python API

import asyncio
from github_dkg import DKGClient, GitHubClient, GitHubDKGIngestor

async def main():
    dkg = DKGClient(base_url="http://localhost:9200", token="your-token")
    gh = GitHubClient(token="your-github-token")
    ingestor = GitHubDKGIngestor(dkg=dkg, github=gh, context_graph_id="cg-123")

    # Bulk ingest
    result = await ingestor.ingest_repo("owner", "repo", since="2024-01-01")
    print(f"Ingested {result.total} items ({len(result.errors)} errors)")

    # Single item
    resp = await ingestor.ingest_issue("owner", "repo", 42)
    print(f"Turn URI: {resp['turnUri']}")

    # Promote to Shared Working Memory
    await ingestor.promote(resp["turnUri"])

asyncio.run(main())

--since filtering

--since accepts an ISO 8601 timestamp and limits ingest to items updated after that point.

  • Issues: filtered server-side by GitHub via the since parameter on /issues.
  • Pull requests: GitHub's /pulls endpoint has no since filter, so the package requests sort=updated&direction=desc and stops paginating once results fall below the cutoff. Net result: only PRs touched after --since are fetched and ingested.

Comment-only updates (a new comment without an issue/PR body edit) still bump updated_at, so they're included.

Rate limiting

GitHubClient raises github_dkg.github_client.GitHubRateLimitError when GitHub returns 403/429 with X-RateLimit-Remaining: 0. The exception carries reset_at (unix timestamp) so callers can decide whether to back off, sleep, or fail. Authenticated tokens get 5,000 requests/hour; bulk-ingesting a large repo with many comment-heavy PRs can approach this limit.

from github_dkg.github_client import GitHubRateLimitError

try:
    result = await ingestor.ingest_repo("OriginTrail", "dkg-v9")
except GitHubRateLimitError as e:
    print(f"Rate limited; resets at unix={e.reset_at}")

Memory layers

Layer Flag Visibility
Working Memory --layer wm (default) Private to your node
Shared Working Memory --layer swm Gossiped across the paranet

Promotion from Working Memory to Shared Working Memory is always explicit — nothing is shared automatically.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

github_dkg-0.1.4.tar.gz (25.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

github_dkg-0.1.4-py3-none-any.whl (12.8 kB view details)

Uploaded Python 3

File details

Details for the file github_dkg-0.1.4.tar.gz.

File metadata

  • Download URL: github_dkg-0.1.4.tar.gz
  • Upload date:
  • Size: 25.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for github_dkg-0.1.4.tar.gz
Algorithm Hash digest
SHA256 3ec0413cd07bfde5fb6403cdad448575182194275eb8d22c09bd480dda9f9c31
MD5 f87485d9443d2ea9da5a4645d9089d04
BLAKE2b-256 c4be490e8387bd18042296817fe8d7b242e08a5d5e1f423a320e93eb00898baf

See more details on using hashes here.

Provenance

The following attestation bundles were made for github_dkg-0.1.4.tar.gz:

Publisher: publish.yml on haroldboom/github-dkg

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file github_dkg-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: github_dkg-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 12.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for github_dkg-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 e32b88fba49cdd7e288ac986d8efbbbf086dea1ffe3a8a00922a30b2755db2b0
MD5 b26a4f742f95debcf16dc84ebb38d1f1
BLAKE2b-256 18205534299a9ea1af74a3caf5d88dbcab3b9511c074846f279d7db42ac016fb

See more details on using hashes here.

Provenance

The following attestation bundles were made for github_dkg-0.1.4-py3-none-any.whl:

Publisher: publish.yml on haroldboom/github-dkg

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page