cli-usereq 0.75.11__tar.gz → 0.75.16__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.
- {cli_usereq-0.75.11 → cli_usereq-0.75.16}/PKG-INFO +2 -2
- {cli_usereq-0.75.11 → cli_usereq-0.75.16}/README.md +1 -1
- {cli_usereq-0.75.11 → cli_usereq-0.75.16}/pyproject.toml +1 -1
- {cli_usereq-0.75.11 → cli_usereq-0.75.16}/src/usereq/__init__.py +1 -1
- {cli_usereq-0.75.11 → cli_usereq-0.75.16}/src/usereq/cli.py +160 -75
- {cli_usereq-0.75.11 → cli_usereq-0.75.16}/src/usereq/config_cli.py +34 -1
- {cli_usereq-0.75.11 → cli_usereq-0.75.16}/src/usereq/config_schema.py +45 -2
- {cli_usereq-0.75.11 → cli_usereq-0.75.16}/src/usereq/resources/prompts/analyze.md +15 -13
- {cli_usereq-0.75.11 → cli_usereq-0.75.16}/src/usereq/resources/prompts/change.md +14 -12
- {cli_usereq-0.75.11 → cli_usereq-0.75.16}/src/usereq/resources/prompts/check.md +11 -9
- {cli_usereq-0.75.11 → cli_usereq-0.75.16}/src/usereq/resources/prompts/cover.md +14 -12
- {cli_usereq-0.75.11 → cli_usereq-0.75.16}/src/usereq/resources/prompts/create.md +7 -2
- {cli_usereq-0.75.11 → cli_usereq-0.75.16}/src/usereq/resources/prompts/fix.md +14 -12
- {cli_usereq-0.75.11 → cli_usereq-0.75.16}/src/usereq/resources/prompts/flowchart.md +12 -11
- {cli_usereq-0.75.11 → cli_usereq-0.75.16}/src/usereq/resources/prompts/implement.md +10 -5
- {cli_usereq-0.75.11 → cli_usereq-0.75.16}/src/usereq/resources/prompts/new.md +13 -11
- {cli_usereq-0.75.11 → cli_usereq-0.75.16}/src/usereq/resources/prompts/orchestrate.md +16 -10
- {cli_usereq-0.75.11 → cli_usereq-0.75.16}/src/usereq/resources/prompts/readme.md +13 -11
- {cli_usereq-0.75.11 → cli_usereq-0.75.16}/src/usereq/resources/prompts/recreate.md +12 -11
- {cli_usereq-0.75.11 → cli_usereq-0.75.16}/src/usereq/resources/prompts/refactor.md +15 -13
- {cli_usereq-0.75.11 → cli_usereq-0.75.16}/src/usereq/resources/prompts/references.md +9 -4
- {cli_usereq-0.75.11 → cli_usereq-0.75.16}/src/usereq/resources/prompts/renumber.md +9 -4
- {cli_usereq-0.75.11 → cli_usereq-0.75.16}/src/usereq/resources/prompts/workflow.md +31 -12
- {cli_usereq-0.75.11 → cli_usereq-0.75.16}/src/usereq/resources/prompts/write.md +8 -2
- cli_usereq-0.75.16/src/usereq/resources/prompts-version.txt +1 -0
- {cli_usereq-0.75.11 → cli_usereq-0.75.16}/src/usereq/static_check.py +256 -3
- {cli_usereq-0.75.11 → cli_usereq-0.75.16}/uv.lock +1 -1
- cli_usereq-0.75.11/src/usereq/resources/prompts-version.txt +0 -1
- {cli_usereq-0.75.11 → cli_usereq-0.75.16}/LICENSE +0 -0
- {cli_usereq-0.75.11 → cli_usereq-0.75.16}/MANIFEST.in +0 -0
- {cli_usereq-0.75.11 → cli_usereq-0.75.16}/setup.cfg +0 -0
- {cli_usereq-0.75.11 → cli_usereq-0.75.16}/setup.py +0 -0
- {cli_usereq-0.75.11 → cli_usereq-0.75.16}/src/usereq/__main__.py +0 -0
- {cli_usereq-0.75.11 → cli_usereq-0.75.16}/src/usereq/compress.py +0 -0
- {cli_usereq-0.75.11 → cli_usereq-0.75.16}/src/usereq/compress_files.py +0 -0
- {cli_usereq-0.75.11 → cli_usereq-0.75.16}/src/usereq/doxygen_parser.py +0 -0
- {cli_usereq-0.75.11 → cli_usereq-0.75.16}/src/usereq/find_constructs.py +0 -0
- {cli_usereq-0.75.11 → cli_usereq-0.75.16}/src/usereq/generate_markdown.py +0 -0
- {cli_usereq-0.75.11 → cli_usereq-0.75.16}/src/usereq/resources/guidelines/Google_C++_Style_Guide.md +0 -0
- {cli_usereq-0.75.11 → cli_usereq-0.75.16}/src/usereq/resources/guidelines/Google_Python_Style_Guide.md +0 -0
- {cli_usereq-0.75.11 → cli_usereq-0.75.16}/src/usereq/resources/guidelines/Google_TypeScript_Style_Guide.md +0 -0
- {cli_usereq-0.75.11 → cli_usereq-0.75.16}/src/usereq/resources/guidelines/RFC2119.md +0 -0
- {cli_usereq-0.75.11 → cli_usereq-0.75.16}/src/usereq/resources/templates/Agentic_Text_Authoring_Guidance.md +0 -0
- {cli_usereq-0.75.11 → cli_usereq-0.75.16}/src/usereq/resources/templates/Document_Source_Code_in_Doxygen_Style.md +0 -0
- {cli_usereq-0.75.11 → cli_usereq-0.75.16}/src/usereq/resources/templates/HDT_Test_Authoring_Guide.md +0 -0
- {cli_usereq-0.75.11 → cli_usereq-0.75.16}/src/usereq/resources/templates/Requirements_Template.md +0 -0
- {cli_usereq-0.75.11 → cli_usereq-0.75.16}/src/usereq/source_analyzer.py +0 -0
- {cli_usereq-0.75.11 → cli_usereq-0.75.16}/src/usereq/token_counter.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: cli-usereq
|
|
3
|
-
Version: 0.75.
|
|
3
|
+
Version: 0.75.16
|
|
4
4
|
Summary: Initialize a project with prompts, agents, and templates from the useReq repository.
|
|
5
5
|
Author: Ogekuri
|
|
6
6
|
License-Expression: GPL-3.0-only
|
|
@@ -34,7 +34,7 @@ Dynamic: license-file
|
|
|
34
34
|
> * **No Support or Feature Requests:** Please **do not** open issues, bug reports, or feature requests. They will not be addressed or accepted at this stage of development.
|
|
35
35
|
> * **No Warranty:** This software is provided **"AS IS"**, without warranty of any kind, express or implied. You may use it strictly for **testing and evaluation purposes** at your own sole risk.
|
|
36
36
|
|
|
37
|
-
# useReq / req (0.75.
|
|
37
|
+
# useReq / req (0.75.16)
|
|
38
38
|
|
|
39
39
|
<p align="center">
|
|
40
40
|
<img src="https://img.shields.io/badge/python-3.11%2B-3776AB?style=flat-square&logo=python&logoColor=white" alt="Python 3.11+">
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
> * **No Support or Feature Requests:** Please **do not** open issues, bug reports, or feature requests. They will not be addressed or accepted at this stage of development.
|
|
11
11
|
> * **No Warranty:** This software is provided **"AS IS"**, without warranty of any kind, express or implied. You may use it strictly for **testing and evaluation purposes** at your own sole risk.
|
|
12
12
|
|
|
13
|
-
# useReq / req (0.75.
|
|
13
|
+
# useReq / req (0.75.16)
|
|
14
14
|
|
|
15
15
|
<p align="center">
|
|
16
16
|
<img src="https://img.shields.io/badge/python-3.11%2B-3776AB?style=flat-square&logo=python&logoColor=white" alt="Python 3.11+">
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "cli-usereq"
|
|
7
|
-
version = "0.75.
|
|
7
|
+
version = "0.75.16"
|
|
8
8
|
description = "Initialize a project with prompts, agents, and templates from the useReq repository."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.11"
|
|
@@ -18,7 +18,7 @@ from . import source_analyzer # usereq.source_analyzer submodule
|
|
|
18
18
|
from . import token_counter # usereq.token_counter submodule
|
|
19
19
|
from typing import Any
|
|
20
20
|
|
|
21
|
-
__version__ = "0.75.
|
|
21
|
+
__version__ = "0.75.16"
|
|
22
22
|
"""! @brief Semantic version string of the package."""
|
|
23
23
|
|
|
24
24
|
|
|
@@ -205,6 +205,7 @@ def provider_skills_path(provider: str) -> str:
|
|
|
205
205
|
"""
|
|
206
206
|
return format_home_relative_path(provider_skills_root(provider))
|
|
207
207
|
|
|
208
|
+
|
|
208
209
|
INVALID_WT_NAME_RE = re.compile(r'[<>:"/\\|?*\x00-\x1f\s]')
|
|
209
210
|
"""! @brief Regex matching characters invalid in both Linux and Windows directory names."""
|
|
210
211
|
|
|
@@ -283,7 +284,15 @@ TOOL_PROGRAM_NAME = "cli-usereq"
|
|
|
283
284
|
TOOL_RECEIPT_FILENAME = "uv-receipt.toml"
|
|
284
285
|
"""! @brief Canonical uv tool receipt filename recording the installed requirement source (SRS-343, SRS-440)."""
|
|
285
286
|
|
|
286
|
-
NON_REGISTRY_REQUIREMENT_KEYS = (
|
|
287
|
+
NON_REGISTRY_REQUIREMENT_KEYS = (
|
|
288
|
+
"git",
|
|
289
|
+
"url",
|
|
290
|
+
"path",
|
|
291
|
+
"editable",
|
|
292
|
+
"rev",
|
|
293
|
+
"tag",
|
|
294
|
+
"branch",
|
|
295
|
+
)
|
|
287
296
|
"""! @brief Receipt requirement keys marking a uv tool source other than the PyPI index (SRS-440).
|
|
288
297
|
@details `uv` records the resolved source of every installed tool requirement in its receipt;
|
|
289
298
|
any of these keys means the requirement does not resolve from the PyPI index, so the plain
|
|
@@ -406,7 +415,7 @@ def build_parser() -> argparse.ArgumentParser:
|
|
|
406
415
|
usage = (
|
|
407
416
|
"req [-h] [--upgrade] [--develop] [--dev] [--force] [--uninstall] [--prj-base PRJ_BASE] [--git-base GIT_BASE] "
|
|
408
417
|
"[--set-docs-dir DOCS_DIR] [--set-src-dir SRC_DIR] [--set-tests-dir TESTS_DIR] [--verbose] [--debug] "
|
|
409
|
-
"[--print [PATH]] [--info [PATH]] [--print-raw] [--get PATH] [--set PATH VALUE] [--unset PATH] "
|
|
418
|
+
"[--print [PATH]] [--info [PATH]] [--print-raw] [--write-config] [--get PATH] [--set PATH VALUE] [--unset PATH] "
|
|
410
419
|
"[--enable PROVIDER] [--disable PROVIDER] [--enable-auto-install] [--disable-auto-install] "
|
|
411
420
|
"[--enable-line-numbers] "
|
|
412
421
|
"[--enable-static-check SPEC] [--disable-static-check SPEC] "
|
|
@@ -476,14 +485,22 @@ def build_parser() -> argparse.ArgumentParser:
|
|
|
476
485
|
"formatting or headings."
|
|
477
486
|
),
|
|
478
487
|
)
|
|
488
|
+
parser.add_argument(
|
|
489
|
+
"--write-config",
|
|
490
|
+
action="store_true",
|
|
491
|
+
default=False,
|
|
492
|
+
dest="config_write",
|
|
493
|
+
help=(
|
|
494
|
+
"Write the schema default of every configuration parameter missing "
|
|
495
|
+
"from ~/.config/usereq/config.json without altering stored values."
|
|
496
|
+
),
|
|
497
|
+
)
|
|
479
498
|
parser.add_argument(
|
|
480
499
|
"--get",
|
|
481
500
|
metavar="PATH",
|
|
482
501
|
default=None,
|
|
483
502
|
dest="config_get",
|
|
484
|
-
help=(
|
|
485
|
-
"Print the JSON value stored at the canonical configuration PATH."
|
|
486
|
-
),
|
|
503
|
+
help=("Print the JSON value stored at the canonical configuration PATH."),
|
|
487
504
|
)
|
|
488
505
|
parser.add_argument(
|
|
489
506
|
"--set",
|
|
@@ -491,9 +508,7 @@ def build_parser() -> argparse.ArgumentParser:
|
|
|
491
508
|
metavar=("PATH", "VALUE"),
|
|
492
509
|
default=None,
|
|
493
510
|
dest="config_set",
|
|
494
|
-
help=(
|
|
495
|
-
"Validate and store VALUE at the canonical configuration PATH."
|
|
496
|
-
),
|
|
511
|
+
help=("Validate and store VALUE at the canonical configuration PATH."),
|
|
497
512
|
)
|
|
498
513
|
parser.add_argument(
|
|
499
514
|
"--unset",
|
|
@@ -699,10 +714,7 @@ def build_parser() -> argparse.ArgumentParser:
|
|
|
699
714
|
metavar="WT_NAME",
|
|
700
715
|
default=None,
|
|
701
716
|
dest="git_wt_delete",
|
|
702
|
-
help=(
|
|
703
|
-
"Remove a git worktree and branch by name "
|
|
704
|
-
"(requires --git-base)."
|
|
705
|
-
),
|
|
717
|
+
help=("Remove a git worktree and branch by name (requires --git-base)."),
|
|
706
718
|
)
|
|
707
719
|
# Bare analysis subcommands (SRS-408). Legacy --prefixed forms are not parsed
|
|
708
720
|
# (SRS-409); --prj-base is mandatory exactly per SRS-396/SRS-410 and --git-base is
|
|
@@ -819,10 +831,7 @@ def build_parser() -> argparse.ArgumentParser:
|
|
|
819
831
|
sub = subparsers.add_parser(
|
|
820
832
|
"find",
|
|
821
833
|
parents=[base_options, line_number_options],
|
|
822
|
-
usage=(
|
|
823
|
-
"req find --prj-base PRJ_BASE "
|
|
824
|
-
"[--enable-line-numbers] TAG PATTERN"
|
|
825
|
-
),
|
|
834
|
+
usage=("req find --prj-base PRJ_BASE [--enable-line-numbers] TAG PATTERN"),
|
|
826
835
|
help=(
|
|
827
836
|
"Find and extract specific constructs from the configured src-dir: "
|
|
828
837
|
"find TAG PATTERN. TAG accepts pipe-separated tags; the per-language "
|
|
@@ -866,9 +875,7 @@ def build_parser() -> argparse.ArgumentParser:
|
|
|
866
875
|
sub = subparsers.add_parser(
|
|
867
876
|
"uninstall",
|
|
868
877
|
usage="req uninstall",
|
|
869
|
-
help=(
|
|
870
|
-
"Remove req-* skill artifacts of the configured providers."
|
|
871
|
-
),
|
|
878
|
+
help=("Remove req-* skill artifacts of the configured providers."),
|
|
872
879
|
)
|
|
873
880
|
|
|
874
881
|
sub = subparsers.add_parser(
|
|
@@ -950,7 +957,9 @@ def maybe_print_version(argv: list[str], pypi_latest: Optional[str] = None) -> b
|
|
|
950
957
|
github_latest = None
|
|
951
958
|
pypi_value = pypi_latest if pypi_latest else UNKNOWN_VERSION_LABEL
|
|
952
959
|
github_value = github_latest if github_latest else UNKNOWN_VERSION_LABEL
|
|
953
|
-
print(
|
|
960
|
+
print(
|
|
961
|
+
f"{'Current Installed':<{VERSION_REPORT_LABEL_WIDTH}}: {installed_version}"
|
|
962
|
+
)
|
|
954
963
|
print(f"{'Latest @ PyPI':<{VERSION_REPORT_LABEL_WIDTH}}: {pypi_value}")
|
|
955
964
|
print(f"{'Latest @ GitHub':<{VERSION_REPORT_LABEL_WIDTH}}: {github_value}")
|
|
956
965
|
return True
|
|
@@ -2469,9 +2478,7 @@ def apply_disable_static_check_specs(specs: list[str]) -> None:
|
|
|
2469
2478
|
else:
|
|
2470
2479
|
canonical_lang = STATIC_CHECK_LANG_CANONICAL.get(spec.strip().lower())
|
|
2471
2480
|
if canonical_lang is None:
|
|
2472
|
-
raise ReqError(
|
|
2473
|
-
f"Error: unknown static-check language '{spec}'.", 1
|
|
2474
|
-
)
|
|
2481
|
+
raise ReqError(f"Error: unknown static-check language '{spec}'.", 1)
|
|
2475
2482
|
merged.pop(canonical_lang, None)
|
|
2476
2483
|
for lang in [key for key, entries in merged.items() if not entries]:
|
|
2477
2484
|
del merged[lang]
|
|
@@ -2557,8 +2564,7 @@ def _non_symlink_regular_files(directory: Path) -> list[Path]:
|
|
|
2557
2564
|
entries = [
|
|
2558
2565
|
Path(entry.path)
|
|
2559
2566
|
for entry in os.scandir(directory)
|
|
2560
|
-
if entry.is_file(follow_symlinks=False)
|
|
2561
|
-
and not entry.name.startswith(".")
|
|
2567
|
+
if entry.is_file(follow_symlinks=False) and not entry.name.startswith(".")
|
|
2562
2568
|
]
|
|
2563
2569
|
return sorted(entries)
|
|
2564
2570
|
|
|
@@ -2609,9 +2615,7 @@ def generate_templates_file_names() -> list[str]:
|
|
|
2609
2615
|
@return {list[str]} Bare template file names in deterministic sorted order.
|
|
2610
2616
|
@satisfies SRS-498, SRS-514, SRS-516
|
|
2611
2617
|
"""
|
|
2612
|
-
return [
|
|
2613
|
-
file_path.name for file_path in _non_symlink_regular_files(templates_dir())
|
|
2614
|
-
]
|
|
2618
|
+
return [file_path.name for file_path in _non_symlink_regular_files(templates_dir())]
|
|
2615
2619
|
|
|
2616
2620
|
|
|
2617
2621
|
def _print_resource_report() -> None:
|
|
@@ -2861,6 +2865,7 @@ def prune_empty_dirs(root: Path) -> None:
|
|
|
2861
2865
|
except OSError:
|
|
2862
2866
|
continue
|
|
2863
2867
|
|
|
2868
|
+
|
|
2864
2869
|
def remove_generated_resources() -> None:
|
|
2865
2870
|
"""!
|
|
2866
2871
|
@brief Removes `req-*` skill artifacts generated by the tool from user-level provider directories.
|
|
@@ -2893,6 +2898,7 @@ def remove_generated_resources() -> None:
|
|
|
2893
2898
|
if root.is_dir():
|
|
2894
2899
|
prune_empty_dirs(root)
|
|
2895
2900
|
|
|
2901
|
+
|
|
2896
2902
|
def _render_simple_table(headers: list[str], rows: list[list[str]]) -> str:
|
|
2897
2903
|
"""!
|
|
2898
2904
|
@brief Render one Unicode box-drawing table from headers and rows.
|
|
@@ -2909,9 +2915,7 @@ def _render_simple_table(headers: list[str], rows: list[list[str]]) -> str:
|
|
|
2909
2915
|
def _line(cells: list[str]) -> str:
|
|
2910
2916
|
return (
|
|
2911
2917
|
"│ "
|
|
2912
|
-
+ " │ ".join(
|
|
2913
|
-
cell.ljust(widths[index]) for index, cell in enumerate(cells)
|
|
2914
|
-
)
|
|
2918
|
+
+ " │ ".join(cell.ljust(widths[index]) for index, cell in enumerate(cells))
|
|
2915
2919
|
+ " │"
|
|
2916
2920
|
)
|
|
2917
2921
|
|
|
@@ -3010,9 +3014,7 @@ def run_show(args: Namespace) -> None:
|
|
|
3010
3014
|
doc_dir_value = str(config["docs-dir"])
|
|
3011
3015
|
test_dir_value = str(config["tests-dir"])
|
|
3012
3016
|
src_dir_value = ", ".join(str(item) for item in config["src-dir"])
|
|
3013
|
-
auto_install_state = (
|
|
3014
|
-
"enabled" if load_auto_install_enabled() else "disabled"
|
|
3015
|
-
)
|
|
3017
|
+
auto_install_state = "enabled" if load_auto_install_enabled() else "disabled"
|
|
3016
3018
|
print("Active Configuration")
|
|
3017
3019
|
print(
|
|
3018
3020
|
_render_simple_table(
|
|
@@ -3090,11 +3092,7 @@ def run_show(args: Namespace) -> None:
|
|
|
3090
3092
|
print()
|
|
3091
3093
|
print("Static Checks")
|
|
3092
3094
|
if sc_rows:
|
|
3093
|
-
print(
|
|
3094
|
-
_render_simple_table(
|
|
3095
|
-
["Language", "Module", "Cmd", "Params"], sc_rows
|
|
3096
|
-
)
|
|
3097
|
-
)
|
|
3095
|
+
print(_render_simple_table(["Language", "Module", "Cmd", "Params"], sc_rows))
|
|
3098
3096
|
else:
|
|
3099
3097
|
print("(none)")
|
|
3100
3098
|
|
|
@@ -3188,6 +3186,7 @@ def run_set_directories(args: Namespace) -> None:
|
|
|
3188
3186
|
if normalized_srcs is not None:
|
|
3189
3187
|
log(f"OK: src-dir set to {', '.join(normalized_srcs)}")
|
|
3190
3188
|
|
|
3189
|
+
|
|
3191
3190
|
def _validate_enable_static_check_command_executables(
|
|
3192
3191
|
static_check_config: Mapping[str, list[dict[str, Any]]],
|
|
3193
3192
|
*,
|
|
@@ -3358,7 +3357,6 @@ def run(args: Namespace) -> None:
|
|
|
3358
3357
|
print(f"Installation completed successfully in {home_value}")
|
|
3359
3358
|
_print_resource_report()
|
|
3360
3359
|
|
|
3361
|
-
|
|
3362
3360
|
# Build and print installation report table with per-provider skills details.
|
|
3363
3361
|
def _format_install_table(
|
|
3364
3362
|
skills_map: dict[str, set[str]],
|
|
@@ -3432,9 +3430,9 @@ def run(args: Namespace) -> None:
|
|
|
3432
3430
|
provider_part = (
|
|
3433
3431
|
provider_lines[idx] if idx < len(provider_lines) else ""
|
|
3434
3432
|
).ljust(provider_width)
|
|
3435
|
-
skill_part = (
|
|
3436
|
-
|
|
3437
|
-
)
|
|
3433
|
+
skill_part = (skill_lines[idx] if idx < len(skill_lines) else "").ljust(
|
|
3434
|
+
skills_width
|
|
3435
|
+
)
|
|
3438
3436
|
lines.append(f"\u2502 {provider_part} \u2502 {skill_part} \u2502")
|
|
3439
3437
|
return lines
|
|
3440
3438
|
|
|
@@ -3461,7 +3459,9 @@ def run(args: Namespace) -> None:
|
|
|
3461
3459
|
@param line {str} One already-rendered table line.
|
|
3462
3460
|
@return {str} Line with border glyphs wrapped in ANSI bright-red and reset sequences.
|
|
3463
3461
|
"""
|
|
3464
|
-
border_chars = frozenset(
|
|
3462
|
+
border_chars = frozenset(
|
|
3463
|
+
"\u250c\u252c\u2510\u251c\u253c\u2524\u2514\u2534\u2518\u2500\u2502"
|
|
3464
|
+
)
|
|
3465
3465
|
return "".join(
|
|
3466
3466
|
f"{ANSI_BRIGHT_RED}{char}{ANSI_RESET}" if char in border_chars else char
|
|
3467
3467
|
for char in line
|
|
@@ -3738,12 +3738,15 @@ def _require_git_base(args: Namespace) -> Path:
|
|
|
3738
3738
|
"""
|
|
3739
3739
|
return resolve_git_root(_require_git_base_value(args))
|
|
3740
3740
|
|
|
3741
|
+
|
|
3741
3742
|
def run_git_check(args: Namespace) -> None:
|
|
3742
3743
|
"""!
|
|
3743
3744
|
@brief Execute --git-check: verify clean git status and valid HEAD.
|
|
3744
3745
|
@param args Parsed CLI namespace.
|
|
3745
3746
|
@return {None} Function return value.
|
|
3746
3747
|
@throws ReqError On git status unclear or when `--git-base` is outside a git repository.
|
|
3748
|
+
@details On failure prints `ERROR: Git status unclear!` to stdout per SRS-312 before
|
|
3749
|
+
raising; `main()` additionally forwards the message to stderr via ReqError handling.
|
|
3747
3750
|
@satisfies SRS-311, SRS-312, SRS-391, SRS-397
|
|
3748
3751
|
"""
|
|
3749
3752
|
git_path = _require_git_base(args)
|
|
@@ -3761,8 +3764,10 @@ def run_git_check(args: Namespace) -> None:
|
|
|
3761
3764
|
timeout=30,
|
|
3762
3765
|
)
|
|
3763
3766
|
except (FileNotFoundError, subprocess.TimeoutExpired, OSError):
|
|
3767
|
+
print("ERROR: Git status unclear!")
|
|
3764
3768
|
raise ReqError("ERROR: Git status unclear!", 1)
|
|
3765
3769
|
if result.returncode != 0:
|
|
3770
|
+
print("ERROR: Git status unclear!")
|
|
3766
3771
|
raise ReqError("ERROR: Git status unclear!", 1)
|
|
3767
3772
|
|
|
3768
3773
|
|
|
@@ -4235,8 +4240,9 @@ def run_files_static_check_cmd(files: list[str], args: Namespace) -> int:
|
|
|
4235
4240
|
- For `Command` module entries, execution order is `<cmd> [params...] <filename>`.
|
|
4236
4241
|
Dispatch context provides project root for checker runtime execution.
|
|
4237
4242
|
All checks execute with `fail_only=True`: passing checks produce no stdout output (SRS-253).
|
|
4243
|
+
The command ignores `"scan-by-dir"` and always dispatches per explicit input file (SRS-591).
|
|
4238
4244
|
Overall exit code: max of all per-file codes (0=all pass, 1=any fail). (SRS-253, SRS-255)
|
|
4239
|
-
@see SRS-253, SRS-254, SRS-255, SRS-341, SRS-396, SRS-408
|
|
4245
|
+
@see SRS-253, SRS-254, SRS-255, SRS-341, SRS-396, SRS-408, SRS-591
|
|
4240
4246
|
"""
|
|
4241
4247
|
from .static_check import STATIC_CHECK_EXT_TO_LANG, dispatch_static_check_for_file
|
|
4242
4248
|
|
|
@@ -4297,18 +4303,34 @@ def run_project_static_check_cmd(args: Namespace) -> int:
|
|
|
4297
4303
|
diagnostics unrelated to project code quality gates.
|
|
4298
4304
|
For each collected file:
|
|
4299
4305
|
- Detects language via `STATIC_CHECK_EXT_TO_LANG` keyed on lowercase extension.
|
|
4306
|
+
- Groups files under ordered, deduplicated scan roots: the configured `src-dir`
|
|
4307
|
+
entries followed by `tests-dir` (SRS-588).
|
|
4308
|
+
Per scan root and language:
|
|
4300
4309
|
- Looks up language in the `"static-check"` section of `~/.config/usereq/config.json`.
|
|
4301
4310
|
- Skips silently when no tool is configured for the file's language.
|
|
4302
|
-
-
|
|
4303
|
-
|
|
4304
|
-
-
|
|
4311
|
+
- Resolves each configured entry's directory-scan mode through `entry_scan_by_dir`
|
|
4312
|
+
(SRS-584, SRS-585).
|
|
4313
|
+
- Dispatches `"scan-by-dir"`-false entries per selected file via
|
|
4314
|
+
`dispatch_static_check_for_file(filepath, lang_config, fail_only=True, project_base=...)`
|
|
4315
|
+
(SRS-587); for `Command` entries, execution order is `<cmd> [params...] <filename>`.
|
|
4316
|
+
- Dispatches `"scan-by-dir"`-true entries as exactly one recursive
|
|
4317
|
+
`dispatch_static_check_for_directory(root, lang_config, fail_only=True, project_base=...)`
|
|
4318
|
+
invocation per root containing selected files of the entry's language (SRS-588, SRS-589);
|
|
4319
|
+
for `Command` entries, execution order is `<cmd> [params...] <root>`.
|
|
4320
|
+
- Excludes existing fixture-corpus directories from directory invocations through
|
|
4321
|
+
module-native exclusion flags (SRS-590).
|
|
4305
4322
|
Dispatch context provides project root for checker runtime execution.
|
|
4306
4323
|
All checks execute with `fail_only=True`: passing checks produce no stdout output (SRS-256).
|
|
4307
|
-
Overall exit code: max of all
|
|
4324
|
+
Overall exit code: max of all dispatch codes (0=all pass, 1=any fail). (SRS-256, SRS-257)
|
|
4308
4325
|
@throws ReqError If no source files are found.
|
|
4309
|
-
@see SRS-256, SRS-257, SRS-336, SRS-341, SRS-396, SRS-408
|
|
4326
|
+
@see SRS-256, SRS-257, SRS-336, SRS-341, SRS-396, SRS-408, SRS-584, SRS-585, SRS-587, SRS-588, SRS-589, SRS-590, SRS-592
|
|
4310
4327
|
"""
|
|
4311
|
-
from .static_check import
|
|
4328
|
+
from .static_check import (
|
|
4329
|
+
STATIC_CHECK_EXT_TO_LANG,
|
|
4330
|
+
dispatch_static_check_for_directory,
|
|
4331
|
+
dispatch_static_check_for_file,
|
|
4332
|
+
entry_scan_by_dir,
|
|
4333
|
+
)
|
|
4312
4334
|
|
|
4313
4335
|
project_base, src_dirs = _resolve_project_src_dirs(args)
|
|
4314
4336
|
sc_config = load_static_check_from_config()
|
|
@@ -4359,26 +4381,79 @@ def run_project_static_check_cmd(args: Namespace) -> int:
|
|
|
4359
4381
|
if not files:
|
|
4360
4382
|
raise ReqError("Error: no source files found in configured directories.", 1)
|
|
4361
4383
|
|
|
4362
|
-
|
|
4384
|
+
# SRS-588: ordered, deduplicated scan roots = configured src-dir entries plus tests-dir.
|
|
4385
|
+
scan_roots: list[Path] = []
|
|
4386
|
+
for rel_dir in selection_dirs:
|
|
4387
|
+
root = (project_base / rel_dir).resolve()
|
|
4388
|
+
if root not in scan_roots:
|
|
4389
|
+
scan_roots.append(root)
|
|
4390
|
+
|
|
4391
|
+
files_by_root: dict[Path, list[str]] = {}
|
|
4363
4392
|
for filepath in files:
|
|
4364
|
-
|
|
4365
|
-
|
|
4366
|
-
|
|
4367
|
-
|
|
4393
|
+
candidate = Path(filepath)
|
|
4394
|
+
for root in scan_roots:
|
|
4395
|
+
if root in candidate.parents:
|
|
4396
|
+
files_by_root.setdefault(root, []).append(filepath)
|
|
4397
|
+
break
|
|
4398
|
+
|
|
4399
|
+
# SRS-590: existing fixture-corpus directories excluded from directory invocations.
|
|
4400
|
+
exclude_by_root: dict[Path, list[str]] = {}
|
|
4401
|
+
for fixture_root in fixture_roots:
|
|
4402
|
+
fixtures_abs = (project_base / fixture_root).resolve()
|
|
4403
|
+
if not fixtures_abs.is_dir():
|
|
4368
4404
|
continue
|
|
4369
|
-
|
|
4370
|
-
|
|
4371
|
-
|
|
4405
|
+
for root in scan_roots:
|
|
4406
|
+
if root in fixtures_abs.parents:
|
|
4407
|
+
exclude_by_root.setdefault(root, []).append(str(fixtures_abs))
|
|
4408
|
+
|
|
4409
|
+
overall = 0
|
|
4410
|
+
for root in scan_roots:
|
|
4411
|
+
root_files = files_by_root.get(root, [])
|
|
4412
|
+
if not root_files:
|
|
4372
4413
|
continue
|
|
4373
|
-
|
|
4374
|
-
|
|
4375
|
-
|
|
4376
|
-
|
|
4377
|
-
|
|
4378
|
-
|
|
4379
|
-
|
|
4380
|
-
|
|
4381
|
-
|
|
4414
|
+
languages = sorted(
|
|
4415
|
+
{
|
|
4416
|
+
lang
|
|
4417
|
+
for lang in (
|
|
4418
|
+
STATIC_CHECK_EXT_TO_LANG.get(Path(filepath).suffix.lower())
|
|
4419
|
+
for filepath in root_files
|
|
4420
|
+
)
|
|
4421
|
+
if lang
|
|
4422
|
+
}
|
|
4423
|
+
)
|
|
4424
|
+
for lang in languages:
|
|
4425
|
+
lang_configs = sc_config.get(lang)
|
|
4426
|
+
if not lang_configs:
|
|
4427
|
+
vlog(f"Skipping {root}: no static-check config for language '{lang}'")
|
|
4428
|
+
continue
|
|
4429
|
+
lang_files = [
|
|
4430
|
+
filepath
|
|
4431
|
+
for filepath in root_files
|
|
4432
|
+
if STATIC_CHECK_EXT_TO_LANG.get(Path(filepath).suffix.lower()) == lang
|
|
4433
|
+
]
|
|
4434
|
+
for lang_config in lang_configs:
|
|
4435
|
+
# SRS-587/SRS-588: per-file dispatch when scan-by-dir resolves false;
|
|
4436
|
+
# one recursive directory invocation per root otherwise.
|
|
4437
|
+
if entry_scan_by_dir(lang_config):
|
|
4438
|
+
rc = dispatch_static_check_for_directory(
|
|
4439
|
+
str(root),
|
|
4440
|
+
lang_config,
|
|
4441
|
+
fail_only=True,
|
|
4442
|
+
project_base=project_base,
|
|
4443
|
+
exclude_dirs=exclude_by_root.get(root, []),
|
|
4444
|
+
)
|
|
4445
|
+
if rc != 0:
|
|
4446
|
+
overall = 1
|
|
4447
|
+
continue
|
|
4448
|
+
for filepath in lang_files:
|
|
4449
|
+
rc = dispatch_static_check_for_file(
|
|
4450
|
+
filepath,
|
|
4451
|
+
lang_config,
|
|
4452
|
+
fail_only=True,
|
|
4453
|
+
project_base=project_base,
|
|
4454
|
+
)
|
|
4455
|
+
if rc != 0:
|
|
4456
|
+
overall = 1
|
|
4382
4457
|
return overall
|
|
4383
4458
|
|
|
4384
4459
|
|
|
@@ -4432,12 +4507,14 @@ def _is_config_schema_command(args: Namespace) -> bool:
|
|
|
4432
4507
|
@param args {Namespace} Parsed CLI namespace.
|
|
4433
4508
|
@return {bool} True when any configuration schema command flag is present.
|
|
4434
4509
|
@details Configuration schema commands are `--print`, `--info`, `--print-raw`,
|
|
4435
|
-
`--get`, `--set`, and `--unset` (SRS-519); they never
|
|
4510
|
+
`--write-config`, `--get`, `--set`, and `--unset` (SRS-519, SRS-593); they never
|
|
4511
|
+
trigger provider installation.
|
|
4436
4512
|
"""
|
|
4437
4513
|
return (
|
|
4438
4514
|
getattr(args, "config_print", None) is not None
|
|
4439
4515
|
or getattr(args, "config_info", None) is not None
|
|
4440
4516
|
or bool(getattr(args, "config_print_raw", False))
|
|
4517
|
+
or bool(getattr(args, "config_write", False))
|
|
4441
4518
|
or getattr(args, "config_get", None) is not None
|
|
4442
4519
|
or getattr(args, "config_set", None) is not None
|
|
4443
4520
|
or getattr(args, "config_unset", None) is not None
|
|
@@ -4449,23 +4526,28 @@ def run_config_schema_command(args: Namespace) -> int:
|
|
|
4449
4526
|
@brief Execute one configuration schema command.
|
|
4450
4527
|
@param args {Namespace} Parsed CLI namespace carrying the configuration flag values.
|
|
4451
4528
|
@return {int} Process exit code: 0 on success, 1 on any configuration failure.
|
|
4452
|
-
@details Dispatches `--print`, `--info`, `--print-raw`, `--
|
|
4453
|
-
`--unset` against the user-global configuration file, writes payloads
|
|
4454
|
-
and reports every diagnostic on stderr (SRS-519, SRS-532).
|
|
4455
|
-
|
|
4529
|
+
@details Dispatches `--print`, `--info`, `--print-raw`, `--write-config`, `--get`,
|
|
4530
|
+
`--set`, and `--unset` against the user-global configuration file, writes payloads
|
|
4531
|
+
to stdout, and reports every diagnostic on stderr (SRS-519, SRS-532, SRS-597).
|
|
4532
|
+
`--write-config` persists the schema default of every canonical top-level parameter
|
|
4533
|
+
missing from the stored payload without altering stored values (SRS-593, SRS-594)
|
|
4534
|
+
through the validated atomic writer (SRS-595, SRS-596).
|
|
4535
|
+
@satisfies SRS-519, SRS-527, SRS-528, SRS-529, SRS-530, SRS-531, SRS-532, SRS-593,
|
|
4536
|
+
SRS-594, SRS-595, SRS-596, SRS-597
|
|
4456
4537
|
"""
|
|
4457
4538
|
enabled = [
|
|
4458
4539
|
getattr(args, "config_print", None) is not None,
|
|
4459
4540
|
getattr(args, "config_info", None) is not None,
|
|
4460
4541
|
bool(getattr(args, "config_print_raw", False)),
|
|
4542
|
+
bool(getattr(args, "config_write", False)),
|
|
4461
4543
|
getattr(args, "config_get", None) is not None,
|
|
4462
4544
|
getattr(args, "config_set", None) is not None,
|
|
4463
4545
|
getattr(args, "config_unset", None) is not None,
|
|
4464
4546
|
]
|
|
4465
4547
|
if sum(1 for flag in enabled if flag) > 1:
|
|
4466
4548
|
print(
|
|
4467
|
-
"Error: use exactly one of --print, --info, --print-raw,
|
|
4468
|
-
"--set, or --unset.",
|
|
4549
|
+
"Error: use exactly one of --print, --info, --print-raw, "
|
|
4550
|
+
"--write-config, --get, --set, or --unset.",
|
|
4469
4551
|
file=sys.stderr,
|
|
4470
4552
|
)
|
|
4471
4553
|
return 1
|
|
@@ -4480,6 +4562,9 @@ def run_config_schema_command(args: Namespace) -> int:
|
|
|
4480
4562
|
else:
|
|
4481
4563
|
sys.stdout.write(payload.decode("utf-8"))
|
|
4482
4564
|
return 0
|
|
4565
|
+
if getattr(args, "config_write", False):
|
|
4566
|
+
config_cli.handle_write_config(config_path)
|
|
4567
|
+
return 0
|
|
4483
4568
|
get_path = getattr(args, "config_get", None)
|
|
4484
4569
|
if get_path is not None:
|
|
4485
4570
|
print(config_cli.handle_get(config_path, get_path))
|
|
@@ -35,6 +35,7 @@ from .config_schema import (
|
|
|
35
35
|
ROOT_LABEL,
|
|
36
36
|
SchemaNode,
|
|
37
37
|
find_field,
|
|
38
|
+
static_check_dir_scan_default,
|
|
38
39
|
)
|
|
39
40
|
|
|
40
41
|
BRANCH = "├── "
|
|
@@ -178,7 +179,8 @@ def validate_node(node: SchemaNode, value: Any, path: str) -> None:
|
|
|
178
179
|
@return {None} Function return value.
|
|
179
180
|
@throws {ConfigError} Raised with an English diagnostic on any schema violation.
|
|
180
181
|
@details Covers primitives, enums, arrays, map keys, fixed-field dictionaries, required
|
|
181
|
-
fields,
|
|
182
|
+
fields, the Command `cmd` cross-field constraint, and the `scan-by-dir` capability
|
|
183
|
+
cross-field constraint (SRS-530, SRS-536, SRS-586).
|
|
182
184
|
"""
|
|
183
185
|
if node.kind == KIND_STRING:
|
|
184
186
|
if not isinstance(value, str):
|
|
@@ -251,6 +253,13 @@ def validate_node(node: SchemaNode, value: Any, path: str) -> None:
|
|
|
251
253
|
raise ConfigError(
|
|
252
254
|
f"Error: '{path}:cmd' is required when module is Command."
|
|
253
255
|
)
|
|
256
|
+
if value.get("scan-by-dir") is True and not static_check_dir_scan_default(
|
|
257
|
+
value.get("module"), value.get("cmd")
|
|
258
|
+
):
|
|
259
|
+
raise ConfigError(
|
|
260
|
+
f"Error: '{path}:scan-by-dir' must be false or absent: this entry does "
|
|
261
|
+
"not support directory scanning."
|
|
262
|
+
)
|
|
254
263
|
return
|
|
255
264
|
if node.kind == KIND_SECTION:
|
|
256
265
|
if not isinstance(value, dict):
|
|
@@ -1329,6 +1338,30 @@ def handle_unset(config_path: Path, path: str) -> None:
|
|
|
1329
1338
|
write_config(config_path, updated)
|
|
1330
1339
|
|
|
1331
1340
|
|
|
1341
|
+
def handle_write_config(config_path: Path) -> None:
|
|
1342
|
+
"""!
|
|
1343
|
+
@brief Persist schema defaults for canonical parameters missing from the stored payload.
|
|
1344
|
+
@details Bootstraps an absent configuration file from schema defaults (SRS-529),
|
|
1345
|
+
validates the complete resulting configuration before any write (SRS-530), writes the
|
|
1346
|
+
merged payload through the SRS-531 atomic writer only when at least one canonical
|
|
1347
|
+
top-level parameter is missing from the stored payload, and never alters the stored
|
|
1348
|
+
value of any parameter already present (SRS-593, SRS-594, SRS-595, SRS-596, SRS-597).
|
|
1349
|
+
Complexity: O(K) over K canonical top-level keys. Side effects: at most one atomic
|
|
1350
|
+
configuration write; no write occurs when every canonical key is already present.
|
|
1351
|
+
@param config_path {Path} Absolute global configuration file path.
|
|
1352
|
+
@return {None} Function return value.
|
|
1353
|
+
@throws {ConfigError} Raised when the file is unreadable, a stored canonical value
|
|
1354
|
+
violates the schema, or the atomic write fails; the stored file is preserved.
|
|
1355
|
+
@satisfies SRS-529, SRS-530, SRS-531, SRS-593, SRS-594, SRS-595, SRS-596, SRS-597
|
|
1356
|
+
"""
|
|
1357
|
+
ensure_config_file(config_path)
|
|
1358
|
+
raw = read_raw_payload(config_path)
|
|
1359
|
+
missing = [key for key in CONFIG_KEYS if key not in raw]
|
|
1360
|
+
if not missing:
|
|
1361
|
+
return
|
|
1362
|
+
write_config(config_path, normalize_config(raw))
|
|
1363
|
+
|
|
1364
|
+
|
|
1332
1365
|
def handle_print_raw(config_path: Path) -> bytes:
|
|
1333
1366
|
"""!
|
|
1334
1367
|
@brief Return the unmodified on-disk configuration file bytes.
|
|
@@ -97,6 +97,41 @@ STATIC_CHECK_LANGUAGES = (
|
|
|
97
97
|
STATIC_CHECK_MODULES = ("Dummy", "Pylance", "Ruff", "Command")
|
|
98
98
|
"""! @brief Canonical static-check module names accepted by the entry schema (SRS-250)."""
|
|
99
99
|
|
|
100
|
+
STATIC_CHECK_DIR_SCAN_MODULES: frozenset[str] = frozenset({"Pylance", "Ruff"})
|
|
101
|
+
"""! @brief Built-in static-check modules supporting recursive directory-scan execution (SRS-584)."""
|
|
102
|
+
|
|
103
|
+
STATIC_CHECK_DIR_SCAN_COMMANDS: frozenset[str] = frozenset(
|
|
104
|
+
{"cppcheck", "eslint", "ruff", "pyright"}
|
|
105
|
+
)
|
|
106
|
+
"""! @brief Command `cmd` binaries supporting recursive directory-scan execution (SRS-584)."""
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
def static_check_dir_scan_default(module: Any, cmd: Any = None) -> bool:
|
|
110
|
+
"""!
|
|
111
|
+
@brief Resolve the default directory-scan mode of one static-check entry.
|
|
112
|
+
@param module {Any} Raw module token; matched case-insensitively against
|
|
113
|
+
`STATIC_CHECK_MODULES`.
|
|
114
|
+
@param cmd {Any} Raw Command `cmd` token; matched lowercased against
|
|
115
|
+
`STATIC_CHECK_DIR_SCAN_COMMANDS`.
|
|
116
|
+
@return {bool} True exactly for SRS-584 directory-scan-capable entries, False otherwise.
|
|
117
|
+
@details Capability table: `Pylance` and `Ruff` are always capable, `Dummy` is never
|
|
118
|
+
capable, and `Command` is capable exactly when `cmd` is `cppcheck`, `eslint`, `ruff`,
|
|
119
|
+
or `pyright`. Non-string tokens are never capable. Complexity: O(1). No side effects.
|
|
120
|
+
@satisfies SRS-584, SRS-585
|
|
121
|
+
"""
|
|
122
|
+
if not isinstance(module, str):
|
|
123
|
+
return False
|
|
124
|
+
module_key = module.strip().lower()
|
|
125
|
+
for canonical in STATIC_CHECK_MODULES:
|
|
126
|
+
if canonical.lower() != module_key:
|
|
127
|
+
continue
|
|
128
|
+
if canonical in STATIC_CHECK_DIR_SCAN_MODULES:
|
|
129
|
+
return True
|
|
130
|
+
if canonical == "Command" and isinstance(cmd, str):
|
|
131
|
+
return cmd.strip().lower() in STATIC_CHECK_DIR_SCAN_COMMANDS
|
|
132
|
+
return False
|
|
133
|
+
return False
|
|
134
|
+
|
|
100
135
|
DEFAULT_STATIC_CHECK: dict[str, list[dict[str, Any]]] = {
|
|
101
136
|
"C": [
|
|
102
137
|
{
|
|
@@ -167,7 +202,7 @@ class SchemaNode:
|
|
|
167
202
|
def _entry_fields() -> tuple[SchemaNode, ...]:
|
|
168
203
|
"""!
|
|
169
204
|
@brief Build the fixed field set of one static-check dictionary entry (SRS-540).
|
|
170
|
-
@return {tuple[SchemaNode, ...]} Ordered `module`, `cmd`, and `
|
|
205
|
+
@return {tuple[SchemaNode, ...]} Ordered `module`, `cmd`, `params`, and `scan-by-dir` field nodes.
|
|
171
206
|
"""
|
|
172
207
|
return (
|
|
173
208
|
SchemaNode(
|
|
@@ -203,6 +238,14 @@ def _entry_fields() -> tuple[SchemaNode, ...]:
|
|
|
203
238
|
non_empty=False,
|
|
204
239
|
),
|
|
205
240
|
),
|
|
241
|
+
SchemaNode(
|
|
242
|
+
token="scan-by-dir",
|
|
243
|
+
kind=KIND_BOOLEAN,
|
|
244
|
+
description="Recursive directory-scan execution mode.",
|
|
245
|
+
constraints="true only for directory-scan-capable entries",
|
|
246
|
+
optional=True,
|
|
247
|
+
example="true",
|
|
248
|
+
),
|
|
206
249
|
)
|
|
207
250
|
|
|
208
251
|
|
|
@@ -211,7 +254,7 @@ _STATIC_CHECK_ENTRY = SchemaNode(
|
|
|
211
254
|
kind=KIND_DICTIONARY,
|
|
212
255
|
description="One static-check entry.",
|
|
213
256
|
type_label="Dictionary",
|
|
214
|
-
constraints="fields: module, cmd, params",
|
|
257
|
+
constraints="fields: module, cmd, params, scan-by-dir",
|
|
215
258
|
fields=_entry_fields(),
|
|
216
259
|
)
|
|
217
260
|
"""! @brief Fixed-schema dictionary describing one static-check entry (SRS-540)."""
|