mega-brain-ai 1.1.0
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.
Potentially problematic release.
This version of mega-brain-ai might be problematic. Click here for more details.
- package/.claude/CLAUDE.md +155 -0
- package/.claude/commands/agents.md +161 -0
- package/.claude/commands/ask.md +117 -0
- package/.claude/commands/benchmark.md +224 -0
- package/.claude/commands/chat.md +343 -0
- package/.claude/commands/compare.md +116 -0
- package/.claude/commands/conclave.md +194 -0
- package/.claude/commands/config.md +133 -0
- package/.claude/commands/council.md +194 -0
- package/.claude/commands/create-agent.md +452 -0
- package/.claude/commands/debate.md +157 -0
- package/.claude/commands/documentation/create-architecture-documentation.md +175 -0
- package/.claude/commands/dossiers.md +180 -0
- package/.claude/commands/evolve.md +223 -0
- package/.claude/commands/extract-dna.md +170 -0
- package/.claude/commands/extract-knowledge.md +507 -0
- package/.claude/commands/inbox.md +296 -0
- package/.claude/commands/ingest-empresa.md +191 -0
- package/.claude/commands/ingest.md +182 -0
- package/.claude/commands/jarvis-briefing.md +67 -0
- package/.claude/commands/jarvis-control.md +169 -0
- package/.claude/commands/jarvis-full.md +181 -0
- package/.claude/commands/jarvis.md +212 -0
- package/.claude/commands/ler-drive.md +212 -0
- package/.claude/commands/log.md +158 -0
- package/.claude/commands/loop.md +133 -0
- package/.claude/commands/loops.md +73 -0
- package/.claude/commands/mission-autopilot.md +538 -0
- package/.claude/commands/mission.md +353 -0
- package/.claude/commands/process-inbox.md +148 -0
- package/.claude/commands/process-jarvis.md +3036 -0
- package/.claude/commands/process-video.md +131 -0
- package/.claude/commands/rag-search.md +78 -0
- package/.claude/commands/resume.md +33 -0
- package/.claude/commands/save.md +38 -0
- package/.claude/commands/scan-inbox.md +125 -0
- package/.claude/commands/setup.md +99 -0
- package/.claude/commands/system-digest.md +243 -0
- package/.claude/commands/verify.md +182 -0
- package/.claude/commands/view-dna.md +169 -0
- package/.claude/hooks/agent_doctor.py +433 -0
- package/.claude/hooks/agent_memory_persister.py +203 -0
- package/.claude/hooks/auto_formatter.py +158 -0
- package/.claude/hooks/checkpoint_writer.py +244 -0
- package/.claude/hooks/claude_md_guard.py +146 -0
- package/.claude/hooks/creation_validator.py +357 -0
- package/.claude/hooks/enforce_dual_location.py +501 -0
- package/.claude/hooks/enforce_plan_mode.py +220 -0
- package/.claude/hooks/inbox_age_alert.py +367 -0
- package/.claude/hooks/jarvis_briefing.py +506 -0
- package/.claude/hooks/ledger_updater.py +301 -0
- package/.claude/hooks/memory_hints_injector.py +251 -0
- package/.claude/hooks/memory_updater.py +202 -0
- package/.claude/hooks/multi_agent_hook.py +464 -0
- package/.claude/hooks/notification_system.py +120 -0
- package/.claude/hooks/pattern_analyzer.py +526 -0
- package/.claude/hooks/pending_tracker.py +188 -0
- package/.claude/hooks/post_batch_cascading.py +1740 -0
- package/.claude/hooks/post_output_validator.py +358 -0
- package/.claude/hooks/post_tool_use.py +120 -0
- package/.claude/hooks/post_write_validator.py +200 -0
- package/.claude/hooks/quality_watchdog.py +394 -0
- package/.claude/hooks/ralph_wiggum.py +277 -0
- package/.claude/hooks/session-source-sync.py +218 -0
- package/.claude/hooks/session_autosave_v2.py +1135 -0
- package/.claude/hooks/session_end.py +203 -0
- package/.claude/hooks/session_start.py +939 -0
- package/.claude/hooks/skill_indexer.py +48 -0
- package/.claude/hooks/skill_router.py +358 -0
- package/.claude/hooks/stop_hook_completeness.py +178 -0
- package/.claude/hooks/subagent_tracker.py +163 -0
- package/.claude/hooks/token_checkpoint.py +584 -0
- package/.claude/hooks/user_prompt_submit.py +125 -0
- package/.claude/rules/ANTHROPIC-STANDARDS.md +384 -0
- package/.claude/rules/CLAUDE-LITE.md +201 -0
- package/.claude/rules/RULE-GROUP-1.md +320 -0
- package/.claude/rules/RULE-GROUP-2.md +307 -0
- package/.claude/rules/RULE-GROUP-3.md +248 -0
- package/.claude/rules/RULE-GROUP-4.md +427 -0
- package/.claude/rules/RULE-GROUP-5.md +388 -0
- package/.claude/rules/RULE-GROUP-6.md +387 -0
- package/.claude/rules/logging.md +53 -0
- package/.claude/rules/mcp-governance.md +128 -0
- package/.claude/rules/pipeline.md +60 -0
- package/.claude/rules/state-management.md +93 -0
- package/.claude/scripts/apply-tags.py +77 -0
- package/.claude/scripts/batch-extract-transcriptions.py +132 -0
- package/.claude/scripts/build-complete-index.py +250 -0
- package/.claude/scripts/build-planilha-index.py +170 -0
- package/.claude/scripts/complete-tag-matching.py +250 -0
- package/.claude/scripts/deduplicate-inbox.py +139 -0
- package/.claude/scripts/docx-xml-extractor.py +141 -0
- package/.claude/scripts/extract-docx-text.py +58 -0
- package/.claude/scripts/extract-single-transcription.py +74 -0
- package/.claude/scripts/extract_docx_from_gdrive.py +77 -0
- package/.claude/scripts/organized-downloader.py +246 -0
- package/.claude/scripts/planilha-tagger.py +187 -0
- package/.claude/scripts/revert-tags.py +70 -0
- package/.claude/scripts/source-sync.py +265 -0
- package/.claude/scripts/tag-inbox-files.py +276 -0
- package/.claude/scripts/tag-inbox-v2.py +253 -0
- package/.claude/scripts/test-extraction.py +35 -0
- package/.claude/scripts/test-full-extraction.py +74 -0
- package/.claude/skills/00-SKILL-CREATOR/SKILL.md +186 -0
- package/.claude/skills/01-SKILL-DOCS-MEGABRAIN/SKILL.md +251 -0
- package/.claude/skills/02-SKILL-PYTHON-MEGABRAIN/SKILL.md +323 -0
- package/.claude/skills/03-SKILL-AGENT-CREATION/SKILL.md +374 -0
- package/.claude/skills/04-SKILL-KNOWLEDGE-EXTRACTION/SKILL.md +318 -0
- package/.claude/skills/05-SKILL-PIPELINE-JARVIS/SKILL.md +430 -0
- package/.claude/skills/06-SKILL-BRAINSTORMING/SKILL.md +72 -0
- package/.claude/skills/07-SKILL-DISPATCHING-PARALLEL-AGENTS/SKILL.md +193 -0
- package/.claude/skills/08-SKILL-EXECUTING-PLANS/SKILL.md +114 -0
- package/.claude/skills/09-SKILL-WRITING-PLANS/SKILL.md +184 -0
- package/.claude/skills/10-SKILL-VERIFICATION-BEFORE-COMPLETION/SKILL.md +130 -0
- package/.claude/skills/11-SKILL-USING-SUPERPOWERS/SKILL.md +105 -0
- package/.claude/skills/DETECTION-PROTOCOL.md +217 -0
- package/.claude/skills/README.md +240 -0
- package/.claude/skills/SKILL-REGISTRY.md +284 -0
- package/.claude/skills/SKILL-SUGGESTIONS.md +114 -0
- package/.claude/skills/_TEMPLATES/SKILL-WRITER-GUIDE.md +385 -0
- package/.claude/skills/chronicler/SKILL.md +146 -0
- package/.claude/skills/chronicler/chronicler_core.py +468 -0
- package/.claude/skills/code-review/SKILL.md +160 -0
- package/.claude/skills/council/SKILL.md +210 -0
- package/.claude/skills/executor/SKILL.md +161 -0
- package/.claude/skills/fase-2-5-tagging/SKILL.md +182 -0
- package/.claude/skills/feature-dev/SKILL.md +154 -0
- package/.claude/skills/finance-agent/SKILL.md +137 -0
- package/.claude/skills/frontend-design/SKILL.md +165 -0
- package/.claude/skills/gdrive-transcription-downloader/SKILL.md +249 -0
- package/.claude/skills/gemini-fallback/SKILL.md +67 -0
- package/.claude/skills/gemini-fallback/gemini_fetch.py +0 -0
- package/.claude/skills/gha/SKILL.md +96 -0
- package/.claude/skills/gha/gha_diagnostic.py +227 -0
- package/.claude/skills/github-workflow/SKILL.md +190 -0
- package/.claude/skills/hookify/SKILL.md +134 -0
- package/.claude/skills/hybrid-source-reading/SKILL.md +265 -0
- package/.claude/skills/jarvis/SKILL.md +546 -0
- package/.claude/skills/jarvis-briefing/SKILL.md +340 -0
- package/.claude/skills/ler-planilha/SKILL.md +281 -0
- package/.claude/skills/plugin-dev/SKILL.md +176 -0
- package/.claude/skills/pr-review-toolkit/SKILL.md +178 -0
- package/.claude/skills/resume/SKILL.md +61 -0
- package/.claude/skills/save/SKILL.md +87 -0
- package/.claude/skills/skill-writer/SKILL.md +153 -0
- package/.claude/skills/skill-writer/examples.md +191 -0
- package/.claude/skills/skill-writer/troubleshooting.md +205 -0
- package/.claude/skills/smart-download-tagger/SKILL.md +148 -0
- package/.claude/skills/source-sync/SKILL.md +240 -0
- package/.claude/skills/sync-docs/SKILL.md +193 -0
- package/.claude/skills/sync-docs/config.json +37 -0
- package/.claude/skills/sync-docs/gdrive_sync.py +358 -0
- package/.claude/skills/sync-docs/reauth.py +71 -0
- package/.claude/skills/talent-agent/SKILL.md +183 -0
- package/.claude/skills/verify/SKILL.md +154 -0
- package/.claude/skills/verify/verify_runner.py +0 -0
- package/.claude/skills/verify-6-levels/SKILL.md +234 -0
- package/.claude/templates/BATCH-LOG-TEMPLATE.md +221 -0
- package/.claudeignore +9 -0
- package/.gitattributes +4 -0
- package/.github/layer1-allowlist.txt +80 -0
- package/.github/layer2-manifest.txt +40 -0
- package/.gitignore +219 -0
- package/README.md +1210 -0
- package/agents/_templates/INDEX.md +741 -0
- package/agents/_templates/TEMPLATE-AGENT-MD-ULTRA-ROBUSTO-V3.md +2399 -0
- package/agents/boardroom/CHECKLIST-MASTER.md +281 -0
- package/agents/boardroom/INTEGRATION-GUIDE.md +406 -0
- package/agents/boardroom/README.md +238 -0
- package/agents/boardroom/config/BOARDROOM-CONFIG.md +186 -0
- package/agents/boardroom/config/TTS-INTEGRATION.md +258 -0
- package/agents/boardroom/config/VOICE-PROFILES.md +624 -0
- package/agents/boardroom/config/voice_mapping.json +128 -0
- package/agents/boardroom/scripts/audio_generator.py +375 -0
- package/agents/boardroom/scripts/audio_generator_edge.py +353 -0
- package/agents/boardroom/scripts/jarvis_boardroom_hook.py +415 -0
- package/agents/boardroom/scripts/notebooklm_generator.py +578 -0
- package/agents/boardroom/templates/EPISODE-TEMPLATE.md +367 -0
- package/agents/boardroom/templates/scene-templates/SCENE-AGENT-DEBATE.md +252 -0
- package/agents/boardroom/templates/scene-templates/SCENE-COUNCIL.md +270 -0
- package/agents/boardroom/templates/scene-templates/SCENE-DNA-CONSULTATION.md +126 -0
- package/agents/boardroom/templates/scene-templates/SCENE-QUESTION.md +174 -0
- package/agents/boardroom/workflows/WORKFLOW-AUDIO-GENERATION.md +421 -0
- package/agents/constitution/BASE-CONSTITUTION.md +254 -0
- package/agents/council/CRITIC.md +197 -0
- package/agents/council/DEVILS-ADVOCATE.md +274 -0
- package/agents/council/SYNTHESIZER.md +293 -0
- package/agents/council/advogado-do-diabo/AGENT.md +489 -0
- package/agents/council/advogado-do-diabo/SOUL.md +100 -0
- package/agents/council/critico-metodologico/AGENT.md +670 -0
- package/agents/council/critico-metodologico/SOUL.md +107 -0
- package/agents/council/sintetizador/AGENT.md +558 -0
- package/agents/council/sintetizador/SOUL.md +94 -0
- package/agents/persons/_example/AGENT-EXAMPLE.md +42 -0
- package/agents/persons/_example/DNA-EXAMPLE.yaml +61 -0
- package/agents/protocols/AGENT-COGNITION-PROTOCOL.md +779 -0
- package/agents/protocols/AGENT-INTEGRITY-PROTOCOL.md +692 -0
- package/agents/protocols/BATCH-VISUAL-PROTOCOL.md +841 -0
- package/agents/protocols/DNA-CONFIG-TEMPLATE.yaml +181 -0
- package/agents/protocols/DNA-EXTRACTION-PROTOCOL.md +370 -0
- package/agents/protocols/EPISTEMIC-PROTOCOL.md +333 -0
- package/agents/protocols/LOG-STRUCTURE-PROTOCOL.md +65 -0
- package/agents/protocols/MEMORY-PROTOCOL.md +567 -0
- package/agents/protocols/NARRATIVE-SYNTHESIS-PROTOCOL.md +278 -0
- package/agents/protocols/PHASE-4-VERIFICATION-CHECKPOINT.md +146 -0
- package/agents/protocols/SOUL-TEMPLATE.md +416 -0
- package/agents/protocols/TEMPLATE-EVOLUTION-PROTOCOL.md +544 -0
- package/agents/protocols/VISUAL-DIFF-PROTOCOL.md +159 -0
- package/agents/sua-empresa/README.md +44 -0
- package/agents/sua-empresa/_example/jds/EXAMPLE-JD.md +42 -0
- package/agents/sua-empresa/_example/org/EXAMPLE-ORG.md +32 -0
- package/agents/sua-empresa/_example/roles/EXAMPLE-ROLE.md +38 -0
- package/bin/cli.js +2 -0
- package/bin/lib/ascii-art.js +234 -0
- package/bin/lib/installer.js +402 -0
- package/bin/lib/setup-wizard.js +95 -0
- package/bin/lib/validate-email.js +109 -0
- package/bin/mega-brain.js +97 -0
- package/bin/push.js +342 -0
- package/bin/templates/env.example +38 -0
- package/inbox/.gitkeep +0 -0
- package/integrations/README.md +46 -0
- package/integrations/mcps/MCP-REGISTRY.md +56 -0
- package/integrations/mcps/excalidraw/CONFIG.md +56 -0
- package/integrations/mcps/gdrive/CONFIG.md +38 -0
- package/knowledge/dna/.gitkeep +0 -0
- package/knowledge/dossiers/persons/.gitkeep +0 -0
- package/knowledge/dossiers/persons/DOSSIER-EXAMPLE.md +49 -0
- package/knowledge/dossiers/system/.gitkeep +0 -0
- package/knowledge/dossiers/themes/.gitkeep +0 -0
- package/knowledge/playbooks/.gitkeep +0 -0
- package/knowledge/playbooks/PLAYBOOK-EXAMPLE.md +50 -0
- package/knowledge/sources/.gitkeep +0 -0
- package/logs/.gitkeep +0 -0
- package/package.json +128 -0
- package/processing/canonical/.gitkeep +0 -0
- package/processing/chunks/.gitkeep +0 -0
- package/processing/insights/.gitkeep +0 -0
- package/processing/narratives/.gitkeep +0 -0
- package/reference/CONSELHO.md +337 -0
- package/reference/CONTEXT7_README.md +28 -0
- package/reference/JARVIS-LOGGING-PROTOCOL.md +380 -0
- package/reference/QUICK-START.md +197 -0
- package/reference/README-RALPH-CASCATEAMENTO.md +207 -0
- package/reference/TEMPLATE-MASTER.md +727 -0
- package/reference/prds/prd-jarvis-mega-brain-v3.md +1305 -0
- package/reference/templates/phase5/IMPLEMENTATION-GUIDE.md +355 -0
- package/reference/templates/phase5/MOGA-BRAIN-PHASE5-TEMPLATES.md +1284 -0
- package/reference/templates/phase5/README.md +165 -0
- package/reference/workflow-claude-code-boris-cherny-continuous-claude.md +2232 -0
- package/system/database/001_moneyclub_buyers.sql +160 -0
- package/system/database/002_premium_token.sql +97 -0
- package/system/database/apply-migration.mjs +129 -0
- package/system/docs/MEGA-BRAIN-DEMO-COMPLETA.md +1226 -0
- package/system/docs/MEGA-BRAIN-MANIFESTO-COMPLETO.md +1054 -0
- package/system/docs/MOGA-BRAIN-EXPLICACAO-COMPLETA.md +791 -0
- package/system/docs/STRATEGIC-INTEGRATION-GUIDE.md +725 -0
- package/system/docs/architecture/01-system-context.md +136 -0
- package/system/docs/architecture/02-components.md +225 -0
- package/system/docs/architecture/03-data-flow.md +235 -0
- package/system/docs/architecture/04-integrations.md +283 -0
- package/system/docs/architecture/README.md +71 -0
- package/system/docs/architecture/diagrams/component-diagram.mmd +50 -0
- package/system/docs/architecture/diagrams/data-flow.mmd +39 -0
- package/system/docs/architecture/diagrams/system-overview.mmd +68 -0
- package/system/protocols/AGENT-AUTHORITY.md +217 -0
- package/system/protocols/CONSTITUICAO-BASE.md +115 -0
- package/system/protocols/CONSTITUTION.md +231 -0
- package/system/protocols/GOVERNANCE-MAP.md +123 -0
- package/system/protocols/HOOK-SECURITY-THREAT-MODEL.md +152 -0
- package/system/protocols/ORQUESTRACAO-PROTOCOL.md +215 -0
- package/system/protocols/_archive/CHUNKING-PROTOCOL.md +207 -0
- package/system/protocols/_archive/ENTITY-RESOLUTION-PROTOCOL.md +269 -0
- package/system/protocols/_archive/INSIGHT-EXTRACTION-PROTOCOL.md +257 -0
- package/system/protocols/_archive/NARRATIVE-SYNTHESIS-PROTOCOL.md +290 -0
- package/system/protocols/agents/AGENT-INTERACTION.md +315 -0
- package/system/protocols/agents/CORTEX-PROTOCOL.md +520 -0
- package/system/protocols/agents/EPISTEMIC-PROTOCOL.md +465 -0
- package/system/protocols/agents/MEMORY-PROTOCOL.md +366 -0
- package/system/protocols/agents/WAR-ROOM.md +355 -0
- package/system/protocols/company/COMPANY-DOCUMENT-PROTOCOL.md +793 -0
- package/system/protocols/company/COMPANY-ENRICHMENT-PROTOCOL.md +679 -0
- package/system/protocols/conclave/CONCLAVE-LOG-TEMPLATE-v2.md +309 -0
- package/system/protocols/conclave/CONCLAVE-PROTOCOL.md +518 -0
- package/system/protocols/conclave/DEBATE-DYNAMICS-CONFIG.yaml +322 -0
- package/system/protocols/conclave/DEBATE-DYNAMICS-PROTOCOL.md +613 -0
- package/system/protocols/conclave/DEBATE-PROTOCOL.md +323 -0
- package/system/protocols/council/COUNCIL-LOG-TEMPLATE-v2.md +309 -0
- package/system/protocols/council/COUNCIL-PROTOCOL.md +518 -0
- package/system/protocols/council/DEBATE-DYNAMICS-CONFIG.yaml +322 -0
- package/system/protocols/council/DEBATE-DYNAMICS-PROTOCOL.md +613 -0
- package/system/protocols/council/DEBATE-PROTOCOL.md +323 -0
- package/system/protocols/dna/DNA-EXTRACTION-PROTOCOL.md +1214 -0
- package/system/protocols/dna/ENRICHMENT-PROTOCOL.md +408 -0
- package/system/protocols/dna/REASONING-MODEL-PROTOCOL.md +331 -0
- package/system/protocols/pipeline/DOSSIER-COMPILATION-PROTOCOL.md +790 -0
- package/system/protocols/pipeline/NARRATIVE-METABOLISM-PROTOCOL.md +292 -0
- package/system/protocols/pipeline/PIPELINE-JARVIS-v2.1.md +606 -0
- package/system/protocols/pipeline/PROMPT-1.1-CHUNKING.md +154 -0
- package/system/protocols/pipeline/PROMPT-1.2-ENTITY-RESOLUTION.md +186 -0
- package/system/protocols/pipeline/PROMPT-2.1-DNA-TAGS-INCREMENT.md +208 -0
- package/system/protocols/pipeline/PROMPT-2.1-INSIGHT-EXTRACTION.md +191 -0
- package/system/protocols/pipeline/PROMPT-3.1-NARRATIVE-SYNTHESIS.md +331 -0
- package/system/protocols/pipeline/SOURCES-COMPILATION-PROTOCOL.md +340 -0
- package/system/protocols/system/AUTO-LOG-PROTOCOL.md +369 -0
- package/system/protocols/system/CHECKPOINT-ENFORCEMENT.md +176 -0
- package/system/protocols/system/ENFORCEMENT.md +435 -0
- package/system/protocols/system/LOG-TEMPLATES.md +1068 -0
|
@@ -0,0 +1,301 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
LEDGER UPDATER HOOK
|
|
4
|
+
===================
|
|
5
|
+
Atualiza o LEDGER.md automaticamente em pontos chave.
|
|
6
|
+
|
|
7
|
+
Baseado no Continuous Claude: Context persistence via ledgers
|
|
8
|
+
|
|
9
|
+
Triggers:
|
|
10
|
+
- SessionEnd: Salva estado final
|
|
11
|
+
- Após completar tarefa significativa
|
|
12
|
+
- Antes de parar
|
|
13
|
+
|
|
14
|
+
Usage:
|
|
15
|
+
python3 ledger_updater.py [action] [details]
|
|
16
|
+
|
|
17
|
+
Actions:
|
|
18
|
+
- complete_task: Marca tarefa como completada
|
|
19
|
+
- add_blocker: Adiciona bloqueio
|
|
20
|
+
- set_next_action: Define próxima ação
|
|
21
|
+
- update_status: Atualiza status geral
|
|
22
|
+
- session_end: Finaliza sessão
|
|
23
|
+
"""
|
|
24
|
+
|
|
25
|
+
import sys
|
|
26
|
+
import os
|
|
27
|
+
import json
|
|
28
|
+
import re
|
|
29
|
+
from pathlib import Path
|
|
30
|
+
from datetime import datetime
|
|
31
|
+
|
|
32
|
+
PROJECT_ROOT = Path(os.environ.get('CLAUDE_PROJECT_DIR', '.'))
|
|
33
|
+
LEDGER_PATH = PROJECT_ROOT / ".claude" / "LEDGER.md"
|
|
34
|
+
MISSION_STATE_PATH = (
|
|
35
|
+
PROJECT_ROOT / ".claude" / "mission-control" / "MISSION-STATE.json"
|
|
36
|
+
)
|
|
37
|
+
INBOX_PATH = PROJECT_ROOT / "inbox"
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def count_inbox_files() -> int:
|
|
41
|
+
"""Count files in INBOX"""
|
|
42
|
+
if not INBOX_PATH.exists():
|
|
43
|
+
return 0
|
|
44
|
+
|
|
45
|
+
count = 0
|
|
46
|
+
exclude = ["_DUPLICATAS", "_BACKUP", ".DS_Store", "_INDEX"]
|
|
47
|
+
|
|
48
|
+
for item in INBOX_PATH.rglob("*"):
|
|
49
|
+
if item.is_file() and not any(e in str(item) for e in exclude):
|
|
50
|
+
if item.suffix.lower() in [".txt", ".md", ".docx", ".pdf"]:
|
|
51
|
+
count += 1
|
|
52
|
+
return count
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
def get_mission_state() -> dict:
|
|
56
|
+
"""Get current mission state"""
|
|
57
|
+
if not MISSION_STATE_PATH.exists():
|
|
58
|
+
return {}
|
|
59
|
+
try:
|
|
60
|
+
with open(MISSION_STATE_PATH, "r", encoding="utf-8") as f:
|
|
61
|
+
return json.load(f)
|
|
62
|
+
except:
|
|
63
|
+
return {}
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
def read_ledger() -> str:
|
|
67
|
+
"""Read current ledger content"""
|
|
68
|
+
if not LEDGER_PATH.exists():
|
|
69
|
+
return ""
|
|
70
|
+
return LEDGER_PATH.read_text(encoding="utf-8")
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
def write_ledger(content: str):
|
|
74
|
+
"""Write ledger content"""
|
|
75
|
+
LEDGER_PATH.write_text(content, encoding="utf-8")
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
def update_timestamp(content: str) -> str:
|
|
79
|
+
"""Update the timestamp in ledger"""
|
|
80
|
+
now = datetime.now().isoformat()
|
|
81
|
+
|
|
82
|
+
# Update timestamp line
|
|
83
|
+
pattern = r"\*\*Timestamp:\*\* .+"
|
|
84
|
+
replacement = f"**Timestamp:** {now}"
|
|
85
|
+
content = re.sub(pattern, replacement, content)
|
|
86
|
+
|
|
87
|
+
return content
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
def update_inbox_status(content: str) -> str:
|
|
91
|
+
"""Update INBOX status in ledger"""
|
|
92
|
+
inbox_count = count_inbox_files()
|
|
93
|
+
now = datetime.now().strftime("%Y-%m-%d %H:%M")
|
|
94
|
+
|
|
95
|
+
# Find and update INBOX table
|
|
96
|
+
# Pattern for "Arquivos pendentes" row
|
|
97
|
+
pattern = r"\| \*\*Arquivos pendentes\*\* \| .+ \|"
|
|
98
|
+
replacement = f"| **Arquivos pendentes** | {inbox_count} |"
|
|
99
|
+
content = re.sub(pattern, replacement, content)
|
|
100
|
+
|
|
101
|
+
# Update last scan
|
|
102
|
+
pattern = r"\| \*\*Última varredura\*\* \| .+ \|"
|
|
103
|
+
replacement = f"| **Última varredura** | {now} |"
|
|
104
|
+
content = re.sub(pattern, replacement, content)
|
|
105
|
+
|
|
106
|
+
return content
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
def update_mission_status(content: str) -> str:
|
|
110
|
+
"""Update mission status from MISSION-STATE.json"""
|
|
111
|
+
state = get_mission_state()
|
|
112
|
+
|
|
113
|
+
if not state:
|
|
114
|
+
return content
|
|
115
|
+
|
|
116
|
+
current = state.get("current_state", {})
|
|
117
|
+
|
|
118
|
+
# Update mission ID
|
|
119
|
+
mission_id = current.get("mission_id", state.get("mission_id", "-"))
|
|
120
|
+
pattern = r"\| \*\*ID\*\* \| .+ \|"
|
|
121
|
+
replacement = f"| **ID** | {mission_id} |"
|
|
122
|
+
content = re.sub(pattern, replacement, content)
|
|
123
|
+
|
|
124
|
+
# Update phase
|
|
125
|
+
phase = current.get("phase", "-")
|
|
126
|
+
phase_name = current.get("phase_name", "")
|
|
127
|
+
pattern = r"\| \*\*Fase\*\* \| .+ \|"
|
|
128
|
+
replacement = f"| **Fase** | {phase} ({phase_name}) |"
|
|
129
|
+
content = re.sub(pattern, replacement, content)
|
|
130
|
+
|
|
131
|
+
# Update status
|
|
132
|
+
status = current.get("status", "-")
|
|
133
|
+
pattern = r"\| \*\*Status\*\* \| .+ \|"
|
|
134
|
+
replacement = f"| **Status** | {status} |"
|
|
135
|
+
content = re.sub(pattern, replacement, content)
|
|
136
|
+
|
|
137
|
+
# Update batch info if available
|
|
138
|
+
batch_current = current.get("batch_current", "-")
|
|
139
|
+
batch_total = current.get("batch_total", "-")
|
|
140
|
+
percent = current.get("percent_complete", "-")
|
|
141
|
+
|
|
142
|
+
pattern = r"\| \*\*Batch atual\*\* \| .+ \|"
|
|
143
|
+
content = re.sub(pattern, f"| **Batch atual** | {batch_current} |", content)
|
|
144
|
+
|
|
145
|
+
pattern = r"\| \*\*Batch total\*\* \| .+ \|"
|
|
146
|
+
content = re.sub(pattern, f"| **Batch total** | {batch_total} |", content)
|
|
147
|
+
|
|
148
|
+
pattern = r"\| \*\*Progresso\*\* \| .+ \|"
|
|
149
|
+
content = re.sub(pattern, f"| **Progresso** | {percent}% |", content)
|
|
150
|
+
|
|
151
|
+
return content
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
def add_completed_task(content: str, task: str) -> str:
|
|
155
|
+
"""Add a completed task to the ledger"""
|
|
156
|
+
now = datetime.now().strftime("%H:%M")
|
|
157
|
+
task_line = f"- [x] [{now}] {task}"
|
|
158
|
+
|
|
159
|
+
# Find the completed tasks section and add
|
|
160
|
+
marker = "## ✅ Tarefas Completadas"
|
|
161
|
+
if marker in content:
|
|
162
|
+
# Find the next section
|
|
163
|
+
parts = content.split(marker)
|
|
164
|
+
if len(parts) >= 2:
|
|
165
|
+
# Find where to insert (after the header)
|
|
166
|
+
section = parts[1]
|
|
167
|
+
lines = section.split("\n")
|
|
168
|
+
|
|
169
|
+
# Find first empty checkbox or "Nenhuma tarefa"
|
|
170
|
+
insert_idx = None
|
|
171
|
+
for i, line in enumerate(lines):
|
|
172
|
+
if "(Nenhuma tarefa" in line:
|
|
173
|
+
lines[i] = task_line
|
|
174
|
+
insert_idx = -1 # Signal we replaced
|
|
175
|
+
break
|
|
176
|
+
elif line.strip().startswith("- ["):
|
|
177
|
+
insert_idx = i + 1
|
|
178
|
+
|
|
179
|
+
if insert_idx is None:
|
|
180
|
+
# Add after section header
|
|
181
|
+
for i, line in enumerate(lines):
|
|
182
|
+
if line.strip() == "" and i > 0:
|
|
183
|
+
lines.insert(i, task_line)
|
|
184
|
+
break
|
|
185
|
+
elif insert_idx > 0:
|
|
186
|
+
lines.insert(insert_idx, task_line)
|
|
187
|
+
|
|
188
|
+
parts[1] = "\n".join(lines)
|
|
189
|
+
content = marker.join(parts)
|
|
190
|
+
|
|
191
|
+
return content
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
def add_blocker(content: str, blocker: str) -> str:
|
|
195
|
+
"""Add a blocker to the ledger"""
|
|
196
|
+
now = datetime.now().strftime("%H:%M")
|
|
197
|
+
blocker_line = f"- [{now}] {blocker}"
|
|
198
|
+
|
|
199
|
+
marker = "## ⚠️ Bloqueios Encontrados"
|
|
200
|
+
if marker in content:
|
|
201
|
+
# Remove "(Nenhum bloqueio registrado)" if present
|
|
202
|
+
content = content.replace("- (Nenhum bloqueio registrado)", blocker_line)
|
|
203
|
+
|
|
204
|
+
return content
|
|
205
|
+
|
|
206
|
+
|
|
207
|
+
def set_next_action(content: str, action: str, priority: str = "Alta") -> str:
|
|
208
|
+
"""Set the next action"""
|
|
209
|
+
pattern = r"AÇÃO: .+"
|
|
210
|
+
replacement = f"AÇÃO: {action}"
|
|
211
|
+
content = re.sub(pattern, replacement, content)
|
|
212
|
+
|
|
213
|
+
pattern = r"PRIORIDADE: .+"
|
|
214
|
+
replacement = f"PRIORIDADE: {priority}"
|
|
215
|
+
content = re.sub(pattern, replacement, content)
|
|
216
|
+
|
|
217
|
+
return content
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+
def add_iteration(content: str, duration: str, tasks: str, status: str) -> str:
|
|
221
|
+
"""Add iteration to history"""
|
|
222
|
+
now = datetime.now().strftime("%Y-%m-%d")
|
|
223
|
+
|
|
224
|
+
# Find the history table
|
|
225
|
+
marker = "## 📊 Histórico de Iterações"
|
|
226
|
+
if marker in content:
|
|
227
|
+
parts = content.split(marker)
|
|
228
|
+
if len(parts) >= 2:
|
|
229
|
+
# Find last row number
|
|
230
|
+
matches = re.findall(r"\| (\d+) \|", parts[1])
|
|
231
|
+
last_num = int(matches[-1]) if matches else 0
|
|
232
|
+
new_num = last_num + 1
|
|
233
|
+
|
|
234
|
+
# Add new row before the closing
|
|
235
|
+
new_row = f"| {new_num} | {now} | {duration} | {tasks} | {status} |"
|
|
236
|
+
|
|
237
|
+
# Find where to insert
|
|
238
|
+
lines = parts[1].split("\n")
|
|
239
|
+
for i, line in enumerate(lines):
|
|
240
|
+
if line.strip().startswith("---") and i > 5:
|
|
241
|
+
lines.insert(i, new_row)
|
|
242
|
+
break
|
|
243
|
+
|
|
244
|
+
parts[1] = "\n".join(lines)
|
|
245
|
+
content = marker.join(parts)
|
|
246
|
+
|
|
247
|
+
return content
|
|
248
|
+
|
|
249
|
+
|
|
250
|
+
def main():
|
|
251
|
+
try:
|
|
252
|
+
if len(sys.argv) < 2:
|
|
253
|
+
# Default: update all status
|
|
254
|
+
action = "update_status"
|
|
255
|
+
else:
|
|
256
|
+
action = sys.argv[1]
|
|
257
|
+
|
|
258
|
+
details = sys.argv[2] if len(sys.argv) > 2 else ""
|
|
259
|
+
|
|
260
|
+
# Read current ledger
|
|
261
|
+
content = read_ledger()
|
|
262
|
+
|
|
263
|
+
if not content:
|
|
264
|
+
print("Ledger not found - skipping update")
|
|
265
|
+
sys.exit(0) # Não bloquear se ledger não existe
|
|
266
|
+
|
|
267
|
+
# Always update timestamp and status
|
|
268
|
+
content = update_timestamp(content)
|
|
269
|
+
content = update_inbox_status(content)
|
|
270
|
+
content = update_mission_status(content)
|
|
271
|
+
|
|
272
|
+
# Handle specific action
|
|
273
|
+
if action == "complete_task" and details:
|
|
274
|
+
content = add_completed_task(content, details)
|
|
275
|
+
print(f"✅ Task marked complete: {details}")
|
|
276
|
+
|
|
277
|
+
elif action == "add_blocker" and details:
|
|
278
|
+
content = add_blocker(content, details)
|
|
279
|
+
print(f"⚠️ Blocker added: {details}")
|
|
280
|
+
|
|
281
|
+
elif action == "set_next_action" and details:
|
|
282
|
+
content = set_next_action(content, details)
|
|
283
|
+
print(f"🎯 Next action set: {details}")
|
|
284
|
+
|
|
285
|
+
elif action == "session_end":
|
|
286
|
+
# Add iteration to history
|
|
287
|
+
content = add_iteration(content, "-", "Session ended", "✅")
|
|
288
|
+
print("📝 Session recorded in ledger")
|
|
289
|
+
|
|
290
|
+
# Write updated ledger
|
|
291
|
+
write_ledger(content)
|
|
292
|
+
|
|
293
|
+
except Exception as e:
|
|
294
|
+
# NUNCA bloquear operações do Claude Code por erro no ledger
|
|
295
|
+
sys.stderr.write(f"[LEDGER_UPDATER] Erro: {e}\n")
|
|
296
|
+
|
|
297
|
+
sys.exit(0)
|
|
298
|
+
|
|
299
|
+
|
|
300
|
+
if __name__ == "__main__":
|
|
301
|
+
main()
|
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
Memory Hints Injector v1.0 (Mega Brain) - Bracket-Aware Agent Memory Enhancement
|
|
4
|
+
|
|
5
|
+
Implements MIS (Memory Integration System) for bracket-aware memory injection
|
|
6
|
+
that adapts to context window usage.
|
|
7
|
+
|
|
8
|
+
Adapted from: aios-core/.claude/hooks/memory_hints_injector.py
|
|
9
|
+
|
|
10
|
+
BRACKETS:
|
|
11
|
+
FRESH (60-100% context remaining) -> No extra memory needed
|
|
12
|
+
MODERATE (40-60%) -> Brief memory reminder (~50 tokens)
|
|
13
|
+
DEPLETED (25-40%) -> Extended memory reinforcement (~200 tokens)
|
|
14
|
+
CRITICAL (0-25%) -> Full memory + handoff warning (~1000 tokens)
|
|
15
|
+
|
|
16
|
+
INTEGRATION:
|
|
17
|
+
- Runs at UserPromptSubmit, AFTER skill_router.py
|
|
18
|
+
- Tracks prompt_count in STATE.json (mis.prompt_count)
|
|
19
|
+
- Reads from .claude/agent-memory/ (our existing data store)
|
|
20
|
+
- Returns feedback with memory hints when bracket warrants it
|
|
21
|
+
|
|
22
|
+
FAIL-OPEN: Never blocks user input. Returns {"continue": true} on any error.
|
|
23
|
+
|
|
24
|
+
Hook Type: UserPromptSubmit
|
|
25
|
+
"""
|
|
26
|
+
|
|
27
|
+
import json
|
|
28
|
+
import sys
|
|
29
|
+
import os
|
|
30
|
+
import time
|
|
31
|
+
from pathlib import Path
|
|
32
|
+
|
|
33
|
+
PROJECT_ROOT = Path(os.environ.get('CLAUDE_PROJECT_DIR', '.'))
|
|
34
|
+
STATE_DIR = PROJECT_ROOT / ".claude" / "jarvis"
|
|
35
|
+
STATE_FILE = STATE_DIR / "STATE.json"
|
|
36
|
+
AGENT_MEMORY_DIR = PROJECT_ROOT / ".claude" / "agent-memory"
|
|
37
|
+
|
|
38
|
+
# Context Brackets
|
|
39
|
+
BRACKET_LAYER_MAP = {
|
|
40
|
+
"FRESH": {"layer": 0, "max_tokens": 0, "max_lines": 0},
|
|
41
|
+
"MODERATE": {"layer": 1, "max_tokens": 50, "max_lines": 5},
|
|
42
|
+
"DEPLETED": {"layer": 2, "max_tokens": 200, "max_lines": 20},
|
|
43
|
+
"CRITICAL": {"layer": 3, "max_tokens": 1000, "max_lines": 50},
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
DEFAULTS = {
|
|
47
|
+
"avg_tokens_per_prompt": 1500,
|
|
48
|
+
"max_context": 200000,
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
INTERNAL_TIMEOUT_MS = 80
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def calculate_bracket(context_percent):
|
|
55
|
+
"""Calculate context bracket from remaining context percentage."""
|
|
56
|
+
if not isinstance(context_percent, (int, float)):
|
|
57
|
+
return "CRITICAL"
|
|
58
|
+
if context_percent >= 60:
|
|
59
|
+
return "FRESH"
|
|
60
|
+
if context_percent >= 40:
|
|
61
|
+
return "MODERATE"
|
|
62
|
+
if context_percent >= 25:
|
|
63
|
+
return "DEPLETED"
|
|
64
|
+
return "CRITICAL"
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
def estimate_context_percent(prompt_count, avg_tokens=None, max_context=None):
|
|
68
|
+
"""Estimate percentage of context remaining based on prompt count."""
|
|
69
|
+
avg = avg_tokens or DEFAULTS["avg_tokens_per_prompt"]
|
|
70
|
+
mx = max_context or DEFAULTS["max_context"]
|
|
71
|
+
|
|
72
|
+
if not isinstance(prompt_count, (int, float)) or prompt_count < 0:
|
|
73
|
+
return 100
|
|
74
|
+
if mx <= 0:
|
|
75
|
+
return 0
|
|
76
|
+
|
|
77
|
+
used = prompt_count * avg
|
|
78
|
+
percent = 100 - (used / mx * 100)
|
|
79
|
+
return max(0.0, min(100.0, percent))
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
def load_state():
|
|
83
|
+
"""Load STATE.json safely."""
|
|
84
|
+
if not STATE_FILE.exists():
|
|
85
|
+
return {}
|
|
86
|
+
try:
|
|
87
|
+
with open(STATE_FILE, "r", encoding="utf-8") as f:
|
|
88
|
+
return json.load(f)
|
|
89
|
+
except (json.JSONDecodeError, IOError):
|
|
90
|
+
return {}
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
def save_state(state):
|
|
94
|
+
"""Save STATE.json safely."""
|
|
95
|
+
try:
|
|
96
|
+
STATE_DIR.mkdir(parents=True, exist_ok=True)
|
|
97
|
+
with open(STATE_FILE, "w", encoding="utf-8") as f:
|
|
98
|
+
json.dump(state, f, indent=2, ensure_ascii=False)
|
|
99
|
+
except Exception:
|
|
100
|
+
pass
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
def get_active_agent(state):
|
|
104
|
+
"""Get active agent slug from state."""
|
|
105
|
+
session = state.get("session", {})
|
|
106
|
+
agent = session.get("agent_active")
|
|
107
|
+
if agent and isinstance(agent, str) and agent.strip():
|
|
108
|
+
return agent.strip()
|
|
109
|
+
return None
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
def estimate_tokens(text):
|
|
113
|
+
"""Rough token estimation (~4 chars per token)."""
|
|
114
|
+
if not text:
|
|
115
|
+
return 0
|
|
116
|
+
return max(1, len(text) // 4)
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
def read_agent_memory_hints(agent_slug, max_lines, max_tokens):
|
|
120
|
+
"""
|
|
121
|
+
Read memory hints from agent's MEMORY.md, respecting token budget.
|
|
122
|
+
Reads from the END of the file (most recent entries) working backwards.
|
|
123
|
+
"""
|
|
124
|
+
memory_path = AGENT_MEMORY_DIR / agent_slug / "MEMORY.md"
|
|
125
|
+
if not memory_path.exists():
|
|
126
|
+
return ""
|
|
127
|
+
|
|
128
|
+
try:
|
|
129
|
+
content = memory_path.read_text(encoding="utf-8")
|
|
130
|
+
except Exception:
|
|
131
|
+
return ""
|
|
132
|
+
|
|
133
|
+
lines = content.split("\n")
|
|
134
|
+
if len(lines) < 10:
|
|
135
|
+
return ""
|
|
136
|
+
|
|
137
|
+
useful_lines = []
|
|
138
|
+
tokens_used = 0
|
|
139
|
+
|
|
140
|
+
for line in reversed(lines):
|
|
141
|
+
stripped = line.strip()
|
|
142
|
+
|
|
143
|
+
if not stripped:
|
|
144
|
+
if useful_lines:
|
|
145
|
+
useful_lines.insert(0, "")
|
|
146
|
+
continue
|
|
147
|
+
|
|
148
|
+
if stripped.startswith("# ") and len(useful_lines) == 0:
|
|
149
|
+
continue
|
|
150
|
+
if stripped.startswith("> ") and len(useful_lines) == 0:
|
|
151
|
+
continue
|
|
152
|
+
|
|
153
|
+
line_tokens = estimate_tokens(stripped)
|
|
154
|
+
|
|
155
|
+
if tokens_used + line_tokens > max_tokens:
|
|
156
|
+
break
|
|
157
|
+
if len(useful_lines) >= max_lines:
|
|
158
|
+
break
|
|
159
|
+
|
|
160
|
+
useful_lines.insert(0, line)
|
|
161
|
+
tokens_used += line_tokens
|
|
162
|
+
|
|
163
|
+
result = "\n".join(useful_lines).strip()
|
|
164
|
+
|
|
165
|
+
while result.startswith("---"):
|
|
166
|
+
result = result[3:].strip()
|
|
167
|
+
|
|
168
|
+
return result
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
def main():
|
|
172
|
+
"""Main hook execution."""
|
|
173
|
+
start_time = time.time()
|
|
174
|
+
|
|
175
|
+
try:
|
|
176
|
+
input_data = sys.stdin.read()
|
|
177
|
+
|
|
178
|
+
state = load_state()
|
|
179
|
+
if not state:
|
|
180
|
+
print(json.dumps({"continue": True}))
|
|
181
|
+
return
|
|
182
|
+
|
|
183
|
+
# MIS Prompt Counter
|
|
184
|
+
session_id = state.get("session_id", "")
|
|
185
|
+
mis = state.setdefault("mis", {})
|
|
186
|
+
|
|
187
|
+
if mis.get("session_id") != session_id:
|
|
188
|
+
mis["session_id"] = session_id
|
|
189
|
+
mis["prompt_count"] = 0
|
|
190
|
+
|
|
191
|
+
prompt_count = mis.get("prompt_count", 0) + 1
|
|
192
|
+
mis["prompt_count"] = prompt_count
|
|
193
|
+
|
|
194
|
+
# Calculate Bracket
|
|
195
|
+
context_percent = estimate_context_percent(prompt_count)
|
|
196
|
+
bracket = calculate_bracket(context_percent)
|
|
197
|
+
mis["bracket"] = bracket
|
|
198
|
+
mis["context_percent"] = round(context_percent, 1)
|
|
199
|
+
|
|
200
|
+
save_state(state)
|
|
201
|
+
|
|
202
|
+
# Check if memory hints needed
|
|
203
|
+
layer_config = BRACKET_LAYER_MAP.get(bracket, BRACKET_LAYER_MAP["FRESH"])
|
|
204
|
+
max_tokens = layer_config["max_tokens"]
|
|
205
|
+
max_lines = layer_config["max_lines"]
|
|
206
|
+
|
|
207
|
+
if max_tokens <= 0:
|
|
208
|
+
print(json.dumps({"continue": True}))
|
|
209
|
+
return
|
|
210
|
+
|
|
211
|
+
# Timeout check
|
|
212
|
+
elapsed_ms = (time.time() - start_time) * 1000
|
|
213
|
+
if elapsed_ms > INTERNAL_TIMEOUT_MS * 0.5:
|
|
214
|
+
print(json.dumps({"continue": True}))
|
|
215
|
+
return
|
|
216
|
+
|
|
217
|
+
# Get active agent
|
|
218
|
+
raw_slug = get_active_agent(state)
|
|
219
|
+
if not raw_slug:
|
|
220
|
+
print(json.dumps({"continue": True}))
|
|
221
|
+
return
|
|
222
|
+
|
|
223
|
+
agent_slug = raw_slug
|
|
224
|
+
|
|
225
|
+
# Read memory hints
|
|
226
|
+
hints = read_agent_memory_hints(agent_slug, max_lines, max_tokens)
|
|
227
|
+
|
|
228
|
+
# Final timeout check
|
|
229
|
+
elapsed_ms = (time.time() - start_time) * 1000
|
|
230
|
+
if elapsed_ms > INTERNAL_TIMEOUT_MS:
|
|
231
|
+
print(json.dumps({"continue": True}))
|
|
232
|
+
return
|
|
233
|
+
|
|
234
|
+
# Return feedback
|
|
235
|
+
if hints:
|
|
236
|
+
if bracket == "CRITICAL":
|
|
237
|
+
prefix = f"[MIS:{bracket}] Context at {round(context_percent)}%. Memory reinforcement for @{agent_slug}:"
|
|
238
|
+
else:
|
|
239
|
+
prefix = f"[MIS:{bracket}] @{agent_slug} memory:"
|
|
240
|
+
|
|
241
|
+
feedback = f"{prefix}\n{hints}"
|
|
242
|
+
print(json.dumps({"continue": True, "feedback": feedback}))
|
|
243
|
+
else:
|
|
244
|
+
print(json.dumps({"continue": True}))
|
|
245
|
+
|
|
246
|
+
except Exception:
|
|
247
|
+
print(json.dumps({"continue": True}))
|
|
248
|
+
|
|
249
|
+
|
|
250
|
+
if __name__ == "__main__":
|
|
251
|
+
main()
|