prizmkit 1.1.159 → 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.
Files changed (77) hide show
  1. package/bundled/VERSION.json +3 -3
  2. package/bundled/adapters/codebuddy/settings-adapter.js +76 -25
  3. package/bundled/dev-pipeline/prizmkit_runtime/gitops.py +9 -2
  4. package/bundled/dev-pipeline/prizmkit_runtime/runtime_commit.py +42 -15
  5. package/bundled/dev-pipeline/templates/bootstrap-prompt.md +1 -1
  6. package/bundled/dev-pipeline/templates/bootstrap-tier3.md +1 -1
  7. package/bundled/dev-pipeline/templates/sections/runtime-commit-handoff.md +6 -6
  8. package/bundled/dev-pipeline/tests/test_generate_bootstrap_prompt.py +4 -3
  9. package/bundled/dev-pipeline/tests/test_generate_bugfix_prompt.py +2 -2
  10. package/bundled/dev-pipeline/tests/test_generate_refactor_prompt.py +2 -2
  11. package/bundled/dev-pipeline/tests/test_runtime_commit.py +68 -13
  12. package/bundled/dev-pipeline/tests/test_unified_cli.py +10 -6
  13. package/bundled/rules/prizm/prizm-commit-workflow.md +7 -7
  14. package/bundled/rules/prizm/prizm-documentation.md +24 -65
  15. package/bundled/rules/prizm/prizm-progressive-loading.md +9 -8
  16. package/bundled/skills/_metadata.json +1 -1
  17. package/bundled/skills/prizmkit-code-review/SKILL.md +1 -1
  18. package/bundled/skills/prizmkit-committer/SKILL.md +48 -41
  19. package/bundled/skills/prizmkit-deploy/SKILL.md +172 -198
  20. package/bundled/skills/prizmkit-deploy/references/capability-contract.md +137 -0
  21. package/bundled/skills/prizmkit-deploy/references/deploy-record-schema.json +1053 -0
  22. package/bundled/skills/prizmkit-deploy/references/deployment-declaration-schema.json +291 -0
  23. package/bundled/skills/prizmkit-deploy/references/legacy-migration.md +90 -0
  24. package/bundled/skills/prizmkit-deploy/references/policy-and-execution.md +170 -0
  25. package/bundled/skills/prizmkit-deploy/references/real-resource-test-policy.md +73 -0
  26. package/bundled/skills/prizmkit-deploy/references/verification-and-recovery.md +164 -0
  27. package/bundled/skills/prizmkit-deploy/scripts/validate-deploy-artifact.py +371 -0
  28. package/bundled/skills/prizmkit-implement/SKILL.md +2 -2
  29. package/bundled/skills/prizmkit-init/SKILL.md +17 -17
  30. package/bundled/skills/prizmkit-init/references/update-supplement.md +5 -5
  31. package/bundled/skills/prizmkit-prizm-docs/SKILL.md +17 -11
  32. package/bundled/skills/prizmkit-prizm-docs/assets/prizm-docs-format.md +95 -155
  33. package/bundled/skills/prizmkit-prizm-docs/references/op-init.md +6 -5
  34. package/bundled/skills/prizmkit-prizm-docs/references/op-rebuild.md +4 -2
  35. package/bundled/skills/prizmkit-prizm-docs/references/op-status.md +9 -10
  36. package/bundled/skills/prizmkit-prizm-docs/references/op-update.md +6 -5
  37. package/bundled/skills/prizmkit-prizm-docs/references/op-validate.md +13 -12
  38. package/bundled/skills/prizmkit-retrospective/SKILL.md +3 -3
  39. package/bundled/skills/prizmkit-test/SKILL.md +26 -13
  40. package/bundled/skills/prizmkit-test/references/boundary-contract-and-test-double-guidance.md +8 -4
  41. package/bundled/skills/prizmkit-test/references/independent-test-review.md +7 -3
  42. package/bundled/skills/prizmkit-test/references/test-coverage-model.md +33 -10
  43. package/bundled/skills/prizmkit-test/references/test-report-template.md +33 -11
  44. package/bundled/skills/prizmkit-workflow/SKILL.md +5 -7
  45. package/bundled/skills/prizmkit-workflow/references/workflow-state-protocol.md +5 -6
  46. package/bundled/templates/hooks/commit-intent-status.py +9 -41
  47. package/bundled/templates/hooks/commit-intent.json +3 -3
  48. package/bundled/templates/hooks/diff-prizm-docs.py +3 -1
  49. package/bundled/templates/hooks/prizm-pre-commit.py +32 -6
  50. package/bundled/templates/hooks/run-python-hook.cjs +44 -0
  51. package/bundled/templates/hooks/validate-prizm-docs.py +399 -173
  52. package/bundled/templates/project-memory-template.md +19 -19
  53. package/package.json +1 -1
  54. package/src/clean.js +6 -7
  55. package/src/gitignore-template.js +8 -12
  56. package/src/scaffold.js +125 -71
  57. package/bundled/skills/prizmkit-deploy/assets/deploy-document-template.md +0 -89
  58. package/bundled/skills/prizmkit-deploy/references/ci-cd-workflows.md +0 -145
  59. package/bundled/skills/prizmkit-deploy/references/cloud-platform-deploy.md +0 -109
  60. package/bundled/skills/prizmkit-deploy/references/data-safety-examples.md +0 -120
  61. package/bundled/skills/prizmkit-deploy/references/database-setup.md +0 -65
  62. package/bundled/skills/prizmkit-deploy/references/deploy-config-schema.md +0 -150
  63. package/bundled/skills/prizmkit-deploy/references/deploy-history-schema.md +0 -78
  64. package/bundled/skills/prizmkit-deploy/references/deploy-metadata-schema.json +0 -49
  65. package/bundled/skills/prizmkit-deploy/references/deployment-modes.md +0 -50
  66. package/bundled/skills/prizmkit-deploy/references/direct-upload.md +0 -26
  67. package/bundled/skills/prizmkit-deploy/references/dns-setup.md +0 -42
  68. package/bundled/skills/prizmkit-deploy/references/docker-deploy.md +0 -31
  69. package/bundled/skills/prizmkit-deploy/references/firewall-setup.md +0 -37
  70. package/bundled/skills/prizmkit-deploy/references/live-validation-notes.md +0 -21
  71. package/bundled/skills/prizmkit-deploy/references/nginx-blue-green.md +0 -59
  72. package/bundled/skills/prizmkit-deploy/references/pending-input-schema.json +0 -164
  73. package/bundled/skills/prizmkit-deploy/references/ssh-adapter-flow.md +0 -221
  74. package/bundled/skills/prizmkit-deploy/references/ssh-bootstrap-flow.md +0 -49
  75. package/bundled/skills/prizmkit-deploy/references/ssh-execution-flow.md +0 -41
  76. package/bundled/skills/prizmkit-deploy/references/ssh-takeover.md +0 -20
  77. package/bundled/skills/prizmkit-deploy/references/ssl-setup.md +0 -56
@@ -1,42 +0,0 @@
1
- # DNS Setup Guidance
2
-
3
- Read this file when the user has a domain for their project but DNS is not yet pointing to the server.
4
-
5
- ## Step 1 — Check DNS resolution
6
-
7
- ```
8
- dig +short <domain> A
9
- ```
10
-
11
- If it resolves to the server IP: DNS is already configured, proceed to SSL (`references/ssl-setup.md`).
12
- If not: continue below.
13
-
14
- ## Step 2 — DNS setup guidance
15
-
16
- ```
17
- Domain <example.com> is not yet pointing to server <server-IP>.
18
-
19
- Add the following record at your DNS provider (e.g., Alibaba Cloud, Cloudflare, Namecheap):
20
-
21
- Type: A
22
- Name: @
23
- Value: <server-IP>
24
- TTL: 600
25
-
26
- To also support the www subdomain:
27
- Type: A
28
- Name: www
29
- Value: <server-IP>
30
-
31
- Reply "done" when configured, and I'll verify and set up the SSL certificate.
32
- ```
33
-
34
- ## Step 3 — Verify after user confirmation
35
-
36
- - Re-run `dig +short <domain> A` to confirm resolution.
37
- - If still not resolved: warn about DNS propagation delay (can take up to 48 hours, usually 5-30 minutes). Offer to wait or continue without SSL for now.
38
- - Once confirmed: proceed to SSL (`references/ssl-setup.md`).
39
-
40
- ## Edge case — IP-only deployment
41
-
42
- If user has no domain: skip DNS + SSL sections. Generate a note in deploy.md: "Project accessed via IP, no domain or HTTPS configured. Recommend purchasing a domain and running `/prizmkit-deploy setup-ssl`."
@@ -1,31 +0,0 @@
1
- # Docker Deployment Path
2
-
3
- Guided deployment when a `Dockerfile` or `docker-compose.yml` is detected, or the user requests Docker deployment.
4
-
5
- ## Detect and Configure
6
-
7
- 1. Read `Dockerfile` — extract base image, exposed ports, build steps.
8
- 2. Read `docker-compose.yml` if present — extract services, volumes, environment, ports.
9
- 3. Identify image name: from compose project name or repo directory name.
10
- 4. Identify port mappings: from `EXPOSE`, `ports:` in compose, or ask the user.
11
-
12
- ## Build and Deploy
13
-
14
- 1. Build: `docker build -t <project>:<releaseId> .` or `docker compose build`.
15
- 2. Check for running containers with the same name: `docker ps -a --filter name=<project>`.
16
- 3. If a previous container exists:
17
- - For blue/green on a server with Nginx: start new container on different port, health check, switch upstream.
18
- - For single-container setup: stop old, start new — warn about brief downtime.
19
- 4. Start: `docker run -d --name <project>-<releaseId> -p <port>:<port> <project>:<releaseId>` or `docker compose up -d`.
20
- 5. Health check the new container.
21
- 6. Write deploy-history event.
22
-
23
- ## Operations
24
-
25
- | Command | Docker CLI |
26
- |---------|-----------|
27
- | status | `docker ps --filter name=<project>` |
28
- | logs | `docker logs <container-name> --tail 100` |
29
- | restart | `docker restart <container-name>` |
30
- | rollback | `docker stop <new-container> && docker start <old-container>` |
31
- | cleanup | `docker image prune -a --filter "label=project=<project>"` |
@@ -1,37 +0,0 @@
1
- # Firewall Setup (UFW)
2
-
3
- Read this file when the user wants AI-assisted firewall configuration during bootstrap.
4
-
5
- ## Flow
6
-
7
- 1. After core tools are installed, ask the user:
8
- > "Want me to configure the firewall (ufw)? Only necessary ports will be opened, improving server security."
9
-
10
- 2. If user declines: skip, record to deploy config.
11
-
12
- 3. If user agrees, ask which additional ports to open (beyond SSH/HTTP/HTTPS):
13
- > "By default only SSH(22), HTTP(80), HTTPS(443) are opened. Should the blue/green preview ports (3101/3102) also be opened? If you need other ports (e.g., for remote database management), list them together."
14
-
15
- 4. Collect ports, then ask:
16
- > "Firewall rules are ready. Should I apply them directly, or will you do it yourself?"
17
- > - **A. You apply them** — AI runs ufw commands
18
- > - **B. I'll do it myself** — output rule list, user executes manually
19
-
20
- ## Planned rules (output before executing)
21
-
22
- ```
23
- ufw default deny incoming
24
- ufw default allow outgoing
25
- ufw allow 22/tcp # SSH
26
- ufw allow 80/tcp # HTTP
27
- ufw allow 443/tcp # HTTPS
28
- ufw allow 3101/tcp # blue preview (user-approved)
29
- ufw allow 3102/tcp # green preview (user-approved)
30
- ufw --force enable
31
- ```
32
-
33
- ## Rules for automatic execution
34
-
35
- - Check `ufw status` first — if rules already exist, append only missing rules, don't overwrite.
36
- - Never `ufw reset` unless explicitly asked, because it wipes custom rules the user may have configured manually.
37
- - Record a `"security-baseline"` event in deploy history with the rule list, so future sessions can detect existing configuration.
@@ -1,21 +0,0 @@
1
- # Implementation Notes from Live Validation
2
-
3
- These findings from the first PrizmKit deployment (PrizmIdeas) guide edge-case handling. Read when troubleshooting bootstrap or deploy issues.
4
-
5
- 1. **Detect port conflicts before installing Nginx.** Check what's on port 80/443 and ask before stopping anything, because overwriting an existing web server without confirmation can break unrelated services.
6
-
7
- 2. **Verify npm separately from node.** Minimal Node installs may not bundle npm. Run `which npm` after installing Node, because `node --version` succeeding doesn't guarantee npm is available.
8
-
9
- 3. **Fix locale on bare Ubuntu.** Run `locale-gen en_US.UTF-8` early to avoid perl warnings in apt. This is safe to run unconditionally even if locale is already configured.
10
-
11
- 4. **Deploy key workflow is inherently interactive.** Generate key → wait for user to add to GitHub → verify. Headless mode cannot complete this because it requires the user to paste the key into GitHub's UI.
12
-
13
- 5. **`pm2 startup` needs explicit PATH.** Always use `env PATH=$PATH:/usr/bin pm2 startup ...`, because the pm2 binary may not be on root's default PATH.
14
-
15
- 6. **Persist deploy metadata on server.** After public health and history recording succeed, atomically write `shared/deploy-metadata.json` from `${SKILL_DIR}/references/deploy-metadata-schema.json`, including active color/port, release identity, operation event identity, and UTC update time. Subsequent deploys and rollbacks depend on this active-slot record.
16
-
17
- 7. **Detect first deployment.** If no `current` symlink and no PM2 process for the app, skip rollback safety checks and use blue (3101) as initial color.
18
-
19
- 8. **Build-time env vars.** Copy `.env.production` before `npm run build`, not after. `NEXT_PUBLIC_*` vars are baked at build time and won't be picked up if the .env is added later.
20
-
21
- 9. **Node.js version flexibility.** Default to v22 LTS if v25 is unavailable. Most frameworks tolerate a minor version diff, and v22 has broader package compatibility.
@@ -1,59 +0,0 @@
1
- # Nginx Blue/Green Configuration Template
2
-
3
- ## Server Block Template
4
-
5
- ```nginx
6
- # PrizmKit Managed: <project> — DO NOT EDIT MANUALLY
7
- upstream <project>_backend {
8
- server 127.0.0.1:<activePort>;
9
- }
10
-
11
- server {
12
- listen 80 default_server;
13
- server_name _;
14
-
15
- # PrizmKit managed marker: <project>
16
- location / {
17
- proxy_pass http://<project>_backend;
18
- proxy_http_version 1.1;
19
- proxy_set_header Host $host;
20
- proxy_set_header X-Real-IP $remote_addr;
21
- proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
22
- proxy_set_header X-Forwarded-Proto $scheme;
23
- }
24
- }
25
- ```
26
-
27
- ## Traffic Switch Procedure
28
-
29
- When switching from one color to another:
30
-
31
- 1. Update the `upstream` block: change `server 127.0.0.1:<oldPort>` to `server 127.0.0.1:<newPort>`
32
- 2. Run `nginx -t` to validate syntax
33
- 3. If syntax check passes: `systemctl reload nginx`
34
- 4. If syntax check fails: DO NOT reload. Abort the switch. Report the error.
35
-
36
- ## Managed Marker
37
-
38
- All PrizmKit-generated Nginx config must contain:
39
- ```
40
- # PrizmKit Managed: <project> — DO NOT EDIT MANUALLY
41
- ```
42
-
43
- Before modifying any server block that lacks this marker, ask for user confirmation.
44
-
45
- ## First-Time Setup
46
-
47
- - Disable default nginx site: `rm -f /etc/nginx/sites-enabled/default`
48
- - Create new config: `/etc/nginx/sites-available/<project>`
49
- - Symlink: `ln -sf /etc/nginx/sites-available/<project> /etc/nginx/sites-enabled/<project>`
50
- - Test: `nginx -t`
51
- - Reload: `systemctl reload nginx`
52
-
53
- ## Rediscovery of Active Port
54
-
55
- If `deploy-metadata.json` is missing, rediscover the active upstream port from Nginx config:
56
- ```
57
- grep "server 127.0.0.1:" /etc/nginx/sites-available/<project>
58
- ```
59
- Then match the port against configured blue/green ports to determine active color.
@@ -1,164 +0,0 @@
1
- {
2
- "$schema": "https://json-schema.org/draft/2020-12/schema",
3
- "title": "PrizmKit Deployment Pending Input",
4
- "type": "object",
5
- "additionalProperties": false,
6
- "required": [
7
- "schema_version",
8
- "result",
9
- "operation",
10
- "environment",
11
- "known_context",
12
- "questions"
13
- ],
14
- "properties": {
15
- "schema_version": {
16
- "const": 1
17
- },
18
- "result": {
19
- "const": "NEEDS_INPUT"
20
- },
21
- "operation": {
22
- "enum": [
23
- "configure",
24
- "deploy",
25
- "status",
26
- "logs",
27
- "restart",
28
- "rollback",
29
- "health",
30
- "history",
31
- "validate"
32
- ]
33
- },
34
- "environment": {
35
- "enum": ["dev", "test", null]
36
- },
37
- "known_context": {
38
- "type": "object",
39
- "additionalProperties": false,
40
- "required": ["project_type", "target", "config_path"],
41
- "properties": {
42
- "project_type": {
43
- "type": ["string", "null"]
44
- },
45
- "target": {
46
- "type": ["string", "null"]
47
- },
48
- "config_path": {
49
- "const": ".prizmkit/deploy/deploy.config.json"
50
- }
51
- }
52
- },
53
- "questions": {
54
- "type": "array",
55
- "minItems": 1,
56
- "items": {
57
- "type": "object",
58
- "additionalProperties": false,
59
- "required": [
60
- "id",
61
- "prompt",
62
- "answer_type",
63
- "required",
64
- "config_pointer",
65
- "options"
66
- ],
67
- "properties": {
68
- "id": {
69
- "type": "string",
70
- "pattern": "^[a-z][a-z0-9_]{0,63}$"
71
- },
72
- "prompt": {
73
- "type": "string",
74
- "minLength": 1
75
- },
76
- "answer_type": {
77
- "enum": ["text", "single_choice", "multi_choice", "boolean", "integer"]
78
- },
79
- "required": {
80
- "type": "boolean"
81
- },
82
- "config_pointer": {
83
- "type": "string",
84
- "pattern": "^/(?:[^~/]|~[01])+(?:/(?:[^~/]|~[01])*)*$"
85
- },
86
- "options": {
87
- "type": "array",
88
- "items": {
89
- "type": "object",
90
- "additionalProperties": false,
91
- "required": ["value", "label"],
92
- "properties": {
93
- "value": {
94
- "type": ["string", "number", "boolean"]
95
- },
96
- "label": {
97
- "type": "string",
98
- "minLength": 1
99
- }
100
- }
101
- }
102
- }
103
- },
104
- "allOf": [
105
- {
106
- "if": {
107
- "properties": {
108
- "answer_type": {
109
- "enum": ["single_choice", "multi_choice"]
110
- }
111
- }
112
- },
113
- "then": {
114
- "properties": {
115
- "options": {
116
- "minItems": 1
117
- }
118
- }
119
- },
120
- "else": {
121
- "properties": {
122
- "options": {
123
- "maxItems": 0
124
- }
125
- }
126
- }
127
- }
128
- ]
129
- }
130
- }
131
- },
132
- "examples": [
133
- {
134
- "schema_version": 1,
135
- "result": "NEEDS_INPUT",
136
- "operation": "configure",
137
- "environment": null,
138
- "known_context": {
139
- "project_type": "Node.js",
140
- "target": null,
141
- "config_path": ".prizmkit/deploy/deploy.config.json"
142
- },
143
- "questions": [
144
- {
145
- "id": "deployment_target",
146
- "prompt": "Which deployment target should this project use?",
147
- "answer_type": "single_choice",
148
- "required": true,
149
- "config_pointer": "/deploymentMode",
150
- "options": [
151
- {
152
- "value": "ssh",
153
- "label": "SSH Linux server"
154
- },
155
- {
156
- "value": "docker",
157
- "label": "Docker"
158
- }
159
- ]
160
- }
161
- ]
162
- }
163
- ]
164
- }
@@ -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).