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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Ignore Bazel symlinks
bazel-*

# Local pnpm install output — Bazel builds against the lockfile directly.
node_modules/

11 changes: 11 additions & 0 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,20 @@ load(
"@cgrindel_bazel_starlib//updatesrc:defs.bzl",
"updatesrc_update_all",
)
load("@npm//:defs.bzl", "npm_link_all_packages")
load("@npm//:prettier/package_json.bzl", prettier_bin = "bin")

bzlformat_pkg(name = "bzlformat")

npm_link_all_packages(name = "node_modules")

# Expose the prettier CLI as a runnable Bazel target so that other sh_binary
# rules can pick it up as a runfile.
prettier_bin.prettier_binary(
name = "prettier",
visibility = ["//visibility:public"],
)

bzlformat_missing_pkgs(
name = "bzlformat_missing_pkgs",
)
Expand Down
23 changes: 23 additions & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,19 @@ bazel_dep(name = "cgrindel_bazel_starlib", version = "0.30.0")
bazel_dep(name = "rules_shell", version = "0.8.0")
bazel_dep(name = "jq.bzl", version = "0.6.1")
bazel_dep(name = "rules_multitool", version = "1.11.1")
bazel_dep(name = "rules_claude", version = "0.1.0")
bazel_dep(name = "aspect_rules_js", version = "3.1.2")
bazel_dep(name = "aspect_rules_lint", version = "2.6.0")

# rules_claude isn't published to the Bazel Central Registry, so the
# bazel_dep version above never resolves on its own. git_override pulls
# the module straight from the repo at a pinned commit, which is the
# installation pattern the rules_claude README recommends.
git_override(
module_name = "rules_claude",
commit = "1a978976e61cc1bb38a69fccc1158e0b44246bd0",
remote = "https://github.com/buildbuddy-io/rules_claude.git",
)

jq_toolchains = use_extension(
"@jq.bzl//jq:extensions.bzl",
Expand All @@ -21,3 +34,13 @@ multitool = use_extension(
)
multitool.hub(lockfile = "//:multitool.lock.json")
use_repo(multitool, "multitool")

claude = use_extension("@rules_claude//claude:extensions.bzl", "claude")
claude.download(use_latest = True)

npm = use_extension("@aspect_rules_js//npm:extensions.bzl", "npm")
npm.npm_translate_lock(
name = "npm",
pnpm_lock = "//:pnpm-lock.yaml",
)
use_repo(npm, "npm")
383 changes: 342 additions & 41 deletions MODULE.bazel.lock

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions lib/claude/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
load("@cgrindel_bazel_starlib//bzlformat:defs.bzl", "bzlformat_pkg")

bzlformat_pkg(name = "bzlformat")

filegroup(
name = "summary_prompt",
srcs = ["summary_prompt.md"],
visibility = ["//:__subpackages__"],
)
29 changes: 29 additions & 0 deletions lib/claude/summary_prompt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
You are drafting a weekly status summary for a developer based on their
GitHub activity for the past week.

The "Activity" Markdown block below lists pull requests the developer
authored and reviewed, grouped by repository. Each PR has a title and URL.

Your job is to produce SUMMARY SECTIONS that describe the week's work in
human-readable terms, grouped into two categories:

1. `## Glydways` — paid work at Glydways. Includes any PR in a repo under
the `glydways/*` GitHub organization (authored or reviewed).
2. `## Open Source` — personal and community work. Includes every other
repository.

Format requirements:

- Output ONLY the summary sections, in this order: `## Glydways` first if
there is any Glydways activity, then `## Open Source` if there is any
open-source activity.
- Skip a category entirely (don't emit the heading) if it has no activity.
- Under each heading, write 2-5 succinct bullets describing outcomes
("Migrated X to Y", "Reviewed N dependency-update PRs from Renovate").
Group related PRs into a single bullet rather than enumerating each.
- Bullets should focus on outcomes and themes, not PR titles.
- Plain Markdown only. No code fences. No preamble ("Here's the summary").
No trailing commentary.
- End the output with a single trailing newline.

Activity:
15 changes: 8 additions & 7 deletions lib/jq/github.jq
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@ def format_pr_body:


def closed_pr_to_md:
"- [\(.title)](\(.html_url))"
" - [\(.title)](\(.html_url))"
;

# Expects an array of PRs that are already grouped by repository_url
def closed_repo_prs_to_md:
"## \(.[0].repository_url | repo_title)" as $repo_url |
"- **\(.[0].repository_url | repo_title)**" as $repo_url |
map(. | closed_pr_to_md) as $pr_mds |
[ $repo_url ] + $pr_mds |
join("\n")
Expand All @@ -64,26 +64,27 @@ def closed_repo_prs_to_md:

def closed_pr_search_response_to_md:
[ .items | group_by(.repository_url) | .[] | closed_repo_prs_to_md ] |
join("\n\n")
[ "### Authored" ] + . |
join("\n")
;

# Reviewed PRs

def reviewed_pr_to_md:
[" - [\(.title)](\(.html_url))"] |
[" - [\(.title)](\(.html_url))"] |
map(select(.)) |
join("\n")
join("\n")
;

def reviewed_repo_prs_to_md:
"- \(.[0].repository_url | repo_title)" as $repo_url |
"- **\(.[0].repository_url | repo_title)**" as $repo_url |
map(. | reviewed_pr_to_md) as $pr_mds |
[ $repo_url ] + $pr_mds |
join("\n")
;

def reviewed_pr_search_response_to_md:
[ .items | group_by(.repository_url) | .[] | reviewed_repo_prs_to_md ] |
[ "## Reviewed PRs" ] + . |
[ "### Reviewed" ] + . |
join("\n")
;
11 changes: 11 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"name": "cgrindel_github_snippets",
"version": "0.0.0",
"private": true,
"devDependencies": {
"prettier": "3.8.3"
},
"pnpm": {
"onlyBuiltDependencies": []
}
}
24 changes: 24 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions tests/lib_tests/jq_tests/github_tests.txt
Original file line number Diff line number Diff line change
Expand Up @@ -53,33 +53,33 @@ null
# Basic, no body
import "github" as github; github::closed_pr_to_md
{"title": "This is the title.","html_url":"https://url_to_pr"}
"- [This is the title.](https://url_to_pr)"
" - [This is the title.](https://url_to_pr)"

# Basic, with body
import "github" as github; github::closed_pr_to_md
{"title": "This is the title.","html_url":"https://url_to_pr","body":"- This is the body."}
"- [This is the title.](https://url_to_pr)"
" - [This is the title.](https://url_to_pr)"

# Body evaluates to empty string
import "github" as github; github::closed_pr_to_md
{"title": "This is the title.","html_url":"https://url_to_pr","body":""}
"- [This is the title.](https://url_to_pr)"
" - [This is the title.](https://url_to_pr)"


# MARK - closed_repo_prs_to_md

# Basic
import "github" as github; github::closed_repo_prs_to_md
[{"repository_url":"https://github.com/cgrindel/repo_url","title": "First PR","html_url":"https://first_pr_url"},{"repository_url":"https://github.com/cgrindel/repo_url","title": "Second PR","html_url":"https://second_pr_url"}]
"## `cgrindel/repo_url`\n- [First PR](https://first_pr_url)\n- [Second PR](https://second_pr_url)"
"- **`cgrindel/repo_url`**\n - [First PR](https://first_pr_url)\n - [Second PR](https://second_pr_url)"


# MARK - closed_pr_search_response_to_md

# Basic
import "github" as github; github::closed_pr_search_response_to_md
{"items":[{"repository_url":"https://github.com/cgrindel/first_repo_url","title": "First PR","html_url":"https://first_pr_url"},{"repository_url":"https://github.com/cgrindel/second_repo_url","title": "Second PR","html_url":"https://second_pr_url"}]}
"## `cgrindel/first_repo_url`\n- [First PR](https://first_pr_url)\n\n## `cgrindel/second_repo_url`\n- [Second PR](https://second_pr_url)"
"### Authored\n- **`cgrindel/first_repo_url`**\n - [First PR](https://first_pr_url)\n- **`cgrindel/second_repo_url`**\n - [Second PR](https://second_pr_url)"


# MARK - repo_title
Expand Down
15 changes: 13 additions & 2 deletions tests/tools_tests/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,26 @@ sh_test(
"//tools:generate_weekly_snippets",
"@jq_toolchains//:resolved_toolchain",
],
env = {"JQ_BIN": "$(JQ_BIN)"},
# The script invokes the source .sh directly via rlocation, so it does
# not inherit env vars from the sh_binary target. We replay the same
# env wiring here so the script's CLAUDE_BIN / PRETTIER_BIN_RUNFILE
# references resolve under `set -u`.
env = {
"CLAUDE_BIN": "$(CLAUDE_BIN)",
"JQ_BIN": "$(JQ_BIN)",
"PRETTIER_BIN_RUNFILE": "cgrindel_github_snippets/prettier_/prettier",
},
env_inherit = [
# The HOME, GH_TOKEN, and GITHUB_TOKEN environment variables help the gh utility find
# its auth info.
"GITHUB_TOKEN",
"GH_TOKEN",
"HOME",
],
toolchains = ["@jq_toolchains//:resolved_toolchain"],
toolchains = [
"//tools:claude_runfile",
"@jq_toolchains//:resolved_toolchain",
],
deps = [
"@bazel_tools//tools/bash/runfiles",
"@cgrindel_bazel_starlib//shlib/lib:assertions",
Expand Down
Loading
Loading