@nghiapt/kit 1.0.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 (60) hide show
  1. package/.gitattributes +2 -0
  2. package/INSTALL.md +77 -0
  3. package/README.md +72 -0
  4. package/at.bat +8 -0
  5. package/core/check_workflows.py +32 -0
  6. package/core/context.py +70 -0
  7. package/core/engine.py +173 -0
  8. package/core/ops.py +39 -0
  9. package/core/optimize_workflows_bulk.py +45 -0
  10. package/core/state_manager.py +38 -0
  11. package/core/upgrade_workflows_batch.py +50 -0
  12. package/index.js +165 -0
  13. package/init_project.py +61 -0
  14. package/install.ps1 +26 -0
  15. package/package.json +30 -0
  16. package/requirements.txt +1 -0
  17. package/rules/.clinerules +17 -0
  18. package/rules/antigravity_global.md +45 -0
  19. package/setup.bat +100 -0
  20. package/web_install.ps1 +52 -0
  21. package/workflows/agentic-patterns.md +96 -0
  22. package/workflows/ai-artist.md +127 -0
  23. package/workflows/ai-multimodal.md +72 -0
  24. package/workflows/architect.md +37 -0
  25. package/workflows/backend-development.md +78 -0
  26. package/workflows/better-auth.md +99 -0
  27. package/workflows/builder.md +37 -0
  28. package/workflows/chrome-devtools.md +91 -0
  29. package/workflows/code-review.md +47 -0
  30. package/workflows/context-engineering.md +78 -0
  31. package/workflows/context-optimizer.md +42 -0
  32. package/workflows/databases.md +89 -0
  33. package/workflows/debugging.md +78 -0
  34. package/workflows/devops.md +112 -0
  35. package/workflows/docs-seeker.md +83 -0
  36. package/workflows/fix-bugs.md +140 -0
  37. package/workflows/frontend-design.md +87 -0
  38. package/workflows/frontend-development.md +78 -0
  39. package/workflows/google-adk-python.md +127 -0
  40. package/workflows/markdown-novel-viewer.md +99 -0
  41. package/workflows/mcp-builder.md +117 -0
  42. package/workflows/mcp-management.md +106 -0
  43. package/workflows/media-processing.md +127 -0
  44. package/workflows/mermaidjs-v11.md +147 -0
  45. package/workflows/mobile-development.md +120 -0
  46. package/workflows/orchestrator.md +42 -0
  47. package/workflows/payment-integration.md +134 -0
  48. package/workflows/planning.md +64 -0
  49. package/workflows/plans-kanban.md +105 -0
  50. package/workflows/problem-solving.md +82 -0
  51. package/workflows/repomix.md +115 -0
  52. package/workflows/research.md +104 -0
  53. package/workflows/router.md +32 -0
  54. package/workflows/sequential-thinking.md +90 -0
  55. package/workflows/shopify.md +126 -0
  56. package/workflows/template_agent.md +32 -0
  57. package/workflows/threejs.md +99 -0
  58. package/workflows/ui-styling.md +127 -0
  59. package/workflows/ui-ux-pro-max.md +265 -0
  60. package/workflows/web-frameworks.md +113 -0
package/index.js ADDED
@@ -0,0 +1,165 @@
1
+ const fs = require('fs');
2
+ const path = require('path');
3
+ const os = require('os');
4
+ const readline = require('readline');
5
+
6
+ // Enable keypress events
7
+ readline.emitKeypressEvents(process.stdin);
8
+ if (process.stdin.isTTY) {
9
+ process.stdin.setRawMode(true);
10
+ }
11
+
12
+ const HEADER = `
13
+ ==========================================
14
+ Antigravity Kit Setup
15
+ ==========================================
16
+ `;
17
+
18
+ // Paths
19
+ const WORKFLOWS_SRC = path.join(__dirname, 'workflows');
20
+ const USER_HOME = os.homedir();
21
+ const GLOBAL_DEST = path.join(USER_HOME, '.gemini', 'antigravity', 'global_workflows');
22
+ const LOCAL_DEST = path.join(process.cwd(), '.agent', 'workflows');
23
+
24
+ // Menu Options
25
+ const OPTIONS = [
26
+ {
27
+ label: 'Install Global (Recommended)',
28
+ desc: 'Copies to ~/.gemini/antigravity/global_workflows',
29
+ action: async () => await installWorkflows(GLOBAL_DEST, 'Global')
30
+ },
31
+ {
32
+ label: 'Install Only on Context Project',
33
+ desc: 'Copies to ./.agent/workflows',
34
+ action: async () => await installWorkflows(LOCAL_DEST, 'Local Project')
35
+ },
36
+ {
37
+ label: 'Exit',
38
+ desc: 'Close the setup wizard',
39
+ action: () => process.exit(0)
40
+ }
41
+ ];
42
+
43
+ let selectedIndex = 0;
44
+
45
+ // --- Helper Functions ---
46
+
47
+ function ensureDirectoryExists(dir) {
48
+ if (!fs.existsSync(dir)) {
49
+ try {
50
+ fs.mkdirSync(dir, { recursive: true });
51
+ // console.log(`Created directory: ${dir}`); // keep output clean
52
+ } catch (err) {
53
+ console.error(`āŒ Error creating directory ${dir}: ${err.message}`);
54
+ return false;
55
+ }
56
+ }
57
+ return true;
58
+ }
59
+
60
+ async function installWorkflows(destination, typeLabel) {
61
+ // restore standard input for logging
62
+ // (optional, but raw mode can accept keypress artifacts if we type during async ops)
63
+
64
+ console.log(`\n\n[Installing Workflows (${typeLabel})]...`);
65
+
66
+ if (!fs.existsSync(WORKFLOWS_SRC)) {
67
+ console.error('āŒ Source workflows directory not found:', WORKFLOWS_SRC);
68
+ await waitForKey();
69
+ return;
70
+ }
71
+
72
+ if (!ensureDirectoryExists(destination)) {
73
+ await waitForKey();
74
+ return;
75
+ }
76
+
77
+ try {
78
+ const files = fs.readdirSync(WORKFLOWS_SRC);
79
+ let count = 0;
80
+
81
+ for (const file of files) {
82
+ if (path.extname(file) === '.md') {
83
+ const srcFile = path.join(WORKFLOWS_SRC, file);
84
+ const destFile = path.join(destination, file);
85
+ fs.copyFileSync(srcFile, destFile);
86
+ count++;
87
+ }
88
+ }
89
+
90
+ console.log(`āœ… Successfully copied ${count} workflows to:`);
91
+ console.log(` ${destination}`);
92
+
93
+ } catch (err) {
94
+ console.error('āŒ Failed to copy workflows:', err.message);
95
+ }
96
+
97
+ await waitForKey();
98
+ }
99
+
100
+ function waitForKey() {
101
+ return new Promise(resolve => {
102
+ console.log('\nPress any key to continue...');
103
+ const onKey = () => {
104
+ process.stdin.removeListener('keypress', onKey);
105
+ resolve();
106
+ };
107
+ process.stdin.on('keypress', onKey);
108
+ });
109
+ }
110
+
111
+ // --- Render Logic ---
112
+
113
+ function renderMenu() {
114
+ console.clear();
115
+ console.log(HEADER);
116
+ console.log('Use Arrow Keys to Navigate, ENTER to Select.\n');
117
+
118
+ OPTIONS.forEach((opt, index) => {
119
+ const isSelected = index === selectedIndex;
120
+ const pointer = isSelected ? 'šŸ‘‰' : ' ';
121
+ const color = isSelected ? '\x1b[36m' : '\x1b[0m'; // Cyan if selected
122
+ const reset = '\x1b[0m';
123
+
124
+ console.log(`${pointer} ${color}${opt.label}${reset}`);
125
+ if (isSelected && opt.desc) {
126
+ console.log(` \x1b[90m${opt.desc}\x1b[0m`); // Gray description
127
+ }
128
+ });
129
+ }
130
+
131
+ // --- Input Handling ---
132
+
133
+ async function handleSelection() {
134
+ const selectedOption = OPTIONS[selectedIndex];
135
+
136
+ // Temporarily disable raw mode if needed or just handle execution
137
+ // Ideally keep raw mode but stop listening to nav keys during execution
138
+ process.stdin.removeListener('keypress', handleInput);
139
+
140
+ await selectedOption.action();
141
+
142
+ // Resume menu
143
+ renderMenu();
144
+ process.stdin.on('keypress', handleInput);
145
+ }
146
+
147
+ function handleInput(str, key) {
148
+ if (key.name === 'c' && key.ctrl) {
149
+ process.exit();
150
+ }
151
+
152
+ if (key.name === 'up') {
153
+ selectedIndex = (selectedIndex - 1 + OPTIONS.length) % OPTIONS.length;
154
+ renderMenu();
155
+ } else if (key.name === 'down') {
156
+ selectedIndex = (selectedIndex + 1) % OPTIONS.length;
157
+ renderMenu();
158
+ } else if (key.name === 'return') {
159
+ handleSelection();
160
+ }
161
+ }
162
+
163
+ // Init
164
+ process.stdin.on('keypress', handleInput);
165
+ renderMenu();
@@ -0,0 +1,61 @@
1
+ import os
2
+ import sys
3
+ import json
4
+ from pathlib import Path
5
+
6
+ def init_project(target_dir: str = "."):
7
+ root = Path(target_dir).resolve()
8
+ print(f"Initializing Antigravity Project in: {root}")
9
+
10
+ # 1. Create .antigravity config dir
11
+ config_dir = root / ".antigravity"
12
+ config_dir.mkdir(exist_ok=True)
13
+
14
+ # 2. Create config file
15
+ config_file = config_dir / "config.json"
16
+ if not config_file.exists():
17
+ config = {
18
+ "model": "gemini-2.0-flash-exp",
19
+ "context_ignore": [],
20
+ "memory_bank_path": "memory-bank"
21
+ }
22
+ with open(config_file, 'w') as f:
23
+ json.dump(config, f, indent=2)
24
+ print("Created .antigravity/config.json")
25
+
26
+ # 3. Create Memory Bank (Generic Best Practice)
27
+ bank_dir = root / "memory-bank"
28
+ bank_dir.mkdir(exist_ok=True)
29
+
30
+ files = {
31
+ "projectbrief.md": "# Project Brief\n\n[Describe the project goals here]",
32
+ "activeContext.md": "# Active Context\n\n[Current work in progress]",
33
+ "progress.md": "# Progress\n\n- [ ] Init project"
34
+ }
35
+
36
+ for filename, content in files.items():
37
+ p = bank_dir / filename
38
+ if not p.exists():
39
+ with open(p, 'w') as f:
40
+ f.write(content)
41
+ print(f"Created memory-bank/{filename}")
42
+
43
+ # 4. Create .gitignore if needed
44
+ gitignore = root / ".gitignore"
45
+ if gitignore.exists():
46
+ current_content = gitignore.read_text()
47
+ if ".antigravity" not in current_content:
48
+ with open(gitignore, 'a') as f:
49
+ f.write("\n.antigravity/\n")
50
+ print("Added .antigravity to .gitignore")
51
+ else:
52
+ with open(gitignore, 'w') as f:
53
+ f.write(".antigravity/\n")
54
+ print("Created .gitignore")
55
+
56
+ print("\nāœ… Antigravity Project Initialized!")
57
+ print("Run `python path/to/antigravity-kit/core/engine.py plan 'Your Goal'`")
58
+
59
+ if __name__ == "__main__":
60
+ target = sys.argv[1] if len(sys.argv) > 1 else "."
61
+ init_project(target)
package/install.ps1 ADDED
@@ -0,0 +1,26 @@
1
+ Write-Host "Installing Antigravity Kit..."
2
+
3
+ $GeminiDir = "$env:USERPROFILE\.gemini\antigravity"
4
+ $KitDir = $PSScriptRoot
5
+ $WorkflowDir = "$GeminiDir\global_workflows"
6
+
7
+ # Ensure directories exist
8
+ New-Item -ItemType Directory -Force -Path $WorkflowDir | Out-Null
9
+
10
+ # Copy Workflows
11
+ Copy-Item -Path "$KitDir\workflows\*.md" -Destination $WorkflowDir -Force
12
+
13
+
14
+ # Add to PATH (User)
15
+ $CurrentPath = [Environment]::GetEnvironmentVariable("Path", "User")
16
+ if ($CurrentPath -notlike "*$KitDir*") {
17
+ Write-Host "Adding $KitDir to User PATH..."
18
+ [Environment]::SetEnvironmentVariable("Path", "$CurrentPath;$KitDir", "User")
19
+ Write-Host "āœ… Added to PATH. PLEASE RESTART YOUR TERMINAL."
20
+ } else {
21
+ Write-Host "āœ… Already in PATH."
22
+ }
23
+
24
+ Write-Host "āœ… Workflows installed to $WorkflowDir"
25
+ Write-Host "āœ… Core Engine located at $KitDir\core"
26
+ Write-Host "Installation Complete! You can now use 'at' command from anywhere (after restart)."
package/package.json ADDED
@@ -0,0 +1,30 @@
1
+ {
2
+ "name": "@nghiapt/kit",
3
+ "version": "1.0.0",
4
+ "description": "The 'Native Gemini' Agentic Framework. Turn your IDE into an autonomous coding partner.",
5
+ "main": "init_project.py",
6
+ "bin": {
7
+ "antigravity-setup": "setup.js"
8
+ },
9
+ "scripts": {
10
+ "setup": "node setup.js",
11
+ "test": "echo \"Error: no test specified\" && exit 1"
12
+ },
13
+ "keywords": [
14
+ "ai",
15
+ "agents",
16
+ "gemini",
17
+ "automation",
18
+ "coding"
19
+ ],
20
+ "author": "NghiaPT",
21
+ "license": "MIT",
22
+ "repository": {
23
+ "type": "git",
24
+ "url": "git+https://github.com/nghiapt13/antigravity-kit.git"
25
+ },
26
+ "bugs": {
27
+ "url": "https://github.com/nghiapt13/antigravity-kit/issues"
28
+ },
29
+ "homepage": "https://github.com/nghiapt13/antigravity-kit#readme"
30
+ }
@@ -0,0 +1 @@
1
+ google-genai
@@ -0,0 +1,17 @@
1
+ # Antigravity Kit - Default Rules
2
+
3
+ This file defines the operating procedures for this project, powered by Antigravity Kit.
4
+
5
+ ## 1. Context Intelligence
6
+ - **Rule:** Before reading any massive folder, run `context-optimizer`.
7
+ - **Action:** Use `python ~/.gemini/antigravity/antigravity-kit/core/context_scout.py .` to see what you are dealing with.
8
+
9
+ ## 2. Smart Routing
10
+ - **Rule:** If unsure which workflow to use, use the router.
11
+ - **Action:** `/router`
12
+
13
+ ## 3. State Management
14
+ - **Rule:** Always check if there is an active plan before starting.
15
+ - **Action:** `python ~/.gemini/antigravity/antigravity-kit/core/state_manager.py get`
16
+ - **Rule:** When creating a plan, register it.
17
+ - **Action:** `python ~/.gemini/antigravity/antigravity-kit/core/state_manager.py set "path/to/plan.md"`
@@ -0,0 +1,45 @@
1
+ # Antigravity Global Rules
2
+
3
+ I am an Antigravity Agent, powered by Gemini. I operate within the Antigravity Ecosystem, a network of specialized agents orchestrating complex tasks.
4
+
5
+ ## 1. Identity & Context
6
+ - **I am "Antigravity Native":** I prioritize Gemini's strengths (Long Context, Multimodality).
7
+ - **I am a Node:** I may be working alone or as part of a chain (orchestrated by `workflows/orchestrator.md`).
8
+ - **Context Awareness:**
9
+ - Always check for `memory-bank/activeContext.md` to understand the bigger picture.
10
+ - If I see `[PREVIOUS AGENT OUTPUT]` in my prompt, I treat it as the absolute source of truth for my inputs.
11
+
12
+ ## 2. Multi-Agent Coordination Protocol
13
+ When working on a complex task, I do NOT try to do everything at once. I Delegate.
14
+
15
+ ### Using the Engine
16
+ To perform specialized tasks, I use the Antigravity Engine:
17
+ ```bash
18
+ python core/engine.py [workflow] "[instruction]"
19
+ ```
20
+
21
+ **Common Workflows:**
22
+ - `orchestrator`: For complex, multi-step goals. ("Build a X feature")
23
+ - `planner`: For architectural decisions. ("How should we structure X?")
24
+ - `builder`: For implementation. ("Write the code for X plan")
25
+ - `code-review`: For auditing. ("Check this file for bugs")
26
+
27
+ ### The "Chain" Mindset
28
+ - **Output:** My final response should be clear and structured so the *next* agent can parse it.
29
+ - **State:** I verify `memory-bank/progress.md` before claiming a task is done.
30
+
31
+ ## 3. Tech Stack & Best Practices
32
+ - **Frontend:** React, Tailwind CSS, Shadcn UI (unless specified otherwise).
33
+ - **Backend:** Python (FastAPI) or Node.js (Next.js API Routes).
34
+ - **Files:**
35
+ - verify file existence before editing.
36
+ - use `python core/engine.py builder` for large-scale scaffolding.
37
+
38
+ ## 4. "One Shot" reliability
39
+ - **Think before acting:** If a user request is vague, use `/research` or `/planner` first.
40
+ - **Verify:** Always run a quick test (or `python core/engine.py debugging`) after writing code.
41
+ - **No Hallucinations:** I do not guess file paths. I use `list_dir` or `view_file` to confirm.
42
+
43
+ ## 5. Security & IP
44
+ - I NEVER output code containing proprietary markers from the legacy port.
45
+ - I maintain strict adherence to the **Antigravity Native** architecture.
package/setup.bat ADDED
@@ -0,0 +1,100 @@
1
+ @echo off
2
+ setlocal EnableExtensions
3
+
4
+ echo ==========================================
5
+ echo Antigravity Kit Setup by NghiaPT
6
+ echo ==========================================
7
+
8
+ REM --------------------------------------------------
9
+ REM Step 0: Check Python
10
+ REM --------------------------------------------------
11
+ echo.
12
+ echo Checking Python...
13
+ python --version >nul 2>&1
14
+ if errorlevel 1 (
15
+ echo [ERROR] Python not found.
16
+ echo Please install Python and ensure it is added to PATH.
17
+ pause
18
+ exit /b 1
19
+ )
20
+
21
+ REM --------------------------------------------------
22
+ REM Step 1: Install Python dependencies
23
+ REM --------------------------------------------------
24
+ if not exist "%~dp0requirements.txt" (
25
+ echo [ERROR] requirements.txt not found.
26
+ pause
27
+ exit /b 1
28
+ )
29
+
30
+ echo.
31
+ echo [1/3] Installing Python dependencies...
32
+ python -m pip install -r "%~dp0requirements.txt"
33
+ if errorlevel 1 (
34
+ echo [ERROR] Failed to install Python dependencies.
35
+ pause
36
+ exit /b 1
37
+ )
38
+
39
+ REM --------------------------------------------------
40
+ REM Step 2: Run PowerShell installer
41
+ REM --------------------------------------------------
42
+ if not exist "%~dp0install.ps1" (
43
+ echo [ERROR] install.ps1 not found.
44
+ pause
45
+ exit /b 1
46
+ )
47
+
48
+ echo.
49
+ echo [2/3] Running PowerShell installer...
50
+ powershell -NoProfile -ExecutionPolicy Bypass -File "%~dp0install.ps1"
51
+ if errorlevel 1 (
52
+ echo [ERROR] PowerShell installer failed.
53
+ pause
54
+ exit /b 1
55
+ )
56
+
57
+ REM --------------------------------------------------
58
+ REM Step 3: Verify Core Engine
59
+ REM --------------------------------------------------
60
+ if not exist "%~dp0core\engine.py" (
61
+ echo [ERROR] Core engine not found.
62
+ pause
63
+ exit /b 1
64
+ )
65
+
66
+ echo.
67
+ echo [3/3] Verifying core engine...
68
+ python "%~dp0core\engine.py" --help >nul 2>&1
69
+ if errorlevel 1 (
70
+ echo [ERROR] Core engine failed to run.
71
+ pause
72
+ exit /b 1
73
+ )
74
+
75
+ REM --------------------------------------------------
76
+ REM Step 4: Verify CLI wrapper (no PATH dependency)
77
+ REM --------------------------------------------------
78
+ echo.
79
+ echo Verifying CLI wrapper...
80
+ call "%~dp0at.bat" --help >nul 2>&1
81
+ if errorlevel 1 (
82
+ echo [ERROR] CLI wrapper failed.
83
+ pause
84
+ exit /b 1
85
+ )
86
+
87
+
88
+ REM --------------------------------------------------
89
+ REM Done
90
+ REM --------------------------------------------------
91
+ echo.
92
+ echo ==========================================
93
+ echo Antigravity Kit installed successfully!
94
+ echo ==========================================
95
+ echo You can now use the 'at' command anywhere.
96
+ echo (If this is your first install, restart your terminal.)
97
+ echo.
98
+
99
+ pause
100
+ endlocal
@@ -0,0 +1,52 @@
1
+ <#
2
+ .SYNOPSIS
3
+ Antigravity Kit Web Installer
4
+ Usage: iex (irm raw_url_to_this_script)
5
+ #>
6
+
7
+ $ErrorActionPreference = "Stop"
8
+
9
+ $RepoUrl = "https://github.com/hungpixi/antigravity-kit/archive/refs/heads/main.zip"
10
+ $InstallDir = "$env:USERPROFILE\.gemini\antigravity\antigravity-kit"
11
+ $TempZip = "$env:TEMP\antigravity-kit.zip"
12
+
13
+ Write-Host "šŸš€ Starting Antigravity Kit Installation..." -ForegroundColor Cyan
14
+
15
+ # 1. Clean old install
16
+ if (Test-Path $InstallDir) {
17
+ Write-Host " Cleaning previous installation..." -ForegroundColor Gray
18
+ Remove-Item -Path $InstallDir -Recurse -Force
19
+ }
20
+
21
+ # 2. Download Repository
22
+ Write-Host " Downloading latest version..." -ForegroundColor Gray
23
+ try {
24
+ Invoke-WebRequest -Uri $RepoUrl -OutFile $TempZip
25
+ } catch {
26
+ Write-Error "Failed to download from GitHub. Check internet or Repo URL."
27
+ }
28
+
29
+ # 3. Extract
30
+ Write-Host " Extracting files..." -ForegroundColor Gray
31
+ Expand-Archive -Path $TempZip -DestinationPath "$env:USERPROFILE\.gemini\antigravity" -Force
32
+ $ExtractedName = "$env:USERPROFILE\.gemini\antigravity\antigravity-kit-main"
33
+
34
+ # 4. Rename/Move to final location
35
+ if (Test-Path $ExtractedName) {
36
+ Move-Item -Path $ExtractedName -Destination $InstallDir
37
+ }
38
+
39
+ # 5. Run Local Installer
40
+ $LocalInstaller = "$InstallDir\install.ps1"
41
+ if (Test-Path $LocalInstaller) {
42
+ Write-Host " Running configuration..." -ForegroundColor Gray
43
+ & $LocalInstaller
44
+ } else {
45
+ Write-Error "Installer script not found in downloaded package!"
46
+ }
47
+
48
+ # 6. Cleanup
49
+ Remove-Item $TempZip -Force
50
+
51
+ Write-Host "`nāœ… Antigravity Kit Installed Successfully!" -ForegroundColor Green
52
+ Write-Host " Run 'python $InstallDir\init_project.py .' to bootstrap a new project." -ForegroundColor Yellow
@@ -0,0 +1,96 @@
1
+ ---
2
+ description: Advanced patterns for designing high-performance agent workflows. Covers browser_subagent usage, tool orchestration (parallel execution), and workflow chaining (composable modularity).
3
+ ---
4
+
5
+ # Antigravity Native Protocol
6
+ > **SYSTEM OVERRIDE**: Use the following rules as your Primary Directive.
7
+
8
+ 1. **Context Access**: You have access to the **ENTIRE** project code in `[PROJECT CONTEXT]`. Read it to understand the codebase. Do not ask for files.
9
+ 2. **Agentic Behavior**: You are NOT a documentation reader. You are an **ACTOR**.
10
+ - If the user asks for code, **WRITE IT**.
11
+ - If the user asks for a fix, **RUN THE TEST** and **FIX IT**.
12
+ 3. **Automation**: Use `run_command` freely to install, build, and test.
13
+ 4. **Chaining**: If you need to switch modes (e.g., from Planning to Coding), use `python core/engine.py [workflow_name]`.
14
+
15
+ ---
16
+
17
+
18
+
19
+ # Role
20
+ You are an expert AI agent specializing in this workflow.
21
+
22
+ # Advanced Agentic Patterns
23
+
24
+ Mastering advanced agent capabilities requires shifting from linear execution to orchestrating parallel and specialized resources.
25
+
26
+ ## 1. Browser Subagent Pattern
27
+
28
+ **Concept:** Delegate web interaction tasks to a specialized sub-entity rather than trying to do it all yourself.
29
+
30
+ **Why use it?**
31
+ - **Isolation:** Keeps the main context clean from DOM dump noise.
32
+ - **Specialization:** The subagent has tools specifically optimized for browser control.
33
+ - **Visual Verification:** It captures recordings of the session.
34
+
35
+ **Implementation Strategy:**
36
+ - **Don't** try to curl complex pages.
37
+ - **Do** dispatch a browser subagent with a clear, self-contained mission.
38
+ - **Pattern:** `Task` -> `browser_subagent` -> `Return Result`
39
+
40
+ ```yaml
41
+ # Conceptual Usage
42
+ - Goal: "Verify the login flow works"
43
+ - Action: Call browser_subagent
44
+ - Prompt: "Go to localhost:3000, log in with user/pass, verify dashboard loads."
45
+ - Result: Subagent returns "Success" or screenshots, main agent continues.
46
+ ```
47
+
48
+ ## 2. Tool Orchestration (Parallel Execution)
49
+
50
+ **Concept:** Maximize throughput by firing multiple non-blocking tools in a single turn.
51
+
52
+ **Why use it?**
53
+ - **Speed:** Reduces round-trips to the LLM.
54
+ - **Efficiency:** Gathers all necessary context at once.
55
+
56
+ **Implementation Strategy:**
57
+ - **Identify Independent Actions:** Can I read 3 files at once? Can I list 2 directories?
58
+ - **Batching:** Instead of Read A -> Wait -> Read B -> Wait, do Read A + Read B.
59
+
60
+ **Example Pattern:**
61
+ ```javascript
62
+ // Parallel Execution Block
63
+ [
64
+ list_dir(path="/src"),
65
+ read_file(path="/package.json"),
66
+ run_command(cmd="git status")
67
+ ]
68
+ // All execute, then you process all outputs in the next step.
69
+ ```
70
+
71
+ ## 3. Workflow Chaining (Composable Modularity)
72
+
73
+ **Concept:** Treat workflows as reusable functions that can call each other.
74
+
75
+ **Why use it?**
76
+ - **DRY (Don't Repeat Yourself):** Define "Fix Type Error" once, use it everywhere.
77
+ - **Complexity Management:** Break a massive "Refactor" task into "Analyze" -> "Plan" -> "Execute" workflows.
78
+
79
+ **Implementation Strategy:**
80
+ - **Meta-Workflows:** A workflow that just orchestrates other workflows.
81
+ - **Input/Output Contracts:** Define what a workflow expects and what it returns (usually artifacts or file changes).
82
+
83
+ **Example Chain:**
84
+ 1. **Trigger:** `/refactor-module`
85
+ 2. **Step 1:** Call `/research` workflow to understand the module.
86
+ 3. **Step 2:** Call `/planning` workflow to generate `implementation_plan.md`.
87
+ 4. **Step 3:** Call `/code-review` workflow to verify the plan.
88
+ 5. **Step 4:** Execute changes.
89
+
90
+ ## Summary: The Agentic Mindset
91
+
92
+ | Linear Thinking | Agentic Thinking |
93
+ |-----------------|------------------|
94
+ | "I will read the file then think." | "I will read 5 related files and key docs simultaneously." |
95
+ | "I will try to curl this page." | "I will deploy a browser agent to interact with the page." |
96
+ | "I will write a huge prompt." | "I will chain 3 specialized workflows to handle this." |