@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
@@ -0,0 +1,219 @@
1
+ /**
2
+ * src/system/updater.ts — Auto-Updater Engine for AgenticWorkflow
3
+ */
4
+
5
+ import fs from 'node:fs';
6
+ import path from 'node:path';
7
+ import { execSync } from 'node:child_process';
8
+ import type { UpdateCheckResult, UpdateOptions, UpdateResult, RollbackResult } from './types.ts';
9
+
10
+ export class AutoUpdater {
11
+ private projectDir: string;
12
+ private historyFile: string;
13
+
14
+ constructor(projectDir: string = '.') {
15
+ this.projectDir = path.resolve(projectDir);
16
+ this.historyFile = path.join(this.projectDir, '.update_history.json');
17
+ }
18
+
19
+ private runGit(cmd: string): string {
20
+ try {
21
+ return execSync(`git ${cmd}`, { cwd: this.projectDir, stdio: 'pipe', encoding: 'utf-8' }).trim();
22
+ } catch (e: any) {
23
+ return '';
24
+ }
25
+ }
26
+
27
+ public getLocalVersion(): string {
28
+ try {
29
+ const pkgPath = path.join(this.projectDir, 'package.json');
30
+ if (fs.existsSync(pkgPath)) {
31
+ const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf-8'));
32
+ return pkg.version || '1.0.0';
33
+ }
34
+ } catch {
35
+ // Ignore
36
+ }
37
+ return '1.0.0';
38
+ }
39
+
40
+ public checkForUpdates(): UpdateCheckResult {
41
+ const currentCommit = this.runGit('rev-parse HEAD') || 'unknown';
42
+ const branch = this.runGit('rev-parse --abbrev-ref HEAD') || 'main';
43
+ const currentVersion = this.getLocalVersion();
44
+
45
+ let remoteCommit = currentCommit;
46
+ let behindCount = 0;
47
+ const commits: Array<{ hash: string; message: string; date: string }> = [];
48
+
49
+ // Try checking remote via ls-remote or fetch
50
+ try {
51
+ const remoteHead = this.runGit(`ls-remote origin refs/heads/${branch}`);
52
+ if (remoteHead) {
53
+ remoteCommit = remoteHead.split(/\s+/)[0] || currentCommit;
54
+ }
55
+ if (remoteCommit && remoteCommit !== currentCommit) {
56
+ // We have a difference
57
+ behindCount = 1;
58
+ commits.push({
59
+ hash: remoteCommit.substring(0, 7),
60
+ message: `Upstream update available on origin/${branch}`,
61
+ date: new Date().toISOString()
62
+ });
63
+ }
64
+ } catch {
65
+ // Remote might be offline
66
+ }
67
+
68
+ return {
69
+ hasUpdate: remoteCommit !== currentCommit && remoteCommit !== 'unknown',
70
+ currentCommit,
71
+ currentVersion,
72
+ remoteCommit,
73
+ remoteVersion: remoteCommit !== currentCommit ? `${currentVersion}-next` : currentVersion,
74
+ branch,
75
+ behindCount,
76
+ commits,
77
+ channel: branch === 'main' ? 'stable' : 'nightly'
78
+ };
79
+ }
80
+
81
+ public update(options: UpdateOptions = {}): UpdateResult {
82
+ const strategy = options.strategy || 'stash-and-pull';
83
+ const branch = options.branch || this.runGit('rev-parse --abbrev-ref HEAD') || 'main';
84
+ const previousCommit = this.runGit('rev-parse HEAD');
85
+
86
+ const status = this.runGit('status --porcelain');
87
+ const isDirty = status.length > 0;
88
+ let stashed = false;
89
+
90
+ if (isDirty) {
91
+ if (strategy === 'stash-and-pull') {
92
+ const stashMsg = `agentic-auto-update-${Date.now()}`;
93
+ this.runGit(`stash push -m "${stashMsg}"`);
94
+ stashed = true;
95
+ } else if (!options.force) {
96
+ return {
97
+ success: false,
98
+ previousCommit,
99
+ newCommit: previousCommit,
100
+ message: 'Working directory has uncommitted changes. Use --force or stash changes first.',
101
+ stashed: false,
102
+ reinstalled: false,
103
+ refreshed: false
104
+ };
105
+ }
106
+ }
107
+
108
+ try {
109
+ // Perform pull
110
+ this.runGit(`pull origin ${branch}`);
111
+ const newCommit = this.runGit('rev-parse HEAD');
112
+
113
+ let reinstalled = false;
114
+ if (options.autoReinstall) {
115
+ try {
116
+ execSync('bun install', { cwd: this.projectDir, stdio: 'pipe' });
117
+ reinstalled = true;
118
+ } catch {
119
+ // Fallback or ignore
120
+ }
121
+ }
122
+
123
+ // Record update in history file
124
+ this.saveHistoryRecord({
125
+ timestamp: new Date().toISOString(),
126
+ previousCommit,
127
+ newCommit,
128
+ branch,
129
+ stashed
130
+ });
131
+
132
+ return {
133
+ success: true,
134
+ previousCommit,
135
+ newCommit,
136
+ message: `Updated successfully from ${previousCommit.substring(0, 7)} to ${newCommit.substring(0, 7)}`,
137
+ stashed,
138
+ reinstalled,
139
+ refreshed: !!options.autoRefresh
140
+ };
141
+ } catch (err: any) {
142
+ // Rollback on failure if stashed
143
+ if (stashed) {
144
+ this.runGit('stash pop');
145
+ }
146
+ return {
147
+ success: false,
148
+ previousCommit,
149
+ newCommit: previousCommit,
150
+ message: `Update failed: ${err.message || String(err)}`,
151
+ stashed: false,
152
+ reinstalled: false,
153
+ refreshed: false
154
+ };
155
+ }
156
+ }
157
+
158
+ public rollback(): RollbackResult {
159
+ const history = this.getHistory();
160
+ if (history.length === 0) {
161
+ return {
162
+ success: false,
163
+ rolledBackTo: '',
164
+ message: 'No update history found to rollback.'
165
+ };
166
+ }
167
+
168
+ const last = history[history.length - 1];
169
+ const targetCommit = last.previousCommit;
170
+
171
+ try {
172
+ this.runGit(`reset --hard ${targetCommit}`);
173
+ if (last.stashed) {
174
+ try {
175
+ this.runGit('stash pop');
176
+ } catch {
177
+ // Ignore stash conflicts
178
+ }
179
+ }
180
+
181
+ // Remove last record
182
+ history.pop();
183
+ fs.writeFileSync(this.historyFile, JSON.stringify(history, null, 2));
184
+
185
+ return {
186
+ success: true,
187
+ rolledBackTo: targetCommit,
188
+ message: `Successfully rolled back to commit ${targetCommit.substring(0, 7)}`
189
+ };
190
+ } catch (err: any) {
191
+ return {
192
+ success: false,
193
+ rolledBackTo: '',
194
+ message: `Rollback failed: ${err.message}`
195
+ };
196
+ }
197
+ }
198
+
199
+ public getHistory(): any[] {
200
+ try {
201
+ if (fs.existsSync(this.historyFile)) {
202
+ return JSON.parse(fs.readFileSync(this.historyFile, 'utf-8'));
203
+ }
204
+ } catch {
205
+ // Ignore
206
+ }
207
+ return [];
208
+ }
209
+
210
+ private saveHistoryRecord(record: any): void {
211
+ try {
212
+ const history = this.getHistory();
213
+ history.push(record);
214
+ fs.writeFileSync(this.historyFile, JSON.stringify(history, null, 2));
215
+ } catch {
216
+ // Ignore write errors
217
+ }
218
+ }
219
+ }
@@ -0,0 +1,137 @@
1
+ /**
2
+ * src/system/version-tracker.ts — Version Tracker, Matrix & Migration Engine
3
+ */
4
+
5
+ import fs from 'node:fs';
6
+ import path from 'node:path';
7
+ import { execSync } from 'node:child_process';
8
+ import type { VersionMatrix, ComponentVersion, MigrationStep } from './types.ts';
9
+
10
+ export class VersionTracker {
11
+ private projectDir: string;
12
+ private migrationFile: string;
13
+
14
+ constructor(projectDir: string = '.') {
15
+ this.projectDir = path.resolve(projectDir);
16
+ this.migrationFile = path.join(this.projectDir, '.migration_history.json');
17
+ }
18
+
19
+ private runGit(cmd: string): string {
20
+ try {
21
+ return execSync(`git ${cmd}`, { cwd: this.projectDir, stdio: 'pipe', encoding: 'utf-8' }).trim();
22
+ } catch {
23
+ return '';
24
+ }
25
+ }
26
+
27
+ public getPackageVersion(): string {
28
+ try {
29
+ const pkgPath = path.join(this.projectDir, 'package.json');
30
+ if (fs.existsSync(pkgPath)) {
31
+ const data = JSON.parse(fs.readFileSync(pkgPath, 'utf-8'));
32
+ return data.version || '1.1.0';
33
+ }
34
+ } catch {
35
+ // Ignore
36
+ }
37
+ return '1.1.0';
38
+ }
39
+
40
+ public getVersionMatrix(): VersionMatrix {
41
+ const pkgVersion = this.getPackageVersion();
42
+ const commit = this.runGit('rev-parse HEAD') || 'unknown';
43
+ const branch = this.runGit('rev-parse --abbrev-ref HEAD') || 'main';
44
+ const dirty = this.runGit('status --porcelain').length > 0;
45
+
46
+ const components: ComponentVersion[] = [
47
+ { name: 'AgenticWorkflow CLI', version: pkgVersion, channel: branch === 'main' ? 'stable' : 'dev', path: 'bin/cli.js' },
48
+ { name: 'TypeScript Async Engine', version: pkgVersion, channel: 'stable', path: 'src/engine_ts/' },
49
+ { name: 'Python AsyncIO Engine', version: pkgVersion, channel: 'stable', path: 'core/engine_py/' },
50
+ { name: 'TOON Protocol Adapter', version: '4.1.1', channel: 'standard', path: 'src/engine_ts/toon-adapter.ts' },
51
+ { name: 'Universal Agentic Hooks', version: '1.2.0', channel: 'governed', path: 'src/hooks/' },
52
+ { name: 'Skills Mesh Indexer', version: '2.0.0', channel: 'dynamic', path: 'core/skills_indexer.py' },
53
+ { name: 'Supportive Tools Director', version: '1.1.0', channel: 'continuous', path: 'src/integrations/' }
54
+ ];
55
+
56
+ return {
57
+ cliVersion: pkgVersion,
58
+ tsEngineVersion: pkgVersion,
59
+ pyEngineVersion: pkgVersion,
60
+ toonProtocolVersion: '4.1.1',
61
+ uahfHooksVersion: '1.2.0',
62
+ gitCommit: commit,
63
+ gitBranch: branch,
64
+ gitClean: !dirty,
65
+ buildDate: '2026-09-06T14:40:00Z',
66
+ components
67
+ };
68
+ }
69
+
70
+ public compareVersions(v1: string, v2: string): number {
71
+ const clean1 = v1.replace(/^v/, '').split('.').map(Number);
72
+ const clean2 = v2.replace(/^v/, '').split('.').map(Number);
73
+
74
+ for (let i = 0; i < 3; i++) {
75
+ const num1 = clean1[i] || 0;
76
+ const num2 = clean2[i] || 0;
77
+ if (num1 > num2) return 1;
78
+ if (num1 < num2) return -1;
79
+ }
80
+ return 0;
81
+ }
82
+
83
+ public getAvailableMigrations(): MigrationStep[] {
84
+ return [
85
+ {
86
+ fromVersion: '1.0.0',
87
+ toVersion: '1.0.5',
88
+ name: 'migrate_to_toon_v41',
89
+ description: 'Convert JSON state caches to TOON v4.1 format and generate skills-index.toon',
90
+ executed: true,
91
+ timestamp: '2026-09-01T00:00:00Z'
92
+ },
93
+ {
94
+ fromVersion: '1.0.5',
95
+ toVersion: '1.1.0',
96
+ name: 'provision_supportive_tools',
97
+ description: 'Initialize integrations.json and provision Ponytail, Fable, Caveman',
98
+ executed: true,
99
+ timestamp: '2026-09-05T00:00:00Z'
100
+ },
101
+ {
102
+ fromVersion: '1.1.0',
103
+ toVersion: '1.2.0',
104
+ name: 'enable_system_engines',
105
+ description: 'Bootstrap system engines: updater, installer, doctor, health, notifications',
106
+ executed: true,
107
+ timestamp: '2026-09-06T14:40:00Z'
108
+ }
109
+ ];
110
+ }
111
+
112
+ public getChangelog(): Record<string, string[]> {
113
+ return {
114
+ '1.1.0': [
115
+ 'Universal System Engines Suite: Auto-Updater, Auto-Installer, Refresher, Doctor, Health Engine, Dependencies Engine, Notifications, Announcements, Version Tracker',
116
+ 'Full dual-runtime parity across TypeScript/Bun and Python 3 engines',
117
+ 'Doctor automated remediation (--fix) and real-time health telemetry',
118
+ 'Rich ANSI terminal toast banners and native macOS desktop notifications'
119
+ ],
120
+ '1.0.5': [
121
+ 'Integrated official TOON v4.1 adapter delivering 30-60% token savings',
122
+ 'Built Agentic Skills Mesh with synchronized JSON and TOON indexing',
123
+ 'Supportive Tools Subsystem: Ponytail YAGNI ladder, Fable circuit breakers, Caveman mode'
124
+ ],
125
+ '1.0.0': [
126
+ 'Universal Agentic Hooks Framework (UAHF) governing multi-agent sessions',
127
+ 'Autopilot self-fueling execution loop with 4-layer verification (L0-L2)'
128
+ ]
129
+ };
130
+ }
131
+
132
+ public formatMatrixToon(matrix: VersionMatrix): string {
133
+ return `version_matrix{cli:"${matrix.cliVersion}",branch:"${matrix.gitBranch}",commit:"${matrix.gitCommit.substring(0, 7)}",clean:${matrix.gitClean}}:
134
+ components[${matrix.components.length}]{name,version,channel,path}:
135
+ ${matrix.components.map(c => ` "${c.name}",${c.version},${c.channel},${c.path || ''}`).join('\n')}`;
136
+ }
137
+ }