phiward 0.2.0b1__py3-none-any.whl

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 (53) hide show
  1. phiward/__init__.py +8 -0
  2. phiward/__main__.py +5 -0
  3. phiward/_toml.py +211 -0
  4. phiward/adapters/__init__.py +105 -0
  5. phiward/adapters/claude.py +429 -0
  6. phiward/broker.py +831 -0
  7. phiward/carryover.py +1613 -0
  8. phiward/claude_settings.py +1307 -0
  9. phiward/cli.py +110 -0
  10. phiward/config.py +936 -0
  11. phiward/confine.py +476 -0
  12. phiward/copying.py +533 -0
  13. phiward/core.py +105 -0
  14. phiward/data/agents-section.md +43 -0
  15. phiward/doctor.py +1132 -0
  16. phiward/fasthook.py +70 -0
  17. phiward/fsinfo.py +241 -0
  18. phiward/gateway.py +159 -0
  19. phiward/githooks.py +248 -0
  20. phiward/guards/__init__.py +0 -0
  21. phiward/guards/protected_paths.py +1138 -0
  22. phiward/hidden.py +281 -0
  23. phiward/init.py +155 -0
  24. phiward/install.py +828 -0
  25. phiward/inventory.py +173 -0
  26. phiward/mcp.py +186 -0
  27. phiward/mcp_config.py +1736 -0
  28. phiward/names.py +5 -0
  29. phiward/packs/dates.toml +17 -0
  30. phiward/packs/genomics.toml +51 -0
  31. phiward/packs/msk.toml +32 -0
  32. phiward/pathid.py +403 -0
  33. phiward/pathmatch.py +98 -0
  34. phiward/paths.py +942 -0
  35. phiward/pin.py +214 -0
  36. phiward/procinfo.py +73 -0
  37. phiward/remote.py +448 -0
  38. phiward/run.py +788 -0
  39. phiward/safeio.py +84 -0
  40. phiward/sanitize.py +691 -0
  41. phiward/selfcheck.py +1506 -0
  42. phiward/service.py +321 -0
  43. phiward/session_note.py +86 -0
  44. phiward/setup_cmd.py +886 -0
  45. phiward/shell.py +504 -0
  46. phiward/wholetool.py +1463 -0
  47. phiward-0.2.0b1.dist-info/METADATA +147 -0
  48. phiward-0.2.0b1.dist-info/RECORD +53 -0
  49. phiward-0.2.0b1.dist-info/WHEEL +5 -0
  50. phiward-0.2.0b1.dist-info/entry_points.txt +3 -0
  51. phiward-0.2.0b1.dist-info/licenses/LICENSE +662 -0
  52. phiward-0.2.0b1.dist-info/licenses/NOTICE +16 -0
  53. phiward-0.2.0b1.dist-info/top_level.txt +1 -0
phiward/cli.py ADDED
@@ -0,0 +1,110 @@
1
+ """The `phiward` command. Each subcommand lives in its own module and is imported on use,
2
+ so a hook call loads only what it needs."""
3
+
4
+ import sys
5
+ from typing import List, Optional
6
+
7
+ USAGE = """usage: phiward <command> [args]
8
+ phiward <command> --help
9
+ phiward --version the installed version (also: phiward version, -V)
10
+
11
+ The operator's commands (run them in your own terminal, not through an agent):
12
+ setup first-time setup: asks questions and writes the user config
13
+ (--first-run: the first config without questions, only when none exists)
14
+ pin approve the listed programs; record the derived protected folders
15
+ broker run the gateway commands outside the agent; start it yourself
16
+ (broker --service [--write]: install it as a login service)
17
+ carryover status|add|show|accept|reset
18
+ read and keep what `launch` sessions put in quarantine
19
+
20
+ Wire a project and a tool:
21
+ init [--root DIR] set up a project: AGENTS.md rules, settings, git hooks (it only adds)
22
+ install claude print the wiring for Claude Code, or write it after a diff and a yes
23
+ doctor show the config in force and what may turn the guards off
24
+ mcp list|wrap|unwrap show your MCP servers; run one under `phiward launch` (wrap), or
25
+ not (unwrap, in your own terminal)
26
+
27
+ Work with protected data:
28
+ run [GRANTS] -- CMD run CMD with read access to protected data, output masked
29
+ copy SRC... DST copy into a protected folder or a configured remote, nothing printed
30
+ launch [--tool NAME] [--memory] [--report FILE] [-- PROGRAM...]
31
+ run a whole agent tool in the kernel profile (Mode B)
32
+ check -- CMD show the decision for a shell command in the current folder
33
+ sanitize filter stdin to stdout, masking protected paths and identifiers
34
+
35
+ Called by tools (you rarely run these yourself):
36
+ hook claude read a hook payload on stdin and reply as Claude Code expects
37
+ session-note claude the start-of-session note (a SessionStart hook)
38
+ mcp an MCP server with the gateway as tools
39
+ git-hook NAME run a git hook (pre-commit, pre-push), or install them
40
+ """
41
+
42
+
43
+ def main(argv: Optional[List[str]] = None) -> int:
44
+ args = list(sys.argv[1:] if argv is None else argv)
45
+ if args[:3] == ["hook", "claude", "--launched"]:
46
+ # written only by `launch` into the tool's own settings: the kernel decides, this is a
47
+ # fast first layer; without the roots it is the full hook (a variable alone never
48
+ # chooses it)
49
+ if "PHIWARD_HOOK_ROOTS" in __import__("os").environ:
50
+ from phiward import fasthook
51
+ return fasthook.main()
52
+ args = args[:2]
53
+ if args[:1] in (["--version"], ["-V"], ["version"]):
54
+ from phiward import __version__
55
+ print(f"phiward {__version__}")
56
+ return 0
57
+ if not args or args[0] in ("-h", "--help", "help"):
58
+ print(USAGE, end="")
59
+ return 0 if args else 2
60
+ cmd, rest = args[0], args[1:]
61
+ if cmd == "hook":
62
+ from phiward.adapters import run_hook
63
+ return run_hook(rest)
64
+ if cmd == "init":
65
+ from phiward import init
66
+ return init.main(rest)
67
+ if cmd == "mcp":
68
+ from phiward import mcp
69
+ return mcp.main(rest)
70
+ if cmd == "session-note":
71
+ from phiward import session_note
72
+ return session_note.main(rest)
73
+ if cmd == "check":
74
+ from phiward.adapters import run_check
75
+ return run_check(rest)
76
+ if cmd == "sanitize":
77
+ from phiward import sanitize
78
+ return sanitize.main(rest)
79
+ if cmd == "run":
80
+ from phiward import run
81
+ return run.main(rest)
82
+ if cmd == "setup":
83
+ from phiward import setup_cmd
84
+ return setup_cmd.main(rest)
85
+ if cmd == "pin":
86
+ from phiward import pin
87
+ return pin.main(rest)
88
+ if cmd == "broker":
89
+ from phiward import broker
90
+ return broker.main(rest)
91
+ if cmd == "launch":
92
+ from phiward import wholetool
93
+ return wholetool.main(rest)
94
+ if cmd == "carryover":
95
+ from phiward import carryover
96
+ return carryover.main(rest)
97
+ if cmd == "copy":
98
+ from phiward import copying as copy
99
+ return copy.main(rest)
100
+ if cmd == "git-hook":
101
+ from phiward import githooks
102
+ return githooks.main(rest)
103
+ if cmd == "install":
104
+ from phiward.adapters import run_install
105
+ return run_install(rest)
106
+ if cmd == "doctor":
107
+ from phiward import doctor
108
+ return doctor.main(rest)
109
+ print(f"phiward: unknown command '{cmd}'\n" + USAGE, file=sys.stderr, end="")
110
+ return 2