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.
- phiward/__init__.py +8 -0
- phiward/__main__.py +5 -0
- phiward/_toml.py +211 -0
- phiward/adapters/__init__.py +105 -0
- phiward/adapters/claude.py +429 -0
- phiward/broker.py +831 -0
- phiward/carryover.py +1613 -0
- phiward/claude_settings.py +1307 -0
- phiward/cli.py +110 -0
- phiward/config.py +936 -0
- phiward/confine.py +476 -0
- phiward/copying.py +533 -0
- phiward/core.py +105 -0
- phiward/data/agents-section.md +43 -0
- phiward/doctor.py +1132 -0
- phiward/fasthook.py +70 -0
- phiward/fsinfo.py +241 -0
- phiward/gateway.py +159 -0
- phiward/githooks.py +248 -0
- phiward/guards/__init__.py +0 -0
- phiward/guards/protected_paths.py +1138 -0
- phiward/hidden.py +281 -0
- phiward/init.py +155 -0
- phiward/install.py +828 -0
- phiward/inventory.py +173 -0
- phiward/mcp.py +186 -0
- phiward/mcp_config.py +1736 -0
- phiward/names.py +5 -0
- phiward/packs/dates.toml +17 -0
- phiward/packs/genomics.toml +51 -0
- phiward/packs/msk.toml +32 -0
- phiward/pathid.py +403 -0
- phiward/pathmatch.py +98 -0
- phiward/paths.py +942 -0
- phiward/pin.py +214 -0
- phiward/procinfo.py +73 -0
- phiward/remote.py +448 -0
- phiward/run.py +788 -0
- phiward/safeio.py +84 -0
- phiward/sanitize.py +691 -0
- phiward/selfcheck.py +1506 -0
- phiward/service.py +321 -0
- phiward/session_note.py +86 -0
- phiward/setup_cmd.py +886 -0
- phiward/shell.py +504 -0
- phiward/wholetool.py +1463 -0
- phiward-0.2.0b1.dist-info/METADATA +147 -0
- phiward-0.2.0b1.dist-info/RECORD +53 -0
- phiward-0.2.0b1.dist-info/WHEEL +5 -0
- phiward-0.2.0b1.dist-info/entry_points.txt +3 -0
- phiward-0.2.0b1.dist-info/licenses/LICENSE +662 -0
- phiward-0.2.0b1.dist-info/licenses/NOTICE +16 -0
- 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
|