@mamdouh-aboammar/agentic-workflow 1.2.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.
Files changed (118) hide show
  1. package/.claude-plugin/plugin.json +10 -0
  2. package/.codex-plugin/plugin.json +13 -0
  3. package/.skills.json +19 -0
  4. package/AGENTS.md +1344 -0
  5. package/CLAUDE.md +178 -0
  6. package/GEMINI.md +102 -0
  7. package/LICENSE +21 -0
  8. package/README.md +350 -0
  9. package/SKILL.md +132 -0
  10. package/bin/agentic-hooks.sh +79 -0
  11. package/bin/cli.js +1060 -0
  12. package/core/__init__.py +52 -0
  13. package/core/ai_evaluator.py +117 -0
  14. package/core/autopilot_engine.py +368 -0
  15. package/core/clean_code_guard.py +188 -0
  16. package/core/engine_py/__init__.py +29 -0
  17. package/core/engine_py/agent_worker.py +136 -0
  18. package/core/engine_py/decider.py +150 -0
  19. package/core/engine_py/energy.py +45 -0
  20. package/core/engine_py/event_bus.py +63 -0
  21. package/core/engine_py/executor.py +186 -0
  22. package/core/engine_py/models.py +193 -0
  23. package/core/engine_py/queue.py +314 -0
  24. package/core/engine_py/runner.py +116 -0
  25. package/core/engine_py/system_workers.py +70 -0
  26. package/core/engine_py/toon_adapter.py +586 -0
  27. package/core/engine_py/verification_controller.py +208 -0
  28. package/core/engine_py/worker.py +167 -0
  29. package/core/engine_spec/event_schema.json +65 -0
  30. package/core/engine_spec/example_workflow.yaml +73 -0
  31. package/core/engine_spec/workflow_schema.json +127 -0
  32. package/core/hooks/__init__.py +29 -0
  33. package/core/hooks/adapters/__init__.py +25 -0
  34. package/core/hooks/adapters/claude_adapter.py +83 -0
  35. package/core/hooks/adapters/cli_agent_adapter.py +82 -0
  36. package/core/hooks/adapters/codex_adapter.py +78 -0
  37. package/core/hooks/adapters/cursor_adapter.py +73 -0
  38. package/core/hooks/adapters/gemini_adapter.py +93 -0
  39. package/core/hooks/adapters/homebrew_adapter.py +69 -0
  40. package/core/hooks/adapters/mcp_proxy.py +133 -0
  41. package/core/hooks/adapters/shell_adapter.py +65 -0
  42. package/core/hooks/dispatcher.py +118 -0
  43. package/core/hooks/policy_engine.py +375 -0
  44. package/core/hooks/session_end.py +141 -0
  45. package/core/hooks/types.py +147 -0
  46. package/core/integrations/__init__.py +28 -0
  47. package/core/integrations/installer.py +225 -0
  48. package/core/integrations/lifecycle_director.py +175 -0
  49. package/core/integrations/registry.py +105 -0
  50. package/core/multi_agent_system.py +164 -0
  51. package/core/skills_indexer.py +742 -0
  52. package/core/system/__init__.py +25 -0
  53. package/core/system/announcements.py +72 -0
  54. package/core/system/dependencies.py +69 -0
  55. package/core/system/doctor.py +171 -0
  56. package/core/system/health.py +144 -0
  57. package/core/system/installer.py +137 -0
  58. package/core/system/notifications.py +97 -0
  59. package/core/system/refresher.py +110 -0
  60. package/core/system/updater.py +167 -0
  61. package/core/system/version_tracker.py +65 -0
  62. package/docs/architecture_plan.md +7 -0
  63. package/docs/guides/failure-recovery.md +714 -0
  64. package/docs/implementation_summary.md +10 -0
  65. package/docs/protocols/autopilot-execution.md +148 -0
  66. package/docs/protocols/code-change-protocol.md +49 -0
  67. package/docs/protocols/context-preservation-detail.md +114 -0
  68. package/docs/protocols/quality-gates.md +110 -0
  69. package/docs/protocols/ulw-mode.md +60 -0
  70. package/docs/research_findings.md +10 -0
  71. package/docs/solutions/autonomous-autopilot-engine-architecture.md +38 -0
  72. package/install.sh +111 -0
  73. package/marketplace.json +37 -0
  74. package/package.json +81 -0
  75. package/skills/agentic-workflow/SKILL.md +132 -0
  76. package/skills/agentic-workflow/skill-spec.json +100 -0
  77. package/soul.md +445 -0
  78. package/src/engine_ts/decider.ts +186 -0
  79. package/src/engine_ts/event-bus.ts +57 -0
  80. package/src/engine_ts/executor.ts +262 -0
  81. package/src/engine_ts/index.ts +12 -0
  82. package/src/engine_ts/queue.ts +93 -0
  83. package/src/engine_ts/runner.ts +108 -0
  84. package/src/engine_ts/skills-indexer.ts +264 -0
  85. package/src/engine_ts/toon-adapter.ts +91 -0
  86. package/src/engine_ts/types.ts +134 -0
  87. package/src/engine_ts/verification-controller.ts +204 -0
  88. package/src/engine_ts/worker.ts +280 -0
  89. package/src/hooks/adapters/claude-adapter.ts +54 -0
  90. package/src/hooks/adapters/cli-agent-adapter.ts +46 -0
  91. package/src/hooks/adapters/codex-adapter.ts +69 -0
  92. package/src/hooks/adapters/cursor-adapter.ts +60 -0
  93. package/src/hooks/adapters/gemini-adapter.ts +71 -0
  94. package/src/hooks/adapters/homebrew-adapter.ts +36 -0
  95. package/src/hooks/adapters/mcp-proxy.ts +66 -0
  96. package/src/hooks/adapters/shell-adapter.ts +42 -0
  97. package/src/hooks/dispatcher.ts +113 -0
  98. package/src/hooks/index.ts +16 -0
  99. package/src/hooks/policy-engine.ts +376 -0
  100. package/src/hooks/session-end.ts +125 -0
  101. package/src/hooks/types.ts +61 -0
  102. package/src/index.d.ts +34 -0
  103. package/src/index.ts +23 -0
  104. package/src/integrations/index.ts +7 -0
  105. package/src/integrations/installer.ts +208 -0
  106. package/src/integrations/lifecycle-director.ts +139 -0
  107. package/src/integrations/registry.ts +82 -0
  108. package/src/system/announcements.ts +143 -0
  109. package/src/system/dependencies.ts +176 -0
  110. package/src/system/doctor.ts +374 -0
  111. package/src/system/health.ts +270 -0
  112. package/src/system/index.ts +14 -0
  113. package/src/system/installer.ts +262 -0
  114. package/src/system/notifications.ts +180 -0
  115. package/src/system/refresher.ts +207 -0
  116. package/src/system/types.ts +268 -0
  117. package/src/system/updater.ts +219 -0
  118. package/src/system/version-tracker.ts +137 -0
package/SKILL.md ADDED
@@ -0,0 +1,132 @@
1
+ ---
2
+ name: agentic-workflow
3
+ description: >
4
+ Pluripotent stem-cell framework and universal agentic toolchain for autonomous
5
+ workflows. Use when designing, building, orchestrating, validating, or optimizing
6
+ complex multi-step AI agent workflows across Research, Planning, and Implementation —
7
+ even if the user says "build an autonomous pipeline", "design agent workflow",
8
+ "execute in autopilot", "run ulw mode", or "setup quality gates". Do NOT use for
9
+ simple single-file one-off edits without workflow structure.
10
+ ---
11
+
12
+ # AgenticWorkflow: Universal Agentic Skill & Execution Toolchain
13
+
14
+ A pluripotent stem-cell framework and multi-agent execution engine that turns complex tasks into deterministic, self-verifying autonomous workflows.
15
+
16
+ ## Execution Invariant
17
+
18
+ $$\text{Intent} \xrightarrow{\text{Research}} \text{Plan (SOT state.yaml)} \xrightarrow{\text{Implementation}} \text{4-Layer Quality Gates} \xrightarrow{\text{pACS Delta}} \text{Verified Deliverable}$$
19
+
20
+ ---
21
+
22
+ ## ⚡ Dynamic Mode Router
23
+
24
+ Detect the desired mode from context or explicit flags:
25
+
26
+ | Mode | Trigger Phrases | Core Execution Flow |
27
+ |---|---|---|
28
+ | **1. DESIGN** | "design workflow", "new pipeline", "workflow.md" | Research → Planning → Implementation 3-stage blueprint generation |
29
+ | **2. EXECUTE** | "run workflow", "execute pipeline", "start step" | SOT state-machine driver with step-by-step deliverable generation |
30
+ | **3. AUTOPILOT**| "autopilot", "fully automated", "hands-off" | Auto-approve `(human)` checkpoints with decision logs; enforce safety hooks |
31
+ | **4. ULW** | "ulw", "ultrawork", "maximum rigor" | 3 Intensifiers: Sisyphus Persistence, Mandatory Decomposition, Retry Escalation |
32
+ | **5. VERIFY** | "verify step", "quality gates", "run pacs" | L0 Anti-Skip → L1 Verification → L1.5 pACS → L2 Adversarial Review |
33
+ | **6. OPTIMIZE**| "optimize workflow", "reduce cycle time", "streamline" | Lean bottleneck analysis, automation scoring, cycle time compression |
34
+
35
+ ---
36
+
37
+ ## 3 Absolute Criteria (Constitutional Canon)
38
+
39
+ Every workflow, tool, and subagent created or governed by this skill strictly inherits the 3 Absolute Criteria:
40
+
41
+ 1. **Absolute Criterion 1: Quality of the Final Deliverable**
42
+ > Speed, token cost, workload, and length limits are completely ignored. The sole criterion for every decision is the **quality of the final deliverable**.
43
+ 2. **Absolute Criterion 2: Single-File SOT + Hierarchical Memory**
44
+ > All shared state is concentrated in a single file (`state.yaml`). SOT write permission belongs exclusively to the Orchestrator / Team Lead. Parallel agents never mutate shared files simultaneously.
45
+ 3. **Absolute Criterion 3: Code Change Protocol (CCP)**
46
+ > Before writing, modifying, adding, or deleting code, internally perform: Step 1 (Understand Intent) → Step 2 (Ripple Effect Analysis) → Step 3 (Change Plan). Governed by Coding Anchor Points (CAP-1~4).
47
+
48
+ ---
49
+
50
+ ## 4-Layer Quality Assurance Stack
51
+
52
+ ```mermaid
53
+ flowchart TD
54
+ StepStart["Step Execution"] --> L0["L0: Anti-Skip Physical Guard (File exists & >= 100 bytes)"]
55
+ L0 -->|PASS| L1["L1: Verification Gate (100% functional goal achievement)"]
56
+ L0 -->|FAIL| Diag["Abductive Diagnosis"]
57
+ L1 -->|PASS| L15["L1.5: pACS Self-Rating (F/C/L Pre-mortem scoring)"]
58
+ L1 -->|FAIL| Diag
59
+ L15 -->|RED: <50| Diag
60
+ L15 -->|GREEN / YELLOW| L2["L2: Adversarial Review (@reviewer + @fact-checker)"]
61
+ L2 -->|PASS| SOT["Advance SOT (current_step + 1)"]
62
+ L2 -->|FAIL| Diag
63
+ Diag --> Retry["Retry with Alternative Hypothesis (Max 3)"]
64
+ ```
65
+
66
+ 1. **L0 Anti-Skip Guard**: Deterministically verifies deliverable exists on disk and is non-empty (`MIN_OUTPUT_SIZE >= 100 bytes`).
67
+ 2. **L1 Verification Gate**: Semantic verification that all acceptance criteria are 100% achieved.
68
+ 3. **L1.5 pACS (Predicted Agent Confidence Score)**: Pre-mortem evaluation across Faithfulness, Completeness, Logic. $pACS = \min(F, C, L)$.
69
+ - `GREEN (>= 70)`: Auto-advance.
70
+ - `YELLOW (50 - 69)`: Flag weak dimension in Decision Log and proceed.
71
+ - `RED (< 50)`: Halt and trigger rework.
72
+ 4. **L2 Adversarial Review**: Independent Generator-Critic evaluation by `@reviewer` and `@fact-checker`.
73
+
74
+ ---
75
+
76
+ ## Autonomous Self-Fueling Engine & Circuit Breaker
77
+
78
+ The system operates as an end-to-end autonomous engine with built-in energy management:
79
+ 1. **Self-Fueling & Energy Loop**: Dynamic token and context headroom monitoring with automatic RLM state compaction and refueling checkpoints before context exhaustion.
80
+ 2. **Fable Circuit Breaker**: State transitions `CLOSED` → `OPEN` → `HALF_OPEN`. Automatically halts speculative thrashing when consecutive failure streak $\ge 2$, isolates root causes via Abductive Diagnosis (`diagnose_context.py`), and executes structured recovery.
81
+ 3. **Clean Code Guard**: Automated AST guard pass checking the 24 Clean Code imperatives (small functions, intent-revealing names, maximum 4 parameters, no swallowed exceptions, no fake success mocks).
82
+ 4. **AI Engineering Evaluation**: Integrated four-fifths disparate impact testing ($\ge 0.80$), PSI distribution drift monitoring, and adversarial prompt-injection sanitization.
83
+ 5. **OmniSkill Dynamic Intent Routing**: Decomposes complex natural language intent into an optimal multi-step DAG across Research, Planning, Implementation, and Verification.
84
+
85
+ ---
86
+
87
+ ## CLI & Toolchain Integration
88
+
89
+ ```bash
90
+ # Launch autonomous end-to-end autopilot workflow with self-fueling & energy management
91
+ agentic-workflow autopilot --title "Production Pipeline" --goal "Autonomous Delivery"
92
+
93
+ # Run Clean Code Guard audit pass (SOLID, 24 Imperatives, AI failure modes)
94
+ agentic-workflow guard [directory]
95
+
96
+ # Execute AI Engineer fairness, drift, and prompt-injection evaluation gates
97
+ agentic-workflow eval
98
+
99
+ # Query multi-agent observable trace logs and spans
100
+ agentic-workflow traces
101
+
102
+ # Run OmniSkill dynamic intent routing and multi-host validation
103
+ agentic-workflow omni-skill route "build an autonomous pipeline"
104
+ agentic-workflow omni-skill validate
105
+
106
+ # Check live workflow dashboard and observability metrics
107
+ agentic-workflow status
108
+
109
+ # Run full automated test suite (safety, guard, MAS, evaluator)
110
+ agentic-workflow test
111
+ ```
112
+
113
+ ---
114
+
115
+ ## Universal Multi-Agent & Multi-Host Distribution
116
+
117
+ Install and use AgenticWorkflow instantly across any platform or AI harness:
118
+
119
+ ```bash
120
+ # Skills.sh / Vercel AI (Universal Agent Discovery)
121
+ npx skills add imMamdouhaboammar/agentic-workflow
122
+
123
+ # Zero-Install CLI (Bun & Node/npx)
124
+ bunx agentic-workflow --help
125
+ npx agentic-workflow --help
126
+
127
+ # Python Environment (pip / PyPI)
128
+ pip install agentic-workflow
129
+
130
+ # Universal Multi-Agent Installer (Claude, Gemini, Cursor, Codex, OpenCode)
131
+ curl -fsSL https://raw.githubusercontent.com/imMamdouhaboammar/agentic-workflow/main/install.sh | bash
132
+ ```
@@ -0,0 +1,79 @@
1
+ #!/usr/bin/env bash
2
+ # ==============================================================================
3
+ # Universal Agentic Hooks Framework (UAHF) — Shell & Terminal Hooks
4
+ # ==============================================================================
5
+ # Ingests, normalizes, and governs all shell commands executed by interactive users,
6
+ # terminal sessions, or agent subprocesses (Claude, Codex, Antigravity, Cursor, Kimi).
7
+ # Handles pre-execution security and post-session Fable handoff compaction.
8
+ # ==============================================================================
9
+
10
+ export AGENTIC_HOOKS_ACTIVE=1
11
+ PROJECT_DIR="${AGENTIC_PROJECT_DIR:-$(pwd)}"
12
+
13
+ # 1. Intercepted Homebrew Wrapper
14
+ brew() {
15
+ if [ -x "$PROJECT_DIR/bin/cli.js" ]; then
16
+ bun "$PROJECT_DIR/bin/cli.js" hooks brew-shim "$@"
17
+ return $?
18
+ elif command -v python3 >/dev/null 2>&1 && [ -f "$PROJECT_DIR/core/hooks/dispatcher.py" ]; then
19
+ python3 -c "from core.hooks.adapters.homebrew_adapter import HomebrewHookAdapter; import sys; sys.exit(HomebrewHookAdapter().run_shim(sys.argv[1:]))" "$@"
20
+ return $?
21
+ fi
22
+ # Fallback to standard brew if framework not reachable
23
+ command brew "$@"
24
+ }
25
+
26
+ # 2. Shell Command Interceptor (Zsh preexec / Bash DEBUG trap)
27
+ __agentic_preexec_hook() {
28
+ local cmd="$1"
29
+ [ -z "$cmd" ] && return 0
30
+
31
+ # Fast-path: Skip evaluation for trivial builtins to maintain instant prompt speed
32
+ case "$cmd" in
33
+ cd*|pwd|echo*|printf*|true|false|test*|export*|unset*) return 0 ;;
34
+ esac
35
+
36
+ if command -v bun >/dev/null 2>&1 && [ -f "$PROJECT_DIR/bin/cli.js" ]; then
37
+ bun "$PROJECT_DIR/bin/cli.js" hooks dispatch --command "$cmd" --source terminal
38
+ local verdict=$?
39
+ if [ $verdict -ne 0 ]; then
40
+ return 1
41
+ fi
42
+ elif command -v python3 >/dev/null 2>&1 && [ -f "$PROJECT_DIR/core/hooks/dispatcher.py" ]; then
43
+ python3 -c "from core.hooks.adapters.shell_adapter import ShellHookAdapter; import sys; sys.exit(ShellHookAdapter().run_cli_preexec(sys.argv[1]))" "$cmd"
44
+ local verdict=$?
45
+ if [ $verdict -ne 0 ]; then
46
+ return 1
47
+ fi
48
+ fi
49
+ return 0
50
+ }
51
+
52
+ # 3. End of Session Hook & Fable Continuation State Compaction
53
+ __agentic_session_end_hook() {
54
+ if [ -n "$AGENTIC_SESSION_FINALIZED" ]; then
55
+ return 0
56
+ fi
57
+ export AGENTIC_SESSION_FINALIZED=1
58
+
59
+ if command -v bun >/dev/null 2>&1 && [ -f "$PROJECT_DIR/bin/cli.js" ]; then
60
+ bun "$PROJECT_DIR/bin/cli.js" hooks session-end --agent terminal --reason shell_exit >/dev/null 2>&1
61
+ elif command -v python3 >/dev/null 2>&1 && [ -f "$PROJECT_DIR/core/hooks/session_end.py" ]; then
62
+ python3 -c "from core.hooks.session_end import SessionEndManager; SessionEndManager('${PROJECT_DIR}').handle_session_end(agent_id='terminal', reason='shell_exit')" >/dev/null 2>&1
63
+ fi
64
+ }
65
+
66
+ # 4. Zsh / Bash Bindings & Exit Trap
67
+ trap __agentic_session_end_hook EXIT
68
+
69
+ if [ -n "$ZSH_VERSION" ]; then
70
+ autoload -Uz add-zsh-hook 2>/dev/null
71
+ if command -v add-zsh-hook >/dev/null 2>&1; then
72
+ __agentic_zsh_preexec() {
73
+ __agentic_preexec_hook "$1"
74
+ }
75
+ add-zsh-hook preexec __agentic_zsh_preexec
76
+ fi
77
+ fi
78
+
79
+ echo "⚡ [UAHF] Agentic Shell & End-of-Session Hooks Activated (Project: $PROJECT_DIR)"