# SCOPE: PER-PROJECT kit activation (once per project). For the PER-MACHINE style
# install (global agent instructions + output style), use prompt-style.txt.
# Distinct artifacts — do not merge them.

Read YGGDRASIL/PLAYBOOK.md (it is the agent playbook — follow it) and perform the
COMPLETE setup of the context-economy system (OKF + Graphify + Graph RAG) in this
project:

0. MIGRATION PREREQUISITE: if this project ALREADY HAS an older copy of the kit
   (folder `YGGDRASIL/` or the pre-rename `SETUP-GRAPHIFY/`), replace it WITH THE
   NEW VERSION BEFORE running setup.py (otherwise you run the old
   installer, with no wrapper). Details in YGGDRASIL/MIGRATION.md. First time
   (fresh kit)? Skip this step. Environment prerequisite: `graphify` installed
   (otherwise: `uv tool install graphifyy`).

1. EXPLORE: explore the whole project and detect the layout (single repo / monorepo /
   multi-repo / no git).

2. BUILD: run `graphify` (Claude Code: `/graphify`) — generates
   graphify-out/graph.json + GRAPH_REPORT.md. Greenfield with no code? Skip this and
   use `setup.py --okf` (see YGGDRASIL/prompt-bootstrap.txt).

3. INSTALL: run `python3 YGGDRASIL/scripts/setup.py`. It detects the layout,
   installs post-commit hooks, creates/updates AGENTS.md (with pointers in CLAUDE.md
   and .cursor/rules/), scaffolds knowledge/, generates
   PROJECT_MAP/LABELS_REVIEW/KNOWLEDGE_REVIEW, **and installs the Bash output
   WRAPPER** (PreToolUse hook → graphify-out/wrap.py). What to expect from the wrapper:
   - verbose commands (>50 lines) become a `[graphify-wrap] exit N | ...` header
     + the path to the full log in graphify-out/runs/ (the valid path appears ONLY on
     the [graphify-wrap] line);
   - mutating commands (`rm`, `git push`, mutating POST) always fall to the native
     prompt;
   - bypass: `GRAPHIFY_WRAP=0` turns it off (vanilla). Fail-open: if it breaks, the
     raw command runs.
   Also check the reported CONTENT LANGUAGE: it decides the language of labels and
   knowledge/*.md (instructions stay English). Wrong? Fix it before curating, with
   `--content-language <tag>` or in .graphify_map_config.json.

4. DESCRIBE: fill in the project-description section in AGENTS.md ("### About this
   project", or its localized heading) — 3–6 lines: services/modules, stack, where the
   contract/schema lives, non-obvious decisions — and remove the placeholder comment.

5. CURATE KNOWLEDGE (OKF): answer graphify-out/KNOWLEDGE_REVIEW.md — for every
   question with a real answer, write ONE knowledge/<slug>.md (template in
   knowledge/TEMPLATE.md; only `type` is mandatory, and it stays in the canonical
   English strings; use `resource:` when the rule lives outside git; link concepts
   with ./other.md). Start with the 2–3 concepts that would cause the most confusion
   (priority order, not a limit). "Don't document for the sake of documenting" = do
   not duplicate what the code already tells (a duplicate ages and lies); it does NOT
   mean document little. Record entries in knowledge/log.md. Do NOT edit
   knowledge/index.md (auto-generated).

6. INDEX: run `python3 graphify-out/hook-update-knowledge.py` — indexes new concepts,
   regenerates PROJECT_MAP + index.md, and initializes the hash state (from then on
   indexing is automatic, riding along on post-commit). Run it a second time to
   confirm the silent no-op.

7. RICH LABELS: answer graphify-out/LABELS_REVIEW.md by writing into
   graphify-out/.graphify_labels_override.json in the **`curated`** format
   (recommended): `{"slug": {"anchor": "<node_id>", "curated": "Layer · Function"}}` —
   write ONLY layer+function; relabel COMPUTES dependencies + `[Nn → godnode]`
   metadata on every run (always fresh). The layer must come from the layer_vocab
   listed in the file; if it is empty, defining it is the first step (the review file
   instructs this). Write the labels in the project's content language. Then run
   `python3 graphify-out/relabel.py`. Do not label generated code. Label what you
   understood while exploring — a guessed label is worse than a heuristic one. From
   here on, labeling is the closing of every work item, not a separate task.

8. VALIDATE: one test commit in a repo fires the post-commit hook — confirm in
   graphify-out/hook.log that (a) the graph + PROJECT_MAP updated and (b) the
   knowledge sync rode along (a no-op if nothing changed). Revert the test commit.
   relabel warns about orphan anchors and collisions at the end of the run — fix them
   if any appear.

At the end, show me: the PROJECT_MAP.md, the list of knowledge/*.md created, and
confirmation that the hook worked.
