prizmkit 1.1.111 → 1.1.112

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 (110) hide show
  1. package/bundled/VERSION.json +3 -3
  2. package/bundled/agents/prizm-dev-team-reviewer.md +12 -1
  3. package/bundled/dev-pipeline/prizmkit_runtime/interoperability.py +1 -0
  4. package/bundled/dev-pipeline/scripts/generate-bootstrap-prompt.py +19 -73
  5. package/bundled/dev-pipeline/scripts/generate-bugfix-prompt.py +283 -421
  6. package/bundled/dev-pipeline/scripts/generate-recovery-prompt.py +1 -1
  7. package/bundled/dev-pipeline/scripts/generate-refactor-prompt.py +259 -481
  8. package/bundled/dev-pipeline/scripts/init-bugfix-pipeline.py +34 -0
  9. package/bundled/dev-pipeline/scripts/init-pipeline.py +12 -0
  10. package/bundled/dev-pipeline/scripts/init-refactor-pipeline.py +24 -1
  11. package/bundled/dev-pipeline/scripts/prompt_framework.py +312 -0
  12. package/bundled/dev-pipeline/scripts/update-bug-status.py +87 -20
  13. package/bundled/dev-pipeline/scripts/update-feature-status.py +82 -16
  14. package/bundled/dev-pipeline/scripts/update-refactor-status.py +68 -28
  15. package/bundled/dev-pipeline/scripts/utils.py +171 -0
  16. package/bundled/dev-pipeline/templates/bootstrap-prompt.md +1 -1
  17. package/bundled/dev-pipeline/templates/bootstrap-tier2.md +10 -18
  18. package/bundled/dev-pipeline/templates/bootstrap-tier3.md +14 -25
  19. package/bundled/dev-pipeline/templates/bug-fix-list-schema.json +9 -1
  20. package/bundled/dev-pipeline/templates/bugfix-bootstrap-prompt.md +11 -8
  21. package/bundled/dev-pipeline/templates/refactor-bootstrap-prompt.md +122 -182
  22. package/bundled/dev-pipeline/templates/sections/bugfix-artifacts.md +16 -0
  23. package/bundled/dev-pipeline/templates/sections/bugfix-critical-paths.md +12 -0
  24. package/bundled/dev-pipeline/templates/sections/bugfix-mission.md +9 -0
  25. package/bundled/dev-pipeline/templates/sections/bugfix-phase-commit-report.md +31 -0
  26. package/bundled/dev-pipeline/templates/sections/bugfix-phase-critic.md +22 -0
  27. package/bundled/dev-pipeline/templates/sections/bugfix-phase-diagnose-plan.md +23 -0
  28. package/bundled/dev-pipeline/templates/sections/bugfix-phase-implement.md +20 -0
  29. package/bundled/dev-pipeline/templates/sections/bugfix-phase-init.md +9 -0
  30. package/bundled/dev-pipeline/templates/sections/bugfix-phase-manual-verification.md +15 -0
  31. package/bundled/dev-pipeline/templates/sections/bugfix-phase-review.md +29 -0
  32. package/bundled/dev-pipeline/templates/sections/bugfix-reminders.md +11 -0
  33. package/bundled/dev-pipeline/templates/sections/bugfix-session-context.md +7 -0
  34. package/bundled/dev-pipeline/templates/sections/bugfix-session-status.md +31 -0
  35. package/bundled/dev-pipeline/templates/sections/bugfix-task-contract.md +40 -0
  36. package/bundled/dev-pipeline/templates/sections/failure-capture.md +2 -2
  37. package/bundled/dev-pipeline/templates/sections/phase-browser-verification-auto.md +1 -1
  38. package/bundled/dev-pipeline/templates/sections/refactor-artifacts.md +17 -0
  39. package/bundled/dev-pipeline/templates/sections/refactor-critical-paths.md +13 -0
  40. package/bundled/dev-pipeline/templates/sections/refactor-mission.md +9 -0
  41. package/bundled/dev-pipeline/templates/sections/refactor-phase-commit-report.md +37 -0
  42. package/bundled/dev-pipeline/templates/sections/refactor-phase-critic.md +22 -0
  43. package/bundled/dev-pipeline/templates/sections/refactor-phase-implement.md +16 -0
  44. package/bundled/dev-pipeline/templates/sections/refactor-phase-init.md +9 -0
  45. package/bundled/dev-pipeline/templates/sections/refactor-phase-plan.md +22 -0
  46. package/bundled/dev-pipeline/templates/sections/refactor-phase-review.md +19 -0
  47. package/bundled/dev-pipeline/templates/sections/refactor-reminders.md +11 -0
  48. package/bundled/dev-pipeline/templates/sections/refactor-session-context.md +7 -0
  49. package/bundled/dev-pipeline/templates/sections/refactor-session-status.md +28 -0
  50. package/bundled/dev-pipeline/templates/sections/refactor-task-contract.md +52 -0
  51. package/bundled/dev-pipeline/tests/test_generate_bootstrap_prompt.py +17 -5
  52. package/bundled/dev-pipeline/tests/test_python_runner_parity.py +197 -0
  53. package/bundled/dev-pipeline/tests/test_unified_cli.py +6 -2
  54. package/bundled/dev-pipeline/tests/test_utils.py +66 -1
  55. package/bundled/skills/_metadata.json +1 -1
  56. package/bundled/skills/app-planner/SKILL.md +8 -7
  57. package/bundled/skills/app-planner/references/project-brief-guide.md +2 -2
  58. package/bundled/skills/app-planner/references/rules/backend/derivation-rules.md +1 -1
  59. package/bundled/skills/app-planner/references/rules/frontend/derivation-rules.md +1 -1
  60. package/bundled/skills/app-planner/references/rules-configuration.md +53 -26
  61. package/bundled/skills/bug-fix-workflow/SKILL.md +191 -336
  62. package/bundled/skills/bug-planner/SKILL.md +6 -5
  63. package/bundled/skills/bug-planner/references/critic-and-verification.md +3 -3
  64. package/bundled/skills/bug-planner/references/schema-validation.md +2 -1
  65. package/bundled/skills/bug-planner/scripts/validate-bug-list.py +30 -1
  66. package/bundled/skills/bugfix-pipeline-launcher/SKILL.md +16 -16
  67. package/bundled/skills/bugfix-pipeline-launcher/references/configuration.md +2 -2
  68. package/bundled/skills/feature-pipeline-launcher/SKILL.md +19 -11
  69. package/bundled/skills/feature-planner/SKILL.md +9 -11
  70. package/bundled/skills/feature-planner/assets/planning-guide.md +1 -1
  71. package/bundled/skills/feature-planner/references/decomposition-patterns.md +1 -1
  72. package/bundled/skills/feature-planner/references/error-recovery.md +2 -1
  73. package/bundled/skills/feature-planner/references/incremental-feature-planning.md +2 -2
  74. package/bundled/skills/feature-planner/references/new-project-planning.md +35 -39
  75. package/bundled/skills/feature-planner/scripts/validate-and-generate.py +1 -1
  76. package/bundled/skills/feature-workflow/SKILL.md +169 -298
  77. package/bundled/skills/prizmkit/SKILL.md +103 -57
  78. package/bundled/skills/prizmkit-code-review/SKILL.md +97 -116
  79. package/bundled/skills/prizmkit-code-review/references/review-report-template.md +1 -0
  80. package/bundled/skills/prizmkit-code-review/references/reviewer-agent-prompt.md +12 -1
  81. package/bundled/skills/prizmkit-committer/SKILL.md +59 -47
  82. package/bundled/skills/prizmkit-deploy/SKILL.md +162 -381
  83. package/bundled/skills/prizmkit-deploy/references/ssh-adapter-flow.md +220 -0
  84. package/bundled/skills/prizmkit-implement/SKILL.md +51 -40
  85. package/bundled/skills/prizmkit-init/SKILL.md +4 -3
  86. package/bundled/skills/prizmkit-plan/SKILL.md +85 -70
  87. package/bundled/skills/prizmkit-prizm-docs/SKILL.md +94 -73
  88. package/bundled/skills/prizmkit-prizm-docs/assets/prizm-docs-format.md +20 -18
  89. package/bundled/skills/prizmkit-prizm-docs/references/op-update.md +18 -14
  90. package/bundled/skills/prizmkit-retrospective/SKILL.md +56 -48
  91. package/bundled/skills/prizmkit-retrospective/references/structural-sync-steps.md +79 -27
  92. package/bundled/skills/prizmkit-test/SKILL.md +138 -141
  93. package/bundled/skills/prizmkit-test/references/examples.md +10 -8
  94. package/bundled/skills/prizmkit-test/references/test-generation-steps.md +1 -1
  95. package/bundled/skills/prizmkit-test/references/test-report-template.md +2 -2
  96. package/bundled/skills/recovery-workflow/SKILL.md +195 -256
  97. package/bundled/skills/recovery-workflow/evals/evals.json +21 -13
  98. package/bundled/skills/recovery-workflow/references/detection.md +48 -39
  99. package/bundled/skills/recovery-workflow/scripts/detect-recovery-state.py +258 -322
  100. package/bundled/skills/refactor-pipeline-launcher/SKILL.md +29 -11
  101. package/bundled/skills/refactor-planner/SKILL.md +2 -2
  102. package/bundled/skills/refactor-planner/references/behavior-preservation.md +24 -19
  103. package/bundled/skills/refactor-planner/references/fast-path.md +2 -4
  104. package/bundled/skills/refactor-planner/references/planning-phases.md +2 -2
  105. package/bundled/skills/refactor-workflow/SKILL.md +173 -307
  106. package/package.json +1 -1
  107. package/src/scaffold.js +5 -0
  108. package/bundled/dev-pipeline/templates/agent-prompts/reviewer-review.md +0 -6
  109. package/bundled/skills/feature-workflow/references/brainstorm-guide.md +0 -137
  110. package/bundled/skills/refactor-workflow/references/brainstorm-guide.md +0 -116
@@ -1,444 +1,225 @@
1
1
  ---
2
2
  name: "prizmkit-deploy"
3
- description: "Universal deployment gateway for any PrizmKit project. Discovers project type and target (SSH server, Vercel, Docker, etc.), then routes: full automation for SSH Linux with PM2 + Nginx + blue/green switching, guided setup for cloud platforms, or safe documentation fallback for unsupported targets. Also operates existing deployments: status, logs, restart, rollback, health checks, history, validate. Use this skill whenever the user asks about deployment, hosting, going live, or server operations. Triggers on: 'deploy', 'ship it', 'take this live', 'deploy to Vercel', 'deploy to my server', 'check deploy status', 'view logs', 'restart app', 'rollback', 'how do I deploy this', any deployment or hosting question. (project)"
3
+ description: "Universal deployment gateway for PrizmKit projects. Discovers project type and deployment target, then routes to SSH Linux automation, cloud platform guidance, Docker guidance, or documented fallback. Also operates existing deployments: status, logs, restart, rollback, health, history, and validate. Use whenever the user asks to deploy, host, go live, release, take live, check deployment status, view logs, restart, rollback, or troubleshoot server operations. If the user says only 'ship it', clarify whether they mean commit or deploy before invoking. (project)"
4
4
  ---
5
5
 
6
6
  # PrizmKit Deploy — Universal Deployment Gateway
7
7
 
8
- `/prizmkit-deploy` is the single entry point for all deployment work. When a user asks to deploy anything any project type, any target this skill handles it.
8
+ `/prizmkit-deploy` is the deployment and operations entry point. It discovers what is being deployed, where it should run, and which adapter or fallback applies.
9
9
 
10
- Three possible outcomes depending on what's supported:
11
- 1. **Full automation** (SSH Linux server): configure, bootstrap, deploy, verify, operate — complete AI takeover.
12
- 2. **Guided setup** (cloud platforms like Vercel, Netlify, Docker): generate config, walk through CLI steps, verify.
13
- 3. **Documented fallback** (unsupported targets): detect what's possible, produce deploy.md, record the adapter gap.
10
+ Possible outcomes:
14
11
 
15
- When invited, behave as a deployment engineer. Ask until you understand what is being deployed, where it runs, how it is built, how it starts, what secrets it needs, how traffic reaches it, and how health is checked.
12
+ 1. **Full automation** SSH Linux server for supported Node.js apps using PM2 + Nginx blue/green.
13
+ 2. **Guided setup** — cloud platforms or Docker where user CLI/account steps are required.
14
+ 3. **Documented fallback** — unsupported project/target combinations get deploy documentation and an adapter-gap record.
16
15
 
17
16
  ### When to Use
18
- - User says "deploy", "ship it", "take this live", "deploy to Vercel", "deploy to my server"
19
- - User wants to check deploy status, view logs, restart app, rollback
20
- - First-time deployment configuration or repair
17
+ - User says "deploy", "go live", "take this live", "release", "deploy to Vercel", "deploy to my server"
18
+ - User wants deploy status, logs, restart, rollback, health checks, history, or validation
19
+ - First-time deployment configuration or existing deployment repair/takeover
21
20
  - Any deployment, hosting, or server operation question
22
21
 
23
22
  ### When NOT to Use
24
- - Project has no code to deploy (empty/scaffold project)
25
- - Local dev environment startup — use the project's dev scripts instead
26
- - Purely CI/CD pipeline debugging unrelated to deployment
27
- - User wants to edit application code — use /prizmkit-plan and /prizmkit-implement
23
+ - User says only "ship it" — clarify commit vs deploy first
24
+ - Local development startup — use project dev scripts or `/run`
25
+ - Pure CI test failure unrelated to deployment
26
+ - User wants application code changes — use `/prizmkit-plan` and `/prizmkit-implement`
28
27
 
29
28
  ## Data Safety Gate
30
29
 
31
- Before executing any command that could **irreversibly destroy, overwrite, or modify data**, pause and get explicit user confirmation. This is a hard gate — the cost of a false negative (losing real data) is catastrophic, while asking one extra question costs nothing.
30
+ Before executing any command that could irreversibly destroy, overwrite, or modify data, pause and get explicit user confirmation.
32
31
 
33
- ### Detection
32
+ Danger signals:
34
33
 
35
- Before running any shell command, scan it for these patterns:
34
+ | Category | Examples | Action |
35
+ |---|---|---|
36
+ | Database reset/loss | `prisma migrate reset`, `DROP TABLE`, `TRUNCATE`, broad `DELETE`/`UPDATE` | Explain data loss and require clear yes/no confirmation |
37
+ | File/system overwrite | `rm -rf`, writes under `/etc/`, overwriting existing config without backup | Confirm and back up when applicable |
38
+ | Cloud/resource deletion | `terraform destroy`, `kubectl delete`, bucket/resource deletion | Confirm exact resources and impact |
39
+ | Production traffic switch | first production deploy, rollback, Nginx upstream change | Confirm target environment and rollback plan |
36
40
 
37
- | Category | Dangerous patterns | What's at risk |
38
- |----------|-------------------|----------------|
39
- | Database schema | `prisma db push --force-reset`, `prisma db push --accept-data-loss`, `prisma migrate reset`, `prisma migrate dev --create-only` | All existing data dropped, schema reset |
40
- | Database data | `DROP TABLE`, `DROP DATABASE`, `TRUNCATE`, `DELETE FROM` without `WHERE`, `UPDATE` without `WHERE` | Data deletion or corruption |
41
- | File system | `rm -rf`, `> /etc/`, overwriting existing configs without backup | Config loss, system breakage |
42
- | Cloud resources | `terraform destroy`, `kubectl delete`, cloud resource deletion, S3 bucket removal | Infrastructure/service loss |
41
+ If a destructive data operation is detected in headless mode, refuse with `DATA_SAFETY_DENIED`; unattended pipelines must not destroy data.
43
42
 
44
- ### Confirmation Flow
43
+ Read `${SKILL_DIR}/references/data-safety-examples.md` when concrete examples are needed.
45
44
 
46
- When a dangerous pattern is detected:
45
+ ## Discovery
47
46
 
48
- 1. **Stop.** Do not execute. Do not ask "should I proceed?" while already running the command.
49
- 2. **Explain** what the command will do and what data will be lost, in plain language.
50
- 3. **Ask** an explicit yes/no question. Accept only a clear "yes" or equivalent — ambiguous responses ("sure, I guess", "ok go ahead") count as "no" when the consequence is data loss.
51
- 4. **Only proceed** on unambiguous consent. If the user says anything other than a clear affirmative, abort.
52
- 5. **Record** the confirmation decision and the command that was run in deploy history.
47
+ Before deploying, discover project and target.
53
48
 
54
- ### Headless Mode
49
+ ### Project Detection
55
50
 
56
- If a destructive data operation is detected in headless mode, **refuse and exit** with `DATA_SAFETY_DENIED`. Data destruction must never happen without human oversight — an unattended pipeline that runs `--force-reset` could wipe a production database with no one watching.
51
+ Scan build/package files and classify:
57
52
 
58
- ### Examples
53
+ | Signal | Classification |
54
+ |---|---|
55
+ | `package.json` with `next` | Next.js |
56
+ | `package.json` with `vite` | Vite frontend |
57
+ | generic `package.json` | Node.js |
58
+ | `requirements.txt` / `pyproject.toml` | Python |
59
+ | `go.mod` | Go |
60
+ | `Cargo.toml` | Rust |
61
+ | `Dockerfile` | Docker image |
62
+ | `docker-compose.yml` | Docker Compose |
59
63
 
60
- Read `${SKILL_DIR}/references/data-safety-examples.md` for concrete few-shot examples of dangerous commands caught by this gate, including the correct and incorrect ways to handle them.
64
+ Also detect:
65
+ - environment variables referenced in source
66
+ - ports/listen calls
67
+ - database dependencies
68
+ - existing deployment config at `.prizmkit/deploy/deploy.config.json`
61
69
 
62
- ## Deployment Discovery
70
+ ### Target Detection
63
71
 
64
- Before doing anything else, discover what you're deploying and where. This phase routes the request to the right adapter or fallback. It runs regardless of mode (interactive or headless), but interactive mode may ask questions; headless mode reads from existing config and exits with `NEEDS_INPUT` if critical details are missing.
72
+ Priority:
65
73
 
66
- ### Step 1: Project Detection
74
+ 1. User-specified target: Vercel, own server, Docker, etc.
75
+ 2. Existing config: `.prizmkit/deploy/deploy.config.json`
76
+ 3. Project files: `vercel.json`, `netlify.toml`, `fly.toml`, `Dockerfile`, `docker-compose.yml`, GitHub deploy workflow, `app.yaml`, `serverless.yml`
77
+ 4. Interactive question: ask where the project should be deployed
78
+ 5. Headless with missing target: exit `NEEDS_INPUT` and write pending questions to `.prizmkit/deploy/pending-input.json`
67
79
 
68
- Scan the project root for build/package files and classify:
80
+ ## Adapter Routing
69
81
 
70
- | File found | Language/Framework | Build command | Start command |
71
- |------------|-------------------|---------------|---------------|
72
- | `package.json` with `next` dep | Next.js | `next build` | `next start -p <port>` |
73
- | `package.json` with `vite` dep | Vite (React/Vue) | `vite build` | `vite preview` |
74
- | `package.json` (generic) | Node.js | `npm run build` | `npm run start` |
75
- | `go.mod` | Go | `go build` | `./<binary>` |
76
- | `Cargo.toml` | Rust | `cargo build --release` | `./target/release/<binary>` |
77
- | `requirements.txt` / `pyproject.toml` | Python | — | `python -m uvicorn` or similar |
78
- | `Dockerfile` | Containerized | `docker build` | `docker run` |
79
- | `docker-compose.yml` | Docker Compose | `docker compose build` | `docker compose up` |
80
- | `Makefile` only | C/C++/generic | `make` | `make run` or binary |
82
+ | Target | Route | Reference |
83
+ |---|---|---|
84
+ | SSH Linux server + Node.js project | Full automation | `references/ssh-adapter-flow.md` |
85
+ | Vercel / Netlify / Fly.io | Guided CLI setup | `references/cloud-platform-deploy.md` |
86
+ | Docker / Docker Compose | Guided build/run | `references/docker-deploy.md` |
87
+ | Unsupported target or project type | Documented fallback | §Unsupported Fallback |
81
88
 
82
- Also scan for:
83
- - **Environment variables**: grep for `process.env.`, `os.environ`, `os.Getenv`, `env::var` — catalog every reference
84
- - **Port usage**: grep for port numbers, `listen()`, `PORT` env var
85
- - **Database dependencies**: check package.json/requirements.txt/go.mod for database drivers
86
-
87
- ### Step 2: Deployment Target Detection
88
-
89
- Determine WHERE the user wants to deploy. Check in order:
90
-
91
- **A. User-specified target** (highest priority):
92
- - "deploy to Vercel" / "deploy to my server" / "deploy with Docker" → use what the user says.
93
-
94
- **B. Detect from project files** (if user hasn't specified):
95
- - `vercel.json` → Vercel
96
- - `netlify.toml` → Netlify
97
- - `fly.toml` → Fly.io
98
- - `Dockerfile` or `docker-compose.yml` → Docker
99
- - `.github/workflows/deploy.yml` → check what it targets
100
- - `app.yaml` → GCP App Engine
101
- - `serverless.yml` → Serverless Framework
102
-
103
- **C. Ask the user** (interactive only):
104
- - "Where should this project be deployed?"
105
- - Options to suggest based on detected files + common choices:
106
- - "My own Linux server (SSH access) — full AI automation"
107
- - "Vercel / Netlify — guided CLI setup"
108
- - "Docker — guided container deployment"
109
- - "Other — generate deployment documentation"
110
-
111
- If headless mode and no target can be determined, exit with `NEEDS_INPUT` listing the missing target information.
112
-
113
- **D. Check for existing deployment**:
114
- - Does `.prizmkit/deploy/deploy.config.json` already exist? If yes, read the configured target.
115
- - Does the user mention a server IP or hostname? Check if it's already reachable.
116
-
117
- ### Step 3: Route to Adapter
118
-
119
- Based on detected target, route the rest of the session:
120
-
121
- 1. **SSH Linux server** → §SSH Deployment Path — full automation: bootstrap, configure, deploy, operate. First-version adapter: PM2 + Nginx + blue/green.
122
- 2. **Vercel / Netlify** → §Cloud Platform Deployment Path — guided: detect CLI tools, walk through deploy commands, generate deploy.md. Details in `references/cloud-platform-deploy.md`.
123
- 3. **Docker** → §Docker Deployment Path — guided: detect Dockerfile/Compose, build image, container lifecycle. Details in `references/docker-deploy.md`.
124
- 4. **Unsupported** → §Unsupported Deployment Fallback — generate deploy.md, record adapter gap, provide manual checklist.
125
-
126
- Cloud and Docker paths follow the same discovery and documentation patterns but use platform CLIs instead of SSH + PM2.
127
-
128
- **Compatibility check before routing to SSH**: The SSH adapter (PM2 + Nginx + blue/green) requires a Node.js project — verify `package.json` exists. Non-Node.js projects (Go, Rust, Python) targeting a Linux server route to Unsupported Fallback with a note: "Adapter gap: PM2 adapter requires Node.js."
129
-
130
- ### Step 4: Unsupported Deployment Fallback
131
-
132
- When the deployment target or project type isn't covered by any adapter, don't fail silently. Instead:
133
-
134
- 1. **Detect what you can**: project language, framework, build/start commands, env vars, port usage, database dependencies.
135
- 2. **Generate `.prizmkit/deploy/deploy.md`**: human-readable deployment guide with prerequisites, environment variables table, build/start instructions, health check suggestions.
136
- 3. **Record the adapter gap**: write a note in deploy.md and deploy-history identifying what's missing (e.g., "Adapter needed: Python/FastAPI on systemd").
137
- 4. **Provide a manual checklist**: concrete steps the user can follow to deploy manually.
138
- 5. **Offer to generate CI/CD config**: if `.github/workflows/` exists or the user wants one, generate a basic deploy workflow.
89
+ Compatibility check before SSH: the full SSH adapter currently requires a Node.js project with `package.json`. Non-Node Linux server targets route to Unsupported Fallback with an adapter-gap note.
139
90
 
140
91
  ## Mode Detection
141
92
 
142
- Detect invocation mode from the user's initial message. The mode determines what you're allowed to do:
143
-
144
- **Interactive mode** (user typed `/prizmkit-deploy` or asked directly):
145
- - May ask as many questions as needed to fill in missing deployment details.
146
- - May request approvals for privileged, destructive, or traffic-impacting actions.
147
- - May deploy to any environment (dev/test/production).
148
- - Production requires explicit user confirmation before execution.
93
+ Interactive mode:
94
+ - May ask questions and request approvals.
95
+ - May deploy to dev, test, or production.
96
+ - Production requires explicit confirmation before execution.
149
97
 
150
- **Headless mode** (invoked via `--headless` flag, pipeline, or script):
151
- - Never wait for user input — unattended shells that time out on a prompt block pipelines silently without visible errors, so exit with clear status codes instead.
152
- - May ONLY target `dev` or `test` environments.
153
- - If `--env production` in headless mode: exit immediately with `ENVIRONMENT_DENIED — production deployment requires interactive mode`, because production deploys must never happen without human oversight.
154
- - If required info is missing, exit with `NEEDS_INPUT` and write pending questions to `.prizmkit/deploy/pending-input.json`.
155
- - May only perform actions already authorized by `deploy.config.json`.
98
+ Headless mode:
99
+ - Never wait for user input.
100
+ - May target only dev or test environments.
101
+ - Reject production with `ENVIRONMENT_DENIED`.
102
+ - If required info is missing, exit `NEEDS_INPUT` and write `.prizmkit/deploy/pending-input.json`.
103
+ - Perform only actions already authorized by `deploy.config.json`.
156
104
 
157
105
  ## Command Routing
158
106
 
159
- When the user invokes `/prizmkit-deploy`, determine intent from the first word after the command:
160
-
161
- ```
162
- /prizmkit-deploy deploy (if config exists) or configure (if not)
163
- /prizmkit-deploy configure first-run or repair configuration wizard
164
- /prizmkit-deploy deploy full deployment pipeline
165
- /prizmkit-deploy status show PM2 process status for all apps
166
- /prizmkit-deploy logs --app <id> tail PM2 logs for the given app
167
- /prizmkit-deploy restart --app <id> PM2 restart for the given app
168
- /prizmkit-deploy rollback --app <id> [--to <releaseId>] rollback to previous or specified release
169
- /prizmkit-deploy health --app <id> run configured health checks
170
- /prizmkit-deploy history list recent deployment events from deploy-history/
171
- /prizmkit-deploy validate run validation checks without deploying
107
+ Determine intent from the first word after `/prizmkit-deploy`:
108
+
109
+ ```text
110
+ /prizmkit-deploy -> deploy if config exists, otherwise configure
111
+ /prizmkit-deploy configure -> first-run or repair configuration wizard
112
+ /prizmkit-deploy deploy -> full deployment pipeline
113
+ /prizmkit-deploy status -> show runtime and active release status
114
+ /prizmkit-deploy logs --app <id> -> show recent logs
115
+ /prizmkit-deploy restart --app <id> -> restart active app process and health check
116
+ /prizmkit-deploy rollback --app <id> [--to <releaseId>] -> rollback
117
+ /prizmkit-deploy health --app <id> -> run health checks
118
+ /prizmkit-deploy history -> list deploy history
119
+ /prizmkit-deploy validate -> validate config and target without deploying
172
120
  ```
173
121
 
174
- ### No-arg behavior
175
-
176
- - If `.prizmkit/deploy/deploy.config.json` does not exist start first-run configuration wizard.
177
- - If config exists and validates show deployment summary (active release, app status, last deploy time) and ask which environment, then proceed to deploy.
178
- - If config exists but required fields are missing or validation is stale → enter repair flow.
122
+ No-arg behavior:
123
+ - If config is missing, start configuration.
124
+ - If config exists and validates, show deployment summary and ask for environment.
125
+ - If config exists but is incomplete or stale, enter repair flow.
179
126
 
180
- ## File Structure
127
+ ## Artifact Structure
181
128
 
182
- All artifacts live under `.prizmkit/deploy/`:
129
+ All deployment artifacts live under `.prizmkit/deploy/`:
183
130
 
184
- ```
131
+ ```text
185
132
  .prizmkit/deploy/
186
- deploy.md # human-readable documentation
187
- deploy.config.json # machine-readable config & validation state
188
- pending-input.json # pending questions for headless mode resume
133
+ deploy.md
134
+ deploy.config.json
135
+ pending-input.json
189
136
  deploy-history/
190
- <deployment-id>.json # one per deploy/rollback/event
191
- deploy-scripts/ # future — PrizmKit-managed deploy scripts
192
- secrets.enc.json # optional, encrypted local secrets
193
- secrets.local.json # optional, plaintext secrets (must be gitignored)
194
- ```
195
-
196
- Read `references/deploy-config-schema.md` when writing or validating `deploy.config.json`. Read `references/deploy-history-schema.md` when writing history records.
197
-
198
- ## SSH Deployment Path
199
-
200
- The following sections define the SSH deployment adapter — the only fully-automated path. Route here when Discovery determines the target is a Linux server with SSH access.
201
-
202
- ### SSH: Deployment Mode Selection
203
-
204
- After Discovery routes to SSH, **before** entering the configuration wizard, ask the user how they want to deploy.
205
-
206
- **First question:**
207
- > "How do you want to deploy to the server?"
208
- > - **A. Direct Upload (quick start)** — build locally, transfer to server and start. Good for first deployment.
209
- > - **B. CI/CD Auto-Deploy (recommended)** — configure GitHub Actions, then `git push` auto-deploys.
210
-
211
- **If user chooses CI/CD, second question:**
212
- > "CI/CD has two modes:"
213
- > - **Push mode** — GitHub Actions runner builds, SCP transfers to server. Low server load.
214
- > - **Pull mode** — server pulls code and builds itself. Simpler config but requires a Deploy Key.
215
-
216
- For detailed mode descriptions and the full Push/Pull comparison table, read `references/deployment-modes.md`.
217
-
218
- **Config field:** `deployStrategy` in `deploy.config.json` — `"direct-upload"`, `"ci-cd-push"`, or `"ci-cd-pull"`. Existing configs without this field default to `"ci-cd-pull"` for backward compatibility.
219
-
220
- ### SSH: Server Model
221
-
222
- Servers are generic SSH targets. A server is valid if it:
223
- - Can be reached over SSH.
224
- - Provides a Linux shell.
225
- - Can install or has Node.js, npm, PM2, Nginx, Git.
226
- - Can access the configured Git repository (Pull mode only).
227
-
228
- Server-side directory layout:
229
- ```
230
- /var/www/<project>/
231
- releases/
232
- <release-id>/
233
- shared/
234
- .env.production # mode 600, owner: runtime user
235
- deploy-metadata.json # active color, last release, timestamp
236
- current -> releases/<release-id>
237
- deploy-logs/
137
+ deploy-scripts/
138
+ secrets.enc.json
139
+ secrets.local.json
238
140
  ```
239
141
 
240
- SSH roles: `bootstrapUser` (usually root, for initial setup) and `runtimeUser` (default `deploy`, for app processes). App processes never run as root.
241
-
242
- ### SSH: First-Run Configuration Wizard
243
-
244
- When `.prizmkit/deploy/deploy.config.json` does not exist, enter configuration wizard. Flow: **deployment mode → collect → validate → confirm → persist**.
245
-
246
- **Before any questions:** ask deployment mode (see §SSH: Deployment Mode Selection). This determines required steps:
247
-
248
- | Step | Direct Upload | CI/CD Push | CI/CD Pull |
249
- |------|:---:|:---:|:---:|
250
- | SSH Server Discovery | Required | Required | Required |
251
- | Repository Access | Skipped | Skipped | Required |
252
- | Application Configuration | Required | Required | Required |
253
- | Environment Variables | Required | Required | Required |
254
- | Persist Configuration | Required | Required | Required |
255
-
256
- #### Step 1: SSH Server Discovery
257
-
258
- Ask for and validate:
259
- - **Server host and port** (e.g., `43.161.221.171:22`)
260
- - **Bootstrap user** (usually `root`) — for initial package install and user creation
261
- - **Runtime user** (recommend `deploy`) — app runs as this user, never root
262
- - **Auth method** — SSH key path or agent
263
-
264
- Validate immediately: `ssh <bootstrapUser>@<host> 'echo OK'`. If that fails, nothing else matters — stop and fix connectivity first.
265
-
266
- #### Step 2: Repository Access (CI/CD Pull mode only)
267
-
268
- Only needed when `deployStrategy` is `"ci-cd-pull"` — the server needs to `git pull` code. Skip for `"direct-upload"` (no Git on server) and `"ci-cd-push"` (GitHub Actions handles checkout).
269
-
270
- Ask for: Git URL, branch, auth strategy (prefer read-only Deploy Key).
271
-
272
- If using Deploy Key:
273
- 1. Generate ed25519 key on server: `sudo -u <runtimeUser> ssh-keygen -t ed25519 -f ~/.ssh/id_ed25519 -N ""`
274
- 2. Show public key to user: "Add this to GitHub Deploy Keys (read-only)"
275
- 3. Wait for confirmation, then verify: attempt a git clone as runtime user
276
-
277
- #### Step 3: Application Configuration
278
-
279
- For each app, collect: id, path, packageManager, installCommand, buildCommand, startCommand, blue/green port pair (default 3101/3102), healthChecks.
280
-
281
- #### Step 4: Environment Variables
282
-
283
- Scan source code for `process.env.<VAR>` references. Ask user for each required value. Identify secrets vs non-secrets. Ask about secret storage strategy (see §Secrets Management).
284
-
285
- #### Step 5: Persist Configuration
142
+ Read `references/deploy-config-schema.md` when writing or validating config. Read `references/deploy-history-schema.md` when writing history records.
286
143
 
287
- Write `deploy.config.json` with all collected values and `validated: {}` stubs for each section. Write `deploy.md` as human-readable documentation.
144
+ Reference index:
145
+ - `references/ssh-adapter-flow.md` — load when routing to SSH Linux full automation.
146
+ - `references/deployment-modes.md` — load when the user needs push/pull/direct-upload comparison.
147
+ - `references/ssh-bootstrap-flow.md`, `references/firewall-setup.md`, `references/database-setup.md` — load during SSH bootstrap branches.
148
+ - `references/direct-upload.md`, `references/ci-cd-workflows.md` — load for strategy-specific setup.
149
+ - `references/dns-setup.md`, `references/ssl-setup.md` — load for domain and HTTPS setup.
150
+ - `references/ssh-execution-flow.md`, `references/nginx-blue-green.md`, `references/ssh-takeover.md` — load for deploy execution, traffic switching, rollback, or takeover.
151
+ - `references/cloud-platform-deploy.md`, `references/docker-deploy.md` — load for non-SSH guided routes.
152
+ - `references/live-validation-notes.md` — load when troubleshooting bootstrap or deploy failures.
288
153
 
289
- ### SSH: Bootstrap Flow
154
+ Never record raw secret values in config, docs, or history. Secret presence metadata is allowed; raw values and unsalted hashes are not.
290
155
 
291
- Before first deployment, bootstrap the server. Present a plan showing every privileged action before executing anything.
156
+ ## SSH Automation Route
292
157
 
293
- Read `${SKILL_DIR}/references/ssh-bootstrap-flow.md` for the full bootstrap procedure (preflight, check-and-install, user/dir setup, PM2 startup, deploy key). When the bootstrap reaches firewall or database steps, it routes to `references/firewall-setup.md` and `references/database-setup.md`. Key rules: bootstrap operations must be idempotent, existing config files must be backed up before modification, and each step's result must be recorded.
158
+ When routing to SSH Linux full automation, read `${SKILL_DIR}/references/ssh-adapter-flow.md` first. That reference coordinates the detailed SSH sub-procedures:
294
159
 
295
- ### SSH: Direct Upload Deployment
160
+ - deployment mode selection and first-run wizard
161
+ - server model and directory layout
162
+ - bootstrap and privileged action safety
163
+ - direct upload vs CI/CD push vs CI/CD pull
164
+ - DNS and SSL guidance
165
+ - PM2 + Nginx blue/green execution
166
+ - rollback and operations commands
167
+ - secrets and multi-app coordination
296
168
 
297
- When `deployStrategy` is `"direct-upload"`, the AI builds locally and transfers artifacts to the server. No Git operations on the server. Full procedure in `references/direct-upload.md`.
169
+ Key invariants:
170
+ - Present privileged bootstrap plans before execution.
171
+ - Back up existing config before modification.
172
+ - Run `nginx -t` before reload.
173
+ - Do not switch traffic until staged health checks pass.
174
+ - If failure happens before traffic switch, leave the live version unchanged.
175
+ - Preserve failed releases/logs for debugging.
298
176
 
299
- ### SSH: CI/CD Pipeline Configuration
177
+ ## Cloud and Docker Routes
300
178
 
301
- When `deployStrategy` is `"ci-cd-push"` or `"ci-cd-pull"`, generate `.github/workflows/deploy.yml` with the appropriate workflow template. Both modes share the same trigger and secrets. Full YAML templates in `references/ci-cd-workflows.md`.
179
+ Cloud platforms:
180
+ - Read `references/cloud-platform-deploy.md`.
181
+ - Detect required CLI/account steps.
182
+ - Generate or update deploy documentation and config.
183
+ - Guide the user through interactive login or dashboard steps when needed.
302
184
 
303
- After generating the workflow, verify: the first `git push` to the configured branch will trigger the first deployment. Monitor the GitHub Actions run and report results.
185
+ Docker:
186
+ - Read `references/docker-deploy.md`.
187
+ - Detect Dockerfile/Compose configuration.
188
+ - Build/run/validate with explicit environment and volume handling.
189
+ - For destructive volume or database operations, apply the Data Safety Gate.
304
190
 
305
- ### SSH: DNS Guidance
191
+ ## Unsupported Fallback
306
192
 
307
- Before SSL, check if the user has a domain pointing to the server.
193
+ When no adapter covers the detected target/project type:
308
194
 
309
- 1. Ask: "Do you have a domain to bind to this project?" If no domain → skip DNS + SSL, note in deploy.md.
310
- 2. Check DNS: `dig +short <domain> A`. If resolved proceed to SSL.
311
- 3. If not resolved: show the user DNS setup instructions. Full procedure in `references/dns-setup.md`.
312
-
313
- ### SSH: SSL/HTTPS Configuration
314
-
315
- Once DNS is confirmed pointing to the server, configure HTTPS via Let's Encrypt.
316
-
317
- 1. Detect cloud vendor via metadata endpoints.
318
- 2. If cloud vendor detected, ask: Let's Encrypt (recommended) or cloud vendor certificate.
319
- 3. Install certbot and request certificate.
320
- 4. Verify auto-renewal with `certbot renew --dry-run`.
321
-
322
- Full procedure in `references/ssl-setup.md`.
323
-
324
- ### SSH: Deployment Execution Flow
325
-
326
- Read `${SKILL_DIR}/references/ssh-execution-flow.md` for the full 5-group pipeline: pre-flight, fetch & build, stage & health check, switch & verify, cleanup & record. Key invariant: if any step before traffic switch fails, STOP — do not touch the live version.
327
-
328
- ### SSH: Blue/Green PM2 + Nginx Strategy
329
-
330
- - Blue: port 3101 (default), Green: port 3102 (default).
331
- - Active color persisted in `/var/www/<project>/shared/deploy-metadata.json`.
332
- - PM2 process naming: `<project>-<app>-<color>` (deterministic, never reuse old release IDs).
333
- - Nginx config must include: `# PrizmKit Managed: <project> — DO NOT EDIT MANUALLY`.
334
- - Before modifying any Nginx config lacking this marker, ask for user confirmation.
335
- - Always `nginx -t` before `systemctl reload nginx`.
336
-
337
- See `references/nginx-blue-green.md` for the full Nginx config template and traffic switch procedure.
338
-
339
- ### SSH: Rollback
340
-
341
- Two triggers: **automatic** (health check failure after traffic switch) and **manual** (`/prizmkit-deploy rollback --app <id> [--to <releaseId>]`).
342
-
343
- Steps: identify target release → verify build exists → start PM2 on its port → update Nginx upstream → `nginx -t` → reload → health checks → write rollback event. Do NOT delete the failed release or its logs — preserve for debugging.
344
-
345
- If no previous release exists, rollback is not possible — state this clearly.
346
-
347
- ### SSH: Operations Commands
348
-
349
- **status:** `pm2 list` as runtime user + active release, active color/port, last deploy timestamp.
350
-
351
- **logs --app \<id\>:** `pm2 logs <process-name> --lines 100` as runtime user.
352
-
353
- **restart --app \<id\>:** identify active PM2 process → `pm2 restart` → wait → health checks.
354
-
355
- **health --app \<id\>:** run all configured health checks, report pass/fail for each.
356
-
357
- **history:** list `.prizmkit/deploy/deploy-history/` events chronologically.
358
-
359
- ### SSH: Post-Deploy CI/CD Upgrade
360
-
361
- After a successful direct-upload deployment, proactively offer CI/CD setup:
362
-
363
- > "Deployment succeeded. Want me to set up CI/CD auto-deploy? After that, `git push` will auto-deploy."
364
-
365
- If user agrees, ask push vs pull, then configure accordingly. If Pull mode: set up deploy key. If Push mode: add GitHub Actions secrets. Generate `deploy.yml` from `references/ci-cd-workflows.md`, update `deployStrategy` in config, write upgrade event to history.
366
-
367
- ## Environment Policy
368
-
369
- | Mode | dev | test | production |
370
- |------|-----|------|------------|
371
- | Interactive | Allowed | Allowed | Allowed (requires confirmation) |
372
- | Headless | Allowed | Allowed | **REJECTED** — exits with ENVIRONMENT_DENIED |
373
-
374
- Headless must reject production because production deploys require human oversight — an unattended pipeline timing out mid-deploy can leave the site in a broken state with no one monitoring.
375
-
376
- ## Secrets Management
377
-
378
- Four storage modes, configured during first-run wizard:
379
-
380
- - **ask-every-time**: Prompt for secrets on each deploy. Safest, most manual.
381
- - **encrypted-local**: Store in `.prizmkit/deploy/secrets.enc.json`. Encrypt with user passphrase using Argon2id/scrypt KDF. Decryption material never stored alongside ciphertext.
382
- - **plaintext-local**: Store in `.prizmkit/deploy/secrets.local.json`. Must be gitignored. Before each deploy, verify the file is not tracked by git. If tracked, stop and ask to resolve.
383
- - **user-managed-on-server-only**: User handles secrets manually. Skill verifies server-side `.env.production` has all required vars before deploying.
384
-
385
- Server runtime secrets live in `/var/www/<project>/shared/.env.production` with mode `600`, owned by runtime user.
386
-
387
- Deploy history records secret presence metadata only (e.g., `{"SUPABASE_SERVICE_ROLE_KEY": {"present": true}}`). Never record raw secret values or unsalted hashes.
388
-
389
- ### SSH: Existing Deployment Takeover
390
-
391
- When deploying to a server that already has deployment assets, read `${SKILL_DIR}/references/ssh-takeover.md` for the detection procedure and takeover decision flow. Record takeover decision and validation results in config and history.
392
-
393
- ### SSH: Nginx Management
394
-
395
- - First Nginx config creation or update of a non-PrizmKit block requires user confirmation.
396
- - Subsequent updates to PrizmKit-managed blocks (`# PrizmKit Managed:` marker) may proceed automatically.
397
- - Always `nginx -t` before reload.
398
-
399
- See `references/nginx-blue-green.md` for the full Nginx config template.
400
-
401
- ### SSH: Bootstrap Safety Rules
402
-
403
- Before executing privileged bootstrap work, generate an action plan listing: packages, users/groups, SSH keys, Nginx config, directories/permissions, services that may be restarted.
404
-
405
- Rules:
406
- - User gives one explicit approval for the entire bootstrap plan.
407
- - If the plan changes during execution, pause and ask again.
408
- - Bootstrap operations must be idempotent.
409
- - Existing config files must be backed up before modification.
410
- - All privileged actions and results recorded in deploy history.
411
- - Failed bootstrap stops before deployment, provides recovery instructions.
412
-
413
- ### SSH: Multi-App Coordination
414
-
415
- An all-app deploy creates one release group. Rules:
416
- - Pre-traffic phases must complete for ALL selected apps before ANY app switches traffic.
417
- - If any app fails before traffic switch, NO app switches traffic. Staged processes stopped, live system unchanged.
418
- - If any app fails after traffic switch, default: group rollback.
419
- - Single-app deploys (`--app <id>`) do not affect unrelated apps.
195
+ 1. Detect what you can: language, framework, build/start commands, env vars, port usage, databases.
196
+ 2. Generate `.prizmkit/deploy/deploy.md` with prerequisites, env vars, build/start instructions, health checks, and manual steps.
197
+ 3. Record adapter gap in deploy history: missing adapter, detected project type, target, fallback output.
198
+ 4. Offer to generate basic CI/CD config when applicable.
420
199
 
421
200
  ## Validation
422
201
 
423
- Validation is mandatory before production deploy. Check: SSH connectivity, required tools (node, npm, git, pm2, nginx), repository reachability, port availability, required env vars, Nginx config syntax, health check routes accessible.
424
-
425
- Persist validation in `deploy.config.json` under each section's `validated` field.
426
-
427
- ## Adapter Paths
428
-
429
- After Discovery routes to a deployment target, read the corresponding reference:
430
-
431
- | Target | Reference | Mode |
432
- |--------|-----------|------|
433
- | SSH Linux server | SSH sections in this file | Full automation |
434
- | Vercel, Netlify, Fly.io | `references/cloud-platform-deploy.md` | Guided CLI |
435
- | Docker / Docker Compose | `references/docker-deploy.md` | Guided build + run |
436
- | Unrecognized target | §Deployment Discovery Step 4 | Documented fallback |
437
-
438
- ## Deploy History Record Schema
439
-
440
- Each deployment, rollback, or significant event writes a record to `.prizmkit/deploy/deploy-history/<id>.json`. Full schema in `references/deploy-history-schema.md`. Never record raw secret values in history — presence metadata only.
441
-
442
- ## Implementation Notes
443
-
444
- Live validation findings from the first PrizmKit deployment are in `references/live-validation-notes.md`. Read when troubleshooting bootstrap or deploy issues — these cover port conflict detection, npm verification, locale fixes, deploy key interactivity, PM2 PATH handling, and build-time env var timing.
202
+ Before production deploy, validate:
203
+
204
+ - target connectivity
205
+ - required tools
206
+ - repository or artifact availability
207
+ - port availability
208
+ - required environment variables
209
+ - process manager/runtime config
210
+ - Nginx syntax when applicable
211
+ - health check routes
212
+ - rollback readiness
213
+
214
+ Persist validation results in `deploy.config.json` under the relevant `validated` fields.
215
+
216
+ ## Output
217
+
218
+ Report:
219
+ - detected project and target
220
+ - selected adapter or fallback
221
+ - environment and deploy strategy
222
+ - actions performed
223
+ - validation/health results
224
+ - deploy history record path
225
+ - next recommended action