napoln 0.2.3__tar.gz → 0.2.4__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.4/.release-please-manifest.json +3 -0
- {napoln-0.2.3 → napoln-0.2.4}/CHANGELOG.md +7 -0
- {napoln-0.2.3 → napoln-0.2.4}/PKG-INFO +1 -1
- {napoln-0.2.3 → napoln-0.2.4}/pyproject.toml +1 -1
- {napoln-0.2.3 → napoln-0.2.4}/src/napoln/__init__.py +1 -1
- {napoln-0.2.3 → napoln-0.2.4}/src/napoln/cli.py +17 -0
- {napoln-0.2.3 → napoln-0.2.4}/src/napoln/commands/add.py +13 -2
- napoln-0.2.4/src/napoln/commands/setup.py +104 -0
- {napoln-0.2.3 → napoln-0.2.4}/src/napoln/core/agents.py +38 -4
- {napoln-0.2.3 → napoln-0.2.4}/src/napoln/prompts.py +57 -0
- napoln-0.2.4/tests/features/setup.feature +30 -0
- napoln-0.2.4/tests/steps/test_setup.py +130 -0
- napoln-0.2.3/.release-please-manifest.json +0 -3
- {napoln-0.2.3 → napoln-0.2.4}/.github/workflows/ci.yml +0 -0
- {napoln-0.2.3 → napoln-0.2.4}/.github/workflows/pr-title.yml +0 -0
- {napoln-0.2.3 → napoln-0.2.4}/.github/workflows/release-please.yml +0 -0
- {napoln-0.2.3 → napoln-0.2.4}/.github/workflows/release.yml +0 -0
- {napoln-0.2.3 → napoln-0.2.4}/.gitignore +0 -0
- {napoln-0.2.3 → napoln-0.2.4}/AGENTS.md +0 -0
- {napoln-0.2.3 → napoln-0.2.4}/ARCHITECTURE.md +0 -0
- {napoln-0.2.3 → napoln-0.2.4}/CONTRIBUTING.md +0 -0
- {napoln-0.2.3 → napoln-0.2.4}/LICENSE +0 -0
- {napoln-0.2.3 → napoln-0.2.4}/README.md +0 -0
- {napoln-0.2.3 → napoln-0.2.4}/SPEC.md +0 -0
- {napoln-0.2.3 → napoln-0.2.4}/STORIES.md +0 -0
- {napoln-0.2.3 → napoln-0.2.4}/justfile +0 -0
- {napoln-0.2.3 → napoln-0.2.4}/release-please-config.json +0 -0
- {napoln-0.2.3 → napoln-0.2.4}/skills-lock.json +0 -0
- {napoln-0.2.3 → napoln-0.2.4}/src/napoln/commands/__init__.py +0 -0
- {napoln-0.2.3 → napoln-0.2.4}/src/napoln/commands/config.py +0 -0
- {napoln-0.2.3 → napoln-0.2.4}/src/napoln/commands/init.py +0 -0
- {napoln-0.2.3 → napoln-0.2.4}/src/napoln/commands/install.py +0 -0
- {napoln-0.2.3 → napoln-0.2.4}/src/napoln/commands/list_cmd.py +0 -0
- {napoln-0.2.3 → napoln-0.2.4}/src/napoln/commands/remove.py +0 -0
- {napoln-0.2.3 → napoln-0.2.4}/src/napoln/commands/upgrade.py +0 -0
- {napoln-0.2.3 → napoln-0.2.4}/src/napoln/core/__init__.py +0 -0
- {napoln-0.2.3 → napoln-0.2.4}/src/napoln/core/hasher.py +0 -0
- {napoln-0.2.3 → napoln-0.2.4}/src/napoln/core/linker.py +0 -0
- {napoln-0.2.3 → napoln-0.2.4}/src/napoln/core/manifest.py +0 -0
- {napoln-0.2.3 → napoln-0.2.4}/src/napoln/core/merger.py +0 -0
- {napoln-0.2.3 → napoln-0.2.4}/src/napoln/core/resolver.py +0 -0
- {napoln-0.2.3 → napoln-0.2.4}/src/napoln/core/store.py +0 -0
- {napoln-0.2.3 → napoln-0.2.4}/src/napoln/core/validator.py +0 -0
- {napoln-0.2.3 → napoln-0.2.4}/src/napoln/errors.py +0 -0
- {napoln-0.2.3 → napoln-0.2.4}/src/napoln/output.py +0 -0
- {napoln-0.2.3 → napoln-0.2.4}/src/napoln/skills/napoln-manage/SKILL.md +0 -0
- {napoln-0.2.3 → napoln-0.2.4}/tests/__init__.py +0 -0
- {napoln-0.2.3 → napoln-0.2.4}/tests/conftest.py +0 -0
- {napoln-0.2.3 → napoln-0.2.4}/tests/features/config.feature +0 -0
- {napoln-0.2.3 → napoln-0.2.4}/tests/features/first_run.feature +0 -0
- {napoln-0.2.3 → napoln-0.2.4}/tests/features/init.feature +0 -0
- {napoln-0.2.3 → napoln-0.2.4}/tests/features/install.feature +0 -0
- {napoln-0.2.3 → napoln-0.2.4}/tests/features/list.feature +0 -0
- {napoln-0.2.3 → napoln-0.2.4}/tests/features/upgrade.feature +0 -0
- {napoln-0.2.3 → napoln-0.2.4}/tests/fixtures/invalid-skill/SKILL.md +0 -0
- {napoln-0.2.3 → napoln-0.2.4}/tests/fixtures/multi-skill-repo/README.md +0 -0
- {napoln-0.2.3 → napoln-0.2.4}/tests/fixtures/multi-skill-repo/skills/skill-a/SKILL.md +0 -0
- {napoln-0.2.3 → napoln-0.2.4}/tests/fixtures/multi-skill-repo/skills/skill-b/SKILL.md +0 -0
- {napoln-0.2.3 → napoln-0.2.4}/tests/fixtures/valid-skill/SKILL.md +0 -0
- {napoln-0.2.3 → napoln-0.2.4}/tests/integration/test_cli.py +0 -0
- {napoln-0.2.3 → napoln-0.2.4}/tests/steps/__init__.py +0 -0
- {napoln-0.2.3 → napoln-0.2.4}/tests/steps/conftest.py +0 -0
- {napoln-0.2.3 → napoln-0.2.4}/tests/steps/test_config.py +0 -0
- {napoln-0.2.3 → napoln-0.2.4}/tests/steps/test_first_run.py +0 -0
- {napoln-0.2.3 → napoln-0.2.4}/tests/steps/test_init.py +0 -0
- {napoln-0.2.3 → napoln-0.2.4}/tests/steps/test_install.py +0 -0
- {napoln-0.2.3 → napoln-0.2.4}/tests/steps/test_list.py +0 -0
- {napoln-0.2.3 → napoln-0.2.4}/tests/steps/test_upgrade.py +0 -0
- {napoln-0.2.3 → napoln-0.2.4}/tests/unit/test_agents.py +0 -0
- {napoln-0.2.3 → napoln-0.2.4}/tests/unit/test_hasher.py +0 -0
- {napoln-0.2.3 → napoln-0.2.4}/tests/unit/test_linker.py +0 -0
- {napoln-0.2.3 → napoln-0.2.4}/tests/unit/test_manifest.py +0 -0
- {napoln-0.2.3 → napoln-0.2.4}/tests/unit/test_merger.py +0 -0
- {napoln-0.2.3 → napoln-0.2.4}/tests/unit/test_resolver.py +0 -0
- {napoln-0.2.3 → napoln-0.2.4}/tests/unit/test_store.py +0 -0
- {napoln-0.2.3 → napoln-0.2.4}/tests/unit/test_validator.py +0 -0
- {napoln-0.2.3 → napoln-0.2.4}/uv.lock +0 -0
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.2.4](https://github.com/raiderrobert/napoln/compare/v0.2.3...v0.2.4) (2026-04-15)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* add `napoln setup` to choose default agents ([#16](https://github.com/raiderrobert/napoln/issues/16)) ([e8d78a6](https://github.com/raiderrobert/napoln/commit/e8d78a6f74c3c2dfa6fb02d422b594bbb324645b))
|
|
9
|
+
|
|
3
10
|
## [0.2.3](https://github.com/raiderrobert/napoln/compare/v0.2.2...v0.2.3) (2026-04-15)
|
|
4
11
|
|
|
5
12
|
|
|
@@ -233,6 +233,23 @@ def init(
|
|
|
233
233
|
raise typer.Exit(code=exit_code)
|
|
234
234
|
|
|
235
235
|
|
|
236
|
+
# ─── setup ────────────────────────────────────────────────────────────────────
|
|
237
|
+
|
|
238
|
+
|
|
239
|
+
@app.command()
|
|
240
|
+
def setup(
|
|
241
|
+
force: Annotated[
|
|
242
|
+
bool,
|
|
243
|
+
typer.Option("--force", help="Re-run setup even if default agents are already configured."),
|
|
244
|
+
] = False,
|
|
245
|
+
) -> None:
|
|
246
|
+
"""Choose which agents `napoln add` should install to by default."""
|
|
247
|
+
from napoln.commands.setup import run_setup
|
|
248
|
+
|
|
249
|
+
exit_code = run_setup(force=force)
|
|
250
|
+
raise typer.Exit(code=exit_code)
|
|
251
|
+
|
|
252
|
+
|
|
236
253
|
# ─── config ───────────────────────────────────────────────────────────────────
|
|
237
254
|
|
|
238
255
|
|
|
@@ -349,9 +349,12 @@ def run_add(
|
|
|
349
349
|
else:
|
|
350
350
|
resolved_list = [resolved_result]
|
|
351
351
|
|
|
352
|
-
# Detect agents
|
|
352
|
+
# Detect agents — prefer configured defaults over auto-detection
|
|
353
|
+
default_agent_ids = agents_mod.load_default_agent_ids(napoln_home)
|
|
353
354
|
try:
|
|
354
|
-
agent_configs = agents_mod.resolve_agents(
|
|
355
|
+
agent_configs = agents_mod.resolve_agents(
|
|
356
|
+
agent_ids, home, project_root, scope, default_agent_ids=default_agent_ids
|
|
357
|
+
)
|
|
355
358
|
except ValueError as e:
|
|
356
359
|
output.error(str(e))
|
|
357
360
|
return 1
|
|
@@ -363,6 +366,14 @@ def run_add(
|
|
|
363
366
|
)
|
|
364
367
|
return 1
|
|
365
368
|
|
|
369
|
+
# If the user has multiple agents installed but never configured defaults,
|
|
370
|
+
# nudge them toward `napoln setup` so they don't keep spray-installing.
|
|
371
|
+
if agent_ids is None and not default_agent_ids and scope == "global" and len(agent_configs) > 1:
|
|
372
|
+
output.info(
|
|
373
|
+
f"Installing to all {len(agent_configs)} detected agents. "
|
|
374
|
+
"Run `napoln setup` to choose defaults."
|
|
375
|
+
)
|
|
376
|
+
|
|
366
377
|
if dry_run:
|
|
367
378
|
output.dry_run_header()
|
|
368
379
|
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
"""napoln setup — One-time interactive onboarding to choose default agents."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import os
|
|
6
|
+
import tomllib
|
|
7
|
+
from pathlib import Path
|
|
8
|
+
|
|
9
|
+
import tomli_w
|
|
10
|
+
|
|
11
|
+
from napoln import output
|
|
12
|
+
from napoln.core import agents as agents_mod
|
|
13
|
+
from napoln.prompts import pick_agents
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def _get_napoln_home() -> Path:
|
|
17
|
+
return Path(os.environ.get("NAPOLN_HOME", Path.home() / ".napoln"))
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def _ensure_initialized(napoln_home: Path) -> None:
|
|
21
|
+
napoln_home.mkdir(parents=True, exist_ok=True)
|
|
22
|
+
(napoln_home / "store").mkdir(exist_ok=True)
|
|
23
|
+
(napoln_home / "cache").mkdir(exist_ok=True)
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def _load_config(config_path: Path) -> dict:
|
|
27
|
+
if not config_path.exists():
|
|
28
|
+
return {}
|
|
29
|
+
try:
|
|
30
|
+
return tomllib.loads(config_path.read_text(encoding="utf-8"))
|
|
31
|
+
except (OSError, tomllib.TOMLDecodeError):
|
|
32
|
+
return {}
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def _write_default_agents(config_path: Path, agent_ids: list[str]) -> None:
|
|
36
|
+
data = _load_config(config_path)
|
|
37
|
+
section = data.setdefault("napoln", {})
|
|
38
|
+
section["default_agents"] = agent_ids
|
|
39
|
+
section.setdefault("default_scope", "global")
|
|
40
|
+
config_path.parent.mkdir(parents=True, exist_ok=True)
|
|
41
|
+
config_path.write_text(tomli_w.dumps(data), encoding="utf-8")
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def run_setup(force: bool = False) -> int:
|
|
45
|
+
"""Run the interactive onboarding wizard.
|
|
46
|
+
|
|
47
|
+
Detects available agents, prompts the user to pick defaults, and persists
|
|
48
|
+
the selection to ``[napoln].default_agents`` in ``~/.napoln/config.toml``.
|
|
49
|
+
|
|
50
|
+
Args:
|
|
51
|
+
force: Re-run even if defaults are already configured.
|
|
52
|
+
|
|
53
|
+
Returns:
|
|
54
|
+
Exit code (0 on success, 1 on cancel/error).
|
|
55
|
+
"""
|
|
56
|
+
napoln_home = _get_napoln_home()
|
|
57
|
+
home = Path(os.environ.get("HOME", Path.home()))
|
|
58
|
+
config_path = napoln_home / "config.toml"
|
|
59
|
+
|
|
60
|
+
_ensure_initialized(napoln_home)
|
|
61
|
+
|
|
62
|
+
existing = agents_mod.load_default_agent_ids(napoln_home)
|
|
63
|
+
if existing and not force:
|
|
64
|
+
names = ", ".join(agents_mod.AGENTS[aid].display_name for aid in existing)
|
|
65
|
+
output.info(f"Default agents already configured: {names}")
|
|
66
|
+
output.info("Re-run with --force to change them.")
|
|
67
|
+
return 0
|
|
68
|
+
|
|
69
|
+
detected = agents_mod.detect_agents(home)
|
|
70
|
+
if not detected:
|
|
71
|
+
output.error(
|
|
72
|
+
"No agents detected on this machine.",
|
|
73
|
+
fix=(
|
|
74
|
+
"Install one of: Claude Code, Gemini CLI, pi, Codex, Cursor — "
|
|
75
|
+
"then re-run `napoln setup`."
|
|
76
|
+
),
|
|
77
|
+
)
|
|
78
|
+
return 1
|
|
79
|
+
|
|
80
|
+
output.header("napoln setup")
|
|
81
|
+
output.info(f"Detected {len(detected)} agent(s) on this machine.")
|
|
82
|
+
|
|
83
|
+
# Only preselect agents already in config; on first run the list is empty
|
|
84
|
+
# so the user has to actively pick — having a tool installed is not the
|
|
85
|
+
# same as wanting skills installed into it.
|
|
86
|
+
selected = pick_agents(detected, preselected_ids=existing)
|
|
87
|
+
|
|
88
|
+
if selected is None:
|
|
89
|
+
output.warning("Setup cancelled.")
|
|
90
|
+
return 1
|
|
91
|
+
|
|
92
|
+
if not selected:
|
|
93
|
+
output.warning("No agents selected — defaults will not be saved.")
|
|
94
|
+
return 1
|
|
95
|
+
|
|
96
|
+
selected_ids = [a.id for a in selected]
|
|
97
|
+
_write_default_agents(config_path, selected_ids)
|
|
98
|
+
|
|
99
|
+
names = ", ".join(a.display_name for a in selected)
|
|
100
|
+
output.success(f"Saved default agents: {names}")
|
|
101
|
+
output.info(f"Wrote {config_path}")
|
|
102
|
+
output.info("Future `napoln add` commands will install to these agents by default.")
|
|
103
|
+
output.info("Override per-command with `--agents <id1,id2,...>`.")
|
|
104
|
+
return 0
|
|
@@ -6,6 +6,7 @@ Supports: Claude Code, Gemini CLI, pi, Codex, Cursor.
|
|
|
6
6
|
from __future__ import annotations
|
|
7
7
|
|
|
8
8
|
import shutil
|
|
9
|
+
import tomllib
|
|
9
10
|
from dataclasses import dataclass
|
|
10
11
|
from pathlib import Path
|
|
11
12
|
|
|
@@ -137,22 +138,52 @@ def detect_agents(
|
|
|
137
138
|
return detected
|
|
138
139
|
|
|
139
140
|
|
|
141
|
+
def load_default_agent_ids(napoln_home: Path) -> list[str]:
|
|
142
|
+
"""Read configured default_agents from napoln config.toml.
|
|
143
|
+
|
|
144
|
+
Returns an empty list if the config does not exist or has no defaults set.
|
|
145
|
+
Unknown agent IDs are silently dropped (the config command validates input,
|
|
146
|
+
but a config file edited by hand may contain stale entries).
|
|
147
|
+
"""
|
|
148
|
+
config_path = napoln_home / "config.toml"
|
|
149
|
+
if not config_path.exists():
|
|
150
|
+
return []
|
|
151
|
+
try:
|
|
152
|
+
data = tomllib.loads(config_path.read_text(encoding="utf-8"))
|
|
153
|
+
except (OSError, tomllib.TOMLDecodeError):
|
|
154
|
+
return []
|
|
155
|
+
raw = data.get("napoln", {}).get("default_agents", [])
|
|
156
|
+
if not isinstance(raw, list):
|
|
157
|
+
return []
|
|
158
|
+
return [aid for aid in raw if isinstance(aid, str) and aid in AGENTS]
|
|
159
|
+
|
|
160
|
+
|
|
140
161
|
def resolve_agents(
|
|
141
|
-
agent_ids: list[str] | None,
|
|
162
|
+
agent_ids: list[str] | None,
|
|
163
|
+
home: Path,
|
|
164
|
+
project_root: Path | None = None,
|
|
165
|
+
scope: str = "global",
|
|
166
|
+
default_agent_ids: list[str] | None = None,
|
|
142
167
|
) -> list[AgentConfig]:
|
|
143
|
-
"""Resolve agent list from explicit IDs or auto-detection.
|
|
168
|
+
"""Resolve agent list from explicit IDs, configured defaults, or auto-detection.
|
|
169
|
+
|
|
170
|
+
Resolution order:
|
|
171
|
+
1. Explicit ``agent_ids`` (e.g., from ``--agents`` flag).
|
|
172
|
+
2. ``default_agent_ids`` (e.g., from ``[napoln].default_agents`` in config.toml).
|
|
173
|
+
3. Auto-detection of installed agents.
|
|
144
174
|
|
|
145
175
|
Args:
|
|
146
|
-
agent_ids: Explicit agent IDs, or None
|
|
176
|
+
agent_ids: Explicit agent IDs, or None to fall through to defaults/auto-detect.
|
|
147
177
|
home: User home directory.
|
|
148
178
|
project_root: Project root (for project-scope).
|
|
149
179
|
scope: "global" or "project".
|
|
180
|
+
default_agent_ids: Configured defaults to prefer over auto-detection.
|
|
150
181
|
|
|
151
182
|
Returns:
|
|
152
183
|
List of AgentConfig objects.
|
|
153
184
|
|
|
154
185
|
Raises:
|
|
155
|
-
ValueError: If an unknown agent ID is specified
|
|
186
|
+
ValueError: If an unknown agent ID is specified in ``agent_ids``.
|
|
156
187
|
"""
|
|
157
188
|
if agent_ids:
|
|
158
189
|
configs = []
|
|
@@ -162,6 +193,9 @@ def resolve_agents(
|
|
|
162
193
|
configs.append(AGENTS[aid])
|
|
163
194
|
return configs
|
|
164
195
|
|
|
196
|
+
if default_agent_ids:
|
|
197
|
+
return [AGENTS[aid] for aid in default_agent_ids if aid in AGENTS]
|
|
198
|
+
|
|
165
199
|
return detect_agents(home, project_root, scope)
|
|
166
200
|
|
|
167
201
|
|
|
@@ -6,6 +6,8 @@ import sys
|
|
|
6
6
|
from dataclasses import dataclass
|
|
7
7
|
from pathlib import Path
|
|
8
8
|
|
|
9
|
+
from napoln.core.agents import AgentConfig
|
|
10
|
+
|
|
9
11
|
|
|
10
12
|
@dataclass
|
|
11
13
|
class SkillChoice:
|
|
@@ -109,3 +111,58 @@ def pick_skills(choices: list[SkillChoice]) -> list[SkillChoice]:
|
|
|
109
111
|
return []
|
|
110
112
|
|
|
111
113
|
return selected
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
def pick_agents(
|
|
117
|
+
available: list[AgentConfig],
|
|
118
|
+
preselected_ids: list[str] | None = None,
|
|
119
|
+
) -> list[AgentConfig] | None:
|
|
120
|
+
"""Interactive checkbox picker for agents.
|
|
121
|
+
|
|
122
|
+
Returns the selected agents, or None if the user cancelled (ctrl-c).
|
|
123
|
+
Returns an empty list if the user confirmed with nothing selected.
|
|
124
|
+
|
|
125
|
+
Falls back to selecting all available agents in non-TTY environments so
|
|
126
|
+
automation does not hang.
|
|
127
|
+
"""
|
|
128
|
+
if not available:
|
|
129
|
+
return []
|
|
130
|
+
|
|
131
|
+
if not sys.stdin.isatty():
|
|
132
|
+
return list(available)
|
|
133
|
+
|
|
134
|
+
import questionary
|
|
135
|
+
from questionary import constants as q_constants
|
|
136
|
+
from questionary.prompts import common as q_common
|
|
137
|
+
|
|
138
|
+
q_constants.INDICATOR_SELECTED = "✓"
|
|
139
|
+
q_constants.INDICATOR_UNSELECTED = " "
|
|
140
|
+
q_common.INDICATOR_SELECTED = "✓"
|
|
141
|
+
q_common.INDICATOR_UNSELECTED = " "
|
|
142
|
+
|
|
143
|
+
preselected = set(preselected_ids or [])
|
|
144
|
+
max_name = max(len(a.display_name) for a in available)
|
|
145
|
+
|
|
146
|
+
options = []
|
|
147
|
+
for agent in available:
|
|
148
|
+
tokens: list[tuple[str, str]] = [
|
|
149
|
+
("class:text", f"{agent.display_name:<{max_name}}"),
|
|
150
|
+
("class:text", f" ({agent.id})"),
|
|
151
|
+
]
|
|
152
|
+
options.append(
|
|
153
|
+
questionary.Choice(
|
|
154
|
+
title=tokens,
|
|
155
|
+
value=agent,
|
|
156
|
+
checked=agent.id in preselected,
|
|
157
|
+
)
|
|
158
|
+
)
|
|
159
|
+
|
|
160
|
+
style = questionary.Style([("selected", "noreverse")])
|
|
161
|
+
|
|
162
|
+
selected = questionary.checkbox(
|
|
163
|
+
"Default agents:",
|
|
164
|
+
choices=options,
|
|
165
|
+
style=style,
|
|
166
|
+
).ask()
|
|
167
|
+
|
|
168
|
+
return selected
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
Feature: Choose default agents
|
|
2
|
+
As a developer with multiple AI coding tools installed
|
|
3
|
+
I want to pick which agents napoln installs to by default
|
|
4
|
+
So that `napoln add` does not spray skills across every detected tool
|
|
5
|
+
|
|
6
|
+
Scenario: Setup persists default agents to config
|
|
7
|
+
Given Claude Code and Cursor are installed
|
|
8
|
+
When I run napoln setup with selection "claude-code"
|
|
9
|
+
Then the config contains default_agents "claude-code"
|
|
10
|
+
And the exit code is 0
|
|
11
|
+
|
|
12
|
+
Scenario: Add respects configured default agents
|
|
13
|
+
Given Claude Code and Cursor are installed
|
|
14
|
+
And default_agents is configured to "claude-code"
|
|
15
|
+
When I run napoln add with a valid local skill
|
|
16
|
+
Then the skill is placed only for Claude Code
|
|
17
|
+
And the exit code is 0
|
|
18
|
+
|
|
19
|
+
Scenario: Add hints at setup when defaults are unset and multiple agents detected
|
|
20
|
+
Given Claude Code and Cursor are installed
|
|
21
|
+
And default_agents is not configured
|
|
22
|
+
When I run napoln add with a valid local skill
|
|
23
|
+
Then the output contains "napoln setup"
|
|
24
|
+
And the exit code is 0
|
|
25
|
+
|
|
26
|
+
Scenario: Setup with no agents detected fails with guidance
|
|
27
|
+
Given no agents are installed
|
|
28
|
+
When I run napoln setup non-interactively
|
|
29
|
+
Then the output contains "No agents detected"
|
|
30
|
+
And the exit code is 1
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
"""Step definitions for setup.feature."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import tomllib
|
|
6
|
+
|
|
7
|
+
import tomli_w
|
|
8
|
+
from pytest_bdd import given, parsers, scenario, then, when
|
|
9
|
+
from typer.testing import CliRunner
|
|
10
|
+
|
|
11
|
+
from napoln.cli import app
|
|
12
|
+
from tests.steps.conftest import NapolnTestEnv
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
@scenario("../features/setup.feature", "Setup persists default agents to config")
|
|
16
|
+
def test_setup_persists_defaults():
|
|
17
|
+
pass
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
@scenario("../features/setup.feature", "Add respects configured default agents")
|
|
21
|
+
def test_add_respects_defaults():
|
|
22
|
+
pass
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
@scenario(
|
|
26
|
+
"../features/setup.feature",
|
|
27
|
+
"Add hints at setup when defaults are unset and multiple agents detected",
|
|
28
|
+
)
|
|
29
|
+
def test_add_hints_at_setup():
|
|
30
|
+
pass
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
@scenario("../features/setup.feature", "Setup with no agents detected fails with guidance")
|
|
34
|
+
def test_setup_no_agents():
|
|
35
|
+
pass
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
# ─── Given ────────────────────────────────────────────────────────────────────
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
@given("Claude Code and Cursor are installed", target_fixture="env")
|
|
42
|
+
def claude_and_cursor(napoln_env: NapolnTestEnv, monkeypatch):
|
|
43
|
+
(napoln_env.home / ".claude").mkdir(parents=True, exist_ok=True)
|
|
44
|
+
(napoln_env.home / ".cursor").mkdir(parents=True, exist_ok=True)
|
|
45
|
+
# Don't let pi/codex on the real PATH leak into detection.
|
|
46
|
+
monkeypatch.setattr("napoln.core.agents._check_on_path", lambda cmd: False)
|
|
47
|
+
return napoln_env
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
@given("no agents are installed", target_fixture="env")
|
|
51
|
+
def no_agents(napoln_env: NapolnTestEnv, monkeypatch):
|
|
52
|
+
monkeypatch.setattr("napoln.core.agents._check_on_path", lambda cmd: False)
|
|
53
|
+
return napoln_env
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
@given(parsers.parse('default_agents is configured to "{ids}"'))
|
|
57
|
+
def configure_defaults(env: NapolnTestEnv, ids: str):
|
|
58
|
+
env.napoln_home.mkdir(parents=True, exist_ok=True)
|
|
59
|
+
config_path = env.napoln_home / "config.toml"
|
|
60
|
+
data = {"napoln": {"default_agents": [a.strip() for a in ids.split(",")]}}
|
|
61
|
+
config_path.write_text(tomli_w.dumps(data))
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
@given("default_agents is not configured")
|
|
65
|
+
def no_defaults(env: NapolnTestEnv):
|
|
66
|
+
config_path = env.napoln_home / "config.toml"
|
|
67
|
+
assert not config_path.exists()
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
# ─── When ────────────────────────────────────────────────────────────────────
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
@when(parsers.parse('I run napoln setup with selection "{ids}"'), target_fixture="result_env")
|
|
74
|
+
def run_setup_with_selection(env: NapolnTestEnv, ids: str, cli_runner: CliRunner, monkeypatch):
|
|
75
|
+
from napoln.core import agents as agents_mod
|
|
76
|
+
|
|
77
|
+
selected_ids = [a.strip() for a in ids.split(",")]
|
|
78
|
+
selected = [agents_mod.AGENTS[aid] for aid in selected_ids]
|
|
79
|
+
# Bypass the questionary prompt: return the chosen agents directly.
|
|
80
|
+
monkeypatch.setattr(
|
|
81
|
+
"napoln.commands.setup.pick_agents", lambda available, preselected_ids=None: selected
|
|
82
|
+
)
|
|
83
|
+
env.result = cli_runner.invoke(app, ["setup"], env=env.env_vars)
|
|
84
|
+
return env
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
@when("I run napoln setup non-interactively", target_fixture="result_env")
|
|
88
|
+
def run_setup_noninteractive(env: NapolnTestEnv, cli_runner: CliRunner):
|
|
89
|
+
env.result = cli_runner.invoke(app, ["setup"], env=env.env_vars)
|
|
90
|
+
return env
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
@when("I run napoln add with a valid local skill", target_fixture="result_env")
|
|
94
|
+
def run_add(env: NapolnTestEnv, cli_runner: CliRunner):
|
|
95
|
+
skill_path = env.create_local_skill()
|
|
96
|
+
env.result = cli_runner.invoke(app, ["add", str(skill_path)], env=env.env_vars)
|
|
97
|
+
return env
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
# ─── Then ────────────────────────────────────────────────────────────────────
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
@then(parsers.parse('the config contains default_agents "{ids}"'))
|
|
104
|
+
def config_has_defaults(result_env: NapolnTestEnv, ids: str):
|
|
105
|
+
config_path = result_env.napoln_home / "config.toml"
|
|
106
|
+
assert config_path.exists(), "config.toml was not written"
|
|
107
|
+
data = tomllib.loads(config_path.read_text())
|
|
108
|
+
expected = [a.strip() for a in ids.split(",")]
|
|
109
|
+
assert data["napoln"]["default_agents"] == expected
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
@then("the skill is placed only for Claude Code")
|
|
113
|
+
def placed_only_for_claude(result_env: NapolnTestEnv):
|
|
114
|
+
claude_skill = result_env.home / ".claude" / "skills" / "test-skill"
|
|
115
|
+
cursor_skill = result_env.home / ".cursor" / "skills" / "test-skill"
|
|
116
|
+
assert claude_skill.exists(), f"Expected Claude placement at {claude_skill}"
|
|
117
|
+
assert not cursor_skill.exists(), f"Did not expect Cursor placement at {cursor_skill}"
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
@then(parsers.parse('the output contains "{text}"'))
|
|
121
|
+
def output_contains(result_env: NapolnTestEnv, text: str):
|
|
122
|
+
combined = result_env.result.output + (result_env.result.stderr or "")
|
|
123
|
+
assert text in combined, f"Expected '{text}' in:\n{combined}"
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
@then(parsers.parse("the exit code is {code:d}"))
|
|
127
|
+
def check_exit_code(result_env: NapolnTestEnv, code: int):
|
|
128
|
+
assert result_env.result.exit_code == code, (
|
|
129
|
+
f"exit={result_env.result.exit_code} output={result_env.result.output!r}"
|
|
130
|
+
)
|
|
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
|