prizmkit 1.1.161 → 1.1.164

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 (62) hide show
  1. package/bin/create-prizmkit.js +4 -4
  2. package/bundled/VERSION.json +3 -3
  3. package/bundled/adapters/cursor/assets/prizmkit-hook.cjs +65 -0
  4. package/bundled/adapters/cursor/hooks-adapter.js +139 -0
  5. package/bundled/adapters/cursor/paths.js +11 -0
  6. package/bundled/adapters/cursor/rules-adapter.js +49 -0
  7. package/bundled/adapters/cursor/skill-adapter.js +27 -0
  8. package/bundled/dev-pipeline/README.md +21 -6
  9. package/bundled/dev-pipeline/prizmkit_runtime/checkpoint_state.py +3 -25
  10. package/bundled/dev-pipeline/prizmkit_runtime/config.py +71 -14
  11. package/bundled/dev-pipeline/prizmkit_runtime/gitops.py +28 -4
  12. package/bundled/dev-pipeline/prizmkit_runtime/heartbeat.py +5 -2
  13. package/bundled/dev-pipeline/prizmkit_runtime/platform_detection.py +21 -3
  14. package/bundled/dev-pipeline/prizmkit_runtime/runners.py +82 -9
  15. package/bundled/dev-pipeline/prizmkit_runtime/runtime_commit.py +123 -0
  16. package/bundled/dev-pipeline/prizmkit_runtime/sessions.py +123 -28
  17. package/bundled/dev-pipeline/prizmkit_runtime/status.py +2 -0
  18. package/bundled/dev-pipeline/prizmkit_runtime/test_result.py +1 -42
  19. package/bundled/dev-pipeline/scripts/init-bugfix-pipeline.py +43 -6
  20. package/bundled/dev-pipeline/scripts/init-pipeline.py +46 -8
  21. package/bundled/dev-pipeline/scripts/init-refactor-pipeline.py +41 -6
  22. package/bundled/dev-pipeline/scripts/parse-stream-progress.py +143 -27
  23. package/bundled/dev-pipeline/scripts/update-bug-status.py +8 -4
  24. package/bundled/dev-pipeline/scripts/update-feature-status.py +12 -8
  25. package/bundled/dev-pipeline/scripts/update-refactor-status.py +8 -4
  26. package/bundled/dev-pipeline/scripts/utils.py +3 -12
  27. package/bundled/dev-pipeline/templates/bug-fix-list-schema.json +4 -2
  28. package/bundled/dev-pipeline/templates/feature-list-schema.json +4 -2
  29. package/bundled/dev-pipeline/templates/refactor-list-schema.json +4 -2
  30. package/bundled/dev-pipeline/tests/live_ai_cli_log_smoke.py +2 -1
  31. package/bundled/dev-pipeline/tests/test_checkpoint_state.py +5 -23
  32. package/bundled/dev-pipeline/tests/test_generate_bootstrap_prompt.py +2 -2
  33. package/bundled/dev-pipeline/tests/test_python_runner_parity.py +452 -6
  34. package/bundled/dev-pipeline/tests/test_runtime_commit.py +138 -1
  35. package/bundled/dev-pipeline/tests/test_unified_cli.py +406 -30
  36. package/bundled/dev-pipeline/tests/test_utils.py +23 -0
  37. package/bundled/rules/USAGE.md +3 -0
  38. package/bundled/skills/_metadata.json +1 -1
  39. package/bundled/skills/bug-planner/SKILL.md +0 -1
  40. package/bundled/skills/bug-planner/references/verification.md +0 -2
  41. package/bundled/skills/bug-planner/scripts/validate-bug-list.py +37 -7
  42. package/bundled/skills/feature-planner/SKILL.md +5 -8
  43. package/bundled/skills/feature-planner/scripts/validate-and-generate.py +43 -19
  44. package/bundled/skills/prizmkit-init/SKILL.md +1 -1
  45. package/bundled/skills/prizmkit-init/references/config-schema.md +2 -2
  46. package/bundled/skills/prizmkit-plan/references/review-plan-spec-loop.md +2 -3
  47. package/bundled/skills/prizmkit-prizm-docs/assets/prizm-docs-format.md +1 -1
  48. package/bundled/skills/prizmkit-prizm-docs/references/op-init.md +1 -1
  49. package/bundled/skills/refactor-planner/SKILL.md +1 -3
  50. package/bundled/skills/refactor-planner/scripts/validate-and-generate-refactor.py +38 -9
  51. package/package.json +4 -2
  52. package/src/ai-cli-launch.js +9 -2
  53. package/src/clean.js +42 -6
  54. package/src/config.js +51 -10
  55. package/src/detect-platform.js +30 -8
  56. package/src/external-skills.js +33 -99
  57. package/src/index.js +5 -0
  58. package/src/manifest.js +30 -4
  59. package/src/platforms.js +11 -4
  60. package/src/prompts.js +12 -4
  61. package/src/scaffold.js +75 -4
  62. package/src/upgrade.js +15 -14
@@ -121,7 +121,7 @@ HelpRunner = Callable[[Sequence[str]], str]
121
121
 
122
122
  def _normalize_platform(platform: str | None) -> str:
123
123
  normalized = (platform or "").strip().lower()
124
- return normalized if normalized in {"claude", "codex", "codebuddy", "pi", "custom"} else "codebuddy"
124
+ return normalized if normalized in {"claude", "codex", "codebuddy", "pi", "cursor", "custom"} else "codebuddy"
125
125
 
126
126
 
127
127
  def _prompt_text(path: Path) -> str:
@@ -129,13 +129,35 @@ def _prompt_text(path: Path) -> str:
129
129
 
130
130
 
131
131
  def _default_help_runner(command: Sequence[str]) -> str:
132
- completed = subprocess.run(
133
- list(command),
134
- stdout=subprocess.PIPE,
135
- stderr=subprocess.STDOUT,
136
- text=True,
137
- check=False,
138
- )
132
+ try:
133
+ completed = subprocess.run(
134
+ list(command),
135
+ stdout=subprocess.PIPE,
136
+ stderr=subprocess.STDOUT,
137
+ text=True,
138
+ check=False,
139
+ timeout=10,
140
+ )
141
+ except (OSError, subprocess.SubprocessError):
142
+ return ""
143
+ return completed.stdout or ""
144
+
145
+
146
+ def _default_cursor_probe_runner(command: Sequence[str]) -> str:
147
+ """Run a Cursor identity/capability probe and require a successful exit."""
148
+ try:
149
+ completed = subprocess.run(
150
+ list(command),
151
+ stdout=subprocess.PIPE,
152
+ stderr=subprocess.STDOUT,
153
+ text=True,
154
+ check=False,
155
+ timeout=10,
156
+ )
157
+ except (OSError, subprocess.SubprocessError):
158
+ return ""
159
+ if completed.returncode != 0:
160
+ return ""
139
161
  return completed.stdout or ""
140
162
 
141
163
 
@@ -146,10 +168,37 @@ def detect_stream_json_support(
146
168
  ) -> StreamJsonSupport:
147
169
  """Detect stream-json support using shell-compatible provider rules."""
148
170
  normalized = _normalize_platform(platform)
149
- command_name = Path(str(cli_command).split()[0].strip("'\"")).name.lower()
171
+ raw_command = str(cli_command).strip()
172
+ unquoted = (
173
+ raw_command[1:-1]
174
+ if len(raw_command) >= 2 and raw_command[0] == raw_command[-1] and raw_command[0] in "'\""
175
+ else raw_command
176
+ )
177
+ command_token = (
178
+ unquoted
179
+ if len(unquoted) >= 3 and unquoted[1:3] in {":\\", ":/"} and unquoted.lower().endswith((".exe", ".cmd", ".bat"))
180
+ else raw_command.split()[0].strip("'\"")
181
+ )
182
+ command_name = command_token.replace("\\", "/").rsplit("/", 1)[-1].lower()
183
+ for suffix in (".exe", ".cmd", ".bat"):
184
+ if command_name.endswith(suffix):
185
+ command_name = command_name[: -len(suffix)]
186
+ break
150
187
  runner = help_runner or _default_help_runner
151
188
  if normalized == "codebuddy" or command_name == "cbc":
152
189
  return StreamJsonSupport(True, "stream-json", "codebuddy-default")
190
+ if normalized == "cursor" or command_name == "agent":
191
+ cursor_runner = runner if help_runner is not None else _default_cursor_probe_runner
192
+ version_output = cursor_runner((cli_command, "--version"))
193
+ help_output = cursor_runner((cli_command, "--help"))
194
+ required = ("--print", "--force", "--trust", "--output-format")
195
+ missing = tuple(flag for flag in required if flag not in help_output)
196
+ if "cursor" not in f"{version_output}\n{help_output}".lower():
197
+ missing = (*missing, "Cursor identity not found")
198
+ if not missing:
199
+ return StreamJsonSupport(True, "cursor-stream-json", "cursor-version-help")
200
+ notes = tuple(f"{flag} not found" if flag.startswith("--") else flag for flag in missing)
201
+ return StreamJsonSupport(False, "", "cursor-version-help", notes)
153
202
  if normalized == "pi" or command_name == "pi":
154
203
  help_output = runner((cli_command, "--help"))
155
204
  required = ("--mode", "--approve", "--no-session", "--tools", "--model", "--thinking")
@@ -200,6 +249,20 @@ def build_ai_session_command(config: AISessionConfig) -> AISessionCommand:
200
249
  argv.extend(config.extra_args)
201
250
  return AISessionCommand(tuple(argv), prompt, "pi", "stdin", prompt)
202
251
 
252
+ if platform == "cursor":
253
+ argv = [
254
+ config.cli_command,
255
+ "--print",
256
+ "--force",
257
+ "--trust",
258
+ ]
259
+ if config.use_stream_json:
260
+ argv.extend(["--output-format", "stream-json"])
261
+ if config.model:
262
+ argv.extend(["--model", config.model])
263
+ argv.extend(config.extra_args)
264
+ return AISessionCommand(tuple(argv), prompt, "cursor", "stdin", prompt)
265
+
203
266
  if platform == "claude":
204
267
  argv = [
205
268
  config.cli_command,
@@ -331,12 +394,17 @@ def _permission_denial_text(event: object) -> str:
331
394
  return text[:500] if any(marker in lower for marker in markers) else ""
332
395
 
333
396
 
334
- def parse_stream_progress_lines(lines: Sequence[str]) -> ProgressSummary:
397
+ def parse_stream_progress_lines(
398
+ lines: Sequence[str],
399
+ provider_hint: str | None = None,
400
+ ) -> ProgressSummary:
335
401
  """Parse raw JSONL lines into additive provider-neutral progress metadata."""
336
402
  event_type_counts: Counter[str] = Counter()
337
403
  permission_denials: list[str] = []
338
404
  claude_session_id = ""
339
405
  cb_session_id = ""
406
+ cursor_session_id = ""
407
+ cursor_stream = _normalize_platform(provider_hint) == "cursor"
340
408
  result_subtype = ""
341
409
  stop_reason = ""
342
410
  has_usage = False
@@ -362,10 +430,20 @@ def parse_stream_progress_lines(lines: Sequence[str]) -> ProgressSummary:
362
430
  event_type_counts[event_type] += 1
363
431
  if isinstance(event.get("sessionId"), str) and not cb_session_id:
364
432
  cb_session_id = event["sessionId"].strip()
433
+ if event_type == "tool_call":
434
+ cursor_stream = True
435
+ if not cursor_session_id and claude_session_id:
436
+ cursor_session_id = claude_session_id
437
+ claude_session_id = ""
438
+ if cursor_stream and isinstance(event.get("session_id"), str) and not cursor_session_id:
439
+ cursor_session_id = event["session_id"].strip()
365
440
  if event_type == "system" and event.get("subtype") == "init":
366
441
  session_id = event.get("session_id")
367
442
  if isinstance(session_id, str):
368
- claude_session_id = session_id.strip()
443
+ if cursor_stream:
444
+ cursor_session_id = cursor_session_id or session_id.strip()
445
+ else:
446
+ claude_session_id = session_id.strip()
369
447
  if event_type == "result":
370
448
  result_subtype = str(event.get("subtype") or event.get("result_subtype") or "")
371
449
  stop_reason = str(event.get("stop_reason") or "")
@@ -396,6 +474,7 @@ def parse_stream_progress_lines(lines: Sequence[str]) -> ProgressSummary:
396
474
  event_type_counts=dict(event_type_counts),
397
475
  claude_session_id=claude_session_id,
398
476
  cb_session_id=cb_session_id,
477
+ cursor_session_id=cursor_session_id,
399
478
  result_subtype=result_subtype,
400
479
  stop_reason=stop_reason,
401
480
  has_usage=has_usage,
@@ -410,18 +489,20 @@ def parse_stream_progress_lines(lines: Sequence[str]) -> ProgressSummary:
410
489
  class _FallbackProgressTracker:
411
490
  """Bounded additive progress fallback when the shared parser cannot load."""
412
491
 
413
- def __init__(self):
492
+ def __init__(self, provider_hint: str | None = None):
414
493
  self._event_type_counts: Counter[str] = Counter()
415
494
  self._summary = ProgressSummary()
495
+ self._provider_hint = provider_hint
416
496
 
417
497
  def process_event(self, event: object) -> None:
418
498
  line = json.dumps(event, ensure_ascii=False, default=str) if isinstance(event, dict) else str(event)
419
- current = parse_stream_progress_lines((line,))
499
+ current = parse_stream_progress_lines((line,), self._provider_hint)
420
500
  self._event_type_counts.update(current.event_type_counts)
421
501
  self._summary = ProgressSummary(
422
502
  event_type_counts=dict(self._event_type_counts),
423
503
  claude_session_id=current.claude_session_id or self._summary.claude_session_id,
424
504
  cb_session_id=current.cb_session_id or self._summary.cb_session_id,
505
+ cursor_session_id=current.cursor_session_id or self._summary.cursor_session_id,
425
506
  result_subtype=current.result_subtype or self._summary.result_subtype,
426
507
  stop_reason=current.stop_reason or self._summary.stop_reason,
427
508
  has_usage=current.has_usage or self._summary.has_usage,
@@ -483,12 +564,7 @@ def _progress_refresh_key(data: Mapping[str, object]) -> tuple[object, ...]:
483
564
  str(data.get("current_tool") or ""),
484
565
  str(data.get("current_phase") or ""),
485
566
  int(data.get("total_tool_calls") or 0),
486
- int(data.get("active_subagent_count") or 0),
487
- int(data.get("subagent_spawn_count") or 0),
488
- str(data.get("subagent_stats_source") or ""),
489
- str(data.get("subagent_provider") or ""),
490
- json.dumps(data.get("subagent_states") or [], sort_keys=True, default=str),
491
- json.dumps(data.get("subagent_observed_ids") or [], sort_keys=True, default=str),
567
+ json.dumps(data.get("subagent_statistics") or {}, sort_keys=True, default=str),
492
568
  str(data.get("child_activity_signature") or ""),
493
569
  int(data.get("child_total_bytes") or 0),
494
570
  str(data.get("fatal_error_code") or ""),
@@ -582,7 +658,12 @@ def _emit_ai_interruption_received(
582
658
  tool = str(progress.get("current_tool") or "unavailable")
583
659
  messages = _diagnostic_int(progress.get("message_count"))
584
660
  tool_calls = _diagnostic_int(progress.get("total_tool_calls"))
585
- active_subagents = _diagnostic_int(progress.get("active_subagent_count"))
661
+ subagent_statistics = progress.get("subagent_statistics")
662
+ active_subagents = _diagnostic_int(
663
+ subagent_statistics.get("active")
664
+ if isinstance(subagent_statistics, Mapping)
665
+ else 0
666
+ )
586
667
  elapsed = _format_elapsed(time.time() - started_epoch)
587
668
  heartbeat_details = heartbeat_state.details if heartbeat_state is not None else "unavailable"
588
669
  heartbeat_stale = heartbeat_state.stale if heartbeat_state is not None else "unavailable"
@@ -730,13 +811,19 @@ def _compact_progress_line(
730
811
  child_bytes = int(data.get("child_total_bytes") or 0)
731
812
  child_files = data.get("child_session_files")
732
813
  child_file_count = len(child_files) if isinstance(child_files, list) else 0
733
- spawned = int(data.get("subagent_spawn_count") or 0)
734
- active = int(data.get("active_subagent_count") or 0)
735
- subagent_states = data.get("subagent_states")
736
- if spawned or active or subagent_states:
814
+ subagent_statistics = data.get("subagent_statistics")
815
+ if isinstance(subagent_statistics, Mapping):
816
+ spawned = int(subagent_statistics.get("spawned") or 0)
817
+ active = int(subagent_statistics.get("active") or 0)
818
+ state_counts = subagent_statistics.get("states")
819
+ else:
820
+ spawned = 0
821
+ active = 0
822
+ state_counts = []
823
+ if spawned or active or state_counts:
737
824
  state_bits = []
738
- if isinstance(subagent_states, list):
739
- for item in subagent_states:
825
+ if isinstance(state_counts, list):
826
+ for item in state_counts:
740
827
  if not isinstance(item, Mapping):
741
828
  continue
742
829
  status = str(item.get("status") or "unknown")
@@ -832,6 +919,7 @@ def _reader_thread(
832
919
  result_queue: "queue.Queue[dict[str, object]]",
833
920
  progress_path: Path | None = None,
834
921
  live_output: bool = False,
922
+ provider_hint: str | None = None,
835
923
  ) -> None:
836
924
  tracker_lock = threading.Lock()
837
925
  progress_refresh_stop = threading.Event()
@@ -839,9 +927,14 @@ def _reader_thread(
839
927
  refresh_progress: Callable[[bool], None] | None = None
840
928
  tracker_class, normalizer_class = _load_stream_parser_classes()
841
929
  try:
842
- tracker = tracker_class(session_log) if tracker_class is not None else _FallbackProgressTracker()
930
+ tracker = tracker_class(session_log) if tracker_class is not None else _FallbackProgressTracker(provider_hint)
931
+ if tracker_class is not None and provider_hint is not None:
932
+ try:
933
+ tracker.provider_hint = str(provider_hint).strip().lower()
934
+ except (AttributeError, TypeError):
935
+ pass
843
936
  except Exception:
844
- tracker = _FallbackProgressTracker()
937
+ tracker = _FallbackProgressTracker(provider_hint)
845
938
  try:
846
939
  normalizer = normalizer_class() if normalizer_class is not None else None
847
940
  except Exception:
@@ -960,6 +1053,7 @@ def _summary_from_progress_dict(data: Mapping[str, object], fallback: ProgressSu
960
1053
  event_type_counts=event_counts if isinstance(event_counts, Mapping) else fallback.event_type_counts,
961
1054
  claude_session_id=str(data.get("claude_session_id") or fallback.claude_session_id),
962
1055
  cb_session_id=str(data.get("cb_session_id") or fallback.cb_session_id),
1056
+ cursor_session_id=str(data.get("cursor_session_id") or fallback.cursor_session_id),
963
1057
  result_subtype=str(data.get("result_subtype") or fallback.result_subtype),
964
1058
  stop_reason=str(data.get("stop_reason") or fallback.stop_reason),
965
1059
  has_usage=bool(data.get("has_usage") or fallback.has_usage),
@@ -1011,6 +1105,7 @@ class AISessionLauncher:
1011
1105
  reader_result_queue,
1012
1106
  self.config.progress_path,
1013
1107
  self.config.live_output and self.config.verbose and not self.config.suppress_stream_output,
1108
+ self.config.platform,
1014
1109
  ),
1015
1110
  daemon=True,
1016
1111
  )
@@ -37,6 +37,7 @@ class ProgressSummary:
37
37
  event_type_counts: Mapping[str, int] = field(default_factory=dict)
38
38
  claude_session_id: str = ""
39
39
  cb_session_id: str = ""
40
+ cursor_session_id: str = ""
40
41
  result_subtype: str = ""
41
42
  stop_reason: str = ""
42
43
  has_usage: bool = False
@@ -52,6 +53,7 @@ class ProgressSummary:
52
53
  "event_type_counts": dict(self.event_type_counts),
53
54
  "claude_session_id": self.claude_session_id,
54
55
  "cb_session_id": self.cb_session_id,
56
+ "cursor_session_id": self.cursor_session_id,
55
57
  "result_subtype": self.result_subtype,
56
58
  "stop_reason": self.stop_reason,
57
59
  "has_usage": self.has_usage,
@@ -31,7 +31,6 @@ _INDEPENDENT_REVIEW_KEYS = {
31
31
  "downgrade_reason",
32
32
  "final_state_rechecked",
33
33
  }
34
- _LEGACY_RESULT_KEYS = _RESULT_KEYS | {"review_required", "review_scope"}
35
34
 
36
35
 
37
36
  def load_test_result(path: str | Path) -> dict[str, Any] | None:
@@ -43,27 +42,6 @@ def load_test_result(path: str | Path) -> dict[str, Any] | None:
43
42
  return _validate_test_result_value(value)
44
43
 
45
44
 
46
- def load_legacy_test_result(path: str | Path) -> dict[str, Any] | None:
47
- """Read a historical pass projection without permitting new legacy output."""
48
- try:
49
- value = json.loads(Path(path).read_text(encoding="utf-8"))
50
- except (OSError, ValueError, TypeError):
51
- return None
52
- if not isinstance(value, dict):
53
- return None
54
- if set(value) == _RESULT_KEYS:
55
- return _validate_test_result_value(value)
56
- if set(value) != _LEGACY_RESULT_KEYS:
57
- return None
58
- if value.get("review_required") is not False or value.get("review_scope") is not None:
59
- return None
60
- normalized = {
61
- key: item for key, item in value.items()
62
- if key not in {"review_required", "review_scope"}
63
- }
64
- return _validate_test_result_value(normalized)
65
-
66
-
67
45
  def _validate_test_result_value(value: object) -> dict[str, Any] | None:
68
46
  if not isinstance(value, dict):
69
47
  return None
@@ -136,22 +114,6 @@ def valid_test_artifact_pair(
136
114
  report_path,
137
115
  result_path,
138
116
  required_result=required_result,
139
- legacy=False,
140
- )
141
-
142
-
143
- def valid_legacy_test_artifact_pair(
144
- report_path: str | Path,
145
- result_path: str | Path,
146
- *,
147
- required_result: str | None = None,
148
- ) -> bool:
149
- """Validate a historical completed pair for read-only recovery."""
150
- return _valid_test_artifact_pair(
151
- report_path,
152
- result_path,
153
- required_result=required_result,
154
- legacy=True,
155
117
  )
156
118
 
157
119
 
@@ -160,7 +122,6 @@ def _valid_test_artifact_pair(
160
122
  result_path: str | Path,
161
123
  *,
162
124
  required_result: str | None,
163
- legacy: bool,
164
125
  ) -> bool:
165
126
  report = Path(report_path)
166
127
  result = Path(result_path)
@@ -168,9 +129,7 @@ def _valid_test_artifact_pair(
168
129
  return False
169
130
  if report.resolve().parent != result.resolve().parent:
170
131
  return False
171
- projection = (
172
- load_legacy_test_result(result) if legacy else load_test_result(result)
173
- )
132
+ projection = load_test_result(result)
174
133
  if projection is None:
175
134
  return False
176
135
  if required_result is not None and projection.get("result") != required_result:
@@ -20,6 +20,15 @@ from utils import stable_topological_order
20
20
 
21
21
  EXPECTED_SCHEMA = "dev-pipeline-bug-fix-list-v1"
22
22
  BUG_ID_PATTERN = re.compile(r"^B-\d{3}$")
23
+ ALLOWED_LIST_FIELDS = {
24
+ "$schema", "project_name", "project_description", "created_at",
25
+ "created_by", "bugs", "global_context",
26
+ }
27
+ ALLOWED_GLOBAL_CONTEXT_FIELDS = {
28
+ "tech_stack", "language", "runtime", "frontend_framework",
29
+ "frontend_styling", "backend_framework", "database", "orm",
30
+ "testing_strategy", "bundler", "project_type", "ci_pipeline",
31
+ }
23
32
 
24
33
  REQUIRED_BUG_FIELDS = [
25
34
  "id",
@@ -31,6 +40,15 @@ REQUIRED_BUG_FIELDS = [
31
40
  "acceptance_criteria",
32
41
  "status",
33
42
  ]
43
+ ALLOWED_BUG_FIELDS = set(REQUIRED_BUG_FIELDS) | {
44
+ "priority",
45
+ "environment",
46
+ "affected_modules",
47
+ "dependencies",
48
+ "user_context",
49
+ "browser_interaction",
50
+ "model",
51
+ }
34
52
 
35
53
  VALID_SEVERITIES = ["critical", "high", "medium", "low"]
36
54
  VALID_VERIFICATION_TYPES = ["automated", "manual", "hybrid"]
@@ -80,6 +98,12 @@ def validate_schema(data):
80
98
  """Validate the top-level schema and structure of the bug fix list."""
81
99
  errors = []
82
100
 
101
+ unknown_root = set(data) - ALLOWED_LIST_FIELDS
102
+ if unknown_root:
103
+ errors.append("Bug fix list has unknown fields: {}".format(
104
+ ", ".join(sorted(unknown_root))
105
+ ))
106
+
83
107
  # Check $schema
84
108
  schema = data.get("$schema")
85
109
  if schema != EXPECTED_SCHEMA:
@@ -93,6 +117,17 @@ def validate_schema(data):
93
117
  elif not isinstance(data["project_name"], str) or not data["project_name"].strip():
94
118
  errors.append("project_name must be a non-empty string")
95
119
 
120
+ global_context = data.get("global_context")
121
+ if global_context is not None:
122
+ if not isinstance(global_context, dict):
123
+ errors.append("global_context must be an object")
124
+ else:
125
+ unknown_context = set(global_context) - ALLOWED_GLOBAL_CONTEXT_FIELDS
126
+ if unknown_context:
127
+ errors.append("global_context has unknown fields: {}".format(
128
+ ", ".join(sorted(unknown_context))
129
+ ))
130
+
96
131
  # Check bugs array
97
132
  if "bugs" not in data:
98
133
  errors.append("Missing required field: bugs")
@@ -114,12 +149,6 @@ def validate_bugs(bugs):
114
149
  errors.append("Bug at index {} is not an object".format(i))
115
150
  continue
116
151
 
117
- for retired_field in ("critic", "critic_count"):
118
- if retired_field in bug:
119
- errors.append(
120
- "Bug at index {} uses retired field '{}'".format(i, retired_field)
121
- )
122
-
123
152
  # Check required fields
124
153
  for field in REQUIRED_BUG_FIELDS:
125
154
  if field not in bug:
@@ -127,6 +156,14 @@ def validate_bugs(bugs):
127
156
  "Bug at index {} missing required field: {}".format(i, field)
128
157
  )
129
158
 
159
+ unknown = set(bug) - ALLOWED_BUG_FIELDS
160
+ if unknown:
161
+ errors.append(
162
+ "Bug at index {} has unknown fields: {}".format(
163
+ i, ", ".join(sorted(unknown))
164
+ )
165
+ )
166
+
130
167
  # Validate bug ID format
131
168
  bid = bug.get("id")
132
169
  if bid is not None:
@@ -23,6 +23,15 @@ EXPECTED_SCHEMA = "dev-pipeline-feature-list-v1"
23
23
  FEATURE_ID_PATTERN = re.compile(r"^F-\d{3}(-[A-Z])?$")
24
24
  TERMINAL_STATUSES = {"completed", "failed", "skipped", "split", "auto_skipped"}
25
25
  VALID_PRIORITIES = {"critical", "high", "medium", "low"}
26
+ ALLOWED_LIST_FIELDS = {
27
+ "$schema", "project_name", "project_description", "created_at",
28
+ "created_by", "features", "global_context",
29
+ }
30
+ ALLOWED_GLOBAL_CONTEXT_FIELDS = {
31
+ "tech_stack", "language", "runtime", "frontend_framework",
32
+ "frontend_styling", "backend_framework", "database", "orm",
33
+ "design_system", "testing_strategy", "bundler", "project_type",
34
+ }
26
35
 
27
36
  REQUIRED_FEATURE_FIELDS = [
28
37
  "id",
@@ -33,6 +42,16 @@ REQUIRED_FEATURE_FIELDS = [
33
42
  "acceptance_criteria",
34
43
  "status",
35
44
  ]
45
+ ALLOWED_FEATURE_FIELDS = set(REQUIRED_FEATURE_FIELDS) | {
46
+ "estimated_complexity",
47
+ "session_granularity",
48
+ "sub_features",
49
+ "model",
50
+ "completion_notes",
51
+ "user_context",
52
+ "browser_interaction",
53
+ "testing",
54
+ }
36
55
 
37
56
 
38
57
  def parse_args():
@@ -71,6 +90,12 @@ def validate_schema(data):
71
90
  """Validate the top-level schema and structure of the feature list."""
72
91
  errors = []
73
92
 
93
+ unknown_root = set(data) - ALLOWED_LIST_FIELDS
94
+ if unknown_root:
95
+ errors.append("Feature list has unknown fields: {}".format(
96
+ ", ".join(sorted(unknown_root))
97
+ ))
98
+
74
99
  # Check $schema
75
100
  schema = data.get("$schema")
76
101
  if schema != EXPECTED_SCHEMA:
@@ -78,13 +103,24 @@ def validate_schema(data):
78
103
  "Invalid $schema: expected '{}', got '{}'".format(EXPECTED_SCHEMA, schema)
79
104
  )
80
105
 
81
- # Check project_name (supports legacy app_name for backward compatibility)
82
- project_name = data.get("project_name", data.get("app_name"))
106
+ # Check project_name
107
+ project_name = data.get("project_name")
83
108
  if project_name is None:
84
109
  errors.append("Missing required field: project_name")
85
110
  elif not isinstance(project_name, str) or not project_name.strip():
86
111
  errors.append("project_name must be a non-empty string")
87
112
 
113
+ global_context = data.get("global_context")
114
+ if global_context is not None:
115
+ if not isinstance(global_context, dict):
116
+ errors.append("global_context must be an object")
117
+ else:
118
+ unknown_context = set(global_context) - ALLOWED_GLOBAL_CONTEXT_FIELDS
119
+ if unknown_context:
120
+ errors.append("global_context has unknown fields: {}".format(
121
+ ", ".join(sorted(unknown_context))
122
+ ))
123
+
88
124
  # Check features array
89
125
  if "features" not in data:
90
126
  errors.append("Missing required field: features")
@@ -106,12 +142,6 @@ def validate_features(features):
106
142
  errors.append("Feature at index {} is not an object".format(i))
107
143
  continue
108
144
 
109
- for retired_field in ("critic", "critic_count"):
110
- if retired_field in feature:
111
- errors.append(
112
- "Feature at index {} uses retired field '{}'".format(i, retired_field)
113
- )
114
-
115
145
  # Check required fields
116
146
  for field in REQUIRED_FEATURE_FIELDS:
117
147
  if field not in feature:
@@ -119,6 +149,14 @@ def validate_features(features):
119
149
  "Feature at index {} missing required field: {}".format(i, field)
120
150
  )
121
151
 
152
+ unknown = set(feature) - ALLOWED_FEATURE_FIELDS
153
+ if unknown:
154
+ errors.append(
155
+ "Feature at index {} has unknown fields: {}".format(
156
+ i, ", ".join(sorted(unknown))
157
+ )
158
+ )
159
+
122
160
  # Validate feature ID format
123
161
  fid = feature.get("id")
124
162
  if fid is not None:
@@ -21,6 +21,15 @@ from utils import load_json_file, stable_topological_order
21
21
 
22
22
  EXPECTED_SCHEMA = "dev-pipeline-refactor-list-v1"
23
23
  REFACTOR_ID_PATTERN = re.compile(r"^R-\d{3}$")
24
+ ALLOWED_LIST_FIELDS = {
25
+ "$schema", "project_name", "project_description", "created_at",
26
+ "created_by", "refactors", "global_context",
27
+ }
28
+ ALLOWED_GLOBAL_CONTEXT_FIELDS = {
29
+ "tech_stack", "language", "runtime", "frontend_framework",
30
+ "frontend_styling", "backend_framework", "database", "orm",
31
+ "testing_strategy", "bundler", "project_type", "ci_pipeline",
32
+ }
24
33
 
25
34
  REQUIRED_REFACTOR_FIELDS = [
26
35
  "id",
@@ -35,6 +44,13 @@ REQUIRED_REFACTOR_FIELDS = [
35
44
  "dependencies",
36
45
  "status",
37
46
  ]
47
+ ALLOWED_REFACTOR_FIELDS = set(REQUIRED_REFACTOR_FIELDS) | {
48
+ "estimated_lines",
49
+ "completion_notes",
50
+ "user_context",
51
+ "browser_interaction",
52
+ "model",
53
+ }
38
54
 
39
55
  VALID_TYPES = ["extract", "rename", "restructure", "simplify", "decouple", "migrate"]
40
56
  VALID_PRIORITIES = ["critical", "high", "medium", "low"]
@@ -75,6 +91,12 @@ def validate_schema(data):
75
91
  """Validate the top-level schema and structure of the refactor list."""
76
92
  errors = []
77
93
 
94
+ unknown_root = set(data) - ALLOWED_LIST_FIELDS
95
+ if unknown_root:
96
+ errors.append("Refactor list has unknown fields: {}".format(
97
+ ", ".join(sorted(unknown_root))
98
+ ))
99
+
78
100
  # Check $schema
79
101
  schema = data.get("$schema")
80
102
  if schema != EXPECTED_SCHEMA:
@@ -88,6 +110,17 @@ def validate_schema(data):
88
110
  elif not isinstance(data["project_name"], str) or not data["project_name"].strip():
89
111
  errors.append("project_name must be a non-empty string")
90
112
 
113
+ global_context = data.get("global_context")
114
+ if global_context is not None:
115
+ if not isinstance(global_context, dict):
116
+ errors.append("global_context must be an object")
117
+ else:
118
+ unknown_context = set(global_context) - ALLOWED_GLOBAL_CONTEXT_FIELDS
119
+ if unknown_context:
120
+ errors.append("global_context has unknown fields: {}".format(
121
+ ", ".join(sorted(unknown_context))
122
+ ))
123
+
91
124
  # Check refactors array
92
125
  if "refactors" not in data:
93
126
  errors.append("Missing required field: refactors")
@@ -109,12 +142,6 @@ def validate_refactors(refactors):
109
142
  errors.append("Refactor at index {} is not an object".format(i))
110
143
  continue
111
144
 
112
- for retired_field in ("critic", "critic_count"):
113
- if retired_field in refactor:
114
- errors.append(
115
- "Refactor at index {} uses retired field '{}'".format(i, retired_field)
116
- )
117
-
118
145
  # Check required fields
119
146
  for field in REQUIRED_REFACTOR_FIELDS:
120
147
  if field not in refactor:
@@ -122,6 +149,14 @@ def validate_refactors(refactors):
122
149
  "Refactor at index {} missing required field: {}".format(i, field)
123
150
  )
124
151
 
152
+ unknown = set(refactor) - ALLOWED_REFACTOR_FIELDS
153
+ if unknown:
154
+ errors.append(
155
+ "Refactor at index {} has unknown fields: {}".format(
156
+ i, ", ".join(sorted(unknown))
157
+ )
158
+ )
159
+
125
160
  # Validate refactor ID format
126
161
  rid = refactor.get("id")
127
162
  if rid is not None: