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
10 changes: 2 additions & 8 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -1,8 +1,2 @@
# Default owners
* @catenasys/btp-engineering

# Documentation has additional team to review
/docs/* @catenasys/btp-engineering @catenasys/btp-documentation

# Repository Admin only for .github
/.github/* @catenasys/repository-admin
# Repository owner — required reviewer for all PRs
* @scealiontach
152 changes: 0 additions & 152 deletions .github/settings.yml

This file was deleted.

27 changes: 0 additions & 27 deletions .github/workflows/pr-monitor.yaml

This file was deleted.

9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,12 @@ dist
build
markers
.vscode

.claude/runs

.claude/sprints/

.claude/sprint-loop-counter

.mcp.json
.claude-sprint.env
10 changes: 0 additions & 10 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,6 @@ repos:
rev: v0.1.17
hooks:
- id: helmlint
- repo: https://github.com/gherynos/pre-commit-java
rev: v0.2.0
hooks:
- id: checkstyle
args:
- -c
- google_checks.xml
exclude: ".*/src/test/.*"
- id: cpd
exclude: ".*/src/test/.*"
- repo: https://github.com/jumanjihouse/pre-commit-hooks
rev: 3.0.0
hooks:
Expand Down
120 changes: 120 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
# AGENTS.md — this repository

Shared cross-agent instructions for this repository. Claude-specific
additions live in CLAUDE.md, which includes this file.

## Repository purpose

Personal collection of bash scripts and shared libraries. The build packages
three tarballs from `bash/`: documentation (`doc-*.tar.gz`), executable
commands (`bin-*.tar.gz`), and source libraries (`lib-*.tar.gz`).

## Common commands

```bash
make # default: package (builds all three tarballs in dist/)
make clean # remove dist/
make package # explicit package target
make publish # tag-driven gh release upload (only when RELEASABLE=yes)
make what_version # print VERSION / LONG_VERSION / MAVEN_REVISION

pre-commit run --all-files # full lint suite
pre-commit run shellcheck --all-files # only shellcheck
pre-commit run shfmt --all-files # only shfmt

bash/bashadoc bash/<lib>.sh # generate markdown docs for one library
bash/pack-script -f <command> -o <out> # inline @include deps -> standalone
```

There is no test suite — this repo is shell scripts and libraries, not a tested codebase.
CI (`.github/workflows/pre-commit.yaml`) only runs pre-commit hooks; Jenkins runs
`make clean build`, `make package`, `make analyze`, `make test`, `make archive`,
and on `main` `make publish`.

## Architecture

The code in `bash/` follows a deliberate split that is critical to understand:

- **Library files** end in `.sh` (e.g. `options.sh`, `git.sh`, `log.sh`). They
are sourced, never executed directly. Every function in a library MUST use
namespace qualification: `package::function` (e.g. `git::cmd`, `log::error`).
- **Command scripts** have no extension (e.g. `pack-script`, `changelog`,
`clean-branches`). They are executable, source `includer.sh`, pull in
libraries with `@include`, and use `options.sh` to parse args.
- **Naming**: script names use dashes, never underscores (convention only,
not enforced by a hook). The pre-commit hooks `script-must-have-extension`
and `script-must-not-have-extension` enforce the `.sh` ↔ no-extension split
between libraries and command scripts.

### The `@include` mechanism

`includer.sh` defines `@include <name>` which sources `bash/<name>.sh` exactly
once per process. Deduplication uses a `cksum`-derived guard variable, so the
same include from multiple call sites is safe and cheap. Every library starts
with `source "$(dirname "${BASH_SOURCE[0]}")/includer.sh"` followed by its
`@include` declarations.

### Documentation annotations

`doc.sh` defines `@doc`, `@arg`, `@package` as no-op functions purely so they
can appear in source as inline annotations. `bash/bashadoc` parses these via
`declare -f` to produce markdown. Apply them as:

```bash
@package mypkg # at top of library, after @include lines

function mypkg::do_thing() {
@doc One-line description of what this does
@arg _1_ first positional arg
@arg -o "<arg>" the -o flag
...
}
```

The Makefile's `dist/doc-*.tar.gz` target runs `bashadoc` over every `bash/*.sh`.

### Building self-contained command scripts

`bash/pack-script` is the bin-tarball packer. It walks `@include` directives
transitively and produces a single bash file with `doc.sh` + `annotations.sh`
prepended, all `@include` lines stripped, and shebang/`includer.sh` references
removed. The Makefile's `dist/bin-*.tar.gz` target identifies command scripts
by `grep -q "includer"` AND no `.sh` extension — packing depends on those
two markers. Adding a new command without sourcing `includer` will silently
exclude it from the bin tarball.

### Options parsing

Commands declare options imperatively before parsing:

```bash
options::standard # adds -v verbose
options::add -o f -d "input file" -a -m -e InputFile # mandatory -> $InputFile
options::add -o x -d "dry run" -x DryRun # flag, sets DryRun=true
options::parse "$@"
shift "$((OPTIND - 1))"
```

`-e VAR` exports the value into a global; `-x VAR` marks a flag; `-f fn` calls
`fn` with the optarg. `-h` is added automatically. `options::parse` exits with
help if no args are provided unless `NO_SYNTAX_EXIT` is set.

## Conventions

- **Branch names**: pre-commit's `no-commit-to-branch` hook rejects pushes to
any branch not matching `^(fix|feature|refactor)/[a-zA-Z0-9\-]+$`. Use
`feature/...`, `fix/...`, or `refactor/...`.
- **Commit messages**: commitizen runs at `commit-msg` stage, so conventional
commits (`feat:`, `fix:`, `docs:`, `ci:`, etc.) are enforced.
- **Formatting**: shfmt with `-i 2 -ci` (2-space indent, indent switch cases).
shellcheck runs with `-x -P SCRIPTDIR` so cross-file `source` directives
resolve. Tabs are forbidden everywhere except `Makefile`, `*.mk`, and `*.go`.
- **Function namespacing**: anything in a `*.sh` library must be
`package::name`. Bare `function bar()` is reserved for command scripts and
for backward-compat shims that delegate via `deprecated newfunc::name "$@"`
(see `annotations::deprecated`).
- **`commands::use <bin>`** caches a `command -v` lookup in `$_<bin>` and
errors out if missing. Prefer `$(commands::use awk)` over bare `awk` in
libraries that should fail loudly when a tool is absent.

Linear Project: shell-scripts
16 changes: 16 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
@AGENTS.md

<!--
This file contains Claude-specific overlay for this repository.
Cross-agent shared content is in AGENTS.md, included above via the
@AGENTS.md directive. Claude-specific content below is wrapped in
CLAUDE-ONLY markers to make drift detection mechanical.
-->

<!-- CLAUDE-ONLY -->
# CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when
working with code in this repository.

<!-- /CLAUDE-ONLY -->
Loading