prizmkit 1.1.107 → 1.1.108

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 (78) hide show
  1. package/bin/create-prizmkit.js +4 -0
  2. package/bundled/VERSION.json +3 -3
  3. package/bundled/dev-pipeline/prizmkit_runtime/config.py +81 -14
  4. package/bundled/dev-pipeline/prizmkit_runtime/heartbeat.py +19 -8
  5. package/bundled/dev-pipeline/prizmkit_runtime/interoperability.py +0 -1
  6. package/bundled/dev-pipeline/prizmkit_runtime/launch_profiles.py +18 -0
  7. package/bundled/dev-pipeline/prizmkit_runtime/runner_bookkeeping.py +22 -2
  8. package/bundled/dev-pipeline/prizmkit_runtime/runner_recovery.py +3 -1
  9. package/bundled/dev-pipeline/prizmkit_runtime/runners.py +20 -1
  10. package/bundled/dev-pipeline/prizmkit_runtime/sessions.py +151 -30
  11. package/bundled/dev-pipeline/scripts/continuation.py +0 -1
  12. package/bundled/dev-pipeline/scripts/generate-bootstrap-prompt.py +6 -46
  13. package/bundled/dev-pipeline/scripts/generate-bugfix-prompt.py +7 -34
  14. package/bundled/dev-pipeline/scripts/generate-refactor-prompt.py +40 -33
  15. package/bundled/dev-pipeline/scripts/utils.py +123 -0
  16. package/bundled/dev-pipeline/templates/agent-prompts/critic-plan-challenge.md +4 -3
  17. package/bundled/dev-pipeline/templates/bootstrap-prompt.md +1 -1
  18. package/bundled/dev-pipeline/templates/bootstrap-tier1.md +8 -7
  19. package/bundled/dev-pipeline/templates/bootstrap-tier2.md +25 -36
  20. package/bundled/dev-pipeline/templates/bootstrap-tier3.md +16 -31
  21. package/bundled/dev-pipeline/templates/bugfix-bootstrap-prompt.md +4 -16
  22. package/bundled/dev-pipeline/templates/refactor-bootstrap-prompt.md +3 -15
  23. package/bundled/dev-pipeline/templates/sections/checkpoint-system.md +14 -48
  24. package/bundled/dev-pipeline/templates/sections/context-budget-rules.md +7 -13
  25. package/bundled/dev-pipeline/templates/sections/feature-context.md +0 -4
  26. package/bundled/dev-pipeline/templates/sections/phase-browser-verification-auto.md +0 -7
  27. package/bundled/dev-pipeline/templates/sections/phase-browser-verification-opencli.md +0 -7
  28. package/bundled/dev-pipeline/templates/sections/phase-browser-verification.md +0 -7
  29. package/bundled/dev-pipeline/templates/sections/phase-commit-full.md +0 -14
  30. package/bundled/dev-pipeline/templates/sections/phase-commit.md +0 -14
  31. package/bundled/dev-pipeline/templates/sections/phase-context-snapshot-agent-suffix.md +0 -7
  32. package/bundled/dev-pipeline/templates/sections/phase-context-snapshot-base.md +0 -2
  33. package/bundled/dev-pipeline/templates/sections/phase-context-snapshot-lite-suffix.md +0 -7
  34. package/bundled/dev-pipeline/templates/sections/phase-critic-plan-full.md +6 -8
  35. package/bundled/dev-pipeline/templates/sections/phase-critic-plan.md +3 -7
  36. package/bundled/dev-pipeline/templates/sections/phase-implement-agent.md +0 -7
  37. package/bundled/dev-pipeline/templates/sections/phase-implement-full.md +0 -7
  38. package/bundled/dev-pipeline/templates/sections/phase-implement-lite.md +0 -7
  39. package/bundled/dev-pipeline/templates/sections/phase-plan-agent.md +2 -9
  40. package/bundled/dev-pipeline/templates/sections/phase-plan-lite.md +1 -8
  41. package/bundled/dev-pipeline/templates/sections/phase-prizmkit-test.md +15 -16
  42. package/bundled/dev-pipeline/templates/sections/phase-review-agent.md +0 -7
  43. package/bundled/dev-pipeline/templates/sections/phase-review-full.md +0 -7
  44. package/bundled/dev-pipeline/templates/sections/phase-specify-plan-full.md +2 -9
  45. package/bundled/dev-pipeline/templates/sections/phase0-init.md +0 -7
  46. package/bundled/dev-pipeline/templates/sections/phase0-test-baseline.md +2 -15
  47. package/bundled/dev-pipeline/tests/conftest.py +0 -1
  48. package/bundled/dev-pipeline/tests/test_generate_bootstrap_prompt.py +350 -23
  49. package/bundled/dev-pipeline/tests/test_generate_bugfix_prompt.py +36 -17
  50. package/bundled/dev-pipeline/tests/test_generate_refactor_prompt.py +117 -14
  51. package/bundled/dev-pipeline/tests/test_python_runner_parity.py +79 -2
  52. package/bundled/dev-pipeline/tests/test_unified_cli.py +658 -13
  53. package/bundled/skills/_metadata.json +4 -4
  54. package/bundled/skills/app-planner/SKILL.md +1 -1
  55. package/bundled/skills/app-planner/references/architecture-decisions.md +1 -1
  56. package/bundled/skills/bug-fix-workflow/SKILL.md +174 -128
  57. package/bundled/skills/bug-planner/SKILL.md +101 -15
  58. package/bundled/skills/bug-planner/references/severity-rules.md +20 -8
  59. package/bundled/skills/feature-planner/SKILL.md +87 -8
  60. package/bundled/skills/feature-planner/assets/planning-guide.md +34 -10
  61. package/bundled/skills/feature-workflow/SKILL.md +100 -81
  62. package/bundled/skills/{prizm-kit → prizmkit}/SKILL.md +1 -1
  63. package/bundled/skills/prizmkit-code-review/SKILL.md +1 -1
  64. package/bundled/skills/refactor-planner/SKILL.md +88 -7
  65. package/bundled/skills/refactor-planner/references/fast-path.md +2 -1
  66. package/bundled/skills/refactor-planner/references/planning-phases.md +29 -11
  67. package/bundled/skills/refactor-workflow/SKILL.md +116 -57
  68. package/bundled/templates/project-memory-template.md +1 -1
  69. package/package.json +1 -1
  70. package/src/ai-cli-launch.js +194 -0
  71. package/src/config.js +26 -14
  72. package/src/index.js +11 -44
  73. package/src/platforms.js +10 -3
  74. package/src/prompts.js +60 -2
  75. package/src/scaffold.js +26 -14
  76. package/bundled/dev-pipeline/scripts/prizmkit-test-gate.py +0 -446
  77. package/bundled/dev-pipeline/templates/sections/log-size-awareness.md +0 -20
  78. package/bundled/dev-pipeline/tests/test_prizmkit_test_gate.py +0 -107
@@ -19,7 +19,7 @@ import os
19
19
  import re
20
20
  import sys
21
21
 
22
- from utils import enrich_global_context, load_json_file, read_platform_conventions, setup_logging
22
+ from utils import enrich_global_context, load_json_file, read_checkpoint_system_section, resolve_prompt_platform, setup_logging
23
23
  from continuation import add_continuation_args, append_continuation_handoff, is_continuation
24
24
 
25
25
 
@@ -134,6 +134,7 @@ def parse_args():
134
134
  parser.add_argument("--resume-phase", required=True, help='Phase to resume from, or "null" for fresh start')
135
135
  parser.add_argument("--state-dir", default=None, help="State directory (default: .prizmkit/state/refactor)")
136
136
  parser.add_argument("--output", required=True, help="Output path for the rendered prompt")
137
+ parser.add_argument("--project-root", default=None, help="AI-visible project root used for rendered prompt paths")
137
138
  parser.add_argument("--template", default=None, help="Custom template path. Defaults to {script_dir}/../templates/refactor-bootstrap-prompt.md")
138
139
  parser.add_argument("--mode", default=None, help="Pipeline execution mode override: lite, standard, full")
139
140
  parser.add_argument("--critic", default=None, help="Enable critic agent: true/false")
@@ -167,19 +168,6 @@ def _parse_positive_int_env(name, default):
167
168
  return parsed
168
169
 
169
170
 
170
- def load_log_size_section(script_dir):
171
- """Load passive checkpoint guidance for normal prompt generation."""
172
- section_path = os.path.join(
173
- script_dir, "..", "templates", "sections", "log-size-awareness.md",
174
- )
175
- if not os.path.isfile(section_path):
176
- return ""
177
-
178
- content, err = read_text_file(section_path)
179
- if err:
180
- return ""
181
- return content
182
-
183
171
  def find_refactor(refactors, refactor_id):
184
172
  """Find and return the refactor dict matching the given ID."""
185
173
  for refactor in refactors:
@@ -396,22 +384,39 @@ def resolve_project_root(script_dir):
396
384
  return os.path.abspath(pipeline_parent)
397
385
 
398
386
 
387
+ def _project_root_from_prizmkit_path(path):
388
+ """Infer project root from a path nested under .prizmkit/."""
389
+ if not path:
390
+ return ""
391
+ current = os.path.abspath(path)
392
+ if not os.path.isdir(current):
393
+ current = os.path.dirname(current)
394
+ while current and current != os.path.dirname(current):
395
+ if os.path.basename(current) == ".prizmkit":
396
+ return os.path.abspath(os.path.dirname(current))
397
+ current = os.path.dirname(current)
398
+ return ""
399
+
400
+
401
+ def _args_project_root(args, script_dir):
402
+ """Return explicit AI-visible project root, plan-path root, or script-layout default."""
403
+ explicit = getattr(args, "project_root", None)
404
+ if explicit:
405
+ return os.path.abspath(explicit)
406
+ plan_root = _project_root_from_prizmkit_path(getattr(args, "refactor_list", ""))
407
+ if plan_root:
408
+ return plan_root
409
+ return resolve_project_root(script_dir)
410
+
411
+
399
412
  def build_replacements(args, refactor, refactors, global_context, script_dir):
400
413
  """Build the full dict of placeholder -> replacement value."""
401
- project_root = resolve_project_root(script_dir)
414
+ project_root = _args_project_root(args, script_dir)
402
415
 
403
416
  # Platform-aware agent/team path resolution
404
- platform = os.environ.get("PRIZMKIT_PLATFORM", "")
417
+ platform = resolve_prompt_platform(project_root)
405
418
  home_dir = os.path.expanduser("~")
406
419
 
407
- if not platform:
408
- if os.path.isdir(os.path.join(project_root, ".codex", "agents")):
409
- platform = "codex"
410
- elif os.path.isdir(os.path.join(project_root, ".claude", "agents")):
411
- platform = "claude"
412
- else:
413
- platform = "codebuddy"
414
-
415
420
  if platform == "claude":
416
421
  agents_dir = os.path.join(project_root, ".claude", "agents")
417
422
  team_config_path = os.path.join(project_root, ".claude", "team-info.json")
@@ -428,10 +433,16 @@ def build_replacements(args, refactor, refactors, global_context, script_dir):
428
433
  dev_subagent = os.path.join(agents_dir, f"prizm-dev-team-dev{agent_ext}")
429
434
  reviewer_subagent = os.path.join(agents_dir, f"prizm-dev-team-reviewer{agent_ext}")
430
435
 
431
- # Session status path
436
+ # Session status is controlled by the main runner state dir, even when
437
+ # rendered project paths are AI-visible worktree paths.
438
+ state_dir = (
439
+ os.path.abspath(args.state_dir)
440
+ if args.state_dir
441
+ else os.path.join(project_root, ".prizmkit", "state", "refactor")
442
+ )
432
443
  session_status_path = os.path.join(
433
- project_root, ".prizmkit", "state", "refactor", args.refactor_id,
434
- "sessions", args.session_id, "session-status.json"
444
+ state_dir, args.refactor_id, "sessions", args.session_id,
445
+ "session-status.json",
435
446
  )
436
447
 
437
448
  # Scope
@@ -493,7 +504,6 @@ def build_replacements(args, refactor, refactors, global_context, script_dir):
493
504
  browser_verify_steps = " # (validate UI renders correctly and feature still works)"
494
505
 
495
506
  replacements = {
496
- "{{LOG_SIZE_AWARENESS}}": load_log_size_section(script_dir),
497
507
  "{{SESSION_LOG_PATH}}": os.path.join(
498
508
  ".prizmkit", "state", "refactor", args.refactor_id,
499
509
  "sessions", args.session_id, "logs", "session.log",
@@ -527,8 +537,8 @@ def build_replacements(args, refactor, refactors, global_context, script_dir):
527
537
  "{{CHECKPOINT_PATH}}": os.path.join(
528
538
  ".prizmkit", "refactor", args.refactor_id, "workflow-checkpoint.json",
529
539
  ),
540
+ "{{CHECKPOINT_SYSTEM}}": read_checkpoint_system_section(script_dir),
530
541
  "{{TIMESTAMP}}": "", # Placeholder — agent fills in timestamp
531
- "{{PLATFORM_CONVENTIONS}}": read_platform_conventions(project_root),
532
542
  "{{BROWSER_ENABLED}}": "true" if browser_enabled else "false",
533
543
  "{{BROWSER_TOOL}}": browser_tool,
534
544
  "{{BROWSER_VERIFY_STEPS}}": browser_verify_steps,
@@ -696,9 +706,6 @@ def main():
696
706
 
697
707
  # Build replacements
698
708
  replacements = build_replacements(args, refactor, refactors, global_context, script_dir)
699
- if is_continuation(args):
700
- replacements["{{LOG_SIZE_AWARENESS}}"] = ""
701
-
702
709
  # Render the template
703
710
  rendered = render_template(template_content, replacements, args.resume_phase, refactor)
704
711
 
@@ -708,7 +715,7 @@ def main():
708
715
  emit_failure(err)
709
716
 
710
717
  # Generate checkpoint file
711
- project_root = resolve_project_root(script_dir)
718
+ project_root = _args_project_root(args, script_dir)
712
719
  checkpoint_rel = os.path.join(
713
720
  ".prizmkit", "refactor", args.refactor_id, "workflow-checkpoint.json",
714
721
  )
@@ -79,6 +79,46 @@ def error_out(message, code=1):
79
79
  sys.exit(code)
80
80
 
81
81
 
82
+ def read_checkpoint_system_section(script_dir):
83
+ """Read the shared checkpoint prompt section for feature/bugfix/refactor prompts."""
84
+ path = os.path.join(
85
+ os.path.abspath(script_dir), "..", "templates", "sections", "checkpoint-system.md"
86
+ )
87
+ try:
88
+ with open(path, "r", encoding="utf-8") as f:
89
+ return f.read()
90
+ except IOError:
91
+ return """## Workflow Checkpoint System
92
+
93
+ A checkpoint file tracks your progress through this workflow:
94
+
95
+ **Path**: `{{CHECKPOINT_PATH}}`
96
+
97
+ ### Checkpoint Update Helper
98
+
99
+ Use this helper to update checkpoint status. Do not hand-edit `workflow-checkpoint.json` directly.
100
+
101
+ ```bash
102
+ python3 .prizmkit/dev-pipeline/scripts/update-checkpoint.py \\
103
+ --checkpoint-path {{CHECKPOINT_PATH}} \\
104
+ --step <step-id-or-skill-name> \\
105
+ --status <in_progress|completed|failed|skipped> \\
106
+ --note "<optional note>"
107
+ ```
108
+
109
+ - Use the step `skill` value such as `prizmkit-implement`, or the step id such as `S04`.
110
+ - Omit `--note` when there is no useful failure or handoff note.
111
+
112
+ ### Rules
113
+
114
+ 1. **Before each skill**: Read `workflow-checkpoint.json`, verify the previous step has `status: "completed"` or `status: "skipped"`. If it is still `"pending"` or `"in_progress"`, complete it first before moving on.
115
+ 2. **Starting a skill**: Use the checkpoint update helper to mark the current step as `status: "in_progress"`.
116
+ 3. **After each skill completes**: Use the checkpoint update helper to mark the current step as `status: "completed"`.
117
+ 4. **On failure**: Use the checkpoint update helper to mark the step as `status: "failed"`, write `failure-log.md` with the reason, and continue only when the workflow rules allow it.
118
+ 5. **On session exit**: The checkpoint file reflects your actual progress. Do NOT manually set future steps to `"completed"`.
119
+ """
120
+
121
+
82
122
  def pad_right(text, width):
83
123
  """Pad text with spaces to fill width, accounting for ANSI escape codes."""
84
124
  i = 0
@@ -520,6 +560,89 @@ def enrich_global_context(global_context, project_root):
520
560
  return global_context
521
561
 
522
562
 
563
+
564
+ def read_json_object(path):
565
+ """Read a JSON object, returning an empty dict when unavailable."""
566
+ try:
567
+ with open(path, "r", encoding="utf-8") as f:
568
+ data = json.load(f)
569
+ except (IOError, OSError, json.JSONDecodeError):
570
+ return {}
571
+ return data if isinstance(data, dict) else {}
572
+
573
+
574
+ def platform_from_command(command):
575
+ """Map an AI CLI command/config value to a PrizmKit platform name."""
576
+ cmd = str(command or "").strip().lower()
577
+ if not cmd:
578
+ return ""
579
+ base = os.path.basename(cmd.split()[0])
580
+ if base in ("claude", "claude-code") or "claude" in base:
581
+ return "claude"
582
+ if base in ("codex", "openai-codex") or "codex" in base:
583
+ return "codex"
584
+ if base in ("cbc", "codebuddy") or "codebuddy" in base:
585
+ return "codebuddy"
586
+ return ""
587
+
588
+
589
+ def valid_prompt_platform(value):
590
+ """Normalize a platform value for prompt path rendering."""
591
+ value = str(value or "").strip().lower()
592
+ if value in ("claude", "codex", "codebuddy"):
593
+ return value
594
+ return ""
595
+
596
+
597
+ def resolve_prompt_platform(project_root):
598
+ """Resolve the platform whose agent paths should appear in prompts.
599
+
600
+ Explicit ``PRIZMKIT_PLATFORM`` wins. Otherwise prefer active/configured AI
601
+ CLI because mixed installs contain several platform directories. Filesystem
602
+ markers are only a final fallback.
603
+ """
604
+ explicit = valid_prompt_platform(os.environ.get("PRIZMKIT_PLATFORM", ""))
605
+ if explicit:
606
+ return explicit
607
+
608
+ for env_name in ("AI_CLI", "CLAUDECODE", "CLAUDE_CODE"):
609
+ detected = platform_from_command(os.environ.get(env_name, ""))
610
+ if detected:
611
+ return detected
612
+
613
+ config = read_json_object(os.path.join(project_root, ".prizmkit", "config.json"))
614
+ for key in ("ai_cli", "aiCli"):
615
+ detected = platform_from_command(config.get(key, ""))
616
+ if detected:
617
+ return detected
618
+ detected = valid_prompt_platform(config.get("platform", ""))
619
+ if detected:
620
+ return detected
621
+
622
+ manifest = read_json_object(os.path.join(project_root, ".prizmkit", "manifest.json"))
623
+ options = manifest.get("options", {}) if isinstance(manifest.get("options"), dict) else {}
624
+ for value in (manifest.get("aiCli", ""), options.get("aiCli", "")):
625
+ detected = platform_from_command(value)
626
+ if detected:
627
+ return detected
628
+ detected = valid_prompt_platform(manifest.get("platform", ""))
629
+ if detected:
630
+ return detected
631
+
632
+ marker_order = (
633
+ ("claude", os.path.join(project_root, ".claude", "agents")),
634
+ ("codex", os.path.join(project_root, ".codex", "agents")),
635
+ ("codebuddy", os.path.join(project_root, ".codebuddy", "agents")),
636
+ )
637
+ for candidate, marker in marker_order:
638
+ if os.path.isdir(marker):
639
+ return candidate
640
+
641
+ raise RuntimeError(
642
+ "PrizmKit agents not found. None of .claude/agents/, .codex/agents/, or .codebuddy/agents/ exists. "
643
+ "Run `npx prizmkit install` first, set .prizmkit/config.json ai_cli/platform, or set PRIZMKIT_PLATFORM=claude|codex|codebuddy explicitly."
644
+ )
645
+
523
646
  def read_platform_conventions(project_root):
524
647
  """Resolve the platform-specific project conventions file.
525
648
 
@@ -1,7 +1,8 @@
1
1
  "Read {{CRITIC_SUBAGENT_PATH}}. For feature {{FEATURE_ID}} (slug: {{FEATURE_SLUG}}):
2
2
  **MODE: Plan Challenge**
3
3
  1. Read `.prizmkit/specs/{{FEATURE_SLUG}}/context-snapshot.md` FIRST — Section 3 has project context, Section 4 has file manifest.
4
- 2. Read `.prizmkit/prizm-docs/root.prizm` and relevant L1/L2 docs for affected modules.
5
- 3. Read existing source files in the modules this plan touches.
6
- 4. Challenge plan.md against the project's existing architecture, patterns, and style.
4
+ 2. Use context-snapshot.md as the shared source of truth. Do not create or enter AI tool-created `.claude/worktrees/...` subagent worktrees; use default/no worktree isolation and do not request worktree isolation.
5
+ 3. PrizmKit pipeline-managed linked git worktrees under `.prizmkit/state/worktrees/...` are a separate runner feature controlled by `USE_WORKTREE`; do not confuse them with AI tool-created `.claude/worktrees/...`.
6
+ 4. Read additional `.prizmkit/prizm-docs/` or source excerpts only when needed to verify a specific challenge.
7
+ 5. Challenge plan.md against the project's existing architecture, patterns, and style.
7
8
  Write `.prizmkit/specs/{{FEATURE_SLUG}}/challenge-report.md` with findings (or 'No significant challenges')."
@@ -44,7 +44,7 @@ Infer what needs to be done from the feature context above and follow the standa
44
44
  - Do NOT push to remote — the user will push manually.
45
45
  - Write all artifacts to `.prizmkit/specs/{{FEATURE_SLUG}}/`.
46
46
  - If a step fails after 3 attempts, write a status report and stop.
47
- - **Anti re-read**: once you read a file into context, do NOT read it again — use `grep -n`/`sed -n` for specific lines. 3 full Reads of same file report BLOCKED.
47
+ - **Never re-read unmodified files**: once you read a file into context, do NOT read it again unless it was modified by an Edit/Write after your last read — use `grep -n`/`sed -n` for specific lines. Before issuing a Read, ask: "Have I read this file before, and has it changed since?" If no — do NOT read it. Subagents (Critic, Reviewer) must rely on context-snapshot.md rather than re-reading files the orchestrator already read.
48
48
  - **Read offset safety**: if Read returns "shorter than offset"/"empty" — run `wc -l` then `sed -n`, do NOT retry same offset.
49
49
  - **Hard Round Cap**: after 6 total test-fix rounds, STOP trial-and-error. Switch to read-once-then-rewrite. Do NOT exceed 7 rounds.
50
50
  - **Layered test**: debug with single-file tests, only run full suite as gate when single-file is green.
@@ -46,21 +46,18 @@ You are running in **headless non-interactive mode** with a FINITE context windo
46
46
 
47
47
  1. **context-snapshot.md is your single source of truth** — After Phase 1 builds it, ALWAYS read context-snapshot.md instead of re-reading individual source files
48
48
  2. **Never re-read your own writes** — After you create/modify a file, do NOT read it back to verify. Trust your write was correct.
49
- 3. **Stay focused** — Do NOT explore code unrelated to this feature. No curiosity-driven reads.
49
+ 3. **Never re-read unmodified files** — Once you have read a file into context, do NOT read it again unless it was modified by an Edit/Write operation after your last read. Use `grep -n '<pattern>' <file>` or `sed -n '<start>,<end>p' <file>` for targeted line lookups instead of full-file Read. Before issuing a Read, ask yourself: "Have I read this file before, and has it changed since?" If the answer is "no, it hasn't changed" — do NOT read it. This applies to all files including those summarized in context-snapshot.md Section 4. Subagents (Critic, Reviewer) must receive context-snapshot.md and rely on it rather than independently re-reading the same files the orchestrator already read.
50
+ 4. **Stay focused** — Do NOT explore code unrelated to this feature. No curiosity-driven reads.
50
51
  4. **One task at a time** — In Phase 3 (implement), complete and test one task before starting the next.
51
52
  5. **Minimize tool output** — Never load full command output into context. First capture to a temp file (`cmd 2>&1 | tee /tmp/out.txt | tail -20`), then scan the head/tail to identify relevant fields, and use targeted filtering (`grep`, `sed`, `awk`) to extract only the information needed for the current task. Only read the filtered result — never the raw full output.
52
53
  6. **No intermediate commits** — Do NOT run `git add`/`git commit` during Phase 1-3. All changes are committed once at the end in Phase 4 via `/prizmkit-committer`.
53
54
  7. **Capture test output once** — When running test suites, always use `<test-command> 2>&1 | tee /tmp/test-out.txt | tail -20`. Then grep `/tmp/test-out.txt` for details. Never re-run the suite just to apply a different filter.
54
- 8. **Scaffold / generated file awareness** — Files created by scaffolding tools (`npm init`, `npx create-*`, etc.) are boilerplate. Tag them, record in context-snapshot.md, and NEVER re-read them. If you need to modify one, edit directly without reading first.
55
55
  9. **Package version verification (BLOCKING)** — Before writing ANY dependency version, verify it exists via registry query (`npm view <pkg> dist-tags.latest`, `pip index versions <pkg>`, etc.). NEVER guess version numbers.
56
56
  10. **Build artifact hygiene** — After build/compile, ensure output is in `.gitignore`. Never commit binaries/build output.
57
57
  11. **Read offset safety (BLOCKING)** — If Read returns "shorter than offset"/"File is empty"/"Wasted call" — do NOT retry same offset. Run `wc -l <file>` to get real line count, then `sed -n` for exact range. 2 consecutive offset errors → STOP Reading that file. Never guess offsets — `grep -n '<anchor>'` first.
58
58
 
59
59
  ---
60
60
 
61
- {{LOG_SIZE_AWARENESS}}
62
- ---
63
-
64
61
  ## PrizmKit Directory Convention
65
62
 
66
63
  ```
@@ -114,7 +111,7 @@ ls .prizmkit/specs/{{FEATURE_SLUG}}/ 2>/dev/null
114
111
 
115
112
  If plan.md missing, run `/prizmkit-plan` with `artifact_dir=.prizmkit/specs/{{FEATURE_SLUG}}/` to generate `plan.md`:
116
113
  - The plan.md should include: key components, data flow, files to create/modify, and a Tasks section with `[ ]` checkboxes (each task = one implementable unit). Keep under 80 lines.
117
- - Resolve any `[NEEDS CLARIFICATION]` markers using the feature description do NOT pause for interactive input.
114
+ - Resolve uncertain requirements from the feature description, existing code, and conservative existing-project patterns.
118
115
 
119
116
  **Database Design Gate** (if feature involves data persistence — new tables, schema changes, new entities):
120
117
  Before proceeding past CP-1:
@@ -178,7 +175,11 @@ Read `review-report.md` and check the Verdict:
178
175
 
179
176
  Run `/prizmkit-test scope=this-change artifact_dir=.prizmkit/specs/{{FEATURE_SLUG}}/` after review and before commit.
180
177
 
181
- Before invoking the skill, create `.prizmkit/specs/{{FEATURE_SLUG}}/.prizmkit-test-started` so stale reports are ignored.
178
+ Before invoking the skill, create a current-run marker so stale reports are ignored:
179
+ ```bash
180
+ mkdir -p .prizmkit/specs/{{FEATURE_SLUG}}
181
+ touch .prizmkit/specs/{{FEATURE_SLUG}}/.prizmkit-test-started
182
+ ```
182
183
 
183
184
  Gate requirements:
184
185
  - Generate or update tests only for this feature's changed files, changed public interfaces, and acceptance criteria.
@@ -52,21 +52,18 @@ You are running in **headless non-interactive mode** with a FINITE context windo
52
52
 
53
53
  1. **context-snapshot.md is your single source of truth** — After Phase 1 builds it, ALWAYS read context-snapshot.md instead of re-reading individual source files
54
54
  2. **Never re-read your own writes** — After you create/modify a file, do NOT read it back to verify. Trust your write was correct.
55
- 3. **Stay focused** — Do NOT explore code unrelated to this feature. No curiosity-driven reads.
55
+ 3. **Never re-read unmodified files** — Once you have read a file into context, do NOT read it again unless it was modified by an Edit/Write operation after your last read. Use `grep -n '<pattern>' <file>` or `sed -n '<start>,<end>p' <file>` for targeted line lookups instead of full-file Read. Before issuing a Read, ask yourself: "Have I read this file before, and has it changed since?" If the answer is "no, it hasn't changed" — do NOT read it. This applies to all files including those summarized in context-snapshot.md Section 4. Subagents (Critic, Reviewer) must receive context-snapshot.md and rely on it rather than independently re-reading the same files the orchestrator already read.
56
+ 4. **Stay focused** — Do NOT explore code unrelated to this feature. No curiosity-driven reads.
56
57
  4. **One task at a time** — In Phase 4 (implement), complete and test one task before starting the next.
57
58
  5. **Minimize tool output** — Never load full command output into context. First capture to a temp file (`cmd 2>&1 | tee /tmp/out.txt | tail -20`), then scan the head/tail to identify relevant fields, and use targeted filtering (`grep`, `sed`, `awk`) to extract only the information needed for the current task. Only read the filtered result — never the raw full output.
58
59
  6. **No intermediate commits** — Do NOT run `git add`/`git commit` during Phase 1-5. All changes are committed once at the end in Phase 6 via `/prizmkit-committer`.
59
60
  7. **Capture test output once** — When running test suites, always use `<test-command> 2>&1 | tee /tmp/test-out.txt | tail -20`. Then grep `/tmp/test-out.txt` for details. Never re-run the suite just to apply a different filter.
60
- 8. **Scaffold / generated file awareness** — Files created by scaffolding tools are boilerplate. Tag them, record in context-snapshot.md, NEVER re-read. Edit directly without reading first.
61
61
  9. **Package version verification (BLOCKING)** — Verify dependency versions via registry query before writing them. NEVER guess.
62
62
  10. **Build artifact hygiene** — After build/compile, ensure output is in `.gitignore`.
63
63
  11. **Read offset safety (BLOCKING)** — If Read returns "shorter than offset"/"File is empty"/"Wasted call" — do NOT retry same offset. Run `wc -l <file>` to get real line count, then `sed -n` for exact range. 2 consecutive offset errors → STOP Reading that file. Never guess offsets — `grep -n '<anchor>'` first.
64
64
 
65
65
  ---
66
66
 
67
- {{LOG_SIZE_AWARENESS}}
68
- ---
69
-
70
67
  ## PrizmKit Directory Convention
71
68
 
72
69
  ```
@@ -99,13 +96,6 @@ If any agent times out:
99
96
  ### Phase 0: SKIP (already initialized)
100
97
  {{END_IF_INIT_DONE}}
101
98
 
102
- ### Phase 0.5: Detect Test Commands
103
-
104
- You know this project's tech stack. Identify ALL test commands that apply (e.g., `go test ./...`, `npm test`, `cargo test`, `pytest`, `make test`, etc.). Record them as `TEST_CMDS`.
105
-
106
- Do not run tests in this phase. Test execution happens after code review in the scoped PrizmKit Test gate.
107
-
108
- > **Test Output Rule**: When the post-review gate runs, capture test output to a temp file (`tee /tmp/test-out.txt`). Then grep the file instead of re-running the suite.
109
99
 
110
100
  ### Phase 1: Build Context Snapshot (you, the orchestrator)
111
101
 
@@ -159,20 +149,20 @@ ls .prizmkit/specs/{{FEATURE_SLUG}}/plan.md 2>/dev/null
159
149
 
160
150
  If either missing, run `/prizmkit-plan` with `artifact_dir=.prizmkit/specs/{{FEATURE_SLUG}}/` to generate missing files:
161
151
  - `plan.md`: architecture — components, interfaces, data flow, files to create/modify, testing approach, and a Tasks section with `[ ]` checkboxes ordered by dependency
162
- - Resolve any `[NEEDS CLARIFICATION]` markers using the feature description do NOT pause for interactive input.
152
+ - Resolve uncertain requirements from the feature description, existing code, and conservative existing-project patterns.
163
153
 
164
154
  **Database Design Gate** (if feature involves data persistence — new tables, schema changes, new entities):
165
155
  Before proceeding past CP-1, verify:
166
156
  1. Plan.md Data Model section references existing schema/model files (scan for `*.prisma`, `*.sql`, `migrations/`, `models/`, `*.entity.*` files; read them if not already in context-snapshot)
167
157
  2. All new tables/fields follow existing naming conventions, ID strategy, timestamp patterns, and constraint style
168
- 3. No `[NEEDS CLARIFICATION]` remains in Data Model section — resolve by reading existing code and making a conservative choice that matches existing patterns. Document the resolution in plan.md.
158
+ 3. No unresolved data model uncertainty remains in the Data Model section — resolve by reading existing code and making a conservative choice that matches existing patterns. Document the resolution in plan.md.
169
159
  4. If a DB design decision genuinely cannot be resolved from existing code alone, document the assumption made and flag it in the Implementation Log for user review.
170
160
 
171
161
  **CP-1**: plan.md exists with Tasks section.
172
162
 
173
163
  ### Phase 3: Analyze — Reviewer Subagent
174
164
 
175
- Spawn Reviewer agent (Agent tool, subagent_type="prizm-dev-team-reviewer", mode="plan", run_in_background=false).
165
+ Spawn Reviewer agent (Agent tool, subagent_type="prizm-dev-team-reviewer", mode="plan", run_in_background=false, isolation=default/no worktree). Do not request worktree isolation; this prevents AI tool-created `.claude/worktrees/...` subagent worktrees. PrizmKit pipeline-managed linked git worktrees under `.prizmkit/state/worktrees/...` are separate and controlled by `USE_WORKTREE`.
176
166
 
177
167
  Spawn failure cap: for team/config/lock errors, retry at most once for this Reviewer spawn. If the second attempt fails, do not poll for report artifacts; fix/check the plan inline or write `failure-log.md` before stopping for recovery.
178
168
 
@@ -201,7 +191,7 @@ If CRITIC:MISSING — skip Phase 3.5 entirely and proceed to Phase 4. Log: "Crit
201
191
 
202
192
  **If {{CRITIC_COUNT}} = 1 → Single Critic** (skip to CP-2.5 after this):
203
193
 
204
- Spawn Critic agent (Agent tool, subagent_type="prizm-dev-team-critic", mode="plan", run_in_background=false).
194
+ Spawn Critic agent (Agent tool, subagent_type="prizm-dev-team-critic", mode="plan", run_in_background=false, isolation=default/no worktree). Do not request worktree isolation; this prevents AI tool-created `.claude/worktrees/...` subagent worktrees. PrizmKit pipeline-managed linked git worktrees under `.prizmkit/state/worktrees/...` are separate and controlled by `USE_WORKTREE`.
205
195
 
206
196
  Spawn failure cap: for team/config/lock errors, retry at most once for this Critic spawn. If the second attempt fails, do not poll for challenge reports; perform the plan challenge inline and record the fallback.
207
197
 
@@ -209,9 +199,10 @@ Prompt:
209
199
  > "Read {{CRITIC_SUBAGENT_PATH}}. For feature {{FEATURE_ID}} (slug: {{FEATURE_SLUG}}):
210
200
  > **MODE: Plan Challenge**
211
201
  > 1. Read `.prizmkit/specs/{{FEATURE_SLUG}}/context-snapshot.md` FIRST — Section 3 has project context, Section 4 has file manifest.
212
- > 2. Read `.prizmkit/prizm-docs/root.prizm` and relevant L1/L2 docs for affected modules.
213
- > 3. Read existing source files in the modules this plan touches.
214
- > 4. Challenge plan.md against the project's existing architecture, patterns, and style.
202
+ > 2. Use context-snapshot.md as the shared source of truth. Do not create or enter AI tool-created `.claude/worktrees/...` subagent worktrees; use default/no worktree isolation and do not request worktree isolation.
203
+ > 3. PrizmKit pipeline-managed linked git worktrees under `.prizmkit/state/worktrees/...` are a separate runner feature controlled by `USE_WORKTREE`; do not confuse them with AI tool-created `.claude/worktrees/...`.
204
+ > 4. Read additional `.prizmkit/prizm-docs/` or source excerpts only when needed to verify a specific challenge.
205
+ > 5. Challenge plan.md against the project's existing architecture, patterns, and style.
215
206
  > Write `.prizmkit/specs/{{FEATURE_SLUG}}/challenge-report.md` with findings (or 'No significant challenges')."
216
207
 
217
208
  Wait for Critic to return.
@@ -222,15 +213,16 @@ Wait for Critic to return.
222
213
 
223
214
  **IMPORTANT**: Spawn all 3 Critics in PARALLEL (issue all 3 Agent tool calls in the SAME message turn). Do NOT wait for one before spawning the next.
224
215
 
225
- Spawn Critic-A, Critic-B, Critic-C simultaneously (each with mode="plan", run_in_background=false):
216
+ Spawn Critic-A, Critic-B, Critic-C simultaneously (each with mode="plan", run_in_background=false, isolation=default/no worktree). Do not request worktree isolation; this prevents AI tool-created `.claude/worktrees/...` subagent worktrees. PrizmKit pipeline-managed linked git worktrees under `.prizmkit/state/worktrees/...` are separate and controlled by `USE_WORKTREE`:
226
217
 
227
218
  Critic-A prompt:
228
219
  > "Read {{CRITIC_SUBAGENT_PATH}}. For feature {{FEATURE_ID}} (slug: {{FEATURE_SLUG}}):
229
220
  > **MODE: Plan Challenge — Lens: Architecture & Scalability**
230
221
  > Focus on: architectural pattern fit, scalability implications, over-engineering risks, component boundary design.
231
222
  > 1. Read `.prizmkit/specs/{{FEATURE_SLUG}}/context-snapshot.md` FIRST — Section 3 has TRAPS/RULES, Section 4 has file manifest.
232
- > 2. Read `.prizmkit/prizm-docs/root.prizm` and relevant L1/L2 docs for affected modules.
233
- > 3. Read existing source files in the modules this plan touches.
223
+ > 2. Use context-snapshot.md as the shared source of truth. Do not create or enter AI tool-created `.claude/worktrees/...` subagent worktrees; use default/no worktree isolation and do not request worktree isolation.
224
+ > 3. PrizmKit pipeline-managed linked git worktrees under `.prizmkit/state/worktrees/...` are a separate runner feature controlled by `USE_WORKTREE`; do not confuse them with AI tool-created `.claude/worktrees/...`.
225
+ > 4. Read additional `.prizmkit/prizm-docs/` or source excerpts only when needed to verify a specific challenge.
234
226
  > 4. Challenge plan.md through your architecture lens.
235
227
  > Write `.prizmkit/specs/{{FEATURE_SLUG}}/challenge-report-A.md`."
236
228
 
@@ -239,8 +231,9 @@ Critic-B prompt:
239
231
  > **MODE: Plan Challenge — Lens: Data Model & Edge Cases**
240
232
  > Focus on: data model design fit, entity relationships, edge cases in business logic, missing boundary conditions.
241
233
  > 1. Read `.prizmkit/specs/{{FEATURE_SLUG}}/context-snapshot.md` FIRST — Section 3 has TRAPS/RULES, Section 4 has file manifest.
242
- > 2. Read `.prizmkit/prizm-docs/root.prizm` and relevant L1/L2 docs for affected modules.
243
- > 3. Read existing source files in the modules this plan touches.
234
+ > 2. Use context-snapshot.md as the shared source of truth. Do not create or enter AI tool-created `.claude/worktrees/...` subagent worktrees; use default/no worktree isolation and do not request worktree isolation.
235
+ > 3. PrizmKit pipeline-managed linked git worktrees under `.prizmkit/state/worktrees/...` are a separate runner feature controlled by `USE_WORKTREE`; do not confuse them with AI tool-created `.claude/worktrees/...`.
236
+ > 4. Read additional `.prizmkit/prizm-docs/` or source excerpts only when needed to verify a specific challenge.
244
237
  > 4. Challenge plan.md through your data/edge-case lens.
245
238
  > Write `.prizmkit/specs/{{FEATURE_SLUG}}/challenge-report-B.md`."
246
239
 
@@ -249,8 +242,9 @@ Critic-C prompt:
249
242
  > **MODE: Plan Challenge — Lens: Security & Performance**
250
243
  > Focus on: security attack surface, authentication/authorization gaps, performance bottlenecks, resource leaks.
251
244
  > 1. Read `.prizmkit/specs/{{FEATURE_SLUG}}/context-snapshot.md` FIRST — Section 3 has TRAPS/RULES, Section 4 has file manifest.
252
- > 2. Read `.prizmkit/prizm-docs/root.prizm` and relevant L1/L2 docs for affected modules.
253
- > 3. Read existing source files in the modules this plan touches.
245
+ > 2. Use context-snapshot.md as the shared source of truth. Do not create or enter AI tool-created `.claude/worktrees/...` subagent worktrees; use default/no worktree isolation and do not request worktree isolation.
246
+ > 3. PrizmKit pipeline-managed linked git worktrees under `.prizmkit/state/worktrees/...` are a separate runner feature controlled by `USE_WORKTREE`; do not confuse them with AI tool-created `.claude/worktrees/...`.
247
+ > 4. Read additional `.prizmkit/prizm-docs/` or source excerpts only when needed to verify a specific challenge.
254
248
  > 4. Challenge plan.md through your security/performance lens.
255
249
  > Write `.prizmkit/specs/{{FEATURE_SLUG}}/challenge-report-C.md`."
256
250
 
@@ -309,15 +303,6 @@ For each Verification Gate from the Task Contract, write one evidence line to Im
309
303
 
310
304
  **CP-2**: All tasks `[x]`, Implementation Log written with Gate Evidence, and blocked gates documented in `failure-log.md`. Test execution is deferred until after code review.
311
305
 
312
- **Checkpoint update**:
313
- ```bash
314
- python3 $PIPELINE_DIR/scripts/update-checkpoint.py \
315
- --checkpoint-path .prizmkit/specs/{{FEATURE_SLUG}}/workflow-checkpoint.json \
316
- --step prizmkit-implement \
317
- --status completed
318
- ```
319
-
320
-
321
306
  ### Review — Code Review
322
307
 
323
308
  Review the completed implementation before the scoped feature test gate runs. Use `artifact_dir=.prizmkit/specs/{{FEATURE_SLUG}}/` so the code-review skill can read spec, plan, context snapshot, implementation log, and current diff artifacts. Do not require or read a prior `/prizmkit-test` report here; test generation and test-fix looping happen in the next phase.
@@ -347,7 +332,11 @@ Read `review-report.md` and check the Verdict:
347
332
 
348
333
  Run `/prizmkit-test scope=this-change artifact_dir=.prizmkit/specs/{{FEATURE_SLUG}}/` after review and before commit.
349
334
 
350
- Before invoking the skill, create `.prizmkit/specs/{{FEATURE_SLUG}}/.prizmkit-test-started` so stale reports are ignored.
335
+ Before invoking the skill, create a current-run marker so stale reports are ignored:
336
+ ```bash
337
+ mkdir -p .prizmkit/specs/{{FEATURE_SLUG}}
338
+ touch .prizmkit/specs/{{FEATURE_SLUG}}/.prizmkit-test-started
339
+ ```
351
340
 
352
341
  Gate requirements:
353
342
  - Generate or update tests only for this feature's changed files, changed public interfaces, and acceptance criteria.