prizmkit 1.1.162 → 1.1.165
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 +4 -4
- package/bundled/VERSION.json +3 -3
- package/bundled/adapters/cursor/assets/prizmkit-hook.cjs +65 -0
- package/bundled/adapters/cursor/hooks-adapter.js +139 -0
- package/bundled/adapters/cursor/paths.js +11 -0
- package/bundled/adapters/cursor/rules-adapter.js +49 -0
- package/bundled/adapters/cursor/skill-adapter.js +27 -0
- package/bundled/dev-pipeline/README.md +18 -5
- package/bundled/dev-pipeline/prizmkit_runtime/checkpoint_state.py +3 -25
- package/bundled/dev-pipeline/prizmkit_runtime/config.py +71 -14
- package/bundled/dev-pipeline/prizmkit_runtime/gitops.py +28 -4
- package/bundled/dev-pipeline/prizmkit_runtime/heartbeat.py +5 -2
- package/bundled/dev-pipeline/prizmkit_runtime/platform_detection.py +21 -3
- package/bundled/dev-pipeline/prizmkit_runtime/runners.py +19 -5
- package/bundled/dev-pipeline/prizmkit_runtime/sessions.py +123 -28
- package/bundled/dev-pipeline/prizmkit_runtime/status.py +2 -0
- package/bundled/dev-pipeline/prizmkit_runtime/test_result.py +1 -42
- package/bundled/dev-pipeline/scripts/init-bugfix-pipeline.py +43 -6
- package/bundled/dev-pipeline/scripts/init-pipeline.py +46 -8
- package/bundled/dev-pipeline/scripts/init-refactor-pipeline.py +41 -6
- package/bundled/dev-pipeline/scripts/parse-stream-progress.py +143 -27
- package/bundled/dev-pipeline/scripts/update-feature-status.py +2 -2
- package/bundled/dev-pipeline/scripts/utils.py +3 -12
- package/bundled/dev-pipeline/templates/bug-fix-list-schema.json +4 -2
- package/bundled/dev-pipeline/templates/feature-list-schema.json +4 -2
- package/bundled/dev-pipeline/templates/refactor-list-schema.json +4 -2
- package/bundled/dev-pipeline/tests/live_ai_cli_log_smoke.py +2 -1
- package/bundled/dev-pipeline/tests/test_checkpoint_state.py +5 -23
- package/bundled/dev-pipeline/tests/test_generate_bootstrap_prompt.py +2 -2
- package/bundled/dev-pipeline/tests/test_python_runner_parity.py +231 -0
- package/bundled/dev-pipeline/tests/test_unified_cli.py +406 -30
- package/bundled/dev-pipeline/tests/test_utils.py +23 -0
- package/bundled/rules/USAGE.md +3 -0
- package/bundled/skills/_metadata.json +1 -1
- package/bundled/skills/app-planner/SKILL.md +18 -9
- package/bundled/skills/app-planner/references/app-design-guide.md +7 -5
- package/bundled/skills/app-planner/references/brainstorm-guide.md +13 -21
- package/bundled/skills/app-planner/references/generated-plan-review.md +6 -2
- package/bundled/skills/bug-planner/SKILL.md +13 -5
- package/bundled/skills/bug-planner/assets/bug-confirmation-template.md +11 -7
- package/bundled/skills/bug-planner/references/generated-plan-review.md +7 -3
- package/bundled/skills/bug-planner/references/verification.md +0 -2
- package/bundled/skills/bug-planner/scripts/validate-bug-list.py +37 -7
- package/bundled/skills/feature-planner/SKILL.md +17 -11
- package/bundled/skills/feature-planner/assets/planning-guide.md +13 -13
- package/bundled/skills/feature-planner/references/completeness-review.md +8 -4
- package/bundled/skills/feature-planner/references/generated-plan-review.md +6 -2
- package/bundled/skills/feature-planner/scripts/validate-and-generate.py +43 -19
- package/bundled/skills/prizmkit-init/SKILL.md +1 -1
- package/bundled/skills/prizmkit-init/references/config-schema.md +2 -2
- package/bundled/skills/prizmkit-plan/SKILL.md +15 -4
- package/bundled/skills/prizmkit-plan/assets/plan-template.md +18 -3
- package/bundled/skills/prizmkit-plan/assets/spec-template.md +17 -5
- package/bundled/skills/prizmkit-plan/references/clarify-guide.md +26 -24
- package/bundled/skills/prizmkit-plan/references/review-plan-spec-loop.md +7 -5
- package/bundled/skills/prizmkit-plan/references/verification-checklist.md +15 -6
- package/bundled/skills/prizmkit-prizm-docs/assets/prizm-docs-format.md +1 -1
- package/bundled/skills/prizmkit-prizm-docs/references/op-init.md +1 -1
- package/bundled/skills/refactor-planner/SKILL.md +18 -11
- package/bundled/skills/refactor-planner/references/generated-plan-review.md +6 -2
- package/bundled/skills/refactor-planner/references/planning-phases.md +14 -9
- package/bundled/skills/refactor-planner/references/refactor-scoping-guide.md +8 -2
- package/bundled/skills/refactor-planner/scripts/validate-and-generate-refactor.py +38 -9
- package/package.json +4 -2
- package/src/ai-cli-launch.js +9 -2
- package/src/clean.js +42 -6
- package/src/config.js +51 -10
- package/src/detect-platform.js +30 -8
- package/src/external-skills.js +33 -99
- package/src/index.js +5 -0
- package/src/manifest.js +30 -4
- package/src/platforms.js +11 -4
- package/src/prompts.js +12 -4
- package/src/scaffold.js +75 -4
- package/src/upgrade.js +15 -14
|
@@ -9,8 +9,8 @@ Detailed procedures for Phases 4-6 of the refactor-planner interactive workflow,
|
|
|
9
9
|
Read `${SKILL_DIR}/assets/planning-guide.md` for decomposition patterns and dependency ordering rules.
|
|
10
10
|
|
|
11
11
|
For each refactoring goal:
|
|
12
|
-
1. Identify atomic
|
|
13
|
-
2. Determine inter-item dependencies
|
|
12
|
+
1. Identify only the atomic operations necessary for the confirmed structural outcome; map each operation to a goal, behavior invariant, existing contract, or evidenced risk
|
|
13
|
+
2. Determine inter-item dependencies from actual producer/consumer relationships; use safe renames before structural changes as a default heuristic, not a substitute for evidence
|
|
14
14
|
3. Assess complexity per item from concrete indicators (file count, cross-module scope, public API/import-path impact, dependency depth, test coverage, behavior-preservation risk, migration impact)
|
|
15
15
|
4. Assign priority from concrete impact (blocked delivery, correctness/security/data risk, maintainability value, or local cleanup), not from size or user urgency alone
|
|
16
16
|
5. Assign behavior preservation strategy per item (read `${SKILL_DIR}/references/behavior-preservation.md`)
|
|
@@ -19,7 +19,7 @@ For each refactoring goal:
|
|
|
19
19
|
|
|
20
20
|
## Phase 5: Per-Item Confirmation Loop
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
Present items in reviewable groups. Use `AskUserQuestion` for each consequential scope, target-architecture, public-contract, migration, or behavior-preservation decision; independent low-risk items may share one confirmation batch when their meanings remain clear:
|
|
23
23
|
|
|
24
24
|
```text
|
|
25
25
|
Refactor Item R-001:
|
|
@@ -37,19 +37,21 @@ Refactor Item R-001:
|
|
|
37
37
|
Dependencies: [none / R-002, R-003]
|
|
38
38
|
```
|
|
39
39
|
|
|
40
|
-
Offer `Accept`, `Modify`, and `Skip` as selectable options. Re-display modified items before acceptance
|
|
40
|
+
Offer `Accept`, `Modify`, and `Skip` as selectable options. Re-display modified consequential items before acceptance. Do not ask the user to approve unconstrained implementation mechanics that preserve all confirmed boundaries and remain locally reversible.
|
|
41
41
|
|
|
42
42
|
---
|
|
43
43
|
|
|
44
44
|
## Phase 6: Completeness Review Checklist
|
|
45
45
|
|
|
46
|
-
1. **Dependency ordering check**: Verify items form a valid DAG (no cycles).
|
|
46
|
+
1. **Dependency ordering check**: Verify items form a valid DAG (no cycles). Follow verified producer/consumer dependencies; otherwise prefer the risk-reducing order safe renames -> extract/inline -> structural changes -> migrations.
|
|
47
47
|
2. **Behavior preservation check**: Every item must have a declared preservation strategy. Flag any item with `manual` strategy and no test coverage.
|
|
48
48
|
3. **Gap detection**: Are there intermediate steps needed between items? Does item A's output match item B's input assumption?
|
|
49
49
|
4. **Cross-module impact**: Do any items affect modules outside the declared scope?
|
|
50
|
-
5. **
|
|
51
|
-
|
|
52
|
-
|
|
50
|
+
5. **Intent and design necessity**: Does every item map to a confirmed structural goal, behavior invariant, existing contract, or evidenced risk? Remove unrelated cleanup and speculative redesign.
|
|
51
|
+
6. **Evidence status**: Are current-state observations, inferred architecture, recommendations, assumptions, and unknowns labeled distinctly? No AI-proposed architecture may appear as confirmed user intent without confirmation.
|
|
52
|
+
7. **Headless Context Completeness Gate**: Review every new or changed item as if the reviewer has never seen the planning conversation. Preserve unchanged historical items. Scan all AI-visible fields and sections first: every generated natural-language value in `project_description`, `global_context`, item fields, scope explanations, behavior-preservation/evidence text, `user_context`, comments, and parentheticals must be session-independent, with no dialogue-role labels, question IDs, answer tokens, planning-option recommendation markers, or planning provenance. Review changed root prose even when no refactor item changed. Then assess `description` plus `acceptance_criteria` without `user_context` and answer from the artifact alone:
|
|
53
|
+
1. What exact confirmed structural problem or outcome is this task responsible for, and how does it preserve the intent baseline?
|
|
54
|
+
2. What current architecture exists according to evidence, which target statements are confirmed versus recommended/assumed, and what target architecture must replace it?
|
|
53
55
|
3. Which approach was selected, expressed by meaning rather than an option label?
|
|
54
56
|
4. What scope boundaries, constraints, and non-goals must be preserved?
|
|
55
57
|
5. Why is each reference material and target path relevant, and what should be inspected?
|
|
@@ -57,6 +59,7 @@ Offer `Accept`, `Modify`, and `Skip` as selectable options. Re-display modified
|
|
|
57
59
|
7. Which behavior-preservation decisions and completion evidence prove equivalence?
|
|
58
60
|
8. Does any phrase require an unseen earlier question, recommendation, or option list?
|
|
59
61
|
9. Do quoted source materials agree with the final task decision?
|
|
62
|
+
10. Does every operation map to a confirmed structural goal, behavior invariant, existing contract, or evidenced risk, with no unrelated cleanup or speculative redesign?
|
|
60
63
|
|
|
61
64
|
Return `NEEDS_FIXES` whenever any answer is missing, ambiguous, or available only in `user_context`. Parenthetical notes must pass the same gate. Do not emit transcript annotations such as `(original response: "...")`; preserve substantive rationale, but omit bare selection tokens and `全部按照推荐` or equivalent blanket recommendation approval after normalization. Ask the user for clarification when a relative statement has more than one plausible antecedent; never guess.
|
|
62
65
|
|
|
@@ -107,12 +110,14 @@ Flag items using `manual` strategy prominently — they carry the highest risk o
|
|
|
107
110
|
|
|
108
111
|
## Dependency Ordering
|
|
109
112
|
|
|
110
|
-
Auto-detect
|
|
113
|
+
Auto-detect producer/consumer dependencies and enforce the resulting safe order. When no evidence requires another sequence, use this risk-reducing heuristic:
|
|
111
114
|
1. **Safe renames** first (lowest risk, no structural change)
|
|
112
115
|
2. **Extract/inline** operations (moderate risk, changes module boundaries)
|
|
113
116
|
3. **Structural changes** (higher risk, reorganizes architecture)
|
|
114
117
|
4. **Migrations** last (highest risk, changes patterns/paradigms)
|
|
115
118
|
|
|
119
|
+
Do not reorder items against verified dependencies merely to match the heuristic.
|
|
120
|
+
|
|
116
121
|
---
|
|
117
122
|
|
|
118
123
|
## Complexity Assessment
|
|
@@ -2,11 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
This guide helps assess refactoring scope, determine the appropriate approach, and identify risks before decomposing into executable items.
|
|
4
4
|
|
|
5
|
+
Treat numeric thresholds and named patterns in this guide as evidence prompts, not user-intent overrides. Base the final scope, complexity, and decomposition on verified files, consumers, contracts, tests, and the confirmed structural goal. Label estimates as recommendations or assumptions until evidence supports them.
|
|
6
|
+
|
|
5
7
|
---
|
|
6
8
|
|
|
7
9
|
## 1. Scope Classification
|
|
8
10
|
|
|
9
|
-
|
|
11
|
+
Classify the observed refactoring effort into the closest of three scope categories. Classification recommends planning depth; it does not expand the user's goal or make a larger target architecture mandatory.
|
|
10
12
|
|
|
11
13
|
### Incremental Refactoring
|
|
12
14
|
|
|
@@ -78,6 +80,8 @@ Before decomposing, assess the blast radius of the proposed refactoring.
|
|
|
78
80
|
|
|
79
81
|
### Impact Categories
|
|
80
82
|
|
|
83
|
+
Use file counts as an initial heuristic, then adjust from verified public contracts, dependency direction, behavior risk, and test coverage. A high count of mechanical import updates can be lower risk than one safety-critical public contract.
|
|
84
|
+
|
|
81
85
|
| Affected Files | Impact Level | Planning Implication |
|
|
82
86
|
|---------------|-------------|---------------------|
|
|
83
87
|
| 1-3 | Low | Single item likely sufficient |
|
|
@@ -136,6 +140,8 @@ Assess risk for each refactoring item and for the overall plan.
|
|
|
136
140
|
|
|
137
141
|
### Per-Item Risk Factors
|
|
138
142
|
|
|
143
|
+
Use only measurements supported by repository evidence. If coverage, code age, complexity, or dependency counts are unknown, mark them unknown rather than selecting a risk band from intuition.
|
|
144
|
+
|
|
139
145
|
| Factor | Low Risk | Medium Risk | High Risk |
|
|
140
146
|
|--------|----------|-------------|-----------|
|
|
141
147
|
| Test coverage | >80% on target | 40-80% | <40% |
|
|
@@ -167,7 +173,7 @@ Aggregate item risks to assess the plan:
|
|
|
167
173
|
|
|
168
174
|
### Splitting Heuristics
|
|
169
175
|
|
|
170
|
-
|
|
176
|
+
Treat these as triggers to assess a split, not automatic requirements. Split only when it reduces evidenced coordination, behavior-preservation, context, or rollback risk without breaking a necessary atomic migration:
|
|
171
177
|
|
|
172
178
|
1. **Item count exceeds 8**: More than 8 items in a single plan increases coordination risk. Split into logical phases.
|
|
173
179
|
2. **Estimated duration exceeds a day**: If the pipeline is expected to run for many hours, split at natural boundaries.
|
|
@@ -37,6 +37,21 @@ VALID_TYPES = {"extract", "rename", "restructure", "simplify", "decouple", "migr
|
|
|
37
37
|
VALID_PRIORITIES = {"critical", "high", "medium", "low"}
|
|
38
38
|
VALID_COMPLEXITIES = {"low", "medium", "high"}
|
|
39
39
|
VALID_PRESERVATION_STRATEGIES = {"test-gate", "snapshot", "manual"}
|
|
40
|
+
ALLOWED_LIST_FIELDS = {
|
|
41
|
+
"$schema", "project_name", "project_description", "created_at",
|
|
42
|
+
"created_by", "refactors", "global_context",
|
|
43
|
+
}
|
|
44
|
+
ALLOWED_GLOBAL_CONTEXT_FIELDS = {
|
|
45
|
+
"tech_stack", "language", "runtime", "frontend_framework",
|
|
46
|
+
"frontend_styling", "backend_framework", "database", "orm",
|
|
47
|
+
"testing_strategy", "bundler", "project_type", "ci_pipeline",
|
|
48
|
+
}
|
|
49
|
+
ALLOWED_REFACTOR_FIELDS = {
|
|
50
|
+
"id", "title", "description", "scope", "type", "priority", "complexity",
|
|
51
|
+
"estimated_lines", "behavior_preservation", "dependencies",
|
|
52
|
+
"acceptance_criteria", "status", "completion_notes", "user_context",
|
|
53
|
+
"browser_interaction", "model",
|
|
54
|
+
}
|
|
40
55
|
|
|
41
56
|
REFACTOR_ID_RE = re.compile(r"^R-\d{3}$")
|
|
42
57
|
|
|
@@ -155,6 +170,12 @@ def validate_refactor_list(data):
|
|
|
155
170
|
# ------------------------------------------------------------------
|
|
156
171
|
# 1. Top-level schema validation
|
|
157
172
|
# ------------------------------------------------------------------
|
|
173
|
+
unknown_root = set(data) - ALLOWED_LIST_FIELDS
|
|
174
|
+
if unknown_root:
|
|
175
|
+
errors.append("refactor list has unknown fields: {}".format(
|
|
176
|
+
", ".join(sorted(unknown_root))
|
|
177
|
+
))
|
|
178
|
+
|
|
158
179
|
schema = data.get("$schema")
|
|
159
180
|
if schema != SCHEMA_VERSION:
|
|
160
181
|
errors.append(
|
|
@@ -165,6 +186,17 @@ def validate_refactor_list(data):
|
|
|
165
186
|
if not isinstance(project_name, str) or not project_name.strip():
|
|
166
187
|
errors.append("project_name must be a non-empty string")
|
|
167
188
|
|
|
189
|
+
global_context = data.get("global_context")
|
|
190
|
+
if global_context is not None:
|
|
191
|
+
if not isinstance(global_context, dict):
|
|
192
|
+
errors.append("global_context must be an object")
|
|
193
|
+
else:
|
|
194
|
+
unknown_context = set(global_context) - ALLOWED_GLOBAL_CONTEXT_FIELDS
|
|
195
|
+
if unknown_context:
|
|
196
|
+
errors.append("global_context has unknown fields: {}".format(
|
|
197
|
+
", ".join(sorted(unknown_context))
|
|
198
|
+
))
|
|
199
|
+
|
|
168
200
|
refactors = data.get("refactors")
|
|
169
201
|
if not isinstance(refactors, list) or len(refactors) == 0:
|
|
170
202
|
errors.append("refactors must be a non-empty array")
|
|
@@ -209,6 +241,12 @@ def validate_refactor_list(data):
|
|
|
209
241
|
label, ", ".join(sorted(missing))
|
|
210
242
|
))
|
|
211
243
|
|
|
244
|
+
unknown = set(refactor.keys()) - ALLOWED_REFACTOR_FIELDS
|
|
245
|
+
if unknown:
|
|
246
|
+
errors.append("{} has unknown fields: {}".format(
|
|
247
|
+
label, ", ".join(sorted(unknown))
|
|
248
|
+
))
|
|
249
|
+
|
|
212
250
|
# -- ID format & uniqueness --
|
|
213
251
|
rid = refactor.get("id", "")
|
|
214
252
|
if not REFACTOR_ID_RE.match(str(rid)):
|
|
@@ -246,15 +284,6 @@ def validate_refactor_list(data):
|
|
|
246
284
|
)
|
|
247
285
|
)
|
|
248
286
|
|
|
249
|
-
# -- Retired fields --
|
|
250
|
-
for retired_field in ("critic", "critic_count"):
|
|
251
|
-
if retired_field in refactor:
|
|
252
|
-
errors.append(
|
|
253
|
-
"{}: '{}' field is retired; remove it from refactor-list data".format(
|
|
254
|
-
label, retired_field
|
|
255
|
-
)
|
|
256
|
-
)
|
|
257
|
-
|
|
258
287
|
# -- Scope --
|
|
259
288
|
scope = refactor.get("scope")
|
|
260
289
|
if isinstance(scope, dict):
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "prizmkit",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.165",
|
|
4
4
|
"description": "Create a new PrizmKit-powered project with clean initialization — no framework dev files, just what you need.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -36,7 +36,9 @@
|
|
|
36
36
|
"framework",
|
|
37
37
|
"codebuddy",
|
|
38
38
|
"claude-code",
|
|
39
|
-
"codex"
|
|
39
|
+
"codex",
|
|
40
|
+
"cursor",
|
|
41
|
+
"cursor-agent"
|
|
40
42
|
],
|
|
41
43
|
"author": "PrizmKit",
|
|
42
44
|
"license": "MIT"
|
package/src/ai-cli-launch.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const BUILT_IN_AI_CLI_NAMES = new Set(['claude', 'cbc', 'codebuddy', 'codex', 'pi']);
|
|
1
|
+
const BUILT_IN_AI_CLI_NAMES = new Set(['claude', 'cbc', 'codebuddy', 'codex', 'pi', 'agent']);
|
|
2
2
|
|
|
3
3
|
function asText(value) {
|
|
4
4
|
return typeof value === 'string' ? value : '';
|
|
@@ -81,6 +81,8 @@ export function formatCliArgsForPrompt(args = []) {
|
|
|
81
81
|
function normalizeExecutable(aiCli) {
|
|
82
82
|
const trimmed = asText(aiCli).trim();
|
|
83
83
|
if (!trimmed) return '';
|
|
84
|
+
const unquoted = trimmed.replace(/^(['"])(.*)\1$/, '$2');
|
|
85
|
+
if (/^[A-Za-z]:\\/.test(unquoted) && /\.(exe|cmd|bat)$/i.test(unquoted)) return unquoted;
|
|
84
86
|
const tokens = tokenizeCliArgs(trimmed);
|
|
85
87
|
if (tokens.length !== 1) {
|
|
86
88
|
throw new Error('自定义 AI CLI 需要把可执行命令和额外参数分开填写;请把额外参数写入无头模式希望添加的参数。');
|
|
@@ -89,8 +91,13 @@ function normalizeExecutable(aiCli) {
|
|
|
89
91
|
}
|
|
90
92
|
|
|
91
93
|
function executableBasename(aiCli) {
|
|
94
|
+
const raw = asText(aiCli).trim();
|
|
95
|
+
const unquoted = raw.replace(/^(['"])(.*)\1$/, '$2');
|
|
96
|
+
if (/^[A-Za-z]:\\/.test(unquoted) && /\.(exe|cmd|bat)$/i.test(unquoted)) {
|
|
97
|
+
return (unquoted.split(/[\\/]/).pop()?.toLowerCase() || '').replace(/\.(exe|cmd|bat)$/i, '');
|
|
98
|
+
}
|
|
92
99
|
const executable = normalizeExecutable(aiCli);
|
|
93
|
-
return executable.split(/[\\/]/).pop()?.toLowerCase() || '';
|
|
100
|
+
return (executable.split(/[\\/]/).pop()?.toLowerCase() || '').replace(/\.(exe|cmd|bat)$/i, '');
|
|
94
101
|
}
|
|
95
102
|
|
|
96
103
|
export function isBuiltInAiCli(aiCli) {
|
package/src/clean.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import chalk from 'chalk';
|
|
2
2
|
import path from 'path';
|
|
3
3
|
import fs from 'fs-extra';
|
|
4
|
-
import {
|
|
4
|
+
import { pathToFileURL } from 'node:url';
|
|
5
|
+
import { getAdaptersDir, loadMetadata, loadRulesMetadata } from './metadata.js';
|
|
5
6
|
import { readManifest } from './manifest.js';
|
|
6
7
|
import { privateProjectMemoryFile, projectMemoryFile } from './platforms.js';
|
|
7
8
|
|
|
@@ -170,6 +171,18 @@ async function removeGeneratedCodexConfig(projectRoot, dryRun) {
|
|
|
170
171
|
return { path: configPath, removed: true };
|
|
171
172
|
}
|
|
172
173
|
|
|
174
|
+
async function removeCursorHooks(projectRoot, dryRun) {
|
|
175
|
+
const adapterPath = path.join(getAdaptersDir(), 'cursor', 'hooks-adapter.js');
|
|
176
|
+
const { removeHooks } = await import(pathToFileURL(adapterPath).href);
|
|
177
|
+
return (await removeHooks(projectRoot, dryRun)).map(change => ({
|
|
178
|
+
path: path.join(projectRoot, change.path),
|
|
179
|
+
removed: !dryRun && change.action === 'removed',
|
|
180
|
+
updated: !dryRun && change.action === 'updated',
|
|
181
|
+
reason: dryRun ? 'dry_run' : undefined,
|
|
182
|
+
note: change.action === 'updated' ? '(PrizmKit hook entries)' : undefined,
|
|
183
|
+
}));
|
|
184
|
+
}
|
|
185
|
+
|
|
173
186
|
export async function runClean(directory, options = {}) {
|
|
174
187
|
const projectRoot = path.resolve(directory || '.');
|
|
175
188
|
const dryRun = Boolean(options.dryRun);
|
|
@@ -191,18 +204,19 @@ export async function runClean(directory, options = {}) {
|
|
|
191
204
|
// Read manifest for accurate cleanup (covers skills from older versions)
|
|
192
205
|
const manifest = await readManifest(projectRoot);
|
|
193
206
|
|
|
207
|
+
// Validate and merge-remove Cursor hooks before any destructive cleanup.
|
|
208
|
+
const cursorHookResults = await removeCursorHooks(projectRoot, dryRun);
|
|
209
|
+
|
|
194
210
|
const metadataSkillNames = Object.keys(metadata.skills);
|
|
195
211
|
const externalSkillNames = (metadata.external_skills?.known || []).map(s => s.name);
|
|
196
212
|
const manifestSkillNames = manifest?.files?.skills || [];
|
|
197
213
|
const allSkillNames = [...new Set([...metadataSkillNames, ...externalSkillNames, ...manifestSkillNames])];
|
|
198
214
|
|
|
199
|
-
// Retired PrizmKit named-agent files
|
|
200
|
-
const
|
|
215
|
+
// Retired PrizmKit named-agent files have deterministic managed identities.
|
|
216
|
+
const agentFiles = [
|
|
201
217
|
LEGACY_DEV_AGENT_FILE,
|
|
202
218
|
LEGACY_REVIEWER_AGENT_FILE,
|
|
203
219
|
];
|
|
204
|
-
const manifestAgentFiles = manifest?.files?.agents || [];
|
|
205
|
-
const agentFiles = [...new Set([...knownAgentFiles, ...manifestAgentFiles])];
|
|
206
220
|
const codexAgentFiles = [...new Set(agentFiles.flatMap(f => [f, f.replace(/\.md$/, '.toml')]))];
|
|
207
221
|
|
|
208
222
|
// Rule file names installed by PrizmKit (union of metadata + manifest)
|
|
@@ -255,6 +269,10 @@ export async function runClean(directory, options = {}) {
|
|
|
255
269
|
const piSkillsDir = path.join(projectRoot, '.pi', 'skills');
|
|
256
270
|
results.push(...await removeKnownEntries(piSkillsDir, allSkillNames, dryRun));
|
|
257
271
|
|
|
272
|
+
// .cursor/skills/ — Cursor project Agent Skills
|
|
273
|
+
const cursorSkillsDir = path.join(projectRoot, '.cursor', 'skills');
|
|
274
|
+
results.push(...await removeKnownEntries(cursorSkillsDir, allSkillNames, dryRun));
|
|
275
|
+
|
|
258
276
|
// .claude/agents/ — retired PrizmKit named-agent files
|
|
259
277
|
const claudeAgentsDir = path.join(projectRoot, '.claude', 'agents');
|
|
260
278
|
results.push(...await removeKnownEntries(claudeAgentsDir, agentFiles, dryRun));
|
|
@@ -286,7 +304,15 @@ export async function runClean(directory, options = {}) {
|
|
|
286
304
|
const piRulesDir = path.join(projectRoot, '.pi', 'rules');
|
|
287
305
|
results.push(...await removeKnownEntries(piRulesDir, ruleFileNames.map(n => `${n}.md`), dryRun));
|
|
288
306
|
|
|
289
|
-
|
|
307
|
+
const cursorRulesDir = path.join(projectRoot, '.cursor', 'rules');
|
|
308
|
+
results.push(...await removeKnownEntries(
|
|
309
|
+
cursorRulesDir,
|
|
310
|
+
[...ruleFileNames.map(n => `${n}.mdc`), 'prizmkit-framework.mdc'],
|
|
311
|
+
dryRun,
|
|
312
|
+
));
|
|
313
|
+
results.push(...cursorHookResults);
|
|
314
|
+
|
|
315
|
+
for (const platform of ['codebuddy', 'claude', 'codex', 'pi', 'cursor']) {
|
|
290
316
|
const memoryFile = projectMemoryFile(platform);
|
|
291
317
|
const privateMemoryFile = privateProjectMemoryFile(platform);
|
|
292
318
|
if (!privateMemoryFile) continue;
|
|
@@ -297,6 +323,13 @@ export async function runClean(directory, options = {}) {
|
|
|
297
323
|
results.push(await cleanMarkedProjectMemory(projectRoot, privateMemoryFile, dryRun));
|
|
298
324
|
}
|
|
299
325
|
|
|
326
|
+
if (!dryRun) {
|
|
327
|
+
for (const relativeDir of ['.cursor/hooks', '.cursor/rules', '.cursor/skills', '.cursor']) {
|
|
328
|
+
const dir = path.join(projectRoot, relativeDir);
|
|
329
|
+
if (await fs.pathExists(dir) && (await fs.readdir(dir)).length === 0) await fs.remove(dir);
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
|
|
300
333
|
// ── Private host-memory .gitignore cleanup (never `.prizmkit/**`) ─────────
|
|
301
334
|
const gitignoreResult = await cleanGitignore(projectRoot, dryRun);
|
|
302
335
|
|
|
@@ -318,6 +351,9 @@ export async function runClean(directory, options = {}) {
|
|
|
318
351
|
if (item.removed) {
|
|
319
352
|
const note = item.note ? chalk.gray(` ${item.note}`) : '';
|
|
320
353
|
console.log(chalk.green(` ✓ 已删除: ${item.path}`) + note);
|
|
354
|
+
} else if (item.updated) {
|
|
355
|
+
const note = item.note ? chalk.gray(` ${item.note}`) : '';
|
|
356
|
+
console.log(chalk.green(` ✓ 已更新: ${item.path}`) + note);
|
|
321
357
|
} else if (item.reason === 'dry_run') {
|
|
322
358
|
console.log(chalk.gray(` [dry-run] ${item.path}`));
|
|
323
359
|
}
|
package/src/config.js
CHANGED
|
@@ -14,13 +14,14 @@ import fs from 'fs-extra';
|
|
|
14
14
|
import path from 'path';
|
|
15
15
|
import { readFileSync } from 'fs';
|
|
16
16
|
import { dirname, join } from 'path';
|
|
17
|
-
import { fileURLToPath } from 'url';
|
|
17
|
+
import { fileURLToPath, pathToFileURL } from 'url';
|
|
18
18
|
import { confirm } from '@inquirer/prompts';
|
|
19
19
|
|
|
20
20
|
import { readManifest, writeManifest, buildManifest, diffManifest } from './manifest.js';
|
|
21
21
|
import {
|
|
22
22
|
loadMetadata,
|
|
23
23
|
loadRulesMetadata,
|
|
24
|
+
getAdaptersDir,
|
|
24
25
|
} from './metadata.js';
|
|
25
26
|
import {
|
|
26
27
|
installSkills,
|
|
@@ -83,6 +84,35 @@ async function removeGeneratedCodexConfig(projectRoot, dryRun) {
|
|
|
83
84
|
}
|
|
84
85
|
}
|
|
85
86
|
|
|
87
|
+
async function removeCursorManagedFiles(projectRoot, dryRun) {
|
|
88
|
+
const adapterPath = path.join(getAdaptersDir(), 'cursor', 'hooks-adapter.js');
|
|
89
|
+
const { removeHooks } = await import(pathToFileURL(adapterPath).href);
|
|
90
|
+
for (const change of await removeHooks(projectRoot, dryRun)) {
|
|
91
|
+
const verb = change.action === 'updated' ? 'update' : 'remove';
|
|
92
|
+
console.log(dryRun
|
|
93
|
+
? chalk.gray(` [dry-run] ${verb} ${change.path}`)
|
|
94
|
+
: change.action === 'updated'
|
|
95
|
+
? chalk.green(` ✓ updated ${change.path} (removed PrizmKit hooks)`)
|
|
96
|
+
: chalk.red(` ✗ removed ${change.path}`));
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
const guidancePath = path.join(projectRoot, '.cursor', 'rules', 'prizmkit-framework.mdc');
|
|
100
|
+
if (await fs.pathExists(guidancePath)) {
|
|
101
|
+
if (dryRun) console.log(chalk.gray(' [dry-run] remove .cursor/rules/prizmkit-framework.mdc'));
|
|
102
|
+
else {
|
|
103
|
+
await fs.remove(guidancePath);
|
|
104
|
+
console.log(chalk.red(' ✗ removed .cursor/rules/prizmkit-framework.mdc'));
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
if (!dryRun) {
|
|
109
|
+
for (const relativeDir of ['.cursor/hooks', '.cursor/rules', '.cursor']) {
|
|
110
|
+
const dir = path.join(projectRoot, relativeDir);
|
|
111
|
+
if (await fs.pathExists(dir) && (await fs.readdir(dir)).length === 0) await fs.remove(dir);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
86
116
|
/**
|
|
87
117
|
* Detect which platforms are actually installed on filesystem.
|
|
88
118
|
*/
|
|
@@ -100,9 +130,11 @@ async function detectInstalledPlatforms(projectRoot) {
|
|
|
100
130
|
const hasCodeBuddy = await hasPlatformFiles(path.join(projectRoot, '.codebuddy', 'skills'));
|
|
101
131
|
const hasCodex = await hasPlatformFiles(path.join(projectRoot, '.agents', 'skills'));
|
|
102
132
|
const hasPi = await hasPlatformFiles(path.join(projectRoot, '.pi', 'skills'));
|
|
103
|
-
const
|
|
133
|
+
const hasCursor = await hasPlatformFiles(path.join(projectRoot, '.cursor', 'skills'));
|
|
134
|
+
const detected = [hasClaude && 'claude', hasCodeBuddy && 'codebuddy', hasCodex && 'codex', hasPi && 'pi', hasCursor && 'cursor'].filter(Boolean);
|
|
104
135
|
|
|
105
136
|
if (detected.length > 1) return detected.length === 2 && hasClaude && hasCodeBuddy ? 'both' : 'all';
|
|
137
|
+
if (hasCursor) return 'cursor';
|
|
106
138
|
if (hasPi) return 'pi';
|
|
107
139
|
if (hasCodex) return 'codex';
|
|
108
140
|
if (hasCodeBuddy) return 'codebuddy';
|
|
@@ -221,14 +253,14 @@ async function migrateProjectMemoryOnPlatformDrop(droppedPlatform, newPlatforms,
|
|
|
221
253
|
* Selective removal — only removes known PrizmKit files, leaves user-created files intact.
|
|
222
254
|
*/
|
|
223
255
|
async function removePlatformFiles(platform, projectRoot, manifest, dryRun) {
|
|
256
|
+
// Validate and remove merge-sensitive Cursor hooks before any other platform mutation.
|
|
257
|
+
if (platform === 'cursor') await removeCursorManagedFiles(projectRoot, dryRun);
|
|
258
|
+
|
|
224
259
|
const skillNames = manifest?.files?.skills || [];
|
|
225
260
|
const ruleFileNames = manifest?.files?.rules || [];
|
|
226
261
|
const agentFileNames = [
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
LEGACY_DEV_AGENT_FILE,
|
|
230
|
-
LEGACY_REVIEWER_AGENT_FILE,
|
|
231
|
-
]),
|
|
262
|
+
LEGACY_DEV_AGENT_FILE,
|
|
263
|
+
LEGACY_REVIEWER_AGENT_FILE,
|
|
232
264
|
];
|
|
233
265
|
|
|
234
266
|
if (skillNames.length) {
|
|
@@ -247,7 +279,9 @@ async function removePlatformFiles(platform, projectRoot, manifest, dryRun) {
|
|
|
247
279
|
}
|
|
248
280
|
|
|
249
281
|
// Settings
|
|
250
|
-
if (platform === '
|
|
282
|
+
if (platform === 'cursor') {
|
|
283
|
+
// Merge-sensitive Cursor hooks and managed framework guidance were handled first.
|
|
284
|
+
} else if (platform === 'codex') {
|
|
251
285
|
await removeGeneratedCodexConfig(projectRoot, dryRun);
|
|
252
286
|
const legacySettingsFile = path.join(projectRoot, '.codex', 'prizmkit-settings.json');
|
|
253
287
|
if (await fs.pathExists(legacySettingsFile)) {
|
|
@@ -380,6 +414,13 @@ async function removePlatformFiles(platform, projectRoot, manifest, dryRun) {
|
|
|
380
414
|
await fs.remove(dir);
|
|
381
415
|
}
|
|
382
416
|
}
|
|
417
|
+
} else if (platform === 'cursor') {
|
|
418
|
+
for (const relativeDir of ['.cursor/skills', '.cursor/rules', '.cursor/hooks', '.cursor']) {
|
|
419
|
+
const dir = path.join(projectRoot, relativeDir);
|
|
420
|
+
if (await fs.pathExists(dir) && !dryRun && (await fs.readdir(dir)).length === 0) {
|
|
421
|
+
await fs.remove(dir);
|
|
422
|
+
}
|
|
423
|
+
}
|
|
383
424
|
}
|
|
384
425
|
}
|
|
385
426
|
|
|
@@ -441,7 +482,7 @@ export async function runConfig(directory, options = {}) {
|
|
|
441
482
|
};
|
|
442
483
|
|
|
443
484
|
if (options.platform !== undefined && !isKnownPlatform(options.platform)) {
|
|
444
|
-
throw new Error(`Unknown platform "${options.platform}". Expected codebuddy, claude, codex, or all.`);
|
|
485
|
+
throw new Error(`Unknown platform "${options.platform}". Expected codebuddy, claude, codex, pi, cursor, or all.`);
|
|
445
486
|
}
|
|
446
487
|
|
|
447
488
|
// Display current config
|
|
@@ -519,7 +560,7 @@ export async function runConfig(directory, options = {}) {
|
|
|
519
560
|
}
|
|
520
561
|
|
|
521
562
|
if (!isKnownPlatform(newConfig.platform)) {
|
|
522
|
-
throw new Error(`Unknown platform "${newConfig.platform}". Expected codebuddy, claude, codex, or all.`);
|
|
563
|
+
throw new Error(`Unknown platform "${newConfig.platform}". Expected codebuddy, claude, codex, pi, cursor, or all.`);
|
|
523
564
|
}
|
|
524
565
|
|
|
525
566
|
// ── Phase 3: COMPUTE DIFF ────────────────────────────────────────────────
|
package/src/detect-platform.js
CHANGED
|
@@ -9,7 +9,7 @@ import os from 'os';
|
|
|
9
9
|
/**
|
|
10
10
|
* 允许检测的命令白名单(仅用于 which 检测)
|
|
11
11
|
*/
|
|
12
|
-
const ALLOWED_COMMANDS = ['cbc', 'claude', 'codex', 'pi'];
|
|
12
|
+
const ALLOWED_COMMANDS = ['cbc', 'claude', 'codex', 'pi', 'agent'];
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
15
|
* 检查命令是否存在于 PATH 中
|
|
@@ -27,23 +27,44 @@ function commandExists(cmd) {
|
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
+
function cursorAgentExists() {
|
|
31
|
+
if (!commandExists('agent')) return false;
|
|
32
|
+
try {
|
|
33
|
+
const options = {
|
|
34
|
+
encoding: 'utf8',
|
|
35
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
36
|
+
timeout: 5000,
|
|
37
|
+
};
|
|
38
|
+
const version = String(execFileSync('agent', ['--version'], options) || '');
|
|
39
|
+
const help = String(execFileSync('agent', ['--help'], options) || '');
|
|
40
|
+
const identity = `${version}\n${help}`.toLowerCase();
|
|
41
|
+
const requiredFlags = ['--print', '--force', '--trust', '--output-format'];
|
|
42
|
+
return identity.includes('cursor') && requiredFlags.every(flag => help.includes(flag));
|
|
43
|
+
} catch {
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
30
48
|
/**
|
|
31
49
|
* 检测已安装的 AI CLI 工具,并返回推荐的默认平台和 CLI 命令。
|
|
32
50
|
*
|
|
33
|
-
* 注意:platform
|
|
34
|
-
*
|
|
51
|
+
* 注意:platform 控制目录结构,suggestedCli 是实际运行的可执行命令。
|
|
52
|
+
* Cursor 的 `agent` 名称通用,只有安全的 version/help 身份探测通过才自动选择。
|
|
35
53
|
*
|
|
36
|
-
* @returns {{ cbc: boolean, claude: boolean, codex: boolean, pi: boolean, suggested: string, suggestedCli: string }}
|
|
54
|
+
* @returns {{ cbc: boolean, claude: boolean, codex: boolean, pi: boolean, cursor: boolean, suggested: string, suggestedCli: string }}
|
|
37
55
|
*/
|
|
38
56
|
export function detectPlatform() {
|
|
39
57
|
const cbc = commandExists('cbc');
|
|
40
58
|
const claude = commandExists('claude');
|
|
41
59
|
const codex = commandExists('codex');
|
|
42
60
|
const pi = commandExists('pi');
|
|
61
|
+
const cursor = cursorAgentExists();
|
|
43
62
|
|
|
44
|
-
// Preserve historical recommendations when Pi
|
|
63
|
+
// Preserve historical recommendations when Cursor and Pi are absent.
|
|
45
64
|
let suggested = 'codebuddy';
|
|
46
|
-
if (
|
|
65
|
+
if (cursor) {
|
|
66
|
+
suggested = (cbc || claude || codex || pi) ? 'all' : 'cursor';
|
|
67
|
+
} else if (pi) {
|
|
47
68
|
suggested = (cbc || claude || codex) ? 'all' : 'pi';
|
|
48
69
|
} else if (cbc && claude && codex) {
|
|
49
70
|
suggested = 'all';
|
|
@@ -55,12 +76,13 @@ export function detectPlatform() {
|
|
|
55
76
|
suggested = 'codebuddy';
|
|
56
77
|
}
|
|
57
78
|
|
|
58
|
-
// Preserve historical precedence and use
|
|
79
|
+
// Preserve historical precedence and use Cursor only when it is the first available CLI.
|
|
59
80
|
let suggestedCli = '';
|
|
60
81
|
if (cbc) suggestedCli = 'cbc';
|
|
61
82
|
else if (claude) suggestedCli = 'claude';
|
|
62
83
|
else if (codex) suggestedCli = 'codex';
|
|
63
84
|
else if (pi) suggestedCli = 'pi';
|
|
85
|
+
else if (cursor) suggestedCli = 'agent';
|
|
64
86
|
|
|
65
|
-
return { cbc, claude, codex, pi, suggested, suggestedCli };
|
|
87
|
+
return { cbc, claude, codex, pi, cursor, suggested, suggestedCli };
|
|
66
88
|
}
|