@xenonbyte/req-2-plan 0.5.0 → 0.5.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xenonbyte/req-2-plan",
3
- "version": "0.5.0",
3
+ "version": "0.5.1",
4
4
  "description": "Requirement-to-PLAN workflow CLI and agent integration installer.",
5
5
  "bin": {
6
6
  "r2p": "bin/r2p.js"
@@ -84,10 +84,7 @@ def _load_run(work_id: str, base_path: Path | None = None):
84
84
  no command — read-only or mutating — ever follows `.req-to-plan` or
85
85
  `.req-to-plan/<id>` out of the workspace.
86
86
  """
87
- root = base_path or Path.cwd()
88
- _reject_symlink_or_exit(root / ".req-to-plan", "unsafe_workspace_dir_symlink")
89
- run_dir = _get_run_dir(work_id, base_path)
90
- _reject_symlink_or_exit(run_dir, f"Run directory is a symlink: {run_dir}")
87
+ run_dir = _reject_symlinked_run_paths(work_id, base_path)
91
88
  mgr = RunStateManager(run_dir)
92
89
  try:
93
90
  return mgr.load(), mgr, run_dir
@@ -118,6 +115,20 @@ def _reject_symlink_or_exit(path: Path, message: str) -> None:
118
115
  print_and_exit(format_error(message, exit_code=EXIT_CONFLICT), EXIT_CONFLICT)
119
116
 
120
117
 
118
+ def _reject_symlinked_run_paths(work_id, base_path: Path | None) -> Path:
119
+ """Reject a symlinked workspace or run directory, then return the run dir.
120
+
121
+ Guards `.req-to-plan` and `.req-to-plan/<id>` up front (EXIT_CONFLICT) so no
122
+ command — read-only or mutating — ever follows either out of the workspace.
123
+ Call before any filesystem mutation that targets the run dir.
124
+ """
125
+ root = base_path or Path.cwd()
126
+ _reject_symlink_or_exit(root / ".req-to-plan", "unsafe_workspace_dir_symlink")
127
+ run_dir = _get_run_dir(work_id, base_path)
128
+ _reject_symlink_or_exit(run_dir, f"Run directory is a symlink: {run_dir}")
129
+ return run_dir
130
+
131
+
121
132
  def _validate_repo_path(raw: str) -> Path:
122
133
  """Return a repo path only when it is an existing directory."""
123
134
  repo_path = Path(raw)
@@ -223,7 +234,7 @@ def _cmd_run_start(args):
223
234
  EXIT_CLI_ERR,
224
235
  )
225
236
  repo_path = _validate_repo_path(args.repo_path) if args.repo_path else None
226
- run_dir = _get_run_dir(work_id, args.base_path)
237
+ run_dir = _reject_symlinked_run_paths(work_id, args.base_path)
227
238
  mgr = RunStateManager(run_dir)
228
239
 
229
240
  run_dir_occupied = False
@@ -2000,7 +2011,7 @@ def _cmd_context_build(args):
2000
2011
  from tools.workflow_cli.context_pack import build_context_pack, write_context_pack
2001
2012
 
2002
2013
  work_id = str(_validate_work_id(args.work_id))
2003
- run_dir = _get_run_dir(work_id, args.base_path)
2014
+ run_dir = _reject_symlinked_run_paths(work_id, args.base_path)
2004
2015
  if not run_dir.exists():
2005
2016
  print_and_exit(
2006
2017
  format_error(f"run not found: {work_id}", exit_code=EXIT_NOT_FOUND),
@@ -1 +1 @@
1
- R2P_VERSION = "0.5.0"
1
+ R2P_VERSION = "0.5.1"