napoln 0.2.9__tar.gz → 0.2.10__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.
- napoln-0.2.10/.release-please-manifest.json +3 -0
- {napoln-0.2.9 → napoln-0.2.10}/CHANGELOG.md +17 -0
- {napoln-0.2.9 → napoln-0.2.10}/PKG-INFO +1 -1
- {napoln-0.2.9 → napoln-0.2.10}/pyproject.toml +1 -1
- {napoln-0.2.9 → napoln-0.2.10}/src/napoln/__init__.py +1 -1
- {napoln-0.2.9 → napoln-0.2.10}/src/napoln/core/agents.py +14 -1
- {napoln-0.2.9 → napoln-0.2.10}/src/napoln/core/manifest.py +13 -1
- {napoln-0.2.9 → napoln-0.2.10}/src/napoln/core/resolver.py +33 -7
- {napoln-0.2.9 → napoln-0.2.10}/tests/unit/test_agents.py +3 -0
- {napoln-0.2.9 → napoln-0.2.10}/tests/unit/test_manifest.py +48 -0
- {napoln-0.2.9 → napoln-0.2.10}/tests/unit/test_resolver.py +107 -1
- napoln-0.2.9/.release-please-manifest.json +0 -3
- {napoln-0.2.9 → napoln-0.2.10}/.github/workflows/ci.yml +0 -0
- {napoln-0.2.9 → napoln-0.2.10}/.github/workflows/pr-title.yml +0 -0
- {napoln-0.2.9 → napoln-0.2.10}/.github/workflows/release-please.yml +0 -0
- {napoln-0.2.9 → napoln-0.2.10}/.github/workflows/release.yml +0 -0
- {napoln-0.2.9 → napoln-0.2.10}/.gitignore +0 -0
- {napoln-0.2.9 → napoln-0.2.10}/AGENTS.md +0 -0
- {napoln-0.2.9 → napoln-0.2.10}/ARCHITECTURE.md +0 -0
- {napoln-0.2.9 → napoln-0.2.10}/CLAUDE.md +0 -0
- {napoln-0.2.9 → napoln-0.2.10}/CONTRIBUTING.md +0 -0
- {napoln-0.2.9 → napoln-0.2.10}/LICENSE +0 -0
- {napoln-0.2.9 → napoln-0.2.10}/README.md +0 -0
- {napoln-0.2.9 → napoln-0.2.10}/justfile +0 -0
- {napoln-0.2.9 → napoln-0.2.10}/napoln-demo.gif +0 -0
- {napoln-0.2.9 → napoln-0.2.10}/release-please-config.json +0 -0
- {napoln-0.2.9 → napoln-0.2.10}/skills-lock.json +0 -0
- {napoln-0.2.9 → napoln-0.2.10}/src/napoln/cli.py +0 -0
- {napoln-0.2.9 → napoln-0.2.10}/src/napoln/commands/__init__.py +0 -0
- {napoln-0.2.9 → napoln-0.2.10}/src/napoln/commands/add.py +0 -0
- {napoln-0.2.9 → napoln-0.2.10}/src/napoln/commands/config.py +0 -0
- {napoln-0.2.9 → napoln-0.2.10}/src/napoln/commands/init.py +0 -0
- {napoln-0.2.9 → napoln-0.2.10}/src/napoln/commands/install.py +0 -0
- {napoln-0.2.9 → napoln-0.2.10}/src/napoln/commands/list_cmd.py +0 -0
- {napoln-0.2.9 → napoln-0.2.10}/src/napoln/commands/remove.py +0 -0
- {napoln-0.2.9 → napoln-0.2.10}/src/napoln/commands/setup.py +0 -0
- {napoln-0.2.9 → napoln-0.2.10}/src/napoln/commands/upgrade.py +0 -0
- {napoln-0.2.9 → napoln-0.2.10}/src/napoln/core/__init__.py +0 -0
- {napoln-0.2.9 → napoln-0.2.10}/src/napoln/core/hasher.py +0 -0
- {napoln-0.2.9 → napoln-0.2.10}/src/napoln/core/home.py +0 -0
- {napoln-0.2.9 → napoln-0.2.10}/src/napoln/core/linker.py +0 -0
- {napoln-0.2.9 → napoln-0.2.10}/src/napoln/core/merger.py +0 -0
- {napoln-0.2.9 → napoln-0.2.10}/src/napoln/core/store.py +0 -0
- {napoln-0.2.9 → napoln-0.2.10}/src/napoln/core/validator.py +0 -0
- {napoln-0.2.9 → napoln-0.2.10}/src/napoln/errors.py +0 -0
- {napoln-0.2.9 → napoln-0.2.10}/src/napoln/output.py +0 -0
- {napoln-0.2.9 → napoln-0.2.10}/src/napoln/prompts.py +0 -0
- {napoln-0.2.9 → napoln-0.2.10}/src/napoln/skills/napoln-manage/SKILL.md +0 -0
- {napoln-0.2.9 → napoln-0.2.10}/tests/__init__.py +0 -0
- {napoln-0.2.9 → napoln-0.2.10}/tests/conftest.py +0 -0
- {napoln-0.2.9 → napoln-0.2.10}/tests/features/config.feature +0 -0
- {napoln-0.2.9 → napoln-0.2.10}/tests/features/first_run.feature +0 -0
- {napoln-0.2.9 → napoln-0.2.10}/tests/features/init.feature +0 -0
- {napoln-0.2.9 → napoln-0.2.10}/tests/features/install.feature +0 -0
- {napoln-0.2.9 → napoln-0.2.10}/tests/features/list.feature +0 -0
- {napoln-0.2.9 → napoln-0.2.10}/tests/features/setup.feature +0 -0
- {napoln-0.2.9 → napoln-0.2.10}/tests/features/upgrade.feature +0 -0
- {napoln-0.2.9 → napoln-0.2.10}/tests/fixtures/invalid-skill/SKILL.md +0 -0
- {napoln-0.2.9 → napoln-0.2.10}/tests/fixtures/multi-skill-repo/README.md +0 -0
- {napoln-0.2.9 → napoln-0.2.10}/tests/fixtures/multi-skill-repo/skills/skill-a/SKILL.md +0 -0
- {napoln-0.2.9 → napoln-0.2.10}/tests/fixtures/multi-skill-repo/skills/skill-b/SKILL.md +0 -0
- {napoln-0.2.9 → napoln-0.2.10}/tests/fixtures/valid-skill/SKILL.md +0 -0
- {napoln-0.2.9 → napoln-0.2.10}/tests/integration/test_cli.py +0 -0
- {napoln-0.2.9 → napoln-0.2.10}/tests/steps/__init__.py +0 -0
- {napoln-0.2.9 → napoln-0.2.10}/tests/steps/conftest.py +0 -0
- {napoln-0.2.9 → napoln-0.2.10}/tests/steps/test_config.py +0 -0
- {napoln-0.2.9 → napoln-0.2.10}/tests/steps/test_first_run.py +0 -0
- {napoln-0.2.9 → napoln-0.2.10}/tests/steps/test_init.py +0 -0
- {napoln-0.2.9 → napoln-0.2.10}/tests/steps/test_install.py +0 -0
- {napoln-0.2.9 → napoln-0.2.10}/tests/steps/test_list.py +0 -0
- {napoln-0.2.9 → napoln-0.2.10}/tests/steps/test_setup.py +0 -0
- {napoln-0.2.9 → napoln-0.2.10}/tests/steps/test_upgrade.py +0 -0
- {napoln-0.2.9 → napoln-0.2.10}/tests/unit/test_hasher.py +0 -0
- {napoln-0.2.9 → napoln-0.2.10}/tests/unit/test_linker.py +0 -0
- {napoln-0.2.9 → napoln-0.2.10}/tests/unit/test_merger.py +0 -0
- {napoln-0.2.9 → napoln-0.2.10}/tests/unit/test_resolve_and_store.py +0 -0
- {napoln-0.2.9 → napoln-0.2.10}/tests/unit/test_store.py +0 -0
- {napoln-0.2.9 → napoln-0.2.10}/tests/unit/test_validator.py +0 -0
- {napoln-0.2.9 → napoln-0.2.10}/uv.lock +0 -0
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.2.10](https://github.com/raiderrobert/napoln/compare/v0.2.9...v0.2.10) (2026-04-25)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* add Hermes agent support ([e8745e1](https://github.com/raiderrobert/napoln/commit/e8745e19a29c7135014d4dc7e93798ea46079dc3))
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* write manifest atomically via temp + rename ([#63](https://github.com/raiderrobert/napoln/issues/63)) ([7751e0f](https://github.com/raiderrobert/napoln/commit/7751e0fa796353b9833f74ae152419055caffdd1)), closes [#20](https://github.com/raiderrobert/napoln/issues/20)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
### Performance Improvements
|
|
17
|
+
|
|
18
|
+
* scope and throttle git fetches in resolve_git ([#66](https://github.com/raiderrobert/napoln/issues/66)) ([6c4d0da](https://github.com/raiderrobert/napoln/commit/6c4d0daee3afa975252c57b988de13a7c7684bbe)), closes [#25](https://github.com/raiderrobert/napoln/issues/25)
|
|
19
|
+
|
|
3
20
|
## [0.2.9](https://github.com/raiderrobert/napoln/compare/v0.2.8...v0.2.9) (2026-04-22)
|
|
4
21
|
|
|
5
22
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"""Agent detection and path configuration.
|
|
2
2
|
|
|
3
|
-
Supports: Claude Code, Gemini CLI, pi, Codex, Cursor.
|
|
3
|
+
Supports: Claude Code, Gemini CLI, pi, Codex, Cursor, Hermes.
|
|
4
4
|
"""
|
|
5
5
|
|
|
6
6
|
from __future__ import annotations
|
|
@@ -66,6 +66,12 @@ AGENTS: dict[str, AgentConfig] = {
|
|
|
66
66
|
global_skill_dir=".cursor/skills",
|
|
67
67
|
project_skill_dir=".agents/skills",
|
|
68
68
|
),
|
|
69
|
+
"hermes": AgentConfig(
|
|
70
|
+
id="hermes",
|
|
71
|
+
display_name="Hermes",
|
|
72
|
+
global_skill_dir=".hermes/skills",
|
|
73
|
+
project_skill_dir=".hermes/skills",
|
|
74
|
+
),
|
|
69
75
|
}
|
|
70
76
|
|
|
71
77
|
|
|
@@ -90,6 +96,7 @@ def detect_agents(
|
|
|
90
96
|
- pi: ~/.pi/ exists OR `pi` on PATH
|
|
91
97
|
- Codex: `codex` on PATH
|
|
92
98
|
- Cursor: ~/.cursor/ exists
|
|
99
|
+
- Hermes: ~/.hermes/ exists OR `hermes` on PATH
|
|
93
100
|
|
|
94
101
|
For project scope, checks for agent directories in project root.
|
|
95
102
|
|
|
@@ -118,6 +125,9 @@ def detect_agents(
|
|
|
118
125
|
|
|
119
126
|
if _check_dir_exists(home / ".cursor"):
|
|
120
127
|
detected.append(AGENTS["cursor"])
|
|
128
|
+
|
|
129
|
+
if _check_dir_exists(home / ".hermes") or _check_on_path("hermes"):
|
|
130
|
+
detected.append(AGENTS["hermes"])
|
|
121
131
|
elif scope == "project" and project_root:
|
|
122
132
|
if _check_dir_exists(project_root / ".claude"):
|
|
123
133
|
detected.append(AGENTS["claude-code"])
|
|
@@ -135,6 +145,9 @@ def detect_agents(
|
|
|
135
145
|
if AGENTS["cursor"] not in detected:
|
|
136
146
|
detected.append(AGENTS["cursor"])
|
|
137
147
|
|
|
148
|
+
if _check_dir_exists(project_root / ".hermes"):
|
|
149
|
+
detected.append(AGENTS["hermes"])
|
|
150
|
+
|
|
138
151
|
return detected
|
|
139
152
|
|
|
140
153
|
|
|
@@ -6,6 +6,7 @@ Located at ~/.napoln/manifest.toml (global) or .napoln/manifest.toml (project).
|
|
|
6
6
|
|
|
7
7
|
from __future__ import annotations
|
|
8
8
|
|
|
9
|
+
import os
|
|
9
10
|
import tomllib
|
|
10
11
|
from dataclasses import dataclass, field
|
|
11
12
|
from datetime import datetime, timezone
|
|
@@ -136,7 +137,18 @@ def write_manifest(manifest: Manifest, path: Path) -> None:
|
|
|
136
137
|
|
|
137
138
|
data["skills"][name] = skill_data
|
|
138
139
|
|
|
139
|
-
|
|
140
|
+
serialized = tomli_w.dumps(data)
|
|
141
|
+
tmp_path = path.parent / f".{path.name}.tmp"
|
|
142
|
+
try:
|
|
143
|
+
tmp_path.write_text(serialized, encoding="utf-8")
|
|
144
|
+
os.replace(tmp_path, path)
|
|
145
|
+
except Exception:
|
|
146
|
+
if tmp_path.exists():
|
|
147
|
+
try:
|
|
148
|
+
tmp_path.unlink()
|
|
149
|
+
except OSError:
|
|
150
|
+
pass
|
|
151
|
+
raise
|
|
140
152
|
|
|
141
153
|
|
|
142
154
|
def add_skill_to_manifest(
|
|
@@ -8,6 +8,7 @@ from __future__ import annotations
|
|
|
8
8
|
import re
|
|
9
9
|
import shutil
|
|
10
10
|
import subprocess
|
|
11
|
+
import time
|
|
11
12
|
from dataclasses import dataclass
|
|
12
13
|
from pathlib import Path
|
|
13
14
|
|
|
@@ -35,6 +36,26 @@ _DOMAIN_PATH = re.compile(
|
|
|
35
36
|
)
|
|
36
37
|
_SEMVER_TAG = re.compile(r"^v?(\d+\.\d+\.\d+(?:-.+)?)$")
|
|
37
38
|
|
|
39
|
+
# Cached git fetches are considered fresh within this many seconds.
|
|
40
|
+
_FETCH_THROTTLE_SECONDS = 300
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def _fetch_sentinel(cache_dir: Path, owner: str, repo: str) -> Path:
|
|
44
|
+
"""Return the path to the last-fetch marker for a cached clone."""
|
|
45
|
+
return cache_dir / f".{owner}-{repo}.last-fetch"
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def _should_fetch(sentinel: Path, now: float | None = None) -> bool:
|
|
49
|
+
"""Return True if the cached clone's fetch marker is missing or stale."""
|
|
50
|
+
if not sentinel.exists():
|
|
51
|
+
return True
|
|
52
|
+
try:
|
|
53
|
+
mtime = sentinel.stat().st_mtime
|
|
54
|
+
except OSError:
|
|
55
|
+
return True
|
|
56
|
+
current = time.time() if now is None else now
|
|
57
|
+
return (current - mtime) >= _FETCH_THROTTLE_SECONDS
|
|
58
|
+
|
|
38
59
|
|
|
39
60
|
@dataclass
|
|
40
61
|
class ParsedSource:
|
|
@@ -222,16 +243,20 @@ def resolve_git(
|
|
|
222
243
|
|
|
223
244
|
repo_url = f"https://{parsed.host}/{parsed.owner}/{parsed.repo}.git"
|
|
224
245
|
clone_dir = cache_dir / f"{parsed.owner}-{parsed.repo}"
|
|
246
|
+
sentinel = _fetch_sentinel(cache_dir, parsed.owner, parsed.repo)
|
|
225
247
|
|
|
226
248
|
try:
|
|
227
249
|
if clone_dir.exists():
|
|
228
|
-
#
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
250
|
+
# Refresh the existing clone, but throttle to avoid a fetch per
|
|
251
|
+
# add/upgrade on large repos.
|
|
252
|
+
if _should_fetch(sentinel):
|
|
253
|
+
subprocess.run(
|
|
254
|
+
["git", "fetch", "origin", "--tags"],
|
|
255
|
+
cwd=str(clone_dir),
|
|
256
|
+
capture_output=True,
|
|
257
|
+
check=True,
|
|
258
|
+
)
|
|
259
|
+
sentinel.touch()
|
|
235
260
|
else:
|
|
236
261
|
# Fresh clone
|
|
237
262
|
clone_dir.mkdir(parents=True, exist_ok=True)
|
|
@@ -240,6 +265,7 @@ def resolve_git(
|
|
|
240
265
|
capture_output=True,
|
|
241
266
|
check=True,
|
|
242
267
|
)
|
|
268
|
+
sentinel.touch()
|
|
243
269
|
except subprocess.CalledProcessError as e:
|
|
244
270
|
raise ResolverError(
|
|
245
271
|
f"Failed to clone {repo_url}",
|
|
@@ -21,6 +21,7 @@ class TestAgentConfig:
|
|
|
21
21
|
("pi", ".agents/skills"),
|
|
22
22
|
("codex", ".agents/skills"),
|
|
23
23
|
("cursor", ".cursor/skills"),
|
|
24
|
+
("hermes", ".hermes/skills"),
|
|
24
25
|
],
|
|
25
26
|
)
|
|
26
27
|
def test_global_paths(self, tmp_path, agent_id, global_dir):
|
|
@@ -36,6 +37,7 @@ class TestAgentConfig:
|
|
|
36
37
|
("pi", ".agents/skills"),
|
|
37
38
|
("codex", ".agents/skills"),
|
|
38
39
|
("cursor", ".agents/skills"),
|
|
40
|
+
("hermes", ".hermes/skills"),
|
|
39
41
|
],
|
|
40
42
|
)
|
|
41
43
|
def test_project_paths(self, tmp_path, agent_id, project_dir):
|
|
@@ -65,6 +67,7 @@ class TestDetectAgents:
|
|
|
65
67
|
(".gemini", "gemini-cli"),
|
|
66
68
|
(".pi", "pi"),
|
|
67
69
|
(".cursor", "cursor"),
|
|
70
|
+
(".hermes", "hermes"),
|
|
68
71
|
],
|
|
69
72
|
)
|
|
70
73
|
def test_detects_agent_by_config_dir(self, tmp_path, dot_dir, expected_agent_id):
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
"""Tests for napoln.core.manifest — manifest TOML read/write."""
|
|
2
2
|
|
|
3
|
+
import pytest
|
|
4
|
+
|
|
3
5
|
from napoln.core.manifest import (
|
|
4
6
|
AgentPlacement,
|
|
5
7
|
Manifest,
|
|
@@ -77,6 +79,52 @@ class TestReadWriteManifest:
|
|
|
77
79
|
write_manifest(Manifest(), path)
|
|
78
80
|
assert path.exists()
|
|
79
81
|
|
|
82
|
+
def test_atomic_write_preserves_prior_contents_on_failure(self, tmp_path, monkeypatch):
|
|
83
|
+
"""If the write is interrupted mid-stream, the original manifest must survive."""
|
|
84
|
+
from pathlib import Path as _Path
|
|
85
|
+
|
|
86
|
+
path = tmp_path / "manifest.toml"
|
|
87
|
+
|
|
88
|
+
# Seed a known-good manifest.
|
|
89
|
+
original = Manifest()
|
|
90
|
+
original.skills["alpha"] = SkillEntry(
|
|
91
|
+
source="local/alpha",
|
|
92
|
+
version="1.0.0",
|
|
93
|
+
store_hash="abc1234",
|
|
94
|
+
installed="2026-04-14T10:00:00Z",
|
|
95
|
+
updated="2026-04-14T10:00:00Z",
|
|
96
|
+
)
|
|
97
|
+
write_manifest(original, path)
|
|
98
|
+
original_bytes = path.read_bytes()
|
|
99
|
+
|
|
100
|
+
# Simulate an interruption: the bytes have started to land on disk,
|
|
101
|
+
# but the write does not complete. A non-atomic writer clobbers the
|
|
102
|
+
# target; an atomic writer must leave the target untouched.
|
|
103
|
+
real_write_text = _Path.write_text
|
|
104
|
+
|
|
105
|
+
def failing_write_text(self, data, *args, **kwargs):
|
|
106
|
+
# Write a truncated prefix, then raise to mimic a killed process.
|
|
107
|
+
real_write_text(self, data[: len(data) // 2], *args, **kwargs)
|
|
108
|
+
raise RuntimeError("simulated interruption")
|
|
109
|
+
|
|
110
|
+
monkeypatch.setattr(_Path, "write_text", failing_write_text)
|
|
111
|
+
|
|
112
|
+
replacement = Manifest()
|
|
113
|
+
replacement.skills["beta"] = SkillEntry(
|
|
114
|
+
source="local/beta",
|
|
115
|
+
version="2.0.0",
|
|
116
|
+
store_hash="def5678",
|
|
117
|
+
installed="2026-04-14T11:00:00Z",
|
|
118
|
+
updated="2026-04-14T11:00:00Z",
|
|
119
|
+
)
|
|
120
|
+
with pytest.raises(RuntimeError, match="simulated interruption"):
|
|
121
|
+
write_manifest(replacement, path)
|
|
122
|
+
|
|
123
|
+
# Target must still contain the original contents and no stray temp file.
|
|
124
|
+
assert path.read_bytes() == original_bytes
|
|
125
|
+
leftovers = sorted(p.name for p in tmp_path.iterdir() if p.name != "manifest.toml")
|
|
126
|
+
assert leftovers == [], f"unexpected files: {leftovers}"
|
|
127
|
+
|
|
80
128
|
|
|
81
129
|
class TestAddSkillToManifest:
|
|
82
130
|
"""Adding skills to the manifest."""
|
|
@@ -1,8 +1,17 @@
|
|
|
1
1
|
"""Tests for napoln.core.resolver — source parsing and resolution."""
|
|
2
2
|
|
|
3
|
+
import subprocess
|
|
4
|
+
|
|
3
5
|
import pytest
|
|
4
6
|
|
|
5
|
-
from napoln.core
|
|
7
|
+
from napoln.core import resolver
|
|
8
|
+
from napoln.core.resolver import (
|
|
9
|
+
ParsedSource,
|
|
10
|
+
_fetch_sentinel,
|
|
11
|
+
_should_fetch,
|
|
12
|
+
parse_source,
|
|
13
|
+
resolve_local,
|
|
14
|
+
)
|
|
6
15
|
from napoln.errors import ResolverError
|
|
7
16
|
|
|
8
17
|
|
|
@@ -186,3 +195,100 @@ class TestResolveLocal:
|
|
|
186
195
|
|
|
187
196
|
resolved = resolve_local(_local_parsed(skill_dir))
|
|
188
197
|
assert resolved.version == "0.0.0"
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
class TestShouldFetch:
|
|
201
|
+
"""Throttle decision for cached git fetches."""
|
|
202
|
+
|
|
203
|
+
def test_missing_sentinel_triggers_fetch(self, tmp_path):
|
|
204
|
+
assert _should_fetch(tmp_path / ".missing") is True
|
|
205
|
+
|
|
206
|
+
def test_recent_sentinel_skips_fetch(self, tmp_path):
|
|
207
|
+
sentinel = tmp_path / ".last-fetch"
|
|
208
|
+
sentinel.touch()
|
|
209
|
+
assert _should_fetch(sentinel, now=sentinel.stat().st_mtime + 10) is False
|
|
210
|
+
|
|
211
|
+
def test_stale_sentinel_triggers_fetch(self, tmp_path):
|
|
212
|
+
sentinel = tmp_path / ".last-fetch"
|
|
213
|
+
sentinel.touch()
|
|
214
|
+
assert _should_fetch(sentinel, now=sentinel.stat().st_mtime + 3600) is True
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
class TestResolveGitFetch:
|
|
218
|
+
"""resolve_git fetch scope and throttling."""
|
|
219
|
+
|
|
220
|
+
@pytest.fixture
|
|
221
|
+
def git_parsed(self):
|
|
222
|
+
return ParsedSource(
|
|
223
|
+
source_type="git",
|
|
224
|
+
host="github.com",
|
|
225
|
+
owner="owner",
|
|
226
|
+
repo="repo",
|
|
227
|
+
path="",
|
|
228
|
+
version="main",
|
|
229
|
+
original="owner/repo@main",
|
|
230
|
+
)
|
|
231
|
+
|
|
232
|
+
@pytest.fixture
|
|
233
|
+
def populated_cache(self, tmp_path, git_parsed):
|
|
234
|
+
"""A cache dir with an already-cloned repo containing a SKILL.md."""
|
|
235
|
+
cache_dir = tmp_path / "cache"
|
|
236
|
+
clone_dir = cache_dir / f"{git_parsed.owner}-{git_parsed.repo}"
|
|
237
|
+
clone_dir.mkdir(parents=True)
|
|
238
|
+
(clone_dir / "SKILL.md").write_text("---\nname: repo\ndescription: x\n---\n# Hi")
|
|
239
|
+
return cache_dir, clone_dir
|
|
240
|
+
|
|
241
|
+
def _install_fake_git(self, monkeypatch, calls):
|
|
242
|
+
monkeypatch.setattr(resolver.shutil, "which", lambda _: "/usr/bin/git")
|
|
243
|
+
|
|
244
|
+
def fake_run(cmd, *_args, **_kwargs):
|
|
245
|
+
calls.append(list(cmd))
|
|
246
|
+
return subprocess.CompletedProcess(cmd, 0, stdout=b"", stderr=b"")
|
|
247
|
+
|
|
248
|
+
monkeypatch.setattr(resolver.subprocess, "run", fake_run)
|
|
249
|
+
|
|
250
|
+
def test_fetch_uses_origin_not_all_and_writes_sentinel(
|
|
251
|
+
self, monkeypatch, git_parsed, populated_cache
|
|
252
|
+
):
|
|
253
|
+
cache_dir, _ = populated_cache
|
|
254
|
+
calls: list[list[str]] = []
|
|
255
|
+
self._install_fake_git(monkeypatch, calls)
|
|
256
|
+
|
|
257
|
+
resolver.resolve_git(git_parsed, cache_dir)
|
|
258
|
+
|
|
259
|
+
fetch_calls = [c for c in calls if c[:2] == ["git", "fetch"]]
|
|
260
|
+
assert fetch_calls == [["git", "fetch", "origin", "--tags"]]
|
|
261
|
+
assert _fetch_sentinel(cache_dir, git_parsed.owner, git_parsed.repo).exists()
|
|
262
|
+
|
|
263
|
+
def test_second_resolve_within_throttle_skips_fetch(
|
|
264
|
+
self, monkeypatch, git_parsed, populated_cache
|
|
265
|
+
):
|
|
266
|
+
cache_dir, _ = populated_cache
|
|
267
|
+
calls: list[list[str]] = []
|
|
268
|
+
self._install_fake_git(monkeypatch, calls)
|
|
269
|
+
|
|
270
|
+
resolver.resolve_git(git_parsed, cache_dir)
|
|
271
|
+
fetch_count_after_first = sum(1 for c in calls if c[:2] == ["git", "fetch"])
|
|
272
|
+
resolver.resolve_git(git_parsed, cache_dir)
|
|
273
|
+
fetch_count_after_second = sum(1 for c in calls if c[:2] == ["git", "fetch"])
|
|
274
|
+
|
|
275
|
+
assert fetch_count_after_first == 1
|
|
276
|
+
assert fetch_count_after_second == 1 # second call reused the cache
|
|
277
|
+
|
|
278
|
+
def test_stale_sentinel_re_fetches(self, monkeypatch, git_parsed, populated_cache):
|
|
279
|
+
cache_dir, _ = populated_cache
|
|
280
|
+
calls: list[list[str]] = []
|
|
281
|
+
self._install_fake_git(monkeypatch, calls)
|
|
282
|
+
|
|
283
|
+
resolver.resolve_git(git_parsed, cache_dir)
|
|
284
|
+
|
|
285
|
+
sentinel = _fetch_sentinel(cache_dir, git_parsed.owner, git_parsed.repo)
|
|
286
|
+
import os as _os
|
|
287
|
+
|
|
288
|
+
old = sentinel.stat().st_mtime - (resolver._FETCH_THROTTLE_SECONDS + 60)
|
|
289
|
+
_os.utime(sentinel, (old, old))
|
|
290
|
+
|
|
291
|
+
resolver.resolve_git(git_parsed, cache_dir)
|
|
292
|
+
|
|
293
|
+
fetch_calls = [c for c in calls if c[:2] == ["git", "fetch"]]
|
|
294
|
+
assert len(fetch_calls) == 2
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|