agent-efficiency 1.4.2__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_efficiency/__init__.py +15 -0
- agent_efficiency/_bundle/mcp/server.py +519 -0
- agent_efficiency/_bundle/rules/AGENT_RULES.md +9 -0
- agent_efficiency/_bundle/scripts/ae_cli.py +327 -0
- agent_efficiency/_bundle/scripts/ae_init.py +267 -0
- agent_efficiency/_bundle/scripts/ae_manage.py +578 -0
- agent_efficiency/_bundle/scripts/install.py +308 -0
- agent_efficiency/_bundle/scripts/pretool_hook.py +350 -0
- agent_efficiency/_bundle/scripts/render_demo_svg.py +180 -0
- agent_efficiency/_bundle/scripts/setup_hooks.py +330 -0
- agent_efficiency/_bundle/scripts/sync_shared.py +85 -0
- agent_efficiency/_bundle/scripts/validate_skills.py +150 -0
- agent_efficiency/_bundle/skills/adaptive-orchestration-handoff/SKILL.md +80 -0
- agent_efficiency/_bundle/skills/adaptive-orchestration-handoff/config/models.json +237 -0
- agent_efficiency/_bundle/skills/adaptive-orchestration-handoff/examples/workflow.md +77 -0
- agent_efficiency/_bundle/skills/adaptive-orchestration-handoff/references/routing-and-escalation.md +63 -0
- agent_efficiency/_bundle/skills/adaptive-orchestration-handoff/references/state-and-handoff.md +84 -0
- agent_efficiency/_bundle/skills/adaptive-orchestration-handoff/scripts/_ae_core/__init__.py +90 -0
- agent_efficiency/_bundle/skills/adaptive-orchestration-handoff/scripts/_ae_core/io_lock.py +199 -0
- agent_efficiency/_bundle/skills/adaptive-orchestration-handoff/scripts/_ae_core/savings.py +249 -0
- agent_efficiency/_bundle/skills/adaptive-orchestration-handoff/scripts/_ae_core/security.py +235 -0
- agent_efficiency/_bundle/skills/adaptive-orchestration-handoff/scripts/_ae_core/usage.py +195 -0
- agent_efficiency/_bundle/skills/adaptive-orchestration-handoff/scripts/agent_state.py +266 -0
- agent_efficiency/_bundle/skills/adaptive-orchestration-handoff/scripts/context_doctor.py +780 -0
- agent_efficiency/_bundle/skills/adaptive-orchestration-handoff/scripts/llm_adapter.py +306 -0
- agent_efficiency/_bundle/skills/adaptive-orchestration-handoff/scripts/route_task.py +496 -0
- agent_efficiency/_bundle/skills/adaptive-orchestration-handoff/scripts/state_ops.py +580 -0
- agent_efficiency/_bundle/skills/adaptive-orchestration-handoff/scripts/state_render.py +428 -0
- agent_efficiency/_bundle/skills/adaptive-orchestration-handoff/scripts/state_store.py +440 -0
- agent_efficiency/_bundle/skills/adaptive-orchestration-handoff/scripts/transcript_audit.py +854 -0
- agent_efficiency/_bundle/skills/local-context-index/SKILL.md +71 -0
- agent_efficiency/_bundle/skills/local-context-index/references/cli-reference.md +112 -0
- agent_efficiency/_bundle/skills/local-context-index/scripts/_ae_core/__init__.py +90 -0
- agent_efficiency/_bundle/skills/local-context-index/scripts/_ae_core/io_lock.py +199 -0
- agent_efficiency/_bundle/skills/local-context-index/scripts/_ae_core/savings.py +249 -0
- agent_efficiency/_bundle/skills/local-context-index/scripts/_ae_core/security.py +235 -0
- agent_efficiency/_bundle/skills/local-context-index/scripts/_ae_core/usage.py +195 -0
- agent_efficiency/_bundle/skills/local-context-index/scripts/compact_run.py +395 -0
- agent_efficiency/_bundle/skills/local-context-index/scripts/context_index.py +341 -0
- agent_efficiency/_bundle/skills/local-context-index/scripts/idx_db.py +393 -0
- agent_efficiency/_bundle/skills/local-context-index/scripts/idx_ignore.py +184 -0
- agent_efficiency/_bundle/skills/local-context-index/scripts/idx_indexer.py +330 -0
- agent_efficiency/_bundle/skills/local-context-index/scripts/idx_lsp.py +213 -0
- agent_efficiency/_bundle/skills/local-context-index/scripts/idx_parsers.py +769 -0
- agent_efficiency/_bundle/skills/local-context-index/scripts/idx_search.py +498 -0
- agent_efficiency/_bundle/skills/local-context-index/scripts/idx_slice.py +610 -0
- agent_efficiency/_bundle/skills/local-context-index/scripts/idx_trace.py +553 -0
- agent_efficiency/_bundle/skills/local-context-index/scripts/idx_workspace.py +219 -0
- agent_efficiency/_bundle/skills/prompt-cache-manager/SKILL.md +52 -0
- agent_efficiency/_bundle/skills/prompt-cache-manager/references/provider-caching.md +52 -0
- agent_efficiency/_bundle/skills/prompt-cache-manager/scripts/_ae_core/__init__.py +90 -0
- agent_efficiency/_bundle/skills/prompt-cache-manager/scripts/_ae_core/io_lock.py +199 -0
- agent_efficiency/_bundle/skills/prompt-cache-manager/scripts/_ae_core/savings.py +249 -0
- agent_efficiency/_bundle/skills/prompt-cache-manager/scripts/_ae_core/security.py +235 -0
- agent_efficiency/_bundle/skills/prompt-cache-manager/scripts/_ae_core/usage.py +195 -0
- agent_efficiency/_bundle/skills/prompt-cache-manager/scripts/cache_payload.py +278 -0
- agent_efficiency/_bundle/skills/prompt-cache-manager/scripts/prompt_cache.py +488 -0
- agent_efficiency/cli.py +23 -0
- agent_efficiency/mcp_entry.py +25 -0
- agent_efficiency-1.4.2.dist-info/METADATA +267 -0
- agent_efficiency-1.4.2.dist-info/RECORD +64 -0
- agent_efficiency-1.4.2.dist-info/WHEEL +4 -0
- agent_efficiency-1.4.2.dist-info/entry_points.txt +4 -0
- agent_efficiency-1.4.2.dist-info/licenses/LICENSE +21 -0
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""AgentEfficiency — Persistent project state, decision log, checkpoint & zero-reexploration handoff CLI facade.
|
|
3
|
+
|
|
4
|
+
Delegates storage/drift to `state_store.py`, command handlers to `state_ops.py`,
|
|
5
|
+
Markdown rendering to `state_render.py`, and IDE transcript auditing to `transcript_audit.py`.
|
|
6
|
+
"""
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
import argparse
|
|
10
|
+
import json
|
|
11
|
+
import os
|
|
12
|
+
import sys
|
|
13
|
+
from pathlib import Path
|
|
14
|
+
from typing import Optional, Sequence
|
|
15
|
+
|
|
16
|
+
_SCRIPT_DIR = str(Path(__file__).resolve().parent)
|
|
17
|
+
if _SCRIPT_DIR not in sys.path:
|
|
18
|
+
sys.path.insert(0, _SCRIPT_DIR)
|
|
19
|
+
|
|
20
|
+
from _ae_core import ( # noqa: E402, F401
|
|
21
|
+
DEFAULT_TIER_PRICES,
|
|
22
|
+
atomic_write_json,
|
|
23
|
+
atomic_write_text,
|
|
24
|
+
configure_utf8_stdio,
|
|
25
|
+
ensure_git_info_exclude,
|
|
26
|
+
estimate_tokens,
|
|
27
|
+
file_lock,
|
|
28
|
+
git_cmd,
|
|
29
|
+
is_secret_path,
|
|
30
|
+
is_within,
|
|
31
|
+
redact_secrets_with_flag as redact_secrets,
|
|
32
|
+
sanitize_inline,
|
|
33
|
+
)
|
|
34
|
+
from state_ops import handle_checkpoint, handle_mutating, handle_readonly # noqa: E402
|
|
35
|
+
from state_render import ( # noqa: E402, F401
|
|
36
|
+
build_brief_dossier,
|
|
37
|
+
cache_summary as _cache_summary,
|
|
38
|
+
index_summary_for_files as _index_summary_for_files,
|
|
39
|
+
relevant_decisions as _relevant_decisions,
|
|
40
|
+
render_all,
|
|
41
|
+
render_blockers,
|
|
42
|
+
render_checkpoint_markdown,
|
|
43
|
+
render_completed,
|
|
44
|
+
render_current_state,
|
|
45
|
+
render_decisions,
|
|
46
|
+
render_handoff_markdown,
|
|
47
|
+
render_task_queue,
|
|
48
|
+
)
|
|
49
|
+
from state_store import ( # noqa: E402, F401
|
|
50
|
+
MAX_HASH_FILE_BYTES,
|
|
51
|
+
SCHEMA_VERSION,
|
|
52
|
+
TIER_TO_ALIAS,
|
|
53
|
+
VALID_TASK_ID_RE,
|
|
54
|
+
_check_ownership_conflicts,
|
|
55
|
+
_empty_state,
|
|
56
|
+
_empty_telemetry,
|
|
57
|
+
_file_sha12,
|
|
58
|
+
_git_snapshot,
|
|
59
|
+
_is_internal_artifact_status,
|
|
60
|
+
_migrate_state,
|
|
61
|
+
_parse_rel_paths,
|
|
62
|
+
_paths_overlap_scope,
|
|
63
|
+
_promote_next_active,
|
|
64
|
+
_read_state_json,
|
|
65
|
+
_resolve_task_id,
|
|
66
|
+
_safe_state_dir,
|
|
67
|
+
_validate_task_id,
|
|
68
|
+
build_brief,
|
|
69
|
+
build_session_start,
|
|
70
|
+
init_state,
|
|
71
|
+
load_state_readonly,
|
|
72
|
+
normalize_rel_path,
|
|
73
|
+
now_iso,
|
|
74
|
+
save_state,
|
|
75
|
+
)
|
|
76
|
+
from transcript_audit import audit_sessions, format_compact_audit # noqa: E402, F401
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
def _build_parser() -> argparse.ArgumentParser:
|
|
80
|
+
ap = argparse.ArgumentParser(description="AgentEfficiency persistent state, decisions, checkpoint & handoff manager.")
|
|
81
|
+
sub = ap.add_subparsers(dest="subcmd", required=True)
|
|
82
|
+
|
|
83
|
+
sub.add_parser("init", help="Initialize .agent-state directory").add_argument("repo", type=Path)
|
|
84
|
+
for name, hl in (("start", "Start a task"), ("queue", "Enqueue a task")):
|
|
85
|
+
p = sub.add_parser(name, help=hl)
|
|
86
|
+
p.add_argument("repo", type=Path)
|
|
87
|
+
p.add_argument("--objective", required=True)
|
|
88
|
+
p.add_argument("--criteria", default="Not specified")
|
|
89
|
+
p.add_argument("--tier", choices=["low", "medium", "high", "critical"], default="medium")
|
|
90
|
+
p.add_argument("--priority", choices=["low", "normal", "high", "critical"], default="normal")
|
|
91
|
+
if name == "start":
|
|
92
|
+
p.add_argument("--owner", default=os.getenv("USER", "agent"))
|
|
93
|
+
p.add_argument("--own-files", default="")
|
|
94
|
+
p.add_argument("--queue", action="store_true")
|
|
95
|
+
p.add_argument("--parallel", action="store_true")
|
|
96
|
+
|
|
97
|
+
p = sub.add_parser("list", help="List tasks (read-only)")
|
|
98
|
+
p.add_argument("repo", type=Path)
|
|
99
|
+
p.add_argument("--status", default=None)
|
|
100
|
+
sub.add_parser("status", help="Compact JSON status (read-only)").add_argument("repo", type=Path)
|
|
101
|
+
sub.add_parser("metrics", help="Show cumulative telemetry (read-only)").add_argument("repo", type=Path)
|
|
102
|
+
|
|
103
|
+
p = sub.add_parser("session-start", help="1-call compound startup (brief + recent git + PROJECT_MAP + optional --auto-index)")
|
|
104
|
+
p.add_argument("repo", type=Path)
|
|
105
|
+
p.add_argument("--max-tokens", type=int, default=1400)
|
|
106
|
+
p.add_argument("--auto-index", action="store_true", help="Build/refresh local index incrementally before loading PROJECT_MAP.md")
|
|
107
|
+
p.add_argument("--no-map", action="store_true", help="Omit compact PROJECT_MAP.md excerpt")
|
|
108
|
+
p.add_argument("--format", choices=["md", "json", "claude-hook", "gemini-hook"], default="md")
|
|
109
|
+
|
|
110
|
+
p = sub.add_parser("update", help="Update task progress, files, tier, notes, or failure count")
|
|
111
|
+
p.add_argument("repo", type=Path)
|
|
112
|
+
p.add_argument("--task-id", default=None)
|
|
113
|
+
p.add_argument("--next", required=True)
|
|
114
|
+
p.add_argument("--files", default="")
|
|
115
|
+
p.add_argument("--own-files", default="")
|
|
116
|
+
p.add_argument("--tests", default="")
|
|
117
|
+
p.add_argument("--notes", default="")
|
|
118
|
+
p.add_argument("--tier", choices=["low", "medium", "high", "critical"], default=None)
|
|
119
|
+
p.add_argument("--failure", action="store_true")
|
|
120
|
+
p.add_argument("--reset-failures", action="store_true")
|
|
121
|
+
|
|
122
|
+
p = sub.add_parser("record-inspection", help="Record inspected file + disk SHA (preserves multiple ranges)")
|
|
123
|
+
p.add_argument("repo", type=Path)
|
|
124
|
+
p.add_argument("--task-id", default=None)
|
|
125
|
+
p.add_argument("--path", required=True)
|
|
126
|
+
p.add_argument("--lines", default="")
|
|
127
|
+
p.add_argument("--finding", required=True)
|
|
128
|
+
|
|
129
|
+
p = sub.add_parser("record-attempt", help="Record tried approach (worked|failed|rejected)")
|
|
130
|
+
p.add_argument("repo", type=Path)
|
|
131
|
+
p.add_argument("--task-id", default=None)
|
|
132
|
+
p.add_argument("--approach", required=True)
|
|
133
|
+
p.add_argument("--outcome", choices=["worked", "failed", "rejected"], required=True)
|
|
134
|
+
p.add_argument("--reason", required=True)
|
|
135
|
+
|
|
136
|
+
p = sub.add_parser("record-check", help="Record verified command & exit code")
|
|
137
|
+
p.add_argument("repo", type=Path)
|
|
138
|
+
p.add_argument("--task-id", default=None)
|
|
139
|
+
p.add_argument("--cmd", dest="check_cmd", required=True)
|
|
140
|
+
p.add_argument("--exit-code", type=int, required=True)
|
|
141
|
+
p.add_argument("--summary", default="")
|
|
142
|
+
|
|
143
|
+
p = sub.add_parser("decision", help="Record architectural decision")
|
|
144
|
+
p.add_argument("repo", type=Path)
|
|
145
|
+
p.add_argument("--task-id", default=None)
|
|
146
|
+
p.add_argument("--title", required=True)
|
|
147
|
+
p.add_argument("--rationale", required=True)
|
|
148
|
+
p.add_argument("--alternatives", default="")
|
|
149
|
+
p.add_argument("--files", default="")
|
|
150
|
+
p.add_argument("--supersedes", default=None)
|
|
151
|
+
p.add_argument("--author", default=os.getenv("USER", "agent"))
|
|
152
|
+
|
|
153
|
+
p = sub.add_parser("decisions", help="Query decisions (read-only)")
|
|
154
|
+
p.add_argument("repo", type=Path)
|
|
155
|
+
p.add_argument("--file", default=None)
|
|
156
|
+
p.add_argument("--query", default=None)
|
|
157
|
+
p.add_argument("--all", action="store_true")
|
|
158
|
+
|
|
159
|
+
p = sub.add_parser("blocker", help="Add or resolve blocker")
|
|
160
|
+
p.add_argument("repo", type=Path)
|
|
161
|
+
p.add_argument("--task-id", default=None)
|
|
162
|
+
p.add_argument("--add", default=None)
|
|
163
|
+
p.add_argument("--resolve", default=None)
|
|
164
|
+
p.add_argument("--resolution", default="resolved")
|
|
165
|
+
|
|
166
|
+
p = sub.add_parser("block", help="Mark task status as blocked and record reason")
|
|
167
|
+
p.add_argument("repo", type=Path)
|
|
168
|
+
p.add_argument("--task-id", default=None)
|
|
169
|
+
p.add_argument("--reason", required=True)
|
|
170
|
+
|
|
171
|
+
p = sub.add_parser("cancel", help="Cancel a task cleanly")
|
|
172
|
+
p.add_argument("repo", type=Path)
|
|
173
|
+
p.add_argument("--task-id", default=None)
|
|
174
|
+
p.add_argument("--reason", required=True)
|
|
175
|
+
|
|
176
|
+
p = sub.add_parser("reopen", help="Reopen a completed or cancelled task")
|
|
177
|
+
p.add_argument("repo", type=Path)
|
|
178
|
+
p.add_argument("--task-id", required=True)
|
|
179
|
+
p.add_argument("--owner", default=os.getenv("USER", "agent"))
|
|
180
|
+
|
|
181
|
+
p = sub.add_parser("switch", help="Switch active task pointer to another in_progress task")
|
|
182
|
+
p.add_argument("repo", type=Path)
|
|
183
|
+
p.add_argument("--task-id", required=True)
|
|
184
|
+
|
|
185
|
+
p = sub.add_parser("prune", help="Archive older completed/cancelled tasks to keep state.json compact")
|
|
186
|
+
p.add_argument("repo", type=Path)
|
|
187
|
+
p.add_argument("--keep-completed", type=int, default=10)
|
|
188
|
+
|
|
189
|
+
p = sub.add_parser("handoff", help="Generate zero-reexploration HANDOFF.md + handoff.json")
|
|
190
|
+
p.add_argument("repo", type=Path)
|
|
191
|
+
p.add_argument("--task-id", default=None)
|
|
192
|
+
p.add_argument("--recipient", default="next-agent")
|
|
193
|
+
p.add_argument("--summary", required=True)
|
|
194
|
+
p.add_argument("--next", required=True)
|
|
195
|
+
p.add_argument("--files", default="Not recorded")
|
|
196
|
+
p.add_argument("--tests", default="Not recorded")
|
|
197
|
+
p.add_argument("--warnings", default="None recorded")
|
|
198
|
+
p.add_argument("--entry-points", default="")
|
|
199
|
+
|
|
200
|
+
p = sub.add_parser("accept", help="Accept handed-off/queued/blocked task")
|
|
201
|
+
p.add_argument("repo", type=Path)
|
|
202
|
+
p.add_argument("--task-id", default=None)
|
|
203
|
+
p.add_argument("--owner", required=True)
|
|
204
|
+
p.add_argument("--tier", choices=["low", "medium", "high", "critical"], default=None)
|
|
205
|
+
p.add_argument("--model-alias", default=None)
|
|
206
|
+
|
|
207
|
+
p = sub.add_parser("brief", help="Zero-reexploration onboarding dossier (read-only)")
|
|
208
|
+
p.add_argument("repo", type=Path)
|
|
209
|
+
p.add_argument("--task-id", default=None)
|
|
210
|
+
p.add_argument("--max-tokens", type=int, default=1200)
|
|
211
|
+
p.add_argument("--format", choices=["md", "json", "gemini-hook"], default="md")
|
|
212
|
+
|
|
213
|
+
p = sub.add_parser("complete", help="Mark task completed")
|
|
214
|
+
p.add_argument("repo", type=Path)
|
|
215
|
+
p.add_argument("--task-id", default=None)
|
|
216
|
+
p.add_argument("--result", required=True)
|
|
217
|
+
|
|
218
|
+
p = sub.add_parser("record-usage", help="Record token & cache usage telemetry")
|
|
219
|
+
p.add_argument("repo", type=Path)
|
|
220
|
+
p.add_argument("--tier", choices=["low", "medium", "high", "critical"], default="medium")
|
|
221
|
+
p.add_argument("--input-tokens", type=int, required=True)
|
|
222
|
+
p.add_argument("--cached-tokens", type=int, default=0)
|
|
223
|
+
p.add_argument("--cache-write-tokens", type=int, default=0)
|
|
224
|
+
p.add_argument("--output-tokens", type=int, default=0)
|
|
225
|
+
|
|
226
|
+
p = sub.add_parser("checkpoint", help="Zero-friction auto-checkpoint (git diff + touched symbols + optional check/note)")
|
|
227
|
+
p.add_argument("repo", type=Path)
|
|
228
|
+
p.add_argument("--task-id", default=None)
|
|
229
|
+
p.add_argument("--note", default="")
|
|
230
|
+
p.add_argument("--cmd", dest="check_cmd", default=None)
|
|
231
|
+
p.add_argument("--exit-code", type=int, default=None)
|
|
232
|
+
p.add_argument("--summary", default="")
|
|
233
|
+
p.add_argument("--hook-format", choices=["none", "gemini", "claude"], default="none")
|
|
234
|
+
|
|
235
|
+
p = sub.add_parser("audit-sessions", help="Analyze local IDE transcripts for repeat-read waste, USD cost & trends")
|
|
236
|
+
p.add_argument("--source", choices=["auto", "antigravity", "claude", "codex", "gemini", "cursor", "opencode", "cline", "path"], default="auto")
|
|
237
|
+
p.add_argument("--path", type=Path, default=None)
|
|
238
|
+
p.add_argument("--limit", type=int, default=6)
|
|
239
|
+
p.add_argument("--compare-window", type=int, default=None)
|
|
240
|
+
p.add_argument("--format", choices=["compact", "card", "json"], default="compact")
|
|
241
|
+
return ap
|
|
242
|
+
|
|
243
|
+
|
|
244
|
+
def main(argv: Optional[Sequence[str]] = None) -> int:
|
|
245
|
+
configure_utf8_stdio()
|
|
246
|
+
args = _build_parser().parse_args(argv)
|
|
247
|
+
if args.subcmd == "audit-sessions":
|
|
248
|
+
rep = audit_sessions(source=args.source, explicit_path=args.path, limit=args.limit, compare_window=args.compare_window)
|
|
249
|
+
if args.format == "json":
|
|
250
|
+
print(json.dumps(rep, indent=2, ensure_ascii=False))
|
|
251
|
+
elif args.format == "card":
|
|
252
|
+
from transcript_audit import format_card_audit
|
|
253
|
+
print(format_card_audit(rep))
|
|
254
|
+
else:
|
|
255
|
+
print(format_compact_audit(rep))
|
|
256
|
+
return 0
|
|
257
|
+
repo = args.repo.resolve()
|
|
258
|
+
if args.subcmd in ("list", "status", "brief", "decisions", "metrics", "session-start"):
|
|
259
|
+
return handle_readonly(repo, args)
|
|
260
|
+
if args.subcmd == "checkpoint":
|
|
261
|
+
return handle_checkpoint(repo, args)
|
|
262
|
+
return handle_mutating(repo, args)
|
|
263
|
+
|
|
264
|
+
|
|
265
|
+
if __name__ == "__main__":
|
|
266
|
+
raise SystemExit(main())
|