Metadata-Version: 2.4
Name: MProcs
Version: 8.8.6
Summary: MProcs - derived from NeonBunny
Author-email: tderk <usvu.tech@gmail.com>
License: MIT
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: requests
Requires-Dist: ddgs
Provides-Extra: dev
Requires-Dist: pytest; extra == "dev"
Requires-Dist: black; extra == "dev"
Requires-Dist: flake8; extra == "dev"
Dynamic: license-file

# MProcs

Derived from NeonBunny. A Life program by tderk, originally LPro.py and Destiny [2024].

## Rebuildable & Uploadable PIP Project

This folder is a rebuildable pip project restored from PyPI `MProcs==8.8.4.4` (sdist `mprocs-8.8.4.4.tar.gz`).

### Structure
```
MProcs/
├── pyproject.toml       # PEP 517/621 build-system & project metadata (fixed dependencies placement)
├── setup.cfg            # egg_info config
├── MANIFEST.in          # sdist file inclusion
├── LICENSE              # MIT
├── README.md
└── src/
    └── MProcs/
        ├── __init__.py
        └── scripts/
            ├── main.py, lpro.py, lpro_s.py, gwf.py, etc.
            └── data/*.json
```

Fix applied vs. original PyPI sdist: moved `dependencies = ["requests","ddgs"]` from `[tool.setuptools.package-data]` into `[project].dependencies` so `Requires-Dist` is correctly emitted on build.

### Rebuild

```bash
# from this directory (/home/kredt/BDCS/MProcs)
pip install --upgrade build twine
python -m build              # creates dist/mprocs-8.8.4.4.tar.gz + .whl
# or
pip wheel . --no-deps
pip install dist/mprocs-*.whl  # test install
MProcs --help
mprocs --help
lpro --help
```

### Upload

```bash
twine check dist/*
twine upload dist/*           # to PyPI (requires API token)
# test upload
twine upload --repository testpypi dist/*
pip install --index-url https://test.pypi.org/simple/ MProcs
```

### Original artifacts saved
- `orig_sdist/mprocs-8.8.4.4.tar.gz` (PyPI sdist)
- `orig_wheel/mprocs-8.8.4.4-py3-none-any.whl` (PyPI wheel)
- `pyproject.toml.orig` (original buggy file for reference)

Installed entry points: `MProcs`, `mprocs`, `lpro`, `lpro-s`, `gwf`
Requires-Python: >=3.8

---
## Update 8.8.4.5 — A-HB (Agent Handbook) feature

**Source:** decrypted `A-HB.html` (password `BREEZYSOUND`) — 54 chapters (~10670 passages) across Volumes 1-7:
- Volume 1 Criminology (15 chapters), Volume 2 Military Studies (9), Volume 3 Police Studies (6),
  Volume 4 Intelligence (5), Volume 5 Agent Operations (6), Volume 6 Normal Activities (8), Volume 7 Buddhist Reflections (5)

**Data:** `src/MProcs/scripts/data/ahb.json` (4.7 MB) loaded via `data_loader.ahb` (exposed as `ahb_data` in `lpro.py`). Passages extracted from HTML (`p|li|h1-h4|blockquote|th|td`) and stripped via regex; full article reconstructed as joined passages.

**Function:** `ahb()` in `src/MProcs/scripts/lpro.py:7597` (inside `mp()`, closure over `z` and `usr`):
1. Asks `Indicate number of (A-HB) results:`
2. Builds pool of `(passage, title, vol, id)` and samples `n` via `random.sample`
3. For each displays `A-HB: {passage}` + `[{title} | {vol}]` and logs `print(usr + f" A-HB: ...", file=z)` + `print(line+header+ct, file=z)` to `MProcs-logs.txt` (file `z`)
4. Asks `Display full article from source header? (enter header/title/id or n):` — if header/id/vol substring matches, displays full article (`=== title ===` + all passages) and logs to `z`; else lists available headers.

**Invocation:**
- Interactive: `ahb` | `A-HB` | `a-hb` | `AHB` | `Agent Handbook` (in `choice()` at `lpro.py:8321`)
- CLI flag: `lpro -ahb` / `lpro -A-HB` / `lpro -agent-handbook` (argparse at `lpro.py:8501`, handler at `9117`)
- Help listed in `commands()` at `lpro.py:443`

**Build:** `pyproject.toml` version bumped `8.8.4.4` → `8.8.4.5`, `twine check` PASSED, wheel includes `ahb.json`.

**Test:**
```bash
PYTHONPATH=src python -m MProcs.scripts.lpro -ahb <<< $'3\nn\n'
# or interactive
lpro
> ahb
Indicate number of (A-HB) results: 2
A-HB: ... [Chapter 1: Fundamentals of Agent Tradecraft | Volume 5: Agent Operations]
Display full article from source header? (enter header/title/id or n): agent-tradecraft
=== Chapter 1: Fundamentals of Agent Tradecraft ===
...
# log verified in MProcs-logs.txt via print(..., file=z)
```


---
## Update 8.8.4.6 — lpro_s non-recording + tsearch integration

**lpro_s.py variant:** mirrored `ahb()` at `src/MProcs/scripts/lpro_s.py:5544` (inside `mp()`, no `z` file logging) — same pool sampling `A-HB: {passage}` + header, asks `Display full article from source header?` and prints full passages without `file=z`. Prevents shadowing by importing `ahb as ahb_data` at `lpro_s.py:20`. Registered in `commands()` at `lpro_s.py:425`, dispatch `choice()` at `lpro_s.py:6193`, flag `parser.add_argument("-ahb"...)` at `lpro_s.py:6355`, handler `if args.ahb: ahb()` at `lpro_s.py:6908`. No recording — prints only via `print()` (bypasses `file=z`).

**tsearch on both:** extended `tsearch()` at `lpro.py:671` and `lpro_s.py:591` to build `ahb_flat = [title + passages as "A-HB: {p} [{title} | {vol}]"]` and pass as extra list to `search_in_lists(search_term, proverbs, ..., strains, ahb_flat)`. Verified `printf "tsearch\ntradecraft\n" | python -m MProcs.scripts.lpro` returns 337 matches including `A-HB:` entries on both.

**Build:** `pyproject.toml` bumped `8.8.4.5` → `8.8.4.6`, rebuilt `dist/mprocs-8.8.4.6*` (`twine check` PASSED), reinstall validated `from MProcs.scripts.data_loader import ahb` 54 articles.

---
## Update 8.8.4.7 — fix whole-volume display → separate-header sections

**Issue:** `ahb()` full-article display previously printed `full_passages` flat (all 223 passages for `agent-tradecraft`), which when invoked via a header that matched a `vol` could appear to dump an entire volume's concatenated text without header separation.

**Fix:** regenerated `src/MProcs/scripts/data/ahb.json` to include `sections` grouping ( `pat = <h1-h4|p|li|blockquote|th|td>` ordered, headers `h1-h4` start new section, following `p|li|...` become `paragraphs`). New size 9.9 MB (9925069 chars), still `twine check` PASSED (wheel 5.3 MB).

**Logic change** `lpro.py:7597` and `lpro_s.py:5544` (`ahb()`):
- First searches `sections` globally for `needle in header.lower()` → if found, displays single matched section `=== {header} === [{title}|{vol}|{aid}]` + its `paragraphs` only (e.g., `1.1 Defining Tradecraft` → 5 paragraphs, verified via `printf "1\n1.1 Defining Tradecraft\n" | python -m MProcs.scripts.lpro -ahb`).
- Else falls back to article-level match (`title|id|vol`) and then renders full article grouped by sections `--- {header} ---` + paragraphs (e.g., `agent-tradecraft` → 45 sections, `Volume 5: Agent Operations` → single article `agent-case-officer` with 40+ sections, not 6-chapter volume).
- Retains recording (`file=z`) for `lpro` and non-recording for `lpro_s`.

**Verification:** `printf "1\nagent-tradecraft\n" | python -m MProcs.scripts.lpro -ahb` now prints `--- 1.1 Defining Tradecraft ---` etc. separately, not intermixed volume dump; `printf "1\nVolume 5: Agent Operations\n" | ...` shows single chapter (371 lines) vs previous whole-volume dump.

**Build:** `pyproject.toml` `8.8.4.6` → `8.8.4.7`, `dist/mprocs-8.8.4.7*` rebuilt, installed `Version: 8.8.4.7`.

---
## Update 8.8.4.8 — numbered selection prompt

**Change:** `ahb()` prompt `Display full article from source header? (enter header/title/id or n)` updated to number-based selection per output count.

- Single result (`number==1`): `Display full article from source header? (y/n):` → `y/yes` displays that passage's source article (grouped sections), `n` exits.
- Multiple results (`number==3` → 1,2,3): `Display full article from source header? Enter number (1-3) or n:` → validates `1-N` integer, displays selected indexed article's full sections. Invalid input shows `Invalid number` / `Invalid input` and returns.
- Display now numbered: `1: A-HB: ...` + `   [title | vol]` for both `lpro.py:7597` and `lpro_s.py:5544`; logging in `lpro` retains `usr + f" {idx}: {line} {header} {ct}"` to `MProcs-logs.txt` (`z`).
- Verified via `printf "3\n2\n" | python -m MProcs.scripts.lpro -ahb` → picks #2, `printf "1\ny\n" | ...` → y branch, and `lpro_s` non-recording variant mirrors without `file=z`.

**Build:** `8.8.4.7` → `8.8.4.8`, `dist/mprocs-8.8.4.8*` rebuilt, `twine check` PASSED.

---
## Update 8.8.4.9 — number selection shows only headered section

**Issue:** Choosing number (1,2,3) displayed whole volume/article (all 45 sections for `agent-tradecraft`) instead of just the separate headered part.

**Fix:** `ahb()` at `lpro.py:7597` / `lpro_s.py:5544` now maps selected passage to its specific `sections` entry. After `selected[sel_idx]` is chosen, `aid_sel` resolves article, then `target_sec` is found where `header == passage_sel` or `passage_sel in paragraphs`. Display is `=== {header} === [{title}|{vol}|{aid}]` + only that section's `paragraphs` (with `file=z` logging for `lpro`), not all `sections`. Example `printf "1\ny\n" | lpro -ahb` where passage `North Korea specialization...` → `=== 6.2.4 Training Curriculum Comparison... ===` (40 lines) vs previous 400+ lines; `printf "3\n2\n" | lpro -ahb` where `2: 15. Forensic Nursing` → only that header's paragraphs. Numbered display `1: A-HB: ...` retained, prompt `Enter number (1-N) or n` for N>1, `(y/n)` for N==1.

**Build:** `8.8.4.8` → `8.8.4.9`, `dist/mprocs-8.8.4.9*` rebuilt, `twine check` PASSED.

---
## Update 8.8.4.10 — loop until n for numbered selection

**Change:** `ahb()` at `lpro.py:7597` / `lpro_s.py:5544` now loops for multiple passages until `n`. Single (`1`) remains `(y/n)` → displays selected headered section once. Multiple (`3` → 1,2,3): `Enter number (1-N) or n:` validates `1-N`, displays that number's headered section (`=== {header} === [{title}|{vol}|{aid}]` + `paragraphs` with `file=z` for `lpro`), then re-prompts `Enter number (1-N) or n:` to display another number until `n`/`q`/`exit`. Verified `printf "3\n1\n2\nn\n" | lpro -ahb` → `=== 14.2 South Korea... ===` then `=== 7.3 Parole... ===` then exit; `printf "1\ny\n"` still single-section. Invalid `0` or non-numeric shows `Invalid number`/`Invalid input` and continues loop.

**Build:** `8.8.4.9` → `8.8.4.10`, `dist/mprocs-8.8.4.10*` rebuilt, `twine check` PASSED.
