feature-map-cli 1.0.0__py3-none-any.whl

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 (40) hide show
  1. feature_map/__init__.py +3 -0
  2. feature_map/__main__.py +3 -0
  3. feature_map/_version.py +1 -0
  4. feature_map/bootstrap.py +189 -0
  5. feature_map/cli.py +273 -0
  6. feature_map/commands/__init__.py +0 -0
  7. feature_map/commands/check_cmd.py +23 -0
  8. feature_map/commands/find_cmd.py +36 -0
  9. feature_map/commands/graph_cmd.py +18 -0
  10. feature_map/commands/impact_cmd.py +55 -0
  11. feature_map/commands/init_cmd.py +72 -0
  12. feature_map/commands/install_cmd.py +54 -0
  13. feature_map/commands/list_cmd.py +37 -0
  14. feature_map/commands/search_cmd.py +21 -0
  15. feature_map/commands/show_cmd.py +34 -0
  16. feature_map/commands/stats_cmd.py +85 -0
  17. feature_map/commands/validate_cmd.py +59 -0
  18. feature_map/config.py +24 -0
  19. feature_map/discover.py +59 -0
  20. feature_map/errors.py +17 -0
  21. feature_map/graph.py +79 -0
  22. feature_map/loader.py +62 -0
  23. feature_map/output.py +54 -0
  24. feature_map/path_extract.py +139 -0
  25. feature_map/path_normalize.py +100 -0
  26. feature_map/path_resolve.py +36 -0
  27. feature_map/paths.py +34 -0
  28. feature_map/share/schema/feature-map.schema.json +39 -0
  29. feature_map/share/skill/SKILL.md +58 -0
  30. feature_map/share/skill/references/authoring.md +37 -0
  31. feature_map/share/skill/references/commands.md +47 -0
  32. feature_map/share/skill/references/existing-repos.md +43 -0
  33. feature_map/share/templates/feature.yaml.tpl +17 -0
  34. feature_map/text_index.py +49 -0
  35. feature_map/validate.py +148 -0
  36. feature_map_cli-1.0.0.dist-info/METADATA +121 -0
  37. feature_map_cli-1.0.0.dist-info/RECORD +40 -0
  38. feature_map_cli-1.0.0.dist-info/WHEEL +4 -0
  39. feature_map_cli-1.0.0.dist-info/entry_points.txt +2 -0
  40. feature_map_cli-1.0.0.dist-info/licenses/LICENSE +21 -0
@@ -0,0 +1,148 @@
1
+ import json
2
+ import re
3
+ from pathlib import Path
4
+ from typing import List, Optional, Tuple
5
+
6
+ import yaml
7
+
8
+ from feature_map.loader import extract_related_slug, normalize_slug
9
+ from feature_map.paths import schema_path
10
+
11
+ REQUIRED_KEYS = ["feature_name", "purpose", "entry_points"]
12
+ RECOMMENDED_KEYS = ["apps", "user_flow", "related_features"]
13
+
14
+ _SCHEMA_CACHE = None
15
+
16
+
17
+ def load_schema() -> dict:
18
+ global _SCHEMA_CACHE
19
+ if _SCHEMA_CACHE is None:
20
+ _SCHEMA_CACHE = json.loads(schema_path().read_text(encoding="utf-8"))
21
+ return _SCHEMA_CACHE
22
+
23
+
24
+ def _matches_schema_type(value, types: List[str]) -> bool:
25
+ if "string" in types and isinstance(value, str):
26
+ return True
27
+ if "array" in types and isinstance(value, list):
28
+ return True
29
+ if "object" in types and isinstance(value, dict):
30
+ return True
31
+ if "null" in types and value is None:
32
+ return True
33
+ return False
34
+
35
+
36
+ def validate_against_schema(data: dict) -> List[str]:
37
+ schema = load_schema()
38
+ errors: List[str] = []
39
+
40
+ for key in schema.get("required", []):
41
+ if key not in data or data[key] in (None, "", []):
42
+ errors.append(f"missing required key '{key}' (schema)")
43
+
44
+ properties = schema.get("properties", {})
45
+ for key, spec in properties.items():
46
+ if key not in data:
47
+ continue
48
+ value = data[key]
49
+ expected = spec.get("type")
50
+ if not expected:
51
+ continue
52
+ if isinstance(expected, str):
53
+ expected = [expected]
54
+ if not _matches_schema_type(value, expected):
55
+ errors.append(f"'{key}' has invalid type per schema")
56
+ continue
57
+ if key == "entry_points" and isinstance(value, list):
58
+ min_items = spec.get("minItems", 0)
59
+ if len(value) < min_items:
60
+ errors.append(f"'entry_points' must have at least {min_items} item(s) (schema)")
61
+ if isinstance(value, str) and spec.get("minLength"):
62
+ if len(value) < spec["minLength"]:
63
+ errors.append(f"'{key}' is too short per schema")
64
+
65
+ return errors
66
+
67
+
68
+ def _extract_field_from_text(text: str, key: str) -> Optional[str]:
69
+ match = re.search(rf"^{re.escape(key)}:\s*(.+)$", text, re.MULTILINE)
70
+ if not match:
71
+ return None
72
+ return match.group(1).strip().strip('"').strip("'")
73
+
74
+
75
+ def validate_map_file(
76
+ path: Path,
77
+ all_slugs: set,
78
+ strict: bool = False,
79
+ ) -> Tuple[List[str], List[str]]:
80
+ errors: List[str] = []
81
+ warnings: List[str] = []
82
+ text = path.read_text(encoding="utf-8")
83
+ data = None
84
+
85
+ try:
86
+ data = yaml.safe_load(text)
87
+ except yaml.YAMLError as exc:
88
+ parse_error = str(exc)
89
+ if strict:
90
+ errors.append(f"{path.name}: YAML parse error: {parse_error}")
91
+ else:
92
+ warnings.append(
93
+ f"{path.name}: YAML parse error (skipped structural checks): {parse_error}"
94
+ )
95
+
96
+ stem = path.stem
97
+ if data is not None:
98
+ if not isinstance(data, dict):
99
+ errors.append(f"{path.name}: root must be a mapping")
100
+ return errors, warnings
101
+
102
+ schema_errors = validate_against_schema(data)
103
+ for msg in schema_errors:
104
+ full = f"{path.name}: {msg}"
105
+ if strict:
106
+ errors.append(full)
107
+ else:
108
+ warnings.append(full)
109
+
110
+ feature_name = data.get("feature_name")
111
+ if feature_name:
112
+ normalized = normalize_slug(str(feature_name))
113
+ if normalized != normalize_slug(stem):
114
+ warnings.append(
115
+ f"{path.name}: feature_name '{feature_name}' "
116
+ f"does not match filename stem '{stem}'"
117
+ )
118
+
119
+ for key in RECOMMENDED_KEYS:
120
+ if key not in data or data[key] in (None, "", []):
121
+ warnings.append(f"{path.name}: missing recommended key '{key}'")
122
+
123
+ related = data.get("related_features") or []
124
+ if isinstance(related, list):
125
+ for entry in related:
126
+ slug = extract_related_slug(entry)
127
+ if slug and slug not in all_slugs:
128
+ warnings.append(
129
+ f"{path.name}: related_features entry '{entry}' "
130
+ f"does not resolve to an existing map (slug: {slug})"
131
+ )
132
+ else:
133
+ schema = load_schema()
134
+ for key in schema.get("required", REQUIRED_KEYS):
135
+ if not _extract_field_from_text(text, key):
136
+ msg = f"{path.name}: missing required key '{key}' (text scan)"
137
+ if strict:
138
+ errors.append(msg)
139
+ else:
140
+ warnings.append(msg)
141
+ feature_name = _extract_field_from_text(text, "feature_name")
142
+ if feature_name and normalize_slug(feature_name) != normalize_slug(stem):
143
+ warnings.append(
144
+ f"{path.name}: feature_name '{feature_name}' "
145
+ f"does not match filename stem '{stem}' (text scan)"
146
+ )
147
+
148
+ return errors, warnings
@@ -0,0 +1,121 @@
1
+ Metadata-Version: 2.5
2
+ Name: feature-map-cli
3
+ Version: 1.0.0
4
+ Summary: Cross-app architecture research CLI driven by .features/*.yaml maps
5
+ Project-URL: Homepage, https://github.com/markschellhas/feature-map
6
+ Project-URL: Repository, https://github.com/markschellhas/feature-map
7
+ Author: Taptics
8
+ License-Expression: MIT
9
+ License-File: LICENSE
10
+ Keywords: agents,architecture,cli,feature-map
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Environment :: Console
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: License :: OSI Approved :: MIT License
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.8
17
+ Classifier: Programming Language :: Python :: 3.9
18
+ Classifier: Programming Language :: Python :: 3.10
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Programming Language :: Python :: 3.12
21
+ Classifier: Topic :: Software Development :: Documentation
22
+ Requires-Python: >=3.8
23
+ Requires-Dist: pyyaml>=6.0
24
+ Provides-Extra: dev
25
+ Requires-Dist: pytest>=7.0; extra == 'dev'
26
+ Description-Content-Type: text/markdown
27
+
28
+ # Feature Map
29
+
30
+ Cross-app architecture research CLI. Agents and engineers keep authoritative
31
+ feature maps in `.features/*.yaml`; `feature-map` lists, searches, validates,
32
+ and graphs them.
33
+
34
+ A wiki stores architecture as prose — agents re-read a whole page to find three
35
+ files. Feature Map stores **fields** (`purpose`, `entry_points`, `apps`) and a
36
+ CLI that returns **names and sections**, so lookup is cheap and `check` can
37
+ prove paths still exist.
38
+
39
+ ## Install
40
+
41
+ ```bash
42
+ pip install -e .
43
+ # pip install feature-map-cli
44
+ # brew install feature-map
45
+ ```
46
+
47
+ Requires Python 3.8+ and PyYAML. The CLI is `feature-map`. Install from PyPI as
48
+ `feature-map-cli` — `pip install featuremap` is a different (biology) project,
49
+ and `feature-map` is blocked on PyPI as too similar to that name.
50
+
51
+ ## Usage
52
+
53
+ ```bash
54
+ cd my-repo
55
+ feature-map init
56
+ feature-map init auth # scaffold .features/auth.yaml
57
+ feature-map list
58
+ feature-map search billing
59
+ feature-map validate
60
+ ```
61
+
62
+ `feature-map init` is idempotent. It:
63
+
64
+ 1. Creates `.features/`
65
+ 2. Copies the agent skill to `.agents/skills/feature-map/` (or `.grok/skills/` if that tree already exists)
66
+ 3. Writes `.feature-map.yaml` defaults when missing
67
+ 4. Appends an `AGENTS.md` block (skip with `--no-agents`)
68
+ 5. Writes `bin/feature-map` as a repo-local shim (skip with `--no-shim`)
69
+
70
+ Refresh the skill after upgrading the package:
71
+
72
+ ```bash
73
+ feature-map init --upgrade-skill
74
+ ```
75
+
76
+ ## Commands
77
+
78
+ | Command | Purpose |
79
+ |---------|---------|
80
+ | `list` | All feature slugs |
81
+ | `show <name>` / `<name>` | Print a map (or `--section`) |
82
+ | `search <query>` | Full-text search |
83
+ | `find <path>` | Reverse lookup by path fragment |
84
+ | `graph [name]` | `related_features` graph (`mermaid`, `json`, `dot`) |
85
+ | `validate [--strict]` | Structural checks |
86
+ | `check` | Stale `entry_points` / `core_components` paths |
87
+ | `impact <file>` | Which maps reference a file |
88
+ | `stats` | Coverage summary |
89
+ | `init` / `init <name>` | Bootstrap repo or scaffold a map |
90
+ | `install` | Setup status |
91
+ | `--json` / `--version` | Machine output / version |
92
+
93
+ Exit codes: `0` ok, `1` user error, `2` validation failure (`--strict`).
94
+
95
+ ## Per-repo config
96
+
97
+ `.feature-map.yaml` at the git root:
98
+
99
+ ```yaml
100
+ features_dir: .features
101
+ apps:
102
+ - api
103
+ - web
104
+ required_sections:
105
+ - purpose
106
+ - entry_points
107
+ min_cli_version: "1.0.0"
108
+ ```
109
+
110
+ `apps` prefixes are used by `check` when resolving paths.
111
+
112
+ ## Develop
113
+
114
+ ```bash
115
+ pip install -e ".[dev]"
116
+ python -m pytest -q
117
+ ```
118
+
119
+ ## License
120
+
121
+ MIT
@@ -0,0 +1,40 @@
1
+ feature_map/__init__.py,sha256=7R2sGclRtd0nksKa47lnjtXvJglHAmAMtTMbjGY6QrY,72
2
+ feature_map/__main__.py,sha256=ihpYQS0sITrj2CLf0pAJE2PdMkBm3sggCwVwbrD9uew,59
3
+ feature_map/_version.py,sha256=Aj77VL1d5Mdku7sgCgKQmPuYavPpAHuZuJcy6bygQZE,21
4
+ feature_map/bootstrap.py,sha256=T0xCn6h4SwZD_2ufmwgDXNTn7DtTDY3scyGmb_G1F_Y,5958
5
+ feature_map/cli.py,sha256=PPoM_uzyRsSzK61tLOyC1cVOV00jBqtKUpYlJvXa2pM,8469
6
+ feature_map/config.py,sha256=YVjjRt8YI5ZqhxF8efdS6UbOwezrD116OfKoBXF6QpA,728
7
+ feature_map/discover.py,sha256=Sc4mi8Qz5bBPwrJseJTe3mLISlGScqpF9PbpV9Ksu-c,1480
8
+ feature_map/errors.py,sha256=-DFSBcqH4hDdJ_H2DpBIKJ-EvT8Mp-PS-d9l8J7Lx0U,633
9
+ feature_map/graph.py,sha256=CCq2jvqQqA8x9oDeU1HSOk4fNZg9yDctXI0HX2-6MPA,2178
10
+ feature_map/loader.py,sha256=iKPo0G4cOvGzVuX2EBrhLUdOoiUs_QsGs27LHqvsQGQ,1679
11
+ feature_map/output.py,sha256=l5opHNvMgP6WjmC41gi0f8RK1xTVnR3xjlfDvL_GoGo,1545
12
+ feature_map/path_extract.py,sha256=0vxAqlbam2pxw7DhLy0sM5f5XDQFc5MylUMJJgDskP8,4650
13
+ feature_map/path_normalize.py,sha256=kPm97cFWYgaAVHxkHkZ7XNo1nMIubL6Jtik3fhwmq9g,3002
14
+ feature_map/path_resolve.py,sha256=XkoJ7XP3xQMbDLn_HS5TnNV5_zMjpmYBnL4w2SdomR4,1331
15
+ feature_map/paths.py,sha256=uStjrRgLq-yXLYE1VM_mgi7FZm-R_RE9IMhB5kcrAGQ,840
16
+ feature_map/text_index.py,sha256=aSjQjNtClGYTWbb8gGEbD-Atap6wnYB8Z4Y4fU5oM2c,1471
17
+ feature_map/validate.py,sha256=HGipWF54wWX-0C_VkUhEmlUCQtMnqyypMNp2uvXzKZU,5045
18
+ feature_map/commands/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
19
+ feature_map/commands/check_cmd.py,sha256=0jZMUsPniUWI6XGa4lAz-S4-qbyfzAie58b7cSbhgl4,549
20
+ feature_map/commands/find_cmd.py,sha256=TJmzwteLZMQi2qmq05ut20tGiFGx40zc8Lkaah3DSnw,1014
21
+ feature_map/commands/graph_cmd.py,sha256=Kd4vCSJgyym7zQ8Q5dB3Y_sOVoUhBYS_gxHycPExuHo,513
22
+ feature_map/commands/impact_cmd.py,sha256=fzMUUUDo2-7p2VUiQJ0m7XPGNkEvAMyvpOwDiDOek5A,1395
23
+ feature_map/commands/init_cmd.py,sha256=OyMgkpCzMyNQwunogzEHJFLK-IlQowL6U61rT2TCUj0,2199
24
+ feature_map/commands/install_cmd.py,sha256=EyYh4lPtAFvqtvgALaMXu3WYpvnX4IdUeIBDEanlhQY,2230
25
+ feature_map/commands/list_cmd.py,sha256=3bdus0wN-5tvY_WlhxoJ-4omuQREAGaYL8nCI5heUiY,1151
26
+ feature_map/commands/search_cmd.py,sha256=au8K8lRGQmnAsWp1s5e2bLl7PLnHfBSGyEssKcc6xd4,570
27
+ feature_map/commands/show_cmd.py,sha256=LXqk_JS72rvrxEPKMlxS1wKJ7iMr6DI3gnGKeEYChfo,1187
28
+ feature_map/commands/stats_cmd.py,sha256=QEia1g-4-VmKtlVdvF1x01kqiw7pAV3w1CeL1xUTdqg,2656
29
+ feature_map/commands/validate_cmd.py,sha256=BxKaHC0H-RK8uVeOgnhHRJbH-hio9pvkJt0T7G1LeCc,1815
30
+ feature_map/share/schema/feature-map.schema.json,sha256=FvsBJHUqYN-fS6eoYBMOoeIZgL3iaPpxeE2nQMCJkcU,738
31
+ feature_map/share/skill/SKILL.md,sha256=krgCWNB8sZkwmAqnXXWKnv29c2vWpBb8mOB6l2n7U2U,2431
32
+ feature_map/share/skill/references/authoring.md,sha256=MG1x1XqlO9bBLZjDMeFmvAq7Ppy8qTO3mhhXbulVZ_0,1772
33
+ feature_map/share/skill/references/commands.md,sha256=x8y0m30umCpfzOEBy5bF8bG-ATh78JE5xoNhuSjZutg,1605
34
+ feature_map/share/skill/references/existing-repos.md,sha256=TFO_OmeoJ_4ykL8PXpOf65Q5e2uYyVaxcCZE5Fpj07g,1917
35
+ feature_map/share/templates/feature.yaml.tpl,sha256=jI7vR3aD5KtpO7iH-IXNU5gQkxCCXEMKOboQPbCOn7g,349
36
+ feature_map_cli-1.0.0.dist-info/METADATA,sha256=Hi6yxAZHE5pcPC_Y8M1RnVi_MJFJsDwoqvXbKWwrQ_c,3529
37
+ feature_map_cli-1.0.0.dist-info/WHEEL,sha256=zOwg4jB6zX2kU910N-cMawjivD6tO8NEWvE12je1bVk,87
38
+ feature_map_cli-1.0.0.dist-info/entry_points.txt,sha256=r5crp3ooQAmyCHdhZhQ7WWv8hwdrD-7RQAm7s2iZNis,53
39
+ feature_map_cli-1.0.0.dist-info/licenses/LICENSE,sha256=H-CvmWwZCsQxUa5fWXoYmOTLK5DyLvPkxdjt6ZxppdE,1064
40
+ feature_map_cli-1.0.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.32.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ feature-map = feature_map.cli:main
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Taptics
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.