Skip to content
Open
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
62 changes: 62 additions & 0 deletions .github/actions/repo-memory-query/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Repo Memory Query

A read-only search of the [Repo Memory](https://github.com/redis-learn/redis-repo-memory) store from a
description of work you are about to do. Use it to find related prior PRs, commits and issues, with
their full squash or commit messages, before any PR exists.

It is separate from the `redis-learn/redis-repo-memory` action on purpose. That action runs on every
push and PR and writes to the store. This one only reads, runs only when someone starts it, and can
change or go away without affecting the memory comments.

It never creates the index, never writes a key, and never posts to a PR or commit. It uses the same
`MEMORY_REDIS_URL` and `OPENAI_API_KEY` secrets as `repo-memory.yml`.

## Run it

```sh
gh workflow run repo-memory-query.yml \
-f query="Move the job-queue use case from JedisPool to RedisClient" \
-f files="content/develop/use-cases/job-queue/java-jedis/RedisJobQueue.java"
```

The workflow file must be on the default branch for `gh workflow run` to find it. Results appear in
the run's step summary as a list. The full text of each result is on one log line that starts with
`REPO_MEMORY_QUERY_RESULT_JSON`, followed by JSON, so a script can read it from
`gh run view <id> --log`.

## Inputs

| Input | Default | Meaning |
| --- | --- | --- |
| `redis-url` | required | Redis URL of the memory store |
| `openai-api-key` | required | Embeds the query with `text-embedding-3-small` |
| `query` | required | The planned work |
| `query-files` | none | Files you plan to change |
| `query-limit` | `5` | Maximum results |
| `query-max-distance` | `0.60` | Cosine distance cutoff, as in the memory action |
| `github-token` | `github.token` | Reads the full message behind each result |

Only items from the repository the workflow runs in are returned.

## Visibility

Workflow logs of a public repository are public. The query text, and the results, are printed in the
log, so don't put anything confidential in a query. The results are titles and messages of this
repository's own public PRs and commits.

## Compatibility with the memory action

`query.js` reads what `redis-learn/redis-repo-memory` writes: the `repo_memory_idx` index, `memory:`
hashes, and a cosine `embedding` field from `text-embedding-3-small`. If the memory action changes
that layout, update `query.js` and the seed in `test.js` to match.

## Test

The test needs an empty Redis 8 (Search is built in) and uses a mock embedding, so it needs no
OpenAI key or network access. It refuses to run against a database that has any keys.

```sh
cd .github/actions/repo-memory-query
npm ci
REPO_MEMORY_TEST_REDIS_URL=redis://localhost:6379 node test.js
```
60 changes: 60 additions & 0 deletions .github/actions/repo-memory-query/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: 'Redis Repo Memory Query'
description: >
Read-only search of an existing Redis Repo Memory store from a description of planned work.
Never writes to Redis and never posts to a pull request or commit.

inputs:
redis-url:
description: >
Redis connection URL of the Repo Memory store (the same value the
redis-learn/redis-repo-memory action uses), e.g. redis://default:<password>@<host>:<port>
required: true
openai-api-key:
description: OpenAI API key used to embed the query (text-embedding-3-small).
required: true
query:
description: Description of the work you are about to do.
required: true
query-files:
description: Files you plan to change, separated by spaces, commas or newlines.
required: false
default: ''
query-limit:
description: Maximum number of results.
required: false
default: '5'
query-max-distance:
description: Maximum cosine distance (0-2, lower is more similar) for a result.
required: false
default: '0.60'
github-token:
description: >
Token used to read the full squash or commit message behind each result.
The default github.token is enough for a public repository.
required: false
default: ${{ github.token }}

runs:
using: 'composite'
steps:
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '24'

- name: Install dependencies
shell: bash
working-directory: ${{ github.action_path }}
run: npm ci --omit=dev

- name: Query memory
shell: bash
env:
REDIS_URL: ${{ inputs.redis-url }}
OPENAI_API_KEY: ${{ inputs.openai-api-key }}
GITHUB_TOKEN: ${{ inputs.github-token }}
QUERY_TEXT: ${{ inputs.query }}
QUERY_FILES: ${{ inputs.query-files }}
QUERY_LIMIT: ${{ inputs.query-limit }}
QUERY_MAX_DISTANCE: ${{ inputs.query-max-distance }}
run: node "${{ github.action_path }}/query.js"
Loading
Loading