nlp-refinement-cli 0.9.0__tar.gz → 0.9.2__tar.gz

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 (61) hide show
  1. {nlp_refinement_cli-0.9.0 → nlp_refinement_cli-0.9.2}/PKG-INFO +6 -4
  2. {nlp_refinement_cli-0.9.0 → nlp_refinement_cli-0.9.2}/README.md +5 -3
  3. {nlp_refinement_cli-0.9.0 → nlp_refinement_cli-0.9.2}/nlp_refinement/doe_receipt_retention.py +3 -0
  4. {nlp_refinement_cli-0.9.0 → nlp_refinement_cli-0.9.2}/nlp_refinement/host_refine.py +2 -0
  5. {nlp_refinement_cli-0.9.0 → nlp_refinement_cli-0.9.2}/nlp_refinement/refine.py +2 -0
  6. nlp_refinement_cli-0.9.2/nlp_refinement/version.py +3 -0
  7. {nlp_refinement_cli-0.9.0 → nlp_refinement_cli-0.9.2}/nlp_refinement_cli.egg-info/PKG-INFO +6 -4
  8. {nlp_refinement_cli-0.9.0 → nlp_refinement_cli-0.9.2}/nlp_refinement_cli.egg-info/SOURCES.txt +4 -0
  9. {nlp_refinement_cli-0.9.0 → nlp_refinement_cli-0.9.2}/pyproject.toml +1 -1
  10. {nlp_refinement_cli-0.9.0 → nlp_refinement_cli-0.9.2}/tests/test_cli_distribution.py +12 -0
  11. {nlp_refinement_cli-0.9.0 → nlp_refinement_cli-0.9.2}/tests/test_plugin_packaging.py +6 -0
  12. nlp_refinement_cli-0.9.2/tests/test_public_marketplace.py +32 -0
  13. nlp_refinement_cli-0.9.2/tests/test_runtime_release_config.py +36 -0
  14. nlp_refinement_cli-0.9.2/tests/test_runtime_setup.py +85 -0
  15. {nlp_refinement_cli-0.9.0 → nlp_refinement_cli-0.9.2}/LICENSE +0 -0
  16. {nlp_refinement_cli-0.9.0 → nlp_refinement_cli-0.9.2}/NOTICE +0 -0
  17. {nlp_refinement_cli-0.9.0 → nlp_refinement_cli-0.9.2}/nlp_refinement/__init__.py +0 -0
  18. {nlp_refinement_cli-0.9.0 → nlp_refinement_cli-0.9.2}/nlp_refinement/diagnostic_doe_support.py +0 -0
  19. {nlp_refinement_cli-0.9.0 → nlp_refinement_cli-0.9.2}/nlp_refinement/format_contracts.py +0 -0
  20. {nlp_refinement_cli-0.9.0 → nlp_refinement_cli-0.9.2}/nlp_refinement/host_client.py +0 -0
  21. {nlp_refinement_cli-0.9.0 → nlp_refinement_cli-0.9.2}/nlp_refinement/host_diagnostics.py +0 -0
  22. {nlp_refinement_cli-0.9.0 → nlp_refinement_cli-0.9.2}/nlp_refinement/host_execution_request.py +0 -0
  23. {nlp_refinement_cli-0.9.0 → nlp_refinement_cli-0.9.2}/nlp_refinement/host_executor.py +0 -0
  24. {nlp_refinement_cli-0.9.0 → nlp_refinement_cli-0.9.2}/nlp_refinement/m8_doe_fixtures.py +0 -0
  25. {nlp_refinement_cli-0.9.0 → nlp_refinement_cli-0.9.2}/nlp_refinement/m8_review_coordinator.py +0 -0
  26. {nlp_refinement_cli-0.9.0 → nlp_refinement_cli-0.9.2}/nlp_refinement/patch_proposal_adapter.py +0 -0
  27. {nlp_refinement_cli-0.9.0 → nlp_refinement_cli-0.9.2}/nlp_refinement/repair_feasibility.py +0 -0
  28. {nlp_refinement_cli-0.9.0 → nlp_refinement_cli-0.9.2}/nlp_refinement/resources/__init__.py +0 -0
  29. {nlp_refinement_cli-0.9.0 → nlp_refinement_cli-0.9.2}/nlp_refinement/resources/prompts/patch-proposal-phase.v5.md +0 -0
  30. {nlp_refinement_cli-0.9.0 → nlp_refinement_cli-0.9.2}/nlp_refinement/resources/prompts/review-phase.v5.md +0 -0
  31. {nlp_refinement_cli-0.9.0 → nlp_refinement_cli-0.9.2}/nlp_refinement/resources/schemas/v5/acceptance-trace.schema.json +0 -0
  32. {nlp_refinement_cli-0.9.0 → nlp_refinement_cli-0.9.2}/nlp_refinement/resources/schemas/v5/artifact.schema.json +0 -0
  33. {nlp_refinement_cli-0.9.0 → nlp_refinement_cli-0.9.2}/nlp_refinement/resources/schemas/v5/finding.schema.json +0 -0
  34. {nlp_refinement_cli-0.9.0 → nlp_refinement_cli-0.9.2}/nlp_refinement/resources/schemas/v5/patch-proposal-result.schema.json +0 -0
  35. {nlp_refinement_cli-0.9.0 → nlp_refinement_cli-0.9.2}/nlp_refinement/resources/schemas/v5/phase-envelope.schema.json +0 -0
  36. {nlp_refinement_cli-0.9.0 → nlp_refinement_cli-0.9.2}/nlp_refinement/resources/schemas/v5/retention-policy.schema.json +0 -0
  37. {nlp_refinement_cli-0.9.0 → nlp_refinement_cli-0.9.2}/nlp_refinement/resources/schemas/v5/review-result.schema.json +0 -0
  38. {nlp_refinement_cli-0.9.0 → nlp_refinement_cli-0.9.2}/nlp_refinement/resources/schemas/v5/run.schema.json +0 -0
  39. {nlp_refinement_cli-0.9.0 → nlp_refinement_cli-0.9.2}/nlp_refinement/review_adapter.py +0 -0
  40. {nlp_refinement_cli-0.9.0 → nlp_refinement_cli-0.9.2}/nlp_refinement/sensitive_data.py +0 -0
  41. {nlp_refinement_cli-0.9.0 → nlp_refinement_cli-0.9.2}/nlp_refinement/state_store.py +0 -0
  42. {nlp_refinement_cli-0.9.0 → nlp_refinement_cli-0.9.2}/nlp_refinement_cli.egg-info/dependency_links.txt +0 -0
  43. {nlp_refinement_cli-0.9.0 → nlp_refinement_cli-0.9.2}/nlp_refinement_cli.egg-info/entry_points.txt +0 -0
  44. {nlp_refinement_cli-0.9.0 → nlp_refinement_cli-0.9.2}/nlp_refinement_cli.egg-info/top_level.txt +0 -0
  45. {nlp_refinement_cli-0.9.0 → nlp_refinement_cli-0.9.2}/setup.cfg +0 -0
  46. {nlp_refinement_cli-0.9.0 → nlp_refinement_cli-0.9.2}/tests/test_contribution_policy.py +0 -0
  47. {nlp_refinement_cli-0.9.0 → nlp_refinement_cli-0.9.2}/tests/test_doe_receipt_retention.py +0 -0
  48. {nlp_refinement_cli-0.9.0 → nlp_refinement_cli-0.9.2}/tests/test_format_contracts.py +0 -0
  49. {nlp_refinement_cli-0.9.0 → nlp_refinement_cli-0.9.2}/tests/test_host_client.py +0 -0
  50. {nlp_refinement_cli-0.9.0 → nlp_refinement_cli-0.9.2}/tests/test_host_coordinator.py +0 -0
  51. {nlp_refinement_cli-0.9.0 → nlp_refinement_cli-0.9.2}/tests/test_host_diagnostics.py +0 -0
  52. {nlp_refinement_cli-0.9.0 → nlp_refinement_cli-0.9.2}/tests/test_host_execution_boundary.py +0 -0
  53. {nlp_refinement_cli-0.9.0 → nlp_refinement_cli-0.9.2}/tests/test_host_executor.py +0 -0
  54. {nlp_refinement_cli-0.9.0 → nlp_refinement_cli-0.9.2}/tests/test_m0_contract.py +0 -0
  55. {nlp_refinement_cli-0.9.0 → nlp_refinement_cli-0.9.2}/tests/test_m8_doe_and_skill_entry.py +0 -0
  56. {nlp_refinement_cli-0.9.0 → nlp_refinement_cli-0.9.2}/tests/test_pypi_publish_workflow.py +0 -0
  57. {nlp_refinement_cli-0.9.0 → nlp_refinement_cli-0.9.2}/tests/test_refine_command.py +0 -0
  58. {nlp_refinement_cli-0.9.0 → nlp_refinement_cli-0.9.2}/tests/test_repair_feasibility.py +0 -0
  59. {nlp_refinement_cli-0.9.0 → nlp_refinement_cli-0.9.2}/tests/test_runtime_bootstrap.py +0 -0
  60. {nlp_refinement_cli-0.9.0 → nlp_refinement_cli-0.9.2}/tests/test_sensitive_data.py +0 -0
  61. {nlp_refinement_cli-0.9.0 → nlp_refinement_cli-0.9.2}/tests/test_state_store.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: nlp-refinement-cli
3
- Version: 0.9.0
3
+ Version: 0.9.2
4
4
  Summary: Durable-local, review-only refinement for natural-language-programming artifacts.
5
5
  License: Apache License
6
6
  Version 2.0, January 2004
@@ -232,13 +232,15 @@ is a separately installed Python distribution; Plugin installation never
232
232
  installs it implicitly. For a published, configured release, the first
233
233
  `$nlp-refine` setup flow may present a pinned CLI installation plan and, only
234
234
  after explicit user confirmation, download, verify, and install that exact
235
- wheel. This source checkout has no production release URL or hash, so its setup
236
- flow deliberately stops instead of inventing a download source.
235
+ wheel. The setup wrapper first checks all three CLI commands through
236
+ `--version`; it treats an older command as incompatible rather than as a valid
237
+ installation. A release configuration is valid only when its matching public
238
+ GitHub Release manifest and wheel assets exist.
237
239
 
238
240
  Manual/offline installation remains supported:
239
241
 
240
242
  ```sh
241
- python3 -m pip install --user /path/to/nlp_refinement_cli-0.9.0-py3-none-any.whl
243
+ python3 -m pip install --user /path/to/nlp_refinement_cli-0.9.2-py3-none-any.whl
242
244
  ```
243
245
 
244
246
  That distribution provides two deliberately separate execution commands plus a
@@ -20,13 +20,15 @@ is a separately installed Python distribution; Plugin installation never
20
20
  installs it implicitly. For a published, configured release, the first
21
21
  `$nlp-refine` setup flow may present a pinned CLI installation plan and, only
22
22
  after explicit user confirmation, download, verify, and install that exact
23
- wheel. This source checkout has no production release URL or hash, so its setup
24
- flow deliberately stops instead of inventing a download source.
23
+ wheel. The setup wrapper first checks all three CLI commands through
24
+ `--version`; it treats an older command as incompatible rather than as a valid
25
+ installation. A release configuration is valid only when its matching public
26
+ GitHub Release manifest and wheel assets exist.
25
27
 
26
28
  Manual/offline installation remains supported:
27
29
 
28
30
  ```sh
29
- python3 -m pip install --user /path/to/nlp_refinement_cli-0.9.0-py3-none-any.whl
31
+ python3 -m pip install --user /path/to/nlp_refinement_cli-0.9.2-py3-none-any.whl
30
32
  ```
31
33
 
32
34
  That distribution provides two deliberately separate execution commands plus a
@@ -10,6 +10,8 @@ import re
10
10
  import stat
11
11
  import time
12
12
 
13
+ from nlp_refinement.version import CLI_VERSION
14
+
13
15
 
14
16
  DEFAULT_FAILURE_EVIDENCE_ROOT = Path("~/.codex/refinement-loop/doe-failures").expanduser()
15
17
  FAILURE_EVIDENCE_RETENTION_SECONDS = 24 * 60 * 60
@@ -64,6 +66,7 @@ def main(argv: list[str] | None = None) -> int:
64
66
  prog="nlp-refinement-doe-prune",
65
67
  description="Remove expired, redacted M8 DOE failure receipts without invoking a model.",
66
68
  )
69
+ parser.add_argument("--version", action="version", version=CLI_VERSION)
67
70
  parser.add_argument("--failure-evidence-root", type=Path, default=DEFAULT_FAILURE_EVIDENCE_ROOT)
68
71
  args = parser.parse_args(argv)
69
72
  removed = purge_expired_failure_receipts(args.failure_evidence_root, int(time.time()))
@@ -11,10 +11,12 @@ from nlp_refinement.host_execution_request import HostExecutionRequest
11
11
  from nlp_refinement.m8_review_coordinator import M8ReviewCoordinator, M8ReviewCoordinatorError
12
12
  from nlp_refinement.refine import default_state_root, output, public_status, snapshot_hash
13
13
  from nlp_refinement.state_store import StateStore, StateStoreError
14
+ from nlp_refinement.version import CLI_VERSION
14
15
 
15
16
 
16
17
  def build_parser() -> argparse.ArgumentParser:
17
18
  parser = argparse.ArgumentParser(prog="nlp-refinement-host")
19
+ parser.add_argument("--version", action="version", version=CLI_VERSION)
18
20
  parser.add_argument("--state-root", type=Path, default=default_state_root())
19
21
  subcommands = parser.add_subparsers(dest="command", required=True)
20
22
  review = subcommands.add_parser(
@@ -22,6 +22,7 @@ from nlp_refinement.host_execution_request import HostExecutionRequest
22
22
  from nlp_refinement.review_adapter import ingest_review, load_review_result
23
23
  from nlp_refinement.sensitive_data import likely_secret_kind
24
24
  from nlp_refinement.state_store import FINAL_STATES, StateStore, StateStoreError
25
+ from nlp_refinement.version import CLI_VERSION
25
26
 
26
27
 
27
28
  # Project identity is independent of the persisted protocol version. Keep it
@@ -65,6 +66,7 @@ def output(value: dict[str, Any]) -> None:
65
66
 
66
67
  def build_parser() -> argparse.ArgumentParser:
67
68
  parser = argparse.ArgumentParser(prog="nlp-refinement")
69
+ parser.add_argument("--version", action="version", version=CLI_VERSION)
68
70
  parser.add_argument("--state-root", type=Path, default=default_state_root())
69
71
  subcommands = parser.add_subparsers(dest="command", required=True)
70
72
 
@@ -0,0 +1,3 @@
1
+ """Single release version shared by all public command entrypoints."""
2
+
3
+ CLI_VERSION = "0.9.2"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: nlp-refinement-cli
3
- Version: 0.9.0
3
+ Version: 0.9.2
4
4
  Summary: Durable-local, review-only refinement for natural-language-programming artifacts.
5
5
  License: Apache License
6
6
  Version 2.0, January 2004
@@ -232,13 +232,15 @@ is a separately installed Python distribution; Plugin installation never
232
232
  installs it implicitly. For a published, configured release, the first
233
233
  `$nlp-refine` setup flow may present a pinned CLI installation plan and, only
234
234
  after explicit user confirmation, download, verify, and install that exact
235
- wheel. This source checkout has no production release URL or hash, so its setup
236
- flow deliberately stops instead of inventing a download source.
235
+ wheel. The setup wrapper first checks all three CLI commands through
236
+ `--version`; it treats an older command as incompatible rather than as a valid
237
+ installation. A release configuration is valid only when its matching public
238
+ GitHub Release manifest and wheel assets exist.
237
239
 
238
240
  Manual/offline installation remains supported:
239
241
 
240
242
  ```sh
241
- python3 -m pip install --user /path/to/nlp_refinement_cli-0.9.0-py3-none-any.whl
243
+ python3 -m pip install --user /path/to/nlp_refinement_cli-0.9.2-py3-none-any.whl
242
244
  ```
243
245
 
244
246
  That distribution provides two deliberately separate execution commands plus a
@@ -19,6 +19,7 @@ nlp_refinement/repair_feasibility.py
19
19
  nlp_refinement/review_adapter.py
20
20
  nlp_refinement/sensitive_data.py
21
21
  nlp_refinement/state_store.py
22
+ nlp_refinement/version.py
22
23
  nlp_refinement/resources/__init__.py
23
24
  nlp_refinement/resources/prompts/patch-proposal-phase.v5.md
24
25
  nlp_refinement/resources/prompts/review-phase.v5.md
@@ -47,9 +48,12 @@ tests/test_host_executor.py
47
48
  tests/test_m0_contract.py
48
49
  tests/test_m8_doe_and_skill_entry.py
49
50
  tests/test_plugin_packaging.py
51
+ tests/test_public_marketplace.py
50
52
  tests/test_pypi_publish_workflow.py
51
53
  tests/test_refine_command.py
52
54
  tests/test_repair_feasibility.py
53
55
  tests/test_runtime_bootstrap.py
56
+ tests/test_runtime_release_config.py
57
+ tests/test_runtime_setup.py
54
58
  tests/test_sensitive_data.py
55
59
  tests/test_state_store.py
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "nlp-refinement-cli"
7
- version = "0.9.0"
7
+ version = "0.9.2"
8
8
  description = "Durable-local, review-only refinement for natural-language-programming artifacts."
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.11"
@@ -8,8 +8,11 @@ import tempfile
8
8
  import tomllib
9
9
  import unittest
10
10
 
11
+ from nlp_refinement.doe_receipt_retention import main as prune_main
11
12
  from nlp_refinement.refine import build_parser, main
12
13
  from nlp_refinement.host_refine import build_parser as build_host_parser
14
+ from nlp_refinement.host_refine import main as host_main
15
+ from nlp_refinement.version import CLI_VERSION
13
16
 
14
17
 
15
18
  ROOT = Path(__file__).resolve().parents[1]
@@ -17,12 +20,21 @@ SNAPSHOT = "a" * 64
17
20
 
18
21
 
19
22
  class CliDistributionTests(unittest.TestCase):
23
+ def test_every_public_command_reports_the_distribution_version(self) -> None:
24
+ for entrypoint in (main, host_main, prune_main):
25
+ output = io.StringIO()
26
+ with redirect_stdout(output), self.assertRaises(SystemExit) as exited:
27
+ entrypoint(["--version"])
28
+ self.assertEqual(exited.exception.code, 0)
29
+ self.assertEqual(output.getvalue(), f"{CLI_VERSION}\n")
30
+
20
31
  def test_distribution_declares_separate_normal_and_external_host_commands(self) -> None:
21
32
  with (ROOT / "pyproject.toml").open("rb") as handle:
22
33
  package = tomllib.load(handle)
23
34
  project = package["project"]
24
35
 
25
36
  self.assertEqual(project["name"], "nlp-refinement-cli")
37
+ self.assertEqual(project["version"], CLI_VERSION)
26
38
  self.assertEqual(package["build-system"]["requires"], ["setuptools", "wheel"])
27
39
  self.assertEqual(project["scripts"], {
28
40
  "nlp-refinement": "nlp_refinement.refine:main",
@@ -35,7 +35,13 @@ class PluginPackagingTests(unittest.TestCase):
35
35
  )
36
36
  self.assertEqual(compatibility["onboardingSkill"], "./skills/nlp-refine-setup/SKILL.md")
37
37
  self.assertTrue((ROOT / "skills" / "nlp-refine-setup" / "SKILL.md").is_file())
38
+ self.assertTrue((ROOT / "runtime-bootstrap-config.json").is_file())
39
+ self.assertTrue((ROOT / "scripts" / "nlp_refinement_runtime_setup.py").is_file())
38
40
  self.assertIn("nlp-refine-setup", (ROOT / "skills" / "nlp-refine" / "SKILL.md").read_text(encoding="utf-8"))
41
+ self.assertIn(
42
+ "nlp_refinement_runtime_setup.py",
43
+ (ROOT / "skills" / "nlp-refine-setup" / "SKILL.md").read_text(encoding="utf-8"),
44
+ )
39
45
  self.assertFalse((ROOT / ".agents" / "skills" / "nlp-refine" / "SKILL.md").exists())
40
46
 
41
47
  def test_authoritative_documents_describe_the_accepted_host_boundary(self) -> None:
@@ -0,0 +1,32 @@
1
+ from __future__ import annotations
2
+
3
+ import json
4
+ from pathlib import Path
5
+ import tomllib
6
+ import unittest
7
+
8
+
9
+ ROOT = Path(__file__).resolve().parents[1]
10
+
11
+
12
+ class PublicMarketplaceTests(unittest.TestCase):
13
+ def test_public_marketplace_pins_the_root_plugin_to_its_release_tag(self) -> None:
14
+ marketplace = json.loads((ROOT / ".agents" / "plugins" / "marketplace.json").read_text(encoding="utf-8"))
15
+ with (ROOT / "pyproject.toml").open("rb") as handle:
16
+ version = tomllib.load(handle)["project"]["version"]
17
+
18
+ self.assertEqual(marketplace["name"], "nlp-refinement")
19
+ self.assertEqual(len(marketplace["plugins"]), 1)
20
+ plugin = marketplace["plugins"][0]
21
+ self.assertEqual(plugin["name"], "nlp-refinement-cli")
22
+ self.assertEqual(plugin["source"], {
23
+ "source": "url",
24
+ "url": "https://github.com/yaoxiaocong-sketch/nlp-refinement.git",
25
+ "ref": f"v{version}",
26
+ })
27
+ self.assertEqual(plugin["policy"], {"installation": "AVAILABLE", "authentication": "ON_INSTALL"})
28
+ self.assertEqual(plugin["category"], "Productivity")
29
+
30
+
31
+ if __name__ == "__main__":
32
+ unittest.main()
@@ -0,0 +1,36 @@
1
+ from __future__ import annotations
2
+
3
+ import hashlib
4
+ import json
5
+ from pathlib import Path
6
+ import tomllib
7
+ import unittest
8
+
9
+
10
+ ROOT = Path(__file__).resolve().parents[1]
11
+ CONFIG = ROOT / "runtime-bootstrap-config.json"
12
+
13
+
14
+ class RuntimeReleaseConfigTests(unittest.TestCase):
15
+ def test_plugin_config_pins_the_checked_in_matching_release_manifest(self) -> None:
16
+ config = json.loads(CONFIG.read_text(encoding="utf-8"))
17
+ with (ROOT / "pyproject.toml").open("rb") as handle:
18
+ package = tomllib.load(handle)
19
+ version = package["project"]["version"]
20
+
21
+ self.assertEqual(config["schema_version"], "nlp-refinement-runtime-bootstrap/v1")
22
+ self.assertEqual(config["plugin_name"], "nlp-refinement-cli")
23
+ self.assertEqual(config["plugin_version"], version)
24
+ manifest_path = ROOT / config["release_manifest"]["source_path"]
25
+ self.assertTrue(manifest_path.is_file())
26
+ self.assertEqual(
27
+ config["release_manifest"]["sha256"],
28
+ hashlib.sha256(manifest_path.read_bytes()).hexdigest(),
29
+ )
30
+ release = json.loads(manifest_path.read_text(encoding="utf-8"))
31
+ self.assertEqual(release["version"], version)
32
+ self.assertEqual(release["plugin"], {"name": "nlp-refinement-cli", "version": version})
33
+
34
+
35
+ if __name__ == "__main__":
36
+ unittest.main()
@@ -0,0 +1,85 @@
1
+ from __future__ import annotations
2
+
3
+ import importlib.util
4
+ import json
5
+ from pathlib import Path
6
+ import sys
7
+ import tempfile
8
+ import unittest
9
+ from unittest.mock import patch
10
+
11
+
12
+ ROOT = Path(__file__).resolve().parents[1]
13
+ SCRIPT = ROOT / "scripts" / "nlp_refinement_runtime_setup.py"
14
+
15
+
16
+ def load_module() -> object:
17
+ spec = importlib.util.spec_from_file_location("nlp_refinement_runtime_setup", SCRIPT)
18
+ assert spec is not None and spec.loader is not None
19
+ module = importlib.util.module_from_spec(spec)
20
+ sys.modules[spec.name] = module
21
+ spec.loader.exec_module(module)
22
+ return module
23
+
24
+
25
+ class RuntimeSetupTests(unittest.TestCase):
26
+ def setUp(self) -> None:
27
+ self.module = load_module()
28
+
29
+ @staticmethod
30
+ def write_plugin_root(root: Path) -> Path:
31
+ root.mkdir()
32
+ (root / "plugin.json").write_text(
33
+ json.dumps({"name": "nlp-refinement-cli", "version": "0.9.2"}), encoding="utf-8"
34
+ )
35
+ (root / "runtime-bootstrap-config.json").write_text(
36
+ json.dumps({
37
+ "schema_version": "nlp-refinement-runtime-bootstrap/v1",
38
+ "plugin_name": "nlp-refinement-cli",
39
+ "plugin_version": "0.9.2",
40
+ "release_manifest": {
41
+ "url": "https://github.com/example/nlp-refinement/releases/download/v0.9.2/release.json",
42
+ "sha256": "a" * 64,
43
+ },
44
+ }),
45
+ encoding="utf-8",
46
+ )
47
+ return root
48
+
49
+ def test_matching_path_commands_finish_without_download_or_install(self) -> None:
50
+ with tempfile.TemporaryDirectory() as directory:
51
+ plugin_root = self.write_plugin_root(Path(directory) / "plugin")
52
+ with patch.object(self.module, "_command_version", return_value="0.9.2"), \
53
+ patch.object(self.module.bootstrap, "run") as bootstrap_run:
54
+ result = self.module.run(plugin_root=plugin_root, apply=False)
55
+
56
+ self.assertEqual(result["status"], "ALREADY_INSTALLED")
57
+ bootstrap_run.assert_not_called()
58
+
59
+ def test_old_or_missing_commands_delegate_only_to_the_pinned_bootstrap(self) -> None:
60
+ with tempfile.TemporaryDirectory() as directory:
61
+ plugin_root = self.write_plugin_root(Path(directory) / "plugin")
62
+ bootstrap_result = {"status": "PLAN_READY", "requires_confirmation": True}
63
+ expected = {
64
+ "status": "PLAN_READY",
65
+ "requires_confirmation": True,
66
+ "release_manifest_url": "https://github.com/example/nlp-refinement/releases/download/v0.9.2/release.json",
67
+ "release_manifest_sha256": "a" * 64,
68
+ }
69
+ with patch.object(self.module, "_command_version", side_effect=["0.8.2", None, None]), \
70
+ patch.object(self.module.bootstrap, "run", return_value=bootstrap_result) as bootstrap_run:
71
+ result = self.module.run(plugin_root=plugin_root, apply=False)
72
+
73
+ self.assertEqual(result, expected)
74
+ self.assertEqual(bootstrap_run.call_args.kwargs["release_manifest_url"], "https://github.com/example/nlp-refinement/releases/download/v0.9.2/release.json")
75
+ self.assertEqual(bootstrap_run.call_args.kwargs["release_manifest_sha256"], "a" * 64)
76
+ self.assertEqual(bootstrap_run.call_args.kwargs["plugin_manifest"], plugin_root / "plugin.json")
77
+ self.assertFalse(bootstrap_run.call_args.kwargs["apply"])
78
+
79
+ def test_relative_or_incomplete_plugin_configuration_stops_without_bootstrap(self) -> None:
80
+ result = self.module.run(plugin_root=Path("relative-plugin-root"), apply=False)
81
+ self.assertEqual(result["code"], "BOOTSTRAP_ROOT_OR_RELEASE_UNAVAILABLE")
82
+
83
+
84
+ if __name__ == "__main__":
85
+ unittest.main()