agent-wiki-cli 0.3.28__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.
- agent_wiki_cli-0.3.28.dist-info/METADATA +425 -0
- agent_wiki_cli-0.3.28.dist-info/RECORD +47 -0
- agent_wiki_cli-0.3.28.dist-info/WHEEL +5 -0
- agent_wiki_cli-0.3.28.dist-info/entry_points.txt +2 -0
- agent_wiki_cli-0.3.28.dist-info/licenses/LICENSE +21 -0
- agent_wiki_cli-0.3.28.dist-info/top_level.txt +1 -0
- llm_wiki_cli/__init__.py +7 -0
- llm_wiki_cli/cli.py +231 -0
- llm_wiki_cli/commands/__init__.py +1 -0
- llm_wiki_cli/commands/bootstrap_cmd.py +1072 -0
- llm_wiki_cli/commands/bump_cmd.py +55 -0
- llm_wiki_cli/commands/context_cmd.py +427 -0
- llm_wiki_cli/commands/extract_cmd.py +745 -0
- llm_wiki_cli/commands/generate_prompt_cmd.py +89 -0
- llm_wiki_cli/commands/hook_cmd.py +161 -0
- llm_wiki_cli/commands/init_cmd.py +92 -0
- llm_wiki_cli/commands/lint_cmd.py +294 -0
- llm_wiki_cli/commands/migrate_cmd.py +892 -0
- llm_wiki_cli/commands/release_cmd.py +163 -0
- llm_wiki_cli/commands/status_cmd.py +70 -0
- llm_wiki_cli/commands/sync_cmd.py +521 -0
- llm_wiki_cli/commands/trigger_cmd.py +205 -0
- llm_wiki_cli/commands/uninstall_cmd.py +221 -0
- llm_wiki_cli/commands/upgrade_cmd.py +196 -0
- llm_wiki_cli/config.py +318 -0
- llm_wiki_cli/extractors/__init__.py +46 -0
- llm_wiki_cli/extractors/common.py +90 -0
- llm_wiki_cli/extractors/go_extractor.py +143 -0
- llm_wiki_cli/extractors/go_scripts/go.mod +3 -0
- llm_wiki_cli/extractors/go_scripts/main.go +668 -0
- llm_wiki_cli/extractors/python_extractor.py +346 -0
- llm_wiki_cli/extractors/rust_extractor.py +143 -0
- llm_wiki_cli/extractors/rust_scripts/Cargo.lock +110 -0
- llm_wiki_cli/extractors/rust_scripts/Cargo.toml +11 -0
- llm_wiki_cli/extractors/rust_scripts/src/main.rs +803 -0
- llm_wiki_cli/extractors/ts_extractor.py +206 -0
- llm_wiki_cli/extractors/ts_scripts/extract.js +485 -0
- llm_wiki_cli/extractors/ts_scripts/package.json +10 -0
- llm_wiki_cli/services/__init__.py +0 -0
- llm_wiki_cli/services/circuit_breaker.py +79 -0
- llm_wiki_cli/services/io.py +47 -0
- llm_wiki_cli/services/lockfile.py +60 -0
- llm_wiki_cli/services/packages.py +173 -0
- llm_wiki_cli/services/paths.py +31 -0
- llm_wiki_cli/services/schema.py +214 -0
- llm_wiki_cli/services/secure_file.py +22 -0
- llm_wiki_cli/services/versioning.py +193 -0
llm_wiki_cli/cli.py
ADDED
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
import argparse
|
|
2
|
+
import os
|
|
3
|
+
import sys
|
|
4
|
+
from .commands import init_cmd, extract_cmd, lint_cmd, hook_cmd, trigger_cmd, bootstrap_cmd, bump_cmd, uninstall_cmd, generate_prompt_cmd, status_cmd, release_cmd, upgrade_cmd, sync_cmd, context_cmd, migrate_cmd
|
|
5
|
+
from .config import AGENT_CHOICES, DEFAULT_WIKI_DIR, PathValidationError
|
|
6
|
+
from . import __version__
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def _positive_int(value: str) -> int:
|
|
10
|
+
parsed = int(value)
|
|
11
|
+
if parsed < 1:
|
|
12
|
+
raise argparse.ArgumentTypeError("must be greater than zero")
|
|
13
|
+
return parsed
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def main():
|
|
17
|
+
parser = argparse.ArgumentParser(description="LLM Wiki CLI")
|
|
18
|
+
parser.add_argument("--version", action="version", version=f"llm-wiki {__version__}")
|
|
19
|
+
subparsers = parser.add_subparsers(dest="command", required=True)
|
|
20
|
+
|
|
21
|
+
# init command
|
|
22
|
+
init_parser = subparsers.add_parser("init", help="Scaffold LLM Wiki structure and schema")
|
|
23
|
+
init_parser.add_argument("--agent", choices=AGENT_CHOICES, default="generic", help="Target agent format for rules/constraints")
|
|
24
|
+
init_parser.add_argument("--wiki-dir", default=DEFAULT_WIKI_DIR, help="Wiki directory to create (default: docs/llm_wiki)")
|
|
25
|
+
init_parser.add_argument("--no-quality-hints", action="store_true", default=False,
|
|
26
|
+
help="Omit agent quality guidelines from the constraint block")
|
|
27
|
+
|
|
28
|
+
# extract command
|
|
29
|
+
# ... (skipping extract/lint)
|
|
30
|
+
extract_parser = subparsers.add_parser("extract", help="Extract project AST and structure into wiki")
|
|
31
|
+
extract_parser.add_argument("--src-dir", default=".", help="Source directory to scan")
|
|
32
|
+
extract_parser.add_argument("--changed", action="store_true",
|
|
33
|
+
help="Only extract files changed in the last git commit")
|
|
34
|
+
extract_parser.add_argument("--summary", action="store_true",
|
|
35
|
+
help="Compact output: file paths with class/function names only")
|
|
36
|
+
extract_parser.add_argument("--paths", nargs="+", metavar="FILE",
|
|
37
|
+
help="Only extract specific file paths (relative to --src-dir)")
|
|
38
|
+
extract_parser.add_argument("--deep", action="store_true",
|
|
39
|
+
help="Include docstrings, params, attributes, and imports")
|
|
40
|
+
extract_parser.add_argument("--package", default=None, metavar="NAME",
|
|
41
|
+
help="Only include files belonging to the named package")
|
|
42
|
+
extract_parser.add_argument("--include-empty", action="store_true",
|
|
43
|
+
help="Include all .py files even if they have no extractable components")
|
|
44
|
+
|
|
45
|
+
# lint command
|
|
46
|
+
lint_parser = subparsers.add_parser("lint", help="Lint LLM Wiki for broken links, orphans, and AST drift")
|
|
47
|
+
lint_parser.add_argument("--wiki-dir", default=DEFAULT_WIKI_DIR, help="Wiki directory to lint")
|
|
48
|
+
lint_parser.add_argument("--src-dir", default=".", help="Source directory to cross-reference against")
|
|
49
|
+
|
|
50
|
+
# hook command
|
|
51
|
+
hook_parser = subparsers.add_parser("install-hook", help="Install git hooks for wiki sync")
|
|
52
|
+
hook_parser.add_argument("--wiki-dir", default=DEFAULT_WIKI_DIR,
|
|
53
|
+
help="Wiki directory to read agent config from (default: docs/llm_wiki)")
|
|
54
|
+
hook_parser.add_argument("--agent", choices=AGENT_CHOICES, default=None,
|
|
55
|
+
help="Override the agent for the post-commit hook (default: read from wiki config)")
|
|
56
|
+
hook_parser.add_argument("--force", action="store_true",
|
|
57
|
+
help="Replace an existing unrelated post-commit hook")
|
|
58
|
+
|
|
59
|
+
# trigger command
|
|
60
|
+
trigger_parser = subparsers.add_parser("trigger-agent", help="Trigger subagent to update wiki using diff")
|
|
61
|
+
trigger_parser.add_argument("--agent", choices=AGENT_CHOICES, default="claude", help="Agent executable to invoke for background sync")
|
|
62
|
+
trigger_parser.add_argument("--wiki-dir", default=DEFAULT_WIKI_DIR,
|
|
63
|
+
help="Wiki directory to update (default: docs/llm_wiki)")
|
|
64
|
+
trigger_parser.add_argument("--reset-breaker", action="store_true",
|
|
65
|
+
help="Reset the circuit breaker after consecutive failures and exit")
|
|
66
|
+
trigger_parser.add_argument("--timeout", type=int, default=300,
|
|
67
|
+
help="Timeout in seconds for the subagent process (default: 300)")
|
|
68
|
+
trigger_parser.add_argument("--max-diff-lines", type=int, default=1000,
|
|
69
|
+
help="Skip sync if diff exceeds this many lines (default: 1000)")
|
|
70
|
+
trigger_parser.add_argument("--max-prompt-bytes", type=_positive_int, default=None,
|
|
71
|
+
help=f"Skip sync if generated prompt exceeds this many bytes (default: {trigger_cmd.DEFAULT_MAX_PROMPT_BYTES})")
|
|
72
|
+
trigger_parser.add_argument("--force", action="store_true",
|
|
73
|
+
help="Bypass diff and prompt size guards (does not bypass lock or circuit breaker)")
|
|
74
|
+
|
|
75
|
+
# bootstrap command
|
|
76
|
+
bootstrap_parser = subparsers.add_parser("bootstrap", help="Generate initial wiki for an existing codebase")
|
|
77
|
+
bootstrap_parser.add_argument("--src-dir", default=".", help="Source directory to scan")
|
|
78
|
+
bootstrap_parser.add_argument("--wiki-dir", default=DEFAULT_WIKI_DIR, help="Wiki output directory")
|
|
79
|
+
bootstrap_parser.add_argument("--overwrite", action="store_true", help="Overwrite existing entity/module pages")
|
|
80
|
+
bootstrap_parser.add_argument("--depth", choices=["shallow", "full"], default="full",
|
|
81
|
+
help="shallow=names only, full=docstrings/attrs/methods/imports/relationships (default: full)")
|
|
82
|
+
bootstrap_parser.add_argument("--skip-workflows", action="store_true",
|
|
83
|
+
help="Skip automatic workflow page generation from call graph")
|
|
84
|
+
|
|
85
|
+
# bump command
|
|
86
|
+
bump_parser = subparsers.add_parser("bump", help="Bump project version (patch or minor)")
|
|
87
|
+
bump_group = bump_parser.add_mutually_exclusive_group(required=True)
|
|
88
|
+
bump_group.add_argument("--patch", dest="bump_type", action="store_const", const="patch",
|
|
89
|
+
help="Bump patch version (0.1.5 -> 0.1.6)")
|
|
90
|
+
bump_group.add_argument("--minor", dest="bump_type", action="store_const", const="minor",
|
|
91
|
+
help="Bump minor version (0.1.6 -> 0.2.0)")
|
|
92
|
+
bump_parser.add_argument("--stage", action="store_true",
|
|
93
|
+
help="Git-add the version file after bumping (for use in hooks)")
|
|
94
|
+
|
|
95
|
+
# generate-prompt command
|
|
96
|
+
gp_parser = subparsers.add_parser("generate-prompt", help="Build a wiki sync prompt for IDE agents (Copilot, Cursor, etc.)")
|
|
97
|
+
gp_parser.add_argument("--wiki-dir", default=DEFAULT_WIKI_DIR, help="Wiki directory (default: docs/llm_wiki)")
|
|
98
|
+
gp_parser.add_argument("--src-dir", default=".", help="Source directory to scan (default: .)")
|
|
99
|
+
gp_parser.add_argument("--output", default=".git/llm-wiki-prompt.txt", help="Output file path (default: .git/llm-wiki-prompt.txt)")
|
|
100
|
+
gp_parser.add_argument("--print", dest="print_prompt", action="store_true", help="Print the prompt to stdout instead of writing to a file")
|
|
101
|
+
|
|
102
|
+
# uninstall command
|
|
103
|
+
uninstall_parser = subparsers.add_parser("uninstall", help="Remove all LLM Wiki artifacts from the project")
|
|
104
|
+
uninstall_parser.add_argument("--wiki-dir", default=DEFAULT_WIKI_DIR, help="Wiki directory path")
|
|
105
|
+
uninstall_parser.add_argument("--remove-wiki", action="store_true",
|
|
106
|
+
help="Also remove the wiki documentation directory")
|
|
107
|
+
uninstall_parser.add_argument("--dry-run", action="store_true",
|
|
108
|
+
help="Preview what would be removed without deleting anything")
|
|
109
|
+
|
|
110
|
+
# status command
|
|
111
|
+
status_parser = subparsers.add_parser("status", help="Show LLM Wiki status (agent, hooks, breaker, pages)")
|
|
112
|
+
status_parser.add_argument("--wiki-dir", default=DEFAULT_WIKI_DIR, help="Wiki directory path")
|
|
113
|
+
|
|
114
|
+
# release command
|
|
115
|
+
release_parser = subparsers.add_parser(
|
|
116
|
+
"release",
|
|
117
|
+
help="Stamp the [Unreleased] CHANGELOG section with the current version",
|
|
118
|
+
)
|
|
119
|
+
release_parser.add_argument(
|
|
120
|
+
"--changelog", default="CHANGELOG.md",
|
|
121
|
+
help="Path to the changelog file (default: CHANGELOG.md)",
|
|
122
|
+
)
|
|
123
|
+
release_parser.add_argument(
|
|
124
|
+
"--stage", action="store_true",
|
|
125
|
+
help="Git-add CHANGELOG.md after stamping (for use in hooks)",
|
|
126
|
+
)
|
|
127
|
+
|
|
128
|
+
# upgrade command
|
|
129
|
+
upgrade_parser = subparsers.add_parser(
|
|
130
|
+
"upgrade",
|
|
131
|
+
help="Refresh all framework-managed artifacts (schema, hooks, dirs) in place",
|
|
132
|
+
)
|
|
133
|
+
upgrade_parser.add_argument("--wiki-dir", default=DEFAULT_WIKI_DIR,
|
|
134
|
+
help="Wiki directory path (default: docs/llm_wiki)")
|
|
135
|
+
upgrade_parser.add_argument("--agent", choices=AGENT_CHOICES, default=None,
|
|
136
|
+
help="Switch to a different agent (default: keep current)")
|
|
137
|
+
upgrade_parser.add_argument("--force", action="store_true",
|
|
138
|
+
help="Replace an existing unrelated post-commit hook")
|
|
139
|
+
upgrade_hints = upgrade_parser.add_mutually_exclusive_group()
|
|
140
|
+
upgrade_hints.add_argument("--quality-hints", dest="quality_hints", action="store_true", default=None,
|
|
141
|
+
help="Include agent quality guidelines in the constraint block")
|
|
142
|
+
upgrade_hints.add_argument("--no-quality-hints", dest="quality_hints", action="store_false",
|
|
143
|
+
help="Omit agent quality guidelines from the constraint block")
|
|
144
|
+
|
|
145
|
+
# sync command
|
|
146
|
+
sync_parser = subparsers.add_parser(
|
|
147
|
+
"sync",
|
|
148
|
+
help="Incrementally update wiki pages for files that changed since last bootstrap/sync",
|
|
149
|
+
)
|
|
150
|
+
sync_parser.add_argument("--src-dir", default=".", help="Source directory to scan (default: .)")
|
|
151
|
+
sync_parser.add_argument("--wiki-dir", default=DEFAULT_WIKI_DIR,
|
|
152
|
+
help="Wiki directory (default: docs/llm_wiki)")
|
|
153
|
+
|
|
154
|
+
# migrate command
|
|
155
|
+
migrate_parser = subparsers.add_parser(
|
|
156
|
+
"migrate",
|
|
157
|
+
help="Reconcile legacy wiki pages with current canonical naming",
|
|
158
|
+
)
|
|
159
|
+
migrate_parser.add_argument("--src-dir", default=".", help="Source directory to scan (default: .)")
|
|
160
|
+
migrate_parser.add_argument("--wiki-dir", default=DEFAULT_WIKI_DIR,
|
|
161
|
+
help="Wiki directory (default: docs/llm_wiki)")
|
|
162
|
+
migrate_parser.add_argument("--dry-run", action="store_true",
|
|
163
|
+
help="Preview migration actions without modifying files")
|
|
164
|
+
migrate_parser.add_argument("--chunk-size", type=_positive_int, metavar="PAGES",
|
|
165
|
+
help="Apply at most this many pending page operations in one migration chunk")
|
|
166
|
+
migrate_parser.add_argument("--chunk", type=_positive_int, metavar="N",
|
|
167
|
+
help="Apply chunk N from the current --chunk-size plan (default: 1)")
|
|
168
|
+
migrate_parser.add_argument("--plan-chunks", action="store_true",
|
|
169
|
+
help="Print the current chunk plan and exit without modifying files")
|
|
170
|
+
|
|
171
|
+
# context command
|
|
172
|
+
context_parser = subparsers.add_parser(
|
|
173
|
+
"context",
|
|
174
|
+
help="Return priority-ranked, token-budgeted codebase context for LLM agents",
|
|
175
|
+
)
|
|
176
|
+
context_parser.add_argument("--budget", type=_positive_int, required=True,
|
|
177
|
+
help="Token budget for the context payload")
|
|
178
|
+
context_parser.add_argument("--src-dir", default=".",
|
|
179
|
+
help="Source directory to scan (default: .)")
|
|
180
|
+
context_parser.add_argument("--format", choices=["json", "markdown"], default="json",
|
|
181
|
+
help="Output format (default: json)")
|
|
182
|
+
context_parser.add_argument("--focus", choices=["changed", "all"], default="changed",
|
|
183
|
+
help="changed=prioritise git diff files, all=treat every file as high priority (default: changed)")
|
|
184
|
+
|
|
185
|
+
args = parser.parse_args()
|
|
186
|
+
|
|
187
|
+
try:
|
|
188
|
+
if args.command == "init":
|
|
189
|
+
init_cmd.run(args)
|
|
190
|
+
elif args.command == "extract":
|
|
191
|
+
extract_cmd.run(args)
|
|
192
|
+
elif args.command == "lint":
|
|
193
|
+
lint_cmd.run(args)
|
|
194
|
+
elif args.command == "install-hook":
|
|
195
|
+
hook_cmd.run(args)
|
|
196
|
+
elif args.command == "trigger-agent":
|
|
197
|
+
trigger_cmd.run(args)
|
|
198
|
+
elif args.command == "bootstrap":
|
|
199
|
+
bootstrap_cmd.run(args)
|
|
200
|
+
elif args.command == "bump":
|
|
201
|
+
bump_cmd.run(args)
|
|
202
|
+
elif args.command == "generate-prompt":
|
|
203
|
+
generate_prompt_cmd.run(args)
|
|
204
|
+
elif args.command == "uninstall":
|
|
205
|
+
uninstall_cmd.run(args)
|
|
206
|
+
elif args.command == "status":
|
|
207
|
+
status_cmd.run(args)
|
|
208
|
+
elif args.command == "release":
|
|
209
|
+
release_cmd.run(args)
|
|
210
|
+
elif args.command == "upgrade":
|
|
211
|
+
upgrade_cmd.run(args)
|
|
212
|
+
elif args.command == "sync":
|
|
213
|
+
sync_cmd.run(args)
|
|
214
|
+
elif args.command == "migrate":
|
|
215
|
+
migrate_cmd.run(args)
|
|
216
|
+
elif args.command == "context":
|
|
217
|
+
context_cmd.run(args)
|
|
218
|
+
except KeyboardInterrupt:
|
|
219
|
+
print("\nAborted.")
|
|
220
|
+
sys.exit(130)
|
|
221
|
+
except PathValidationError as exc:
|
|
222
|
+
print(str(exc), file=sys.stderr)
|
|
223
|
+
sys.exit(1)
|
|
224
|
+
except Exception as exc:
|
|
225
|
+
if os.environ.get("LLM_WIKI_DEBUG"):
|
|
226
|
+
raise
|
|
227
|
+
print(f"Error: {exc}", file=sys.stderr)
|
|
228
|
+
sys.exit(1)
|
|
229
|
+
|
|
230
|
+
if __name__ == "__main__":
|
|
231
|
+
main()
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from . import init_cmd, extract_cmd, lint_cmd, hook_cmd, trigger_cmd, generate_prompt_cmd, release_cmd, sync_cmd, migrate_cmd
|