prizmkit 1.1.174 → 1.1.176
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundled/VERSION.json +3 -3
- package/bundled/rules/prizm/prizm-commit-workflow.md +3 -3
- package/bundled/skills/_metadata.json +1 -1
- package/bundled/skills/bug-planner/SKILL.md +46 -43
- package/bundled/skills/bug-planner/references/error-recovery.md +24 -24
- package/bundled/skills/bug-planner/references/generated-plan-review.md +24 -11
- package/bundled/skills/bug-planner/scripts/validate-bug-list.py +216 -1
- package/bundled/skills/feature-planner/SKILL.md +39 -30
- package/bundled/skills/feature-planner/references/error-recovery.md +25 -15
- package/bundled/skills/feature-planner/references/generated-plan-review.md +24 -11
- package/bundled/skills/feature-planner/references/incremental-feature-planning.md +85 -70
- package/bundled/skills/feature-planner/references/new-project-planning.md +7 -4
- package/bundled/skills/feature-planner/scripts/validate-and-generate.py +213 -0
- package/bundled/skills/prizmkit/SKILL.md +5 -5
- package/bundled/skills/prizmkit-committer/SKILL.md +21 -24
- package/bundled/skills/prizmkit-workflow/SKILL.md +8 -8
- package/bundled/skills/prizmkit-workflow/references/workflow-state-protocol.md +5 -5
- package/bundled/skills/refactor-planner/SKILL.md +47 -14
- package/bundled/skills/refactor-planner/references/error-recovery.md +16 -8
- package/bundled/skills/refactor-planner/references/fast-path.md +6 -5
- package/bundled/skills/refactor-planner/references/generated-plan-review.md +24 -11
- package/bundled/skills/refactor-planner/scripts/validate-and-generate-refactor.py +213 -0
- package/package.json +1 -1
|
@@ -6,12 +6,18 @@ for the dev-pipeline system.
|
|
|
6
6
|
Commands:
|
|
7
7
|
validate Validate an existing .prizmkit/plans/refactor-list.json
|
|
8
8
|
template Generate a blank template .prizmkit/plans/refactor-list.json
|
|
9
|
+
context Print bounded project context plus the five most recent refactors
|
|
10
|
+
show Print one explicitly requested refactor
|
|
11
|
+
append Merge an additions-only draft into an existing validated list
|
|
9
12
|
generate Validate a draft JSON and generate final refactor-list.json with defaults
|
|
10
13
|
summary Print a summary table of refactors from a .prizmkit/plans/refactor-list.json
|
|
11
14
|
|
|
12
15
|
Usage:
|
|
13
16
|
python3 validate-and-generate-refactor.py validate --input .prizmkit/plans/refactor-list.json [--output validated.json]
|
|
14
17
|
python3 validate-and-generate-refactor.py template --output .prizmkit/plans/refactor-list.json
|
|
18
|
+
python3 validate-and-generate-refactor.py context --input .prizmkit/plans/refactor-list.json
|
|
19
|
+
python3 validate-and-generate-refactor.py show --input .prizmkit/plans/refactor-list.json --id R-001
|
|
20
|
+
python3 validate-and-generate-refactor.py append --input additions.json --output .prizmkit/plans/refactor-list.json
|
|
15
21
|
python3 validate-and-generate-refactor.py generate --input draft.json --output .prizmkit/plans/refactor-list.json
|
|
16
22
|
python3 validate-and-generate-refactor.py summary --input .prizmkit/plans/refactor-list.json [--format markdown|json]
|
|
17
23
|
|
|
@@ -20,10 +26,12 @@ Python 3.6+ required. No external dependencies.
|
|
|
20
26
|
|
|
21
27
|
import argparse
|
|
22
28
|
import collections
|
|
29
|
+
import copy
|
|
23
30
|
import json
|
|
24
31
|
import os
|
|
25
32
|
import re
|
|
26
33
|
import sys
|
|
34
|
+
import tempfile
|
|
27
35
|
from datetime import datetime, timezone
|
|
28
36
|
|
|
29
37
|
# ---------------------------------------------------------------------------
|
|
@@ -102,6 +110,25 @@ def _write_json(path, data):
|
|
|
102
110
|
fh.write("\n")
|
|
103
111
|
|
|
104
112
|
|
|
113
|
+
def _write_json_atomic(path, data):
|
|
114
|
+
"""Atomically replace *path* with pretty-printed JSON data."""
|
|
115
|
+
parent = os.path.dirname(os.path.abspath(path))
|
|
116
|
+
if parent and not os.path.isdir(parent):
|
|
117
|
+
os.makedirs(parent, exist_ok=True)
|
|
118
|
+
fd, temp_path = tempfile.mkstemp(prefix=".refactor-list-", suffix=".tmp", dir=parent)
|
|
119
|
+
try:
|
|
120
|
+
with os.fdopen(fd, "w", encoding="utf-8") as fh:
|
|
121
|
+
json.dump(data, fh, indent=2, ensure_ascii=False)
|
|
122
|
+
fh.write("\n")
|
|
123
|
+
os.replace(temp_path, path)
|
|
124
|
+
except Exception:
|
|
125
|
+
try:
|
|
126
|
+
os.unlink(temp_path)
|
|
127
|
+
except OSError:
|
|
128
|
+
pass
|
|
129
|
+
raise
|
|
130
|
+
|
|
131
|
+
|
|
105
132
|
# ---------------------------------------------------------------------------
|
|
106
133
|
# Cycle detection (Kahn's algorithm)
|
|
107
134
|
# ---------------------------------------------------------------------------
|
|
@@ -728,6 +755,148 @@ def cmd_template(args):
|
|
|
728
755
|
return 0
|
|
729
756
|
|
|
730
757
|
|
|
758
|
+
def _load_valid_existing(path):
|
|
759
|
+
"""Load and validate one existing refactor list."""
|
|
760
|
+
data, load_err = _load_json(path)
|
|
761
|
+
if load_err:
|
|
762
|
+
_err(load_err)
|
|
763
|
+
return None, None, 2
|
|
764
|
+
if not isinstance(data, dict):
|
|
765
|
+
_err("Refactor list root must be an object")
|
|
766
|
+
return None, None, 1
|
|
767
|
+
|
|
768
|
+
result = validate_refactor_list(data)
|
|
769
|
+
if not result["valid"]:
|
|
770
|
+
_err("Existing refactor list is invalid")
|
|
771
|
+
for error in result["errors"]:
|
|
772
|
+
_err(" " + error)
|
|
773
|
+
return None, result, 1
|
|
774
|
+
return data, result, 0
|
|
775
|
+
|
|
776
|
+
|
|
777
|
+
def _next_top_level_id(refactors):
|
|
778
|
+
"""Return the next R-NNN ID, or None when numeric capacity is exhausted."""
|
|
779
|
+
numbers = []
|
|
780
|
+
for refactor in refactors:
|
|
781
|
+
match = REFACTOR_ID_RE.match(str(refactor.get("id", "")))
|
|
782
|
+
if match:
|
|
783
|
+
numbers.append(int(str(refactor["id"])[2:]))
|
|
784
|
+
next_number = max(numbers, default=0) + 1
|
|
785
|
+
if next_number > 999:
|
|
786
|
+
return None
|
|
787
|
+
return "R-{:03d}".format(next_number)
|
|
788
|
+
|
|
789
|
+
|
|
790
|
+
def cmd_context(args):
|
|
791
|
+
"""Print bounded existing-list context for incremental planning."""
|
|
792
|
+
data, _, exit_code = _load_valid_existing(args.input)
|
|
793
|
+
if exit_code:
|
|
794
|
+
return exit_code
|
|
795
|
+
|
|
796
|
+
refactors = data["refactors"]
|
|
797
|
+
next_id = _next_top_level_id(refactors)
|
|
798
|
+
if next_id is None:
|
|
799
|
+
_err("Refactor ID capacity exhausted at R-999")
|
|
800
|
+
return 1
|
|
801
|
+
|
|
802
|
+
context = {
|
|
803
|
+
"project_name": data.get("project_name"),
|
|
804
|
+
"project_description": data.get("project_description"),
|
|
805
|
+
"global_context": data.get("global_context") or {},
|
|
806
|
+
"task_count": len(refactors),
|
|
807
|
+
"next_id": next_id,
|
|
808
|
+
"recent_tasks": [
|
|
809
|
+
{"id": refactor.get("id"), "description": refactor.get("description")}
|
|
810
|
+
for refactor in refactors[-5:]
|
|
811
|
+
],
|
|
812
|
+
}
|
|
813
|
+
print(json.dumps(context, indent=2, ensure_ascii=False))
|
|
814
|
+
return 0
|
|
815
|
+
|
|
816
|
+
|
|
817
|
+
def cmd_show(args):
|
|
818
|
+
"""Print one explicitly requested top-level refactor."""
|
|
819
|
+
data, _, exit_code = _load_valid_existing(args.input)
|
|
820
|
+
if exit_code:
|
|
821
|
+
return exit_code
|
|
822
|
+
if not REFACTOR_ID_RE.match(str(args.id)):
|
|
823
|
+
_err("Refactor ID '{}' must match R-NNN".format(args.id))
|
|
824
|
+
return 1
|
|
825
|
+
|
|
826
|
+
for refactor in data["refactors"]:
|
|
827
|
+
if refactor.get("id") == args.id:
|
|
828
|
+
print(json.dumps(refactor, indent=2, ensure_ascii=False))
|
|
829
|
+
return 0
|
|
830
|
+
_err("Refactor '{}' not found".format(args.id))
|
|
831
|
+
return 1
|
|
832
|
+
|
|
833
|
+
|
|
834
|
+
def cmd_append(args):
|
|
835
|
+
"""Append a collection-only draft to an existing validated refactor list."""
|
|
836
|
+
base, _, exit_code = _load_valid_existing(args.output)
|
|
837
|
+
if exit_code:
|
|
838
|
+
return exit_code
|
|
839
|
+
|
|
840
|
+
draft, load_err = _load_json(args.input)
|
|
841
|
+
if load_err:
|
|
842
|
+
_err(load_err)
|
|
843
|
+
return 2
|
|
844
|
+
if not isinstance(draft, dict) or set(draft.keys()) != {"refactors"}:
|
|
845
|
+
_err("Additions draft must be an object containing only 'refactors'")
|
|
846
|
+
return 1
|
|
847
|
+
additions = draft.get("refactors")
|
|
848
|
+
if not isinstance(additions, list) or not additions:
|
|
849
|
+
_err("Additions draft 'refactors' must be a non-empty array")
|
|
850
|
+
return 1
|
|
851
|
+
if not all(isinstance(refactor, dict) for refactor in additions):
|
|
852
|
+
_err("Every refactor addition must be an object")
|
|
853
|
+
return 1
|
|
854
|
+
|
|
855
|
+
merge_base = copy.deepcopy(base)
|
|
856
|
+
if args.replace_tail:
|
|
857
|
+
addition_ids = [refactor.get("id") for refactor in additions]
|
|
858
|
+
tail_ids = [refactor.get("id") for refactor in base["refactors"][-len(additions):]]
|
|
859
|
+
if len(base["refactors"]) < len(additions) or tail_ids != addition_ids:
|
|
860
|
+
_err("--replace-tail requires additions IDs to match the existing final-list suffix exactly")
|
|
861
|
+
return 1
|
|
862
|
+
merge_base["refactors"] = merge_base["refactors"][:-len(additions)]
|
|
863
|
+
|
|
864
|
+
next_id = _next_top_level_id(merge_base["refactors"])
|
|
865
|
+
if next_id is None:
|
|
866
|
+
_err("Refactor ID capacity exhausted at R-999")
|
|
867
|
+
return 1
|
|
868
|
+
start_number = int(next_id[2:])
|
|
869
|
+
prepared = copy.deepcopy(additions)
|
|
870
|
+
for offset, refactor in enumerate(prepared):
|
|
871
|
+
expected_id = "R-{:03d}".format(start_number + offset)
|
|
872
|
+
if start_number + offset > 999:
|
|
873
|
+
_err("Refactor ID capacity exhausted at R-999")
|
|
874
|
+
return 1
|
|
875
|
+
if refactor.get("id") != expected_id:
|
|
876
|
+
_err("Refactor addition {} must use next sequential ID '{}'".format(offset, expected_id))
|
|
877
|
+
return 1
|
|
878
|
+
refactor.setdefault("status", "pending")
|
|
879
|
+
|
|
880
|
+
merged = copy.deepcopy(merge_base)
|
|
881
|
+
merged["refactors"].extend(prepared)
|
|
882
|
+
result = validate_refactor_list(merged)
|
|
883
|
+
result["appended_ids"] = [refactor["id"] for refactor in prepared]
|
|
884
|
+
print(json.dumps(result, indent=2, ensure_ascii=False))
|
|
885
|
+
if not result["valid"]:
|
|
886
|
+
_err("Merged refactor list validation failed")
|
|
887
|
+
for error in result["errors"]:
|
|
888
|
+
_err(" " + error)
|
|
889
|
+
return 1
|
|
890
|
+
|
|
891
|
+
try:
|
|
892
|
+
_write_json_atomic(args.output, merged)
|
|
893
|
+
except Exception as exc:
|
|
894
|
+
_err("Failed to write merged refactor list: {}".format(exc))
|
|
895
|
+
return 2
|
|
896
|
+
_info("Appended {} refactor(s) to {}".format(len(prepared), args.output))
|
|
897
|
+
return 0
|
|
898
|
+
|
|
899
|
+
|
|
731
900
|
def cmd_generate(args):
|
|
732
901
|
"""Handle the 'generate' command.
|
|
733
902
|
|
|
@@ -815,6 +984,9 @@ def main():
|
|
|
815
984
|
" %(prog)s validate --input .prizmkit/plans/refactor-list.json\n"
|
|
816
985
|
" %(prog)s validate --input .prizmkit/plans/refactor-list.json --output validated.json\n"
|
|
817
986
|
" %(prog)s template --output .prizmkit/plans/refactor-list.json\n"
|
|
987
|
+
" %(prog)s context --input .prizmkit/plans/refactor-list.json\n"
|
|
988
|
+
" %(prog)s show --input .prizmkit/plans/refactor-list.json --id R-001\n"
|
|
989
|
+
" %(prog)s append --input additions.json --output .prizmkit/plans/refactor-list.json\n"
|
|
818
990
|
" %(prog)s generate --input draft.json --output .prizmkit/plans/refactor-list.json\n"
|
|
819
991
|
" %(prog)s summary --input .prizmkit/plans/refactor-list.json\n"
|
|
820
992
|
" %(prog)s summary --input .prizmkit/plans/refactor-list.json --format json\n"
|
|
@@ -844,6 +1016,44 @@ def main():
|
|
|
844
1016
|
"--output", required=True, help="Path to write template file"
|
|
845
1017
|
)
|
|
846
1018
|
|
|
1019
|
+
# -- context --
|
|
1020
|
+
p_context = subparsers.add_parser(
|
|
1021
|
+
"context",
|
|
1022
|
+
help="Print root context and the five most recent refactor id/description pairs",
|
|
1023
|
+
)
|
|
1024
|
+
p_context.add_argument(
|
|
1025
|
+
"--input", required=True, help="Path to existing .prizmkit/plans/refactor-list.json"
|
|
1026
|
+
)
|
|
1027
|
+
|
|
1028
|
+
# -- show --
|
|
1029
|
+
p_show = subparsers.add_parser(
|
|
1030
|
+
"show",
|
|
1031
|
+
help="Print one explicitly requested top-level refactor",
|
|
1032
|
+
)
|
|
1033
|
+
p_show.add_argument(
|
|
1034
|
+
"--input", required=True, help="Path to existing .prizmkit/plans/refactor-list.json"
|
|
1035
|
+
)
|
|
1036
|
+
p_show.add_argument(
|
|
1037
|
+
"--id", required=True, help="Exact top-level refactor ID"
|
|
1038
|
+
)
|
|
1039
|
+
|
|
1040
|
+
# -- append --
|
|
1041
|
+
p_append = subparsers.add_parser(
|
|
1042
|
+
"append",
|
|
1043
|
+
help="Append a refactors-only draft to an existing validated refactor list",
|
|
1044
|
+
)
|
|
1045
|
+
p_append.add_argument(
|
|
1046
|
+
"--input", required=True, help="Path to additions-only draft JSON"
|
|
1047
|
+
)
|
|
1048
|
+
p_append.add_argument(
|
|
1049
|
+
"--output", required=True, help="Path to existing final refactor-list.json"
|
|
1050
|
+
)
|
|
1051
|
+
p_append.add_argument(
|
|
1052
|
+
"--replace-tail",
|
|
1053
|
+
action="store_true",
|
|
1054
|
+
help="Replace the exact existing suffix with the same IDs after local review",
|
|
1055
|
+
)
|
|
1056
|
+
|
|
847
1057
|
# -- generate --
|
|
848
1058
|
p_generate = subparsers.add_parser(
|
|
849
1059
|
"generate",
|
|
@@ -880,6 +1090,9 @@ def main():
|
|
|
880
1090
|
dispatch = {
|
|
881
1091
|
"validate": cmd_validate,
|
|
882
1092
|
"template": cmd_template,
|
|
1093
|
+
"context": cmd_context,
|
|
1094
|
+
"show": cmd_show,
|
|
1095
|
+
"append": cmd_append,
|
|
883
1096
|
"generate": cmd_generate,
|
|
884
1097
|
"summary": cmd_summary,
|
|
885
1098
|
}
|