planguard 0.3.0__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.
@@ -0,0 +1,505 @@
1
+ Metadata-Version: 2.3
2
+ Name: planguard
3
+ Version: 0.3.0
4
+ Summary: Make AI-assisted development safer, auditable, and release-ready without breaking normal CLI and git workflows
5
+ License: MIT
6
+ Keywords: ai,agents,cli,developer-tools,governance,pypi
7
+ Author: Arkimetrix Analytics Ltd.
8
+ Requires-Python: >=3.9,<4.0
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: Programming Language :: Python :: 3.9
11
+ Classifier: Programming Language :: Python :: 3.10
12
+ Classifier: Programming Language :: Python :: 3.11
13
+ Classifier: Programming Language :: Python :: 3.12
14
+ Classifier: Programming Language :: Python :: 3.13
15
+ Requires-Dist: networkx (>=3.0)
16
+ Requires-Dist: pyyaml (>=6.0.3,<7.0.0)
17
+ Requires-Dist: rich (>=13)
18
+ Requires-Dist: typer (>=0.9)
19
+ Project-URL: Documentation, https://github.com/DBArkimetrix/planguard#readme
20
+ Project-URL: Homepage, https://github.com/DBArkimetrix/planguard
21
+ Project-URL: Issues, https://github.com/DBArkimetrix/planguard/issues
22
+ Project-URL: Repository, https://github.com/DBArkimetrix/planguard
23
+ Description-Content-Type: text/markdown
24
+
25
+ # PlanGuard
26
+
27
+ Control how AI coding agents make changes in your project.
28
+
29
+ PlanGuard makes AI-assisted development safer without turning it into paperwork. It records intent up front, then enforces the controls that matter against the real git-backed working state: scope drift, protected areas, verification, and an auditable lifecycle log.
30
+
31
+ Works with any language or stack. Runs on Linux, macOS, and Windows.
32
+
33
+ ## Install
34
+
35
+ ### For any project (recommended)
36
+
37
+ Use [pipx](https://pipx.pypa.io/) to install the `planguard` command globally without touching your project's dependencies:
38
+
39
+ ```bash
40
+ pipx install planguard
41
+ ```
42
+
43
+ This works whether your project is Python, JavaScript, Rust, Go, Java, or anything else. The `planguard` command is available system-wide.
44
+
45
+ ### For Python projects
46
+
47
+ Add it as a dev dependency:
48
+
49
+ ```bash
50
+ pip install planguard
51
+ ```
52
+
53
+ Or with Poetry:
54
+
55
+ ```bash
56
+ poetry add --group dev planguard
57
+ ```
58
+
59
+ ### Windows
60
+
61
+ The same commands work in PowerShell or Windows Terminal:
62
+
63
+ ```powershell
64
+ pipx install planguard
65
+ ```
66
+
67
+ Or with pip:
68
+
69
+ ```powershell
70
+ pip install planguard
71
+ ```
72
+
73
+ Requires Python 3.9 or newer. If you don't have Python, install it from [python.org](https://www.python.org/downloads/) or via `winget install Python.Python.3.12`.
74
+
75
+ ### Verify
76
+
77
+ ```bash
78
+ planguard --help
79
+ planguard --version
80
+ ```
81
+
82
+ ## Adding to an Existing Project
83
+
84
+ ### Step 1: Navigate to your project
85
+
86
+ ```bash
87
+ cd /path/to/your-project
88
+ ```
89
+
90
+ ### Step 2: Run init
91
+
92
+ ```bash
93
+ planguard init
94
+ ```
95
+
96
+ The wizard:
97
+ 1. **Scans your project** — detects language, frameworks, source/test directories, build/test/lint commands, git status, CI/CD config
98
+ 2. **Shows what it found** and asks you to confirm
99
+ 3. **Creates three things:**
100
+ - `docs/` — where plans will live
101
+ - `.planguard/` — project context that agents read before working
102
+ - `AGENTS.md` — workflow rules (appended if the file already exists)
103
+
104
+ **What gets added to your repo:**
105
+
106
+ ```
107
+ your-project/
108
+ AGENTS.md <-- new, or appended to
109
+ .planguard/
110
+ project.yaml <-- what this system does, detected stack
111
+ conventions.md <-- coding patterns and style rules
112
+ boundaries.md <-- files/dirs agents must never modify
113
+ glossary.md <-- domain terms mapped to code entities
114
+ policies.yaml <-- governance rules (pattern-based checks)
115
+ docs/
116
+ planning/
117
+ active_plans.yaml <-- plan registry
118
+ ... your existing files unchanged
119
+ ```
120
+
121
+ The `.planguard/` context files are generated with your detected stack pre-filled, but you should review and complete them. The boundaries and conventions files are especially important — they tell agents what's off-limits and what patterns to follow.
122
+
123
+ If AGENTS.md already exists, PlanGuard appends its section (marked with an HTML comment for idempotent re-runs). Your existing rules stay intact.
124
+
125
+ ### Step 3: Commit the framework files
126
+
127
+ ```bash
128
+ git add AGENTS.md docs/
129
+ git commit -m "Add PlanGuard"
130
+ ```
131
+
132
+ Now every AI agent that reads `AGENTS.md` (Claude, Codex, Copilot Workspace, etc.) will see the workflow rules before it starts coding.
133
+
134
+ ## Starting a New Project
135
+
136
+ ```bash
137
+ mkdir my-new-project && cd my-new-project
138
+ git init
139
+ planguard init
140
+ ```
141
+
142
+ The wizard detects an empty project and asks what language/stack you plan to use. It creates the same `docs/` and `AGENTS.md` structure.
143
+
144
+ ## Creating a Plan
145
+
146
+ ```bash
147
+ planguard plan
148
+ ```
149
+
150
+ The wizard walks you through:
151
+
152
+ | Question | What it's for |
153
+ |----------|--------------|
154
+ | What is the objective? | A plain-language description of what you want to accomplish |
155
+ | Short name for this plan | Creates a folder like `docs/your_plan_name/` |
156
+ | Which directories are in scope? | Restricts what the agent is allowed to modify (auto-detected from your project) |
157
+ | Priority | low, medium, high, or critical |
158
+ | Who owns this plan? | Person or team responsible |
159
+ | How will you know this is done? | Observable conditions that must be true before the work is complete |
160
+ | Commands to verify correctness | Test/lint commands to run (auto-detected from your project) |
161
+ | How would you undo this? | Rollback strategy if things go wrong |
162
+ | Known risks? | Optional: describe risks and how to mitigate them |
163
+
164
+ The wizard creates two files:
165
+
166
+ - `docs/<plan_name>/plan.yaml` — objective, scope, phases, risks, dependencies, test strategy
167
+ - `docs/<plan_name>/status.yaml` — progress tracking and handoff notes
168
+
169
+ **Agents and scripts** can skip the wizard by passing flags:
170
+
171
+ ```bash
172
+ planguard plan "your plan name" --objective "Describe the goal" --scope "src/api, tests" --priority high --no-wizard
173
+ ```
174
+
175
+ ## Running Checks
176
+
177
+ ```bash
178
+ planguard check
179
+ ```
180
+
181
+ Runs everything at once and prints a pass/fail report:
182
+
183
+ ```
184
+ Plan: your_plan_name
185
+ [OK] Structure valid
186
+ [OK] Risk score: 2 (threshold: 6)
187
+ [OK] Dependency graph is acyclic
188
+ Status: draft
189
+
190
+ Cross-plan checks:
191
+ No collisions between active plans
192
+
193
+ All checks passed
194
+ ```
195
+
196
+ What it checks:
197
+ - **Validation** — plan.yaml has all required sections
198
+ - **Risk score** — severity-weighted total vs threshold
199
+ - **Dependency graph** — no circular dependencies
200
+ - **Collisions** — no two active plans declare overlapping paths
201
+ - **Scope drift** — active-plan changes after activation must stay inside scope
202
+ - **Policies and boundaries** — protected areas and content rules can be enforced against real changed files
203
+
204
+ Check a specific plan:
205
+
206
+ ```bash
207
+ planguard check your_plan_name
208
+ ```
209
+
210
+ ## Activating and Implementing
211
+
212
+ When checks pass:
213
+
214
+ ```bash
215
+ planguard activate your_plan_name
216
+ ```
217
+
218
+ This re-runs checks, then marks the plan as active. The agent can now implement.
219
+
220
+ After implementation:
221
+
222
+ ```bash
223
+ planguard verify your_plan_name
224
+ planguard complete your_plan_name
225
+ ```
226
+
227
+ `verify` records the exact git-backed snapshot that passed. `complete` only succeeds if the current state still matches that verified snapshot.
228
+
229
+ ## PyPI Distribution
230
+
231
+ PlanGuard is packaged for PyPI through the metadata in `pyproject.toml` and the console script entry point:
232
+
233
+ ```bash
234
+ poetry build
235
+ ```
236
+
237
+ This produces both an sdist and a wheel in `dist/`. Before publishing, validate the artifacts:
238
+
239
+ ```bash
240
+ python -m twine check dist/*
241
+ ```
242
+
243
+ ## Workflow
244
+
245
+ ```
246
+ planguard init --> planguard plan --> planguard check --> planguard activate --> implement --> planguard check --> planguard verify --> planguard complete
247
+ ```
248
+
249
+ | Step | What happens |
250
+ |------|-------------|
251
+ | `planguard init` | Detects project, creates docs/, .planguard/ context, and AGENTS.md |
252
+ | `planguard plan` | Wizard creates plan.yaml and status.yaml |
253
+ | `planguard check` | Validates structure, dependencies, declared scope, and for active plans enforces real post-activation changes against scope/policies/boundaries |
254
+ | `planguard activate` | Runs checks, records a baseline git snapshot, marks plan as ready to implement |
255
+ | implement | The agent (or you) writes code within the plan's scope |
256
+ | `planguard verify` | Runs verification commands and stores the exact snapshot that passed |
257
+ | `planguard complete` | Marks plan as done only if the verified snapshot still matches the current state |
258
+
259
+ ## Plan Lifecycle
260
+
261
+ Every plan has a status: **draft -> active -> completed -> archived**
262
+
263
+ | Status | Meaning |
264
+ |--------|---------|
265
+ | `draft` | Plan exists but is not yet approved for implementation |
266
+ | `active` | Checks passed, implementation is allowed |
267
+ | `completed` | Work is done |
268
+ | `archived` | Removed from all active consideration |
269
+
270
+ Only `draft` and `active` plans appear in collision checks and scheduling.
271
+
272
+ ## All Commands
273
+
274
+ ```bash
275
+ planguard init # Set up PlanGuard in a project (wizard)
276
+ planguard plan # Create a plan (wizard)
277
+ planguard check # Run all checks (structure, risk, collisions, scope/policy enforcement)
278
+ planguard check <name> # Check a specific plan
279
+ planguard activate <name> # Mark plan as ready to implement
280
+ planguard verify <name> # Run verification commands from the plan
281
+ planguard complete <name> # Mark plan as done
282
+ planguard archive <name> # Archive a plan
283
+ planguard status # Table of all plans with status, priority, owner
284
+ planguard list # List active plans
285
+ planguard list --all # Include completed and archived
286
+ planguard log # Show session log (audit trail)
287
+ planguard log <name> # Show log for a specific plan
288
+ planguard graph <name> # Show dependency graph for a plan
289
+ planguard validate # Validate plan structure (prefer 'planguard check')
290
+ ```
291
+
292
+ ## How Multiple Plans Work
293
+
294
+ When several agents or developers work in the same repo:
295
+
296
+ 1. Each piece of work gets its own plan (`planguard plan`)
297
+ 2. Each plan declares which directories it will modify (the scope)
298
+ 3. `planguard check` detects when two active plans have overlapping or nested scope
299
+ 4. Collisions must be resolved (change scope or sequence the work) before both plans can be active
300
+ 5. `planguard status` shows a table of all plans and their state
301
+ 6. Completed plans stop interfering with active work
302
+
303
+ ## Plan Files
304
+
305
+ Each plan is two files:
306
+
307
+ **plan.yaml** — everything about the plan:
308
+
309
+ ```yaml
310
+ plan:
311
+ name: your_plan_name
312
+ status: draft
313
+ created: '2025-03-23'
314
+ owner: your-team
315
+ priority: high
316
+
317
+ objective: Describe what you are trying to accomplish
318
+
319
+ scope:
320
+ included:
321
+ - src/your_module
322
+ - tests/your_module
323
+ excluded:
324
+ - unrelated modules
325
+
326
+ phases:
327
+ - name: analysis
328
+ tasks:
329
+ - Analyze current implementation
330
+ - Identify dependencies
331
+ - name: implementation
332
+ tasks:
333
+ - Implement changes in safe slices
334
+ - name: validation
335
+ tasks:
336
+ - Run regression tests
337
+
338
+ risks:
339
+ - id: RISK-001
340
+ description: May break existing functionality
341
+ severity: high
342
+ mitigation: Add regression tests before making changes
343
+
344
+ done_when:
345
+ - All tests pass
346
+ - No regressions in existing functionality
347
+
348
+ verify_commands:
349
+ - npm test
350
+ - npm run lint
351
+
352
+ rollback_strategy: git revert to prior commit
353
+
354
+ dependencies:
355
+ - id: analysis
356
+ depends_on: []
357
+ - id: implementation
358
+ depends_on: [analysis]
359
+ - id: validation
360
+ depends_on: [implementation]
361
+
362
+ test_strategy:
363
+ - area: Existing functionality in scope paths
364
+ validation: Confirm no unintended behaviour changes
365
+ ```
366
+
367
+ **status.yaml** — progress tracking:
368
+
369
+ ```yaml
370
+ status:
371
+ phase: planning
372
+ progress_percent: 0
373
+
374
+ activation:
375
+ activated_at: ''
376
+ git_branch: ''
377
+ git_head: ''
378
+ baseline_changed_files: []
379
+ baseline_fingerprints: {}
380
+
381
+ verification:
382
+ passed: false
383
+ last_run: ''
384
+ git_branch: ''
385
+ git_head: ''
386
+ changed_files: []
387
+ fingerprints: {}
388
+ commands: []
389
+
390
+ completed_steps: []
391
+ remaining_steps:
392
+ - Review and refine plan
393
+ - Run checks (planguard check)
394
+ - Activate plan (planguard activate)
395
+ - Implement
396
+ - Verify (planguard verify)
397
+ - Complete plan (planguard complete)
398
+
399
+ blockers: []
400
+
401
+ handoff:
402
+ summary: ''
403
+ notes: []
404
+ ```
405
+
406
+ ## Verification
407
+
408
+ After implementation, run the plan's verification commands:
409
+
410
+ ```bash
411
+ planguard verify your_plan_name
412
+ ```
413
+
414
+ This runs every command listed in `verify_commands` from plan.yaml and reports pass/fail. If the plan omitted them, PlanGuard falls back to detected project test/lint commands when it can:
415
+
416
+ ```
417
+ Running: pytest
418
+ [OK] pytest
419
+ Running: npm run lint
420
+ [OK] npm run lint
421
+
422
+ Verification passed
423
+ ```
424
+
425
+ Verification must pass before you mark the plan complete.
426
+
427
+ ## Policies and Boundaries
428
+
429
+ `.planguard/policies.yaml` defines rules that `planguard check` enforces. Scope-only rules can gate sensitive paths before implementation; pattern rules are evaluated against actual changed files after activation:
430
+
431
+ ```yaml
432
+ rules:
433
+ - name: no_raw_sql
434
+ description: "Do not use raw SQL queries"
435
+ pattern: "execute.*SELECT|INSERT|UPDATE|DELETE"
436
+ scope: ["src/**/*.py"]
437
+ action: block
438
+
439
+ - name: migration_requires_approval
440
+ description: "Database migrations need human approval"
441
+ scope: ["migrations/**"]
442
+ action: require_approval
443
+ risk: high
444
+ ```
445
+
446
+ `.planguard/boundaries.md` defines files and directories that agents must never modify. If a plan's scope overlaps with a boundary, `planguard check` blocks it.
447
+
448
+ ## Session Log
449
+
450
+ Every lifecycle event is logged to `.planguard/log.jsonl`:
451
+
452
+ ```bash
453
+ planguard log # Show all events
454
+ planguard log your_plan_name # Filter by plan
455
+ ```
456
+
457
+ Output:
458
+
459
+ ```
460
+ 2025-03-23 14:02 plan_created [your_plan_name] — Describe the goal
461
+ 2025-03-23 14:05 plan_activated [your_plan_name]
462
+ 2025-03-23 15:30 verification [your_plan_name] passed
463
+ 2025-03-23 15:31 plan_completed [your_plan_name]
464
+ ```
465
+
466
+ This is your audit trail — what the agent did, when, whether it worked, and which git state it was operating against.
467
+
468
+ ## What AGENTS.md Does
469
+
470
+ `AGENTS.md` is a convention that AI coding agents read before they start working. It tells them:
471
+
472
+ - Do not write code without a plan
473
+ - Run checks before implementing
474
+ - Stay within the plan's declared scope
475
+ - Verify before completing
476
+
477
+ The `planguard init` command generates this file. You can customise it for your team's specific rules. Any AI agent that respects project-root instruction files (Claude, Codex, Copilot, etc.) will follow it.
478
+
479
+ ## Compatibility with Agent Cookbooks
480
+
481
+ PlanGuard incorporates best practices from the [OpenAI Codex cookbook](https://developers.openai.com/codex/learn/best-practices) and [Claude Code best practices](https://code.claude.com/docs/en/best-practices):
482
+
483
+ | Practice | How PlanGuard implements it |
484
+ |----------|-------------------------------|
485
+ | Include build/test/lint commands in agent instructions | `planguard init` detects your stack and writes commands into AGENTS.md |
486
+ | Define observable "done when" criteria | The plan wizard asks "How will you know this is done?" |
487
+ | Include verification commands | The wizard asks for commands to verify correctness |
488
+ | Explore before editing | AGENTS.md best practices section includes this rule |
489
+ | Validation-gated progression | `planguard activate` runs checks before allowing implementation |
490
+ | Scope changes to declared paths | plan.yaml declares included/excluded paths |
491
+ | Keep a written record of risks and decisions | plan.yaml captures risks, mitigation, and test strategy |
492
+ | Write or update tests for every change | Encoded in AGENTS.md best practices and plan test_strategy |
493
+
494
+ PlanGuard works with any agent that reads AGENTS.md (Codex, Claude, Cursor, Copilot, etc.). If your project also uses CLAUDE.md, PlanGuard detects it and does not interfere — AGENTS.md and CLAUDE.md serve complementary roles.
495
+
496
+ ## Requirements
497
+
498
+ - Python 3.9 or newer
499
+ - Works on Linux, macOS, and Windows
500
+ - No system dependencies beyond Python
501
+
502
+ ## License
503
+
504
+ MIT
505
+