Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
211 changes: 134 additions & 77 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,79 +1,136 @@
# vyb

`vyb` is a CLI that helps you iteratively develop applications, faster.
With 'vyb', you can refine your application spec, generate or update code, or provide your own command extensions to
perform tasks that are relevant to your application workspace.

## Vision
The vision for `vyb` is that it will provide a workflow for developers to collaborate with AI, through well-defined
commands that encapsulate intent and avoid repetitive activities like drafting a prompt or choosing which files to
include in every interaction with the LLM.

Each `vyb` command has a filter for which workspace files should be included in the request to the LLM, and which files
are allowed to be modified by the LLM's response.

### Workflow
The envisioned workflow for `vyb` is as follows:
- `vyb refine` will help the developer draft requirements for their application, marking which features are already
implemented and which still need to be implemented. This could be connected with GitHub API, to link the issue # to the
spec element. In this case, the first step in implementing an issue would be to add it as a TODO in the SPEC;
- `vyb code` implements either a `TODO(vyb)` in the code, or a TODO SPEC element. As of now, this command relies
heavily on `TODO(vyb)` for prioritization, and doesn't really know how to pick a SPEC element to implement. It would be
good to find a better way to tell the CLI which specific task needs to be executed each time the command is called;
- `vyb document` updates README.md files to reflect the application code. Ideally, this activity would be done
atomically when `vyb code` runs, but the prompt isn't there yet. But even after that is resolved, this command will
continue to be useful because the developer may manually change code and allow it to drift over time;
- `vyb inferspec` ensures any manual modifications made to the code are reflected back in the SPEC.md files;

### Git Integration
Every command execution gets a list of files to be modified, along with a commit message. For now, the commit message is
only printed in the output for the user to see, but the goal is to store it in the `.vyb/` folder, alongside the list of
modified files. After reviewing the proposed modifications, the user will then run `vyb accept`, at which point `vyb`
would stage and commit the changes, using the commit message provided by the LLM.

### LLM Quotas
`vyb` only includes files that match the command filtering criteria under the directory in which it is executed, plus
any of its sub-directories. This is to limit the number of tokens sent to the LLM, but it could also hurt the LLM's
ability to resolve a problem if it doesn't have all the context it needs.
Still to be developed, is a summarization logic that will produce embeddings at each relevant application folder,
allowing for better contextualization even when executing `vyb` within a module and not passing it the entire codebase.

This is a high priority feature to be implemented soon, since even vyb's codebase is already reaching o1's token limits
for certain prompts.

## Features

- Iterative specification refinement and code generation
- Automated project file detection and filtering
- Integration with OpenAI for advanced language-based tasks
- Modular command structure using Cobra

## Getting Started

1. Install Go 1.24 or later.
2. Clone this repository.
3. Build the CLI using:
go build -o vyb
4. Obtain an OpenAI API key and store it in the OPENAI_API_KEY env var.

## Basic Usage

Below are some key commands:

• Initialize project:
vyb init

• Remove project metadata:
vyb remove [--force-root]

• Summarize code and docs:
vyb summarize

• Refine specifications:
vyb refine [SPEC.md]

• Implement code:
vyb code [SPEC.md]

Check out the subdirectory README files for deeper insights into the
application's architecture.
`vyb` is an AI-assisted command-line companion that helps developers
iterate on code, documentation and specifications **without having to
craft prompts by hand**. It wraps common workflows (code generation,
refactoring, documentation, spec maintenance, …) into deterministic CLI
commands that:

1. **Select the right context** – only the files relevant for the task
are sent to the LLM.
2. **Apply guarded changes** – proposed modifications are validated
against allow/deny patterns before touching the working tree.
3. **Generate commit messages** – every LLM reply already contains a
Conventional Commit message so you can just `git commit -F` it. (WIP)

---

## Installation

Requirements:

* Go ≥ 1.24
* A valid OpenAI API key (export `OPENAI_API_KEY`)

```bash
# install the latest directly from github
$ go install github.com/vybdev/vyb

# make the binary discoverable
# if #GOPATH is not set in your environment, it is usually under $HOME/go
$ export PATH=$GOPATH/bin:$PATH
```

> TIP Run `vyb --help` at any time to see all registered commands.

---

## Quick-start

```bash
# initialise metadata at the repository root
$ vyb init

# ask the LLM to implement a TODO in the current module
$ vyb code my/pkg/handler.go

# refresh documentation after a big refactor
$ vyb document -a # -a ⇒ include *all* modules
```

All commands only **stage changes** locally; no commit is created. After
reviewing the alterations you can commit them with the message suggested
by `vyb`.

---

## Built-in commands

| Command | Purpose |
|----------------|------------------------------------------------------------|
| `init` | Create `.vyb/metadata.yaml` in the project root |
| `update` | Re-scan workspace, merge & (re)generate annotations |
| `remove` | Delete `.vyb` completely |
| `code` | Implement `TODO(vyb)`s or the file passed as argument |
| `document` | Generate / refresh `README.md` files |
| `refine` | Polish `SPEC.md` content |
| `inferspec` | Make spec match the *current* codebase |

Flags accepted by **all** AI-driven commands:

* `-a, --all` – include every file in the project, not only the current
module.

---

## Core concepts

### Project metadata (`.vyb/metadata.yaml`)

A hierarchical representation of the workspace:

* **Module** – a folder treated as a logical unit. Stores token counts,
MD5 digests and an *Annotation* (see below).
* **FileRef** – path, checksum and token count for each file.

The metadata is fully derived from the file system; you should never
edit it manually.

### Annotations

`vyb` records three complementary summaries for every module:

* **Internal context** – what lives *inside* the module (private view).
* **Public context** – what the module (and its children) expose.
* **External context** – how the module fits in the *overall* application.

These texts are generated with the help of the LLM and later injected
into prompts to reduce the number of files that need to be submitted in each request.

---

## Architecture overview

```
cmd/ entry-points and Cobra command wiring
template/ YAML + Mustache definitions used by AI commands
llm/ OpenAI API wrapper + strongly typed JSON payloads
workspace/ file selection, .gitignore handling, metadata evolution
```

Flow of an AI command (`vyb code` for instance):

1. "template" loads the prompt YAML, computes inclusion/exclusion sets.
2. "selector" walks the workspace to gather the right files.
3. The user & system messages are built, then sent to `llm/openai`.
4. The JSON reply is validated and applied to the working tree.

---

## Extending `vyb`

Put additional `.vyb` YAML templates under:

* `$VYB_HOME/cmd/` – globally available commands.
* `.vyb/cmd/` inside your project – repo-local commands *(planned)*.

See `cmd/template/embedded/code.vyb` for the field reference.

---

## Development & Testing

* Unit tests: `go test ./...`
* Lint / CI: see `.github/workflows/go.yml`

Feel free to open issues or PRs – all contributions are welcome!
98 changes: 0 additions & 98 deletions SPEC.md

This file was deleted.

2 changes: 1 addition & 1 deletion cmd/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"fmt"
"os"

"github.com/dangazineu/vyb/workspace/project"
"github.com/spf13/cobra"
"github.com/vybdev/vyb/workspace/project"
)

var initCmd = &cobra.Command{
Expand Down
2 changes: 1 addition & 1 deletion cmd/remove.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package cmd

import (
"fmt"
"github.com/dangazineu/vyb/workspace/project"
"github.com/spf13/cobra"
"github.com/vybdev/vyb/workspace/project"
"os"
)

Expand Down
2 changes: 1 addition & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package cmd

import (
"fmt"
"github.com/dangazineu/vyb/cmd/template"
"github.com/spf13/cobra"
"github.com/vybdev/vyb/cmd/template"
"os"
)

Expand Down
26 changes: 26 additions & 0 deletions cmd/template/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# cmd/template Directory

This folder contains the *prompt templates* that power every AI-driven
`vyb` command. Each template is a `.vyb` YAML file with the following
fields:

| Field | Description |
|---------------------------------|-------------------------------------------|
| `name` | The CLI sub-command to register |
| `prompt` | User-facing task description (Markdown) |
| `targetSpecificPrompt` *(opt)* | Extra instructions when a file is passed |
| `argInclusionPatterns` | Glob patterns accepted as CLI arguments |
| `argExclusionPatterns` | … patterns that cannot be passed |
| `requestInclusionPatterns` | Files to embed in the LLM payload |
| `requestExclusionPatterns` | Files to never embed |
| `modificationInclusionPatterns` | Files the LLM is allowed to touch |
| `modificationExclusionPatterns` | Guard-rails against accidental edits |

At runtime the loader merges three sources (by precedence):

1. Embedded templates bundled at compile time (`embedded/*.vyb`).
2. User-wide templates under `$VYB_HOME/cmd`.
3. (planned) Project-local templates under `.vyb/cmd`.

Templates use Mustache placeholders to inject dynamic data (e.g. the
command-specific prompt gets embedded into a global *system* prompt).
12 changes: 6 additions & 6 deletions cmd/template/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ import (
"strings"

"github.com/cbroglie/mustache"
"github.com/dangazineu/vyb/llm/openai"
"github.com/dangazineu/vyb/llm/payload"
"github.com/dangazineu/vyb/workspace/context"
"github.com/dangazineu/vyb/workspace/matcher"
"github.com/dangazineu/vyb/workspace/project"
"github.com/dangazineu/vyb/workspace/selector"
"github.com/spf13/cobra"
"github.com/vybdev/vyb/llm/openai"
"github.com/vybdev/vyb/llm/payload"
"github.com/vybdev/vyb/workspace/context"
"github.com/vybdev/vyb/workspace/matcher"
"github.com/vybdev/vyb/workspace/project"
"github.com/vybdev/vyb/workspace/selector"
)

var systemExclusionPatterns = []string{
Expand Down
Loading