Skip to content

Ksschkw/driftlock

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Driftlock

Driftlock is a commit-time gatekeeper that detects when your documentation has fallen behind your code—and then fixes it for you.

It watches every git commit, compares the actual structural changes (function signatures, types, classes) with the documentation you claim describes them, and if there’s a mismatch, it blocks the commit, rewrites the affected documentation, and tells you to stage the new version. No more “I’ll update the docs later.”

Optionally, it can log an immutable audit trail to a Solana devnet contract, because some of you work in industries where proving that docs matched code at every commit is a regulatory requirement.

High-Level

flowchart TD
    A[git commit] --> B[Git pre-commit hook]
    B --> C[driftlock hook-run]
    C --> D{Capture staged diff}
    D --> E[AST structural extraction]
    E --> F{Map changed files to docs}
    F --> G[Read current doc content]
    G --> H[LLM Check: TRUE/FALSE?]
    H -->|TRUE| I["Log hash (optional), exit 0"]
    H -->|FALSE| J[LLM Fix: generate updated doc]
    J --> K[Write updated doc to working tree]
    K --> L[Print message: docs updated, commit blocked]
    L --> M[exit 1]
Loading

Low level component diagram

flowchart TD
    subgraph CLI Layer
        Root[cmd/driftlock/root.go]
        InitCmd[init.go]
        HookRunCmd[hook_run.go]
        CheckCmd[check.go]
        FixCmd[fix.go]
        LogCmd[log.go]
    end

    subgraph Internal
        Config[config/config.go]
        GitUtils[git/git.go]
        DiffCapture[diff/capture.go]
        DiffStructural[diff/structural.go]
        Parser[parser/parser.go + languages.go]
        LLMClient[llm/client.go]
        LLMPrompt[llm/prompt.go]
        LLMResponse[llm/response.go]
        Updater[updater/updater.go]
        AuditHash[audit/hash.go]
        AuditSolana[audit/solana.go]
        HookOrch[hook/hook.go]
    end

    HookRunCmd --> HookOrch
    HookOrch --> GitUtils
    HookOrch --> DiffCapture
    HookOrch --> DiffStructural
    HookOrch --> Config
    HookOrch --> LLMClient
    HookOrch --> Updater
    HookOrch --> AuditHash
    HookOrch --> AuditSolana

    LLMClient --> LLMPrompt
    LLMClient --> LLMResponse
    DiffStructural --> Parser
Loading

Installation

With Go

If you have Go 1.22+:

go install github.com/Ksschkw/driftlock/cmd/driftlock@latest

Pre-built binaries

Download a static binary from the Releases page. Linux, macOS, and Windows builds are available. Place the binary somewhere in your PATH.

Shell installer

curl -fsSL https://raw.githubusercontent.com/Ksschkw/driftlock/main/install.sh | sh

Yes, that pipes a shell script into your shell. It downloads the right binary for your OS and architecture, verifies a checksum, and drops it into /usr/local/bin. If that terrifies you (it should), you can inspect the script first at the same URL.

Quick start

cd your-project
driftlock init              # sets up the hook and a .driftlock.toml
git add . && git commit -m "commit message"
# If your docs are out of sync, the commit is blocked and the docs are updated.

Why

Because out-of-date documentation is technical debt that compiles. Driftlock treats it as a build failure.

License

MIT

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors