prizmkit 1.1.156 → 1.1.160
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/bundled/VERSION.json +3 -3
- package/bundled/adapters/codebuddy/settings-adapter.js +76 -25
- package/bundled/dev-pipeline/prizmkit_runtime/gitops.py +9 -2
- package/bundled/dev-pipeline/prizmkit_runtime/reset.py +1 -1
- package/bundled/dev-pipeline/prizmkit_runtime/runner_classification.py +20 -11
- package/bundled/dev-pipeline/prizmkit_runtime/runtime_commit.py +42 -15
- package/bundled/dev-pipeline/scripts/update-feature-status.py +7 -0
- package/bundled/dev-pipeline/templates/bootstrap-prompt.md +1 -1
- package/bundled/dev-pipeline/templates/bootstrap-tier3.md +1 -1
- package/bundled/dev-pipeline/templates/sections/runtime-commit-handoff.md +6 -6
- package/bundled/dev-pipeline/tests/test_generate_bootstrap_prompt.py +4 -3
- package/bundled/dev-pipeline/tests/test_generate_bugfix_prompt.py +2 -2
- package/bundled/dev-pipeline/tests/test_generate_refactor_prompt.py +2 -2
- package/bundled/dev-pipeline/tests/test_python_runner_parity.py +115 -4
- package/bundled/dev-pipeline/tests/test_reset_modes.py +137 -0
- package/bundled/dev-pipeline/tests/test_runtime_commit.py +68 -13
- package/bundled/dev-pipeline/tests/test_unified_cli.py +12 -7
- package/bundled/rules/prizm/prizm-commit-workflow.md +7 -7
- package/bundled/rules/prizm/prizm-documentation.md +24 -65
- package/bundled/rules/prizm/prizm-progressive-loading.md +9 -8
- package/bundled/skills/_metadata.json +1 -1
- package/bundled/skills/prizmkit/SKILL.md +1 -13
- package/bundled/skills/prizmkit-code-review/SKILL.md +29 -10
- package/bundled/skills/prizmkit-code-review/references/independent-code-review.md +5 -4
- package/bundled/skills/prizmkit-code-review/references/review-report-template.md +15 -0
- package/bundled/skills/prizmkit-code-review/scripts/render_review_report.py +61 -0
- package/bundled/skills/prizmkit-committer/SKILL.md +50 -38
- package/bundled/skills/prizmkit-deploy/SKILL.md +172 -198
- package/bundled/skills/prizmkit-deploy/references/capability-contract.md +137 -0
- package/bundled/skills/prizmkit-deploy/references/deploy-record-schema.json +1053 -0
- package/bundled/skills/prizmkit-deploy/references/deployment-declaration-schema.json +291 -0
- package/bundled/skills/prizmkit-deploy/references/legacy-migration.md +90 -0
- package/bundled/skills/prizmkit-deploy/references/policy-and-execution.md +170 -0
- package/bundled/skills/prizmkit-deploy/references/real-resource-test-policy.md +73 -0
- package/bundled/skills/prizmkit-deploy/references/verification-and-recovery.md +164 -0
- package/bundled/skills/prizmkit-deploy/scripts/validate-deploy-artifact.py +371 -0
- package/bundled/skills/prizmkit-implement/SKILL.md +2 -2
- package/bundled/skills/prizmkit-init/SKILL.md +38 -42
- package/bundled/skills/prizmkit-init/references/config-schema.md +11 -7
- package/bundled/skills/prizmkit-init/references/rules/layer-detection.md +3 -3
- package/bundled/skills/prizmkit-init/references/update-supplement.md +5 -5
- package/bundled/skills/prizmkit-plan/SKILL.md +5 -4
- package/bundled/skills/prizmkit-plan/assets/plan-template.md +4 -1
- package/bundled/skills/prizmkit-plan/references/verification-checklist.md +3 -2
- package/bundled/skills/prizmkit-prizm-docs/SKILL.md +17 -11
- package/bundled/skills/prizmkit-prizm-docs/assets/prizm-docs-format.md +95 -155
- package/bundled/skills/prizmkit-prizm-docs/references/op-init.md +6 -5
- package/bundled/skills/prizmkit-prizm-docs/references/op-rebuild.md +4 -2
- package/bundled/skills/prizmkit-prizm-docs/references/op-status.md +9 -10
- package/bundled/skills/prizmkit-prizm-docs/references/op-update.md +6 -5
- package/bundled/skills/prizmkit-prizm-docs/references/op-validate.md +13 -12
- package/bundled/skills/prizmkit-retrospective/SKILL.md +3 -3
- package/bundled/skills/prizmkit-test/SKILL.md +26 -13
- package/bundled/skills/prizmkit-test/references/boundary-contract-and-test-double-guidance.md +8 -4
- package/bundled/skills/prizmkit-test/references/independent-test-review.md +7 -3
- package/bundled/skills/prizmkit-test/references/test-coverage-model.md +33 -10
- package/bundled/skills/prizmkit-test/references/test-report-template.md +33 -11
- package/bundled/skills/prizmkit-workflow/SKILL.md +33 -3
- package/bundled/skills/prizmkit-workflow/references/workflow-state-protocol.md +23 -5
- package/bundled/templates/hooks/commit-intent-status.py +9 -41
- package/bundled/templates/hooks/commit-intent.json +3 -3
- package/bundled/templates/hooks/diff-prizm-docs.py +3 -1
- package/bundled/templates/hooks/prizm-pre-commit.py +32 -6
- package/bundled/templates/hooks/run-python-hook.cjs +44 -0
- package/bundled/templates/hooks/validate-prizm-docs.py +399 -173
- package/bundled/templates/project-memory-template.md +19 -19
- package/package.json +1 -1
- package/src/clean.js +6 -7
- package/src/gitignore-template.js +8 -12
- package/src/scaffold.js +125 -71
- package/bundled/skills/prizmkit/references/workflow-state-protocol.md +0 -178
- package/bundled/skills/prizmkit-deploy/assets/deploy-document-template.md +0 -89
- package/bundled/skills/prizmkit-deploy/references/ci-cd-workflows.md +0 -145
- package/bundled/skills/prizmkit-deploy/references/cloud-platform-deploy.md +0 -109
- package/bundled/skills/prizmkit-deploy/references/data-safety-examples.md +0 -120
- package/bundled/skills/prizmkit-deploy/references/database-setup.md +0 -65
- package/bundled/skills/prizmkit-deploy/references/deploy-config-schema.md +0 -150
- package/bundled/skills/prizmkit-deploy/references/deploy-history-schema.md +0 -78
- package/bundled/skills/prizmkit-deploy/references/deploy-metadata-schema.json +0 -49
- package/bundled/skills/prizmkit-deploy/references/deployment-modes.md +0 -50
- package/bundled/skills/prizmkit-deploy/references/direct-upload.md +0 -26
- package/bundled/skills/prizmkit-deploy/references/dns-setup.md +0 -42
- package/bundled/skills/prizmkit-deploy/references/docker-deploy.md +0 -31
- package/bundled/skills/prizmkit-deploy/references/firewall-setup.md +0 -37
- package/bundled/skills/prizmkit-deploy/references/live-validation-notes.md +0 -21
- package/bundled/skills/prizmkit-deploy/references/nginx-blue-green.md +0 -59
- package/bundled/skills/prizmkit-deploy/references/pending-input-schema.json +0 -164
- package/bundled/skills/prizmkit-deploy/references/ssh-adapter-flow.md +0 -221
- package/bundled/skills/prizmkit-deploy/references/ssh-bootstrap-flow.md +0 -49
- package/bundled/skills/prizmkit-deploy/references/ssh-execution-flow.md +0 -41
- package/bundled/skills/prizmkit-deploy/references/ssh-takeover.md +0 -20
- package/bundled/skills/prizmkit-deploy/references/ssl-setup.md +0 -56
|
@@ -1,221 +0,0 @@
|
|
|
1
|
-
# SSH Adapter Flow
|
|
2
|
-
|
|
3
|
-
Read this file when Discovery routes `/prizmkit-deploy` to SSH Linux full automation.
|
|
4
|
-
|
|
5
|
-
The SSH adapter supports Node.js projects using PM2 + Nginx blue/green deployment.
|
|
6
|
-
|
|
7
|
-
## 1. Deployment Mode Selection
|
|
8
|
-
|
|
9
|
-
Before entering the configuration wizard, ask how the user wants to deploy:
|
|
10
|
-
|
|
11
|
-
1. **Direct Upload** — build locally, transfer artifacts to the server, start with PM2. Best for first deployment and low-spec servers.
|
|
12
|
-
2. **CI/CD Auto-Deploy** — configure GitHub Actions so pushes deploy automatically.
|
|
13
|
-
|
|
14
|
-
If the user chooses CI/CD, ask which mode:
|
|
15
|
-
|
|
16
|
-
- **Push mode** — GitHub Actions builds and SCPs artifacts to server. Low server load.
|
|
17
|
-
- **Pull mode** — server pulls code and builds itself. Simpler workflow but requires a deploy key and build tools on the server.
|
|
18
|
-
|
|
19
|
-
Read `references/deployment-modes.md` when the user needs the full comparison.
|
|
20
|
-
|
|
21
|
-
Config field: `deployStrategy` in `deploy.config.json` is `direct-upload`, `ci-cd-push`, or `ci-cd-pull`. Existing configs without this field default to `ci-cd-pull` for backward compatibility.
|
|
22
|
-
|
|
23
|
-
## 2. Server Model
|
|
24
|
-
|
|
25
|
-
A valid SSH target:
|
|
26
|
-
|
|
27
|
-
- Is reachable over SSH.
|
|
28
|
-
- Provides a Linux shell.
|
|
29
|
-
- Can install or already has Node.js, npm, PM2, Nginx, and Git.
|
|
30
|
-
- Can access the configured repository when using CI/CD Pull mode.
|
|
31
|
-
|
|
32
|
-
Roles:
|
|
33
|
-
|
|
34
|
-
- `bootstrapUser`: usually root; installs packages and creates users/directories.
|
|
35
|
-
- `runtimeUser`: default `deploy`; app processes run as this user and never as root.
|
|
36
|
-
|
|
37
|
-
Server-side layout:
|
|
38
|
-
|
|
39
|
-
```text
|
|
40
|
-
/var/www/<project>/
|
|
41
|
-
releases/
|
|
42
|
-
<release-id>/
|
|
43
|
-
shared/
|
|
44
|
-
.env.production
|
|
45
|
-
deploy-metadata.json
|
|
46
|
-
current -> releases/<release-id>
|
|
47
|
-
deploy-logs/
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
`shared/.env.production` is strict UTF-8 dotenv data with one unique `KEY=value` assignment per line; update it atomically, keep mode `600`, and require runtime-user ownership. `shared/deploy-metadata.json` must conform to `${SKILL_DIR}/references/deploy-metadata-schema.json`, be written atomically after successful live verification, and contain no secrets.
|
|
51
|
-
|
|
52
|
-
## 3. First-Run Configuration Wizard
|
|
53
|
-
|
|
54
|
-
Flow: deployment mode → collect → validate → confirm → persist.
|
|
55
|
-
|
|
56
|
-
Collect:
|
|
57
|
-
|
|
58
|
-
1. SSH server host/port, bootstrap user, runtime user, auth method.
|
|
59
|
-
2. Repository access only for `ci-cd-pull`: Git URL, branch, deploy-key or other auth.
|
|
60
|
-
3. App configuration: app id, path, package manager, install/build/start commands, blue/green port pair, health checks.
|
|
61
|
-
4. Environment variables: scan source for env references, ask for values or storage strategy.
|
|
62
|
-
5. Persist `deploy.config.json` and render/update `deploy.md` from `${SKILL_DIR}/assets/deploy-document-template.md`.
|
|
63
|
-
|
|
64
|
-
Validate SSH immediately with a harmless connectivity command before collecting deeper config. If SSH fails, stop and fix connectivity first.
|
|
65
|
-
|
|
66
|
-
## 4. Bootstrap
|
|
67
|
-
|
|
68
|
-
Before privileged bootstrap, present an action plan listing:
|
|
69
|
-
|
|
70
|
-
- packages to install
|
|
71
|
-
- users/groups to create
|
|
72
|
-
- SSH keys to generate
|
|
73
|
-
- Nginx config files to create/update
|
|
74
|
-
- directories and permissions
|
|
75
|
-
- services that may restart
|
|
76
|
-
|
|
77
|
-
Rules:
|
|
78
|
-
|
|
79
|
-
- User gives one explicit approval for the bootstrap plan.
|
|
80
|
-
- If the plan changes during execution, pause and ask again.
|
|
81
|
-
- Bootstrap operations must be idempotent.
|
|
82
|
-
- Existing config files must be backed up before modification.
|
|
83
|
-
- Failed bootstrap stops before deployment and provides recovery instructions.
|
|
84
|
-
|
|
85
|
-
Read `references/ssh-bootstrap-flow.md` for the detailed bootstrap procedure. It routes to `references/firewall-setup.md` and `references/database-setup.md` when those branches are selected.
|
|
86
|
-
|
|
87
|
-
## 5. Strategy-Specific Setup
|
|
88
|
-
|
|
89
|
-
Direct upload:
|
|
90
|
-
- Build locally and transfer artifacts.
|
|
91
|
-
- No Git operation is required on the server.
|
|
92
|
-
- Read `references/direct-upload.md`.
|
|
93
|
-
|
|
94
|
-
CI/CD push or pull:
|
|
95
|
-
- Generate `.github/workflows/deploy.yml` from `references/ci-cd-workflows.md`.
|
|
96
|
-
- Verify the first push to the configured branch will trigger deployment.
|
|
97
|
-
- Pull mode requires a deploy key on the server; show the public key and wait for the user to add it to GitHub Deploy Keys before verifying clone access.
|
|
98
|
-
|
|
99
|
-
After a successful direct-upload deployment, offer CI/CD setup so future `git push` can deploy automatically.
|
|
100
|
-
|
|
101
|
-
## 6. DNS and SSL
|
|
102
|
-
|
|
103
|
-
Before SSL, ask whether the user has a domain for the project.
|
|
104
|
-
|
|
105
|
-
- If no domain, skip DNS + SSL and note it in `deploy.md`.
|
|
106
|
-
- If a domain exists, check DNS before SSL.
|
|
107
|
-
- Read `references/dns-setup.md` for DNS instructions.
|
|
108
|
-
- Read `references/ssl-setup.md` for Let's Encrypt / certificate guidance.
|
|
109
|
-
|
|
110
|
-
Always verify certificate renewal when Let's Encrypt is configured.
|
|
111
|
-
|
|
112
|
-
## 7. Deployment Execution
|
|
113
|
-
|
|
114
|
-
Read `references/ssh-execution-flow.md` for the full pipeline.
|
|
115
|
-
|
|
116
|
-
Core sequence:
|
|
117
|
-
|
|
118
|
-
1. Pre-flight and prepare release.
|
|
119
|
-
2. Fetch/build or receive artifact.
|
|
120
|
-
3. Stage new process on inactive blue/green port.
|
|
121
|
-
4. Health-check inactive port.
|
|
122
|
-
5. Switch Nginx upstream only after staged health checks pass.
|
|
123
|
-
6. Verify public endpoint.
|
|
124
|
-
7. Stop old process, cleanup old releases, record history.
|
|
125
|
-
|
|
126
|
-
Failure rules:
|
|
127
|
-
|
|
128
|
-
- If any step before traffic switch fails, stop and leave the live version unchanged.
|
|
129
|
-
- If a public health check fails after traffic switch, rollback immediately.
|
|
130
|
-
- Do not delete failed release logs; preserve them for debugging.
|
|
131
|
-
|
|
132
|
-
## 8. Blue/Green PM2 + Nginx Invariants
|
|
133
|
-
|
|
134
|
-
- Default ports: blue `3101`, green `3102`.
|
|
135
|
-
- Active color is persisted in `shared/deploy-metadata.json` using `${SKILL_DIR}/references/deploy-metadata-schema.json`.
|
|
136
|
-
- PM2 process name: `<project>-<app>-<color>`.
|
|
137
|
-
- Nginx managed blocks include `# PrizmKit Managed: <project> — DO NOT EDIT MANUALLY`.
|
|
138
|
-
- First creation or modification of non-PrizmKit Nginx config requires user confirmation.
|
|
139
|
-
- Always run `nginx -t` before reload.
|
|
140
|
-
|
|
141
|
-
Read `references/nginx-blue-green.md` for config templates and traffic switch details.
|
|
142
|
-
|
|
143
|
-
## 9. Rollback
|
|
144
|
-
|
|
145
|
-
Rollback can be automatic or manual.
|
|
146
|
-
|
|
147
|
-
Manual command:
|
|
148
|
-
|
|
149
|
-
```text
|
|
150
|
-
/prizmkit-deploy rollback --app <id> [--to <releaseId>]
|
|
151
|
-
```
|
|
152
|
-
|
|
153
|
-
Steps:
|
|
154
|
-
|
|
155
|
-
1. Identify target release.
|
|
156
|
-
2. Verify build artifacts exist.
|
|
157
|
-
3. Start PM2 on the target release/port.
|
|
158
|
-
4. Update Nginx upstream.
|
|
159
|
-
5. Run `nginx -t` and reload.
|
|
160
|
-
6. Run public health checks; if they fail, restore the prior verified upstream.
|
|
161
|
-
7. Allocate and atomically write the rollback history event through `${SKILL_DIR}/references/deploy-history-schema.md`.
|
|
162
|
-
8. Atomically update `shared/deploy-metadata.json` through `${SKILL_DIR}/references/deploy-metadata-schema.json` with the restored release/color/port and rollback event identity.
|
|
163
|
-
|
|
164
|
-
If no previous release exists, state clearly that rollback is not possible.
|
|
165
|
-
|
|
166
|
-
## 10. Operations Commands
|
|
167
|
-
|
|
168
|
-
- `status`: PM2 list, active release, active color/port, last deploy.
|
|
169
|
-
- `logs --app <id>`: recent PM2 logs for active process.
|
|
170
|
-
- `restart --app <id>`: restart active PM2 process and run health checks.
|
|
171
|
-
- `health --app <id>`: run configured health checks.
|
|
172
|
-
- `history`: list deploy history events chronologically.
|
|
173
|
-
|
|
174
|
-
Run app commands as `runtimeUser`.
|
|
175
|
-
|
|
176
|
-
## 11. Secrets Management
|
|
177
|
-
|
|
178
|
-
Supported storage modes:
|
|
179
|
-
|
|
180
|
-
- `ask-every-time`
|
|
181
|
-
- `ignored-local-env`
|
|
182
|
-
- `user-managed-on-server-only`
|
|
183
|
-
|
|
184
|
-
Rules:
|
|
185
|
-
|
|
186
|
-
- `ignored-local-env` uses `.prizmkit/deploy/secrets.local.env`, must be ignored by Git and current-user-only, and follows `${SKILL_DIR}/references/database-setup.md` dotenv/migration safety.
|
|
187
|
-
- Legacy `plaintext-local` requires explicit migration to `ignored-local-env`; legacy `encrypted-local` is unsupported and requires user selection of a supported mode before deployment.
|
|
188
|
-
- Server runtime secrets live in `shared/.env.production` with mode `600`.
|
|
189
|
-
- Deploy history records secret presence metadata only.
|
|
190
|
-
- Never record raw secret values, passphrases, decryption keys, or unsalted hashes.
|
|
191
|
-
|
|
192
|
-
## 12. Existing Deployment Takeover
|
|
193
|
-
|
|
194
|
-
When the target server already has deployment assets, read `references/ssh-takeover.md`.
|
|
195
|
-
|
|
196
|
-
Record takeover decisions and validation results in config and history.
|
|
197
|
-
|
|
198
|
-
Before modifying non-PrizmKit-managed Nginx config, ask for confirmation.
|
|
199
|
-
|
|
200
|
-
## 13. Multi-App Coordination
|
|
201
|
-
|
|
202
|
-
An all-app deploy creates one release group.
|
|
203
|
-
|
|
204
|
-
Rules:
|
|
205
|
-
|
|
206
|
-
- Pre-traffic phases must complete for all selected apps before any app switches traffic.
|
|
207
|
-
- If any app fails before traffic switch, no app switches traffic.
|
|
208
|
-
- If any app fails after traffic switch, default to group rollback.
|
|
209
|
-
- Single-app deploys do not affect unrelated apps.
|
|
210
|
-
|
|
211
|
-
## 14. History and Validation
|
|
212
|
-
|
|
213
|
-
Write a deploy-history record for every deploy, rollback, takeover, validation, user-abort, failed deploy, or adapter gap.
|
|
214
|
-
|
|
215
|
-
Read:
|
|
216
|
-
|
|
217
|
-
- `references/deploy-history-schema.md`
|
|
218
|
-
- `references/deploy-config-schema.md`
|
|
219
|
-
- `references/live-validation-notes.md` when troubleshooting bootstrap or deploy failures
|
|
220
|
-
|
|
221
|
-
Validation is mandatory before production deploy.
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
# SSH Bootstrap Flow
|
|
2
|
-
|
|
3
|
-
Bootstraps the server before first deployment. Present a plan showing every privileged action before executing anything.
|
|
4
|
-
|
|
5
|
-
## Always-Run Preflight
|
|
6
|
-
|
|
7
|
-
```
|
|
8
|
-
locale-gen en_US.UTF-8 # fix locale warnings on bare Ubuntu
|
|
9
|
-
apt-get update -qq # refresh package list
|
|
10
|
-
```
|
|
11
|
-
|
|
12
|
-
## Check-and-Install (idempotent)
|
|
13
|
-
|
|
14
|
-
Node.js, npm, PM2, Nginx, Git. Use v22 LTS if v25 not available.
|
|
15
|
-
|
|
16
|
-
## Detect Port Conflicts
|
|
17
|
-
|
|
18
|
-
`ss -tlnp | grep :80 || true`. If port 80/443 is occupied, report and ask how to resolve.
|
|
19
|
-
|
|
20
|
-
## User and Directory Setup
|
|
21
|
-
|
|
22
|
-
```
|
|
23
|
-
useradd -m -s /bin/bash <runtimeUser> # if not exists
|
|
24
|
-
mkdir -p /var/www/<project>/{releases,shared,deploy-logs}
|
|
25
|
-
chown -R <runtimeUser>:<runtimeUser> /var/www/<project>
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
## PM2 Startup
|
|
29
|
-
|
|
30
|
-
```
|
|
31
|
-
env PATH=$PATH:/usr/bin pm2 startup systemd -u <runtimeUser> --hp /home/<runtimeUser>
|
|
32
|
-
```
|
|
33
|
-
|
|
34
|
-
## Deploy Key (Pull mode only)
|
|
35
|
-
|
|
36
|
-
```
|
|
37
|
-
sudo -u <runtimeUser> ssh-keygen -t ed25519 -f ~/.ssh/id_ed25519 -N ""
|
|
38
|
-
sudo -u <runtimeUser> ssh-keyscan -H github.com >> ~/.ssh/known_hosts
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
## Security Baseline (Firewall)
|
|
42
|
-
|
|
43
|
-
After core tools are installed, ask whether to configure ufw. If user agrees, read `references/firewall-setup.md` for the full interactive flow and rule templates.
|
|
44
|
-
|
|
45
|
-
## Database Setup
|
|
46
|
-
|
|
47
|
-
If Discovery detected database drivers, ask whether to install the database on the server. If user agrees, read `references/database-setup.md` for platform-specific setup commands and security notes.
|
|
48
|
-
|
|
49
|
-
After each bootstrap step, record the result. Bootstrap operations must be idempotent. Back up any existing config files before modifying them.
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
# SSH: Deployment Execution Flow
|
|
2
|
-
|
|
3
|
-
Pipeline runs in strict order. Each group must complete before the next begins. If any step before traffic switch fails, STOP — do not touch the live version.
|
|
4
|
-
|
|
5
|
-
## Pre-flight — Change Summary
|
|
6
|
-
|
|
7
|
-
Show what will be deployed using `git log --oneline <last-deployed-commit>..HEAD`. If first deployment, show last 5 commits. If no new commits, warn "No new code changes. Are you sure you want to redeploy?"
|
|
8
|
-
|
|
9
|
-
## Group 1 — Pre-flight & Prepare
|
|
10
|
-
|
|
11
|
-
- Verify SSH, runtime user, tools, deploy key, port availability.
|
|
12
|
-
- Generate `releaseId`: `YYYYMMDDTHHMMSSZ-<short-commit-sha>` in UTC. If that release directory already exists, select the lowest free suffix from `-01` through `-99`; never reuse or overwrite a release directory, and stop if the suffix space is exhausted. Create `releases/<releaseId>`.
|
|
13
|
-
- Determine target color: read `activeColor` from `shared/deploy-metadata.json` and use the opposite. If first deploy (no metadata, no `current` symlink), default to blue (port 3101).
|
|
14
|
-
|
|
15
|
-
## Group 2 — Fetch & Build
|
|
16
|
-
|
|
17
|
-
- **CI/CD Pull mode** (server-side build): git clone → install → copy `.env.production` before build (NEXT_PUBLIC_* vars are baked at build time) → build. If build fails: STOP.
|
|
18
|
-
- **CI/CD Push mode** (runner-side build): extract tarball, skip install/build.
|
|
19
|
-
- **Direct-upload mode**: build was already done locally and SCP'd. Skip this group.
|
|
20
|
-
|
|
21
|
-
## Group 3 — Stage & Health Check
|
|
22
|
-
|
|
23
|
-
- Start new version on inactive port via PM2: `pm2 start npm --name <project>-<app>-<color> -- run start -- -p <inactivePort>`.
|
|
24
|
-
- PM2 process naming: `<project>-<app>-<color>` (e.g., `prizm-ideas-web-green`).
|
|
25
|
-
- Wait 3-5 seconds, run health checks against new port. If any fails: STOP, do NOT switch traffic.
|
|
26
|
-
|
|
27
|
-
## Group 4 — Switch & Verify
|
|
28
|
-
|
|
29
|
-
- Update Nginx upstream to new port. Run `nginx -t` — abort on failure.
|
|
30
|
-
- `systemctl reload nginx`. Update `current` symlink to new release.
|
|
31
|
-
- Run health checks against the public endpoint. If any fails, rollback immediately and do not record the candidate as active.
|
|
32
|
-
|
|
33
|
-
## Group 5 — Cleanup & Record
|
|
34
|
-
|
|
35
|
-
- Allocate the collision-safe deploy event ID and atomically write deploy-history JSON using `${SKILL_DIR}/references/deploy-history-schema.md`, with event identity separate from `releaseId`.
|
|
36
|
-
- After the history record succeeds, atomically write `shared/deploy-metadata.json` from `${SKILL_DIR}/references/deploy-metadata-schema.json` with the verified `activeColor`, `activePort`, `lastReleaseId`, operation event ID, and UTC update time. If either record write fails, preserve both processes/releases, report a recording failure, and require the next operation to rediscover active state from Nginx plus the `current` symlink before retrying metadata repair.
|
|
37
|
-
- Stop the old PM2 process. Remove oldest releases beyond `releaseRetention` count. Run `pm2 save` and update `deploy.config.json` validation status.
|
|
38
|
-
|
|
39
|
-
## Post-deploy — Completion Summary
|
|
40
|
-
|
|
41
|
-
Output a summary (project, URL, version, duration, health status) and update the matching sections of `deploy.md` from `${SKILL_DIR}/assets/deploy-document-template.md`; do not append duplicate headings or an event log. If `deployStrategy` is `"direct-upload"`, offer CI/CD upgrade (see §SSH: Post-Deploy CI/CD Upgrade).
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
# SSH: Existing Deployment Takeover
|
|
2
|
-
|
|
3
|
-
When deploying to a server that already has deployment assets.
|
|
4
|
-
|
|
5
|
-
## Detection
|
|
6
|
-
|
|
7
|
-
1. Check for existing `/var/www/<project>` directory
|
|
8
|
-
2. Check for existing PM2 processes with similar names
|
|
9
|
-
3. Check Nginx config referencing the same domain/IP
|
|
10
|
-
4. Check for port conflicts
|
|
11
|
-
|
|
12
|
-
## Decision Flow
|
|
13
|
-
|
|
14
|
-
Report findings and ask for takeover decision:
|
|
15
|
-
|
|
16
|
-
- **Take over and backup**: Back up existing config, then proceed.
|
|
17
|
-
- **Coexist**: Use different directory/ports/process names.
|
|
18
|
-
- **Manual resolve**: Stop and let the user handle it.
|
|
19
|
-
|
|
20
|
-
Record takeover decision and validation results in config and history.
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
# SSL/HTTPS Configuration (Let's Encrypt + Certbot)
|
|
2
|
-
|
|
3
|
-
Read this file when DNS is confirmed pointing to the server and SSL needs to be configured.
|
|
4
|
-
|
|
5
|
-
## Step 1 — Detect cloud vendor
|
|
6
|
-
|
|
7
|
-
```
|
|
8
|
-
# Try metadata endpoints to detect cloud vendor
|
|
9
|
-
curl -s --connect-timeout 2 http://100.100.100.200/latest/meta-data/ && echo "ALIBABA"
|
|
10
|
-
curl -s --connect-timeout 2 http://metadata.tencentyun.com/latest/meta-data/ && echo "TENCENT"
|
|
11
|
-
curl -s --connect-timeout 2 http://169.254.169.254/latest/meta-data/ && echo "AWS/GCP/AZURE"
|
|
12
|
-
```
|
|
13
|
-
Also check `/etc/hostname` for vendor patterns.
|
|
14
|
-
|
|
15
|
-
## Step 2 — Choose SSL strategy
|
|
16
|
-
|
|
17
|
-
- **Cloud vendor detected** → ask user:
|
|
18
|
-
> "Detected the server is running on <cloud-vendor>. Which SSL approach?"
|
|
19
|
-
> - **A. Let's Encrypt free certificate (recommended)** — one command for permanent auto-renewal, hassle-free
|
|
20
|
-
> - **B. <cloud-vendor> native certificate** — manual download/config, 1-year validity requires manual renewal
|
|
21
|
-
>
|
|
22
|
-
> Choose A and I'll set it up for you; choose B and you'll need to download the certificate from the cloud console and tell me the path.
|
|
23
|
-
- **No cloud vendor / unknown** → use certbot directly, no choice needed.
|
|
24
|
-
|
|
25
|
-
## Step 3 — Certbot install & certificate request
|
|
26
|
-
|
|
27
|
-
```
|
|
28
|
-
# Install certbot (idempotent)
|
|
29
|
-
which certbot || apt-get install -y certbot python3-certbot-nginx
|
|
30
|
-
|
|
31
|
-
# Request certificate
|
|
32
|
-
certbot --nginx -d <domain> -d www.<domain> --non-interactive --agree-tos --email <user-email>
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
**Collect from user before running:**
|
|
36
|
-
- Email address (Let's Encrypt expiry notifications)
|
|
37
|
-
- Confirm domain list (e.g., `example.com, www.example.com`)
|
|
38
|
-
|
|
39
|
-
## Step 4 — Verify auto-renewal
|
|
40
|
-
|
|
41
|
-
```
|
|
42
|
-
systemctl status certbot.timer
|
|
43
|
-
certbot renew --dry-run
|
|
44
|
-
```
|
|
45
|
-
If timer is inactive, enable it: `systemctl enable --now certbot.timer`.
|
|
46
|
-
|
|
47
|
-
## Step 5 — Record
|
|
48
|
-
|
|
49
|
-
- Write SSL configuration summary to deploy.md: certificate paths, auto-renewal status, expiry date.
|
|
50
|
-
- Record a `"ssl-setup"` event in deploy history.
|
|
51
|
-
|
|
52
|
-
## Edge cases
|
|
53
|
-
|
|
54
|
-
- **DNS not yet propagated** → certbot challenge fails. Tell user to wait and retry: `/prizmkit-deploy setup-ssl`.
|
|
55
|
-
- **Existing certificate found** → check expiry date (`certbot certificates`). If expiring within 30 days, warn. Otherwise skip.
|
|
56
|
-
- **Port 80/443 occupied by non-Nginx process** → report and ask how to resolve before proceeding.
|