pythia-plsql 0.15.0__tar.gz → 0.15.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. {pythia_plsql-0.15.0/scripts/pythia_plsql.egg-info → pythia_plsql-0.15.1}/PKG-INFO +8 -2
  2. {pythia_plsql-0.15.0 → pythia_plsql-0.15.1}/README.md +7 -1
  3. {pythia_plsql-0.15.0 → pythia_plsql-0.15.1}/pyproject.toml +1 -1
  4. {pythia_plsql-0.15.0 → pythia_plsql-0.15.1}/scripts/pythia.py +76 -9
  5. {pythia_plsql-0.15.0 → pythia_plsql-0.15.1/scripts/pythia_plsql.egg-info}/PKG-INFO +8 -2
  6. {pythia_plsql-0.15.0 → pythia_plsql-0.15.1}/tests/test_install.py +74 -0
  7. {pythia_plsql-0.15.0 → pythia_plsql-0.15.1}/LICENSE +0 -0
  8. {pythia_plsql-0.15.0 → pythia_plsql-0.15.1}/queries/comment-current.sql +0 -0
  9. {pythia_plsql-0.15.0 → pythia_plsql-0.15.1}/queries/compile-errors.sql +0 -0
  10. {pythia_plsql-0.15.0 → pythia_plsql-0.15.1}/queries/current-schema.sql +0 -0
  11. {pythia_plsql-0.15.0 → pythia_plsql-0.15.1}/queries/db-nls.sql +0 -0
  12. {pythia_plsql-0.15.0 → pythia_plsql-0.15.1}/queries/db-version.sql +0 -0
  13. {pythia_plsql-0.15.0 → pythia_plsql-0.15.1}/queries/dependencies.sql +0 -0
  14. {pythia_plsql-0.15.0 → pythia_plsql-0.15.1}/queries/explain-display.sql +0 -0
  15. {pythia_plsql-0.15.0 → pythia_plsql-0.15.1}/queries/impact.sql +0 -0
  16. {pythia_plsql-0.15.0 → pythia_plsql-0.15.1}/queries/invalid-objects.sql +0 -0
  17. {pythia_plsql-0.15.0 → pythia_plsql-0.15.1}/queries/name-occupants.sql +0 -0
  18. {pythia_plsql-0.15.0 → pythia_plsql-0.15.1}/queries/object-names.sql +0 -0
  19. {pythia_plsql-0.15.0 → pythia_plsql-0.15.1}/queries/object-source.sql +0 -0
  20. {pythia_plsql-0.15.0 → pythia_plsql-0.15.1}/queries/plscope-enabled.sql +0 -0
  21. {pythia_plsql-0.15.0 → pythia_plsql-0.15.1}/queries/plscope-statements.sql +0 -0
  22. {pythia_plsql-0.15.0 → pythia_plsql-0.15.1}/queries/plscope-usages.sql +0 -0
  23. {pythia_plsql-0.15.0 → pythia_plsql-0.15.1}/queries/schema-settings.sql +0 -0
  24. {pythia_plsql-0.15.0 → pythia_plsql-0.15.1}/queries/session-privileges.sql +0 -0
  25. {pythia_plsql-0.15.0 → pythia_plsql-0.15.1}/queries/similar-candidates.sql +0 -0
  26. {pythia_plsql-0.15.0 → pythia_plsql-0.15.1}/queries/source.sql +0 -0
  27. {pythia_plsql-0.15.0 → pythia_plsql-0.15.1}/queries/table-comments.sql +0 -0
  28. {pythia_plsql-0.15.0 → pythia_plsql-0.15.1}/queries/table-indexes.sql +0 -0
  29. {pythia_plsql-0.15.0 → pythia_plsql-0.15.1}/queries/table-stats.sql +0 -0
  30. {pythia_plsql-0.15.0 → pythia_plsql-0.15.1}/queries/unindexed-fks.sql +0 -0
  31. {pythia_plsql-0.15.0 → pythia_plsql-0.15.1}/scripts/pythia_plsql.egg-info/SOURCES.txt +0 -0
  32. {pythia_plsql-0.15.0 → pythia_plsql-0.15.1}/scripts/pythia_plsql.egg-info/dependency_links.txt +0 -0
  33. {pythia_plsql-0.15.0 → pythia_plsql-0.15.1}/scripts/pythia_plsql.egg-info/entry_points.txt +0 -0
  34. {pythia_plsql-0.15.0 → pythia_plsql-0.15.1}/scripts/pythia_plsql.egg-info/requires.txt +0 -0
  35. {pythia_plsql-0.15.0 → pythia_plsql-0.15.1}/scripts/pythia_plsql.egg-info/top_level.txt +0 -0
  36. {pythia_plsql-0.15.0 → pythia_plsql-0.15.1}/setup.cfg +0 -0
  37. {pythia_plsql-0.15.0 → pythia_plsql-0.15.1}/skills/pythia-apply/SKILL.md +0 -0
  38. {pythia_plsql-0.15.0 → pythia_plsql-0.15.1}/skills/pythia-autopilot/SKILL.md +0 -0
  39. {pythia_plsql-0.15.0 → pythia_plsql-0.15.1}/skills/pythia-comment/SKILL.md +0 -0
  40. {pythia_plsql-0.15.0 → pythia_plsql-0.15.1}/skills/pythia-conventions/SKILL.md +0 -0
  41. {pythia_plsql-0.15.0 → pythia_plsql-0.15.1}/skills/pythia-deploy/SKILL.md +0 -0
  42. {pythia_plsql-0.15.0 → pythia_plsql-0.15.1}/skills/pythia-explore/SKILL.md +0 -0
  43. {pythia_plsql-0.15.0 → pythia_plsql-0.15.1}/skills/pythia-explore/reference/data-dictionary.md +0 -0
  44. {pythia_plsql-0.15.0 → pythia_plsql-0.15.1}/skills/pythia-impact/SKILL.md +0 -0
  45. {pythia_plsql-0.15.0 → pythia_plsql-0.15.1}/skills/pythia-package/SKILL.md +0 -0
  46. {pythia_plsql-0.15.0 → pythia_plsql-0.15.1}/skills/pythia-package/reference/plsql-standards.md +0 -0
  47. {pythia_plsql-0.15.0 → pythia_plsql-0.15.1}/skills/pythia-review/SKILL.md +0 -0
  48. {pythia_plsql-0.15.0 → pythia_plsql-0.15.1}/skills/pythia-review/reference/antipatterns.md +0 -0
  49. {pythia_plsql-0.15.0 → pythia_plsql-0.15.1}/skills/pythia-setup/SKILL.md +0 -0
  50. {pythia_plsql-0.15.0 → pythia_plsql-0.15.1}/skills/pythia-setup/reference/environment.md +0 -0
  51. {pythia_plsql-0.15.0 → pythia_plsql-0.15.1}/skills/pythia-skill-author/SKILL.md +0 -0
  52. {pythia_plsql-0.15.0 → pythia_plsql-0.15.1}/skills/pythia-spec/SKILL.md +0 -0
  53. {pythia_plsql-0.15.0 → pythia_plsql-0.15.1}/skills/pythia-table/SKILL.md +0 -0
  54. {pythia_plsql-0.15.0 → pythia_plsql-0.15.1}/skills/pythia-table/reference/ddl-standards.md +0 -0
  55. {pythia_plsql-0.15.0 → pythia_plsql-0.15.1}/skills/pythia-tune/SKILL.md +0 -0
  56. {pythia_plsql-0.15.0 → pythia_plsql-0.15.1}/skills/pythia-tune/reference/tuning-checklist.md +0 -0
  57. {pythia_plsql-0.15.0 → pythia_plsql-0.15.1}/skills/pythia-verify/SKILL.md +0 -0
  58. {pythia_plsql-0.15.0 → pythia_plsql-0.15.1}/skills/pythia-write/SKILL.md +0 -0
  59. {pythia_plsql-0.15.0 → pythia_plsql-0.15.1}/skills/pythia-write/reference/patterns.md +0 -0
  60. {pythia_plsql-0.15.0 → pythia_plsql-0.15.1}/skills/using-pythia/SKILL.md +0 -0
  61. {pythia_plsql-0.15.0 → pythia_plsql-0.15.1}/tests/test_mcp.py +0 -0
  62. {pythia_plsql-0.15.0 → pythia_plsql-0.15.1}/tests/test_phase1.py +0 -0
  63. {pythia_plsql-0.15.0 → pythia_plsql-0.15.1}/tests/test_phase2.py +0 -0
  64. {pythia_plsql-0.15.0 → pythia_plsql-0.15.1}/tests/test_phase3.py +0 -0
  65. {pythia_plsql-0.15.0 → pythia_plsql-0.15.1}/tests/test_phase5.py +0 -0
  66. {pythia_plsql-0.15.0 → pythia_plsql-0.15.1}/tests/test_phase6.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pythia-plsql
3
- Version: 0.15.0
3
+ Version: 0.15.1
4
4
  Summary: PL/SQL development for AI agents on Oracle Database - expert data-dictionary queries, impact analysis, and a snapshot-verified write path with honest rollback.
5
5
  License: MIT
6
6
  Project-URL: Homepage, https://github.com/thaildhe172591/pythia
@@ -139,7 +139,7 @@ Or the same thing piecewise:
139
139
 
140
140
  ```bash
141
141
  pip install pythia-plsql # the CLI (thin driver — no Oracle Instant Client needed)
142
- python -m pythia install # skills + .pythia/ scaffold + Claude Code hooks + Codex AGENTS.md/MCP approver
142
+ python -m pythia install # skills + .pythia/ scaffold + Claude Code CLAUDE.md/hooks + Codex AGENTS.md/MCP approver
143
143
  pythia check # fill in connections.json first, then verify
144
144
  ```
145
145
 
@@ -191,6 +191,12 @@ each agent needs you to finish by hand.
191
191
  - a `deny` rule so the agent cannot forge a grant, and the MCP server
192
192
  enabled.
193
193
 
194
+ It also writes the harness into **`CLAUDE.md`** — the file Claude Code
195
+ itself loads every session — in a marker-delimited block, leaving your own
196
+ text untouched. The rules hold even with `--no-hooks`, before a restart,
197
+ or while the hooks are untrusted; when the block is there, the
198
+ SessionStart hook adds only the live state instead of repeating the guide.
199
+
194
200
  Skills land in `.claude/skills` (or `~/.claude/skills` with `-g`).
195
201
  2. **Restart the Claude Code session** so the hooks and the MCP server load.
196
202
  3. **Run `pythia doctor`.** It confirms the wiring and names every setting
@@ -125,7 +125,7 @@ Or the same thing piecewise:
125
125
 
126
126
  ```bash
127
127
  pip install pythia-plsql # the CLI (thin driver — no Oracle Instant Client needed)
128
- python -m pythia install # skills + .pythia/ scaffold + Claude Code hooks + Codex AGENTS.md/MCP approver
128
+ python -m pythia install # skills + .pythia/ scaffold + Claude Code CLAUDE.md/hooks + Codex AGENTS.md/MCP approver
129
129
  pythia check # fill in connections.json first, then verify
130
130
  ```
131
131
 
@@ -177,6 +177,12 @@ each agent needs you to finish by hand.
177
177
  - a `deny` rule so the agent cannot forge a grant, and the MCP server
178
178
  enabled.
179
179
 
180
+ It also writes the harness into **`CLAUDE.md`** — the file Claude Code
181
+ itself loads every session — in a marker-delimited block, leaving your own
182
+ text untouched. The rules hold even with `--no-hooks`, before a restart,
183
+ or while the hooks are untrusted; when the block is there, the
184
+ SessionStart hook adds only the live state instead of repeating the guide.
185
+
180
186
  Skills land in `.claude/skills` (or `~/.claude/skills` with `-g`).
181
187
  2. **Restart the Claude Code session** so the hooks and the MCP server load.
182
188
  3. **Run `pythia doctor`.** It confirms the wiring and names every setting
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "pythia-plsql"
7
- version = "0.15.0"
7
+ version = "0.15.1"
8
8
  description = "PL/SQL development for AI agents on Oracle Database - expert data-dictionary queries, impact analysis, and a snapshot-verified write path with honest rollback."
9
9
  readme = "README.md"
10
10
  license = { text = "MIT" }
@@ -61,7 +61,7 @@ import pathlib
61
61
  import re
62
62
  import sys
63
63
 
64
- __version__ = "0.15.0" # kept equal to pyproject.toml (tests/test_install.py)
64
+ __version__ = "0.15.1" # kept equal to pyproject.toml (tests/test_install.py)
65
65
 
66
66
  READONLY = re.compile(r"^\s*(select|with)\b", re.I)
67
67
  CONFIG_DIR = ".pythia"
@@ -3117,14 +3117,42 @@ def agents_md_block():
3117
3117
  f"{AGENTS_END}")
3118
3118
 
3119
3119
 
3120
- def merge_agents_md(path):
3121
- """Write the pythia block into an AGENTS.md. The file is the developer's,
3122
- shared with every AGENTS.md-reading agent, so only the delimited block is
3123
- ours: present -> replaced in place, absent -> appended below their text,
3124
- everything else byte-identical. Returns (path, action) where action is
3125
- 'created' | 'updated' | 'unchanged'."""
3120
+ def claude_md_block():
3121
+ """The pythia section for CLAUDE.md — the file Claude Code itself loads
3122
+ every session, whether or not the hooks are wired, trusted or restarted.
3123
+ Same BRIEF_GUIDE as AGENTS.md and the SessionStart hook (one source, no
3124
+ drift), plus what only Claude needs: its approval doors in order, and the
3125
+ standing rules an agent breaks most when nothing reminds it."""
3126
+ return (f"{AGENTS_BEGIN}\n"
3127
+ "## pythia — developing PL/SQL on Oracle\n\n"
3128
+ f"{BRIEF_GUIDE.rstrip()}\n\n"
3129
+ "APPROVAL ON CLAUDE CODE: first door is the `pythia_approve` tool "
3130
+ "(MCP server `pythia`, registered in .mcp.json) — it prompts in "
3131
+ "every permission mode but dontAsk and shows pythia's own card. "
3132
+ "Not connected? Ask an AskUserQuestion whose text is exactly the "
3133
+ "output of `pythia approve --card <token>`, options Approve / "
3134
+ "Reject, never with pre-filled answers; if the hook says no answer "
3135
+ "came back, do not ask the same way again — use the tool, or relay "
3136
+ "`pythia approve <token>` for the developer's terminal. Then run "
3137
+ "the command the approval names yourself.\n\n"
3138
+ "STANDING RULES: writes only through `pythia apply` / `pythia "
3139
+ "deploy` (never sqlplus, never SQLcl run-sql); `pythia impact` "
3140
+ "before any change; `pythia lint` before any apply; never open "
3141
+ ".pythia/connections.json (`pythia connections`); exit 3 is "
3142
+ "written-but-broken, never done; under an autopilot lease report "
3143
+ "every write (`pythia autopilot report`), and a paused lease means "
3144
+ "stop and show the developer. Full contract: `pythia guide`; the "
3145
+ "skills (`using-pythia` routes) carry the workflows.\n"
3146
+ f"{AGENTS_END}")
3147
+
3148
+
3149
+ def merge_marked_block(path, block):
3150
+ """Write a pythia block into a developer's instruction file. The file is
3151
+ theirs, shared with every agent that reads it, so only the delimited
3152
+ block is ours: present -> replaced in place, absent -> appended below
3153
+ their text, everything else byte-identical. Returns (path, action) where
3154
+ action is 'created' | 'updated' | 'unchanged'."""
3126
3155
  path = pathlib.Path(path)
3127
- block = agents_md_block()
3128
3156
  old = path.read_text(encoding="utf-8") if path.is_file() else None
3129
3157
  if old is None:
3130
3158
  new, action = block + "\n", "created"
@@ -3142,6 +3170,16 @@ def merge_agents_md(path):
3142
3170
  return path, action
3143
3171
 
3144
3172
 
3173
+ def merge_agents_md(path):
3174
+ """The pythia block in an AGENTS.md (Codex and AGENTS.md agents)."""
3175
+ return merge_marked_block(path, agents_md_block())
3176
+
3177
+
3178
+ def merge_claude_md(path):
3179
+ """The pythia block in a CLAUDE.md (Claude Code)."""
3180
+ return merge_marked_block(path, claude_md_block())
3181
+
3182
+
3145
3183
  OPERATING_GUIDE = """\
3146
3184
  THE OPERATING MODEL — Learn, Ask, Do (Hoc - Hoi - Lam)
3147
3185
 
@@ -4048,6 +4086,18 @@ def report_claude_hooks(base_dir, ns, events=None):
4048
4086
  print(f"\nClaude Code hooks already in {path}.")
4049
4087
 
4050
4088
 
4089
+ def report_claude_md(project_root):
4090
+ """Project scope: write the harness into <project>/CLAUDE.md, the file
4091
+ Claude Code loads every session — so the rules hold even with --no-hooks,
4092
+ before a restart, or while the hooks are untrusted. Not on -g: a global
4093
+ CLAUDE.md would put pythia into every session on the machine."""
4094
+ path, action = merge_claude_md(pathlib.Path(project_root) / "CLAUDE.md")
4095
+ verb = {"created": "Wrote the pythia harness into",
4096
+ "updated": "Updated the pythia block in",
4097
+ "unchanged": "pythia harness already current in"}[action]
4098
+ print(f"\n{verb} {path} (Claude Code loads it every session).")
4099
+
4100
+
4051
4101
  def report_codex_agents_md(project_root):
4052
4102
  """Project scope: write the harness into <project>/AGENTS.md, the file
4053
4103
  Codex loads every session. Not done on -g — a global AGENTS.md is noise in
@@ -4143,6 +4193,7 @@ def cmd_install(conn, schema, ns):
4143
4193
  else:
4144
4194
  clean_legacy_skills(ns.project_root)
4145
4195
  report_claude_hooks(ns.project_root, ns)
4196
+ report_claude_md(ns.project_root)
4146
4197
  report_codex_agents_md(ns.project_root)
4147
4198
  report_codex_hooks(ns.project_root, ns)
4148
4199
  report_codex_mcp(ns.project_root, ns)
@@ -6342,7 +6393,16 @@ def cmd_hook(conn, schema, ns):
6342
6393
  if isinstance(payload, dict) and payload.get("cwd"):
6343
6394
  _, r2 = find_config(pathlib.Path(payload["cwd"]), {})
6344
6395
  root = r2 or root
6345
- print(BRIEF_GUIDE.rstrip())
6396
+ md = pathlib.Path(root) / "CLAUDE.md"
6397
+ loaded = md.is_file() and AGENTS_BEGIN in md.read_text(
6398
+ encoding="utf-8", errors="replace")
6399
+ if loaded:
6400
+ # Claude Code already loaded the guide from CLAUDE.md: the
6401
+ # hook adds what a static file cannot — the live state
6402
+ print("PYTHIA HARNESS ACTIVE - the rules are in CLAUDE.md "
6403
+ "(pythia block); `pythia guide` prints the full contract.")
6404
+ else:
6405
+ print(BRIEF_GUIDE.rstrip())
6346
6406
  print("STATE " + "\n ".join(session_state_lines(root)))
6347
6407
  return
6348
6408
  out = (pre_tool_decision(payload) if event == "pre-tool"
@@ -6494,6 +6554,13 @@ def harness_checks(project_root, home=None):
6494
6554
  out.append(("fail", "AskUserQuestion",
6495
6555
  f"{what} — {where}. The question returns empty and approval "
6496
6556
  "never arrives; remove it, or approve with pythia_approve"))
6557
+ cmd_md = root / "CLAUDE.md"
6558
+ has_block = cmd_md.is_file() and AGENTS_BEGIN in cmd_md.read_text(
6559
+ encoding="utf-8", errors="replace")
6560
+ out.append(("ok" if has_block else "warn", "claude.md",
6561
+ "CLAUDE.md carries the pythia block" if has_block else
6562
+ f"no pythia block in CLAUDE.md — the rules then reach Claude "
6563
+ f"only through the hooks; {invocation()} install adds it"))
6497
6564
  agents = root / "AGENTS.md"
6498
6565
  out.append(("ok" if agents.is_file() and AGENTS_BEGIN in agents.read_text(
6499
6566
  encoding="utf-8") else "info", "codex",
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pythia-plsql
3
- Version: 0.15.0
3
+ Version: 0.15.1
4
4
  Summary: PL/SQL development for AI agents on Oracle Database - expert data-dictionary queries, impact analysis, and a snapshot-verified write path with honest rollback.
5
5
  License: MIT
6
6
  Project-URL: Homepage, https://github.com/thaildhe172591/pythia
@@ -139,7 +139,7 @@ Or the same thing piecewise:
139
139
 
140
140
  ```bash
141
141
  pip install pythia-plsql # the CLI (thin driver — no Oracle Instant Client needed)
142
- python -m pythia install # skills + .pythia/ scaffold + Claude Code hooks + Codex AGENTS.md/MCP approver
142
+ python -m pythia install # skills + .pythia/ scaffold + Claude Code CLAUDE.md/hooks + Codex AGENTS.md/MCP approver
143
143
  pythia check # fill in connections.json first, then verify
144
144
  ```
145
145
 
@@ -191,6 +191,12 @@ each agent needs you to finish by hand.
191
191
  - a `deny` rule so the agent cannot forge a grant, and the MCP server
192
192
  enabled.
193
193
 
194
+ It also writes the harness into **`CLAUDE.md`** — the file Claude Code
195
+ itself loads every session — in a marker-delimited block, leaving your own
196
+ text untouched. The rules hold even with `--no-hooks`, before a restart,
197
+ or while the hooks are untrusted; when the block is there, the
198
+ SessionStart hook adds only the live state instead of repeating the guide.
199
+
194
200
  Skills land in `.claude/skills` (or `~/.claude/skills` with `-g`).
195
201
  2. **Restart the Claude Code session** so the hooks and the MCP server load.
196
202
  3. **Run `pythia doctor`.** It confirms the wiring and names every setting
@@ -4,6 +4,7 @@ no network, no npx needed.
4
4
 
5
5
  Run: python tests/test_install.py
6
6
  """
7
+ import io
7
8
  import json
8
9
  import os
9
10
  import pathlib
@@ -427,6 +428,79 @@ def test_merge_agents_md_preserves_the_developers_text():
427
428
  assert path.read_text(encoding="utf-8").count(pythia.AGENTS_BEGIN) == 1
428
429
 
429
430
 
431
+ # --- Claude Code: CLAUDE.md, the file Claude Code itself always loads ---------
432
+
433
+ def test_claude_md_block_carries_the_harness_for_claude_not_codex():
434
+ """Claude Code loads CLAUDE.md every session, hooks or not. The block holds
435
+ the same brief guide as AGENTS.md and the session hook — one source — but
436
+ names Claude's approval doors, never Codex's."""
437
+ block = pythia.claude_md_block()
438
+ assert block.startswith(pythia.AGENTS_BEGIN) and block.endswith(pythia.AGENTS_END)
439
+ assert pythia.BRIEF_GUIDE.rstrip() in block
440
+ assert "pythia_approve" in block and "AskUserQuestion" in block
441
+ assert "APPROVAL ON CODEX" not in block
442
+ for rule in ("pythia apply", "pythia deploy", "autopilot", "impact",
443
+ "connections.json"):
444
+ assert rule in block, rule
445
+
446
+
447
+ def test_merge_claude_md_keeps_the_developers_text_and_is_idempotent():
448
+ with tempfile.TemporaryDirectory() as td:
449
+ path = pathlib.Path(td) / "CLAUDE.md"
450
+ assert pythia.merge_claude_md(path) == (path, "created")
451
+ assert pythia.merge_claude_md(path) == (path, "unchanged")
452
+ path.write_text("# Our project\n\nUse tabs.\n", encoding="utf-8")
453
+ assert pythia.merge_claude_md(path)[1] == "updated"
454
+ body = path.read_text(encoding="utf-8")
455
+ assert body.startswith("# Our project\n\nUse tabs.\n")
456
+ assert body.count(pythia.AGENTS_BEGIN) == 1
457
+ pythia.merge_claude_md(path) # a second run
458
+ assert path.read_text(encoding="utf-8").count(pythia.AGENTS_BEGIN) == 1
459
+
460
+
461
+ def test_cmd_install_writes_claude_md_in_the_project_scope():
462
+ import argparse
463
+ import contextlib
464
+ old = os.environ.get("PATH")
465
+ os.environ["PATH"] = "" # no npx: bundled path, offline
466
+ try:
467
+ with tempfile.TemporaryDirectory() as td:
468
+ ns = argparse.Namespace(project_root=td, glob=False, source=None,
469
+ color=False, json=False, no_hooks=True)
470
+ with contextlib.redirect_stdout(io.StringIO()):
471
+ pythia.cmd_install(None, None, ns)
472
+ md = pathlib.Path(td) / "CLAUDE.md"
473
+ assert md.is_file() # even with --no-hooks
474
+ assert pythia.AGENTS_BEGIN in md.read_text(encoding="utf-8")
475
+ finally:
476
+ if old is not None:
477
+ os.environ["PATH"] = old
478
+
479
+
480
+ def test_session_start_does_not_repeat_what_claude_md_already_loaded():
481
+ """With the pythia block in CLAUDE.md the session hook would inject the
482
+ same guide twice; it prints the live state and a pointer instead."""
483
+ import argparse
484
+ import contextlib
485
+ with tempfile.TemporaryDirectory() as td:
486
+ def run():
487
+ old = sys.stdin
488
+ sys.stdin = io.StringIO("")
489
+ buf = io.StringIO()
490
+ try:
491
+ with contextlib.redirect_stdout(buf):
492
+ pythia.cmd_hook(None, None, argparse.Namespace(
493
+ event="session-start", project_root=td))
494
+ finally:
495
+ sys.stdin = old
496
+ return buf.getvalue()
497
+ first_line = pythia.BRIEF_GUIDE.splitlines()[2] # the ROUTE line
498
+ assert first_line in run()
499
+ pythia.merge_claude_md(pathlib.Path(td) / "CLAUDE.md")
500
+ out = run()
501
+ assert first_line not in out and "CLAUDE.md" in out and "STATE" in out
502
+
503
+
430
504
  # --- Codex: session-start hook (TP3) -----------------------------------------
431
505
 
432
506
  def test_merge_codex_hooks_creates_and_is_idempotent():
File without changes
File without changes