Repository navigation
Expand file tree
/
Copy pathgen-stats.sh
More file actions
executable file
·98 lines (82 loc) · 4.46 KB
/
Copy pathgen-stats.sh
File metadata and controls
executable file
·98 lines (82 loc) · 4.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#!/usr/bin/env bash
# gen-stats.sh — regenerate the CIRIS code census and POPULATE the stats into
# profile/CODE_STATS.md and the marked blocks in profile/README.md. The numbers
# are never hand-edited: the code is the single source of truth. Re-run any time
# (locally or from CI) to refresh.
#
# Requires: gh (authenticated), git, jq, and scripts/code-census.sh.
# Usage: scripts/gen-stats.sh
set -euo pipefail
cd "$(dirname "$0")/.." # -> org repo root
ORG="${CIRIS_ORG:-CIRISAI}"
# Optional: pass a path to an existing clones/ dir to skip re-cloning.
if [ -n "${1:-}" ] && [ -d "$1" ]; then
clones="$(cd "$1" && pwd)"
echo "using existing clones at $clones" >&2
else
work="$(mktemp -d)"; trap 'rm -rf "$work"' EXIT
clones="$work/clones"; mkdir -p "$clones"
echo "cloning public $ORG repos ..." >&2
gh repo list "$ORG" --visibility public --no-archived --limit 200 --json name --jq '.[].name' \
| while read -r r; do
git clone --depth 1 -q "https://github.com/$ORG/$r.git" "$clones/$r" 2>/dev/null \
|| echo " skip $r (clone failed)" >&2
done
fi
echo "counting ..." >&2
md="$(scripts/code-census.sh "$clones" --md)"
table="$(printf '%s\n' "$md" | grep -v 'CENSUS_TOTAL')" # visible markdown
total="$(printf '%s\n' "$md" | sed -nE 's/.*CENSUS_TOTAL=([0-9]+).*/\1/p')"
repos="$(printf '%s\n' "$md" | sed -nE 's/.*REPOS=([0-9]+).*/\1/p')"
headline="$(awk -v t="$total" 'BEGIN{printf "%.1fM+", t/1000000}')" # e.g. 1.5M+
# --- 1) profile/CODE_STATS.md : static methodology + generated table -----------
{
cat <<'HDR'
# CIRIS Code Census
<!-- GENERATED by scripts/gen-stats.sh — do not edit by hand. Re-run: scripts/gen-stats.sh -->
Reproducible source-line counts for the public CIRIS repositories.
## Methodology
- **Source code only** — real programming languages. Data and markup (JSON,
YAML, TOML, SVG, TeX, HTML, CSS, Markdown) are excluded: they are config,
fixtures, lockfiles, and prose, not code. (JSON alone is ~1.15M lines org-wide.)
- **Minus tests** — `test/`, `tests/`, `__tests__/`, `spec/`, `e2e/`,
`fixtures/`, and `*_test.*` / `*.test.*` / `*.spec.*`.
- **Minus generated code** — OpenAPI clients (`generated*/`), protobuf stubs
(`*_pb2.py`, `*.pb.go`), build output (`dist/ build/ target/ .next/ out/`).
- **Minus vendored deps** — `vendor/ third_party/ node_modules/`.
- **De-duplicated by content** — every file is hashed; identical content across
repos is counted once (collapses the five GUI forks and vendored copies).
## De-duplicated lines of code, by language
HDR
printf '%s\n' "$table"
cat <<'ARCH'
## The decentralized agent — 7 packages
Three Rust **substrate** crates, three Rust **fabric** crates on top, the agent
above that. (Reticulum mesh transport is vendored, not one of the seven.)
| Layer | Package | Lang |
|:------|:--------|:-----|
| Substrate | [CIRISVerify](https://github.com/CIRISAI/CIRISVerify) — hardware-rooted license verification | Rust |
| Substrate | [CIRISPersist](https://github.com/CIRISAI/CIRISPersist) — signed events, time-series, runtime state | Rust |
| Substrate | [CIRISEdge](https://github.com/CIRISAI/CIRISEdge) — Reticulum-native federation transport | Rust |
| Fabric | [CIRISNodeCore](https://github.com/CIRISAI/CIRISNodeCore) — federation-consensus primitives | Rust |
| Fabric | [CIRISLensCore](https://github.com/CIRISAI/CIRISLensCore) — science layer: cohort routes, manifold scoring | Rust |
| Fabric | [CIRISRegistry](https://github.com/CIRISAI/CIRISRegistry) — cryptographic trust backbone, gRPC | Rust |
| Agent | [CIRISAgent](https://github.com/CIRISAI/CIRISAgent) — H3ERE runtime + Compose Multiplatform client | Python / Kotlin |
## Reproduce
```sh
scripts/gen-stats.sh # clone all public repos, recount, repopulate these stats
```
ARCH
} > profile/CODE_STATS.md
# --- 2) profile/README.md : fill the marked blocks -----------------------------
readme="profile/README.md"
# (a) headline LoC between inline markers
perl -0pi -e "s/<!--CENSUS:LOC-->.*?<!--\\/CENSUS:LOC-->/<!--CENSUS:LOC-->${headline}<!--\\/CENSUS:LOC-->/s" "$readme"
# (b) by-language table between block markers
awk -v tbl="$table" '
/<!--CENSUS:STACK:START-->/ { print; print ""; print tbl; print ""; skip=1; next }
/<!--CENSUS:STACK:END-->/ { skip=0 }
!skip { print }
' "$readme" > "$readme.tmp" && mv "$readme.tmp" "$readme"
echo "populated: total=$total ($headline) across $repos repos" >&2
echo " -> profile/CODE_STATS.md, profile/README.md" >&2