algo-cli-runtime 0.14.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 (237) hide show
  1. algo_cli/__init__.py +3 -0
  2. algo_cli/__main__.py +7 -0
  3. algo_cli/_internal/__init__.py +12 -0
  4. algo_cli/_internal/policy_chain.py +259 -0
  5. algo_cli/action_registry.py +1047 -0
  6. algo_cli/agent_blocks.py +550 -0
  7. algo_cli/agent_pipeline.py +1457 -0
  8. algo_cli/agent_threads.py +308 -0
  9. algo_cli/animations.py +316 -0
  10. algo_cli/cache_admission.py +209 -0
  11. algo_cli/capability_mask.py +66 -0
  12. algo_cli/chat_protocol.py +116 -0
  13. algo_cli/chatgpt_auth.py +510 -0
  14. algo_cli/chatgpt_client.py +657 -0
  15. algo_cli/code_rag.py +479 -0
  16. algo_cli/config.py +651 -0
  17. algo_cli/context_budget.py +679 -0
  18. algo_cli/credential_helpers.py +315 -0
  19. algo_cli/deliberation.py +29 -0
  20. algo_cli/display.py +1470 -0
  21. algo_cli/evals/__init__.py +21 -0
  22. algo_cli/evals/algorithm_effectiveness.py +560 -0
  23. algo_cli/evals/competitive_harness_rating.py +702 -0
  24. algo_cli/evals/cot_quality.py +220 -0
  25. algo_cli/evals/harness_retrieval_benchmark.py +401 -0
  26. algo_cli/evals/performance_regression.py +136 -0
  27. algo_cli/evals/scorecard_grading.py +308 -0
  28. algo_cli/evals/session_distribution.py +84 -0
  29. algo_cli/execution_guardrails.py +806 -0
  30. algo_cli/extensions_manifest.py +84 -0
  31. algo_cli/git_evidence.py +227 -0
  32. algo_cli/google_workspace.py +407 -0
  33. algo_cli/google_workspace_auth.py +523 -0
  34. algo_cli/harness.py +2587 -0
  35. algo_cli/identity.py +557 -0
  36. algo_cli/index_compute_lab.py +228 -0
  37. algo_cli/inference_harness.py +70 -0
  38. algo_cli/intelligence/__init__.py +1103 -0
  39. algo_cli/intelligence/acrobat_config.py +307 -0
  40. algo_cli/intelligence/acrobat_manifests.py +338 -0
  41. algo_cli/intelligence/acrobat_models.py +195 -0
  42. algo_cli/intelligence/acrobat_pipeline.py +295 -0
  43. algo_cli/intelligence/acrobat_runtime.py +302 -0
  44. algo_cli/intelligence/acrobat_security.py +261 -0
  45. algo_cli/intelligence/acrobat_workflows.py +226 -0
  46. algo_cli/intelligence/actionability.py +165 -0
  47. algo_cli/intelligence/adversarial_audit.py +136 -0
  48. algo_cli/intelligence/agent_arena.py +92 -0
  49. algo_cli/intelligence/agent_benchmark.py +236 -0
  50. algo_cli/intelligence/agent_runtime.py +171 -0
  51. algo_cli/intelligence/agents_as_tools.py +70 -0
  52. algo_cli/intelligence/artifact_binding.py +80 -0
  53. algo_cli/intelligence/autonomous_engineer.py +1976 -0
  54. algo_cli/intelligence/backpressure.py +99 -0
  55. algo_cli/intelligence/bloom_filter.py +186 -0
  56. algo_cli/intelligence/bonferroni.py +66 -0
  57. algo_cli/intelligence/boundary_compaction.py +98 -0
  58. algo_cli/intelligence/catalog_verifier.py +172 -0
  59. algo_cli/intelligence/cavecrew.py +118 -0
  60. algo_cli/intelligence/changelog.py +176 -0
  61. algo_cli/intelligence/checkpoint_resume.py +92 -0
  62. algo_cli/intelligence/circuit_breaker.py +88 -0
  63. algo_cli/intelligence/clarification_gate.py +101 -0
  64. algo_cli/intelligence/code_graph.py +180 -0
  65. algo_cli/intelligence/coderank.py +97 -0
  66. algo_cli/intelligence/consistent_hash.py +150 -0
  67. algo_cli/intelligence/consortium_synthesis.py +139 -0
  68. algo_cli/intelligence/construction/__init__.py +241 -0
  69. algo_cli/intelligence/construction/common.py +273 -0
  70. algo_cli/intelligence/construction/documents.py +496 -0
  71. algo_cli/intelligence/construction/labor_units.py +1395 -0
  72. algo_cli/intelligence/construction/payments.py +470 -0
  73. algo_cli/intelligence/construction/risk.py +784 -0
  74. algo_cli/intelligence/content_extractor.py +132 -0
  75. algo_cli/intelligence/context_adaptive.py +102 -0
  76. algo_cli/intelligence/context_ops.py +95 -0
  77. algo_cli/intelligence/count_min.py +145 -0
  78. algo_cli/intelligence/cow_state.py +103 -0
  79. algo_cli/intelligence/critic_loop.py +119 -0
  80. algo_cli/intelligence/cross_source.py +113 -0
  81. algo_cli/intelligence/daemon_mode.py +99 -0
  82. algo_cli/intelligence/dag_orchestration.py +151 -0
  83. algo_cli/intelligence/deep_research.py +155 -0
  84. algo_cli/intelligence/degenerate_detector.py +78 -0
  85. algo_cli/intelligence/delta_report.py +92 -0
  86. algo_cli/intelligence/discovery_event_log.py +92 -0
  87. algo_cli/intelligence/document_ingest.py +298 -0
  88. algo_cli/intelligence/dual_layer_validate.py +151 -0
  89. algo_cli/intelligence/echo_fidelity.py +73 -0
  90. algo_cli/intelligence/ema_tuning.py +104 -0
  91. algo_cli/intelligence/event_log.py +92 -0
  92. algo_cli/intelligence/evidence_graph.py +114 -0
  93. algo_cli/intelligence/extension_host.py +162 -0
  94. algo_cli/intelligence/extension_manifest.py +115 -0
  95. algo_cli/intelligence/falsification_suite.py +178 -0
  96. algo_cli/intelligence/finance/__init__.py +169 -0
  97. algo_cli/intelligence/finance/anomalies.py +135 -0
  98. algo_cli/intelligence/finance/ap_ar.py +351 -0
  99. algo_cli/intelligence/finance/cash.py +162 -0
  100. algo_cli/intelligence/finance/close.py +332 -0
  101. algo_cli/intelligence/finance/common.py +244 -0
  102. algo_cli/intelligence/finance/construction.py +135 -0
  103. algo_cli/intelligence/finance/controls.py +172 -0
  104. algo_cli/intelligence/finance/evidence.py +119 -0
  105. algo_cli/intelligence/finance/exceptions.py +157 -0
  106. algo_cli/intelligence/finance/reconciliations.py +254 -0
  107. algo_cli/intelligence/finance/revenue.py +109 -0
  108. algo_cli/intelligence/finance/tax.py +74 -0
  109. algo_cli/intelligence/finance/workpapers.py +111 -0
  110. algo_cli/intelligence/finding_record.py +120 -0
  111. algo_cli/intelligence/flow_dag.py +267 -0
  112. algo_cli/intelligence/gatherer.py +223 -0
  113. algo_cli/intelligence/golden_master.py +98 -0
  114. algo_cli/intelligence/graph_rag.py +195 -0
  115. algo_cli/intelligence/group_chat.py +143 -0
  116. algo_cli/intelligence/hash_dedup.py +145 -0
  117. algo_cli/intelligence/hyperloglog.py +128 -0
  118. algo_cli/intelligence/incremental_index.py +316 -0
  119. algo_cli/intelligence/index_store.py +16 -0
  120. algo_cli/intelligence/iteration_plan.py +133 -0
  121. algo_cli/intelligence/kernel_plugins.py +167 -0
  122. algo_cli/intelligence/lesson_catalog.py +135 -0
  123. algo_cli/intelligence/llm_fallback.py +169 -0
  124. algo_cli/intelligence/log2_histogram.py +267 -0
  125. algo_cli/intelligence/lsp_integration.py +147 -0
  126. algo_cli/intelligence/memory_evolution.py +117 -0
  127. algo_cli/intelligence/minhash_lsh.py +182 -0
  128. algo_cli/intelligence/multi_model_score.py +174 -0
  129. algo_cli/intelligence/multi_tier_grade.py +211 -0
  130. algo_cli/intelligence/negative_controls.py +113 -0
  131. algo_cli/intelligence/numeric_clamp.py +63 -0
  132. algo_cli/intelligence/occ_editor.py +66 -0
  133. algo_cli/intelligence/output_normalize.py +112 -0
  134. algo_cli/intelligence/parallel_delegation.py +98 -0
  135. algo_cli/intelligence/parallel_fanout.py +104 -0
  136. algo_cli/intelligence/permission_modes.py +105 -0
  137. algo_cli/intelligence/pre_push_gate.py +68 -0
  138. algo_cli/intelligence/prefetch.py +171 -0
  139. algo_cli/intelligence/process_framework.py +217 -0
  140. algo_cli/intelligence/project_graph.py +387 -0
  141. algo_cli/intelligence/query_expansion.py +146 -0
  142. algo_cli/intelligence/ralph_loop.py +117 -0
  143. algo_cli/intelligence/rate_limiter.py +153 -0
  144. algo_cli/intelligence/refactor_transaction.py +94 -0
  145. algo_cli/intelligence/research_workspace.py +108 -0
  146. algo_cli/intelligence/retraction_ledger.py +72 -0
  147. algo_cli/intelligence/saga_pattern.py +88 -0
  148. algo_cli/intelligence/session_fork.py +100 -0
  149. algo_cli/intelligence/shadow_editor.py +67 -0
  150. algo_cli/intelligence/shell_session.py +213 -0
  151. algo_cli/intelligence/source_registry.py +143 -0
  152. algo_cli/intelligence/spawn_scales.py +99 -0
  153. algo_cli/intelligence/stat_stability.py +104 -0
  154. algo_cli/intelligence/structural_validator.py +148 -0
  155. algo_cli/intelligence/subagent_spawner.py +111 -0
  156. algo_cli/intelligence/symmetric_verify.py +70 -0
  157. algo_cli/intelligence/task_classifier.py +129 -0
  158. algo_cli/intelligence/team_execution.py +122 -0
  159. algo_cli/intelligence/tiered_access.py +121 -0
  160. algo_cli/intelligence/utility_registry.py +159 -0
  161. algo_cli/intuition_engine.py +560 -0
  162. algo_cli/intuition_injector.py +82 -0
  163. algo_cli/kernels/__init__.py +5 -0
  164. algo_cli/kernels/manifest.py +763 -0
  165. algo_cli/main.py +3903 -0
  166. algo_cli/memory_candidates.py +541 -0
  167. algo_cli/memory_echo_veil.py +394 -0
  168. algo_cli/memory_runtime.py +112 -0
  169. algo_cli/model_info.py +548 -0
  170. algo_cli/model_profile.py +160 -0
  171. algo_cli/model_routing.py +74 -0
  172. algo_cli/oneshot.py +331 -0
  173. algo_cli/perf_telemetry.py +389 -0
  174. algo_cli/plugins.py +245 -0
  175. algo_cli/private_event_store.py +654 -0
  176. algo_cli/quantization/__init__.py +24 -0
  177. algo_cli/quantization/lloyd_max.py +98 -0
  178. algo_cli/quantization/turbo_quant.py +308 -0
  179. algo_cli/reasoning/__init__.py +46 -0
  180. algo_cli/reasoning/combinatorial.py +356 -0
  181. algo_cli/reasoning/graph_of_thought.py +297 -0
  182. algo_cli/reasoning/mcts.py +220 -0
  183. algo_cli/reasoning/neuro_symbolic.py +250 -0
  184. algo_cli/reasoning/react.py +246 -0
  185. algo_cli/reasoning/reflexion.py +225 -0
  186. algo_cli/reasoning/tree_of_thought.py +241 -0
  187. algo_cli/reasoning_bridge.py +150 -0
  188. algo_cli/reconciliation.py +284 -0
  189. algo_cli/reflex.py +385 -0
  190. algo_cli/resources/docs/ALGO.md +13958 -0
  191. algo_cli/resources/docs/algo-cli-algorithm-evidence-contract.md +60 -0
  192. algo_cli/resources/docs/algo-cli-execution-verification-contract.md +59 -0
  193. algo_cli/resources/docs/algo-cli-memory-lifecycle-contract.md +72 -0
  194. algo_cli/resources/docs/harness-extension-cleanup-recommendation.md +41 -0
  195. algo_cli/resources/docs/index-compute-lab-integration.md +32 -0
  196. algo_cli/resources/docs/inference-harness-loop-blueprint-2026-06.md +55 -0
  197. algo_cli/resources/docs/main-split-map.md +35 -0
  198. algo_cli/resources/docs/privacy-and-context.md +48 -0
  199. algo_cli/resources/docs/reflex-loop-v0.2.md +354 -0
  200. algo_cli/resources/skills/README.md +26 -0
  201. algo_cli/resources/skills/algo-cli.md +59 -0
  202. algo_cli/resources/skills/edit-file-precision.md +49 -0
  203. algo_cli/resources/skills/harness-search-first.md +47 -0
  204. algo_cli/resources/skills/memory-recall-ritual.md +51 -0
  205. algo_cli/resources/skills/qol-algorithms.md +224 -0
  206. algo_cli/resources/skills/smart-error-recovery.md +56 -0
  207. algo_cli/resources/skills/tool-selection-cheatsheet.md +65 -0
  208. algo_cli/retrieval_algorithms.py +127 -0
  209. algo_cli/runtime_qos.py +236 -0
  210. algo_cli/runtime_services.py +320 -0
  211. algo_cli/session_commands.py +95 -0
  212. algo_cli/session_mode.py +113 -0
  213. algo_cli/skills.py +430 -0
  214. algo_cli/slash_dispatch.py +1265 -0
  215. algo_cli/small_context.py +206 -0
  216. algo_cli/spawn_budget.py +89 -0
  217. algo_cli/task_ledger.py +84 -0
  218. algo_cli/task_router.py +197 -0
  219. algo_cli/tool_context.py +94 -0
  220. algo_cli/tool_contract.py +99 -0
  221. algo_cli/tool_policy.py +357 -0
  222. algo_cli/tool_runtime.py +647 -0
  223. algo_cli/tools.py +3056 -0
  224. algo_cli/url_scheme.py +174 -0
  225. algo_cli/verify.py +154 -0
  226. algo_cli/version_manifest.py +178 -0
  227. algo_cli/vision_screenshot_verify.py +76 -0
  228. algo_cli/workspace_resolver.py +68 -0
  229. algo_cli/x_account.py +209 -0
  230. algo_cli/xai_auth.py +374 -0
  231. algo_cli/xai_client.py +600 -0
  232. algo_cli_runtime-0.14.0.dist-info/METADATA +369 -0
  233. algo_cli_runtime-0.14.0.dist-info/RECORD +237 -0
  234. algo_cli_runtime-0.14.0.dist-info/WHEEL +4 -0
  235. algo_cli_runtime-0.14.0.dist-info/entry_points.txt +3 -0
  236. algo_cli_runtime-0.14.0.dist-info/licenses/LICENSE +21 -0
  237. ollama_cli/__init__.py +67 -0
@@ -0,0 +1,354 @@
1
+ ---
2
+ status: historical
3
+ tags: [reflex, design-history]
4
+ ---
5
+
6
+ # Reflex Loop Spec v0.2
7
+
8
+ **Status:** Historical design contract; retained for provenance, not current runtime guidance.
9
+ **Origin:** derived from the v0.1 in-conversation draft and the 2026-06 session notes on self-healing reflex attempts.
10
+ **Provenance note:** the spec is the reflex's *own* contract. It composes existing skills; it does not reimplement them.
11
+
12
+ ---
13
+
14
+ ## §1 Purpose
15
+
16
+ A thin in-session orchestrator that detects when the current approach is failing, decides
17
+ whether recovery is safe, applies the smallest contained corrective action, and verifies
18
+ the recovery actually worked. The reflex is **not** a runtime feature. It is a workflow
19
+ contract that an Algo CLI or compatible agent follows inside an
20
+ existing session.
21
+
22
+ The reflex composes three existing skills:
23
+
24
+ | Phase | Composed skill | Role |
25
+ |---|---|---|
26
+ | DETECT / DECIDE / ACT | `codex:skill:agent-introspection-debugging` | four-phase self-debug loop |
27
+ | VERIFY (code-change mode) | `codex:skill:verification-loop` | post-change quality gate |
28
+ | VERIFY (index / prefilter mode) | harness verify pass + confidence gate | post-mutation index check |
29
+
30
+ The reflex adds three things the composed skills do not own:
31
+
32
+ 1. A **session-scoped attempt ledger** that prevents the same failed action from being
33
+ retried with cosmetic variation.
34
+ 2. A **safe-allowlist** that constrains which tools the ACT step may call, derived from
35
+ the introspection skill's "do not claim unsupported auto-healing actions" rule.
36
+ 3. A **state machine** that gives the loop an exit condition, a budget, and a single
37
+ `resolved:true` terminal signal.
38
+
39
+ Everything else is inherited.
40
+
41
+ ---
42
+
43
+ ## §2 Triggers
44
+
45
+ The reflex activates when at least one of the following is true:
46
+
47
+ 1. **Same tool, same arguments, third call.** (Loop detector — catches `harness_search`
48
+ for the same query, `read_file` on the same path, etc.)
49
+ 2. **Safe-mode block on a non-destructive-looking command.** (Catches destructive
50
+ operations that slipped past the verb classifier — `Move-Item`, `del /s`, etc.)
51
+ 3. **Tool result has zero useful lines and the action was repeated once already.**
52
+ (Catches dead-end reads / searches / web fetches.)
53
+ 4. **In-session attempt ledger hit count > 2 for the same `action_class`.** (Belt and
54
+ suspenders for #1; useful when the same verb is used with different args.)
55
+ 5. **Explicit human request.** ("Use the reflex on this." / "self-heal this.")
56
+
57
+ **Removed from v0.1:** trigger #4 was "in-conversation self-heal mechanism." It duplicated
58
+ the explicit-request trigger and added no signal.
59
+
60
+ **Session-level cap:** the reflex may run at most **3 reflex cycles per session** without
61
+ explicit human approval for further cycles. A 4th attempt must `ESCALATE` rather than
62
+ re-enter DETECT.
63
+
64
+ ---
65
+
66
+ ## §3 State machine
67
+
68
+ ```
69
+ ┌──────────┐
70
+ │ DETECT │ -- agent-introspection-debugging Phase 1 (Capture)
71
+ └────┬─────┘
72
+ │ capture_record
73
+ ▼
74
+ ┌──────────┐
75
+ │ DECIDE │ -- agent-introspection-debugging Phase 2 (Diagnosis)
76
+ └────┬─────┘
77
+ │ diagnosis_record
78
+ ┌────────┴────────┐
79
+ │ │
80
+ resolution = resolution =
81
+ "act" "escalate" / "no_act"
82
+ │ │
83
+ ▼ ▼
84
+ ┌──────────┐ ┌────────────┐
85
+ │ ACT │ │ ESCALATE │ (terminal)
86
+ └────┬─────┘ └────────────┘
87
+ │ action_record
88
+ ▼
89
+ ┌──────────┐
90
+ │ VERIFY │ -- mode chosen below
91
+ └────┬─────┘
92
+ │
93
+ ┌────┴────────────────────┐
94
+ │ │
95
+ mode = "code_change" mode = "index_or_prefilter"
96
+ │ │
97
+ calls verification-loop calls harness verify pass
98
+ reads READY/NOT READY applies confidence gate (2 of 3)
99
+ │ │
100
+ └────┬────────────────────┘
101
+ │
102
+ ┌────┴───────────┐
103
+ │ │
104
+ resolved=true verify_uncertain / verify_failed
105
+ (terminal) │
106
+ ▼
107
+ back to DETECT (with cap guard)
108
+ OR ESCALATE (if cap hit)
109
+ ```
110
+
111
+ **Edge rules:**
112
+
113
+ - A cycle that ends in `ESCALATE` consumes the session cap.
114
+ - A cycle that ends in `resolved:true` does **not** reset the cap; cap counts are
115
+ cumulative across the session.
116
+ - The `back to DETECT` edge from VERIFY is permitted **only** if the cycle counter is
117
+ below the cap and the verify outcome is `verify_uncertain` (not `verify_failed`).
118
+ `verify_failed` is treated as `ESCALATE` regardless of cap state, because a failed
119
+ verify on a recovery is a strong signal the diagnosis was wrong.
120
+
121
+ ---
122
+
123
+ ## §4 Class taxonomy (inherited, not invented)
124
+
125
+ The v0.1 spec invented a small class list (`stale_index`, `dup_index`, `budget_exhausted`,
126
+ `quality_gate_failure`). v0.2 drops that list in favor of the pattern table already
127
+ maintained by `agent-introspection-debugging`, with a **mapping column** for reflex-specific
128
+ classes.
129
+
130
+ The inherited table is the source of truth. Reflex classes are labels, not categories.
131
+
132
+ | Pattern (inherited) | Likely cause (inherited) | Check (inherited) | Reflex class label(s) |
133
+ |---|---|---|---|
134
+ | Maximum tool calls / repeated same command | loop or no-exit observer path | inspect last N tool calls for repetition | `loop_detected` |
135
+ | Context overflow / degraded reasoning | unbounded notes, repeated plans, oversized logs | inspect recent context for duplication and low-signal bulk | `stale_index`, `dup_index`, `context_overflow` |
136
+ | `ECONNREFUSED` / timeout | service unavailable or wrong port | verify service health, URL, and port | `service_unavailable` |
137
+ | `429` / quota exhaustion | retry storm or missing backoff | count repeated calls and inspect retry spacing | `budget_exhausted`, `retry_storm` |
138
+ | File missing after write / stale diff | race, wrong cwd, or branch drift | re-check path, cwd, git status, actual file existence | `stale_diff`, `path_drift` |
139
+ | Tests still failing after "fix" | wrong hypothesis | isolate the exact failing test and re-derive the bug | `quality_gate_failure` |
140
+
141
+ **Why labels, not categories:** the introspection skill's diagnosis is pattern-based and
142
+ may map to multiple reflex class labels. Labels are what the attempt ledger records; the
143
+ diagnosis is what the introspection skill produces. The two stay separate.
144
+
145
+ **Diagnosis precedence (from introspection skill, paraphrased):** before changing anything,
146
+ answer these in order:
147
+
148
+ 1. Is this a logic failure, state failure, environment failure, or policy failure?
149
+ 2. Did the agent lose the real objective and start optimizing the wrong subtask?
150
+ 3. Is the failure deterministic or transient?
151
+ 4. What is the smallest reversible action that would validate the diagnosis?
152
+
153
+ If #2 is yes, the reflex must ESCALATE — the diagnosis question takes priority over the
154
+ class label.
155
+
156
+ ---
157
+
158
+ ## §5 Safe allowlist
159
+
160
+ The ACT step may call only the following, in this order of preference:
161
+
162
+ 1. `harness_search` / `harness_read` (read-only observation, no mutation)
163
+ 2. `run_shell` with **non-mutating verbs only** (`Get-*`, `Test-*`, `Select-String`,
164
+ `rg`, `ls`, `cat`, `head`, `tail`, `find`, `stat`)
165
+ 3. `read_file`, `search_files`, `list_directory`
166
+ 4. `git_status`, `git_diff` (read-only git ops)
167
+ 5. `web_search`, `web_fetch` (external research)
168
+
169
+ **Governing principle (lifted from `agent-introspection-debugging`):** do not claim
170
+ auto-healing actions like "reset agent state," "update harness config," or "rewrite
171
+ the index" unless the agent is actually performing them through a real tool call in
172
+ the current environment. The safe allowlist is a strict subset of what the agent can
173
+ do; it is not a description of what the agent wishes it could do.
174
+
175
+ **If the diagnosis requires an off-list action, the reflex must ESCALATE.** Examples
176
+ that would require off-list actions (and therefore escalate, not act):
177
+
178
+ - The fix needs a destructive `Move-Item` / `del` — escalate.
179
+ - The fix needs to mutate `harness_index.json` directly — escalate to
180
+ `workspace-surface-audit` (per the introspection skill's integration note).
181
+ - The fix needs to push to a remote, install a package, or spawn a background process —
182
+ escalate.
183
+
184
+ **Off-list ESCALATE routing** is delegated to whichever existing skill owns the domain
185
+ (per the introspection skill's "use the narrower ECC skill when one exists" rule). The
186
+ reflex does not invent routing.
187
+
188
+ ---
189
+
190
+ ## §6 Verify
191
+
192
+ The VERIFY step is two-mode. The mode is chosen by inspecting the ACT step's action
193
+ record.
194
+
195
+ ### Mode A: `code_change`
196
+
197
+ If the ACT step emitted a code change (file write, file edit, package install, config
198
+ change), the reflex uses the enabled verification workflow. It may use
199
+ `codex:skill:verification-loop` when external Codex sources are explicitly enabled
200
+ and that record is present; otherwise it falls back to the built-in verification gate.
201
+
202
+ | Verdict | Reflex behavior |
203
+ |---|---|
204
+ | `READY` | `resolved:true`, write ledger, end cycle |
205
+ | `NOT READY` | `verify_failed`, ESCALATE (per §3 edge rules) |
206
+ | `verification-loop` itself fails or is unavailable | `verify_uncertain`, fall through to Mode B if applicable, else ESCALATE |
207
+
208
+ The reflex consumes the **verdict**, not the full report. The full report goes to the
209
+ human-readable introspection output.
210
+
211
+ ### Mode B: `index_or_prefilter`
212
+
213
+ If the ACT step was a prefilter invocation, a query re-issuance, or a read-only
214
+ patch to a script that will be run separately, the reflex does its own confidence
215
+ gate. The gate passes (returns `resolved:true`) when **at least two of the following
216
+ three are true**:
217
+
218
+ 1. The top-hit `path` field in the new `harness_search` result differs from the
219
+ previous top hit.
220
+ 2. The cosine-similarity **delta** between the previous and new top hit (using the
221
+ harness RAG's `_cosine` over the `embedding` field — see
222
+ `algo_cli/harness.py:_cosine`) is **≥ 0.05**.
223
+ 3. The dropped-record count in the new prefilter report matches the count the
224
+ prefilter said it would drop.
225
+
226
+ If fewer than two pass, the reflex records `verify_uncertain` and either re-enters
227
+ DETECT (under cap) or ESCALATES.
228
+
229
+ **Provenance and open tuning.** The 0.05 delta in item 2 is a **starting value**,
230
+ not an inherited threshold. It does **not** come from `harness_prefilter.py`,
231
+ whose similarity gate is `_token_jaccard(...) >= DEDUPE_SIM_THRESHOLD` (0.92,
232
+ absolute, on titles within the same record group). That gate answers a
233
+ different question (is this record a dupe?) than Mode B is asking (did the
234
+ prefilter actually change the top hit the user is looking at?). Conflating them
235
+ was a v0.2 drafting error. The first real session that exercises Mode B should
236
+ log the observed delta distribution; if the median delta is far from 0.05, the
237
+ threshold moves and this section is updated.
238
+
239
+ ### `verify_mode: false` sessions
240
+
241
+ When the user has set `verify_mode: false` for the session (a future flag, not yet
242
+ implemented), DETECT and DECIDE still run. DECIDE's output is constrained to
243
+ `escalate` or `no_act` — it cannot transition to ACT. This is the safe-mode for
244
+ healing behavior the user has explicitly disabled.
245
+
246
+ ---
247
+
248
+ ## §7 Integration matrix
249
+
250
+ | Phase | Skill | Path | Confidence |
251
+ |---|---|---|---|
252
+ | DETECT | `agent-introspection-debugging` | user-configured skill root | read this turn — grounded |
253
+ | DECIDE | `agent-introspection-debugging` | (same) | grounded |
254
+ | ACT | `agent-introspection-debugging` (Phase 3) + safe allowlist (§5) | (same) | grounded, with the allowlist as the reflex's local addition |
255
+ | VERIFY (code_change) | `verification-loop` | user-configured skill root | read this turn — grounded |
256
+ | VERIFY (index_or_prefilter) | harness verify pass + confidence gate | n/a (built into reflex) | grounded |
257
+ | crystallize destination | **no fixed consumer** | label only | **referenced-but-absent** — see Unverified Claims below |
258
+ | off-list ESCALATE (state / repo drift) | `workspace-surface-audit` (per introspection integration note) | not yet located in harness | unverified path |
259
+ | off-list ESCALATE (decision ambiguity) | `council` (per introspection integration note) | not yet located in harness | unverified path |
260
+
261
+ **`continuous-learning-v2` status (revised this turn):** the skill named in
262
+ `agent-introspection-debugging`'s integration section does **not** exist in the harness
263
+ index. The closest functional neighbors are `codex-session-skill-mining` and
264
+ `knowledge-ops`, but neither is a drop-in replacement. v0.2 does not bind a fixed
265
+ consumer — the reflex emits a `crystallize_candidate` label and the human routes it.
266
+
267
+ ---
268
+
269
+ ## §8 Outcomes
270
+
271
+ Each cycle terminates in one of:
272
+
273
+ | Outcome | Meaning | Terminal? |
274
+ |---|---|---|
275
+ | `resolved:true` | Recovery succeeded and verified | yes |
276
+ | `escalated` | Off-list action required, or cap hit, or `verify_failed` | yes (human decision) |
277
+ | `blocked-by-safe-mode` | ACT was called but a tool in the allowlist was blocked by the shell safe mode | yes (per-action, not terminal for the session) |
278
+ | `verify_uncertain` | VERIFY could not produce a confident yes/no | no (re-enters DETECT under cap) |
279
+ | `no_act` | DECIDE determined the right action is "do nothing; restate hypothesis" | yes |
280
+
281
+ A `no_act` outcome is not a failure. The introspection skill's first recovery heuristic
282
+ is "restate the real objective in one sentence." Sometimes the right answer is to stop
283
+ and restate, not to mutate.
284
+
285
+ ---
286
+
287
+ ## §9 Persistence
288
+
289
+ - **In-session:** the attempt ledger is a runtime record. It lives in the agent's
290
+ working memory for the session. There is no filesystem write to a ledger file.
291
+ - **Cross-session:** the **only** durable record is the human-readable
292
+ "Agent Self-Debug Report" produced at the end of the cycle (per the introspection
293
+ skill's Phase 4) and, optionally, a one-line append to the user's `lessons-learned.md`
294
+ for patterns that recur.
295
+ - **Claim:** the v0.1 spec suggested a JSON ledger file with `resolved:true`. v0.2
296
+ rejects that. JSON ledgers are an anti-feature for a workflow that runs once per
297
+ cycle; they invite stale data and write-amplification. The introspection report is
298
+ the ledger. If structured persistence is needed later, the right move is a new
299
+ skill that *crystallizes* the report, not a side-channel file.
300
+
301
+ ---
302
+
303
+ ## §10 Open items → appendices
304
+
305
+ The v0.1 spec ended with a §10 "open items" list. v0.2 splits the resolved and
306
+ unresolved claims into two appendices.
307
+
308
+ ### Appendix A — Resolutions
309
+
310
+ | # | v0.1 issue | v0.2 resolution |
311
+ |---|---|---|
312
+ | 1 | Two-on-the-same-tool vs. three-on-the-same-tool | Three-call threshold; second call warns in-line, third triggers DETECT |
313
+ | 2 | "In-conversation self-heal mechanism" trigger | Removed; folded into explicit-request trigger |
314
+ | 3 | Budget / session cap | 3 cycles per session, 4th must ESCALATE |
315
+ | 4 | Class taxonomy duplication with `agent-introspection-debugging` | Inherited that skill's pattern table; reflex classes are labels, mapped 1:N |
316
+ | 5 | VERIFY one-size-fits-all | Two-mode VERIFY (§6) |
317
+ | 6 | "do not claim unsupported auto-healing" framing | Imported as §5 governing principle |
318
+ | 7 | Off-list actions | §5 — escalate, do not invent a permit |
319
+ | 8 | Confidence gate for index-mode verify | §6 Mode B — two-of-three gate |
320
+ | 9 | Crystallize dedup ownership | §7 — label only, no fixed consumer (skill is absent) |
321
+ | 10 | `harness_healthcheck.py` | Dropped; reflex does not own healthcheck, can call one when available |
322
+ | 11 | Schema example for `escalated` / `blocked-by-safe-mode` | §8 — full outcome table |
323
+ | 12 | `resolved:true` cross-session persistence | §9 — rejected, in-session only |
324
+ | 13 | Off-list ESCALATE routing | §5 / §7 — delegate to existing skills; reflex does not own routing |
325
+ | 14 | Missing outcome types | §8 — five outcomes |
326
+
327
+ ### Appendix B — Unverified Claims
328
+
329
+ | Claim | Why flagged | Action |
330
+ |---|---|---|
331
+ | `continuous-learning-v2` is a real skill | Referenced in `agent-introspection-debugging` integration section; not in harness index | v0.2 treats it as absent; label-only contract |
332
+ | `workspace-surface-audit` path | Referenced in same section; not located this turn | Off-list ESCALATE that needs it must locate it first; do not blind-route |
333
+ | `council` path | Same | Same |
334
+ | `codex-session-skill-mining` and `knowledge-ops` cover the crystallize use case | Both mention dedup / skill creation in their summaries; not yet read end-to-end | Acceptable as a downstream hint; not a reflex contract |
335
+ | `verify_mode: false` flag | Referenced in §6; not implemented | Reserved for a future v0.3, not a v0.2 commitment |
336
+ | Cosine-similarity delta 0.05 in §6 Mode B item 2 | Was mislabelled as inherited from the prefilter; the prefilter's gate is Jaccard 0.92 absolute. 0.05 is a starting delta on the harness RAG's cosine (`algo_cli/harness.py:_cosine`). | Log real deltas in the first session that exercises Mode B; recalibrate. |
337
+
338
+ ---
339
+
340
+ ## End of v0.2
341
+
342
+ Next moves the spec suggests, in order:
343
+
344
+ 1. Read `codex-session-skill-mining` end-to-end to confirm or rule out the
345
+ `continuous-learning-v2` claim. One tool call.
346
+ 2. (Done 2026-06 turn.) §6 Mode B's threshold provenance was wrong — the
347
+ 0.05 is a starting delta on the harness RAG's cosine, not the prefilter's
348
+ Jaccard gate (which is 0.92 absolute). Section updated; threshold itself
349
+ stays at 0.05 pending observed-delta calibration.
350
+ 3. After both, write a one-page operator's guide — the spec is the contract,
351
+ the guide is the "how do I invoke this" doc.
352
+ 4. Hand the `edit_file` tool spec to the reflex as a follow-up. v0.1 deferred this
353
+ because the integration model was wrong; v0.2's safe allowlist and two-mode
354
+ VERIFY now make the tool's contract clearer.
@@ -0,0 +1,26 @@
1
+ # Algo CLI skills
2
+
3
+ This directory contains the public, packaged skills that Algo CLI can retrieve through its harness. They are available in both source checkouts and installed wheels.
4
+
5
+ | Skill | Purpose |
6
+ |---|---|
7
+ | `algo-cli.md` | Product capabilities, configuration, and migration facts. |
8
+ | `edit-file-precision.md` | Precise file edits and common recovery paths. |
9
+ | `harness-search-first.md` | Choosing indexed retrieval before broad scans. |
10
+ | `memory-recall-ritual.md` | Capability-aware memory and retrieval checks. |
11
+ | `qol-algorithms.md` | Small algorithms used on CLI hot paths. |
12
+ | `smart-error-recovery.md` | Classify failures before choosing a retry. |
13
+ | `tool-selection-cheatsheet.md` | Pick the narrowest suitable runtime tool. |
14
+
15
+ ## Sources and privacy
16
+
17
+ Packaged skills and user-created records under `~/.algo_cli` are available by default. Other local agent stores—Codex, Claude, OpenClaw, Mercury, Pi, CLI Agent, and shared `.agents`—are excluded until the user runs `/harness external on`. Retrieved context becomes part of the active model request, so opt-in sources may leave the machine when a cloud provider is selected.
18
+
19
+ ## Adding a skill
20
+
21
+ 1. Use neutral examples and the frontmatter conventions in an existing skill.
22
+ 2. Save the new Markdown file in this directory.
23
+ 3. Run `/harness refresh`.
24
+ 4. Verify retrieval with `harness_search(query="distinctive terms", kind="skill")` and `harness_read(record_id)`.
25
+
26
+ User-generated skills belong under `~/.algo_cli/skills`. External skills do not need to be copied after the corresponding source has been explicitly enabled.
@@ -0,0 +1,59 @@
1
+ # Algo CLI — Local-First Agentic Terminal Assistant
2
+
3
+ **Type:** Primary Coding Agent / Tool
4
+ **Command:** `algo-cli`
5
+ **Current Version:** 0.14.0
6
+
7
+ ## Overview
8
+
9
+ Algo CLI is a powerful local-first terminal agent designed for software engineering workflows. It excels at tool use, long-running tasks, context management, and integrating with a user's broader agent ecosystem via the harness RAG layer.
10
+
11
+ It was previously known as **ollama-cli** and underwent a complete rebrand in June 2026.
12
+
13
+ ## Core Strengths
14
+
15
+ - Excellent structured tool calling with approval system and safe mode
16
+ - Strong identity layer (SOUL, IDENTITY, USER, lessons)
17
+ - Automatic skill crystallization from successful runs
18
+ - Sophisticated context handling (pruning, compaction, summarization); June 2026 hot-path pass: single system-prompt build per agent_loop iteration, O(n) tool pruning, shared embed unpack (`docs/algo-cli-hot-path-perf-2026-06.md`)
19
+ - Deep harness RAG integration across multiple agent tools
20
+ - Support for local Ollama + Ollama Cloud + optional xAI Grok OAuth (user-provided `XAI_CLIENT_ID`)
21
+
22
+ ## Key Commands & Features
23
+
24
+ - `/memory-auto status|on|off`, `/remember`, `/memories`, `/forget` — bounded automatic and explicit long-term memory
25
+ - `/lesson` — append to lessons-learned
26
+ - `/agent` — structured multi-block agent pipelines
27
+ - `/harness`, `/hsearch`, `/hread` — harness RAG control
28
+ - `--oneshot --json` — machine-readable NDJSON output mode
29
+ - Full support for thinking models and reflection checkpoints
30
+
31
+ ## Configuration
32
+
33
+ - Primary config directory: `~/.algo_cli/`
34
+ - Legacy location (`~/.ollama_cli`) is automatically migrated on first run
35
+ - Environment variables use `ALGO_CLI_*` prefix (legacy `OLLAMA_CLI_*` still supported)
36
+
37
+ ## Usage Recommendations
38
+
39
+ Use Algo CLI when you need:
40
+ - Reliable long-horizon tool use with human oversight
41
+ - Strong memory and identity continuity
42
+ - Integration with other agent tools via harness
43
+ - High-quality local model performance with good context management
44
+
45
+ ## Rebrand Notes
46
+
47
+ The project completed a three-phase rebrand in June 2026:
48
+ - Phase 1: Package and command rename
49
+ - Phase 2: Default directory migration to `~/.algo_cli`
50
+ - Phase 3: Full visible branding update
51
+
52
+ Legacy `ollama-cli` command and environment variables remain functional during the transition period.
53
+
54
+ ## Related
55
+
56
+ - GitHub: https://github.com/Seabass-up/algo-cli
57
+ - Primary documentation: README.md in the source repository
58
+
59
+ **Last Updated:** 2026-07
@@ -0,0 +1,49 @@
1
+ ---
2
+ name: edit-file-precision
3
+ description: Use edit_file (find/replace) instead of write_file for surgical edits to existing files. Faster, fewer tokens, less error-prone.
4
+ tags: [algo-cli, edit_file, workflow, file-mutation]
5
+ created: 2026-06-09
6
+ ---
7
+
8
+ # Edit-File Precision
9
+
10
+ ## Trigger
11
+
12
+ When the model needs to modify an existing file (not create a new one, not
13
+ do a full rewrite), reach for `edit_file` first.
14
+
15
+ ## Steps
16
+
17
+ 1. If you don't know the exact current contents of the file, call `read_file`
18
+ first. This avoids failed matches from stale mental models of the file.
19
+ 2. Construct `old_string` with 2-5 lines of surrounding context so the match
20
+ is unique. Use whitespace/indentation exactly as it appears in the file.
21
+ 3. Call `edit_file(path, old_string, new_string)`.
22
+ 4. If the tool returns "matched N locations", tighten `old_string` (add more
23
+ context) or pass `replace_all=True` only when the rewrite is genuinely
24
+ global.
25
+ 5. If the tool returns "old_string not found", re-`read_file` and look for
26
+ trailing whitespace, CRLF, or tabs/spaces mismatches, then retry.
27
+ 6. After a successful edit, optionally `read_file` the changed section to
28
+ verify the result before claiming completion.
29
+
30
+ ## Key Discoveries
31
+
32
+ - edit_file uses `_atomic_write_text` (write-to-tmp + `os.replace`) so partial
33
+ power loss cannot corrupt the file. It is safer than `sed -i` in shell.
34
+ - For files larger than 50k characters, prefer multiple small `edit_file`
35
+ calls over one large `write_file` — each edit returns the affected line
36
+ range, which is much easier to verify than a full rewrite.
37
+ - When making the SAME change in many files (e.g. rename an import), loop
38
+ with `edit_file` and check the return string for the line count to confirm
39
+ the match was unique in each file.
40
+ - edit_file is registered as a DANGEROUS tool (requires `/auto` to skip
41
+ approval) the same way `write_file` is. Plan the prompt for the user.
42
+ - For multi-line replacements, keep `old_string` short but include the
43
+ smallest unique anchor — typically the function signature plus one body
44
+ line is enough.
45
+
46
+ ## Environment
47
+
48
+ algo-cli >= 0.4 (edit_file introduced 2026-06-09). Works on any platform
49
+ where write-to-tmp + os.replace works (Linux, macOS, Windows).
@@ -0,0 +1,47 @@
1
+ ---
2
+ name: harness-search-first
3
+ description: Before broad filesystem scans, call harness_search to find skills, prompts, memory, wiki pages, and workflows already indexed from codex/claude/openclaw/mercury/pi/agents.
4
+ tags: [algo-cli, harness, RAG, navigation]
5
+ created: 2026-06-09
6
+ ---
7
+
8
+ # Harness Search First
9
+
10
+ ## Trigger
11
+
12
+ When the user asks for "the X skill" or "how to do Y" or wants a known
13
+ workflow, or when you are about to scan a large directory tree, run
14
+ `harness_search` first.
15
+
16
+ ## Steps
17
+
18
+ 1. Call `harness_search(query, harness_name=None, kind=None, limit=10)`.
19
+ 2. If results exist, pick the most relevant 1-3 and call
20
+ `harness_read(record_id)` to load their full body.
21
+ 3. If no results match, fall back to `search_files` and `read_file`.
22
+ 4. When writing your final answer, cite the harness record ids you used
23
+ (e.g. "codex:skill:browser-qa/SKILL.md") so the user can find the source.
24
+
25
+ ## Key Discoveries
26
+
27
+ - The harness can cover **seven** external harnesses when the user opts in:
28
+ codex, claude, openclaw, agents, mercury, cli-agent, pi. Their skills
29
+ flow into `harness_search` without any per-harness plumbing.
30
+ - `harness_name` accepts aliases: `openclaude` -> {claude, openclaw},
31
+ `codex-cli` -> {codex}, `all` -> no filter. Use these for natural-language
32
+ routing.
33
+ - `kind` is one of: skill, tool, prompt, memory, wiki, workflow, extension.
34
+ Most retrieval questions are `skill` or `wiki` — start there.
35
+ - For configured project/entity memory questions, prefer `query_knowledge_graph`
36
+ when the user has enabled index-compute-lab; it uses ranked associations and
37
+ can be faster and more relevant than raw `harness_search`.
38
+ - The harness index is mtime-cached in `~/.algo_cli/harness_index.json`.
39
+ After editing a skill file, call `harness_refresh` to update the index
40
+ immediately (otherwise the next /harness refresh will pick it up via mtime).
41
+
42
+ ## Environment
43
+
44
+ algo-cli only. The harness index is built and maintained by
45
+ `algo_cli/harness.py:build_index()`. Rust indexer at `harness-indexer/`
46
+ is an optional speedup for cold-start builds but the Python scanner is
47
+ authoritative.
@@ -0,0 +1,51 @@
1
+ ---
2
+ name: memory-recall-ritual
3
+ description: Capability-aware checks for durable memory, indexed guidance, and an optional knowledge graph when they are relevant to a task.
4
+ tags: [algo-cli, memory, harness, knowledge-graph, ritual]
5
+ created: 2026-06-09
6
+ ---
7
+
8
+ # Memory Recall Ritual
9
+
10
+ ## Trigger
11
+
12
+ When prior user preferences, packaged guidance, or configured project knowledge
13
+ could materially change the task. Skip this ritual for simple direct reads and edits.
14
+
15
+ ## Steps
16
+
17
+ 1. **Use already-loaded memory.** Long-term memories and relevant lessons are
18
+ already included in the system context. Treat them as hints and verify
19
+ consequential facts.
20
+ 2. **Search indexed guidance when relevant.** Call `harness_stats`, then
21
+ `harness_search(query="<topic-relevant terms>")`; read only the strongest
22
+ records with `harness_read`.
23
+ 3. **Use the graph only when enabled.** Check `/icl status`. Call
24
+ `query_knowledge_graph("<topic>")` only when index-compute-lab is enabled
25
+ and ready; never enable or rebuild it implicitly.
26
+ 4. **Plan from evidence.** State what is known, what remains unverified, and
27
+ the next narrow action.
28
+
29
+ ## Key Discoveries
30
+
31
+ - `harness_search` returns RAG snippets, not full files. When the snippet
32
+ is too small to be useful, call `harness_read(record_id)` to get the
33
+ full body. Record ids look like `codex:skill:browser-qa/SKILL.md`.
34
+ - The `~/.algo_cli/memory.json` file is a flat list of facts loaded directly
35
+ into the system context; it is not made searchable merely by refreshing the
36
+ harness.
37
+ - `update_user_profile` writes to `~/.algo_cli/identity/USER.md`. This
38
+ file is prepended to every system prompt. Use it for stable
39
+ user-specific facts (role, location, communication style), not for
40
+ transient session notes (use `remember` for those).
41
+ - `query_knowledge_graph` is an optional index-compute-lab integration. If it
42
+ is disabled or unavailable, continue without it unless the user explicitly
43
+ requests setup or a rebuild.
44
+ - The Mercury compact stop-conditions are injected on every turn
45
+ regardless of session mode. They are the "be careful about X" rule
46
+ the model should never ignore. They are NOT user instructions and
47
+ NOT proof that files exist.
48
+
49
+ ## Environment
50
+
51
+ Algo CLI only. External harness stores and index-compute-lab remain opt-in.