@refactco/refact-os 1.5.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/CHANGELOG.md +60 -0
- package/LICENSE +21 -0
- package/README.md +162 -0
- package/bin/refact-os.js +154 -0
- package/lib/adapters.js +302 -0
- package/lib/company.js +76 -0
- package/lib/frontmatter.js +30 -0
- package/lib/migrate.js +116 -0
- package/lib/project-utils.js +179 -0
- package/lib/refact-config.js +324 -0
- package/lib/scaffold.js +329 -0
- package/lib/validate.js +145 -0
- package/package.json +46 -0
- package/templates/base/AGENTS.md +9 -0
- package/templates/base/CLAUDE.md +3 -0
- package/templates/base/README.md +54 -0
- package/templates/base/agent/AGENTS.md +60 -0
- package/templates/base/agent/CLAUDE.md +7 -0
- package/templates/base/agent/claude-hooks.json +32 -0
- package/templates/base/agent/hooks/claude-sync-transcript.py +236 -0
- package/templates/base/agent/hooks/preflight-metadata.mjs +202 -0
- package/templates/base/agent/hooks/send-transcript-to-remote-server.py +238 -0
- package/templates/base/agent/hooks/sync-chat-transcript.py +188 -0
- package/templates/base/agent/hooks.json +29 -0
- package/templates/base/agent/scripts/import-project-chat-history.py +196 -0
- package/templates/base/agent/scripts/sync-asana.mjs +408 -0
- package/templates/base/agent/skills/adopt/SKILL.md +46 -0
- package/templates/base/agent/skills/close-ticket/SKILL.md +31 -0
- package/templates/base/agent/skills/extract-learnings/SKILL.md +90 -0
- package/templates/base/agent/skills/git-it/SKILL.md +138 -0
- package/templates/base/agent/skills/import-chat-history/SKILL.md +85 -0
- package/templates/base/agent/skills/ingest-input/SKILL.md +43 -0
- package/templates/base/agent/skills/open-ticket/SKILL.md +36 -0
- package/templates/base/agent/skills/process-docs/SKILL.md +69 -0
- package/templates/base/agent/skills/project-status/SKILL.md +35 -0
- package/templates/base/agent/skills/project-status/scripts/scan-status.mjs +153 -0
- package/templates/base/agent/skills/refact/SKILL.md +139 -0
- package/templates/base/agent/skills/setup-project/SKILL.md +140 -0
- package/templates/base/agent/skills/sync-asana/SKILL.md +106 -0
- package/templates/base/agent/skills/update-canonical-record/SKILL.md +28 -0
- package/templates/base/agent/skills/update-package/SKILL.md +51 -0
- package/templates/base/docs/context/project.md +30 -0
- package/templates/base/docs/decisions.md +22 -0
- package/templates/base/docs/index.md +31 -0
- package/templates/base/docs/sources/raw/.gitkeep +0 -0
- package/templates/base/docs/task/.gitkeep +0 -0
- package/templates/base/env.example +14 -0
- package/templates/base/gitignore +34 -0
- package/templates/overlays/client/agent/skills/create-deliverable/SKILL.md +29 -0
- package/templates/overlays/client/docs/deliverables/.gitkeep +0 -0
- package/templates/overlays/code/agent/skills/add-codebase/SKILL.md +239 -0
- package/templates/overlays/code/agent/skills/code-development/SKILL.md +58 -0
- package/templates/overlays/code/agent/skills/code-development/references/gitflow.md +144 -0
- package/templates/overlays/nextjs/agent/skills/nextjs-dev/SKILL.md +93 -0
- package/templates/overlays/nextjs/agent/skills/setup-netlify-deploy/SKILL.md +143 -0
- package/templates/overlays/nextjs/agent/skills/setup-nextjs-app/SKILL.md +118 -0
- package/templates/overlays/nextjs/agent/skills/setup-vercel-deploy/SKILL.md +116 -0
- package/templates/overlays/wordpress/agent/skills/install-wp-skills/SKILL.md +130 -0
- package/templates/overlays/wordpress/agent/skills/setup-kinsta-deploy/SKILL.md +201 -0
- package/templates/overlays/wordpress/agent/skills/wp-env/SKILL.md +478 -0
- package/templates/overlays/wordpress/wp-cli.yml.example +46 -0
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: setup-nextjs-app
|
|
3
|
+
description: Create or adopt a Next.js app under apps/<name>, preserving existing project choices and documenting local runtime details.
|
|
4
|
+
pattern: procedure
|
|
5
|
+
when_to_use: /refact setup nextjs app | add Next.js app | create a Next.js app | adopt existing Next.js codebase.
|
|
6
|
+
when_not_to_use: Non-Next.js projects, or tasks that only modify an already configured app.
|
|
7
|
+
next_skills:
|
|
8
|
+
- nextjs-dev
|
|
9
|
+
- setup-vercel-deploy
|
|
10
|
+
- setup-netlify-deploy
|
|
11
|
+
sub_agents: []
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
# Setup Next.js App Reference
|
|
15
|
+
|
|
16
|
+
Use this reference when the user asks to create a new Next.js application or bring an existing Next.js app into a `refact-os` project.
|
|
17
|
+
|
|
18
|
+
## Goal
|
|
19
|
+
|
|
20
|
+
Create a predictable home for runnable Next.js code without turning `refact-os` into a framework starter. The scaffold owns the agent operating system; `create-next-app` or the existing application owns framework code.
|
|
21
|
+
|
|
22
|
+
## Canonical layout
|
|
23
|
+
|
|
24
|
+
```txt
|
|
25
|
+
<project-root>/
|
|
26
|
+
├── apps/
|
|
27
|
+
│ └── <app-name>/
|
|
28
|
+
│ ├── AGENTS.md
|
|
29
|
+
│ ├── docs/ # earned once technical docs exist
|
|
30
|
+
│ ├── package.json
|
|
31
|
+
│ └── ... Next.js code
|
|
32
|
+
├── agent/
|
|
33
|
+
└── docs/
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Use `apps/web` as the default app name only when the user has not supplied a name. If another app already exists, ask before choosing a name.
|
|
37
|
+
|
|
38
|
+
## Preflight
|
|
39
|
+
|
|
40
|
+
1. Confirm `.refact-os.json` has a `stack.nextjs` entry, or that the target codebase has `next.config.*` / a `next` dependency. If not, ask whether to continue as a Next.js project.
|
|
41
|
+
2. Inspect the existing repo shape:
|
|
42
|
+
- Is there already a Next.js app at the root?
|
|
43
|
+
- Is there already an app under `apps/<name>/`?
|
|
44
|
+
- Which package manager is present: `pnpm-lock.yaml`, `yarn.lock`, `package-lock.json`, or `bun.lockb`?
|
|
45
|
+
3. If moving an existing root app into `apps/<name>/` would touch many files, stop and propose the migration before editing. Do not silently restructure a working app.
|
|
46
|
+
4. Do not overwrite an existing `apps/<name>/` directory.
|
|
47
|
+
|
|
48
|
+
## Flow A — Create a new app
|
|
49
|
+
|
|
50
|
+
1. Resolve:
|
|
51
|
+
- `APP_NAME` from the user's request, or `web` by default.
|
|
52
|
+
- `PACKAGE_MANAGER` from existing lockfiles; if none exist, use `npm`.
|
|
53
|
+
2. Create the app with the official generator, using conservative defaults:
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
npx create-next-app@latest apps/<app-name> --ts --eslint --app --src-dir --import-alias "@/*"
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
If the repo already uses `pnpm`, `yarn`, or `bun`, use that package manager's equivalent runner. Do not force Tailwind, a package manager, or an experimental option unless the user asks.
|
|
60
|
+
|
|
61
|
+
3. Add `apps/<app-name>/AGENTS.md`:
|
|
62
|
+
|
|
63
|
+
```md
|
|
64
|
+
# AGENTS.md
|
|
65
|
+
|
|
66
|
+
This is the Next.js app for this project. Root project context lives in ../../agent/AGENTS.md and ../../docs/.
|
|
67
|
+
|
|
68
|
+
- Prefer existing components, route structure, package manager, and lint/build scripts.
|
|
69
|
+
- App technical docs belong in ./docs/ when they are specific to this app.
|
|
70
|
+
- Run the smallest relevant check after edits: lint, typecheck, tests, or build.
|
|
71
|
+
- Never commit .env* files with real secrets.
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
4. Add an `apps/<app-name>/docs/README.md` only if there is a concrete technical note to capture now. Otherwise let `docs/` be earned later.
|
|
75
|
+
5. Report the app path, install command used, and available scripts from `apps/<app-name>/package.json`.
|
|
76
|
+
|
|
77
|
+
## Flow B — Adopt an existing app
|
|
78
|
+
|
|
79
|
+
1. If the app already lives under `apps/<name>/`, leave it there.
|
|
80
|
+
2. If the app lives at the repo root, ask before moving it. A root-to-`apps/` migration may require updating:
|
|
81
|
+
- CI workflow paths.
|
|
82
|
+
- Vercel project root.
|
|
83
|
+
- Docker files.
|
|
84
|
+
- TypeScript path aliases.
|
|
85
|
+
- Import aliases and workspace package references.
|
|
86
|
+
3. Add `AGENTS.md` inside the app if missing, using the template from Flow A.
|
|
87
|
+
4. Record any unresolved migration decision in `docs/decisions.md` or `docs/task/open/` if the user wants to defer it.
|
|
88
|
+
|
|
89
|
+
## Package manager rules
|
|
90
|
+
|
|
91
|
+
- Existing lockfile wins. Do not introduce a second package manager.
|
|
92
|
+
- In monorepos, prefer the root workspace manager and add the app to the workspace only if the repo already uses workspaces.
|
|
93
|
+
- If package-manager intent is unclear, ask once before generating.
|
|
94
|
+
|
|
95
|
+
## Verification
|
|
96
|
+
|
|
97
|
+
From the app directory, run the smallest useful checks that exist:
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
npm run lint
|
|
101
|
+
npm run build
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
Use the actual package manager. If a script is missing, report that rather than inventing one.
|
|
105
|
+
|
|
106
|
+
## Guardrails
|
|
107
|
+
|
|
108
|
+
- Do not scaffold framework code into the project root by default; use `apps/<app-name>/`.
|
|
109
|
+
- Do not move a root app into `apps/` without user confirmation.
|
|
110
|
+
- Do not add hosting, auth, database, analytics, or UI libraries as part of app setup unless requested.
|
|
111
|
+
- Do not edit generated adapter folders (`.cursor/`, `.claude/`) by hand. Change `agent/` and run `npm run refact:sync`.
|
|
112
|
+
- Do not commit secrets from `.env`, `.env.local`, or provider dashboards.
|
|
113
|
+
|
|
114
|
+
## When to stop and ask
|
|
115
|
+
|
|
116
|
+
- Multiple Next.js apps are present and the user did not name a target.
|
|
117
|
+
- The repo already has a root Next.js app and moving it would affect CI/deploy paths.
|
|
118
|
+
- The user asks for a starter choice with lasting consequences: Tailwind, shadcn/ui, database, auth provider, deployment target, or package manager.
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: setup-vercel-deploy
|
|
3
|
+
description: Link a Next.js app to Vercel and document deployment settings without assuming every Next.js project deploys to Vercel.
|
|
4
|
+
pattern: procedure
|
|
5
|
+
requires_approval: true
|
|
6
|
+
when_to_use: /refact setup vercel deploy | deploy Next.js to Vercel | link this Next.js app to Vercel | configure Vercel for this app.
|
|
7
|
+
when_not_to_use: Non-Vercel hosting, local-only development, or generic Next.js code changes.
|
|
8
|
+
next_skills:
|
|
9
|
+
- nextjs-dev
|
|
10
|
+
sub_agents: []
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
# Vercel Deploy Setup Reference
|
|
14
|
+
|
|
15
|
+
Use this reference when the user explicitly wants a Next.js app linked or configured for Vercel. Do not run this automatically for every Next.js project.
|
|
16
|
+
|
|
17
|
+
## Goal
|
|
18
|
+
|
|
19
|
+
Set up deployment metadata and local verification while keeping project-specific hosting choices explicit. This skill may call external services, create project links, and change deployment settings, so it requires user approval before writes.
|
|
20
|
+
|
|
21
|
+
## Preflight
|
|
22
|
+
|
|
23
|
+
1. Confirm the target app path. If multiple Next.js apps exist, ask which app to deploy.
|
|
24
|
+
2. Confirm Vercel is the intended hosting provider.
|
|
25
|
+
3. Check whether the Vercel CLI exists:
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
vercel --version
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
If missing, ask before installing it. Prefer a project-local or `npx vercel` flow over global installation unless the user wants a global CLI.
|
|
32
|
+
|
|
33
|
+
4. Check authentication:
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
vercel whoami
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
If unauthenticated, stop and ask the user to log in. Do not attempt to handle credentials in chat.
|
|
40
|
+
|
|
41
|
+
5. Inspect existing Vercel state:
|
|
42
|
+
- `.vercel/project.json` means the app or repo is already linked.
|
|
43
|
+
- `vercel.json` may define framework/build/output settings.
|
|
44
|
+
- Existing GitHub workflows may already deploy the app.
|
|
45
|
+
|
|
46
|
+
## Link flow
|
|
47
|
+
|
|
48
|
+
1. From the target app directory, run:
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
vercel link
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
2. If the repo is a monorepo, make sure the Vercel project root points at the app directory (`apps/<app-name>`), not the repo root, unless the repo intentionally builds from root.
|
|
55
|
+
3. Do not commit `.vercel/` unless the team intentionally tracks Vercel project metadata. If unsure, ask. Many teams keep `.vercel/` local and document the project name instead.
|
|
56
|
+
4. Record hosting (`vercel`) and each environment's `branch` + `url` (production and preview/staging) in `.refact-os.json` › `stack.nextjs` when stable. Keep app-specific build details (deployment owner, project name, app root, build command) in `apps/<app-name>/docs/deploy.md`.
|
|
57
|
+
|
|
58
|
+
## Environment variables
|
|
59
|
+
|
|
60
|
+
1. List required variable names from docs, `.env.example`, and code references.
|
|
61
|
+
2. Add or pull variables through Vercel CLI only with explicit user approval:
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
vercel env ls
|
|
65
|
+
vercel env pull
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
3. Never paste secret values into files, chat, logs, or docs. Document names and purpose only.
|
|
69
|
+
4. Keep local `.env.local` uncommitted.
|
|
70
|
+
|
|
71
|
+
## Verification
|
|
72
|
+
|
|
73
|
+
Prefer local production checks before deploying:
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
npm run build
|
|
77
|
+
vercel build
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Use the app's actual package manager. If `vercel build` fails because the project is not linked or env vars are missing, surface the missing piece rather than guessing.
|
|
81
|
+
|
|
82
|
+
For a preview deploy, confirm with the user, then run:
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
vercel deploy
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
For production promotion, require explicit approval:
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
vercel deploy --prod
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## Git integration
|
|
95
|
+
|
|
96
|
+
If Vercel Git integration is enabled, prefer PR preview deployments over ad-hoc CLI deploys. Document:
|
|
97
|
+
|
|
98
|
+
- Production branch.
|
|
99
|
+
- Preview branch behavior.
|
|
100
|
+
- Monorepo root directory.
|
|
101
|
+
- Required Vercel project environment variables.
|
|
102
|
+
|
|
103
|
+
## Guardrails
|
|
104
|
+
|
|
105
|
+
- Never assume Vercel just because the app is Next.js.
|
|
106
|
+
- Never deploy to production without explicit user approval.
|
|
107
|
+
- Never print, commit, or store secret values.
|
|
108
|
+
- Never change DNS, domains, production branch, or project ownership without confirmation.
|
|
109
|
+
- Never overwrite existing `vercel.json` or CI workflows without reading them and explaining the change.
|
|
110
|
+
|
|
111
|
+
## When to stop and ask
|
|
112
|
+
|
|
113
|
+
- The app is already linked to a different Vercel project than the user named.
|
|
114
|
+
- The repo root and Vercel root directory disagree.
|
|
115
|
+
- Required environment variables are unknown or missing.
|
|
116
|
+
- The user asks to promote a preview to production or change domain settings.
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: install-wp-skills
|
|
3
|
+
description: Vendor the WordPress/Gutenberg agent skills into this project. WordPress projects only.
|
|
4
|
+
pattern: procedure
|
|
5
|
+
when_to_use: /refact install wp skills | add WordPress agent skills | pull Gutenberg/block skills.
|
|
6
|
+
when_not_to_use: Non-WordPress projects.
|
|
7
|
+
next_skills: []
|
|
8
|
+
sub_agents: []
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
# Install WordPress Agent Skills Reference
|
|
12
|
+
|
|
13
|
+
Use this reference when the user invokes `/refact install wp skills` (or asks to "add WordPress skills", "pull the WP agent skills", "install Gutenberg/block skills", etc.).
|
|
14
|
+
|
|
15
|
+
## Goal
|
|
16
|
+
|
|
17
|
+
Vendor in a curated set of WordPress-specific skills from the upstream [`WordPress/agent-skills`](https://github.com/WordPress/agent-skills) repository into this project's `.cursor/skills/` directory, alongside the `refact` and `code-development` skills.
|
|
18
|
+
|
|
19
|
+
These skills give the agent expert WordPress knowledge (blocks, block themes, plugin dev, REST API, performance, etc.) without bloating the refact-os scaffolder itself.
|
|
20
|
+
|
|
21
|
+
## Curated skill list (default)
|
|
22
|
+
|
|
23
|
+
| Skill | Teaches |
|
|
24
|
+
|---|---|
|
|
25
|
+
| `wp-block-development` | Gutenberg blocks: `block.json`, attributes, rendering, deprecations |
|
|
26
|
+
| `wp-block-themes` | Block themes: `theme.json`, templates, patterns, style variations |
|
|
27
|
+
| `wp-plugin-development` | Plugin architecture, hooks, settings API, security |
|
|
28
|
+
| `wp-rest-api` | REST routes/endpoints, schema, auth, response shaping |
|
|
29
|
+
| `wp-interactivity-api` | Frontend interactivity with `data-wp-*` directives and stores |
|
|
30
|
+
| `wp-abilities-api` | Capability-based permissions and REST API authentication |
|
|
31
|
+
| `wp-wpcli-and-ops` | WP-CLI automation, multisite, search-replace |
|
|
32
|
+
| `wp-performance` | Profiling, caching, DB optimization, Server-Timing |
|
|
33
|
+
| `wp-phpstan` | PHPStan static analysis tuned for WordPress |
|
|
34
|
+
| `wp-playground` | WordPress Playground for instant local environments |
|
|
35
|
+
|
|
36
|
+
The upstream repo also ships `wordpress-router`, `wp-project-triage`, `wpds`, `wp-plugin-directory-guidelines`, and `blueprint`. They are **not** in the default set — `wordpress-router` and `wp-project-triage` overlap with the `refact` and `code-development` skills; the others are situational. Install them explicitly only if the user asks.
|
|
37
|
+
|
|
38
|
+
## Step 1 — Preflight
|
|
39
|
+
|
|
40
|
+
### 1a. Confirm this is a WordPress project
|
|
41
|
+
|
|
42
|
+
Check `.refact-os.json` for a `stack.wordpress` entry, or look for `wp-content/` / `.wp-env.json`. If the project is **not** WordPress, stop and ask the user to confirm — these skills are WP-specific and have no value in a non-WordPress project.
|
|
43
|
+
|
|
44
|
+
### 1b. Check prerequisites
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
command -v git
|
|
48
|
+
command -v node
|
|
49
|
+
node --version
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
`node` must be **18 or newer** (the upstream `skillpack-build.mjs` script uses modern ESM + node:fs features). If it's older, surface the version and stop.
|
|
53
|
+
|
|
54
|
+
### 1c. Confirm with the user
|
|
55
|
+
|
|
56
|
+
Print the curated list above and ask the user to confirm before proceeding. Offer them the chance to:
|
|
57
|
+
|
|
58
|
+
- Accept the default subset.
|
|
59
|
+
- Add to it (e.g. include `wpds` for design system work).
|
|
60
|
+
- Subtract from it (e.g. skip `wp-playground` if they already use Local).
|
|
61
|
+
|
|
62
|
+
Record the final skill list as `<skills>` for Step 3.
|
|
63
|
+
|
|
64
|
+
## Step 2 — Clone upstream to a temp dir
|
|
65
|
+
|
|
66
|
+
Do **not** clone the upstream repo into the project tree — it would pollute git status. Use a temp directory:
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
WP_SKILLS_TMP="$(mktemp -d -t wp-agent-skills.XXXXXX)"
|
|
70
|
+
git clone --depth=1 https://github.com/WordPress/agent-skills.git "$WP_SKILLS_TMP"
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
If the clone fails (network, rate limit, repo moved), surface the exact error and stop. Do **not** retry by switching protocols or guessing alternate URLs.
|
|
74
|
+
|
|
75
|
+
## Step 3 — Build and install
|
|
76
|
+
|
|
77
|
+
From inside the temp clone, build the distribution and install only the chosen skills with `--targets=cursor`:
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
cd "$WP_SKILLS_TMP"
|
|
81
|
+
node shared/scripts/skillpack-build.mjs --clean
|
|
82
|
+
node shared/scripts/skillpack-install.mjs \
|
|
83
|
+
--dest="<absolute-path-to-this-project>" \
|
|
84
|
+
--targets=cursor \
|
|
85
|
+
--skills=<skills>
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
Notes:
|
|
89
|
+
|
|
90
|
+
- `<absolute-path-to-this-project>` is the directory where the user invoked `/refact`. Capture it before `cd`-ing into the temp dir (`PROJECT_ROOT="$(pwd)"` before the `cd`).
|
|
91
|
+
- `<skills>` is the comma-separated final list from Step 1c (e.g. `wp-block-development,wp-plugin-development,wp-rest-api,...`).
|
|
92
|
+
- The installer uses `--mode=replace` by default, which only overwrites the specific skill subfolders being installed. `.cursor/skills/refact/` and `.cursor/skills/code-development/` are untouched.
|
|
93
|
+
- Do **not** pass `--global` here — these skills should live in the project, not the user's home, so each engagement controls its own set.
|
|
94
|
+
|
|
95
|
+
If the install script errors with "Unknown skill: …", correct the name (skills are case-sensitive, kebab-case) and re-run. Don't silently drop the unknown name from the list.
|
|
96
|
+
|
|
97
|
+
## Step 4 — Clean up
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
rm -rf "$WP_SKILLS_TMP"
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
If `rm` fails (permissions, the user `cd`-ed into the tmp dir, etc.), surface it but do **not** retry with `sudo` or `-f` flags beyond what's shown.
|
|
104
|
+
|
|
105
|
+
## Step 5 — Verify and report
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
ls .cursor/skills/
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
Confirm each requested skill landed as `.cursor/skills/wp-<name>/SKILL.md`. Then report to the user:
|
|
112
|
+
|
|
113
|
+
- The list of installed skills with one-line descriptions (from the table above).
|
|
114
|
+
- A reminder that these skills are now available alongside `refact` and `code-development`, and will be auto-invoked by the agent when relevant tasks come up (e.g. asking to build a block triggers `wp-block-development`).
|
|
115
|
+
- A note that the skills are vendored copies — to update them later, the user can re-run `/refact install wp skills` and the installer will replace the existing folders.
|
|
116
|
+
|
|
117
|
+
## Updating later
|
|
118
|
+
|
|
119
|
+
To pull newer versions of the upstream skills, just re-run this flow. The `--mode=replace` default means each skill folder is rebuilt from the latest upstream contents — local edits to the vendored copies will be lost, so:
|
|
120
|
+
|
|
121
|
+
- If the user has modified a vendored skill, ask before overwriting.
|
|
122
|
+
- Encourage them to upstream the change to `WordPress/agent-skills` rather than fork locally.
|
|
123
|
+
|
|
124
|
+
## Guardrails
|
|
125
|
+
|
|
126
|
+
- **Never** clone the upstream repo into the project tree.
|
|
127
|
+
- **Never** install with `--global` from this flow — global installs belong to the user's home, not a per-project scaffolder.
|
|
128
|
+
- **Never** add `wordpress-router` or `wp-project-triage` to the default set — they overlap with `refact` routing.
|
|
129
|
+
- **Never** silently overwrite a user-modified vendored skill. Ask first.
|
|
130
|
+
- **Never** retry a failed clone or install with elevated permissions or alternative flags without user approval.
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: setup-kinsta-deploy
|
|
3
|
+
description: Create the Kinsta auto-deploy GitHub workflows for apps/wordpress. WordPress-on-Kinsta only.
|
|
4
|
+
pattern: procedure
|
|
5
|
+
requires_approval: true
|
|
6
|
+
when_to_use: /refact setup kinsta auto-deploy | add kinsta deploy | create kinsta workflows.
|
|
7
|
+
when_not_to_use: Non-Kinsta hosting.
|
|
8
|
+
next_skills: []
|
|
9
|
+
sub_agents: []
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
# Kinsta Auto-Deploy Reference
|
|
13
|
+
|
|
14
|
+
Use this reference when the user invokes any of:
|
|
15
|
+
|
|
16
|
+
- `/refact setup kinsta auto-deploy`
|
|
17
|
+
- `/refact add kinsta deploy`
|
|
18
|
+
- `/refact enable kinsta auto-deploy`
|
|
19
|
+
- `/refact create kinsta workflows`
|
|
20
|
+
|
|
21
|
+
This reference both **documents** how the Kinsta auto-deploy works for projects scaffolded by this package, and **drives the agent** to create the GitHub Actions workflow files on demand. The workflow YAMLs are *not* pre-vendored into the project — they are generated by following Step 2 below, because not every engagement deploys to Kinsta.
|
|
22
|
+
|
|
23
|
+
## TL;DR
|
|
24
|
+
|
|
25
|
+
```
|
|
26
|
+
push to main ──▶ .github/workflows/wordpress-deploy-main.yml ──▶ Kinsta prod
|
|
27
|
+
push to stage ──▶ .github/workflows/wordpress-deploy-stage.yml ──▶ Kinsta stage
|
|
28
|
+
|
|
29
|
+
(both path-filtered on apps/wordpress/**; both force-push a fresh single-commit
|
|
30
|
+
tree to Kinsta's bare SSH repo)
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Each workflow:
|
|
34
|
+
|
|
35
|
+
1. Checks out the monorepo.
|
|
36
|
+
2. `cd apps/wordpress && rm -rf .git && git init -b main` — fresh repo each run.
|
|
37
|
+
3. `git add .` — staging is filtered by `apps/wordpress/.gitignore` (WP core is excluded).
|
|
38
|
+
4. Force-pushes the single-commit tree to Kinsta's bare SSH endpoint.
|
|
39
|
+
5. Kinsta's post-receive hook checks the working tree into the WP install root.
|
|
40
|
+
|
|
41
|
+
## Step 1 — Preflight
|
|
42
|
+
|
|
43
|
+
### 1a. Confirm this is a WordPress project
|
|
44
|
+
|
|
45
|
+
Check `.refact-os.json` for a `stack.wordpress` entry and that `apps/wordpress/` exists. If not:
|
|
46
|
+
|
|
47
|
+
- No `apps/wordpress/` → stop and tell the user to scaffold the WordPress app first (`/refact add codebase wordpress`).
|
|
48
|
+
- `stack` has no `wordpress` entry → ask the user to confirm; this flow is WordPress-specific.
|
|
49
|
+
|
|
50
|
+
The **non-secret** deploy routing — each env's `branch`, and its `ssh` `host` / `port` / `path` plus the public `url` — lives in `.refact-os.json` › `stack.wordpress.environments` (`production` and `staging`); read it from there and keep it consistent with the GitHub Actions secrets the workflow consumes (`ENV_IP`, `ENV_NAME`, `ENV_DIRECTORY`, `ENV_*_PORT`). The SSH **private key** (`SSH_PRIV_KEY`) is a secret and lives only in GitHub Actions — never in `.refact-os.json`.
|
|
51
|
+
|
|
52
|
+
### 1b. Confirm the two `.gitignore` files are in place
|
|
53
|
+
|
|
54
|
+
| File | Purpose |
|
|
55
|
+
|---|---|
|
|
56
|
+
| `/.gitignore` (repo root) | Excludes other `apps/<name>/` slots from the monorepo. Pattern: `apps/*` + `!apps/wordpress/`. Adding a new tracked app means another carve-out line. |
|
|
57
|
+
| `/apps/wordpress/.gitignore` | Classic WP "ignore core, allow wp-content" filter. **Also** doubles as the filter for what reaches Kinsta — anything ignored here is never committed during the workflow's fresh-init step, so it never lands on Kinsta. |
|
|
58
|
+
|
|
59
|
+
If `apps/wordpress/.gitignore` is missing, stop. Do not generate one on the fly — the WordPress scaffold owns that file.
|
|
60
|
+
|
|
61
|
+
### 1c. Confirm with the user
|
|
62
|
+
|
|
63
|
+
Tell the user what is about to be created:
|
|
64
|
+
|
|
65
|
+
- `.github/workflows/wordpress-deploy-stage.yml`
|
|
66
|
+
- `.github/workflows/wordpress-deploy-main.yml`
|
|
67
|
+
|
|
68
|
+
And remind them which GitHub Actions secrets they will need to add **before** the workflows can succeed. List them:
|
|
69
|
+
|
|
70
|
+
| Secret | Purpose |
|
|
71
|
+
|---|---|
|
|
72
|
+
| `SSH_PRIV_KEY` | Private SSH key matching the public key added in Kinsta's SSH settings |
|
|
73
|
+
| `ENV_IP` | Kinsta server IP (shared between prod and stage) |
|
|
74
|
+
| `ENV_NAME` | Kinsta user / bare repo name |
|
|
75
|
+
| `ENV_DIRECTORY` | Path slug (e.g. `credaily_764`) |
|
|
76
|
+
| `ENV_PROD_PORT` | Kinsta production SSH port |
|
|
77
|
+
| `ENV_STG_PORT` | Kinsta staging SSH port |
|
|
78
|
+
|
|
79
|
+
Confirm before writing files.
|
|
80
|
+
|
|
81
|
+
## Step 2 — Create the workflow files
|
|
82
|
+
|
|
83
|
+
GitHub Actions only reads workflows from the **repo root** `/.github/workflows/`. Never place these under `apps/wordpress/.github/` — GitHub will not run them, and they would pollute Kinsta's checkout.
|
|
84
|
+
|
|
85
|
+
Each workflow's `branches:` filter must match the branch recorded for that env in `.refact-os.json` › `stack.wordpress.environments` — `staging.branch` drives the stage workflow, `production.branch` the main workflow. The examples below use `stage` and `main`; substitute the project's actual branch names if they differ.
|
|
86
|
+
|
|
87
|
+
### `/.github/workflows/wordpress-deploy-stage.yml`
|
|
88
|
+
|
|
89
|
+
```yaml
|
|
90
|
+
name: WordPress staging deploy
|
|
91
|
+
on:
|
|
92
|
+
push:
|
|
93
|
+
branches: [stage]
|
|
94
|
+
paths:
|
|
95
|
+
- 'apps/wordpress/**'
|
|
96
|
+
workflow_dispatch:
|
|
97
|
+
|
|
98
|
+
jobs:
|
|
99
|
+
deploy:
|
|
100
|
+
runs-on: ubuntu-latest
|
|
101
|
+
steps:
|
|
102
|
+
- uses: actions/checkout@v4
|
|
103
|
+
|
|
104
|
+
- name: Push apps/wordpress to Kinsta (staging)
|
|
105
|
+
run: |
|
|
106
|
+
mkdir -p ~/.ssh
|
|
107
|
+
chmod 700 ~/.ssh
|
|
108
|
+
eval $(ssh-agent -s)
|
|
109
|
+
echo "${{ secrets.SSH_PRIV_KEY }}" | tr -d '\r' | ssh-add -
|
|
110
|
+
ssh-keyscan -p${{ secrets.ENV_STG_PORT }} ${{ secrets.ENV_IP }} >> ~/.ssh/known_hosts
|
|
111
|
+
chmod 644 ~/.ssh/known_hosts
|
|
112
|
+
|
|
113
|
+
cd apps/wordpress
|
|
114
|
+
rm -rf .git
|
|
115
|
+
git init -b main
|
|
116
|
+
git config user.email "deploy@github.actions"
|
|
117
|
+
git config user.name "GitHub Actions"
|
|
118
|
+
git add .
|
|
119
|
+
git commit -m "Deploy ${{ github.sha }} from monorepo"
|
|
120
|
+
git push ssh://${{ secrets.ENV_NAME }}@${{ secrets.ENV_IP }}:${{ secrets.ENV_STG_PORT }}/www/${{ secrets.ENV_DIRECTORY }}/private/${{ secrets.ENV_NAME }}.git HEAD:main --force
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
### `/.github/workflows/wordpress-deploy-main.yml`
|
|
124
|
+
|
|
125
|
+
Identical to the stage file with these substitutions:
|
|
126
|
+
|
|
127
|
+
- `name:` → `WordPress production deploy`
|
|
128
|
+
- `branches: [stage]` → `branches: [main]`
|
|
129
|
+
- Step name → `Push apps/wordpress to Kinsta (production)`
|
|
130
|
+
- `${{ secrets.ENV_STG_PORT }}` → `${{ secrets.ENV_PROD_PORT }}` (in both the `ssh-keyscan` and `git push` lines)
|
|
131
|
+
|
|
132
|
+
Everything else — the path filter, the fresh-init logic, the force-push, the destination path `www/<ENV_DIRECTORY>/private/<ENV_NAME>.git` — stays the same.
|
|
133
|
+
|
|
134
|
+
## Step 3 — Report and hand off
|
|
135
|
+
|
|
136
|
+
Tell the user:
|
|
137
|
+
|
|
138
|
+
1. Which files were created.
|
|
139
|
+
2. The list of GitHub Actions secrets they must add at **Settings → Secrets and variables → Actions** before the first push. If any are missing, the workflow fails at the `ssh-add` or `git push` step.
|
|
140
|
+
3. The next step: push to `stage` first, watch the run in the Actions tab, then promote `stage → main` via PR.
|
|
141
|
+
4. That the workflows are **path-filtered** on `apps/wordpress/**`, so edits elsewhere in the monorepo will not trigger a deploy or burn Actions minutes.
|
|
142
|
+
|
|
143
|
+
## Adding new tracked files under `apps/wordpress/`
|
|
144
|
+
|
|
145
|
+
The nested `apps/wordpress/.gitignore` is an allow-list. New files in `wp-content/mu-plugins/`, `wp-content/plugins/`, or `wp-content/themes/` need an explicit `!` exception or git won't see them — and if git doesn't see them, neither does Kinsta.
|
|
146
|
+
|
|
147
|
+
Example for a new mu-plugin:
|
|
148
|
+
|
|
149
|
+
```gitignore
|
|
150
|
+
# apps/wordpress/.gitignore (excerpt)
|
|
151
|
+
wp-content/mu-plugins/*
|
|
152
|
+
!wp-content/mu-plugins/cre-daily
|
|
153
|
+
!wp-content/mu-plugins/cre-daily.php
|
|
154
|
+
!wp-content/mu-plugins/your-new-plugin.php
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
Verify it works before committing:
|
|
158
|
+
|
|
159
|
+
```bash
|
|
160
|
+
git check-ignore -v apps/wordpress/wp-content/mu-plugins/your-new-plugin.php
|
|
161
|
+
# Should print the `!...` rule line, NOT the `wp-content/mu-plugins/*` line.
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
`git status` showing the file as untracked is the green-light.
|
|
165
|
+
|
|
166
|
+
## Smoke-testing the auto-deploy
|
|
167
|
+
|
|
168
|
+
Round-trip test that doesn't touch theme/plugin code:
|
|
169
|
+
|
|
170
|
+
1. On `stage`, create `apps/wordpress/wp-content/mu-plugins/deploy-test.php`:
|
|
171
|
+
|
|
172
|
+
```php
|
|
173
|
+
<?php
|
|
174
|
+
/** Plugin Name: Deploy Test */
|
|
175
|
+
defined('ABSPATH') || exit;
|
|
176
|
+
add_action('wp_footer', function () {
|
|
177
|
+
echo '<div style="position:fixed;bottom:8px;right:8px;background:#222;color:#fff;padding:6px 10px;font:12px monospace;z-index:99999;">deploy ok · ' . esc_html(gmdate('c')) . '</div>';
|
|
178
|
+
});
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
2. Add `!wp-content/mu-plugins/deploy-test.php` to `apps/wordpress/.gitignore`.
|
|
182
|
+
3. Commit and `git push origin stage`.
|
|
183
|
+
4. Watch `https://github.com/<org>/<repo>/actions` → "WordPress staging deploy" run.
|
|
184
|
+
5. Visit the staging URL — bottom-right badge means the tree reached Kinsta and was checked out.
|
|
185
|
+
6. Revert via a **new commit** (don't amend) — delete the file, remove the gitignore line, push.
|
|
186
|
+
|
|
187
|
+
## Hard rules
|
|
188
|
+
|
|
189
|
+
1. **Force-push (`--force`) is required for the Kinsta endpoint and only the Kinsta endpoint.** Kinsta's bare repo can't fast-forward against a fresh-init tree. Never `--force` to GitHub's `main` or `stage`.
|
|
190
|
+
2. **Never delete or aggressively rewrite `apps/wordpress/.gitignore`.** It's load-bearing — without it, the fresh-init would push WordPress core files to Kinsta on every deploy. Kinsta provisions core; we only push wp-content additions.
|
|
191
|
+
3. **Never place workflows under `apps/wordpress/.github/`.** GitHub doesn't run nested workflows. If any exist there, delete them.
|
|
192
|
+
4. **Never push to `main` directly.** Stage gets validated first, then `stage → main` via PR.
|
|
193
|
+
5. **Don't bypass the path filter** (e.g. removing `paths: 'apps/wordpress/**'`). Doing so means every README edit redeploys to Kinsta.
|
|
194
|
+
|
|
195
|
+
## When to stop and ask the user
|
|
196
|
+
|
|
197
|
+
- About to add a path under `apps/wordpress/` and unsure if the nested allow-list covers it → run `git check-ignore -v` first; if it points at the wildcard rule, you need a new `!` line.
|
|
198
|
+
- A workflow run fails → diagnose, don't retry blindly. Common causes: missing secret, wrong port (`STG` vs `PROD`), SSH key not in Kinsta's allowlist, Kinsta-side bare repo missing.
|
|
199
|
+
- Stage deploy works but production doesn't pick up → confirm `ENV_PROD_PORT` ≠ `ENV_STG_PORT` and both point at the correct Kinsta env.
|
|
200
|
+
- About to delete, rename, or significantly rewrite `apps/wordpress/.gitignore` → stop.
|
|
201
|
+
- About to change a workflow to push something other than `apps/wordpress/` → that's an architecture change; surface and confirm scope.
|