codebyplan 1.5.1 → 1.9.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/dist/cli.js +4462 -748
- package/package.json +5 -1
- package/templates/.gitkeep +0 -0
- package/templates/README.md +20 -0
- package/templates/agents/cbp-cc-executor.md +213 -0
- package/templates/agents/cbp-database-agent.md +229 -0
- package/templates/agents/cbp-improve-claude.md +245 -0
- package/templates/agents/cbp-improve-round.md +284 -0
- package/templates/agents/cbp-mechanical-edits.md +111 -0
- package/templates/agents/cbp-research.md +282 -0
- package/templates/agents/cbp-round-executor.md +604 -0
- package/templates/agents/cbp-security-agent.md +134 -0
- package/templates/agents/cbp-task-check.md +213 -0
- package/templates/agents/cbp-task-planner.md +582 -0
- package/templates/agents/cbp-test-e2e-agent.md +363 -0
- package/templates/agents/cbp-testing-qa-agent.md +400 -0
- package/templates/context/mcp-docs.md +139 -0
- package/templates/hooks/README.md +236 -0
- package/templates/hooks/cbp-auto-test-hooks.sh +44 -0
- package/templates/hooks/cbp-lint-format-on-edit.sh +159 -0
- package/templates/hooks/cbp-maestro-yaml-validate.sh +100 -0
- package/templates/hooks/cbp-mcp-migration-guard.sh +32 -0
- package/templates/hooks/cbp-mcp-round-sync.sh +79 -0
- package/templates/hooks/cbp-mcp-worktree-inject.sh +76 -0
- package/templates/hooks/cbp-notify.sh +68 -0
- package/templates/hooks/cbp-plugin-dispatch.sh +29 -0
- package/templates/hooks/cbp-pre-commit-quality-gate.sh +204 -0
- package/templates/hooks/cbp-statusline.sh +347 -0
- package/templates/hooks/cbp-subagent-statusline.sh +182 -0
- package/templates/hooks/cbp-test-coverage-gate.sh +144 -0
- package/templates/hooks/cbp-test-hooks.sh +320 -0
- package/templates/hooks/hooks.json +85 -0
- package/templates/hooks/validate-context-usage.sh +59 -0
- package/templates/hooks/validate-git-commit.sh +78 -0
- package/templates/hooks/validate-git-stash-deny.sh +32 -0
- package/templates/hooks/validate-structure-lengths.sh +57 -0
- package/templates/hooks/validate-structure-lib.sh +104 -0
- package/templates/hooks/validate-structure-patterns.sh +54 -0
- package/templates/hooks/validate-structure-scope.sh +33 -0
- package/templates/hooks/validate-structure-smoke.sh +95 -0
- package/templates/hooks/validate-structure-templates.sh +34 -0
- package/templates/hooks/validate-structure.sh +69 -0
- package/templates/rules/.gitkeep +0 -0
- package/templates/rules/README.md +47 -0
- package/templates/rules/context-file-loading.md +52 -0
- package/templates/rules/scope-vocabulary.md +64 -0
- package/templates/rules/todo-backend.md +109 -0
- package/templates/settings.project.base.json +55 -0
- package/templates/settings.user.base.json +25 -0
- package/templates/skills/cbp-build-cc-agent/SKILL.md +139 -0
- package/templates/skills/cbp-build-cc-agent/examples/read-only-reviewer.md +32 -0
- package/templates/skills/cbp-build-cc-agent/examples/with-hooks.md +41 -0
- package/templates/skills/cbp-build-cc-agent/examples/with-skills-preload.md +25 -0
- package/templates/skills/cbp-build-cc-agent/reference/cbp-quality.md +153 -0
- package/templates/skills/cbp-build-cc-agent/reference/frontmatter-fields.md +37 -0
- package/templates/skills/cbp-build-cc-agent/reference/permission-modes.md +18 -0
- package/templates/skills/cbp-build-cc-agent/scripts/validate-agent.sh +67 -0
- package/templates/skills/cbp-build-cc-agent/templates/agent.md +66 -0
- package/templates/skills/cbp-build-cc-claude-file/SKILL.md +178 -0
- package/templates/skills/cbp-build-cc-claude-file/examples/minimal-project.md +33 -0
- package/templates/skills/cbp-build-cc-claude-file/examples/monorepo-with-imports.md +39 -0
- package/templates/skills/cbp-build-cc-claude-file/reference/imports.md +72 -0
- package/templates/skills/cbp-build-cc-claude-file/reference/what-belongs.md +39 -0
- package/templates/skills/cbp-build-cc-claude-file/templates/project-claude-md.md +48 -0
- package/templates/skills/cbp-build-cc-claude-file/templates/user-claude-md.md +22 -0
- package/templates/skills/cbp-build-cc-memory/SKILL.md +201 -0
- package/templates/skills/cbp-build-cc-memory/examples/feedback-memory.md +11 -0
- package/templates/skills/cbp-build-cc-memory/examples/project-memory.md +11 -0
- package/templates/skills/cbp-build-cc-memory/examples/reference-memory.md +13 -0
- package/templates/skills/cbp-build-cc-memory/examples/user-memory.md +14 -0
- package/templates/skills/cbp-build-cc-memory/reference/memory-types.md +59 -0
- package/templates/skills/cbp-build-cc-memory/reference/when-to-save.md +62 -0
- package/templates/skills/cbp-build-cc-memory/templates/MEMORY-index.md +4 -0
- package/templates/skills/cbp-build-cc-memory/templates/memory-entry.md +15 -0
- package/templates/skills/cbp-build-cc-mode/SKILL.md +99 -0
- package/templates/skills/cbp-build-cc-rule/SKILL.md +176 -0
- package/templates/skills/cbp-build-cc-rule/examples/global-rule.md +19 -0
- package/templates/skills/cbp-build-cc-rule/examples/scoped-rule.md +41 -0
- package/templates/skills/cbp-build-cc-rule/reference/paths-patterns.md +48 -0
- package/templates/skills/cbp-build-cc-rule/templates/rule.md +32 -0
- package/templates/skills/cbp-build-cc-settings/SKILL.md +220 -0
- package/templates/skills/cbp-build-cc-settings/examples/hooks-config.json +64 -0
- package/templates/skills/cbp-build-cc-settings/examples/permissions-config.json +34 -0
- package/templates/skills/cbp-build-cc-settings/examples/sandbox-config.json +42 -0
- package/templates/skills/cbp-build-cc-settings/reference/cbp-conventions.md +104 -0
- package/templates/skills/cbp-build-cc-settings/reference/permission-rules.md +61 -0
- package/templates/skills/cbp-build-cc-settings/reference/scope-precedence.md +73 -0
- package/templates/skills/cbp-build-cc-settings/reference/settings-fields.md +166 -0
- package/templates/skills/cbp-build-cc-settings/templates/settings.json +23 -0
- package/templates/skills/cbp-build-cc-settings/templates/settings.local.json +10 -0
- package/templates/skills/cbp-build-cc-skill/SKILL.md +154 -0
- package/templates/skills/cbp-build-cc-skill/examples/dynamic-context.md +31 -0
- package/templates/skills/cbp-build-cc-skill/examples/fork-skill.md +22 -0
- package/templates/skills/cbp-build-cc-skill/examples/knowledge-skill.md +25 -0
- package/templates/skills/cbp-build-cc-skill/examples/task-skill.md +29 -0
- package/templates/skills/cbp-build-cc-skill/reference/cbp-quality.md +157 -0
- package/templates/skills/cbp-build-cc-skill/reference/frontmatter-fields.md +35 -0
- package/templates/skills/cbp-build-cc-skill/reference/string-substitutions.md +60 -0
- package/templates/skills/cbp-build-cc-skill/scripts/validate-skill.sh +90 -0
- package/templates/skills/cbp-build-cc-skill/templates/skill.md +51 -0
- package/templates/skills/cbp-checkpoint-check/SKILL.md +156 -0
- package/templates/skills/cbp-checkpoint-complete/SKILL.md +109 -0
- package/templates/skills/cbp-checkpoint-create/SKILL.md +116 -0
- package/templates/skills/cbp-checkpoint-end/SKILL.md +241 -0
- package/templates/skills/cbp-checkpoint-plan/SKILL.md +137 -0
- package/templates/skills/cbp-checkpoint-plan/reference/alternative-comparison-template.md +54 -0
- package/templates/skills/cbp-checkpoint-plan/reference/dep-decision-rubric.md +50 -0
- package/templates/skills/cbp-checkpoint-plan/reference/e2e-discovery-probe.md +57 -0
- package/templates/skills/cbp-checkpoint-plan/reference/gap-analysis-playbook.md +47 -0
- package/templates/skills/cbp-checkpoint-start/SKILL.md +84 -0
- package/templates/skills/cbp-checkpoint-update/SKILL.md +115 -0
- package/templates/skills/cbp-frontend-a11y/SKILL.md +109 -0
- package/templates/skills/cbp-frontend-a11y/reference/aria-roles-states.md +130 -0
- package/templates/skills/cbp-frontend-a11y/reference/contrast-visual.md +122 -0
- package/templates/skills/cbp-frontend-a11y/reference/keyboard-patterns.md +154 -0
- package/templates/skills/cbp-frontend-a11y/reference/semantic-html.md +111 -0
- package/templates/skills/cbp-frontend-design/SKILL.md +145 -0
- package/templates/skills/cbp-frontend-design/reference/nextjs-scss.md +118 -0
- package/templates/skills/cbp-frontend-design/reference/rn-expo.md +101 -0
- package/templates/skills/cbp-frontend-design/reference/tauri-react.md +82 -0
- package/templates/skills/cbp-frontend-ui/SKILL.md +262 -0
- package/templates/skills/cbp-frontend-ui/reference/ui-label-maps.md +42 -0
- package/templates/skills/cbp-frontend-ui/reference/ui-layout-patterns.md +105 -0
- package/templates/skills/cbp-frontend-ui/reference/variant-defaults.md +149 -0
- package/templates/skills/cbp-frontend-ux/SKILL.md +181 -0
- package/templates/skills/cbp-git-branch-feat-create/SKILL.md +115 -0
- package/templates/skills/cbp-git-commit/SKILL.md +278 -0
- package/templates/skills/cbp-git-worktree-create/SKILL.md +226 -0
- package/templates/skills/cbp-git-worktree-remove/SKILL.md +145 -0
- package/templates/skills/cbp-merge-main/SKILL.md +228 -0
- package/templates/skills/cbp-round-check/SKILL.md +104 -0
- package/templates/skills/cbp-round-end/SKILL.md +183 -0
- package/templates/skills/cbp-round-end/reference/findings-presentation.md +44 -0
- package/templates/skills/cbp-round-end/reference/inline-fallback.md +35 -0
- package/templates/skills/cbp-round-execute/SKILL.md +211 -0
- package/templates/skills/cbp-round-execute/reference/inline-fallback.md +59 -0
- package/templates/skills/cbp-round-input/SKILL.md +165 -0
- package/templates/skills/cbp-round-start/SKILL.md +222 -0
- package/templates/skills/cbp-round-update/SKILL.md +163 -0
- package/templates/skills/cbp-session-end/SKILL.md +187 -0
- package/templates/skills/cbp-session-start/SKILL.md +155 -0
- package/templates/skills/cbp-ship/SKILL.md +332 -0
- package/templates/skills/cbp-ship/reference/changesets-overview.md +120 -0
- package/templates/skills/cbp-ship/reference/eas-cli-overview.md +60 -0
- package/templates/skills/cbp-ship/reference/gh-cli-overview.md +135 -0
- package/templates/skills/cbp-ship/reference/gh-cli-shipment-commands.md +283 -0
- package/templates/skills/cbp-ship/reference/npm-publish-monorepo.md +252 -0
- package/templates/skills/cbp-ship/reference/npm-publish-oidc-trusted.md +157 -0
- package/templates/skills/cbp-ship/reference/npm-publish-overview.md +171 -0
- package/templates/skills/cbp-ship/reference/preflight-checklist.md +88 -0
- package/templates/skills/cbp-ship/reference/railway-nestjs-deployment.md +169 -0
- package/templates/skills/cbp-ship/reference/railway-overview.md +120 -0
- package/templates/skills/cbp-ship/reference/railway-troubleshooting.md +168 -0
- package/templates/skills/cbp-ship/reference/release-please-overview.md +99 -0
- package/templates/skills/cbp-ship/reference/surface-expo-eas.md +155 -0
- package/templates/skills/cbp-ship/reference/surface-npm.md +180 -0
- package/templates/skills/cbp-ship/reference/surface-railway.md +152 -0
- package/templates/skills/cbp-ship/reference/surface-supabase.md +178 -0
- package/templates/skills/cbp-ship/reference/surface-tauri.md +138 -0
- package/templates/skills/cbp-ship/reference/surface-vercel.md +124 -0
- package/templates/skills/cbp-ship/reference/surface-vscode-ext.md +144 -0
- package/templates/skills/cbp-ship/reference/surfaces.md +60 -0
- package/templates/skills/cbp-ship/reference/testflight-automation.md +215 -0
- package/templates/skills/cbp-ship/reference/testflight-internal-vs-external.md +69 -0
- package/templates/skills/cbp-ship/reference/testflight-overview.md +98 -0
- package/templates/skills/cbp-ship/reference/versioning.md +116 -0
- package/templates/skills/cbp-ship/scripts/detect-surfaces.sh +217 -0
- package/templates/skills/cbp-ship/scripts/verify-expo-eas.sh +35 -0
- package/templates/skills/cbp-ship/scripts/verify-npm.sh +21 -0
- package/templates/skills/cbp-ship/scripts/verify-railway.sh +41 -0
- package/templates/skills/cbp-ship/scripts/verify-supabase.sh +19 -0
- package/templates/skills/cbp-ship/scripts/verify-tauri.sh +24 -0
- package/templates/skills/cbp-ship/scripts/verify-vercel.sh +32 -0
- package/templates/skills/cbp-ship/scripts/verify-vscode-ext.sh +25 -0
- package/templates/skills/cbp-ship/templates/eas.json +66 -0
- package/templates/skills/cbp-ship/templates/railway.toml +15 -0
- package/templates/skills/cbp-ship/templates/release-please-config.json +17 -0
- package/templates/skills/cbp-ship/templates/vercel.json +19 -0
- package/templates/skills/cbp-ship/templates/vscodeignore +21 -0
- package/templates/skills/cbp-ship/templates/workflow-changesets.yml +41 -0
- package/templates/skills/cbp-ship/templates/workflow-eas-submit.yml +53 -0
- package/templates/skills/cbp-ship/templates/workflow-npm-publish.yml +36 -0
- package/templates/skills/cbp-ship/templates/workflow-release-please.yml +21 -0
- package/templates/skills/cbp-ship/templates/workflow-tauri-release.yml +69 -0
- package/templates/skills/cbp-ship/templates/workflow-vsce-publish.yml +31 -0
- package/templates/skills/cbp-ship-configure/SKILL.md +296 -0
- package/templates/skills/cbp-ship-configure/reference/expo-mobile.md +204 -0
- package/templates/skills/cbp-ship-configure/reference/npm-package.md +165 -0
- package/templates/skills/cbp-ship-configure/reference/railway-backend.md +199 -0
- package/templates/skills/cbp-ship-configure/reference/supabase.md +200 -0
- package/templates/skills/cbp-ship-configure/reference/tauri-desktop.md +181 -0
- package/templates/skills/cbp-ship-configure/reference/vercel.md +117 -0
- package/templates/skills/cbp-ship-configure/reference/vscode-ext.md +155 -0
- package/templates/skills/cbp-ship-main/SKILL.md +65 -0
- package/templates/skills/cbp-supabase-branch-check/SKILL.md +337 -0
- package/templates/skills/cbp-supabase-branch-check/reference/dag-steps.md +29 -0
- package/templates/skills/cbp-supabase-migrate/SKILL.md +314 -0
- package/templates/skills/cbp-supabase-migrate/reference/advisor-triage.md +70 -0
- package/templates/skills/cbp-supabase-migrate/reference/cli-fallback.md +87 -0
- package/templates/skills/cbp-supabase-migrate/reference/preflight-dry-run.md +58 -0
- package/templates/skills/cbp-supabase-setup/SKILL.md +239 -0
- package/templates/skills/cbp-supabase-setup/reference/branching-setup.md +121 -0
- package/templates/skills/cbp-supabase-setup/reference/cli-fallback.md +109 -0
- package/templates/skills/cbp-task-check/SKILL.md +166 -0
- package/templates/skills/cbp-task-complete/SKILL.md +206 -0
- package/templates/skills/cbp-task-complete/reference/checkpoint-done-branching.md +48 -0
- package/templates/skills/cbp-task-complete/reference/next-step-heuristic.md +56 -0
- package/templates/skills/cbp-task-create/SKILL.md +167 -0
- package/templates/skills/cbp-task-start/SKILL.md +239 -0
- package/templates/skills/cbp-task-testing/SKILL.md +277 -0
- package/templates/skills/cbp-todo/SKILL.md +111 -0
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
---
|
|
2
|
+
scope: org-shared
|
|
3
|
+
name: cbp-ship-main
|
|
4
|
+
description: Ship feat branch to production branch via PR — thin wrapper around `codebyplan ship`
|
|
5
|
+
model: sonnet
|
|
6
|
+
effort: high
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# Ship Main Command
|
|
10
|
+
|
|
11
|
+
Compose a PR body from checkpoint context, then delegate all git/gh mechanics to `codebyplan ship`.
|
|
12
|
+
|
|
13
|
+
## Instructions
|
|
14
|
+
|
|
15
|
+
### Step 1: Read Checkpoint Context
|
|
16
|
+
|
|
17
|
+
Use MCP `get_current_task` (repo_id) to get the active checkpoint. Collect `checkpoint.title`, completed task titles (`get_tasks(checkpoint_id)` filtered to `status === 'completed'`), and key decisions from `checkpoint.context.decisions[]`.
|
|
18
|
+
|
|
19
|
+
### Step 2: Compose PR Body
|
|
20
|
+
|
|
21
|
+
Write to `/tmp/cbp-ship-main-body.md`:
|
|
22
|
+
|
|
23
|
+
```markdown
|
|
24
|
+
## Summary
|
|
25
|
+
|
|
26
|
+
{checkpoint.title}
|
|
27
|
+
|
|
28
|
+
## Tasks Completed
|
|
29
|
+
|
|
30
|
+
{bullet list of completed task titles}
|
|
31
|
+
|
|
32
|
+
## Key Changes
|
|
33
|
+
|
|
34
|
+
{2–5 bullets from decisions or task requirements}
|
|
35
|
+
|
|
36
|
+
## Test Plan
|
|
37
|
+
|
|
38
|
+
- All rounds passed testing-qa
|
|
39
|
+
- /cbp-checkpoint-check passed
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### Step 3: Invoke `codebyplan ship`
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
# DRY_RUN is non-empty when the skill was invoked with a dry-run arg; otherwise empty.
|
|
46
|
+
codebyplan ship --body-file /tmp/cbp-ship-main-body.md --json${DRY_RUN:+ --dry-run}
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Pass `--dry-run` through if the skill was invoked with a dry-run arg.
|
|
50
|
+
|
|
51
|
+
### Step 4: Report
|
|
52
|
+
|
|
53
|
+
Parse JSON from Step 3. Report `pr_url`, `merge_commit`, `branch_deleted`. If `checks_failed: true`, surface `checks_failure_reason` and stop.
|
|
54
|
+
|
|
55
|
+
## Key Rules
|
|
56
|
+
|
|
57
|
+
- **Read branch names from config** — never hardcode "main"
|
|
58
|
+
- **Never force push** — always via PR (enforced by `codebyplan ship`)
|
|
59
|
+
- **Pass --dry-run through** when skill is invoked with dry-run arg
|
|
60
|
+
|
|
61
|
+
## Integration
|
|
62
|
+
|
|
63
|
+
- **Called by**: `/cbp-checkpoint-end`
|
|
64
|
+
- **Delegates to**: `codebyplan ship` CLI
|
|
65
|
+
- **Reads**: MCP `get_current_task`, `get_tasks`
|
|
@@ -0,0 +1,337 @@
|
|
|
1
|
+
---
|
|
2
|
+
scope: org-shared
|
|
3
|
+
name: cbp-supabase-branch-check
|
|
4
|
+
description: Gate skill called by /cbp-ship-main (pre-merge) to verify the Supabase preview branch health check is green before allowing a PR to be merged; skips when no DB-path changes are detected.
|
|
5
|
+
argument-hint: "[--mode pre_pr_create|pre_merge] [--target integration|production]"
|
|
6
|
+
allowed-tools: Bash(git *), Bash(gh *), Bash(jq *), Bash(supabase *), Bash(sleep *), Bash(echo *), Read, mcp__supabase__list_branches, mcp__supabase__get_logs
|
|
7
|
+
model: sonnet
|
|
8
|
+
effort: xhigh
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
# Supabase Branch Check
|
|
12
|
+
|
|
13
|
+
Gate skill invoked by `/cbp-ship-main` to verify the Supabase preview branch GitHub check
|
|
14
|
+
is green before allowing a PR to be merged. When no DB-path changes exist on the current
|
|
15
|
+
branch, the skill emits `skipped` immediately — no polling occurs.
|
|
16
|
+
|
|
17
|
+
## Arguments
|
|
18
|
+
|
|
19
|
+
Inspect `$ARGUMENTS`:
|
|
20
|
+
|
|
21
|
+
- `--mode pre_pr_create` — soft mode; `pending_pr` is a pass-through (PR not open yet). Default target: `integration`.
|
|
22
|
+
- `--mode pre_merge` — hard mode (default); `pending_pr` or `blocked` refuse merge. Default target: auto-detect from PR base.
|
|
23
|
+
- `--target integration|production` — override target branch lookup.
|
|
24
|
+
|
|
25
|
+
## Return Contract
|
|
26
|
+
|
|
27
|
+
Every exit path emits a fenced JSON block in chat output so callers can parse deterministically:
|
|
28
|
+
|
|
29
|
+
```json
|
|
30
|
+
{ "status": "passed|skipped|pending_pr|blocked",
|
|
31
|
+
"reason": "human-readable string",
|
|
32
|
+
"failed_step": "clone|pull|health|configure|migrate|seed|deploy",
|
|
33
|
+
"log_excerpt": "verbatim first ~500 chars" }
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
`failed_step` and `log_excerpt` are only included on `blocked` triggered by a DAG failure.
|
|
37
|
+
|
|
38
|
+
## Step 0 — Parse Arguments
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
MODE="pre_merge"
|
|
42
|
+
TARGET=""
|
|
43
|
+
|
|
44
|
+
while [[ $# -gt 0 ]]; do
|
|
45
|
+
case "$1" in
|
|
46
|
+
--mode) MODE="$2"; shift 2 ;;
|
|
47
|
+
--target) TARGET="$2"; shift 2 ;;
|
|
48
|
+
*) shift ;;
|
|
49
|
+
esac
|
|
50
|
+
done
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Validate `MODE`: must be `pre_pr_create` or `pre_merge`. If invalid, stop with error:
|
|
54
|
+
|
|
55
|
+
```
|
|
56
|
+
Invalid --mode value: <value>. Valid values: pre_pr_create, pre_merge.
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Infer `TARGET` when absent:
|
|
60
|
+
- `pre_pr_create` → `integration`
|
|
61
|
+
- `pre_merge` → detect via `gh pr view --json baseRefName --jq '.baseRefName'`; fallback to `integration` if no PR is open.
|
|
62
|
+
|
|
63
|
+
## Step 1 — Read DB Paths Config
|
|
64
|
+
|
|
65
|
+
Read `.codebyplan.json` to obtain the configured DB path globs:
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
DB_PATHS=$(jq -r '.shipment.surfaces.supabase.db_paths[]? // empty' .codebyplan.json 2>/dev/null)
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
If `DB_PATHS` is empty, fall back to defaults:
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
if [ -z "$DB_PATHS" ]; then
|
|
75
|
+
DB_PATHS=$(printf '%s\n' 'supabase/**' 'apps/backend/**' 'packages/**/db/**')
|
|
76
|
+
fi
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
Store each pattern as a separate entry for matching in Step 2.
|
|
80
|
+
|
|
81
|
+
## Step 2 — Detect DB-Path Changes
|
|
82
|
+
|
|
83
|
+
Resolve the BASE branch from `TARGET`. Read `.codebyplan.json`:
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
INTEGRATION=$(jq -r '.branch_config.integration // "development"' .codebyplan.json)
|
|
87
|
+
PRODUCTION=$(jq -r '.branch_config.production // "main"' .codebyplan.json)
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
Set `BASE`:
|
|
91
|
+
- `TARGET=integration` → `BASE="$INTEGRATION"`
|
|
92
|
+
- `TARGET=production` → `BASE="$PRODUCTION"`
|
|
93
|
+
|
|
94
|
+
Run git diff to list changed files:
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
git fetch origin "$BASE" 2>/dev/null
|
|
98
|
+
CHANGED_FILES=$(git diff --name-only "origin/$BASE"...HEAD)
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
if [ -z "$CHANGED_FILES" ]; then
|
|
103
|
+
# No files changed at all — soft-skip
|
|
104
|
+
emit { "status": "skipped", "reason": "No file changes against $BASE" } and exit
|
|
105
|
+
fi
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
Match each changed file against each DB path pattern using bash globstar:
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
shopt -s globstar
|
|
112
|
+
MATCHED=false
|
|
113
|
+
while IFS= read -r file; do
|
|
114
|
+
for pattern in $DB_PATHS; do
|
|
115
|
+
# bash 4+ supports ** in [[ ]] glob matching
|
|
116
|
+
if [[ "$file" == $pattern ]]; then
|
|
117
|
+
MATCHED=true
|
|
118
|
+
break 2
|
|
119
|
+
fi
|
|
120
|
+
done
|
|
121
|
+
done <<< "$CHANGED_FILES"
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
If `MATCHED=false`, emit and exit:
|
|
125
|
+
|
|
126
|
+
```json
|
|
127
|
+
{
|
|
128
|
+
"status": "skipped",
|
|
129
|
+
"reason": "No DB-path changes detected against <BASE>"
|
|
130
|
+
}
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
## Step 3 — Resolve project_ref
|
|
134
|
+
|
|
135
|
+
```bash
|
|
136
|
+
BRANCH=$(git branch --show-current)
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
**MCP path (preferred)**: Call `mcp__supabase__list_branches`. Filter the returned array for the
|
|
140
|
+
entry where the git-branch field matches `$BRANCH`. The field name varies by API version —
|
|
141
|
+
check `git_branch`, `branch_name`, or `ref` at runtime; use the first non-null value.
|
|
142
|
+
Extract `project_ref` from the matched entry.
|
|
143
|
+
|
|
144
|
+
**CLI fallback** (when MCP unavailable):
|
|
145
|
+
|
|
146
|
+
```bash
|
|
147
|
+
if ! command -v supabase >/dev/null 2>&1; then
|
|
148
|
+
# CLI not installed — explicit blocked status (avoids misleading "no preview")
|
|
149
|
+
emit { "status": "blocked", "reason": "supabase CLI not installed — run: npm i -g supabase" } and exit
|
|
150
|
+
fi
|
|
151
|
+
supabase --experimental branches get "$BRANCH" -o env \
|
|
152
|
+
| grep 'SUPABASE_PROJECT_REF' | cut -d= -f2
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
Store as `PROJECT_REF`.
|
|
156
|
+
|
|
157
|
+
## Step 4 — Handle Missing project_ref
|
|
158
|
+
|
|
159
|
+
If `PROJECT_REF` is empty after Step 3:
|
|
160
|
+
|
|
161
|
+
- `MODE=pre_pr_create`:
|
|
162
|
+
|
|
163
|
+
```json
|
|
164
|
+
{
|
|
165
|
+
"status": "pending_pr",
|
|
166
|
+
"reason": "Push commit + open PR — Supabase creates the preview branch when the PR opens"
|
|
167
|
+
}
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
Exit (soft pass — caller proceeds to create the PR).
|
|
171
|
+
|
|
172
|
+
- `MODE=pre_merge`:
|
|
173
|
+
|
|
174
|
+
```json
|
|
175
|
+
{
|
|
176
|
+
"status": "blocked",
|
|
177
|
+
"reason": "No Supabase preview branch found for <BRANCH>. Push commit and open a PR first."
|
|
178
|
+
}
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
Exit (hard block).
|
|
182
|
+
|
|
183
|
+
## Step 5 — PR Existence Check
|
|
184
|
+
|
|
185
|
+
Verify an open PR exists for this branch:
|
|
186
|
+
|
|
187
|
+
```bash
|
|
188
|
+
PR_JSON=$(gh pr view --json number,baseRefName 2>/dev/null)
|
|
189
|
+
PR_NUMBER=$(echo "$PR_JSON" | jq -r '.number // empty')
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
```bash
|
|
193
|
+
if [ -z "$PR_NUMBER" ] && [ "$MODE" = "pre_pr_create" ]; then
|
|
194
|
+
# No PR yet — Supabase will create the preview branch when the PR opens
|
|
195
|
+
emit { "status": "pending_pr", "reason": "No PR open yet for branch <BRANCH>; open a PR and re-run" } and exit
|
|
196
|
+
fi
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
If `PR_NUMBER` is empty AND `MODE=pre_merge`:
|
|
200
|
+
|
|
201
|
+
```json
|
|
202
|
+
{
|
|
203
|
+
"status": "blocked",
|
|
204
|
+
"reason": "No PR open for branch <BRANCH>; cannot verify Supabase Preview check"
|
|
205
|
+
}
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
Exit. (With the pre_pr_create guard above, pre_merge is the only mode that reaches this point with an empty PR_NUMBER.)
|
|
209
|
+
|
|
210
|
+
## Step 6 — Bounded Poll: Supabase Preview Check
|
|
211
|
+
|
|
212
|
+
Poll the GitHub PR checks for the `Supabase Preview` status check. Cap at 20 iterations
|
|
213
|
+
with 15 seconds between each (5-minute ceiling total).
|
|
214
|
+
|
|
215
|
+
```bash
|
|
216
|
+
FAILED=false
|
|
217
|
+
|
|
218
|
+
for i in $(seq 1 20); do
|
|
219
|
+
# Primary: gh ≥2.32 (Jul 2023) supports `bucket` (pass|fail|pending|skipping|cancel).
|
|
220
|
+
# Fallback: older gh omits bucket — request name,state and let jq derive bucket from state.
|
|
221
|
+
CHECK_JSON=$(gh pr checks "$PR_NUMBER" --json name,bucket,state 2>/dev/null \
|
|
222
|
+
|| gh pr checks "$PR_NUMBER" --json name,state 2>/dev/null)
|
|
223
|
+
|
|
224
|
+
BUCKET=$(echo "$CHECK_JSON" \
|
|
225
|
+
| jq -r '.[] | select(.name == "Supabase Preview") |
|
|
226
|
+
(.bucket //
|
|
227
|
+
(.state |
|
|
228
|
+
if . == "SUCCESS" then "pass"
|
|
229
|
+
elif . == "SKIPPED" or . == "NEUTRAL" then "skipping"
|
|
230
|
+
elif . == "FAILURE" or . == "ERROR" or . == "CANCELLED"
|
|
231
|
+
or . == "STALE" or . == "ACTION_REQUIRED"
|
|
232
|
+
or . == "TIMED_OUT" then "fail"
|
|
233
|
+
else "pending" end))
|
|
234
|
+
// empty')
|
|
235
|
+
|
|
236
|
+
case "$BUCKET" in
|
|
237
|
+
pass)
|
|
238
|
+
break
|
|
239
|
+
;;
|
|
240
|
+
skipping)
|
|
241
|
+
break
|
|
242
|
+
;;
|
|
243
|
+
pending)
|
|
244
|
+
echo "poll $i/20: Supabase Preview bucket=$BUCKET, sleeping 15s"
|
|
245
|
+
sleep 15
|
|
246
|
+
;;
|
|
247
|
+
fail)
|
|
248
|
+
FAILED=true
|
|
249
|
+
break
|
|
250
|
+
;;
|
|
251
|
+
cancel)
|
|
252
|
+
FAILED=true
|
|
253
|
+
break
|
|
254
|
+
;;
|
|
255
|
+
"")
|
|
256
|
+
echo "poll $i/20: Supabase Preview not yet in check list, sleeping 15s"
|
|
257
|
+
sleep 15
|
|
258
|
+
;;
|
|
259
|
+
esac
|
|
260
|
+
done
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
After the loop, dispatch on the final `$BUCKET` and `$FAILED` state:
|
|
264
|
+
|
|
265
|
+
```bash
|
|
266
|
+
if [ "$FAILED" = "true" ]; then
|
|
267
|
+
: # proceed to Step 7 (failure path)
|
|
268
|
+
elif [ "$BUCKET" = "pass" ] || [ "$BUCKET" = "skipping" ]; then
|
|
269
|
+
: # proceed to Step 8 (success path — pass/skipping branches differ below)
|
|
270
|
+
else
|
|
271
|
+
# Loop exhausted with $BUCKET still "pending" or empty — emit timeout.
|
|
272
|
+
if [ -n "$BUCKET" ]; then
|
|
273
|
+
REASON="Supabase Preview still $BUCKET after 5 min (20 polls)"
|
|
274
|
+
else
|
|
275
|
+
REASON="Supabase Preview not found in check list after 5 min (20 polls)"
|
|
276
|
+
fi
|
|
277
|
+
fi
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
Timeout emit (when loop exhausted):
|
|
281
|
+
|
|
282
|
+
```json
|
|
283
|
+
{
|
|
284
|
+
"status": "blocked",
|
|
285
|
+
"reason": "<REASON computed above>"
|
|
286
|
+
}
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
## Step 7 — Failure: Fetch Logs and Map DAG Step
|
|
290
|
+
|
|
291
|
+
Read `reference/dag-steps.md` for DAG step → service mapping. Attempt to read the failed
|
|
292
|
+
step name from the check output (`description` or `name` field).
|
|
293
|
+
|
|
294
|
+
Query logs in priority order until a non-empty result is obtained:
|
|
295
|
+
1. `mcp__supabase__get_logs(project_ref=PROJECT_REF, service="postgres")` — migrate/seed/health
|
|
296
|
+
2. `mcp__supabase__get_logs(project_ref=PROJECT_REF, service="api")` — clone/pull/configure
|
|
297
|
+
3. `mcp__supabase__get_logs(project_ref=PROJECT_REF, service="edge-function")` — deploy only
|
|
298
|
+
|
|
299
|
+
Cap excerpt at first 500 chars of the first non-empty result.
|
|
300
|
+
|
|
301
|
+
```json
|
|
302
|
+
{
|
|
303
|
+
"status": "blocked",
|
|
304
|
+
"reason": "<human-readable description of the failure>",
|
|
305
|
+
"failed_step": "<clone|pull|health|configure|migrate|seed|deploy>",
|
|
306
|
+
"log_excerpt": "<verbatim first ~500 chars of logs>"
|
|
307
|
+
}
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
## Step 8 — Success
|
|
311
|
+
|
|
312
|
+
Two sub-cases distinguished by `$BUCKET`:
|
|
313
|
+
|
|
314
|
+
When `$BUCKET = pass` (check ran and passed):
|
|
315
|
+
|
|
316
|
+
```json
|
|
317
|
+
{
|
|
318
|
+
"status": "passed",
|
|
319
|
+
"reason": "Supabase Preview check green for branch <BRANCH>"
|
|
320
|
+
}
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
When `$BUCKET = skipping` (check skipped at CI level — e.g. Supabase decided no preview was needed despite this skill's earlier DB-path check passing):
|
|
324
|
+
|
|
325
|
+
```json
|
|
326
|
+
{
|
|
327
|
+
"status": "passed",
|
|
328
|
+
"reason": "Supabase Preview check skipped at CI for branch <BRANCH>"
|
|
329
|
+
}
|
|
330
|
+
```
|
|
331
|
+
|
|
332
|
+
Both emit `status: passed` so callers proceed; the `reason` differs for traceability.
|
|
333
|
+
|
|
334
|
+
## Integration
|
|
335
|
+
|
|
336
|
+
**Callers**: `/cbp-ship-main` invokes this skill pre-merge (mode=`pre_merge`, target=`production`, no override).
|
|
337
|
+
**Tools used**: `mcp__supabase__list_branches` for project_ref resolution; `mcp__supabase__get_logs` for failure diagnostics; `gh pr checks` for status polling; `supabase --experimental branches get` as CLI fallback.
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
---
|
|
2
|
+
scope: org-shared
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# DAG Steps — Supabase Preview Branch
|
|
6
|
+
|
|
7
|
+
Reference for cbp-supabase-branch-check Step 7. Maps each Supabase branching DAG step
|
|
8
|
+
to its likely root cause, recommended user action, and the get_logs service to query.
|
|
9
|
+
|
|
10
|
+
## Mapping Table
|
|
11
|
+
|
|
12
|
+
| DAG Step | Likely Root Cause | User Action | get_logs service |
|
|
13
|
+
|------------|--------------------------------------------------------|--------------------------------------------------------------------|------------------|
|
|
14
|
+
| clone | Repository not accessible to Supabase app | Re-authorize GitHub app in Supabase dashboard | api |
|
|
15
|
+
| pull | Branch not pushed to remote | git push origin <branch> | api |
|
|
16
|
+
| health | Preview DB failed to provision | Check Supabase status page; retry via dashboard | postgres |
|
|
17
|
+
| configure | supabase/config.toml parse error or missing block | Check config.toml syntax; verify [remotes.*] block | api |
|
|
18
|
+
| migrate | Migration SQL error (syntax, constraint) | Fix migration file, re-push branch | postgres |
|
|
19
|
+
| seed | seed.sql error or timeout | Check supabase/seed.sql; reduce seed size | postgres |
|
|
20
|
+
| deploy | Edge function deploy failure | Check edge function logs; verify function syntax | edge-function |
|
|
21
|
+
|
|
22
|
+
## Service Selection Logic
|
|
23
|
+
|
|
24
|
+
When the DAG step name is not visible in the log, query in this order:
|
|
25
|
+
1. `postgres` — covers migration, seed, and health failures (most common)
|
|
26
|
+
2. `api` — covers clone, pull, configure failures
|
|
27
|
+
3. `edge-function` — only for deploy step failures
|
|
28
|
+
|
|
29
|
+
Provide the first non-empty log result to the user as the `log_excerpt`.
|