@grifhinz/logics-manager 2.0.4 → 2.0.5
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.
- package/README.md +2 -2
- package/VERSION +1 -1
- package/logics_manager/assist.py +366 -0
- package/logics_manager/cli.py +106 -38
- package/logics_manager/flow.py +570 -1
- package/logics_manager/sync.py +138 -0
- package/logics_manager/termstyle.py +75 -0
- package/package.json +2 -1
- package/pyproject.toml +1 -1
package/logics_manager/sync.py
CHANGED
|
@@ -10,6 +10,7 @@ from pathlib import Path
|
|
|
10
10
|
|
|
11
11
|
from .config import find_repo_root
|
|
12
12
|
from .lint import expected_workflow_mermaid_signature
|
|
13
|
+
from .termstyle import colorize_help
|
|
13
14
|
|
|
14
15
|
|
|
15
16
|
@dataclass(frozen=True)
|
|
@@ -499,6 +500,137 @@ def build_parser() -> argparse.ArgumentParser:
|
|
|
499
500
|
return parser
|
|
500
501
|
|
|
501
502
|
|
|
503
|
+
def _build_help() -> str:
|
|
504
|
+
return "\n".join(
|
|
505
|
+
[
|
|
506
|
+
"Logics Sync CLI",
|
|
507
|
+
"Manage workflow transitions and exports.",
|
|
508
|
+
"",
|
|
509
|
+
"Usage:",
|
|
510
|
+
" logics-manager sync <command> [args...]",
|
|
511
|
+
"",
|
|
512
|
+
"Commands:",
|
|
513
|
+
" close-eligible-requests",
|
|
514
|
+
" Auto-close requests when all linked backlog items are done.",
|
|
515
|
+
" Flags: --format {text,json}, --dry-run",
|
|
516
|
+
"",
|
|
517
|
+
" refresh-mermaid-signatures",
|
|
518
|
+
" Refresh stale Mermaid signatures without rewriting diagram bodies.",
|
|
519
|
+
" Flags: --format {text,json}, --dry-run",
|
|
520
|
+
"",
|
|
521
|
+
" schema-status [sources...]",
|
|
522
|
+
" Report schema-version coverage for selected workflow docs.",
|
|
523
|
+
" Flags: --format {text,json}",
|
|
524
|
+
"",
|
|
525
|
+
" context-pack <ref>",
|
|
526
|
+
" Build a compact JSON context pack from workflow docs.",
|
|
527
|
+
" Flags: --mode {summary-only,diff-first,full}, --profile {tiny,normal,deep}, --out, --format {text,json}, --dry-run",
|
|
528
|
+
"",
|
|
529
|
+
" export-graph",
|
|
530
|
+
" Export workflow relationships as a machine-readable graph.",
|
|
531
|
+
" Flags: --out, --format {text,json}, --dry-run",
|
|
532
|
+
"",
|
|
533
|
+
"Examples:",
|
|
534
|
+
" logics-manager sync schema-status",
|
|
535
|
+
" logics-manager sync context-pack req_001_my_request --out logics/context-pack.json",
|
|
536
|
+
" logics-manager sync export-graph --format json",
|
|
537
|
+
]
|
|
538
|
+
)
|
|
539
|
+
|
|
540
|
+
|
|
541
|
+
def _build_subcommand_help(command: str) -> str:
|
|
542
|
+
if command == "close-eligible-requests":
|
|
543
|
+
return "\n".join(
|
|
544
|
+
[
|
|
545
|
+
"Logics Sync Close Eligible Requests",
|
|
546
|
+
"Auto-close requests when all linked backlog items are done.",
|
|
547
|
+
"",
|
|
548
|
+
"Usage:",
|
|
549
|
+
" logics-manager sync close-eligible-requests [args...]",
|
|
550
|
+
"",
|
|
551
|
+
"Flags:",
|
|
552
|
+
" --format {text,json}",
|
|
553
|
+
" --dry-run",
|
|
554
|
+
"",
|
|
555
|
+
"Example:",
|
|
556
|
+
" logics-manager sync close-eligible-requests --dry-run",
|
|
557
|
+
]
|
|
558
|
+
)
|
|
559
|
+
if command == "refresh-mermaid-signatures":
|
|
560
|
+
return "\n".join(
|
|
561
|
+
[
|
|
562
|
+
"Logics Sync Refresh Mermaid Signatures",
|
|
563
|
+
"Refresh stale workflow Mermaid signatures without rewriting diagram bodies.",
|
|
564
|
+
"",
|
|
565
|
+
"Usage:",
|
|
566
|
+
" logics-manager sync refresh-mermaid-signatures [args...]",
|
|
567
|
+
"",
|
|
568
|
+
"Flags:",
|
|
569
|
+
" --format {text,json}",
|
|
570
|
+
" --dry-run",
|
|
571
|
+
]
|
|
572
|
+
)
|
|
573
|
+
if command == "schema-status":
|
|
574
|
+
return "\n".join(
|
|
575
|
+
[
|
|
576
|
+
"Logics Sync Schema Status",
|
|
577
|
+
"Report schema-version coverage for workflow docs.",
|
|
578
|
+
"",
|
|
579
|
+
"Usage:",
|
|
580
|
+
" logics-manager sync schema-status [sources...]",
|
|
581
|
+
"",
|
|
582
|
+
"Flags:",
|
|
583
|
+
" --format {text,json}",
|
|
584
|
+
"",
|
|
585
|
+
"Example:",
|
|
586
|
+
" logics-manager sync schema-status logics/request",
|
|
587
|
+
]
|
|
588
|
+
)
|
|
589
|
+
if command == "context-pack":
|
|
590
|
+
return "\n".join(
|
|
591
|
+
[
|
|
592
|
+
"Logics Sync Context Pack",
|
|
593
|
+
"Build a compact JSON context pack from workflow docs.",
|
|
594
|
+
"",
|
|
595
|
+
"Usage:",
|
|
596
|
+
" logics-manager sync context-pack <ref> [args...]",
|
|
597
|
+
"",
|
|
598
|
+
"Flags:",
|
|
599
|
+
" --mode {summary-only,diff-first,full}",
|
|
600
|
+
" --profile {tiny,normal,deep}",
|
|
601
|
+
" --out",
|
|
602
|
+
" --format {text,json}",
|
|
603
|
+
" --dry-run",
|
|
604
|
+
"",
|
|
605
|
+
"Example:",
|
|
606
|
+
" logics-manager sync context-pack req_001_my_request --out logics/context-pack.json",
|
|
607
|
+
]
|
|
608
|
+
)
|
|
609
|
+
if command == "export-graph":
|
|
610
|
+
return "\n".join(
|
|
611
|
+
[
|
|
612
|
+
"Logics Sync Export Graph",
|
|
613
|
+
"Export workflow relationships as a machine-readable graph.",
|
|
614
|
+
"",
|
|
615
|
+
"Usage:",
|
|
616
|
+
" logics-manager sync export-graph [args...]",
|
|
617
|
+
"",
|
|
618
|
+
"Flags:",
|
|
619
|
+
" --out",
|
|
620
|
+
" --format {text,json}",
|
|
621
|
+
" --dry-run",
|
|
622
|
+
"",
|
|
623
|
+
"Example:",
|
|
624
|
+
" logics-manager sync export-graph --format json",
|
|
625
|
+
]
|
|
626
|
+
)
|
|
627
|
+
return _build_help()
|
|
628
|
+
|
|
629
|
+
|
|
630
|
+
def _print_help(text: str) -> None:
|
|
631
|
+
print(colorize_help(text))
|
|
632
|
+
|
|
633
|
+
|
|
502
634
|
def cmd_close_eligible_requests(args: argparse.Namespace) -> dict[str, object]:
|
|
503
635
|
repo_root = _find_repo_root(Path.cwd())
|
|
504
636
|
scanned, closed = _close_eligible_requests(repo_root, args.dry_run)
|
|
@@ -598,6 +730,12 @@ def cmd_export_graph(args: argparse.Namespace) -> dict[str, object]:
|
|
|
598
730
|
|
|
599
731
|
|
|
600
732
|
def main(argv: list[str]) -> int:
|
|
733
|
+
if not argv or argv[0] in ("-h", "--help"):
|
|
734
|
+
_print_help(_build_help())
|
|
735
|
+
return 0
|
|
736
|
+
if argv[0] in {"close-eligible-requests", "refresh-mermaid-signatures", "schema-status", "context-pack", "export-graph"} and len(argv) > 1 and argv[1] in ("-h", "--help"):
|
|
737
|
+
_print_help(_build_subcommand_help(argv[0]))
|
|
738
|
+
return 0
|
|
601
739
|
parser = build_parser()
|
|
602
740
|
args = parser.parse_args(argv)
|
|
603
741
|
payload = args.func(args)
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import os
|
|
4
|
+
import re
|
|
5
|
+
import sys
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
RESET = "\033[0m"
|
|
9
|
+
BOLD = "\033[1m"
|
|
10
|
+
CYAN = "\033[36m"
|
|
11
|
+
GREEN = "\033[32m"
|
|
12
|
+
YELLOW = "\033[33m"
|
|
13
|
+
MAGENTA = "\033[35m"
|
|
14
|
+
BLUE = "\033[34m"
|
|
15
|
+
RED = "\033[31m"
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def _color_mode() -> str:
|
|
19
|
+
value = os.environ.get("LOGICS_MANAGER_COLOR", "auto").strip().lower()
|
|
20
|
+
if value in {"always", "auto", "never"}:
|
|
21
|
+
return value
|
|
22
|
+
return "auto"
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def supports_color(stream=None) -> bool:
|
|
26
|
+
if stream is None:
|
|
27
|
+
stream = sys.stdout
|
|
28
|
+
mode = _color_mode()
|
|
29
|
+
if mode == "always":
|
|
30
|
+
return True
|
|
31
|
+
if mode == "never" or os.environ.get("NO_COLOR") is not None:
|
|
32
|
+
return False
|
|
33
|
+
return bool(getattr(stream, "isatty", lambda: False)())
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def wrap(text: str, *codes: str) -> str:
|
|
37
|
+
if not codes:
|
|
38
|
+
return text
|
|
39
|
+
return f"{''.join(codes)}{text}{RESET}"
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
_TITLE_RE = re.compile(r"^Logics .* CLI$")
|
|
43
|
+
_SECTION_RE = re.compile(r"^(Usage|Commands|Kinds|Top-level options|Runtime and diagnostics|Review and governance|Context and prompts|Examples|Flags):$")
|
|
44
|
+
_COMMAND_RE = re.compile(r"^\s{2,}[a-z][a-z0-9-]*(?:\s|$)")
|
|
45
|
+
_FLAG_LINE_RE = re.compile(r"^\s{4,}--")
|
|
46
|
+
_EXAMPLE_RE = re.compile(r"^\s{2,}logics-manager\b")
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def colorize_help(text: str) -> str:
|
|
50
|
+
if not supports_color():
|
|
51
|
+
return text
|
|
52
|
+
|
|
53
|
+
lines: list[str] = []
|
|
54
|
+
for line in text.splitlines():
|
|
55
|
+
stripped = line.strip()
|
|
56
|
+
if not stripped:
|
|
57
|
+
lines.append(line)
|
|
58
|
+
continue
|
|
59
|
+
if _TITLE_RE.match(stripped):
|
|
60
|
+
lines.append(wrap(line, BOLD, CYAN))
|
|
61
|
+
continue
|
|
62
|
+
if _SECTION_RE.match(stripped):
|
|
63
|
+
lines.append(wrap(line, BOLD, MAGENTA))
|
|
64
|
+
continue
|
|
65
|
+
if _EXAMPLE_RE.match(line):
|
|
66
|
+
lines.append(wrap(line, GREEN))
|
|
67
|
+
continue
|
|
68
|
+
if _FLAG_LINE_RE.match(line):
|
|
69
|
+
lines.append(wrap(line, YELLOW))
|
|
70
|
+
continue
|
|
71
|
+
if _COMMAND_RE.match(line):
|
|
72
|
+
lines.append(wrap(line, BLUE))
|
|
73
|
+
continue
|
|
74
|
+
lines.append(line)
|
|
75
|
+
return "\n".join(lines)
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@grifhinz/logics-manager",
|
|
3
3
|
"displayName": "Logics Orchestrator",
|
|
4
4
|
"description": "Visual orchestration for Logics workflows inside VS Code.",
|
|
5
|
-
"version": "2.0.
|
|
5
|
+
"version": "2.0.5",
|
|
6
6
|
"publisher": "cdx-logics",
|
|
7
7
|
"icon": "media/icon.png",
|
|
8
8
|
"repository": {
|
|
@@ -149,6 +149,7 @@
|
|
|
149
149
|
"@types/vscode": "^1.86.0",
|
|
150
150
|
"@typescript-eslint/eslint-plugin": "^8.58.1",
|
|
151
151
|
"@typescript-eslint/parser": "^8.58.1",
|
|
152
|
+
"@vscode/vsce": "^3.9.1",
|
|
152
153
|
"@vitest/coverage-v8": "^4.1.2",
|
|
153
154
|
"esbuild": "^0.25.10",
|
|
154
155
|
"eslint": "^10.2.0",
|