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,135 @@
1
+ #!/usr/bin/env bash
2
+ # ============================================================================
3
+ # validate-canonical.sh — TypeScript
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 Validation (TypeScript)"
15
+ echo "============================================"
16
+ echo ""
17
+
18
+ SRC_DIR="${1:-src}"
19
+
20
+ # ---------------------------------------------------------------------------
21
+ # Architecture Reference Tracing
22
+ # ---------------------------------------------------------------------------
23
+ echo "--- Architecture Reference Tracing ---"
24
+ CANONICAL_REFS=0
25
+ TOTAL_TS_FILES=0
26
+ if [ -d "$SRC_DIR" ]; then
27
+ TOTAL_TS_FILES=$(find "$SRC_DIR" -name "*.ts" -o -name "*.tsx" 2>/dev/null | wc -l | tr -d ' ')
28
+ CANONICAL_REFS=$(find "$SRC_DIR" -type f \( -name "*.ts" -o -name "*.tsx" \) -exec grep -lE '(// Canonical:|@canonical).*\.pi/architecture/' {} + 2>/dev/null | wc -l | tr -d ' ')
29
+ if [ "$TOTAL_TS_FILES" -gt 0 ] && [ "$CANONICAL_REFS" -gt 0 ]; then
30
+ PCT=$((CANONICAL_REFS * 100 / TOTAL_TS_FILES))
31
+ pass "Canonical references found: $CANONICAL_REFS / $TOTAL_TS_FILES files ($PCT%)"
32
+ elif [ "$TOTAL_TS_FILES" -gt 0 ]; then
33
+ fail "No canonical references found in $TOTAL_TS_FILES TypeScript files"
34
+ else
35
+ warn "No TypeScript source files found"
36
+ fi
37
+ else
38
+ warn "No source directory found, skipping canonical reference check"
39
+ fi
40
+
41
+ # ---------------------------------------------------------------------------
42
+ # Module-to-Implementation Mapping
43
+ # ---------------------------------------------------------------------------
44
+ echo ""
45
+ echo "--- Module-to-Implementation Mapping ---"
46
+ if [ -d ".pi/architecture/modules" ]; then
47
+ MAPPED=0
48
+ UNMAPPED=0
49
+ for module_doc in .pi/architecture/modules/*.md; do
50
+ [ -f "$module_doc" ] || continue
51
+ MODULE_NAME=$(basename "$module_doc" .md)
52
+ # Look for matching TS files (by convention: module name maps to src/<module>/ or similar)
53
+ if find "$SRC_DIR" -type f \( -name "*.ts" -o -name "*.tsx" \) 2>/dev/null | grep -qi "$MODULE_NAME" 2>/dev/null; then
54
+ MAPPED=$((MAPPED + 1))
55
+ else
56
+ UNMAPPED=$((UNMAPPED + 1))
57
+ fi
58
+ done
59
+ TOTAL_MODULES=$((MAPPED + UNMAPPED))
60
+ if [ "$UNMAPPED" -eq 0 ] && [ "$MAPPED" -gt 0 ]; then
61
+ pass "All $TOTAL_MODULES architecture modules have implementation files"
62
+ elif [ "$MAPPED" -gt 0 ]; then
63
+ pass "Mapped: $MAPPED/$TOTAL_MODULES modules (check $UNMAPPED unmapped)"
64
+ else
65
+ fail "No architecture modules mapped to implementation"
66
+ fi
67
+ else
68
+ warn "No .pi/architecture/modules directory found"
69
+ fi
70
+
71
+ # ---------------------------------------------------------------------------
72
+ # Module Documentation
73
+ # ---------------------------------------------------------------------------
74
+ echo ""
75
+ echo "--- Module Documentation ---"
76
+ if [ -d "$SRC_DIR" ]; then
77
+ EXPORT_WITH_DOCS=0
78
+ EXPORTS_TOTAL=0
79
+ # Check for documented exports: JSDoc comment (/** ... */) immediately before export
80
+ EXPORTS_TOTAL=$(grep -rE "^\s*(export\s+(const|function|class|interface|type|default))" "$SRC_DIR" --include="*.ts" --include="*.tsx" 2>/dev/null | wc -l | tr -d ' ')
81
+ EXPORT_WITH_DOCS=$(grep -B1 -rE "^\s*(export\s+(const|function|class|interface|type|default))" "$SRC_DIR" --include="*.ts" --include="*.tsx" 2>/dev/null | grep -c '\*/' 2>/dev/null || echo "0")
82
+ if [ "$EXPORTS_TOTAL" -gt 0 ]; then
83
+ if [ "$EXPORT_WITH_DOCS" -gt 0 ]; then
84
+ PCT=$((EXPORT_WITH_DOCS * 100 / EXPORTS_TOTAL))
85
+ pass "Documented exports: $EXPORT_WITH_DOCS / $EXPORTS_TOTAL ($PCT%)"
86
+ else
87
+ warn "No exports have JSDoc documentation"
88
+ fi
89
+ else
90
+ pass "No public exports found, nothing to document"
91
+ fi
92
+ else
93
+ warn "No source directory found, skipping documentation check"
94
+ fi
95
+
96
+ # ---------------------------------------------------------------------------
97
+ # ADR Linkage
98
+ # ---------------------------------------------------------------------------
99
+ echo ""
100
+ echo "--- ADR Linkage ---"
101
+ if [ -d ".pi/architecture/decisions" ]; then
102
+ ADR_FILES=$(find .pi/architecture/decisions -name "*.md" 2>/dev/null | wc -l | tr -d ' ')
103
+ ADR_REFS=$(find "$SRC_DIR" -type f \( -name "*.ts" -o -name "*.tsx" \) -exec grep -rlE '(@adr|ADR-)' {} + 2>/dev/null | wc -l | tr -d ' ')
104
+ if [ "$ADR_FILES" -gt 0 ] && [ "$ADR_REFS" -gt 0 ]; then
105
+ pass "ADR references found: $ADR_REFS files link to $ADR_FILES decisions"
106
+ elif [ "$ADR_FILES" -gt 0 ]; then
107
+ warn "No ADR references in code ($ADR_FILES decisions exist)"
108
+ else
109
+ warn "No ADR directory found"
110
+ fi
111
+ else
112
+ warn "No .pi/architecture/decisions directory found"
113
+ fi
114
+
115
+ # ---------------------------------------------------------------------------
116
+ # Summary
117
+ # ---------------------------------------------------------------------------
118
+ echo ""
119
+ echo "============================================"
120
+ echo " Summary"
121
+ echo "============================================"
122
+ echo -e " Passed: ${GREEN}${PASS_COUNT}${NC}"
123
+ echo -e " Failed: ${RED}${#ERRORS[@]}${NC}"
124
+ echo ""
125
+
126
+ if [ ${#ERRORS[@]} -gt 0 ]; then
127
+ echo "FAILURES:"
128
+ for err in "${ERRORS[@]}"; do
129
+ echo " - $err"
130
+ done
131
+ exit 1
132
+ fi
133
+
134
+ echo -e "${GREEN}Canonical validation passed.${NC}"
135
+ exit 0
@@ -0,0 +1,244 @@
1
+ #!/usr/bin/env bash
2
+ # ============================================================================
3
+ # validate-ci.sh — TypeScript
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 " CI/MR Validation (TypeScript)"
15
+ echo "============================================"
16
+ echo ""
17
+
18
+ # Detect package manager
19
+ PKG_MGR=""
20
+ if [ -f "bun.lock" ] || [ -f "bun.lockb" ]; then
21
+ PKG_MGR="bun"
22
+ elif [ -f "yarn.lock" ]; then
23
+ PKG_MGR="yarn"
24
+ elif [ -f "package-lock.json" ]; then
25
+ PKG_MGR="npm"
26
+ fi
27
+
28
+ # ---------------------------------------------------------------------------
29
+ # Build
30
+ # ---------------------------------------------------------------------------
31
+ echo "--- Build ---"
32
+ if [ ! -f "package.json" ]; then
33
+ warn "No package.json found, skipping build"
34
+ else
35
+ if [ -f "tsconfig.json" ]; then
36
+ if command -v npx &>/dev/null; then
37
+ if npx tsc --noEmit 2>/dev/null; then
38
+ pass "TypeScript compilation succeeded (tsc --noEmit)"
39
+ else
40
+ fail "TypeScript compilation failed"
41
+ fi
42
+ else
43
+ warn "tsc not available, skipping type check"
44
+ fi
45
+ elif [ -f "bun.lock" ] || [ -f "bun.lockb" ] && command -v bun &>/dev/null; then
46
+ if bun build 2>/dev/null; then
47
+ pass "Build succeeded (bun build)"
48
+ else
49
+ fail "Build failed (bun build)"
50
+ fi
51
+ else
52
+ if [ "$PKG_MGR" = "bun" ] && command -v bun &>/dev/null; then
53
+ if bun run build 2>/dev/null; then
54
+ pass "Build succeeded (bun run build)"
55
+ else
56
+ fail "Build failed (bun run build)"
57
+ fi
58
+ elif command -v npm &>/dev/null && grep -q '"build"' package.json 2>/dev/null; then
59
+ if npm run build 2>/dev/null; then
60
+ pass "Build succeeded (npm run build)"
61
+ else
62
+ fail "Build failed (npm run build)"
63
+ fi
64
+ else
65
+ pass "No build script defined, skipping build"
66
+ fi
67
+ fi
68
+ fi
69
+
70
+ # ---------------------------------------------------------------------------
71
+ # Tests
72
+ # ---------------------------------------------------------------------------
73
+ echo ""
74
+ echo "--- Tests ---"
75
+ if [ ! -f "package.json" ]; then
76
+ pass "No package.json, skipping tests"
77
+ elif [ "$PKG_MGR" = "bun" ] && command -v bun &>/dev/null; then
78
+ if bun test 2>/dev/null; then
79
+ pass "All tests passed (bun test)"
80
+ else
81
+ fail "Tests failed (bun test)"
82
+ fi
83
+ elif grep -q '"test"' package.json 2>/dev/null; then
84
+ if [ "$PKG_MGR" = "yarn" ] && command -v yarn &>/dev/null; then
85
+ if yarn test 2>/dev/null; then
86
+ pass "All tests passed (yarn test)"
87
+ else
88
+ fail "Tests failed (yarn test)"
89
+ fi
90
+ elif command -v npm &>/dev/null; then
91
+ if npm test 2>/dev/null; then
92
+ pass "All tests passed (npm test)"
93
+ else
94
+ fail "Tests failed (npm test)"
95
+ fi
96
+ else
97
+ warn "No package manager available to run tests"
98
+ fi
99
+ elif command -v npx &>/dev/null; then
100
+ if npx vitest run 2>/dev/null; then
101
+ pass "All tests passed (npx vitest run)"
102
+ elif npx jest --passWithNoTests 2>/dev/null; then
103
+ pass "All tests passed (npx jest)"
104
+ else
105
+ pass "No test runner detected, skipping tests"
106
+ fi
107
+ else
108
+ pass "No test runner available, skipping tests"
109
+ fi
110
+
111
+ # ---------------------------------------------------------------------------
112
+ # Lint
113
+ # ---------------------------------------------------------------------------
114
+ echo ""
115
+ echo "--- Lint ---"
116
+ if [ -f "biome.json" ] && (command -v biome &>/dev/null || command -v npx &>/dev/null); then
117
+ if command -v biome &>/dev/null; then
118
+ if biome check . 2>/dev/null; then
119
+ pass "Lint passed (biome check)"
120
+ else
121
+ fail "Lint failed (biome check)"
122
+ fi
123
+ elif npx biome check . 2>/dev/null; then
124
+ pass "Lint passed (npx biome check)"
125
+ else
126
+ fail "Lint failed (npx biome check)"
127
+ fi
128
+ elif [ -f ".eslintrc" ] || [ -f ".eslintrc.json" ] || [ -f ".eslintrc.js" ] || [ -f ".eslintrc.yaml" ] || [ -f ".eslintrc.yml" ] || [ -f "eslint.config.js" ] || [ -f "eslint.config.mjs" ] || [ -f "eslint.config.ts" ] || grep -q '"eslintConfig"' package.json 2>/dev/null; then
129
+ if command -v eslint &>/dev/null; then
130
+ if eslint . 2>/dev/null; then
131
+ pass "Lint passed (eslint)"
132
+ else
133
+ fail "Lint failed (eslint)"
134
+ fi
135
+ elif command -v npx &>/dev/null; then
136
+ if npx eslint . 2>/dev/null; then
137
+ pass "Lint passed (npx eslint)"
138
+ else
139
+ fail "Lint failed (npx eslint)"
140
+ fi
141
+ else
142
+ warn "eslint not available, skipping lint"
143
+ fi
144
+ else
145
+ warn "No linter configuration detected, skipping lint"
146
+ fi
147
+
148
+ # ---------------------------------------------------------------------------
149
+ # Format
150
+ # ---------------------------------------------------------------------------
151
+ echo ""
152
+ echo "--- Format ---"
153
+ if [ -f "biome.json" ]; then
154
+ if command -v biome &>/dev/null; then
155
+ if biome format . --check 2>/dev/null; then
156
+ pass "Format check passed (biome format)"
157
+ else
158
+ fail "Format check failed (biome format)"
159
+ fi
160
+ elif command -v npx &>/dev/null; then
161
+ if npx biome format . --check 2>/dev/null; then
162
+ pass "Format check passed (npx biome format)"
163
+ else
164
+ fail "Format check failed (npx biome format)"
165
+ fi
166
+ else
167
+ warn "biome not available, skipping format check"
168
+ fi
169
+ elif [ -f ".prettierrc" ] || [ -f ".prettierrc.json" ] || [ -f ".prettierrc.yaml" ] || [ -f ".prettierrc.yml" ] || [ -f ".prettierrc.js" ] || [ -f ".prettierrc.cjs" ] || [ -f ".prettierrc.mjs" ] || grep -q '"prettier"' package.json 2>/dev/null; then
170
+ if command -v prettier &>/dev/null; then
171
+ if prettier --check . 2>/dev/null; then
172
+ pass "Format check passed (prettier)"
173
+ else
174
+ fail "Format check failed (prettier)"
175
+ fi
176
+ elif command -v npx &>/dev/null; then
177
+ if npx prettier --check . 2>/dev/null; then
178
+ pass "Format check passed (npx prettier)"
179
+ else
180
+ fail "Format check failed (npx prettier)"
181
+ fi
182
+ else
183
+ warn "prettier not available, skipping format check"
184
+ fi
185
+ else
186
+ warn "No formatter configuration detected, skipping format check"
187
+ fi
188
+
189
+ # ---------------------------------------------------------------------------
190
+ # Security Audit
191
+ # ---------------------------------------------------------------------------
192
+ echo ""
193
+ echo "--- Security Audit ---"
194
+ if [ "$PKG_MGR" = "bun" ] && command -v bun &>/dev/null; then
195
+ AUDIT_OUT=$(bun audit 2>&1 || true)
196
+ CRITICAL_COUNT=$(echo "$AUDIT_OUT" | grep -ci "critical" 2>/dev/null || echo "0")
197
+ HIGH_COUNT=$(echo "$AUDIT_OUT" | grep -ci "high" 2>/dev/null || echo "0")
198
+ if [ "$CRITICAL_COUNT" -gt 0 ] || [ "$HIGH_COUNT" -gt 0 ]; then
199
+ fail "Security audit found critical/high vulnerabilities"
200
+ else
201
+ MODERATE_COUNT=$(echo "$AUDIT_OUT" | grep -ci "moderate" 2>/dev/null || echo "0")
202
+ if [ "$MODERATE_COUNT" -gt 0 ]; then
203
+ warn "Security audit found moderate vulnerabilities (review recommended)"
204
+ else
205
+ pass "No critical or high vulnerabilities found"
206
+ fi
207
+ fi
208
+ elif command -v npm &>/dev/null; then
209
+ AUDIT_OUT=$(npm audit 2>&1 || true)
210
+ if echo "$AUDIT_OUT" | grep -q "found 0 vulnerabilities" 2>/dev/null; then
211
+ pass "No vulnerabilities found"
212
+ else
213
+ CRITICAL_HIGH=$(echo "$AUDIT_OUT" | grep -E "(critical|high).*vulnerab" 2>/dev/null | head -1 || true)
214
+ if [ -n "$CRITICAL_HIGH" ]; then
215
+ fail "Security audit found critical/high vulnerabilities"
216
+ else
217
+ warn "Security audit reported findings (review manually)"
218
+ fi
219
+ fi
220
+ else
221
+ warn "No package manager available for security audit"
222
+ fi
223
+
224
+ # ---------------------------------------------------------------------------
225
+ # Summary
226
+ # ---------------------------------------------------------------------------
227
+ echo ""
228
+ echo "============================================"
229
+ echo " Summary"
230
+ echo "============================================"
231
+ echo -e " Passed: ${GREEN}${PASS_COUNT}${NC}"
232
+ echo -e " Failed: ${RED}${#ERRORS[@]}${NC}"
233
+ echo ""
234
+
235
+ if [ ${#ERRORS[@]} -gt 0 ]; then
236
+ echo "FAILURES:"
237
+ for err in "${ERRORS[@]}"; do
238
+ echo " - $err"
239
+ done
240
+ exit 1
241
+ fi
242
+
243
+ echo -e "${GREEN}All CI checks passed.${NC}"
244
+ exit 0
@@ -0,0 +1,166 @@
1
+ #!/usr/bin/env bash
2
+ # ============================================================================
3
+ # validate-integration.sh — TypeScript
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 " Integration Validation (TypeScript)"
15
+ echo "============================================"
16
+ echo ""
17
+
18
+ # Detect package manager
19
+ PKG_MGR=""
20
+ if [ -f "bun.lock" ] || [ -f "bun.lockb" ]; then
21
+ PKG_MGR="bun"
22
+ elif [ -f "yarn.lock" ]; then
23
+ PKG_MGR="yarn"
24
+ elif [ -f "package-lock.json" ]; then
25
+ PKG_MGR="npm"
26
+ fi
27
+
28
+ # ---------------------------------------------------------------------------
29
+ # Integration Test Runner
30
+ # ---------------------------------------------------------------------------
31
+ echo "--- Integration Test Runner ---"
32
+ if [ -d "tests/integration" ] || [ -d "test/integration" ]; then
33
+ INT_DIR=""
34
+ if [ -d "tests/integration" ]; then
35
+ INT_DIR="tests/integration"
36
+ elif [ -d "test/integration" ]; then
37
+ INT_DIR="test/integration"
38
+ fi
39
+
40
+ if [ "$PKG_MGR" = "bun" ] && command -v bun &>/dev/null; then
41
+ if bun test "$INT_DIR" 2>/dev/null; then
42
+ pass "Integration tests passed (bun test)"
43
+ else
44
+ fail "Integration tests failed (bun test)"
45
+ fi
46
+ elif command -v npx &>/dev/null; then
47
+ if npx vitest run "$INT_DIR" 2>/dev/null; then
48
+ pass "Integration tests passed (npx vitest)"
49
+ elif npx jest "$INT_DIR" 2>/dev/null; then
50
+ pass "Integration tests passed (npx jest)"
51
+ else
52
+ fail "Integration tests failed"
53
+ fi
54
+ else
55
+ warn "No test runner available for integration tests"
56
+ fi
57
+ else
58
+ pass "No integration test directory (skipped)"
59
+ fi
60
+
61
+ # ---------------------------------------------------------------------------
62
+ # Docker/Compose
63
+ # ---------------------------------------------------------------------------
64
+ echo ""
65
+ echo "--- Docker/Compose ---"
66
+ if [ -f "docker-compose.yml" ] || [ -f "docker-compose.yaml" ]; then
67
+ SERVICES=$(grep -E "^\s{2}\w+:" docker-compose.yml 2>/dev/null | grep -vE "^\s{2}version:|^\s{2}services:" | wc -l | tr -d ' ')
68
+ if [ -f "docker-compose.yaml" ] && [ "$SERVICES" -eq 0 ]; then
69
+ SERVICES=$(grep -E "^\s{2}\w+:" docker-compose.yaml 2>/dev/null | grep -vE "^\s{2}version:|^\s{2}services:" | wc -l | tr -d ' ')
70
+ fi
71
+ pass "Docker Compose found ($SERVICES services — integration tests may require running services)"
72
+ else
73
+ pass "No Docker Compose configuration"
74
+ fi
75
+
76
+ # ---------------------------------------------------------------------------
77
+ # Contract Tests
78
+ # ---------------------------------------------------------------------------
79
+ echo ""
80
+ echo "--- Contract Tests ---"
81
+ CONTRACT_FILES=0
82
+ for dir in tests test; do
83
+ if [ -d "$dir" ]; then
84
+ COUNT=$(find "$dir" -name "*.contract.test.ts" -o -name "*.contract.test.tsx" 2>/dev/null | wc -l | tr -d ' ')
85
+ CONTRACT_FILES=$((CONTRACT_FILES + COUNT))
86
+ fi
87
+ done
88
+ if [ "$CONTRACT_FILES" -gt 0 ]; then
89
+ pass "Contract test files found ($CONTRACT_FILES)"
90
+ else
91
+ pass "No contract test files (*.contract.test.ts)"
92
+ fi
93
+
94
+ # ---------------------------------------------------------------------------
95
+ # Mock/Stub Detection
96
+ # ---------------------------------------------------------------------------
97
+ echo ""
98
+ echo "--- Mock/Stub Detection ---"
99
+ MOCK_USAGE=0
100
+ for ext in ts tsx; do
101
+ COUNT=$(find . -name "*.$ext" -not -path "./node_modules/*" -not -path "./dist/*" \
102
+ -exec grep -lE "(vitest\.mock|jest\.mock|from\s+['\"]msw['\"]|from\s+['\"]@testing-library)" {} + 2>/dev/null | wc -l | tr -d ' ')
103
+ MOCK_USAGE=$((MOCK_USAGE + COUNT))
104
+ done
105
+ if [ "$MOCK_USAGE" -gt 0 ]; then
106
+ pass "Mock/stub usage detected ($MOCK_USAGE files with vitest.mock, jest.mock, msw, or @testing-library)"
107
+ else
108
+ warn "No mocking libraries detected (vitest.mock, jest.mock, msw)"
109
+ fi
110
+
111
+ # ---------------------------------------------------------------------------
112
+ # Database Integration
113
+ # ---------------------------------------------------------------------------
114
+ echo ""
115
+ echo "--- Database Integration ---"
116
+ DB_INTEGRATION_FILES=0
117
+ for dir in tests test; do
118
+ if [ -d "$dir" ]; then
119
+ COUNT=$(find "$dir" -name "*_integration.test.ts" -o -name "*_integration.test.tsx" -o -name "*.db.test.ts" -o -name "*.db.test.tsx" 2>/dev/null | wc -l | tr -d ' ')
120
+ DB_INTEGRATION_FILES=$((DB_INTEGRATION_FILES + COUNT))
121
+ fi
122
+ done
123
+ if [ "$DB_INTEGRATION_FILES" -gt 0 ]; then
124
+ pass "Database integration test files found ($DB_INTEGRATION_FILES)"
125
+ else
126
+ pass "No database integration test files"
127
+ fi
128
+
129
+ # ---------------------------------------------------------------------------
130
+ # HTTP Integration
131
+ # ---------------------------------------------------------------------------
132
+ echo ""
133
+ echo "--- HTTP Integration ---"
134
+ HTTP_LIBS=0
135
+ for ext in ts tsx; do
136
+ COUNT=$(find . -name "*.$ext" -not -path "./node_modules/*" -not -path "./dist/*" \
137
+ -exec grep -lE "(supertest|msw|@testing-library)" {} + 2>/dev/null | wc -l | tr -d ' ')
138
+ HTTP_LIBS=$((HTTP_LIBS + COUNT))
139
+ done
140
+ if [ "$HTTP_LIBS" -gt 0 ]; then
141
+ pass "HTTP integration libraries detected ($HTTP_LIBS files with supertest, msw, or @testing-library)"
142
+ else
143
+ pass "No HTTP integration libraries detected"
144
+ fi
145
+
146
+ # ---------------------------------------------------------------------------
147
+ # Summary
148
+ # ---------------------------------------------------------------------------
149
+ echo ""
150
+ echo "============================================"
151
+ echo " Summary"
152
+ echo "============================================"
153
+ echo -e " Passed: ${GREEN}${PASS_COUNT}${NC}"
154
+ echo -e " Failed: ${RED}${#ERRORS[@]}${NC}"
155
+ echo ""
156
+
157
+ if [ ${#ERRORS[@]} -gt 0 ]; then
158
+ echo "FAILURES:"
159
+ for err in "${ERRORS[@]}"; do
160
+ echo " - $err"
161
+ done
162
+ exit 1
163
+ fi
164
+
165
+ echo -e "${GREEN}Integration validation passed.${NC}"
166
+ exit 0