napoln 0.2.8__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.
Files changed (79) hide show
  1. {napoln-0.2.8 → napoln-0.2.10}/.gitignore +3 -0
  2. napoln-0.2.10/.release-please-manifest.json +3 -0
  3. {napoln-0.2.8 → napoln-0.2.10}/CHANGELOG.md +24 -0
  4. {napoln-0.2.8 → napoln-0.2.10}/PKG-INFO +9 -1
  5. {napoln-0.2.8 → napoln-0.2.10}/README.md +8 -0
  6. {napoln-0.2.8 → napoln-0.2.10}/pyproject.toml +1 -1
  7. {napoln-0.2.8 → napoln-0.2.10}/src/napoln/__init__.py +1 -1
  8. {napoln-0.2.8 → napoln-0.2.10}/src/napoln/commands/add.py +2 -7
  9. {napoln-0.2.8 → napoln-0.2.10}/src/napoln/commands/config.py +5 -10
  10. {napoln-0.2.8 → napoln-0.2.10}/src/napoln/commands/install.py +3 -8
  11. {napoln-0.2.8 → napoln-0.2.10}/src/napoln/commands/list_cmd.py +2 -7
  12. {napoln-0.2.8 → napoln-0.2.10}/src/napoln/commands/remove.py +2 -7
  13. {napoln-0.2.8 → napoln-0.2.10}/src/napoln/commands/setup.py +2 -5
  14. {napoln-0.2.8 → napoln-0.2.10}/src/napoln/commands/upgrade.py +2 -7
  15. {napoln-0.2.8 → napoln-0.2.10}/src/napoln/core/agents.py +14 -1
  16. napoln-0.2.10/src/napoln/core/home.py +15 -0
  17. {napoln-0.2.8 → napoln-0.2.10}/src/napoln/core/manifest.py +13 -1
  18. {napoln-0.2.8 → napoln-0.2.10}/src/napoln/core/resolver.py +33 -7
  19. {napoln-0.2.8 → napoln-0.2.10}/tests/unit/test_agents.py +3 -0
  20. {napoln-0.2.8 → napoln-0.2.10}/tests/unit/test_manifest.py +48 -0
  21. {napoln-0.2.8 → napoln-0.2.10}/tests/unit/test_resolver.py +107 -1
  22. napoln-0.2.8/.release-please-manifest.json +0 -3
  23. {napoln-0.2.8 → napoln-0.2.10}/.github/workflows/ci.yml +0 -0
  24. {napoln-0.2.8 → napoln-0.2.10}/.github/workflows/pr-title.yml +0 -0
  25. {napoln-0.2.8 → napoln-0.2.10}/.github/workflows/release-please.yml +0 -0
  26. {napoln-0.2.8 → napoln-0.2.10}/.github/workflows/release.yml +0 -0
  27. {napoln-0.2.8 → napoln-0.2.10}/AGENTS.md +0 -0
  28. {napoln-0.2.8 → napoln-0.2.10}/ARCHITECTURE.md +0 -0
  29. {napoln-0.2.8 → napoln-0.2.10}/CLAUDE.md +0 -0
  30. {napoln-0.2.8 → napoln-0.2.10}/CONTRIBUTING.md +0 -0
  31. {napoln-0.2.8 → napoln-0.2.10}/LICENSE +0 -0
  32. {napoln-0.2.8 → napoln-0.2.10}/justfile +0 -0
  33. {napoln-0.2.8 → napoln-0.2.10}/napoln-demo.gif +0 -0
  34. {napoln-0.2.8 → napoln-0.2.10}/release-please-config.json +0 -0
  35. {napoln-0.2.8 → napoln-0.2.10}/skills-lock.json +0 -0
  36. {napoln-0.2.8 → napoln-0.2.10}/src/napoln/cli.py +0 -0
  37. {napoln-0.2.8 → napoln-0.2.10}/src/napoln/commands/__init__.py +0 -0
  38. {napoln-0.2.8 → napoln-0.2.10}/src/napoln/commands/init.py +0 -0
  39. {napoln-0.2.8 → napoln-0.2.10}/src/napoln/core/__init__.py +0 -0
  40. {napoln-0.2.8 → napoln-0.2.10}/src/napoln/core/hasher.py +0 -0
  41. {napoln-0.2.8 → napoln-0.2.10}/src/napoln/core/linker.py +0 -0
  42. {napoln-0.2.8 → napoln-0.2.10}/src/napoln/core/merger.py +0 -0
  43. {napoln-0.2.8 → napoln-0.2.10}/src/napoln/core/store.py +0 -0
  44. {napoln-0.2.8 → napoln-0.2.10}/src/napoln/core/validator.py +0 -0
  45. {napoln-0.2.8 → napoln-0.2.10}/src/napoln/errors.py +0 -0
  46. {napoln-0.2.8 → napoln-0.2.10}/src/napoln/output.py +0 -0
  47. {napoln-0.2.8 → napoln-0.2.10}/src/napoln/prompts.py +0 -0
  48. {napoln-0.2.8 → napoln-0.2.10}/src/napoln/skills/napoln-manage/SKILL.md +0 -0
  49. {napoln-0.2.8 → napoln-0.2.10}/tests/__init__.py +0 -0
  50. {napoln-0.2.8 → napoln-0.2.10}/tests/conftest.py +0 -0
  51. {napoln-0.2.8 → napoln-0.2.10}/tests/features/config.feature +0 -0
  52. {napoln-0.2.8 → napoln-0.2.10}/tests/features/first_run.feature +0 -0
  53. {napoln-0.2.8 → napoln-0.2.10}/tests/features/init.feature +0 -0
  54. {napoln-0.2.8 → napoln-0.2.10}/tests/features/install.feature +0 -0
  55. {napoln-0.2.8 → napoln-0.2.10}/tests/features/list.feature +0 -0
  56. {napoln-0.2.8 → napoln-0.2.10}/tests/features/setup.feature +0 -0
  57. {napoln-0.2.8 → napoln-0.2.10}/tests/features/upgrade.feature +0 -0
  58. {napoln-0.2.8 → napoln-0.2.10}/tests/fixtures/invalid-skill/SKILL.md +0 -0
  59. {napoln-0.2.8 → napoln-0.2.10}/tests/fixtures/multi-skill-repo/README.md +0 -0
  60. {napoln-0.2.8 → napoln-0.2.10}/tests/fixtures/multi-skill-repo/skills/skill-a/SKILL.md +0 -0
  61. {napoln-0.2.8 → napoln-0.2.10}/tests/fixtures/multi-skill-repo/skills/skill-b/SKILL.md +0 -0
  62. {napoln-0.2.8 → napoln-0.2.10}/tests/fixtures/valid-skill/SKILL.md +0 -0
  63. {napoln-0.2.8 → napoln-0.2.10}/tests/integration/test_cli.py +0 -0
  64. {napoln-0.2.8 → napoln-0.2.10}/tests/steps/__init__.py +0 -0
  65. {napoln-0.2.8 → napoln-0.2.10}/tests/steps/conftest.py +0 -0
  66. {napoln-0.2.8 → napoln-0.2.10}/tests/steps/test_config.py +0 -0
  67. {napoln-0.2.8 → napoln-0.2.10}/tests/steps/test_first_run.py +0 -0
  68. {napoln-0.2.8 → napoln-0.2.10}/tests/steps/test_init.py +0 -0
  69. {napoln-0.2.8 → napoln-0.2.10}/tests/steps/test_install.py +0 -0
  70. {napoln-0.2.8 → napoln-0.2.10}/tests/steps/test_list.py +0 -0
  71. {napoln-0.2.8 → napoln-0.2.10}/tests/steps/test_setup.py +0 -0
  72. {napoln-0.2.8 → napoln-0.2.10}/tests/steps/test_upgrade.py +0 -0
  73. {napoln-0.2.8 → napoln-0.2.10}/tests/unit/test_hasher.py +0 -0
  74. {napoln-0.2.8 → napoln-0.2.10}/tests/unit/test_linker.py +0 -0
  75. {napoln-0.2.8 → napoln-0.2.10}/tests/unit/test_merger.py +0 -0
  76. {napoln-0.2.8 → napoln-0.2.10}/tests/unit/test_resolve_and_store.py +0 -0
  77. {napoln-0.2.8 → napoln-0.2.10}/tests/unit/test_store.py +0 -0
  78. {napoln-0.2.8 → napoln-0.2.10}/tests/unit/test_validator.py +0 -0
  79. {napoln-0.2.8 → napoln-0.2.10}/uv.lock +0 -0
@@ -25,3 +25,6 @@ Thumbs.db
25
25
  .coverage
26
26
  .pytest_cache/
27
27
  .napoln/
28
+
29
+ # Local worktrees
30
+ .worktrees/
@@ -0,0 +1,3 @@
1
+ {
2
+ ".": "0.2.10"
3
+ }
@@ -1,5 +1,29 @@
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
+
20
+ ## [0.2.9](https://github.com/raiderrobert/napoln/compare/v0.2.8...v0.2.9) (2026-04-22)
21
+
22
+
23
+ ### Documentation
24
+
25
+ * clarify one SKILL.md serves every agent ([#41](https://github.com/raiderrobert/napoln/issues/41)) ([9e130aa](https://github.com/raiderrobert/napoln/commit/9e130aa41cea29b802b5916949868b8f4f81de00)), closes [#10](https://github.com/raiderrobert/napoln/issues/10)
26
+
3
27
  ## [0.2.8](https://github.com/raiderrobert/napoln/compare/v0.2.7...v0.2.8) (2026-04-22)
4
28
 
5
29
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: napoln
3
- Version: 0.2.8
3
+ Version: 0.2.10
4
4
  Summary: A package manager for agent skills
5
5
  License-Expression: MIT
6
6
  License-File: LICENSE
@@ -147,6 +147,14 @@ All mutating commands support `--dry-run`. Use `-p` for project scope on any com
147
147
 
148
148
  Gemini CLI, pi, and Codex share `~/.agents/skills/` — one placement serves all three.
149
149
 
150
+ ### One SKILL.md for every agent
151
+
152
+ A skill is a single `SKILL.md` file. Every supported agent reads the same file;
153
+ napoln does not fork or transform it per agent. Agent-specific frontmatter
154
+ fields are optional, and each agent ignores the fields it does not understand.
155
+ Skill authors should keep one canonical `SKILL.md` per skill rather than
156
+ maintaining per-agent variants.
157
+
150
158
  ## Team Workflow
151
159
 
152
160
  Install with `--project` and commit the manifest:
@@ -126,6 +126,14 @@ All mutating commands support `--dry-run`. Use `-p` for project scope on any com
126
126
 
127
127
  Gemini CLI, pi, and Codex share `~/.agents/skills/` — one placement serves all three.
128
128
 
129
+ ### One SKILL.md for every agent
130
+
131
+ A skill is a single `SKILL.md` file. Every supported agent reads the same file;
132
+ napoln does not fork or transform it per agent. Agent-specific frontmatter
133
+ fields are optional, and each agent ignores the fields it does not understand.
134
+ Skill authors should keep one canonical `SKILL.md` per skill rather than
135
+ maintaining per-agent variants.
136
+
129
137
  ## Team Workflow
130
138
 
131
139
  Install with `--project` and commit the manifest:
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "napoln"
3
- version = "0.2.8"
3
+ version = "0.2.10"
4
4
  description = "A package manager for agent skills"
5
5
  readme = "README.md"
6
6
  license = "MIT"
@@ -1,3 +1,3 @@
1
1
  """napoln — A package manager for agent skills."""
2
2
 
3
- __version__ = "0.2.8"
3
+ __version__ = "0.2.10"
@@ -8,6 +8,7 @@ from typing import cast
8
8
  from napoln import output
9
9
  from napoln.core import agents as agents_mod
10
10
  from napoln.core import linker, manifest, store, validator
11
+ from napoln.core.home import get_napoln_home
11
12
  from napoln.core.resolver import (
12
13
  ParsedSource,
13
14
  ResolvedSource,
@@ -21,12 +22,6 @@ from napoln.errors import MultipleSkillsError, ResolverError
21
22
  from napoln.prompts import SkillChoice, pick_skills
22
23
 
23
24
 
24
- def _get_napoln_home() -> Path:
25
- import os
26
-
27
- return Path(os.environ.get("NAPOLN_HOME", Path.home() / ".napoln"))
28
-
29
-
30
25
  def _ensure_initialized(napoln_home: Path) -> None:
31
26
  """Ensure napoln home directory structure exists."""
32
27
  napoln_home.mkdir(parents=True, exist_ok=True)
@@ -279,7 +274,7 @@ def run_add(
279
274
  """
280
275
  import os
281
276
 
282
- napoln_home = _get_napoln_home()
277
+ napoln_home = get_napoln_home()
283
278
  home = Path(os.environ.get("HOME", Path.home()))
284
279
 
285
280
  _ensure_initialized(napoln_home)
@@ -11,12 +11,7 @@ import tomli_w
11
11
  from napoln import output
12
12
  from napoln.core import agents as agents_mod
13
13
  from napoln.core import manifest, store
14
-
15
-
16
- def _get_napoln_home() -> Path:
17
- import os
18
-
19
- return Path(os.environ.get("NAPOLN_HOME", Path.home() / ".napoln"))
14
+ from napoln.core.home import get_napoln_home
20
15
 
21
16
 
22
17
  # ─── config (bare) ───────────────────────────────────────────────────────────
@@ -26,7 +21,7 @@ def run_config_show() -> int:
26
21
  """Show current configuration: home, store, agents, manifests."""
27
22
  import os
28
23
 
29
- napoln_home = _get_napoln_home()
24
+ napoln_home = get_napoln_home()
30
25
  home = Path(os.environ.get("HOME", Path.home()))
31
26
 
32
27
  output.header("napoln config")
@@ -77,7 +72,7 @@ def run_config_set(key: str, value: str) -> int:
77
72
 
78
73
  Keys use dot notation: e.g., "napoln.default_scope"
79
74
  """
80
- napoln_home = _get_napoln_home()
75
+ napoln_home = get_napoln_home()
81
76
  config_path = napoln_home / "config.toml"
82
77
 
83
78
  if config_path.exists():
@@ -128,7 +123,7 @@ def run_config_doctor(
128
123
  json_output: bool = False,
129
124
  ) -> int:
130
125
  """Health check: store integrity, placements, provenance, git."""
131
- napoln_home = _get_napoln_home()
126
+ napoln_home = get_napoln_home()
132
127
  manifest_path = manifest.get_manifest_path(napoln_home, scope, project_root)
133
128
 
134
129
  issues: list[dict] = []
@@ -253,7 +248,7 @@ def run_config_doctor(
253
248
 
254
249
  def run_config_gc(dry_run: bool = False) -> int:
255
250
  """Remove unreferenced store entries."""
256
- napoln_home = _get_napoln_home()
251
+ napoln_home = get_napoln_home()
257
252
 
258
253
  # Collect all referenced store entries from both manifests
259
254
  referenced: set[str] = set()
@@ -6,15 +6,10 @@ from pathlib import Path
6
6
 
7
7
  from napoln import output
8
8
  from napoln.core import linker, manifest, store
9
+ from napoln.core.home import get_napoln_home
9
10
  from napoln.errors import NapolnError
10
11
 
11
12
 
12
- def _get_napoln_home() -> Path:
13
- import os
14
-
15
- return Path(os.environ.get("NAPOLN_HOME", Path.home() / ".napoln"))
16
-
17
-
18
13
  def _sync_manifest(
19
14
  mf: manifest.Manifest,
20
15
  label: str,
@@ -27,7 +22,7 @@ def _sync_manifest(
27
22
  """
28
23
  synced = 0
29
24
  errors = 0
30
- napoln_home = _get_napoln_home()
25
+ napoln_home = get_napoln_home()
31
26
 
32
27
  for skill_name, entry in sorted(mf.skills.items()):
33
28
  try:
@@ -75,7 +70,7 @@ def run_install(
75
70
  Returns:
76
71
  Exit code (0=success, 1=errors).
77
72
  """
78
- napoln_home = _get_napoln_home()
73
+ napoln_home = get_napoln_home()
79
74
 
80
75
  if dry_run:
81
76
  output.dry_run_header()
@@ -6,12 +6,7 @@ from pathlib import Path
6
6
 
7
7
  from napoln import output
8
8
  from napoln.core import manifest
9
-
10
-
11
- def _get_napoln_home() -> Path:
12
- import os
13
-
14
- return Path(os.environ.get("NAPOLN_HOME", Path.home() / ".napoln"))
9
+ from napoln.core.home import get_napoln_home
15
10
 
16
11
 
17
12
  def _abbreviate_path(path: str, home: str) -> str:
@@ -204,7 +199,7 @@ def run_list(
204
199
  Returns:
205
200
  Exit code (0=always).
206
201
  """
207
- napoln_home = _get_napoln_home()
202
+ napoln_home = get_napoln_home()
208
203
 
209
204
  global_mf: manifest.Manifest | None = None
210
205
  project_mf: manifest.Manifest | None = None
@@ -7,15 +7,10 @@ from pathlib import Path
7
7
 
8
8
  from napoln import output
9
9
  from napoln.core import manifest
10
+ from napoln.core.home import get_napoln_home
10
11
  from napoln.core.resolver import normalize_source_for_match
11
12
 
12
13
 
13
- def _get_napoln_home() -> Path:
14
- import os
15
-
16
- return Path(os.environ.get("NAPOLN_HOME", Path.home() / ".napoln"))
17
-
18
-
19
14
  def _resolve_from_source(
20
15
  from_source: str,
21
16
  mf: manifest.Manifest,
@@ -61,7 +56,7 @@ def run_remove(
61
56
  Returns:
62
57
  Exit code (0=success, 1=error).
63
58
  """
64
- napoln_home = _get_napoln_home()
59
+ napoln_home = get_napoln_home()
65
60
  manifest_path = manifest.get_manifest_path(napoln_home, scope, project_root)
66
61
  mf = manifest.read_manifest(manifest_path)
67
62
 
@@ -10,13 +10,10 @@ import tomli_w
10
10
 
11
11
  from napoln import output
12
12
  from napoln.core import agents as agents_mod
13
+ from napoln.core.home import get_napoln_home
13
14
  from napoln.prompts import pick_agents
14
15
 
15
16
 
16
- def _get_napoln_home() -> Path:
17
- return Path(os.environ.get("NAPOLN_HOME", Path.home() / ".napoln"))
18
-
19
-
20
17
  def _ensure_initialized(napoln_home: Path) -> None:
21
18
  napoln_home.mkdir(parents=True, exist_ok=True)
22
19
  (napoln_home / "store").mkdir(exist_ok=True)
@@ -53,7 +50,7 @@ def run_setup(force: bool = False) -> int:
53
50
  Returns:
54
51
  Exit code (0 on success, 1 on cancel/error).
55
52
  """
56
- napoln_home = _get_napoln_home()
53
+ napoln_home = get_napoln_home()
57
54
  home = Path(os.environ.get("HOME", Path.home()))
58
55
  config_path = napoln_home / "config.toml"
59
56
 
@@ -7,16 +7,11 @@ from typing import cast
7
7
 
8
8
  from napoln import output
9
9
  from napoln.core import linker, manifest, merger, store
10
+ from napoln.core.home import get_napoln_home
10
11
  from napoln.core.resolver import ResolvedSource, parse_source, resolve_git, resolve_local
11
12
  from napoln.errors import ResolverError
12
13
 
13
14
 
14
- def _get_napoln_home() -> Path:
15
- import os
16
-
17
- return Path(os.environ.get("NAPOLN_HOME", Path.home() / ".napoln"))
18
-
19
-
20
15
  def run_upgrade(
21
16
  name: str | None = None,
22
17
  version_constraint: str | None = None,
@@ -33,7 +28,7 @@ def run_upgrade(
33
28
  """
34
29
  import os
35
30
 
36
- napoln_home = _get_napoln_home()
31
+ napoln_home = get_napoln_home()
37
32
  home = Path(os.environ.get("HOME", Path.home()))
38
33
  manifest_path = manifest.get_manifest_path(napoln_home, scope, project_root)
39
34
  mf = manifest.read_manifest(manifest_path)
@@ -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
 
@@ -0,0 +1,15 @@
1
+ """Resolve the napoln home directory.
2
+
3
+ The home directory holds the store, cache, and global manifest.
4
+ Defaults to ~/.napoln/, overridable with NAPOLN_HOME.
5
+ """
6
+
7
+ from __future__ import annotations
8
+
9
+ import os
10
+ from pathlib import Path
11
+
12
+
13
+ def get_napoln_home() -> Path:
14
+ """Return the configured napoln home directory."""
15
+ return Path(os.environ.get("NAPOLN_HOME", Path.home() / ".napoln"))
@@ -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
- path.write_text(tomli_w.dumps(data), encoding="utf-8")
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
- # Update existing clone
229
- subprocess.run(
230
- ["git", "fetch", "--all", "--tags"],
231
- cwd=str(clone_dir),
232
- capture_output=True,
233
- check=True,
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.resolver import ParsedSource, parse_source, resolve_local
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
@@ -1,3 +0,0 @@
1
- {
2
- ".": "0.2.8"
3
- }
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