project-init 0.3.0__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.
- project_init/__init__.py +4 -0
- project_init/__main__.py +662 -0
- project_init/mcps.py +57 -0
- project_init/scaffold.py +374 -0
- project_init/templates/base/AGENTS.md.tmpl +50 -0
- project_init/templates/base/CLAUDE.md.tmpl +16 -0
- project_init/templates/base/CONTRIBUTING.md.tmpl +55 -0
- project_init/templates/base/GEMINI.md.tmpl +16 -0
- project_init/templates/base/LICENSE.tmpl +231 -0
- project_init/templates/base/SECURITY.md.tmpl +26 -0
- project_init/templates/base/docs/explanation/index.md +9 -0
- project_init/templates/base/docs/how-to/index.md +7 -0
- project_init/templates/base/docs/index.md.tmpl +20 -0
- project_init/templates/base/docs/reference/index.md +13 -0
- project_init/templates/base/docs/tutorials/index.md +7 -0
- project_init/templates/base/dot_claude/agents/README.md +30 -0
- project_init/templates/base/dot_claude/config.yaml.tmpl +31 -0
- project_init/templates/base/dot_claude/docs/README.md +26 -0
- project_init/templates/base/dot_claude/docs/adr/adr-001-memory-stack.md.tmpl +22 -0
- project_init/templates/base/dot_claude/docs/adr/adr-002-mcp-choices.md.tmpl +32 -0
- project_init/templates/base/dot_claude/docs/adr/adr-template.md +29 -0
- project_init/templates/base/dot_claude/docs/development/conventions.md.tmpl +31 -0
- project_init/templates/base/dot_claude/docs/development/testing.md +25 -0
- project_init/templates/base/dot_claude/docs/guides/developer-onboarding.md +110 -0
- project_init/templates/base/dot_claude/docs/guides/issue-metadata.md +27 -0
- project_init/templates/base/dot_claude/docs/guides/secrets.md +50 -0
- project_init/templates/base/dot_claude/docs/guides/using-memory.md +36 -0
- project_init/templates/base/dot_claude/hooks/README.md +15 -0
- project_init/templates/base/dot_claude/hooks/agent_guard_adapter.py.tmpl +64 -0
- project_init/templates/base/dot_claude/hooks/dag_workflow.py +610 -0
- project_init/templates/base/dot_claude/memory/MEMORY.md.tmpl +11 -0
- project_init/templates/base/dot_claude/memory/README.md +51 -0
- project_init/templates/base/dot_claude/memory/SCHEMA.md +52 -0
- project_init/templates/base/dot_claude/memory/feedback_conventions.md +11 -0
- project_init/templates/base/dot_claude/memory/project_context.md.tmpl +11 -0
- project_init/templates/base/dot_claude/memory/user_role.md +7 -0
- project_init/templates/base/dot_claude/project-init.md.tmpl +174 -0
- project_init/templates/base/dot_claude/rules/go.md +14 -0
- project_init/templates/base/dot_claude/rules/hooks.md +30 -0
- project_init/templates/base/dot_claude/rules/node.md +17 -0
- project_init/templates/base/dot_claude/rules/python.md +25 -0
- project_init/templates/base/dot_claude/scripts/README.md +15 -0
- project_init/templates/base/dot_claude/scripts/create_issue.sh +577 -0
- project_init/templates/base/dot_claude/scripts/create_nojira_pr.sh +3 -0
- project_init/templates/base/dot_claude/scripts/finish_pr.sh +3 -0
- project_init/templates/base/dot_claude/scripts/install_hooks.sh +55 -0
- project_init/templates/base/dot_claude/scripts/monitor_pr.sh +270 -0
- project_init/templates/base/dot_claude/scripts/promote_review.sh +3 -0
- project_init/templates/base/dot_claude/scripts/push_branch.sh +5 -0
- project_init/templates/base/dot_claude/scripts/push_wiki.sh +34 -0
- project_init/templates/base/dot_claude/scripts/setup_github.sh +219 -0
- project_init/templates/base/dot_claude/scripts/start_issue.sh +134 -0
- project_init/templates/base/dot_claude/settings.json.tmpl +83 -0
- project_init/templates/base/dot_claude/skills/README.md +12 -0
- project_init/templates/base/dot_claude/skills/plan/SKILL.md.tmpl +40 -0
- project_init/templates/base/dot_claude/vault/README.md +21 -0
- project_init/templates/base/dot_claude/vault/decisions/README.md +22 -0
- project_init/templates/base/dot_claude/vault/design/README.md +3 -0
- project_init/templates/base/dot_claude/vault/knowledge/README.md +5 -0
- project_init/templates/base/dot_claude/vault/sessions/README.md +5 -0
- project_init/templates/base/dot_devcontainer/devcontainer.json.tmpl +17 -0
- project_init/templates/base/dot_devcontainer/post-create.sh.tmpl +31 -0
- project_init/templates/base/dot_env.example.tmpl +13 -0
- project_init/templates/base/dot_github/CODEOWNERS.tmpl +12 -0
- project_init/templates/base/dot_github/ISSUE_TEMPLATE/bug.yml +98 -0
- project_init/templates/base/dot_github/ISSUE_TEMPLATE/chore.yml +82 -0
- project_init/templates/base/dot_github/ISSUE_TEMPLATE/config.yml +5 -0
- project_init/templates/base/dot_github/ISSUE_TEMPLATE/docs.yml +84 -0
- project_init/templates/base/dot_github/ISSUE_TEMPLATE/feature.yml +87 -0
- project_init/templates/base/dot_github/ISSUE_TEMPLATE/test.yml +90 -0
- project_init/templates/base/dot_github/copilot-instructions.md.tmpl +25 -0
- project_init/templates/base/dot_github/hooks/commit-msg +52 -0
- project_init/templates/base/dot_github/hooks/pre-commit +16 -0
- project_init/templates/base/dot_github/hooks/pre-push +51 -0
- project_init/templates/base/dot_github/pull_request_template.md +22 -0
- project_init/templates/base/dot_github/workflows/board-automation.yml +232 -0
- project_init/templates/base/dot_github/workflows/ci.yml.tmpl +204 -0
- project_init/templates/base/dot_github/workflows/docs.yml.tmpl +98 -0
- project_init/templates/base/dot_github/workflows/issue-validation.yml +72 -0
- project_init/templates/base/dot_github/workflows/review-status.yml +48 -0
- project_init/templates/base/dot_github/workflows/validate-pr.yml +103 -0
- project_init/templates/base/dot_gitignore.tmpl +41 -0
- project_init/templates/base/dot_golangci.yml.tmpl +20 -0
- project_init/templates/base/dot_vscode/extensions.json.tmpl +10 -0
- project_init/templates/base/dot_vscode/settings.json.tmpl +8 -0
- project_init/templates/base/eslint.config.mjs.tmpl +29 -0
- project_init/templates/base/justfile.tmpl +95 -0
- project_init/templates/base/mise.toml.tmpl +20 -0
- project_init/templates/base/mkdocs.yml.tmpl +32 -0
- project_init/templates/base/renovate.json +14 -0
- project_init/templates/base/ruff.toml.tmpl +31 -0
- project_init/templates/base/typedoc.json.tmpl +14 -0
- project_init/templates/codex/dot_agents/skills/add_adr/SKILL.md +33 -0
- project_init/templates/codex/dot_agents/skills/add_command/SKILL.md +63 -0
- project_init/templates/codex/dot_agents/skills/add_hook/SKILL.md +112 -0
- project_init/templates/codex/dot_agents/skills/audit/SKILL.md +146 -0
- project_init/templates/codex/dot_agents/skills/create_issue/SKILL.md +59 -0
- project_init/templates/codex/dot_agents/skills/github_workflow/SKILL.md +80 -0
- project_init/templates/codex/dot_agents/skills/request_review/SKILL.md +19 -0
- project_init/templates/codex/dot_agents/skills/review/SKILL.md +17 -0
- project_init/templates/codex/dot_agents/skills/save_memory/SKILL.md +17 -0
- project_init/templates/codex/dot_agents/skills/session_summary/SKILL.md +35 -0
- project_init/templates/codex/dot_agents/skills/start_task/SKILL.md +48 -0
- project_init/templates/codex/dot_agents/skills/status/SKILL.md +15 -0
- project_init/templates/codex/dot_codex/hooks.json.tmpl +17 -0
- project_init/templates/fallback/dot_claude/hooks/github_command_guard.sh +11 -0
- project_init/templates/fallback/dot_claude/hooks/post_edit_lint.sh +58 -0
- project_init/templates/fallback/dot_claude/hooks/pre_commit_gate.sh +81 -0
- project_init/templates/fallback/dot_claude/hooks/prod_guard.py +140 -0
- project_init/templates/fallback/dot_claude/hooks/session_setup.sh +62 -0
- project_init/templates/fallback/dot_claude/hooks/workflow_state_reminder.sh +72 -0
- project_init/templates/fallback/dot_claude/skills/INDEX.md +28 -0
- project_init/templates/fallback/dot_claude/skills/add_adr/SKILL.md +33 -0
- project_init/templates/fallback/dot_claude/skills/add_command/SKILL.md +63 -0
- project_init/templates/fallback/dot_claude/skills/add_hook/SKILL.md +112 -0
- project_init/templates/fallback/dot_claude/skills/audit/SKILL.md +146 -0
- project_init/templates/fallback/dot_claude/skills/create_issue/SKILL.md +59 -0
- project_init/templates/fallback/dot_claude/skills/github_workflow/SKILL.md +80 -0
- project_init/templates/fallback/dot_claude/skills/request_review/SKILL.md +19 -0
- project_init/templates/fallback/dot_claude/skills/review/SKILL.md +17 -0
- project_init/templates/fallback/dot_claude/skills/save_memory/SKILL.md +17 -0
- project_init/templates/fallback/dot_claude/skills/session_summary/SKILL.md +35 -0
- project_init/templates/fallback/dot_claude/skills/start_task/SKILL.md +48 -0
- project_init/templates/fallback/dot_claude/skills/status/SKILL.md +15 -0
- project_init/templates/gemini/dot_agents/skills/add_adr/SKILL.md +33 -0
- project_init/templates/gemini/dot_agents/skills/add_command/SKILL.md +63 -0
- project_init/templates/gemini/dot_agents/skills/add_hook/SKILL.md +112 -0
- project_init/templates/gemini/dot_agents/skills/audit/SKILL.md +146 -0
- project_init/templates/gemini/dot_agents/skills/create_issue/SKILL.md +59 -0
- project_init/templates/gemini/dot_agents/skills/github_workflow/SKILL.md +80 -0
- project_init/templates/gemini/dot_agents/skills/request_review/SKILL.md +19 -0
- project_init/templates/gemini/dot_agents/skills/review/SKILL.md +17 -0
- project_init/templates/gemini/dot_agents/skills/save_memory/SKILL.md +17 -0
- project_init/templates/gemini/dot_agents/skills/session_summary/SKILL.md +35 -0
- project_init/templates/gemini/dot_agents/skills/start_task/SKILL.md +48 -0
- project_init/templates/gemini/dot_agents/skills/status/SKILL.md +15 -0
- project_init/templates/gemini/dot_claude/scripts/setup_gemini.sh.tmpl +16 -0
- project_init/templates/gemini/dot_gemini-extension/commands/add_adr.toml +5 -0
- project_init/templates/gemini/dot_gemini-extension/commands/add_command.toml +5 -0
- project_init/templates/gemini/dot_gemini-extension/commands/add_hook.toml +5 -0
- project_init/templates/gemini/dot_gemini-extension/commands/audit.toml +5 -0
- project_init/templates/gemini/dot_gemini-extension/commands/create_issue.toml +5 -0
- project_init/templates/gemini/dot_gemini-extension/commands/github_workflow.toml +5 -0
- project_init/templates/gemini/dot_gemini-extension/commands/request_review.toml +5 -0
- project_init/templates/gemini/dot_gemini-extension/commands/review.toml +5 -0
- project_init/templates/gemini/dot_gemini-extension/commands/save_memory.toml +5 -0
- project_init/templates/gemini/dot_gemini-extension/commands/session_summary.toml +5 -0
- project_init/templates/gemini/dot_gemini-extension/commands/start_task.toml +5 -0
- project_init/templates/gemini/dot_gemini-extension/commands/status.toml +5 -0
- project_init/templates/gemini/dot_gemini-extension/gemini-extension.json.tmpl +6 -0
- project_init/templates/gemini/dot_gemini-extension/hooks/hooks.json.tmpl +18 -0
- project_init/templates/graphify/dot_claude/docs/guides/using-graphify.md +37 -0
- project_init/templates/graphify/dot_claude/rules/graphify.md +18 -0
- project_init/templates/graphify/dot_claude/scripts/setup_graphify.sh +40 -0
- project_init/templates/obsidian/dot_claude/scripts/lint_memory.sh +115 -0
- project_init/templates/obsidian/dot_claude/vault/decisions/adr-000-project-setup.md.tmpl +22 -0
- project_init/templates/obsidian/dot_claude/vault/dot_obsidian/README.md +31 -0
- project_init/templates/obsidian/dot_claude/vault/dot_obsidian/app.json +6 -0
- project_init/templates/obsidian/dot_claude/vault/dot_obsidian/community-plugins.json +1 -0
- project_init/templates/obsidian/dot_claude/vault/dot_obsidian/core-plugins.json +1 -0
- project_init/templates/obsidian/dot_claude/vault/log.md +6 -0
- project_init/templates/obsidian/dot_claude/vault/templates/decision.md +16 -0
- project_init/templates/obsidian/dot_claude/vault/templates/design-note.md +14 -0
- project_init/templates/obsidian/dot_claude/vault/templates/knowledge-note.md +12 -0
- project_init/templates/obsidian/dot_claude/vault/templates/session-note.md +16 -0
- project_init/templates/presets/obsidian-graphify.toml +16 -0
- project_init/templates/presets/obsidian-only.toml +14 -0
- project_init/upgrade.py +569 -0
- project_init-0.3.0.dist-info/METADATA +342 -0
- project_init-0.3.0.dist-info/RECORD +173 -0
- project_init-0.3.0.dist-info/WHEEL +4 -0
- project_init-0.3.0.dist-info/entry_points.txt +2 -0
- project_init-0.3.0.dist-info/licenses/LICENSE +201 -0
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# Issue metadata
|
|
2
|
+
|
|
3
|
+
Issues carry planning metadata in two places.
|
|
4
|
+
|
|
5
|
+
## GitHub labels
|
|
6
|
+
|
|
7
|
+
Use labels for values that workflows and project boards can read.
|
|
8
|
+
|
|
9
|
+
- Type labels: `feature`, `bug`, `chore`, `documentation`, `test`
|
|
10
|
+
- Priority labels: `priority:high`, `priority:medium`, `priority:low`
|
|
11
|
+
- Size labels: `size:XS`, `size:S`, `size:M`, `size:L`, `size:XL`
|
|
12
|
+
- Area labels are repository-specific. Use existing labels only; do not invent new area labels from agent context.
|
|
13
|
+
|
|
14
|
+
`create_issue.sh` creates missing priority and size labels when the token has permission. If label creation fails, the issue is still created and the value remains in the markdown body.
|
|
15
|
+
|
|
16
|
+
## Markdown body
|
|
17
|
+
|
|
18
|
+
Use the markdown body for context GitHub does not model portably:
|
|
19
|
+
|
|
20
|
+
- references to issues, PRs, ADRs, docs, designs, logs, or external links
|
|
21
|
+
- dependencies, blocked-by, parent, and follow-up relationships
|
|
22
|
+
- acceptance criteria
|
|
23
|
+
- implementation notes and affected areas
|
|
24
|
+
- Definition of Ready
|
|
25
|
+
- Definition of Done
|
|
26
|
+
|
|
27
|
+
GitHub Projects fields are synced opportunistically by `board-automation.yml`. Missing fields or options are logged and skipped so issue creation does not fail in a new repository.
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# Secrets handling
|
|
2
|
+
|
|
3
|
+
How secrets flow through this project, and when to escalate beyond `.env`.
|
|
4
|
+
|
|
5
|
+
## The local pattern (scaffolded)
|
|
6
|
+
|
|
7
|
+
- `.env.example` documents every variable the project needs — committed,
|
|
8
|
+
values empty.
|
|
9
|
+
- `.env` holds your real local values — gitignored, never committed.
|
|
10
|
+
- Loading order: shell exports win over `.env`; tools load `.env`
|
|
11
|
+
explicitly (`uv run --env-file .env`, bun auto-load, or direnv).
|
|
12
|
+
- Enforcement: the pre-commit hook runs a gitleaks scan and CI re-scans
|
|
13
|
+
the full history (ADR-007). A leaked value that reaches a commit must be
|
|
14
|
+
**rotated**, not just deleted — assume it is compromised.
|
|
15
|
+
|
|
16
|
+
## When .env stops being enough
|
|
17
|
+
|
|
18
|
+
`.env` files do not scale past a single developer: no audit trail, no
|
|
19
|
+
rotation, manual sharing. Escalate to a secret manager when the team or
|
|
20
|
+
the secret count grows. Common paths, in rough order of adoption effort:
|
|
21
|
+
|
|
22
|
+
| Option | Shape | Fits when |
|
|
23
|
+
|---|---|---|
|
|
24
|
+
| [sops](https://github.com/getsops/sops) + age | encrypted files in the repo | small teams, GitOps workflows, no SaaS dependency |
|
|
25
|
+
| [1Password CLI](https://developer.1password.com/docs/cli/) (`op run`) | secrets injected from a shared vault | team already uses 1Password |
|
|
26
|
+
| [Doppler](https://docs.doppler.com/) | hosted secret manager with env sync | many environments/services, need audit + rotation |
|
|
27
|
+
| Cloud-native (AWS/GCP/Azure secret managers) | IAM-scoped, per-service | production workloads already on that cloud |
|
|
28
|
+
|
|
29
|
+
The scaffolder deliberately installs **none** of these — the choice is
|
|
30
|
+
org-specific. Whichever you pick, keep the contract: `.env.example` stays
|
|
31
|
+
the documentation of record for *what* variables exist; the manager owns
|
|
32
|
+
*values*.
|
|
33
|
+
|
|
34
|
+
## Credential separation (the actual prod-safety boundary)
|
|
35
|
+
|
|
36
|
+
The `prod_guard` hook flags destructive commands (`terraform destroy`,
|
|
37
|
+
`DROP DATABASE`, cloud deletes — see the `prod_guard` hook), but a
|
|
38
|
+
deny-list is a guardrail, not a guarantee (ADR-012). The guarantee is that
|
|
39
|
+
**agent sessions never hold production credentials**:
|
|
40
|
+
|
|
41
|
+
- `.env` files used in agent sessions contain dev/staging values only.
|
|
42
|
+
- Production credentials live in the secret manager and are injected
|
|
43
|
+
exclusively into review-gated CI deploy jobs — never into a local shell
|
|
44
|
+
an agent runs in.
|
|
45
|
+
- A guard cannot delete what the session cannot reach.
|
|
46
|
+
|
|
47
|
+
## CI secrets
|
|
48
|
+
|
|
49
|
+
Use the platform's mechanism (GitHub Actions secrets/environments), never
|
|
50
|
+
files in the repo. Scope them per-environment and rotate on offboarding.
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# Using Memory
|
|
2
|
+
|
|
3
|
+
Two complementary memory systems work together in this project.
|
|
4
|
+
|
|
5
|
+
## `.claude/memory/` — Agent recall
|
|
6
|
+
|
|
7
|
+
Small, structured facts that agents read at the start of each session.
|
|
8
|
+
|
|
9
|
+
- **Index:** `memory/MEMORY.md` — one line per memory file, loaded every session
|
|
10
|
+
- **Files:** `memory/<topic>.md` with frontmatter (`name`, `description`, `type`)
|
|
11
|
+
- **Types:** `user`, `feedback`, `project`, `reference`
|
|
12
|
+
- **When to write:** Learning something reusable that would save time next session
|
|
13
|
+
|
|
14
|
+
Quick-save via slash command:
|
|
15
|
+
```
|
|
16
|
+
/save_memory <fact>
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## `.claude/vault/` — Human workspace
|
|
20
|
+
|
|
21
|
+
Exploratory notes, session logs, design sketches. Managed in Obsidian.
|
|
22
|
+
|
|
23
|
+
- **Sessions:** `vault/sessions/YYYY-MM-DD.md` — written by the `/session_summary` skill
|
|
24
|
+
- **Decisions:** `vault/decisions/` — working notes before a decision solidifies
|
|
25
|
+
- **Knowledge:** `vault/knowledge/` — concepts, research, architecture explorations
|
|
26
|
+
|
|
27
|
+
## The one-way flow
|
|
28
|
+
|
|
29
|
+
When an exploratory vault note becomes a real decision:
|
|
30
|
+
|
|
31
|
+
1. Create `docs/adr/adr-NNN-<topic>.md` (see existing ADRs for format)
|
|
32
|
+
2. Update `docs/README.md` to link the new ADR
|
|
33
|
+
3. Commit and push
|
|
34
|
+
4. Delete or summarise the vault note (avoid duplication)
|
|
35
|
+
|
|
36
|
+
Agents read `docs/adr/` — not vault — for authoritative decisions.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# `.claude/hooks/`
|
|
2
|
+
|
|
3
|
+
Session hooks — deterministic bash or python scripts. The `settings.json` at `.claude/settings.json` wires them to Claude Code events (SessionStart, SessionEnd, PreToolUse, etc.).
|
|
4
|
+
|
|
5
|
+
Keep hooks fast, idempotent, and non-interactive.
|
|
6
|
+
|
|
7
|
+
These hooks are fast-feedback UX for Claude Code sessions — they are not the
|
|
8
|
+
security boundary. Secret scanning (gitleaks) and lifecycle gating run as git
|
|
9
|
+
hooks installed by `.claude/scripts/install_hooks.sh`, with CI as the
|
|
10
|
+
backstop, so they bind every agent and every human (ADR-007).
|
|
11
|
+
|
|
12
|
+
## Hook Executability Convention
|
|
13
|
+
|
|
14
|
+
- **Shell hooks** (`.sh` files): Must have the executable bit (`+x`). They run directly via `bash path/to/hook.sh`.
|
|
15
|
+
- **Python hooks** (`.py` files): Do NOT need the executable bit. They are invoked via `python3 path/to/hook.py`.
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
{{#if multi_agent}}#!/usr/bin/env python3
|
|
2
|
+
"""Adapt non-Claude agent hook payloads for the shared dag_workflow guard.
|
|
3
|
+
|
|
4
|
+
Codex (PreToolUse via .codex/hooks.json) and Gemini CLI (BeforeTool via the
|
|
5
|
+
project extension) reuse the same COMMAND_RULES enforcement Claude Code gets
|
|
6
|
+
from github_command_guard.sh. Payloads differ slightly per agent, so this
|
|
7
|
+
shim extracts the shell command, feeds a Claude-shaped payload into
|
|
8
|
+
dag_workflow.py guard, and translates the verdict to the caller's dialect:
|
|
9
|
+
|
|
10
|
+
codex -> {"decision": "block", ...} (Codex accepts Claude's shape)
|
|
11
|
+
gemini -> {"decision": "deny", ...}
|
|
12
|
+
|
|
13
|
+
Fail-open by design: on any parse error the command proceeds — git hooks
|
|
14
|
+
and CI remain the real enforcement boundary (ADR-007).
|
|
15
|
+
|
|
16
|
+
Usage (wired by the scaffolded hook configs): agent_guard_adapter.py <dialect>
|
|
17
|
+
"""
|
|
18
|
+
|
|
19
|
+
import json
|
|
20
|
+
import subprocess
|
|
21
|
+
import sys
|
|
22
|
+
from pathlib import Path
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def _extract_command(payload: dict) -> str:
|
|
26
|
+
tool_input = payload.get("tool_input") or payload.get("toolInput") or {}
|
|
27
|
+
command = tool_input.get("command") or tool_input.get("cmd") or ""
|
|
28
|
+
if isinstance(command, list):
|
|
29
|
+
command = " ".join(str(part) for part in command)
|
|
30
|
+
return str(command)
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def main() -> int:
|
|
34
|
+
dialect = sys.argv[1] if len(sys.argv) > 1 else "codex"
|
|
35
|
+
try:
|
|
36
|
+
payload = json.loads(sys.stdin.read() or "{}")
|
|
37
|
+
except json.JSONDecodeError:
|
|
38
|
+
return 0
|
|
39
|
+
command = _extract_command(payload)
|
|
40
|
+
if not command:
|
|
41
|
+
return 0
|
|
42
|
+
|
|
43
|
+
guard = Path(__file__).with_name("dag_workflow.py")
|
|
44
|
+
proc = subprocess.run(
|
|
45
|
+
[sys.executable, str(guard), "guard"],
|
|
46
|
+
input=json.dumps({"tool_input": {"command": command}}),
|
|
47
|
+
capture_output=True,
|
|
48
|
+
text=True,
|
|
49
|
+
check=False,
|
|
50
|
+
)
|
|
51
|
+
try:
|
|
52
|
+
verdict = json.loads(proc.stdout.strip() or "null")
|
|
53
|
+
except json.JSONDecodeError:
|
|
54
|
+
return 0
|
|
55
|
+
if isinstance(verdict, dict) and verdict.get("decision") == "block":
|
|
56
|
+
if dialect == "gemini":
|
|
57
|
+
verdict = {"decision": "deny", "reason": verdict.get("reason", "")}
|
|
58
|
+
sys.stdout.write(json.dumps(verdict))
|
|
59
|
+
return 0
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
if __name__ == "__main__":
|
|
63
|
+
sys.exit(main())
|
|
64
|
+
{{/if multi_agent}}
|