prizmkit 1.1.193 → 1.1.195
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/bin/create-prizmkit.js +43 -12
- package/bundled/VERSION.json +3 -3
- package/bundled/dev-pipeline/.env.example +5 -0
- package/bundled/dev-pipeline/README.md +2 -1
- package/bundled/dev-pipeline/prizmkit_runtime/checkpoint_state.py +111 -30
- package/bundled/dev-pipeline/prizmkit_runtime/cli.py +44 -3
- package/bundled/dev-pipeline/prizmkit_runtime/commands.py +29 -9
- package/bundled/dev-pipeline/prizmkit_runtime/config.py +121 -44
- package/bundled/dev-pipeline/prizmkit_runtime/daemon.py +190 -37
- package/bundled/dev-pipeline/prizmkit_runtime/interoperability.py +1 -0
- package/bundled/dev-pipeline/prizmkit_runtime/iterate.py +2480 -0
- package/bundled/dev-pipeline/prizmkit_runtime/paths.py +3 -0
- package/bundled/dev-pipeline/prizmkit_runtime/runner_bookkeeping.py +32 -8
- package/bundled/dev-pipeline/prizmkit_runtime/runners.py +29 -12
- package/bundled/dev-pipeline/prizmkit_runtime/runtime_commit.py +13 -5
- package/bundled/dev-pipeline/prizmkit_runtime/status.py +166 -0
- package/bundled/dev-pipeline/scripts/feature_list_contract.py +964 -0
- package/bundled/dev-pipeline/scripts/generate-bootstrap-prompt.py +18 -40
- package/bundled/dev-pipeline/scripts/generate-bugfix-prompt.py +24 -19
- package/bundled/dev-pipeline/scripts/prompt_framework.py +24 -8
- package/bundled/dev-pipeline/templates/bootstrap-tier3.md +1 -63
- package/bundled/dev-pipeline/templates/bug-fix-list-schema.json +8 -6
- package/bundled/dev-pipeline/templates/bugfix-bootstrap-prompt.md +0 -10
- package/bundled/dev-pipeline/templates/feature-list-schema.json +8 -6
- package/bundled/dev-pipeline/templates/iterate/evaluate-prompt.md +97 -0
- package/bundled/dev-pipeline/templates/iterate/evaluation-schema.json +538 -0
- package/bundled/dev-pipeline/templates/iterate/headless-plan-prompt.md +66 -0
- package/bundled/dev-pipeline/templates/sections/phase-specify-plan-full.md +2 -2
- package/bundled/dev-pipeline/templates/sections/runtime-commit-handoff.md +13 -4
- package/bundled/rules/USAGE.md +15 -48
- package/bundled/rules/_rules-metadata.json +7 -14
- package/bundled/rules/general/coding-baseline.md +23 -0
- package/bundled/rules/prizm/prizm-progressive-loading.md +2 -2
- package/bundled/skills/_metadata.json +12 -42
- package/bundled/skills/app-planner/SKILL.md +2 -2
- package/bundled/skills/app-planner/references/generated-plan-review.md +2 -2
- package/bundled/skills/app-planner/references/project-state-detection.md +1 -1
- package/bundled/skills/app-planner/references/rules-configuration.md +158 -88
- package/bundled/skills/app-planner/scripts/validate-rules-configuration.py +543 -12
- package/bundled/skills/bug-planner/references/verification.md +4 -5
- package/bundled/skills/bugfix-pipeline-launcher/SKILL.md +20 -14
- package/bundled/skills/bugfix-pipeline-launcher/references/configuration.md +49 -9
- package/bundled/skills/feature-pipeline-launcher/SKILL.md +20 -14
- package/bundled/skills/feature-pipeline-launcher/references/configuration.md +49 -9
- package/bundled/skills/feature-planner/SKILL.md +3 -3
- package/bundled/skills/feature-planner/references/browser-interaction.md +9 -29
- package/bundled/skills/iterate-pipeline-launcher/SKILL.md +273 -0
- package/bundled/skills/iterate-pipeline-launcher/references/configuration.md +105 -0
- package/bundled/skills/prizmkit-code-review/SKILL.md +10 -8
- package/bundled/skills/prizmkit-code-review/references/independent-code-review.md +4 -1
- package/bundled/skills/prizmkit-code-review/references/review-report-template.md +2 -1
- package/bundled/skills/prizmkit-code-review/scripts/render_review_report.py +12 -8
- package/bundled/skills/prizmkit-implement/SKILL.md +2 -2
- package/bundled/skills/prizmkit-init/SKILL.md +10 -10
- package/bundled/skills/prizmkit-init/references/brownfield-deep-init.md +81 -0
- package/bundled/skills/prizmkit-plan/SKILL.md +2 -1
- package/bundled/skills/prizmkit-plan/assets/plan-template.md +2 -0
- package/bundled/skills/prizmkit-prizm-docs/SKILL.md +8 -4
- package/bundled/skills/prizmkit-prizm-docs/assets/prizm-docs-format.md +8 -7
- package/bundled/skills/prizmkit-prizm-docs/references/op-init.md +33 -16
- package/bundled/skills/prizmkit-prizm-docs/references/op-validate.md +1 -1
- package/bundled/skills/prizmkit-retrospective/SKILL.md +29 -12
- package/bundled/skills/prizmkit-retrospective/references/retrospective-result-schema.json +126 -2
- package/bundled/skills/prizmkit-retrospective/references/rule-evolution-steps.md +86 -0
- package/bundled/skills/prizmkit-test/SKILL.md +2 -1
- package/bundled/skills/prizmkit-workflow/SKILL.md +8 -0
- package/bundled/skills/prizmkit-workflow/references/cold-start-rules.md +84 -0
- package/bundled/templates/project-memory-template.md +3 -3
- package/package.json +1 -1
- package/src/clean.js +2 -3
- package/src/config.js +52 -39
- package/src/index.js +29 -111
- package/src/prompts.js +20 -87
- package/src/runtime-passthrough.js +324 -0
- package/src/scaffold.js +41 -294
- package/src/upgrade.js +7 -39
- package/bundled/dev-pipeline/templates/sections/phase-browser-verification-auto.md +0 -127
- package/bundled/dev-pipeline/templates/sections/phase-browser-verification-opencli.md +0 -124
- package/src/external-skills.js +0 -103
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
### Browser Verification — MANDATORY
|
|
2
|
-
|
|
3
|
-
You MUST attempt this phase. Mark it as skipped only when no usable browser tool can be found, installed, or started.
|
|
4
|
-
|
|
5
|
-
**Step 0 — Tool Selection (BLOCKING — decide before any browser action)**:
|
|
6
|
-
|
|
7
|
-
0a. Check browser tool availability:
|
|
8
|
-
```bash
|
|
9
|
-
{{RUNTIME_HELPER_CMD}} executable version playwright-cli --arg=--version
|
|
10
|
-
{{RUNTIME_HELPER_CMD}} executable version opencli --arg=--version
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
0b. Use this single decision tree:
|
|
14
|
-
1. If `playwright-cli` is available, use it by default for local dev-server verification.
|
|
15
|
-
2. Else if `opencli` is available, run `opencli doctor`; use `opencli` only if doctor passes.
|
|
16
|
-
3. Else install `playwright-cli` as the default:
|
|
17
|
-
```bash
|
|
18
|
-
npm install -g @playwright/cli@latest
|
|
19
|
-
{{RUNTIME_HELPER_CMD}} executable version playwright-cli --arg=--version
|
|
20
|
-
```
|
|
21
|
-
4. If no browser tool is usable after these steps, append `## Browser Verification: SKIPPED — no usable browser tool` to `context-snapshot.md`, then continue to reporting/checkpoint.
|
|
22
|
-
|
|
23
|
-
Use `opencli` instead of `playwright-cli` only when the scenario requires an existing Chrome login/session or third-party integration cookies.
|
|
24
|
-
|
|
25
|
-
Record your choice in the Browser Verification report as `Tool: playwright-cli`, `Tool: opencli`, or `Tool: skipped`.
|
|
26
|
-
|
|
27
|
-
If tool is `skipped`, do NOT start a dev server and do NOT run browser commands. Go directly to Step 4 Reporting and the checkpoint update.
|
|
28
|
-
|
|
29
|
-
---
|
|
30
|
-
|
|
31
|
-
**If you chose `playwright-cli`**, follow this workflow:
|
|
32
|
-
|
|
33
|
-
0d. Check if playwright-cli skill is installed for the current AI platform:
|
|
34
|
-
```bash
|
|
35
|
-
{{RUNTIME_HELPER_CMD}} platform skill playwright-cli --prefix
|
|
36
|
-
```
|
|
37
|
-
If `SKILL_MISSING`: run `playwright-cli install --skills`. If current platform is NOT claude, copy the installed skill from the Claude user skills directory to the path shown by the helper output for the current platform.
|
|
38
|
-
|
|
39
|
-
0e. Read the installed playwright-cli skill (SKILL.md) for workflow guidance. Learn usage: `playwright-cli --help`.
|
|
40
|
-
|
|
41
|
-
**Step 1 — Start Dev Server + Open (playwright-cli)**:
|
|
42
|
-
1. Identify and start the dev server (see shared helper commands below)
|
|
43
|
-
2. Open: `playwright-cli open http://localhost:<DEV_PORT>`
|
|
44
|
-
3. If auth needed, use playwright-cli to register a test user and log in
|
|
45
|
-
|
|
46
|
-
**Step 2 — Verification (playwright-cli)**:
|
|
47
|
-
Use `playwright-cli snapshot` to discover element refs, then verify these goals:
|
|
48
|
-
{{BROWSER_VERIFY_STEPS}}
|
|
49
|
-
|
|
50
|
-
Construct your verification workflow based on: (1) the playwright-cli skill documentation, (2) the `--help` output, (3) the current task's Verification Gates. Take a final screenshot: `playwright-cli screenshot`.
|
|
51
|
-
|
|
52
|
-
**Step 3 — Cleanup (playwright-cli)**:
|
|
53
|
-
1. `playwright-cli close`
|
|
54
|
-
2. `{{RUNTIME_HELPER_CMD}} process cleanup-pid <pid-from-.prizmkit/state/browser-dev-server.pid>`
|
|
55
|
-
3. `{{RUNTIME_HELPER_CMD}} port check <DEV_PORT>`
|
|
56
|
-
|
|
57
|
-
---
|
|
58
|
-
|
|
59
|
-
**If you chose `opencli`**, follow this workflow:
|
|
60
|
-
|
|
61
|
-
0d. Learn usage: `opencli browser --help`
|
|
62
|
-
|
|
63
|
-
**Step 1 — Start Dev Server + Open (opencli)**:
|
|
64
|
-
1. Identify and start the dev server (see shared helper commands below)
|
|
65
|
-
2. Open: `opencli browser open http://localhost:<DEV_PORT>`
|
|
66
|
-
3. Inspect: `opencli browser state`
|
|
67
|
-
3. If auth needed, opencli reuses Chrome cookies — SSO/OAuth may already be active
|
|
68
|
-
|
|
69
|
-
**Step 2 — Verification (opencli)**:
|
|
70
|
-
Use `opencli browser state` to discover elements with `[N]` indices, then verify these goals:
|
|
71
|
-
{{BROWSER_VERIFY_STEPS}}
|
|
72
|
-
|
|
73
|
-
Key commands: `state`, `click <N>`, `type <N> "text"`, `get text <N>`, `get value <N>`, `wait text "..."`, `wait selector "..."`, `scroll down`, `eval "(function(){ ... })()"`.
|
|
74
|
-
|
|
75
|
-
Run page-changing commands sequentially; for example, run `opencli browser type 3 "hello"`, then run `opencli browser click 7`.
|
|
76
|
-
|
|
77
|
-
Always run `state` after page-changing actions to get fresh indices.
|
|
78
|
-
|
|
79
|
-
**Step 3 — Cleanup (opencli)**:
|
|
80
|
-
1. `opencli browser close`
|
|
81
|
-
2. `{{RUNTIME_HELPER_CMD}} process cleanup-pid <pid-from-.prizmkit/state/browser-dev-server.pid>`
|
|
82
|
-
3. `{{RUNTIME_HELPER_CMD}} port check <DEV_PORT>`
|
|
83
|
-
|
|
84
|
-
---
|
|
85
|
-
|
|
86
|
-
**Shared: Dev Server Port / Process Helpers** (used by both tools):
|
|
87
|
-
|
|
88
|
-
1. Determine `DEV_PORT` from the pipeline value (`{{DEV_PORT}}`) or project config; do not guess.
|
|
89
|
-
2. Verify port available:
|
|
90
|
-
```bash
|
|
91
|
-
{{RUNTIME_HELPER_CMD}} port check <DEV_PORT>
|
|
92
|
-
```
|
|
93
|
-
3. Start dev server:
|
|
94
|
-
```bash
|
|
95
|
-
{{RUNTIME_HELPER_CMD}} process start --pid-file .prizmkit/state/browser-dev-server.pid -- <start-command tokens>
|
|
96
|
-
```
|
|
97
|
-
4. Wait for ready:
|
|
98
|
-
```bash
|
|
99
|
-
{{RUNTIME_HELPER_CMD}} web wait-ready --url http://localhost:<DEV_PORT> --timeout 30 --interval 2
|
|
100
|
-
```
|
|
101
|
-
|
|
102
|
-
---
|
|
103
|
-
|
|
104
|
-
**Step 4 — Reporting** (both tools):
|
|
105
|
-
|
|
106
|
-
Append results to `context-snapshot.md`:
|
|
107
|
-
```
|
|
108
|
-
## Browser Verification
|
|
109
|
-
Tool: <playwright-cli or opencli>
|
|
110
|
-
URL: http://localhost:<DEV_PORT>
|
|
111
|
-
Dev Server Command: <actual command used>
|
|
112
|
-
Tool version: <version>
|
|
113
|
-
Steps executed: [list of commands used]
|
|
114
|
-
Screenshot: [path if taken]
|
|
115
|
-
Result: PASS / FAIL (reason)
|
|
116
|
-
Server cleanup: confirmed
|
|
117
|
-
Browser cleanup: confirmed
|
|
118
|
-
```
|
|
119
|
-
|
|
120
|
-
Browser blocking policy: `{{BROWSER_BLOCKING}}`.
|
|
121
|
-
|
|
122
|
-
If verification fails:
|
|
123
|
-
- If `{{BROWSER_BLOCKING}}` is `true`: update checkpoint step `browser-verification` to failed with terminal `WORKFLOW_BLOCKED` (`{{CHECKPOINT_PYTHON_CMD}} --checkpoint-path {{CHECKPOINT_PATH}} --step browser-verification --status failed --terminal-status WORKFLOW_BLOCKED --blocked-reason browser_verification_failed`), write `failure-log.md` with browser evidence, clean up the dev server/browser, and stop before commit.
|
|
124
|
-
- If `{{BROWSER_BLOCKING}}` is `false`: log the failure details, mark checkpoint step `browser-verification` according to the evidence, clean up the dev server/browser, and continue.
|
|
125
|
-
|
|
126
|
-
You MUST attempt verification and MUST clean up the dev server in both cases.
|
|
127
|
-
|
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
### Browser Verification (opencli) — MANDATORY
|
|
2
|
-
|
|
3
|
-
You MUST execute this phase. Do NOT skip it. Do NOT mark it as completed without actually running opencli.
|
|
4
|
-
|
|
5
|
-
**CRITICAL CONSTRAINT — opencli browser ONLY, NO Playwright**:
|
|
6
|
-
- You MUST use `opencli browser` (the CLI tool) for ALL browser interactions in this phase
|
|
7
|
-
- **NEVER** use playwright-cli, Playwright MCP server, or any MCP-based browser automation
|
|
8
|
-
- All browser actions go through `opencli browser <command>` via the shell/terminal command tool, not through any MCP tool call
|
|
9
|
-
- OpenCLI reuses Chrome's logged-in sessions — your existing authentication is available automatically
|
|
10
|
-
|
|
11
|
-
**Step 0 — OpenCLI Readiness Check (BLOCKING — must pass before any browser action)**:
|
|
12
|
-
|
|
13
|
-
0a. Check if `opencli` is installed:
|
|
14
|
-
```bash
|
|
15
|
-
{{RUNTIME_HELPER_CMD}} executable version opencli --arg=--version
|
|
16
|
-
```
|
|
17
|
-
If output is `NOT_INSTALLED`, install it:
|
|
18
|
-
```bash
|
|
19
|
-
npm install -g @jackwener/opencli@latest
|
|
20
|
-
```
|
|
21
|
-
Then verify installation succeeded: `{{RUNTIME_HELPER_CMD}} executable version opencli --arg=--version`. If installation fails, log `## Browser Verification: SKIPPED — opencli installation failed` in context-snapshot.md and proceed to the next phase.
|
|
22
|
-
|
|
23
|
-
0b. Verify Browser Bridge connectivity:
|
|
24
|
-
```bash
|
|
25
|
-
opencli doctor
|
|
26
|
-
```
|
|
27
|
-
If `opencli doctor` fails (Chrome not running or extension not installed), log `## Browser Verification: SKIPPED — opencli doctor failed (Chrome/extension not ready)` in context-snapshot.md and proceed to the next phase.
|
|
28
|
-
|
|
29
|
-
0c. Learn opencli browser usage (run once per session):
|
|
30
|
-
```bash
|
|
31
|
-
opencli browser --help
|
|
32
|
-
```
|
|
33
|
-
|
|
34
|
-
**Step 1 — Start Dev Server**:
|
|
35
|
-
|
|
36
|
-
You know this project's tech stack. Detect and start the dev server yourself:
|
|
37
|
-
|
|
38
|
-
1. Identify the dev server start command from project config (`package.json` scripts, `Makefile`, `docker-compose.yml`, etc.)
|
|
39
|
-
2. Determine the dev server port from the pre-detected pipeline value (`{{DEV_PORT}}`) or project config. Do NOT hardcode or guess the port. Record it as `DEV_PORT` in your notes.
|
|
40
|
-
3. Verify the port is available:
|
|
41
|
-
```bash
|
|
42
|
-
{{RUNTIME_HELPER_CMD}} port check <DEV_PORT>
|
|
43
|
-
```
|
|
44
|
-
4. Start the dev server with the runtime helper and capture a PID file:
|
|
45
|
-
```bash
|
|
46
|
-
{{RUNTIME_HELPER_CMD}} process start --pid-file .prizmkit/state/browser-dev-server.pid -- <start-command tokens>
|
|
47
|
-
```
|
|
48
|
-
5. Wait for server to be ready:
|
|
49
|
-
```bash
|
|
50
|
-
{{RUNTIME_HELPER_CMD}} web wait-ready --url http://localhost:<DEV_PORT> --timeout 30 --interval 2
|
|
51
|
-
```
|
|
52
|
-
6. Open the app in opencli and inspect page state:
|
|
53
|
-
```bash
|
|
54
|
-
opencli browser open http://localhost:<DEV_PORT>
|
|
55
|
-
opencli browser state
|
|
56
|
-
```
|
|
57
|
-
7. If the page requires authentication, use opencli browser to interact with login forms (opencli reuses Chrome cookies, so SSO/OAuth may already be active)
|
|
58
|
-
|
|
59
|
-
**Step 2 — Verification**:
|
|
60
|
-
|
|
61
|
-
Use `opencli browser state` on the running app to discover elements with `[N]` indices, then verify these goals:
|
|
62
|
-
{{BROWSER_VERIFY_STEPS}}
|
|
63
|
-
|
|
64
|
-
Key opencli browser commands for verification:
|
|
65
|
-
- `opencli browser state` — structured DOM with `[N]` element indices (FREE, always use this)
|
|
66
|
-
- `opencli browser click <N>` — click element by index
|
|
67
|
-
- `opencli browser type <N> "text"` — type into input
|
|
68
|
-
- `opencli browser get text <N>` — read element text
|
|
69
|
-
- `opencli browser get value <N>` — read input value
|
|
70
|
-
- `opencli browser wait text "Success"` — wait for text to appear
|
|
71
|
-
- `opencli browser wait selector ".loaded"` — wait for element
|
|
72
|
-
- `opencli browser scroll down` — scroll page
|
|
73
|
-
- `opencli browser eval "(function(){ ... })()"` — read-only JS evaluation for data extraction
|
|
74
|
-
|
|
75
|
-
**Run commands sequentially and refresh state after page-changing actions**:
|
|
76
|
-
```bash
|
|
77
|
-
opencli browser open http://localhost:<DEV_PORT>
|
|
78
|
-
opencli browser state
|
|
79
|
-
opencli browser type 3 "hello"
|
|
80
|
-
opencli browser type 4 "world"
|
|
81
|
-
opencli browser click 7
|
|
82
|
-
opencli browser state
|
|
83
|
-
```
|
|
84
|
-
|
|
85
|
-
**IMPORTANT**: Always run `opencli browser state` after page-changing actions (open, click on links, scroll) to get fresh element indices. Never guess indices.
|
|
86
|
-
|
|
87
|
-
Construct your verification workflow based on: (1) the `opencli browser --help` output, (2) the current task's Verification Gates. Decide the concrete actions yourself. Take a final screenshot if needed: `opencli browser screenshot`.
|
|
88
|
-
|
|
89
|
-
**Step 3 — Cleanup (REQUIRED — you started it, you stop it)**:
|
|
90
|
-
|
|
91
|
-
1. Close the opencli browser session: `opencli browser close`
|
|
92
|
-
2. Stop the dev server process using the PID file written in Step 1:
|
|
93
|
-
```bash
|
|
94
|
-
{{RUNTIME_HELPER_CMD}} process cleanup-pid <pid-from-.prizmkit/state/browser-dev-server.pid>
|
|
95
|
-
```
|
|
96
|
-
3. Verify port is released:
|
|
97
|
-
```bash
|
|
98
|
-
{{RUNTIME_HELPER_CMD}} port check <DEV_PORT>
|
|
99
|
-
```
|
|
100
|
-
|
|
101
|
-
**Step 4 — Reporting**:
|
|
102
|
-
|
|
103
|
-
Append results to `context-snapshot.md`:
|
|
104
|
-
```
|
|
105
|
-
## Browser Verification
|
|
106
|
-
Tool: opencli
|
|
107
|
-
URL: http://localhost:<DEV_PORT>
|
|
108
|
-
Dev Server Command: <actual command used>
|
|
109
|
-
opencli version: <version>
|
|
110
|
-
Steps executed: [list of opencli browser commands used]
|
|
111
|
-
Screenshot: [path if taken]
|
|
112
|
-
Result: PASS / FAIL (reason)
|
|
113
|
-
Server cleanup: confirmed
|
|
114
|
-
Browser cleanup: confirmed
|
|
115
|
-
```
|
|
116
|
-
|
|
117
|
-
Browser blocking policy: `{{BROWSER_BLOCKING}}`.
|
|
118
|
-
|
|
119
|
-
If verification fails:
|
|
120
|
-
- If `{{BROWSER_BLOCKING}}` is `true`: update checkpoint step `browser-verification` to failed with terminal `WORKFLOW_BLOCKED` (`{{CHECKPOINT_PYTHON_CMD}} --checkpoint-path {{CHECKPOINT_PATH}} --step browser-verification --status failed --terminal-status WORKFLOW_BLOCKED --blocked-reason browser_verification_failed`), write `failure-log.md` with browser evidence, clean up the dev server/browser, and stop before commit.
|
|
121
|
-
- If `{{BROWSER_BLOCKING}}` is `false`: log the failure details, mark checkpoint step `browser-verification` according to the evidence, clean up the dev server/browser, and continue.
|
|
122
|
-
|
|
123
|
-
You MUST attempt verification and MUST clean up the dev server in both cases.
|
|
124
|
-
|
package/src/external-skills.js
DELETED
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External Skills Installer
|
|
3
|
-
*
|
|
4
|
-
* Delegates to `npx skills add <repo> [--skill <name>] --yes` to fetch skills.
|
|
5
|
-
* Supports two modes:
|
|
6
|
-
* - Single skill: `--skill <name>` selects one skill from a repo
|
|
7
|
-
* - Install all: installs all skills from a repo (e.g. pbakaus/impeccable)
|
|
8
|
-
*
|
|
9
|
-
* When run non-interactively (stdio: 'pipe'), npx skills writes canonical
|
|
10
|
-
* .agents/skills/<name>/SKILL.md files. Codex uses that location directly;
|
|
11
|
-
* other platforms get copied into their platform-specific skill directories.
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
import { execSync } from 'node:child_process';
|
|
15
|
-
import path from 'path';
|
|
16
|
-
import os from 'node:os';
|
|
17
|
-
import fs from 'fs-extra';
|
|
18
|
-
import { payloadSkillRoots } from './platforms.js';
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* @param {Object} skill - Skill definition from external_skills.known
|
|
22
|
-
* skill.repo {string} - GitHub short ref (e.g. "pbakaus/impeccable") or full URL
|
|
23
|
-
* skill.name {string} - Skill name (used for display / single-skill mode)
|
|
24
|
-
* skill.installAll {boolean} - If true, install all skills from the repo
|
|
25
|
-
* @param {string} platform - 'claude' | 'codebuddy' | 'codex' | 'pi' | 'cursor' | 'antigravity' | 'all' ('both' supported only for legacy manifests)
|
|
26
|
-
* @param {string} projectRoot - Target project root
|
|
27
|
-
* @param {string} [aiCli] - optional AI CLI command that may require an additional payload platform
|
|
28
|
-
*/
|
|
29
|
-
export async function installExternalSkill(skill, platform, projectRoot, dryRun, aiCli = '') {
|
|
30
|
-
if (!skill.repo) {
|
|
31
|
-
throw new Error(`Skill "${skill.name}" has no repo URL defined`);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
// installAll: install entire repo (all skills), otherwise install single skill by name
|
|
35
|
-
const cmd = skill.installAll
|
|
36
|
-
? `npx skills add ${skill.repo} --yes`
|
|
37
|
-
: `npx skills add ${skill.repo} --skill ${skill.name} --yes`;
|
|
38
|
-
|
|
39
|
-
if (dryRun) {
|
|
40
|
-
console.log(` [dry-run] ${cmd}`);
|
|
41
|
-
if (skill.installAll) {
|
|
42
|
-
console.log(` [dry-run] → all skills from ${skill.repo}`);
|
|
43
|
-
} else {
|
|
44
|
-
const targets = getTargetDirs(platform, projectRoot, aiCli)
|
|
45
|
-
.map(d => path.relative(projectRoot, path.join(d, skill.name, 'SKILL.md')));
|
|
46
|
-
for (const t of targets) console.log(` [dry-run] → ${t}`);
|
|
47
|
-
}
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
// Fetch into an isolated staging root. Running `npx skills` in the target
|
|
52
|
-
// project would let its universal `.agents/skills` output overwrite or delete
|
|
53
|
-
// user-owned Codex resources when Cursor is the selected destination.
|
|
54
|
-
const stagingRoot = await fs.mkdtemp(path.join(os.tmpdir(), 'prizmkit-external-skill-'));
|
|
55
|
-
try {
|
|
56
|
-
execSync(cmd, { cwd: stagingRoot, stdio: 'pipe', timeout: 120000 });
|
|
57
|
-
const agentsSkillsDir = path.join(stagingRoot, '.agents', 'skills');
|
|
58
|
-
|
|
59
|
-
if (!await fs.pathExists(agentsSkillsDir)) {
|
|
60
|
-
throw new Error(`npx skills did not produce .agents/skills/ for ${skill.repo}`);
|
|
61
|
-
}
|
|
62
|
-
const skillNames = skill.installAll
|
|
63
|
-
? (await fs.readdir(agentsSkillsDir, { withFileTypes: true }))
|
|
64
|
-
.filter(entry => entry.isDirectory())
|
|
65
|
-
.map(entry => entry.name)
|
|
66
|
-
: [skill.name];
|
|
67
|
-
|
|
68
|
-
for (const skillName of skillNames) {
|
|
69
|
-
const sourceDir = path.join(agentsSkillsDir, skillName);
|
|
70
|
-
if (!await fs.pathExists(path.join(sourceDir, 'SKILL.md'))) {
|
|
71
|
-
throw new Error(`npx skills did not produce .agents/skills/${skillName}/SKILL.md`);
|
|
72
|
-
}
|
|
73
|
-
for (const targetDir of getTargetDirs(platform, projectRoot, aiCli)) {
|
|
74
|
-
const destination = path.join(targetDir, skillName);
|
|
75
|
-
await fs.remove(destination).catch(() => {});
|
|
76
|
-
await fs.copy(sourceDir, destination);
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
} finally {
|
|
80
|
-
await fs.remove(stagingRoot).catch(() => {});
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
await fs.remove(path.join(projectRoot, 'skills-lock.json')).catch(() => {});
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* Remove all artifacts created by `npx skills` that are not needed by PrizmKit.
|
|
88
|
-
* Call this once after all external skills have been installed.
|
|
89
|
-
*
|
|
90
|
-
* @param {string} platform - 'claude' | 'codebuddy' | 'codex' | 'pi' | 'cursor' | 'antigravity' | 'all' ('both' supported only for legacy manifests)
|
|
91
|
-
* @param {string} [aiCli] - optional AI CLI command that may require an additional payload platform
|
|
92
|
-
*/
|
|
93
|
-
export async function cleanExternalSkillArtifacts(projectRoot, platform, aiCli = '') {
|
|
94
|
-
// External Skills are fetched in an isolated staging root, so target cleanup
|
|
95
|
-
// must not scan or delete platform directories or user-owned Skill symlinks.
|
|
96
|
-
// Resolve targets here to retain validation of the caller's platform inputs.
|
|
97
|
-
getTargetDirs(platform, projectRoot, aiCli);
|
|
98
|
-
await fs.remove(path.join(projectRoot, 'skills-lock.json')).catch(() => {});
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
function getTargetDirs(platform, projectRoot, aiCli = '') {
|
|
102
|
-
return payloadSkillRoots(platform, projectRoot, aiCli);
|
|
103
|
-
}
|