guardian-framework 0.1.0
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.
- package/LICENSE +21 -0
- package/README.md +463 -0
- package/dist/cli.js +12958 -0
- package/dist/exports.js +12765 -0
- package/package.json +61 -0
- package/templates/languages/go-patterns.md +411 -0
- package/templates/languages/java-patterns.md +545 -0
- package/templates/languages/python-patterns.md +312 -0
- package/templates/languages/rust-patterns.md +232 -0
- package/templates/languages/typescript-patterns.md +313 -0
- package/templates/pi/INDEX.md +437 -0
- package/templates/pi/agent/AGENTS.md +166 -0
- package/templates/pi/agents/architecture-coordinator.md +40 -0
- package/templates/pi/agents/architecture-validator.md +36 -0
- package/templates/pi/agents/bootstrap-implementer.md +37 -0
- package/templates/pi/agents/issue-factory.md +31 -0
- package/templates/pi/agents/operations-validator.md +32 -0
- package/templates/pi/agents/security-validator.md +33 -0
- package/templates/pi/architecture/CHANGELOG.md +78 -0
- package/templates/pi/architecture/decisions/ADR-template.md +76 -0
- package/templates/pi/architecture/diagrams/system-overview.md +159 -0
- package/templates/pi/architecture/modules/module-template.md +152 -0
- package/templates/pi/context/checklists.md +91 -0
- package/templates/pi/context/domain-workflow.md +180 -0
- package/templates/pi/context/output-formats.md +135 -0
- package/templates/pi/context/patterns-base.md +47 -0
- package/templates/pi/context/patterns.md +38 -0
- package/templates/pi/context/project.md +88 -0
- package/templates/pi/domain/exploration.md +93 -0
- package/templates/pi/domain/ubiquitous-language.md +24 -0
- package/templates/pi/extensions/architect-lib/generators.ts +528 -0
- package/templates/pi/extensions/architect-lib/helpers.ts +344 -0
- package/templates/pi/extensions/architect-lib/types.ts +117 -0
- package/templates/pi/extensions/architect.ts +1425 -0
- package/templates/pi/extensions/ask-user-question.ts +579 -0
- package/templates/pi/extensions/bash-guard.ts +556 -0
- package/templates/pi/extensions/config-reload.ts +115 -0
- package/templates/pi/extensions/coordinator.ts +304 -0
- package/templates/pi/extensions/curator.ts +543 -0
- package/templates/pi/extensions/domain-explorer.ts +990 -0
- package/templates/pi/extensions/filechanges.ts +656 -0
- package/templates/pi/extensions/goal-loop.ts +717 -0
- package/templates/pi/extensions/hooks.ts +452 -0
- package/templates/pi/extensions/kanban.ts +547 -0
- package/templates/pi/extensions/pipeline.ts +1246 -0
- package/templates/pi/extensions/plan-mode.ts +209 -0
- package/templates/pi/extensions/project-scaffolder.ts +284 -0
- package/templates/pi/extensions/read-only-mode.ts +192 -0
- package/templates/pi/extensions/redaction.ts +128 -0
- package/templates/pi/extensions/session-persistence.ts +174 -0
- package/templates/pi/extensions/slash-commands.ts +229 -0
- package/templates/pi/extensions/snippets.ts +201 -0
- package/templates/pi/extensions/validation-runner.ts +100 -0
- package/templates/pi/github/agents/architecture-coordinator.agent.md +27 -0
- package/templates/pi/github/agents/architecture-validator.agent.md +20 -0
- package/templates/pi/github/agents/bootstrap-implementer.agent.md +20 -0
- package/templates/pi/github/agents/epic-planner.agent.md +70 -0
- package/templates/pi/github/agents/issue-factory.agent.md +20 -0
- package/templates/pi/github/agents/operations-validator.agent.md +20 -0
- package/templates/pi/github/agents/security-validator.agent.md +20 -0
- package/templates/pi/github/copilot/settings.json +16 -0
- package/templates/pi/github/copilot-instructions.md +155 -0
- package/templates/pi/github/instructions/architecture.instructions.md +71 -0
- package/templates/pi/github/instructions/validation.instructions.md +69 -0
- package/templates/pi/github/workflows/01-planning-workflow.md +75 -0
- package/templates/pi/github/workflows/02-issue-generation-workflow.md +69 -0
- package/templates/pi/github/workflows/03-implementation-workflow.md +80 -0
- package/templates/pi/github/workflows/04-validation-workflow.md +68 -0
- package/templates/pi/preflight_report.json +99 -0
- package/templates/pi/prompts/blueprint-update.md +262 -0
- package/templates/pi/prompts/blueprint-validate.md +218 -0
- package/templates/pi/prompts/bug-fix.md +50 -0
- package/templates/pi/prompts/ci-blueprint.md +131 -0
- package/templates/pi/prompts/context-refresh.md +258 -0
- package/templates/pi/prompts/epic-plan.md +356 -0
- package/templates/pi/prompts/epic-template.md +186 -0
- package/templates/pi/prompts/feature-development.md +131 -0
- package/templates/pi/prompts/git-issues.md +243 -0
- package/templates/pi/prompts/hotfix.md +71 -0
- package/templates/pi/prompts/issue-closeout.md +342 -0
- package/templates/pi/prompts/issue-draft.md +218 -0
- package/templates/pi/prompts/issue-implementation-series.md +173 -0
- package/templates/pi/prompts/issue-merge.md +372 -0
- package/templates/pi/prompts/issue-template-set.md +392 -0
- package/templates/pi/prompts/issue-template.md +207 -0
- package/templates/pi/prompts/pattern-extract.md +269 -0
- package/templates/pi/prompts/plan-to-issues.md +430 -0
- package/templates/pi/prompts/refactoring.md +82 -0
- package/templates/pi/prompts/scope-analyzer.md +254 -0
- package/templates/pi/prompts/sync-check.md +230 -0
- package/templates/pi/scripts/categorize-issues.sh +171 -0
- package/templates/pi/scripts/ci/check_architecture_conformance.sh +748 -0
- package/templates/pi/scripts/ci/check_planning_packet.py +228 -0
- package/templates/pi/scripts/ci/run_hardening_stages.sh +264 -0
- package/templates/pi/scripts/ci/run_preflight.sh +649 -0
- package/templates/pi/scripts/ci/run_stage.sh +193 -0
- package/templates/pi/scripts/ci/stage_docs_policy.sh +82 -0
- package/templates/pi/scripts/ci/stage_integration.sh +3 -0
- package/templates/pi/scripts/ci/stage_lint.sh +130 -0
- package/templates/pi/scripts/ci/stage_migration_verify.sh +3 -0
- package/templates/pi/scripts/ci/stage_package_build.sh +3 -0
- package/templates/pi/scripts/ci/stage_release_readiness.sh +3 -0
- package/templates/pi/scripts/ci/stage_remaining.sh +242 -0
- package/templates/pi/scripts/ci/stage_security.sh +3 -0
- package/templates/pi/scripts/ci/stage_static_analysis.sh +114 -0
- package/templates/pi/scripts/ci/stage_unit.sh +119 -0
- package/templates/pi/scripts/ci/validate_agent_output.py +181 -0
- package/templates/pi/scripts/ci/validate_agent_output.sh +243 -0
- package/templates/pi/scripts/create-feature-branch.sh +136 -0
- package/templates/pi/scripts/create-mr.sh +117 -0
- package/templates/pi/scripts/fetch-issues.sh +131 -0
- package/templates/pi/scripts/generate-architecture.sh +161 -0
- package/templates/pi/scripts/git/close-epic.sh +69 -0
- package/templates/pi/scripts/git/close-issue.sh +35 -0
- package/templates/pi/scripts/git/create-tracking-issue.sh +174 -0
- package/templates/pi/scripts/git/link-issue-to-epic.sh +51 -0
- package/templates/pi/scripts/git/update-tracking-issue.sh +66 -0
- package/templates/pi/scripts/languages/go/validate-architecture.sh +139 -0
- package/templates/pi/scripts/languages/go/validate-canonical.sh +129 -0
- package/templates/pi/scripts/languages/go/validate-ci.sh +132 -0
- package/templates/pi/scripts/languages/go/validate-integration.sh +156 -0
- package/templates/pi/scripts/languages/go/validate-operations.sh +146 -0
- package/templates/pi/scripts/languages/go/validate-security.sh +135 -0
- package/templates/pi/scripts/languages/go/validate-tests.sh +125 -0
- package/templates/pi/scripts/languages/java/validate-annotations.sh +185 -0
- package/templates/pi/scripts/languages/java/validate-architecture.sh +159 -0
- package/templates/pi/scripts/languages/java/validate-canonical.sh +114 -0
- package/templates/pi/scripts/languages/java/validate-ci.sh +269 -0
- package/templates/pi/scripts/languages/java/validate-integration.sh +149 -0
- package/templates/pi/scripts/languages/java/validate-operations.sh +142 -0
- package/templates/pi/scripts/languages/java/validate-security.sh +174 -0
- package/templates/pi/scripts/languages/java/validate-spring-architecture.sh +227 -0
- package/templates/pi/scripts/languages/java/validate-tests.sh +159 -0
- package/templates/pi/scripts/languages/python/validate-architecture.sh +99 -0
- package/templates/pi/scripts/languages/python/validate-canonical.sh +124 -0
- package/templates/pi/scripts/languages/python/validate-ci.sh +130 -0
- package/templates/pi/scripts/languages/python/validate-integration.sh +119 -0
- package/templates/pi/scripts/languages/python/validate-operations.sh +107 -0
- package/templates/pi/scripts/languages/python/validate-security.sh +68 -0
- package/templates/pi/scripts/languages/python/validate-tests.sh +102 -0
- package/templates/pi/scripts/languages/rust/validate-architecture.sh +188 -0
- package/templates/pi/scripts/languages/rust/validate-canonical.sh +146 -0
- package/templates/pi/scripts/languages/rust/validate-ci.sh +147 -0
- package/templates/pi/scripts/languages/rust/validate-integration.sh +149 -0
- package/templates/pi/scripts/languages/rust/validate-operations.sh +154 -0
- package/templates/pi/scripts/languages/rust/validate-security.sh +153 -0
- package/templates/pi/scripts/languages/rust/validate-tests.sh +150 -0
- package/templates/pi/scripts/languages/typescript/validate-architecture.sh +157 -0
- package/templates/pi/scripts/languages/typescript/validate-canonical.sh +135 -0
- package/templates/pi/scripts/languages/typescript/validate-ci.sh +244 -0
- package/templates/pi/scripts/languages/typescript/validate-integration.sh +166 -0
- package/templates/pi/scripts/languages/typescript/validate-operations.sh +162 -0
- package/templates/pi/scripts/languages/typescript/validate-security.sh +169 -0
- package/templates/pi/scripts/languages/typescript/validate-tests.sh +158 -0
- package/templates/pi/scripts/merge-mr.sh +95 -0
- package/templates/pi/scripts/mr-validation.sh +228 -0
- package/templates/pi/scripts/validate-architecture-readiness.sh +153 -0
- package/templates/pi/scripts/validate-architecture.sh +22 -0
- package/templates/pi/scripts/validate-canonical.sh +22 -0
- package/templates/pi/scripts/validate-ci.sh +37 -0
- package/templates/pi/scripts/validate-integration.sh +22 -0
- package/templates/pi/scripts/validate-operations.sh +22 -0
- package/templates/pi/scripts/validate-security.sh +22 -0
- package/templates/pi/scripts/validate-tests.sh +22 -0
- package/templates/pi/scripts/validate-ubiquitous-language.sh +291 -0
- package/templates/pi/scripts/validation-cache.sh +139 -0
- package/templates/pi/skills/agents/architecture-coordinator.md +178 -0
- package/templates/pi/skills/agents/architecture-generator.md +79 -0
- package/templates/pi/skills/agents/architecture-validator.md +74 -0
- package/templates/pi/skills/agents/ci-mr-validator.md +46 -0
- package/templates/pi/skills/agents/code-developer.md +76 -0
- package/templates/pi/skills/agents/commit.md +46 -0
- package/templates/pi/skills/agents/curator.md +71 -0
- package/templates/pi/skills/agents/debug.md +59 -0
- package/templates/pi/skills/agents/documentation-maintainer.md +36 -0
- package/templates/pi/skills/agents/goal-loop.md +125 -0
- package/templates/pi/skills/agents/hooks.md +122 -0
- package/templates/pi/skills/agents/integration-validator.md +35 -0
- package/templates/pi/skills/agents/issue-creator.md +75 -0
- package/templates/pi/skills/agents/issue-factory.md +143 -0
- package/templates/pi/skills/agents/kanban.md +85 -0
- package/templates/pi/skills/agents/land.md +59 -0
- package/templates/pi/skills/agents/operations-validator.md +43 -0
- package/templates/pi/skills/agents/pipeline.md +113 -0
- package/templates/pi/skills/agents/plan-mode.md +77 -0
- package/templates/pi/skills/agents/pull.md +40 -0
- package/templates/pi/skills/agents/push.md +41 -0
- package/templates/pi/skills/agents/security-validator.md +85 -0
- package/templates/pi/skills/agents/session-persistence.md +119 -0
- package/templates/pi/skills/agents/slash-commands.md +117 -0
- package/templates/pi/skills/agents/snippets.md +99 -0
- package/templates/pi/skills/agents/subagent-registry.md +78 -0
- package/templates/pi/skills/agents/test-validator.md +42 -0
- package/templates/pi/skills/validators/architecture-validator.md +43 -0
- package/templates/pi/skills/validators/ci-validator.md +27 -0
- package/templates/pi/skills/validators/context-compaction.md +73 -0
- package/templates/pi/skills/validators/integration-validator.md +38 -0
- package/templates/pi/skills/validators/model-registry.md +96 -0
- package/templates/pi/skills/validators/operations-validator.md +34 -0
- package/templates/pi/skills/validators/security-guards.md +72 -0
- package/templates/pi/skills/validators/security-validator.md +41 -0
- package/templates/pi/skills/validators/system-prompt-tiers.md +69 -0
- package/templates/pi/skills/validators/test-validator.md +33 -0
- package/templates/pi/types.ts +62 -0
- package/templates/pi/validators/README.md +93 -0
- package/templates/pi/validators/default.toml +209 -0
- package/templates/pi/validators/spring.toml +142 -0
- package/templates/pi/workpad.md +53 -0
- package/templates/project/java/Dockerfile +14 -0
- package/templates/project/java/README.md +40 -0
- package/templates/project/java/pom.xml +132 -0
- package/templates/project/typescript/Dockerfile +15 -0
- package/templates/project/typescript/README.md +29 -0
- package/templates/project/typescript/package.json +23 -0
- package/templates/project/typescript/tsconfig.json +21 -0
- package/templates/workflow.md +123 -0
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
# Refactoring Workflow
|
|
2
|
+
|
|
3
|
+
**Scope:** Moderate, Complex
|
|
4
|
+
**Optimized for:** Safety — behavior must not change
|
|
5
|
+
|
|
6
|
+
## Flow
|
|
7
|
+
|
|
8
|
+
```
|
|
9
|
+
Refactor Request
|
|
10
|
+
│
|
|
11
|
+
▼
|
|
12
|
+
┌─────────────────────────────────┐
|
|
13
|
+
│ 1. COORDINATOR: Classify scope │
|
|
14
|
+
│ Determine affected modules │
|
|
15
|
+
└──────────────┬──────────────────┘
|
|
16
|
+
│
|
|
17
|
+
▼
|
|
18
|
+
┌─────────────────────────────────┐
|
|
19
|
+
│ 2. CODE-DEVELOPER: Baseline │
|
|
20
|
+
│ Run all tests, record output │
|
|
21
|
+
│ Run all validators, cache │
|
|
22
|
+
│ bash .pi/scripts/validation-cache.sh init <task-id>
|
|
23
|
+
└──────────────┬──────────────────┘
|
|
24
|
+
│
|
|
25
|
+
▼
|
|
26
|
+
┌─────────────────────────────────┐
|
|
27
|
+
│ 3. ARCHITECTURE-VALIDATOR: Plan │
|
|
28
|
+
│ Review refactor approach │
|
|
29
|
+
│ Ensure patterns preserved │
|
|
30
|
+
└──────────────┬──────────────────┘
|
|
31
|
+
│
|
|
32
|
+
▼
|
|
33
|
+
┌─────────────────────────────────┐
|
|
34
|
+
│ 4. CODE-DEVELOPER: Refactor │
|
|
35
|
+
│ Small commits, one change at │
|
|
36
|
+
│ a time │
|
|
37
|
+
│ Run tests after each change │
|
|
38
|
+
└──────────────┬──────────────────┘
|
|
39
|
+
│
|
|
40
|
+
▼
|
|
41
|
+
┌─────────────────────────────────┐
|
|
42
|
+
│ 5. AUTOMATED: Verify no regress │
|
|
43
|
+
│ • validate-ci.sh │
|
|
44
|
+
│ • validate-tests.sh │
|
|
45
|
+
│ • validate-operations.sh │
|
|
46
|
+
│ Compare with baseline │
|
|
47
|
+
└──────────────┬──────────────────┘
|
|
48
|
+
│
|
|
49
|
+
▼
|
|
50
|
+
┌─────────────────────────────────┐
|
|
51
|
+
│ 6. ARCHITECTURE-VALIDATOR: Wire │
|
|
52
|
+
│ Verify wiring still correct │
|
|
53
|
+
│ • Callers exist │
|
|
54
|
+
│ • No duplicates │
|
|
55
|
+
│ • Modules used │
|
|
56
|
+
└──────────────┬──────────────────┘
|
|
57
|
+
│
|
|
58
|
+
▼
|
|
59
|
+
┌─────────────────────────────────┐
|
|
60
|
+
│ 7. CI-MR: Create PR + merge │
|
|
61
|
+
└─────────────────────────────────┘
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## Rules
|
|
65
|
+
|
|
66
|
+
- **Behavior must not change** — all tests must pass with identical output
|
|
67
|
+
- **Small commits** — one logical change per commit for easy revert
|
|
68
|
+
- **Baseline first** — record test output before refactoring
|
|
69
|
+
- **Wiring verification** — ensure all callers still work after refactor
|
|
70
|
+
|
|
71
|
+
## Commands
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
# Baseline
|
|
75
|
+
bash .pi/scripts/validate-ci.sh
|
|
76
|
+
bash .pi/scripts/validate-tests.sh
|
|
77
|
+
bash .pi/scripts/validate-operations.sh [src_dir]
|
|
78
|
+
|
|
79
|
+
# Validation cache
|
|
80
|
+
bash .pi/scripts/validation-cache.sh init <task-id>
|
|
81
|
+
bash .pi/scripts/validation-cache.sh summary <task-id>
|
|
82
|
+
```
|
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
# Scope Analyzer Workflow
|
|
2
|
+
|
|
3
|
+
**Purpose:** Automatically analyze proposed changes and determine scope classification (simple/moderate/complex/critical) to select appropriate validators.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Prerequisites
|
|
8
|
+
|
|
9
|
+
- Changes proposed (diff, branch, or description)
|
|
10
|
+
- `.pi/` blueprint exists
|
|
11
|
+
- Scope classification rules defined in INDEX.md
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## Canonical Reference Requirement
|
|
16
|
+
|
|
17
|
+
**Analyzer output must reference blueprint scope definitions:**
|
|
18
|
+
|
|
19
|
+
```markdown
|
|
20
|
+
<!--
|
|
21
|
+
Canonical Reference: .pi/INDEX.md#scope-classification
|
|
22
|
+
Scope determination follows Guardian framework rules
|
|
23
|
+
-->
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## Workflow Steps
|
|
29
|
+
|
|
30
|
+
### 1. Gather Change Information
|
|
31
|
+
|
|
32
|
+
Collect data about proposed changes:
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
# If diff available
|
|
36
|
+
git diff main --stat
|
|
37
|
+
git diff main --numstat
|
|
38
|
+
|
|
39
|
+
# If branch available
|
|
40
|
+
git log main..HEAD --oneline
|
|
41
|
+
git diff main..HEAD --shortstat
|
|
42
|
+
|
|
43
|
+
# If files specified
|
|
44
|
+
for file in [files]; do
|
|
45
|
+
lines=$(wc -l < "$file")
|
|
46
|
+
echo "$file: $lines lines"
|
|
47
|
+
done
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### 2. File Count Analysis
|
|
51
|
+
|
|
52
|
+
Count files affected:
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
# Files changed
|
|
56
|
+
CHANGED_FILES=$(git diff main --name-only | wc -l)
|
|
57
|
+
|
|
58
|
+
# Categories
|
|
59
|
+
CONFIG_FILES=$(git diff main --name-only | grep -E '\.(json|yaml|toml|config)' | wc -l)
|
|
60
|
+
SOURCE_FILES=$(git diff main --name-only | grep -E 'src/' | wc -l)
|
|
61
|
+
TEST_FILES=$(git diff main --name-only | grep -E 'test|spec' | wc -l)
|
|
62
|
+
DOC_FILES=$(git diff main --name-only | grep -E '\.(md|rst)' | wc -l)
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### 3. Lines Changed Analysis
|
|
66
|
+
|
|
67
|
+
Calculate lines changed:
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
# Total lines
|
|
71
|
+
ADDED=$(git diff main --numstat | awk '{sum+=$1} END {print sum}')
|
|
72
|
+
REMOVED=$(git diff main --numstat | awk '{sum+=$2} END {print sum}')
|
|
73
|
+
NET=$((ADDED - REMOVED))
|
|
74
|
+
|
|
75
|
+
# Per-file breakdown
|
|
76
|
+
git diff main --numstat | while read add rem file; do
|
|
77
|
+
echo "$file: +$add -$rem"
|
|
78
|
+
done
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### 4. Complexity Indicators
|
|
82
|
+
|
|
83
|
+
Check for complexity indicators:
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
# New dependencies
|
|
87
|
+
NEW_DEPS=$(git diff main -- package.json | grep -E '^\+.*"' | grep -v '^\+\+\+' | wc -l)
|
|
88
|
+
|
|
89
|
+
# New files created
|
|
90
|
+
NEW_FILES=$(git diff main --name-status | grep '^A' | wc -l)
|
|
91
|
+
|
|
92
|
+
# Deleted files
|
|
93
|
+
DEL_FILES=$(git diff main --name-status | grep '^D' | wc -l)
|
|
94
|
+
|
|
95
|
+
# Core file changes (high impact)
|
|
96
|
+
CORE_FILES=$(git diff main --name-only | grep -E '(index|main|app|config)' | wc -l)
|
|
97
|
+
|
|
98
|
+
# API changes
|
|
99
|
+
API_CHANGES=$(git diff main --name-only | grep -E '(api|route|endpoint|handler)' | wc -l)
|
|
100
|
+
|
|
101
|
+
# Auth/security related
|
|
102
|
+
SECURITY_FILES=$(git diff main --name-only | grep -E '(auth|security|crypto|permission)' | wc -l)
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### 5. Scope Classification
|
|
106
|
+
|
|
107
|
+
Apply classification rules from INDEX.md:
|
|
108
|
+
|
|
109
|
+
**Classification Matrix:**
|
|
110
|
+
|
|
111
|
+
| Indicator | Simple | Moderate | Complex | Critical |
|
|
112
|
+
|-----------|--------|----------|---------|----------|
|
|
113
|
+
| Files changed | 1 | 2-5 | 5-15 | 15+ |
|
|
114
|
+
| Lines changed | <50 | 50-200 | 200-500 | 500+ |
|
|
115
|
+
| New dependencies | 0 | 0-2 | 2-5 | 5+ |
|
|
116
|
+
| Core file changes | 0 | 0-1 | 1-2 | 2+ |
|
|
117
|
+
| Security changes | 0 | 0 | 1+ | any |
|
|
118
|
+
| API changes | 0 | 0-1 | 1-3 | 3+ |
|
|
119
|
+
|
|
120
|
+
**Decision Logic:**
|
|
121
|
+
|
|
122
|
+
```markdown
|
|
123
|
+
## Scope Calculation
|
|
124
|
+
|
|
125
|
+
### Primary Metrics
|
|
126
|
+
- Files: [N]
|
|
127
|
+
- Lines: [M]
|
|
128
|
+
|
|
129
|
+
### Secondary Indicators
|
|
130
|
+
- New deps: [D]
|
|
131
|
+
- Core files: [C]
|
|
132
|
+
- Security: [S]
|
|
133
|
+
- API: [A]
|
|
134
|
+
|
|
135
|
+
### Classification
|
|
136
|
+
[Apply rules and determine scope]
|
|
137
|
+
|
|
138
|
+
### Required Validators
|
|
139
|
+
[List validators based on scope]
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
### 6. Validator Selection
|
|
143
|
+
|
|
144
|
+
Select validators based on scope:
|
|
145
|
+
|
|
146
|
+
**Validator Requirements by Scope:**
|
|
147
|
+
|
|
148
|
+
| Scope | Required Validators |
|
|
149
|
+
|-------|---------------------|
|
|
150
|
+
| Simple | ci (automated) |
|
|
151
|
+
| Moderate | ci + architecture |
|
|
152
|
+
| Complex | ci + architecture + security + test |
|
|
153
|
+
| Critical | All validators + human approval |
|
|
154
|
+
|
|
155
|
+
**Output validator list:**
|
|
156
|
+
|
|
157
|
+
```markdown
|
|
158
|
+
## Validators Required
|
|
159
|
+
|
|
160
|
+
Based on scope [SCOPE]:
|
|
161
|
+
- ✅ validate-ci.sh (always)
|
|
162
|
+
- ✅ validate-architecture.sh (moderate+)
|
|
163
|
+
- ✅ validate-security.sh (complex+)
|
|
164
|
+
- ✅ validate-tests.sh (complex+)
|
|
165
|
+
- ✅ validate-operations.sh (critical)
|
|
166
|
+
- ⚠️ Human approval required (critical only)
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
### 7. Risk Assessment
|
|
170
|
+
|
|
171
|
+
Assess risk factors:
|
|
172
|
+
|
|
173
|
+
```markdown
|
|
174
|
+
## Risk Factors
|
|
175
|
+
|
|
176
|
+
### High Risk Indicators
|
|
177
|
+
- [ ] Security-related changes
|
|
178
|
+
- [ ] Auth/permission changes
|
|
179
|
+
- [ ] Database schema changes
|
|
180
|
+
- [ ] Breaking API changes
|
|
181
|
+
- [ ] Core architecture changes
|
|
182
|
+
|
|
183
|
+
### Medium Risk Indicators
|
|
184
|
+
- [ ] New dependencies
|
|
185
|
+
- [ ] Configuration changes
|
|
186
|
+
- [ ] Multiple file changes
|
|
187
|
+
|
|
188
|
+
### Low Risk
|
|
189
|
+
- [ ] Single file
|
|
190
|
+
- [ ] Documentation only
|
|
191
|
+
- [ ] Test files only
|
|
192
|
+
|
|
193
|
+
### Risk Level: [HIGH/MEDIUM/LOW]
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
---
|
|
197
|
+
|
|
198
|
+
## Output Summary
|
|
199
|
+
|
|
200
|
+
```markdown
|
|
201
|
+
## Scope Analysis Report
|
|
202
|
+
|
|
203
|
+
<!--
|
|
204
|
+
Canonical Reference: .pi/INDEX.md#scope-classification
|
|
205
|
+
-->
|
|
206
|
+
|
|
207
|
+
### Change Summary
|
|
208
|
+
- Files: [N]
|
|
209
|
+
- Lines added: [+X]
|
|
210
|
+
- Lines removed: [-Y]
|
|
211
|
+
- Net change: [Z]
|
|
212
|
+
|
|
213
|
+
### Scope Classification
|
|
214
|
+
- **Result: [SCOPE]**
|
|
215
|
+
- Files threshold: [N] (threshold: [X])
|
|
216
|
+
- Lines threshold: [M] (threshold: [Y])
|
|
217
|
+
|
|
218
|
+
### Complexity Factors
|
|
219
|
+
- New dependencies: [D]
|
|
220
|
+
- Core files affected: [C]
|
|
221
|
+
- Security changes: [S]
|
|
222
|
+
- API changes: [A]
|
|
223
|
+
|
|
224
|
+
### Validators Required
|
|
225
|
+
[List with justification]
|
|
226
|
+
|
|
227
|
+
### Risk Level: [LEVEL]
|
|
228
|
+
|
|
229
|
+
### Recommendations
|
|
230
|
+
- [Implementation approach suggestion]
|
|
231
|
+
- [Validation sequence suggestion]
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
---
|
|
235
|
+
|
|
236
|
+
## Acceptance Criteria
|
|
237
|
+
|
|
238
|
+
- [ ] File count accurate
|
|
239
|
+
- [ ] Lines changed calculated
|
|
240
|
+
- [ ] Complexity indicators checked
|
|
241
|
+
- [ ] Scope classification correct per INDEX.md rules
|
|
242
|
+
- [ ] Validators selected appropriately
|
|
243
|
+
- [ ] Risk level assessed
|
|
244
|
+
- [ ] Canonical reference included in output
|
|
245
|
+
|
|
246
|
+
---
|
|
247
|
+
|
|
248
|
+
## Next Workflow
|
|
249
|
+
|
|
250
|
+
After scope determined:
|
|
251
|
+
- Simple: Proceed directly to implementation
|
|
252
|
+
- Moderate: Run `/blueprint-validate`, then implementation
|
|
253
|
+
- Complex: Run `/blueprint-validate` + `/sync-check`, then implementation
|
|
254
|
+
- Critical: Get human approval, then full validation sequence
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
# Sync Check Workflow
|
|
2
|
+
|
|
3
|
+
<!--
|
|
4
|
+
Canonical Reference: .pi/prompts/sync-check.md
|
|
5
|
+
Blueprint Source: Guardian Framework v1.2
|
|
6
|
+
-->
|
|
7
|
+
|
|
8
|
+
**Purpose:** Verify generated exports (.claude/, .opencode/, .agents/) are in sync with .pi/ blueprint source. Includes architecture sync verification.
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## Prerequisites
|
|
13
|
+
|
|
14
|
+
- `.pi/` blueprint exists
|
|
15
|
+
- At least one export format generated
|
|
16
|
+
- `guardian.manifest.json` exists
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
## Architecture Sync Verification
|
|
21
|
+
|
|
22
|
+
**Check architecture CHANGELOG for pending changes:**
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
# Check for pending (not synced) changes in CHANGELOG
|
|
26
|
+
grep -E "Status.*pending" .pi/architecture/CHANGELOG.md | head -10
|
|
27
|
+
|
|
28
|
+
# Check last architecture sync date
|
|
29
|
+
jq -r '.lastArchitectureSync' guardian.manifest.json
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
**Pending changes indicate:**
|
|
33
|
+
- Implementation files may have outdated canonical references
|
|
34
|
+
- Architecture spec differs from implementation
|
|
35
|
+
- Need `/blueprint-update` to sync
|
|
36
|
+
|
|
37
|
+
**Canonical Reference Requirement**
|
|
38
|
+
|
|
39
|
+
**Generated files must include canonical reference header:**
|
|
40
|
+
|
|
41
|
+
```typescript
|
|
42
|
+
/**
|
|
43
|
+
* Canonical Reference: .pi/[source-path].md
|
|
44
|
+
* Blueprint Source: Guardian Framework v[X]
|
|
45
|
+
* Generated: [timestamp]
|
|
46
|
+
* DO NOT EDIT DIRECTLY - Modify source in .pi/
|
|
47
|
+
*/
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
**Or for markdown:**
|
|
51
|
+
```markdown
|
|
52
|
+
<!--
|
|
53
|
+
Canonical Reference: .pi/[source-path].md
|
|
54
|
+
Blueprint Source: Guardian Framework v[X]
|
|
55
|
+
Generated: [timestamp]
|
|
56
|
+
DO NOT EDIT DIRECTLY - Modify source in .pi/
|
|
57
|
+
-->
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
---
|
|
61
|
+
|
|
62
|
+
## Workflow Steps
|
|
63
|
+
|
|
64
|
+
### 1. Load Manifest
|
|
65
|
+
|
|
66
|
+
Read the manifest to know what files should exist:
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
cat guardian.manifest.json | jq '.files'
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### 2. Check Export Existence
|
|
73
|
+
|
|
74
|
+
Verify all exported files exist:
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
# Check .claude/ exports
|
|
78
|
+
jq -r '.exports.claude[]' guardian.manifest.json | while read file; do
|
|
79
|
+
if [ -f "$file" ]; then
|
|
80
|
+
echo "✅ $file exists"
|
|
81
|
+
else
|
|
82
|
+
echo "❌ MISSING: $file"
|
|
83
|
+
fi
|
|
84
|
+
done
|
|
85
|
+
|
|
86
|
+
# Check .opencode/ exports (if configured)
|
|
87
|
+
jq -r '.exports.opencode[]' guardian.manifest.json 2>/dev/null | while read file; do
|
|
88
|
+
if [ -f "$file" ]; then
|
|
89
|
+
echo "✅ $file exists"
|
|
90
|
+
else
|
|
91
|
+
echo "❌ MISSING: $file"
|
|
92
|
+
fi
|
|
93
|
+
done
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### 3. Hash Comparison
|
|
97
|
+
|
|
98
|
+
Compare file hashes from manifest to actual files:
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
jq -r '.files | to_entries[] | "\(.key) \(.value.hash)"' guardian.manifest.json | while read path hash; do
|
|
102
|
+
current_hash=$(sha256sum "$path" | cut -d' ' -f1)
|
|
103
|
+
if [ "$current_hash" = "$hash" ]; then
|
|
104
|
+
echo "✅ $path: hash matches"
|
|
105
|
+
else
|
|
106
|
+
echo "❌ $path: HASH MISMATCH (modified)"
|
|
107
|
+
fi
|
|
108
|
+
done
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
### 4. Canonical Header Validation
|
|
112
|
+
|
|
113
|
+
Check that generated files have proper canonical reference:
|
|
114
|
+
|
|
115
|
+
```bash
|
|
116
|
+
for file in .claude/**/*.md .opencode/**/*.md; do
|
|
117
|
+
if [ -f "$file" ]; then
|
|
118
|
+
if grep -q "Canonical Reference:" "$file"; then
|
|
119
|
+
# Extract and verify reference
|
|
120
|
+
ref=$(grep "Canonical Reference:" "$file" | head -1)
|
|
121
|
+
source=$(echo "$ref" | grep -o '.pi/[^"]*' | head -1)
|
|
122
|
+
if [ -f "$source" ]; then
|
|
123
|
+
echo "✅ $file -> $source (valid ref)"
|
|
124
|
+
else
|
|
125
|
+
echo "❌ $file references non-existent $source"
|
|
126
|
+
fi
|
|
127
|
+
else
|
|
128
|
+
echo "❌ $file missing canonical reference header"
|
|
129
|
+
fi
|
|
130
|
+
fi
|
|
131
|
+
done
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
### 5. Drift Detection
|
|
135
|
+
|
|
136
|
+
Detect manual modifications to generated files:
|
|
137
|
+
|
|
138
|
+
```bash
|
|
139
|
+
# Files modified after generation
|
|
140
|
+
for file in .claude/**/*.md; do
|
|
141
|
+
gen_time=$(grep "Generated:" "$file" | grep -o '[0-9-]*')
|
|
142
|
+
mod_time=$(stat -c %Y "$file" 2>/dev/null || stat -f %m "$file")
|
|
143
|
+
# Compare timestamps
|
|
144
|
+
if [ "$mod_time" -gt "$(date -d "$gen_time" +%s 2>/dev/null || echo 0)" ]; then
|
|
145
|
+
echo "⚠️ $file modified after generation"
|
|
146
|
+
fi
|
|
147
|
+
done
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
### 6. Source Freshness Check
|
|
151
|
+
|
|
152
|
+
Check if blueprint source is newer than exports:
|
|
153
|
+
|
|
154
|
+
```bash
|
|
155
|
+
for mapping in $(jq -r '.generationMappings[] | "\(.source) \(.destination)"' guardian.manifest.json); do
|
|
156
|
+
source=$(echo "$mapping" | cut -d' ' -f1)
|
|
157
|
+
dest=$(echo "$mapping" | cut -d' ' -f2)
|
|
158
|
+
if [ -f "$source" ] && [ -f "$dest" ]; then
|
|
159
|
+
source_time=$(stat -c %Y "$source" 2>/dev/null || stat -f %m "$source")
|
|
160
|
+
dest_time=$(stat -c %Y "$dest" 2>/dev/null || stat -f %m "$dest")
|
|
161
|
+
if [ "$source_time" -gt "$dest_time" ]; then
|
|
162
|
+
echo "⚠️ $source newer than $dest (needs regeneration)"
|
|
163
|
+
fi
|
|
164
|
+
fi
|
|
165
|
+
done
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
---
|
|
169
|
+
|
|
170
|
+
## Output Summary
|
|
171
|
+
|
|
172
|
+
```markdown
|
|
173
|
+
## Sync Check Report
|
|
174
|
+
|
|
175
|
+
### Existence Check
|
|
176
|
+
- Total Expected: [N]
|
|
177
|
+
- Found: [M]
|
|
178
|
+
- Missing: [N-M]
|
|
179
|
+
|
|
180
|
+
### Hash Verification
|
|
181
|
+
- Matching: [X]
|
|
182
|
+
- Modified: [Y]
|
|
183
|
+
|
|
184
|
+
### Canonical References
|
|
185
|
+
- Valid: [A]
|
|
186
|
+
- Missing: [B]
|
|
187
|
+
- Broken: [C]
|
|
188
|
+
|
|
189
|
+
### Drift Detection
|
|
190
|
+
- Unmodified: [D]
|
|
191
|
+
- Manual edits: [E]
|
|
192
|
+
|
|
193
|
+
### Freshness
|
|
194
|
+
- Up-to-date: [F]
|
|
195
|
+
- Needs regeneration: [G]
|
|
196
|
+
|
|
197
|
+
### Recommendation
|
|
198
|
+
- [PASS: All in sync]
|
|
199
|
+
- [FAIL: Run `guardian generate`]
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
---
|
|
203
|
+
|
|
204
|
+
## Error Handling
|
|
205
|
+
|
|
206
|
+
| Issue | Solution |
|
|
207
|
+
|-------|----------|
|
|
208
|
+
| Missing exports | Run `guardian generate` |
|
|
209
|
+
| Hash mismatch | Regenerate or update source |
|
|
210
|
+
| Missing canonical header | Regenerate with current framework |
|
|
211
|
+
| Manual edits detected | Migrate edits to .pi/ source, regenerate |
|
|
212
|
+
| Source newer than export | Run `guardian generate` |
|
|
213
|
+
|
|
214
|
+
---
|
|
215
|
+
|
|
216
|
+
## Acceptance Criteria
|
|
217
|
+
|
|
218
|
+
- [ ] All expected exports exist
|
|
219
|
+
- [ ] All file hashes match manifest
|
|
220
|
+
- [ ] All generated files have canonical reference headers
|
|
221
|
+
- [ ] No manual edits in generated files (or documented)
|
|
222
|
+
- [ ] Blueprint sources not newer than exports
|
|
223
|
+
- [ ] Sync status: PASS
|
|
224
|
+
|
|
225
|
+
---
|
|
226
|
+
|
|
227
|
+
## Next Workflow
|
|
228
|
+
|
|
229
|
+
- If PASS: Proceed with implementation
|
|
230
|
+
- If FAIL: Run `guardian generate` then recheck
|