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.
Files changed (216) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +463 -0
  3. package/dist/cli.js +12958 -0
  4. package/dist/exports.js +12765 -0
  5. package/package.json +61 -0
  6. package/templates/languages/go-patterns.md +411 -0
  7. package/templates/languages/java-patterns.md +545 -0
  8. package/templates/languages/python-patterns.md +312 -0
  9. package/templates/languages/rust-patterns.md +232 -0
  10. package/templates/languages/typescript-patterns.md +313 -0
  11. package/templates/pi/INDEX.md +437 -0
  12. package/templates/pi/agent/AGENTS.md +166 -0
  13. package/templates/pi/agents/architecture-coordinator.md +40 -0
  14. package/templates/pi/agents/architecture-validator.md +36 -0
  15. package/templates/pi/agents/bootstrap-implementer.md +37 -0
  16. package/templates/pi/agents/issue-factory.md +31 -0
  17. package/templates/pi/agents/operations-validator.md +32 -0
  18. package/templates/pi/agents/security-validator.md +33 -0
  19. package/templates/pi/architecture/CHANGELOG.md +78 -0
  20. package/templates/pi/architecture/decisions/ADR-template.md +76 -0
  21. package/templates/pi/architecture/diagrams/system-overview.md +159 -0
  22. package/templates/pi/architecture/modules/module-template.md +152 -0
  23. package/templates/pi/context/checklists.md +91 -0
  24. package/templates/pi/context/domain-workflow.md +180 -0
  25. package/templates/pi/context/output-formats.md +135 -0
  26. package/templates/pi/context/patterns-base.md +47 -0
  27. package/templates/pi/context/patterns.md +38 -0
  28. package/templates/pi/context/project.md +88 -0
  29. package/templates/pi/domain/exploration.md +93 -0
  30. package/templates/pi/domain/ubiquitous-language.md +24 -0
  31. package/templates/pi/extensions/architect-lib/generators.ts +528 -0
  32. package/templates/pi/extensions/architect-lib/helpers.ts +344 -0
  33. package/templates/pi/extensions/architect-lib/types.ts +117 -0
  34. package/templates/pi/extensions/architect.ts +1425 -0
  35. package/templates/pi/extensions/ask-user-question.ts +579 -0
  36. package/templates/pi/extensions/bash-guard.ts +556 -0
  37. package/templates/pi/extensions/config-reload.ts +115 -0
  38. package/templates/pi/extensions/coordinator.ts +304 -0
  39. package/templates/pi/extensions/curator.ts +543 -0
  40. package/templates/pi/extensions/domain-explorer.ts +990 -0
  41. package/templates/pi/extensions/filechanges.ts +656 -0
  42. package/templates/pi/extensions/goal-loop.ts +717 -0
  43. package/templates/pi/extensions/hooks.ts +452 -0
  44. package/templates/pi/extensions/kanban.ts +547 -0
  45. package/templates/pi/extensions/pipeline.ts +1246 -0
  46. package/templates/pi/extensions/plan-mode.ts +209 -0
  47. package/templates/pi/extensions/project-scaffolder.ts +284 -0
  48. package/templates/pi/extensions/read-only-mode.ts +192 -0
  49. package/templates/pi/extensions/redaction.ts +128 -0
  50. package/templates/pi/extensions/session-persistence.ts +174 -0
  51. package/templates/pi/extensions/slash-commands.ts +229 -0
  52. package/templates/pi/extensions/snippets.ts +201 -0
  53. package/templates/pi/extensions/validation-runner.ts +100 -0
  54. package/templates/pi/github/agents/architecture-coordinator.agent.md +27 -0
  55. package/templates/pi/github/agents/architecture-validator.agent.md +20 -0
  56. package/templates/pi/github/agents/bootstrap-implementer.agent.md +20 -0
  57. package/templates/pi/github/agents/epic-planner.agent.md +70 -0
  58. package/templates/pi/github/agents/issue-factory.agent.md +20 -0
  59. package/templates/pi/github/agents/operations-validator.agent.md +20 -0
  60. package/templates/pi/github/agents/security-validator.agent.md +20 -0
  61. package/templates/pi/github/copilot/settings.json +16 -0
  62. package/templates/pi/github/copilot-instructions.md +155 -0
  63. package/templates/pi/github/instructions/architecture.instructions.md +71 -0
  64. package/templates/pi/github/instructions/validation.instructions.md +69 -0
  65. package/templates/pi/github/workflows/01-planning-workflow.md +75 -0
  66. package/templates/pi/github/workflows/02-issue-generation-workflow.md +69 -0
  67. package/templates/pi/github/workflows/03-implementation-workflow.md +80 -0
  68. package/templates/pi/github/workflows/04-validation-workflow.md +68 -0
  69. package/templates/pi/preflight_report.json +99 -0
  70. package/templates/pi/prompts/blueprint-update.md +262 -0
  71. package/templates/pi/prompts/blueprint-validate.md +218 -0
  72. package/templates/pi/prompts/bug-fix.md +50 -0
  73. package/templates/pi/prompts/ci-blueprint.md +131 -0
  74. package/templates/pi/prompts/context-refresh.md +258 -0
  75. package/templates/pi/prompts/epic-plan.md +356 -0
  76. package/templates/pi/prompts/epic-template.md +186 -0
  77. package/templates/pi/prompts/feature-development.md +131 -0
  78. package/templates/pi/prompts/git-issues.md +243 -0
  79. package/templates/pi/prompts/hotfix.md +71 -0
  80. package/templates/pi/prompts/issue-closeout.md +342 -0
  81. package/templates/pi/prompts/issue-draft.md +218 -0
  82. package/templates/pi/prompts/issue-implementation-series.md +173 -0
  83. package/templates/pi/prompts/issue-merge.md +372 -0
  84. package/templates/pi/prompts/issue-template-set.md +392 -0
  85. package/templates/pi/prompts/issue-template.md +207 -0
  86. package/templates/pi/prompts/pattern-extract.md +269 -0
  87. package/templates/pi/prompts/plan-to-issues.md +430 -0
  88. package/templates/pi/prompts/refactoring.md +82 -0
  89. package/templates/pi/prompts/scope-analyzer.md +254 -0
  90. package/templates/pi/prompts/sync-check.md +230 -0
  91. package/templates/pi/scripts/categorize-issues.sh +171 -0
  92. package/templates/pi/scripts/ci/check_architecture_conformance.sh +748 -0
  93. package/templates/pi/scripts/ci/check_planning_packet.py +228 -0
  94. package/templates/pi/scripts/ci/run_hardening_stages.sh +264 -0
  95. package/templates/pi/scripts/ci/run_preflight.sh +649 -0
  96. package/templates/pi/scripts/ci/run_stage.sh +193 -0
  97. package/templates/pi/scripts/ci/stage_docs_policy.sh +82 -0
  98. package/templates/pi/scripts/ci/stage_integration.sh +3 -0
  99. package/templates/pi/scripts/ci/stage_lint.sh +130 -0
  100. package/templates/pi/scripts/ci/stage_migration_verify.sh +3 -0
  101. package/templates/pi/scripts/ci/stage_package_build.sh +3 -0
  102. package/templates/pi/scripts/ci/stage_release_readiness.sh +3 -0
  103. package/templates/pi/scripts/ci/stage_remaining.sh +242 -0
  104. package/templates/pi/scripts/ci/stage_security.sh +3 -0
  105. package/templates/pi/scripts/ci/stage_static_analysis.sh +114 -0
  106. package/templates/pi/scripts/ci/stage_unit.sh +119 -0
  107. package/templates/pi/scripts/ci/validate_agent_output.py +181 -0
  108. package/templates/pi/scripts/ci/validate_agent_output.sh +243 -0
  109. package/templates/pi/scripts/create-feature-branch.sh +136 -0
  110. package/templates/pi/scripts/create-mr.sh +117 -0
  111. package/templates/pi/scripts/fetch-issues.sh +131 -0
  112. package/templates/pi/scripts/generate-architecture.sh +161 -0
  113. package/templates/pi/scripts/git/close-epic.sh +69 -0
  114. package/templates/pi/scripts/git/close-issue.sh +35 -0
  115. package/templates/pi/scripts/git/create-tracking-issue.sh +174 -0
  116. package/templates/pi/scripts/git/link-issue-to-epic.sh +51 -0
  117. package/templates/pi/scripts/git/update-tracking-issue.sh +66 -0
  118. package/templates/pi/scripts/languages/go/validate-architecture.sh +139 -0
  119. package/templates/pi/scripts/languages/go/validate-canonical.sh +129 -0
  120. package/templates/pi/scripts/languages/go/validate-ci.sh +132 -0
  121. package/templates/pi/scripts/languages/go/validate-integration.sh +156 -0
  122. package/templates/pi/scripts/languages/go/validate-operations.sh +146 -0
  123. package/templates/pi/scripts/languages/go/validate-security.sh +135 -0
  124. package/templates/pi/scripts/languages/go/validate-tests.sh +125 -0
  125. package/templates/pi/scripts/languages/java/validate-annotations.sh +185 -0
  126. package/templates/pi/scripts/languages/java/validate-architecture.sh +159 -0
  127. package/templates/pi/scripts/languages/java/validate-canonical.sh +114 -0
  128. package/templates/pi/scripts/languages/java/validate-ci.sh +269 -0
  129. package/templates/pi/scripts/languages/java/validate-integration.sh +149 -0
  130. package/templates/pi/scripts/languages/java/validate-operations.sh +142 -0
  131. package/templates/pi/scripts/languages/java/validate-security.sh +174 -0
  132. package/templates/pi/scripts/languages/java/validate-spring-architecture.sh +227 -0
  133. package/templates/pi/scripts/languages/java/validate-tests.sh +159 -0
  134. package/templates/pi/scripts/languages/python/validate-architecture.sh +99 -0
  135. package/templates/pi/scripts/languages/python/validate-canonical.sh +124 -0
  136. package/templates/pi/scripts/languages/python/validate-ci.sh +130 -0
  137. package/templates/pi/scripts/languages/python/validate-integration.sh +119 -0
  138. package/templates/pi/scripts/languages/python/validate-operations.sh +107 -0
  139. package/templates/pi/scripts/languages/python/validate-security.sh +68 -0
  140. package/templates/pi/scripts/languages/python/validate-tests.sh +102 -0
  141. package/templates/pi/scripts/languages/rust/validate-architecture.sh +188 -0
  142. package/templates/pi/scripts/languages/rust/validate-canonical.sh +146 -0
  143. package/templates/pi/scripts/languages/rust/validate-ci.sh +147 -0
  144. package/templates/pi/scripts/languages/rust/validate-integration.sh +149 -0
  145. package/templates/pi/scripts/languages/rust/validate-operations.sh +154 -0
  146. package/templates/pi/scripts/languages/rust/validate-security.sh +153 -0
  147. package/templates/pi/scripts/languages/rust/validate-tests.sh +150 -0
  148. package/templates/pi/scripts/languages/typescript/validate-architecture.sh +157 -0
  149. package/templates/pi/scripts/languages/typescript/validate-canonical.sh +135 -0
  150. package/templates/pi/scripts/languages/typescript/validate-ci.sh +244 -0
  151. package/templates/pi/scripts/languages/typescript/validate-integration.sh +166 -0
  152. package/templates/pi/scripts/languages/typescript/validate-operations.sh +162 -0
  153. package/templates/pi/scripts/languages/typescript/validate-security.sh +169 -0
  154. package/templates/pi/scripts/languages/typescript/validate-tests.sh +158 -0
  155. package/templates/pi/scripts/merge-mr.sh +95 -0
  156. package/templates/pi/scripts/mr-validation.sh +228 -0
  157. package/templates/pi/scripts/validate-architecture-readiness.sh +153 -0
  158. package/templates/pi/scripts/validate-architecture.sh +22 -0
  159. package/templates/pi/scripts/validate-canonical.sh +22 -0
  160. package/templates/pi/scripts/validate-ci.sh +37 -0
  161. package/templates/pi/scripts/validate-integration.sh +22 -0
  162. package/templates/pi/scripts/validate-operations.sh +22 -0
  163. package/templates/pi/scripts/validate-security.sh +22 -0
  164. package/templates/pi/scripts/validate-tests.sh +22 -0
  165. package/templates/pi/scripts/validate-ubiquitous-language.sh +291 -0
  166. package/templates/pi/scripts/validation-cache.sh +139 -0
  167. package/templates/pi/skills/agents/architecture-coordinator.md +178 -0
  168. package/templates/pi/skills/agents/architecture-generator.md +79 -0
  169. package/templates/pi/skills/agents/architecture-validator.md +74 -0
  170. package/templates/pi/skills/agents/ci-mr-validator.md +46 -0
  171. package/templates/pi/skills/agents/code-developer.md +76 -0
  172. package/templates/pi/skills/agents/commit.md +46 -0
  173. package/templates/pi/skills/agents/curator.md +71 -0
  174. package/templates/pi/skills/agents/debug.md +59 -0
  175. package/templates/pi/skills/agents/documentation-maintainer.md +36 -0
  176. package/templates/pi/skills/agents/goal-loop.md +125 -0
  177. package/templates/pi/skills/agents/hooks.md +122 -0
  178. package/templates/pi/skills/agents/integration-validator.md +35 -0
  179. package/templates/pi/skills/agents/issue-creator.md +75 -0
  180. package/templates/pi/skills/agents/issue-factory.md +143 -0
  181. package/templates/pi/skills/agents/kanban.md +85 -0
  182. package/templates/pi/skills/agents/land.md +59 -0
  183. package/templates/pi/skills/agents/operations-validator.md +43 -0
  184. package/templates/pi/skills/agents/pipeline.md +113 -0
  185. package/templates/pi/skills/agents/plan-mode.md +77 -0
  186. package/templates/pi/skills/agents/pull.md +40 -0
  187. package/templates/pi/skills/agents/push.md +41 -0
  188. package/templates/pi/skills/agents/security-validator.md +85 -0
  189. package/templates/pi/skills/agents/session-persistence.md +119 -0
  190. package/templates/pi/skills/agents/slash-commands.md +117 -0
  191. package/templates/pi/skills/agents/snippets.md +99 -0
  192. package/templates/pi/skills/agents/subagent-registry.md +78 -0
  193. package/templates/pi/skills/agents/test-validator.md +42 -0
  194. package/templates/pi/skills/validators/architecture-validator.md +43 -0
  195. package/templates/pi/skills/validators/ci-validator.md +27 -0
  196. package/templates/pi/skills/validators/context-compaction.md +73 -0
  197. package/templates/pi/skills/validators/integration-validator.md +38 -0
  198. package/templates/pi/skills/validators/model-registry.md +96 -0
  199. package/templates/pi/skills/validators/operations-validator.md +34 -0
  200. package/templates/pi/skills/validators/security-guards.md +72 -0
  201. package/templates/pi/skills/validators/security-validator.md +41 -0
  202. package/templates/pi/skills/validators/system-prompt-tiers.md +69 -0
  203. package/templates/pi/skills/validators/test-validator.md +33 -0
  204. package/templates/pi/types.ts +62 -0
  205. package/templates/pi/validators/README.md +93 -0
  206. package/templates/pi/validators/default.toml +209 -0
  207. package/templates/pi/validators/spring.toml +142 -0
  208. package/templates/pi/workpad.md +53 -0
  209. package/templates/project/java/Dockerfile +14 -0
  210. package/templates/project/java/README.md +40 -0
  211. package/templates/project/java/pom.xml +132 -0
  212. package/templates/project/typescript/Dockerfile +15 -0
  213. package/templates/project/typescript/README.md +29 -0
  214. package/templates/project/typescript/package.json +23 -0
  215. package/templates/project/typescript/tsconfig.json +21 -0
  216. package/templates/workflow.md +123 -0
@@ -0,0 +1,174 @@
1
+ #!/usr/bin/env bash
2
+ # Git Wrapper: Create Tracking Issue
3
+ #
4
+ # Creates a tracking issue on GitHub or GitLab that tracks epic progress.
5
+ # Posts to the issue body as each step completes.
6
+ #
7
+ # Usage: bash .pi/scripts/git/create-tracking-issue.sh \
8
+ # --title "Epic: Auth Module v2" \
9
+ # --body "Tracking issue content" \
10
+ # --labels "epic,tracking"
11
+ #
12
+ # Environment variables:
13
+ # GITHUB_TOKEN / GITLAB_TOKEN — API token
14
+ # GITHUB_REPO / GITLAB_PROJECT_ID — repo/project identifier
15
+ # GIT_PLATFORM — "github" or "gitlab" (auto-detected)
16
+
17
+ set -euo pipefail
18
+
19
+ detect_platform() {
20
+ # First: check guardian-manifest.json for repoTool
21
+ if [ -f "guardian-manifest.json" ]; then
22
+ local tool=$(jq -r '.repoTool // ""' guardian-manifest.json 2>/dev/null || echo "")
23
+ if [[ "$tool" == "glab" ]]; then echo "gitlab"; return; fi
24
+ if [[ "$tool" == "gh" ]]; then echo "github"; return; fi
25
+ fi
26
+ # Fallback: check environment or installed CLIs
27
+ if [[ -n "${GIT_PLATFORM:-}" ]]; then
28
+ echo "$GIT_PLATFORM"
29
+ elif command -v gh &>/dev/null && gh auth status &>/dev/null 2>&1; then
30
+ echo "github"
31
+ elif command -v glab &>/dev/null && glab auth status &>/dev/null 2>&1; then
32
+ echo "gitlab"
33
+ else
34
+ echo "none"
35
+ fi
36
+ }
37
+
38
+ # Extract trailing number from a URL or string (macOS-compatible, no -P flag)
39
+ extract_number() {
40
+ echo "$1" | grep -o '[0-9][0-9]*$' || echo ""
41
+ }
42
+
43
+ TITLE=""
44
+ BODY=""
45
+ BODY_FILE=""
46
+ LABELS=""
47
+ MILESTONE=""
48
+ REPO=""
49
+
50
+ while [[ $# -gt 0 ]]; do
51
+ case $1 in
52
+ --title) TITLE="$2"; shift 2 ;;
53
+ --body) BODY="$2"; shift 2 ;;
54
+ --body-file) BODY_FILE="$2"; shift 2 ;;
55
+ --labels) LABELS="$2"; shift 2 ;;
56
+ --milestone) MILESTONE="$2"; shift 2 ;;
57
+ --repo) REPO="$2"; shift 2 ;;
58
+ *) shift ;;
59
+ esac
60
+ done
61
+
62
+ # If --body-file is provided, read body from file (stripping YAML frontmatter)
63
+ if [[ -n "$BODY_FILE" && -f "$BODY_FILE" ]]; then
64
+ # Extract everything after the second --- (YAML frontmatter delimiter)
65
+ BODY=$(awk '/^---$/{n++; next} n>=2{print}' "$BODY_FILE")
66
+ # If stripping produced empty output, use the raw file as fallback
67
+ if [[ -z "$BODY" ]]; then
68
+ BODY=$(cat "$BODY_FILE")
69
+ fi
70
+ fi
71
+
72
+ PLATFORM=$(detect_platform)
73
+
74
+ if [[ "$PLATFORM" == "none" ]]; then
75
+ echo "No git platform detected. Set GITHUB_TOKEN or GITLAB_TOKEN, or install gh/glab CLI."
76
+ echo "Creating local tracking file instead."
77
+ mkdir -p .pi/.tracking
78
+ TRACKING_FILE=".pi/.tracking/issue-$(date +%s).md"
79
+ cat > "$TRACKING_FILE" << EOF
80
+ # $TITLE
81
+
82
+ $BODY
83
+
84
+ Labels: $LABELS
85
+ Milestone: $MILESTONE
86
+ Created: $(date -u +%Y-%m-%dT%H:%M:%SZ)
87
+ EOF
88
+ echo "TRACKING_ID=local:$(basename "$TRACKING_FILE")"
89
+ exit 0
90
+ fi
91
+
92
+ case "$PLATFORM" in
93
+ github)
94
+ # Build gh issue create command directly (no eval needed)
95
+ ARGS=()
96
+ [[ -n "$REPO" ]] && ARGS+=(--repo "$REPO")
97
+ [[ -n "$TITLE" ]] && ARGS+=(--title "$TITLE")
98
+ [[ -n "$MILESTONE" ]] && ARGS+=(--milestone "$MILESTONE")
99
+
100
+ # Body: strip YAML frontmatter from --body-file, then write to temp file for gh
101
+ if [[ -n "$BODY_FILE" && -f "$BODY_FILE" ]]; then
102
+ STRIPPED_BODY=$(awk '/^---$/{n++; next} n>=2{print}' "$BODY_FILE")
103
+ if [[ -n "$STRIPPED_BODY" ]]; then
104
+ TMP_BODY=$(mktemp /tmp/guardian-issue-XXXXXX.md)
105
+ echo "$STRIPPED_BODY" > "$TMP_BODY"
106
+ ARGS+=(--body-file "$TMP_BODY")
107
+ trap "rm -f '$TMP_BODY'" EXIT
108
+ else
109
+ ARGS+=(--body-file "$BODY_FILE")
110
+ fi
111
+ elif [[ -n "$BODY" ]]; then
112
+ ARGS+=(--body "$BODY")
113
+ fi
114
+
115
+ # Create issue (no labels — they may not exist on new repos)
116
+ ISSUE_OUTPUT=$(gh issue create "${ARGS[@]}" 2>&1) || ISSUE_OUTPUT=""
117
+
118
+ if [[ -z "$ISSUE_OUTPUT" ]] || [[ "$ISSUE_OUTPUT" == *"could not"* ]] || [[ "$ISSUE_OUTPUT" == *"GraphQL"* ]] || [[ "$ISSUE_OUTPUT" == *"must provide"* ]]; then
119
+ echo "Failed to create issue: $ISSUE_OUTPUT" >&2
120
+ echo "TRACKING_ID="
121
+ exit 1
122
+ fi
123
+
124
+ ISSUE_NUMBER=$(extract_number "$ISSUE_OUTPUT")
125
+
126
+ # Try to add labels separately (non-fatal)
127
+ if [[ -n "$LABELS" && -n "$ISSUE_NUMBER" ]]; then
128
+ gh issue edit "$ISSUE_NUMBER" --add-label "$LABELS" 2>/dev/null || true
129
+ fi
130
+
131
+ echo "TRACKING_ID=$ISSUE_NUMBER"
132
+ echo "TRACKING_URL=$ISSUE_OUTPUT"
133
+ ;;
134
+
135
+ gitlab)
136
+ ARGS=()
137
+ [[ -n "$REPO" ]] && ARGS+=(--repo "$REPO")
138
+ [[ -n "$TITLE" ]] && ARGS+=(--title "$TITLE")
139
+ [[ -n "$MILESTONE" ]] && ARGS+=(--milestone "$MILESTONE")
140
+
141
+ # Body: strip YAML frontmatter from --body-file, then write to temp file for glab
142
+ if [[ -n "$BODY_FILE" && -f "$BODY_FILE" ]]; then
143
+ STRIPPED_BODY=$(awk '/^---$/{n++; next} n>=2{print}' "$BODY_FILE")
144
+ if [[ -n "$STRIPPED_BODY" ]]; then
145
+ TMP_BODY=$(mktemp /tmp/guardian-issue-XXXXXX.md)
146
+ echo "$STRIPPED_BODY" > "$TMP_BODY"
147
+ ARGS+=(--description-file "$TMP_BODY")
148
+ trap "rm -f '$TMP_BODY'" EXIT
149
+ else
150
+ ARGS+=(--description-file "$BODY_FILE")
151
+ fi
152
+ elif [[ -n "$BODY" ]]; then
153
+ ARGS+=(--description "$BODY")
154
+ fi
155
+
156
+ ISSUE_OUTPUT=$(glab issue create "${ARGS[@]}" 2>&1) || ISSUE_OUTPUT=""
157
+
158
+ if [[ -z "$ISSUE_OUTPUT" ]]; then
159
+ echo "Failed to create issue" >&2
160
+ echo "TRACKING_ID="
161
+ exit 1
162
+ fi
163
+
164
+ ISSUE_NUMBER=$(extract_number "$ISSUE_OUTPUT")
165
+
166
+ # Try to add labels separately (non-fatal)
167
+ if [[ -n "$LABELS" && -n "$ISSUE_NUMBER" ]]; then
168
+ glab issue update "$ISSUE_NUMBER" --label "$LABELS" 2>/dev/null || true
169
+ fi
170
+
171
+ echo "TRACKING_ID=$ISSUE_NUMBER"
172
+ echo "TRACKING_URL=$ISSUE_OUTPUT"
173
+ ;;
174
+ esac
@@ -0,0 +1,51 @@
1
+ #!/usr/bin/env bash
2
+ # Git Wrapper: Link Issue to Epic
3
+ #
4
+ # Usage: bash .pi/scripts/git/link-issue-to-epic.sh \
5
+ # --issue-id 102 \
6
+ # --epic-id 101
7
+
8
+ set -euo pipefail
9
+
10
+ detect_platform() {
11
+ if [ -f "guardian-manifest.json" ]; then
12
+ local tool=$(jq -r '.repoTool // ""' guardian-manifest.json 2>/dev/null || echo "")
13
+ if [[ "$tool" == "glab" ]]; then echo "gitlab"; return; fi
14
+ if [[ "$tool" == "gh" ]]; then echo "github"; return; fi
15
+ fi
16
+ if [[ -n "${GIT_PLATFORM:-}" ]]; then echo "$GIT_PLATFORM"
17
+ elif command -v gh &>/dev/null && gh auth status &>/dev/null 2>&1; then echo "github"
18
+ elif command -v glab &>/dev/null && glab auth status &>/dev/null 2>&1; then echo "gitlab"
19
+ else echo "none"; fi
20
+ }
21
+
22
+ ISSUE_ID=""
23
+ EPIC_ID=""
24
+
25
+ while [[ $# -gt 0 ]]; do
26
+ case $1 in
27
+ --issue-id) ISSUE_ID="$2"; shift 2 ;;
28
+ --epic-id) EPIC_ID="$2"; shift 2 ;;
29
+ *) shift ;;
30
+ esac
31
+ done
32
+
33
+ [[ -z "$ISSUE_ID" || -z "$EPIC_ID" ]] && { echo "Usage: $0 --issue-id <issue> --epic-id <epic>"; exit 1; }
34
+ PLATFORM=$(detect_platform)
35
+
36
+ case "$PLATFORM" in
37
+ github)
38
+ # GitHub uses "closes #N" or "fixes #N" in issue body to link
39
+ gh issue edit "$ISSUE_ID" --body "$(gh issue view "$ISSUE_ID" --json body -q .body)
40
+
41
+ Relates to #$EPIC_ID" 2>/dev/null
42
+ echo "Linked GitHub issue #$ISSUE_ID to #$EPIC_ID"
43
+ ;;
44
+ gitlab)
45
+ glab issue update "$ISSUE_ID" --milestone "$EPIC_ID" 2>/dev/null
46
+ echo "Linked GitLab issue #$ISSUE_ID to epic #$EPIC_ID"
47
+ ;;
48
+ *)
49
+ echo "Linked local issue #$ISSUE_ID to epic #$EPIC_ID (no platform)"
50
+ ;;
51
+ esac
@@ -0,0 +1,66 @@
1
+ #!/usr/bin/env bash
2
+ # Git Wrapper: Update Tracking Issue
3
+ #
4
+ # Posts a progress update comment to a tracking issue.
5
+ #
6
+ # Usage: bash .pi/scripts/git/update-tracking-issue.sh \
7
+ # --id 100 \
8
+ # --comment "✓ Issue #102 complete (CI green, tests pass)"
9
+
10
+ set -euo pipefail
11
+
12
+ detect_platform() {
13
+ if [ -f "guardian-manifest.json" ]; then
14
+ local tool=$(jq -r '.repoTool // ""' guardian-manifest.json 2>/dev/null || echo "")
15
+ if [[ "$tool" == "glab" ]]; then echo "gitlab"; return; fi
16
+ if [[ "$tool" == "gh" ]]; then echo "github"; return; fi
17
+ fi
18
+ if [[ -n "${GIT_PLATFORM:-}" ]]; then echo "$GIT_PLATFORM"
19
+ elif command -v gh &>/dev/null && gh auth status &>/dev/null 2>&1; then echo "github"
20
+ elif command -v glab &>/dev/null && glab auth status &>/dev/null 2>&1; then echo "gitlab"
21
+ else echo "none"; fi
22
+ }
23
+
24
+ ISSUE_ID=""
25
+ COMMENT=""
26
+
27
+ while [[ $# -gt 0 ]]; do
28
+ case $1 in
29
+ --id) ISSUE_ID="$2"; shift 2 ;;
30
+ --comment) COMMENT="$2"; shift 2 ;;
31
+ *) shift ;;
32
+ esac
33
+ done
34
+
35
+ PLATFORM=$(detect_platform)
36
+
37
+ if [[ -z "$ISSUE_ID" || -z "$COMMENT" ]]; then
38
+ echo "Usage: $0 --id <issue_number> --comment <comment_text>"
39
+ exit 1
40
+ fi
41
+
42
+ # Handle local tracking files
43
+ if [[ "$ISSUE_ID" == local:* ]]; then
44
+ TRACKING_FILE=".pi/.tracking/$(echo "$ISSUE_ID" | cut -d: -f2)"
45
+ if [[ -f "$TRACKING_FILE" ]]; then
46
+ echo "" >> "$TRACKING_FILE"
47
+ echo "---" >> "$TRACKING_FILE"
48
+ echo "$COMMENT" >> "$TRACKING_FILE"
49
+ echo "Updated local tracking file: $TRACKING_FILE"
50
+ fi
51
+ exit 0
52
+ fi
53
+
54
+ case "$PLATFORM" in
55
+ github)
56
+ gh issue comment "$ISSUE_ID" --body "$COMMENT" 2>/dev/null && echo "Comment posted to GitHub issue #$ISSUE_ID"
57
+ ;;
58
+ gitlab)
59
+ glab issue note "$ISSUE_ID" --message "$COMMENT" 2>/dev/null && echo "Comment posted to GitLab issue #$ISSUE_ID"
60
+ ;;
61
+ none)
62
+ echo "No git platform detected. Comment not posted."
63
+ echo " Issue: #$ISSUE_ID"
64
+ echo " Comment: $COMMENT"
65
+ ;;
66
+ esac
@@ -0,0 +1,139 @@
1
+ #!/usr/bin/env bash
2
+ # ============================================================================
3
+ # validate-architecture.sh — Go
4
+ # ============================================================================
5
+ set -euo pipefail
6
+
7
+ SRC_DIR="${1:-.}"
8
+ PASS_COUNT=0; ERRORS=(); WARNINGS=()
9
+ RED='\033[0;31m'; GREEN='\033[0;32m'; YELLOW='\033[1;33m'; NC='\033[0m'
10
+ pass() { echo -e "${GREEN}✅ PASS${NC} $1"; PASS_COUNT=$((PASS_COUNT + 1)); }
11
+ fail() { echo -e "${RED}❌ FAIL${NC} $1"; ERRORS+=("$1"); }
12
+ warn() { echo -e "${YELLOW}⚠️ WARN${NC} $1"; WARNINGS+=("$1"); }
13
+
14
+ echo "============================================"
15
+ echo " Architecture Validation (Go)"
16
+ echo "============================================"
17
+ echo ""
18
+
19
+ # ---------------------------------------------------------------------------
20
+ # Layer Structure
21
+ # ---------------------------------------------------------------------------
22
+ echo "--- Layer Structure ---"
23
+ HAS_INTERNAL=false
24
+ HAS_PKG=false
25
+ [ -d "internal" ] && HAS_INTERNAL=true
26
+ [ -d "pkg" ] && HAS_PKG=true
27
+ if [ "$HAS_INTERNAL" = true ] && [ "$HAS_PKG" = true ]; then
28
+ pass "Domain (internal/) and shared (pkg/) layers present"
29
+ elif [ "$HAS_INTERNAL" = true ]; then
30
+ pass "Internal layer present (clean architecture pattern)"
31
+ elif [ "$HAS_PKG" = true ]; then
32
+ pass "Pkg layer present (shared library pattern)"
33
+ else
34
+ warn "No internal/ or pkg/ directory (consider Go clean architecture layout)"
35
+ fi
36
+
37
+ # ---------------------------------------------------------------------------
38
+ # Canonical References
39
+ # ---------------------------------------------------------------------------
40
+ echo ""
41
+ echo "--- Canonical References ---"
42
+ if [ -d ".pi/architecture/modules" ]; then
43
+ MODULE_COUNT=$(find .pi/architecture/modules -name "*.md" 2>/dev/null | wc -l | tr -d ' ')
44
+ pass "Canonical architecture documents found ($MODULE_COUNT modules)"
45
+ else
46
+ warn "No canonical architecture directory (.pi/architecture/modules) found"
47
+ fi
48
+
49
+ # ---------------------------------------------------------------------------
50
+ # Domain Models
51
+ # ---------------------------------------------------------------------------
52
+ echo ""
53
+ echo "--- Domain Models ---"
54
+ DOMAIN_FILES=0
55
+ for dir in "internal/domain" "pkg/domain"; do
56
+ if [ -d "$dir" ]; then
57
+ COUNT=$(grep -rlE 'type\s+\w+\s+struct' "$dir" --include="*.go" 2>/dev/null | wc -l | tr -d ' ')
58
+ DOMAIN_FILES=$((DOMAIN_FILES + COUNT))
59
+ fi
60
+ done
61
+ if [ "$DOMAIN_FILES" -gt 0 ]; then
62
+ pass "Domain model struct definitions found ($DOMAIN_FILES files)"
63
+ else
64
+ warn "No domain model struct definitions in internal/domain/ or pkg/domain/"
65
+ fi
66
+
67
+ # ---------------------------------------------------------------------------
68
+ # Dependency Direction
69
+ # ---------------------------------------------------------------------------
70
+ echo ""
71
+ echo "--- Dependency Direction ---"
72
+ VIOLATIONS=0
73
+ for dir in "internal/domain" "pkg/domain"; do
74
+ if [ -d "$dir" ]; then
75
+ # Domain should not import from infrastructure or cmd
76
+ VIOLATIONS=$((VIOLATIONS + $(grep -rlE 'import.*"(.*/infrastructure|/cmd)"' "$dir" --include="*.go" 2>/dev/null | wc -l | tr -d ' ')))
77
+ fi
78
+ done
79
+ if [ "$VIOLATIONS" -eq 0 ]; then
80
+ pass "Domain layer has no infrastructure/cmd import violations"
81
+ else
82
+ fail "Domain layer imports from infrastructure/cmd ($VIOLATIONS violations)"
83
+ fi
84
+
85
+ # ---------------------------------------------------------------------------
86
+ # Error Handling
87
+ # ---------------------------------------------------------------------------
88
+ echo ""
89
+ echo "--- Error Handling ---"
90
+ if [ -f "go.mod" ]; then
91
+ ERROR_VARIABS=$(grep -rE 'var\s+Err\w+\s*=\s*(errors\.New|fmt\.Errorf)' . --include="*.go" 2>/dev/null | wc -l | tr -d ' ')
92
+ ERROR_STRUCTS=$(grep -rE 'type\s+\w*Error\w*\s+struct' . --include="*.go" 2>/dev/null | wc -l | tr -d ' ')
93
+ TOTAL=$((ERROR_VARIABS + ERROR_STRUCTS))
94
+ if [ "$TOTAL" -gt 0 ]; then
95
+ pass "Custom error types defined ($TOTAL definitions)"
96
+ else
97
+ warn "No custom error types found (consider using sentinel errors or error types)"
98
+ fi
99
+ else
100
+ warn "Not in a Go module, skipping error handling check"
101
+ fi
102
+
103
+ # ---------------------------------------------------------------------------
104
+ # Interfaces
105
+ # ---------------------------------------------------------------------------
106
+ echo ""
107
+ echo "--- Interfaces ---"
108
+ if [ -f "go.mod" ]; then
109
+ INTERFACE_COUNT=$(grep -rE 'type\s+\w+\s+interface' . --include="*.go" 2>/dev/null | wc -l | tr -d ' ')
110
+ if [ "$INTERFACE_COUNT" -gt 0 ]; then
111
+ pass "Interface definitions found ($INTERFACE_COUNT interfaces)"
112
+ else
113
+ warn "No interface definitions found (consider defining contracts)"
114
+ fi
115
+ else
116
+ warn "Not in a Go module, skipping interface check"
117
+ fi
118
+
119
+ # ---------------------------------------------------------------------------
120
+ # Summary
121
+ # ---------------------------------------------------------------------------
122
+ echo ""
123
+ echo "============================================"
124
+ echo " Summary"
125
+ echo "============================================"
126
+ echo -e " Passed: ${GREEN}${PASS_COUNT}${NC}"
127
+ echo -e " Failed: ${RED}${#ERRORS[@]}${NC}"
128
+ echo ""
129
+
130
+ if [ ${#ERRORS[@]} -gt 0 ]; then
131
+ echo "FAILURES:"
132
+ for err in "${ERRORS[@]}"; do
133
+ echo " - $err"
134
+ done
135
+ exit 1
136
+ fi
137
+
138
+ echo -e "${GREEN}Architecture validation passed.${NC}"
139
+ exit 0
@@ -0,0 +1,129 @@
1
+ #!/usr/bin/env bash
2
+ # ============================================================================
3
+ # validate-canonical.sh — Go
4
+ # ============================================================================
5
+ set -euo pipefail
6
+
7
+ PASS_COUNT=0; ERRORS=(); WARNINGS=()
8
+ RED='\033[0;31m'; GREEN='\033[0;32m'; YELLOW='\033[1;33m'; NC='\033[0m'
9
+ pass() { echo -e "${GREEN}✅ PASS${NC} $1"; PASS_COUNT=$((PASS_COUNT + 1)); }
10
+ fail() { echo -e "${RED}❌ FAIL${NC} $1"; ERRORS+=("$1"); }
11
+ warn() { echo -e "${YELLOW}⚠️ WARN${NC} $1"; WARNINGS+=("$1"); }
12
+
13
+ echo "============================================"
14
+ echo " Canonical Reference Validation (Go)"
15
+ echo "============================================"
16
+ echo ""
17
+
18
+ # ---------------------------------------------------------------------------
19
+ # Architecture Reference Tracing
20
+ # ---------------------------------------------------------------------------
21
+ echo "--- Architecture Reference Tracing ---"
22
+ if [ -f "go.mod" ]; then
23
+ GO_FILES=$(find . -name "*.go" -not -path "./vendor/*" 2>/dev/null | wc -l | tr -d ' ')
24
+ if [ "$GO_FILES" -gt 0 ]; then
25
+ CANONICAL_REFS=$(grep -rlE '//\s*(Canonical:|@canonical|Reference:|Canonical\s+ref)' . --include="*.go" 2>/dev/null | wc -l | tr -d ' ')
26
+ if [ "$CANONICAL_REFS" -gt 0 ]; then
27
+ PCT=$((CANONICAL_REFS * 100 / GO_FILES))
28
+ pass "Canonical references found in ${CANONICAL_REFS}/${GO_FILES} Go files (${PCT}%)"
29
+ else
30
+ fail "No canonical reference comments (// Canonical: or // @canonical) found"
31
+ fi
32
+ else
33
+ pass "No Go source files to check"
34
+ fi
35
+ else
36
+ warn "Not in a Go module, skipping reference tracing"
37
+ fi
38
+
39
+ # ---------------------------------------------------------------------------
40
+ # Module-to-Implementation Mapping
41
+ # ---------------------------------------------------------------------------
42
+ echo ""
43
+ echo "--- Module-to-Implementation Mapping ---"
44
+ if [ -d ".pi/architecture/modules" ]; then
45
+ MAPPED=0
46
+ TOTAL=0
47
+ for md in .pi/architecture/modules/*.md; do
48
+ [ -f "$md" ] || continue
49
+ TOTAL=$((TOTAL + 1))
50
+ # Extract module name from filename (strip .md and path)
51
+ MODULE_NAME=$(basename "$md" .md)
52
+ # Check if any Go file path contains the module name component
53
+ if find . -name "*.go" -not -path "./vendor/*" 2>/dev/null | grep -qi "/${MODULE_NAME}"; then
54
+ MAPPED=$((MAPPED + 1))
55
+ fi
56
+ done
57
+ if [ "$TOTAL" -gt 0 ]; then
58
+ PCT=$((MAPPED * 100 / TOTAL))
59
+ if [ "$MAPPED" -eq "$TOTAL" ]; then
60
+ pass "All $TOTAL modules have matching Go implementations"
61
+ else
62
+ warn "$MAPPED/$TOTAL modules mapped to Go files (${PCT}%)"
63
+ fi
64
+ else
65
+ pass "No architecture modules to map"
66
+ fi
67
+ else
68
+ warn "No canonical architecture modules directory found"
69
+ fi
70
+
71
+ # ---------------------------------------------------------------------------
72
+ # Package Documentation
73
+ # ---------------------------------------------------------------------------
74
+ echo ""
75
+ echo "--- Package Documentation ---"
76
+ if [ -f "go.mod" ]; then
77
+ PKG_FILES_WITH_DOC=$(grep -rlE '//\s*Package\s+\w+\s+(implements|provides|defines|is|contains)' . --include="*.go" 2>/dev/null | wc -l | tr -d ' ')
78
+ GO_PACKAGES=$(go list ./... 2>/dev/null | wc -l | tr -d ' ')
79
+ if [ "$GO_PACKAGES" -gt 0 ] && [ "$PKG_FILES_WITH_DOC" -gt 0 ]; then
80
+ pass "Package documentation found in $PKG_FILES_WITH_DOC files"
81
+ else
82
+ warn "No package-level doc comments found (// Package X implements...)"
83
+ fi
84
+ else
85
+ warn "Not in a Go module, skipping package doc check"
86
+ fi
87
+
88
+ # ---------------------------------------------------------------------------
89
+ # ADR Linkage
90
+ # ---------------------------------------------------------------------------
91
+ echo ""
92
+ echo "--- ADR Linkage ---"
93
+ if [ -d ".pi/architecture/decisions" ]; then
94
+ ADR_COUNT=$(find .pi/architecture/decisions -name "*.md" 2>/dev/null | wc -l | tr -d ' ')
95
+ if [ "$ADR_COUNT" -gt 0 ]; then
96
+ ADR_REFS=$(grep -rlE '//\s*ADR[-_]?\d+' . --include="*.go" 2>/dev/null | wc -l | tr -d ' ')
97
+ if [ "$ADR_REFS" -gt 0 ]; then
98
+ pass "ADR references found in $ADR_REFS Go files"
99
+ else
100
+ warn "No ADR references in code ($ADR_COUNT decisions exist)"
101
+ fi
102
+ else
103
+ pass "No ADRs to link to"
104
+ fi
105
+ else
106
+ warn "No ADR directory (.pi/architecture/decisions) found"
107
+ fi
108
+
109
+ # ---------------------------------------------------------------------------
110
+ # Summary
111
+ # ---------------------------------------------------------------------------
112
+ echo ""
113
+ echo "============================================"
114
+ echo " Summary"
115
+ echo "============================================"
116
+ echo -e " Passed: ${GREEN}${PASS_COUNT}${NC}"
117
+ echo -e " Failed: ${RED}${#ERRORS[@]}${NC}"
118
+ echo ""
119
+
120
+ if [ ${#ERRORS[@]} -gt 0 ]; then
121
+ echo "FAILURES:"
122
+ for err in "${ERRORS[@]}"; do
123
+ echo " - $err"
124
+ done
125
+ exit 1
126
+ fi
127
+
128
+ echo -e "${GREEN}Canonical reference validation passed.${NC}"
129
+ exit 0