ag-cortex 0.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.
Files changed (162) hide show
  1. package/.agent/commands/test-browser.md +339 -0
  2. package/.agent/rules/00-constitution.md +46 -0
  3. package/.agent/rules/project-rules.md +49 -0
  4. package/.agent/skills/agent-browser/SKILL.md +223 -0
  5. package/.agent/skills/agent-native-architecture/SKILL.md +435 -0
  6. package/.agent/skills/agent-native-architecture/references/action-parity-discipline.md +409 -0
  7. package/.agent/skills/agent-native-architecture/references/agent-execution-patterns.md +467 -0
  8. package/.agent/skills/agent-native-architecture/references/agent-native-testing.md +582 -0
  9. package/.agent/skills/agent-native-architecture/references/architecture-patterns.md +478 -0
  10. package/.agent/skills/agent-native-architecture/references/dynamic-context-injection.md +338 -0
  11. package/.agent/skills/agent-native-architecture/references/files-universal-interface.md +301 -0
  12. package/.agent/skills/agent-native-architecture/references/from-primitives-to-domain-tools.md +359 -0
  13. package/.agent/skills/agent-native-architecture/references/mcp-tool-design.md +506 -0
  14. package/.agent/skills/agent-native-architecture/references/mobile-patterns.md +871 -0
  15. package/.agent/skills/agent-native-architecture/references/product-implications.md +443 -0
  16. package/.agent/skills/agent-native-architecture/references/refactoring-to-prompt-native.md +317 -0
  17. package/.agent/skills/agent-native-architecture/references/self-modification.md +269 -0
  18. package/.agent/skills/agent-native-architecture/references/shared-workspace-architecture.md +680 -0
  19. package/.agent/skills/agent-native-architecture/references/system-prompt-design.md +250 -0
  20. package/.agent/skills/agent-native-reviewer/SKILL.md +246 -0
  21. package/.agent/skills/andrew-kane-gem-writer/SKILL.md +184 -0
  22. package/.agent/skills/andrew-kane-gem-writer/references/database-adapters.md +231 -0
  23. package/.agent/skills/andrew-kane-gem-writer/references/module-organization.md +121 -0
  24. package/.agent/skills/andrew-kane-gem-writer/references/rails-integration.md +183 -0
  25. package/.agent/skills/andrew-kane-gem-writer/references/resources.md +119 -0
  26. package/.agent/skills/andrew-kane-gem-writer/references/testing-patterns.md +261 -0
  27. package/.agent/skills/ankane-readme-writer/SKILL.md +50 -0
  28. package/.agent/skills/architecture-strategist/SKILL.md +52 -0
  29. package/.agent/skills/best-practices-researcher/SKILL.md +100 -0
  30. package/.agent/skills/bug-reproduction-validator/SKILL.md +67 -0
  31. package/.agent/skills/code-simplicity-reviewer/SKILL.md +85 -0
  32. package/.agent/skills/coding-tutor/.claude-plugin/plugin.json +9 -0
  33. package/.agent/skills/coding-tutor/README.md +37 -0
  34. package/.agent/skills/coding-tutor/commands/quiz-me.md +1 -0
  35. package/.agent/skills/coding-tutor/commands/sync-tutorials.md +25 -0
  36. package/.agent/skills/coding-tutor/commands/teach-me.md +1 -0
  37. package/.agent/skills/coding-tutor/skills/coding-tutor/SKILL.md +214 -0
  38. package/.agent/skills/coding-tutor/skills/coding-tutor/scripts/create_tutorial.py +202 -0
  39. package/.agent/skills/coding-tutor/skills/coding-tutor/scripts/index_tutorials.py +203 -0
  40. package/.agent/skills/coding-tutor/skills/coding-tutor/scripts/quiz_priority.py +190 -0
  41. package/.agent/skills/coding-tutor/skills/coding-tutor/scripts/setup_tutorials.py +132 -0
  42. package/.agent/skills/compound-docs/SKILL.md +510 -0
  43. package/.agent/skills/compound-docs/assets/critical-pattern-template.md +34 -0
  44. package/.agent/skills/compound-docs/assets/resolution-template.md +93 -0
  45. package/.agent/skills/compound-docs/references/yaml-schema.md +65 -0
  46. package/.agent/skills/compound-docs/schema.yaml +176 -0
  47. package/.agent/skills/create-agent-skills/SKILL.md +299 -0
  48. package/.agent/skills/create-agent-skills/references/api-security.md +226 -0
  49. package/.agent/skills/create-agent-skills/references/be-clear-and-direct.md +531 -0
  50. package/.agent/skills/create-agent-skills/references/best-practices.md +404 -0
  51. package/.agent/skills/create-agent-skills/references/common-patterns.md +595 -0
  52. package/.agent/skills/create-agent-skills/references/core-principles.md +437 -0
  53. package/.agent/skills/create-agent-skills/references/executable-code.md +175 -0
  54. package/.agent/skills/create-agent-skills/references/iteration-and-testing.md +474 -0
  55. package/.agent/skills/create-agent-skills/references/official-spec.md +185 -0
  56. package/.agent/skills/create-agent-skills/references/recommended-structure.md +168 -0
  57. package/.agent/skills/create-agent-skills/references/skill-structure.md +372 -0
  58. package/.agent/skills/create-agent-skills/references/using-scripts.md +113 -0
  59. package/.agent/skills/create-agent-skills/references/using-templates.md +112 -0
  60. package/.agent/skills/create-agent-skills/references/workflows-and-validation.md +510 -0
  61. package/.agent/skills/create-agent-skills/templates/router-skill.md +73 -0
  62. package/.agent/skills/create-agent-skills/templates/simple-skill.md +33 -0
  63. package/.agent/skills/create-agent-skills/workflows/add-reference.md +96 -0
  64. package/.agent/skills/create-agent-skills/workflows/add-script.md +93 -0
  65. package/.agent/skills/create-agent-skills/workflows/add-template.md +74 -0
  66. package/.agent/skills/create-agent-skills/workflows/add-workflow.md +120 -0
  67. package/.agent/skills/create-agent-skills/workflows/audit-skill.md +138 -0
  68. package/.agent/skills/create-agent-skills/workflows/create-domain-expertise-skill.md +605 -0
  69. package/.agent/skills/create-agent-skills/workflows/create-new-skill.md +191 -0
  70. package/.agent/skills/create-agent-skills/workflows/get-guidance.md +121 -0
  71. package/.agent/skills/create-agent-skills/workflows/upgrade-to-router.md +161 -0
  72. package/.agent/skills/create-agent-skills/workflows/verify-skill.md +204 -0
  73. package/.agent/skills/data-integrity-guardian/SKILL.md +70 -0
  74. package/.agent/skills/data-migration-expert/SKILL.md +97 -0
  75. package/.agent/skills/deployment-verification-agent/SKILL.md +159 -0
  76. package/.agent/skills/design-implementation-reviewer/SKILL.md +85 -0
  77. package/.agent/skills/design-iterator/SKILL.md +197 -0
  78. package/.agent/skills/dhh-rails-reviewer/SKILL.md +45 -0
  79. package/.agent/skills/dhh-rails-style/SKILL.md +184 -0
  80. package/.agent/skills/dhh-rails-style/references/architecture.md +653 -0
  81. package/.agent/skills/dhh-rails-style/references/controllers.md +303 -0
  82. package/.agent/skills/dhh-rails-style/references/frontend.md +510 -0
  83. package/.agent/skills/dhh-rails-style/references/gems.md +266 -0
  84. package/.agent/skills/dhh-rails-style/references/models.md +359 -0
  85. package/.agent/skills/dhh-rails-style/references/testing.md +338 -0
  86. package/.agent/skills/dspy-ruby/SKILL.md +594 -0
  87. package/.agent/skills/dspy-ruby/assets/config-template.rb +359 -0
  88. package/.agent/skills/dspy-ruby/assets/module-template.rb +326 -0
  89. package/.agent/skills/dspy-ruby/assets/signature-template.rb +143 -0
  90. package/.agent/skills/dspy-ruby/references/core-concepts.md +265 -0
  91. package/.agent/skills/dspy-ruby/references/optimization.md +623 -0
  92. package/.agent/skills/dspy-ruby/references/providers.md +305 -0
  93. package/.agent/skills/every-style-editor/SKILL.md +134 -0
  94. package/.agent/skills/every-style-editor/references/EVERY_WRITE_STYLE.md +529 -0
  95. package/.agent/skills/figma-design-sync/SKILL.md +166 -0
  96. package/.agent/skills/file-todos/SKILL.md +251 -0
  97. package/.agent/skills/file-todos/assets/todo-template.md +155 -0
  98. package/.agent/skills/framework-docs-researcher/SKILL.md +83 -0
  99. package/.agent/skills/frontend-design/SKILL.md +42 -0
  100. package/.agent/skills/gemini-imagegen/SKILL.md +237 -0
  101. package/.agent/skills/gemini-imagegen/requirements.txt +2 -0
  102. package/.agent/skills/gemini-imagegen/scripts/compose_images.py +168 -0
  103. package/.agent/skills/gemini-imagegen/scripts/edit_image.py +157 -0
  104. package/.agent/skills/gemini-imagegen/scripts/gemini_images.py +265 -0
  105. package/.agent/skills/gemini-imagegen/scripts/generate_image.py +147 -0
  106. package/.agent/skills/gemini-imagegen/scripts/multi_turn_chat.py +215 -0
  107. package/.agent/skills/git-history-analyzer/SKILL.md +42 -0
  108. package/.agent/skills/git-worktree/SKILL.md +302 -0
  109. package/.agent/skills/git-worktree/scripts/worktree-manager.sh +345 -0
  110. package/.agent/skills/julik-frontend-races-reviewer/SKILL.md +222 -0
  111. package/.agent/skills/kieran-python-reviewer/SKILL.md +104 -0
  112. package/.agent/skills/kieran-rails-reviewer/SKILL.md +86 -0
  113. package/.agent/skills/kieran-typescript-reviewer/SKILL.md +95 -0
  114. package/.agent/skills/lint/SKILL.md +16 -0
  115. package/.agent/skills/pattern-recognition-specialist/SKILL.md +57 -0
  116. package/.agent/skills/performance-oracle/SKILL.md +110 -0
  117. package/.agent/skills/pr-comment-resolver/SKILL.md +69 -0
  118. package/.agent/skills/rclone/SKILL.md +150 -0
  119. package/.agent/skills/rclone/scripts/check_setup.sh +60 -0
  120. package/.agent/skills/repo-research-analyst/SKILL.md +113 -0
  121. package/.agent/skills/security-sentinel/SKILL.md +93 -0
  122. package/.agent/skills/skill-creator/SKILL.md +209 -0
  123. package/.agent/skills/skill-creator/scripts/init_skill.py +304 -0
  124. package/.agent/skills/skill-creator/scripts/package_skill.py +112 -0
  125. package/.agent/skills/skill-creator/scripts/quick_validate.py +72 -0
  126. package/.agent/skills/spec-flow-analyzer/SKILL.md +113 -0
  127. package/.agent/skills/test-agent/SKILL.md +4 -0
  128. package/.agent/workflows/agent-native-audit.md +277 -0
  129. package/.agent/workflows/ask-user-question.md +21 -0
  130. package/.agent/workflows/changelog.md +137 -0
  131. package/.agent/workflows/compound.md +202 -0
  132. package/.agent/workflows/create-agent-skill.md +8 -0
  133. package/.agent/workflows/deepen-plan-research.md +334 -0
  134. package/.agent/workflows/deepen-plan-synthesis.md +182 -0
  135. package/.agent/workflows/deepen-plan.md +79 -0
  136. package/.agent/workflows/feature-video.md +342 -0
  137. package/.agent/workflows/generate-command.md +162 -0
  138. package/.agent/workflows/heal-skill.md +142 -0
  139. package/.agent/workflows/lfg.md +20 -0
  140. package/.agent/workflows/plan-analysis.md +67 -0
  141. package/.agent/workflows/plan-next-steps.md +63 -0
  142. package/.agent/workflows/plan-review.md +33 -0
  143. package/.agent/workflows/plan-synthesis.md +106 -0
  144. package/.agent/workflows/plan.md +49 -0
  145. package/.agent/workflows/report-bug.md +150 -0
  146. package/.agent/workflows/reproduce-bug.md +99 -0
  147. package/.agent/workflows/resolve-parallel.md +34 -0
  148. package/.agent/workflows/resolve-pr-parallel.md +49 -0
  149. package/.agent/workflows/resolve-todo-parallel.md +35 -0
  150. package/.agent/workflows/review-analysis.md +145 -0
  151. package/.agent/workflows/review-synthesis.md +262 -0
  152. package/.agent/workflows/review.md +64 -0
  153. package/.agent/workflows/ship.md +90 -0
  154. package/.agent/workflows/test-command.md +3 -0
  155. package/.agent/workflows/triage.md +310 -0
  156. package/.agent/workflows/work.md +157 -0
  157. package/.agent/workflows/xcode-test.md +332 -0
  158. package/LICENSE +22 -0
  159. package/README.md +49 -0
  160. package/bin/ag-cortex.js +54 -0
  161. package/lib/core.js +165 -0
  162. package/package.json +31 -0
@@ -0,0 +1,332 @@
1
+ ---
2
+ name: xcode-test
3
+ description: Build and test iOS apps on simulator using XcodeBuildMCP
4
+ argument-hint: "[scheme name or 'current' to use default]"
5
+ ---
6
+
7
+ # Xcode Test Command
8
+
9
+ <command_purpose>Build, install, and test iOS apps on the simulator using XcodeBuildMCP. Captures screenshots, logs, and verifies app behavior.</command_purpose>
10
+
11
+ ## Introduction
12
+
13
+ <role>iOS QA Engineer specializing in simulator-based testing</role>
14
+
15
+ This command tests iOS/macOS apps by:
16
+ - Building for simulator
17
+ - Installing and launching the app
18
+ - Taking screenshots of key screens
19
+ - Capturing console logs for errors
20
+ - Supporting human verification for external flows
21
+
22
+ ## Prerequisites
23
+
24
+ <requirements>
25
+ - Xcode installed with command-line tools
26
+ - XcodeBuildMCP server connected
27
+ - Valid Xcode project or workspace
28
+ - At least one iOS Simulator available
29
+ </requirements>
30
+
31
+ ## Main Tasks
32
+
33
+ ### 0. Verify XcodeBuildMCP is Installed
34
+
35
+ <check_mcp_installed>
36
+
37
+ **First, check if XcodeBuildMCP tools are available.**
38
+
39
+ Try calling:
40
+ ```
41
+ mcp__xcodebuildmcp__list_simulators({})
42
+ ```
43
+
44
+ **If the tool is not found or errors:**
45
+
46
+ Tell the user:
47
+ ```markdown
48
+ **XcodeBuildMCP not installed**
49
+
50
+ Please install the XcodeBuildMCP server first:
51
+
52
+ \`\`\`bash
53
+ Install the XcodeBuildMCP server:
54
+ `npx xcodebuildmcp@latest`
55
+ \`\`\`
56
+
57
+ Then restart Antigravity and run `/xcode-test` again.
58
+ ```
59
+
60
+ **Do NOT proceed** until XcodeBuildMCP is confirmed working.
61
+
62
+ </check_mcp_installed>
63
+
64
+ ### 1. Discover Project and Scheme
65
+
66
+ <discover_project>
67
+
68
+ **Find available projects:**
69
+ ```
70
+ mcp__xcodebuildmcp__discover_projs({})
71
+ ```
72
+
73
+ **List schemes for the project:**
74
+ ```
75
+ mcp__xcodebuildmcp__list_schemes({ project_path: "/path/to/Project.xcodeproj" })
76
+ ```
77
+
78
+ **If argument provided:**
79
+ - Use the specified scheme name
80
+ - Or "current" to use the default/last-used scheme
81
+
82
+ </discover_project>
83
+
84
+ ### 2. Boot Simulator
85
+
86
+ <boot_simulator>
87
+
88
+ **List available simulators:**
89
+ ```
90
+ mcp__xcodebuildmcp__list_simulators({})
91
+ ```
92
+
93
+ **Boot preferred simulator (iPhone 15 Pro recommended):**
94
+ ```
95
+ mcp__xcodebuildmcp__boot_simulator({ simulator_id: "[uuid]" })
96
+ ```
97
+
98
+ **Wait for simulator to be ready:**
99
+ Check simulator state before proceeding with installation.
100
+
101
+ </boot_simulator>
102
+
103
+ ### 3. Build the App
104
+
105
+ <build_app>
106
+
107
+ **Build for iOS Simulator:**
108
+ ```
109
+ mcp__xcodebuildmcp__build_ios_sim_app({
110
+ project_path: "/path/to/Project.xcodeproj",
111
+ scheme: "[scheme_name]"
112
+ })
113
+ ```
114
+
115
+ **Handle build failures:**
116
+ - Capture build errors
117
+ - Create P1 todo for each build error
118
+ - Report to user with specific error details
119
+
120
+ **On success:**
121
+ - Note the built app path for installation
122
+ - Proceed to installation step
123
+
124
+ </build_app>
125
+
126
+ ### 4. Install and Launch
127
+
128
+ <install_launch>
129
+
130
+ **Install app on simulator:**
131
+ ```
132
+ mcp__xcodebuildmcp__install_app_on_simulator({
133
+ app_path: "/path/to/built/App.app",
134
+ simulator_id: "[uuid]"
135
+ })
136
+ ```
137
+
138
+ **Launch the app:**
139
+ ```
140
+ mcp__xcodebuildmcp__launch_app_on_simulator({
141
+ bundle_id: "[app.bundle.id]",
142
+ simulator_id: "[uuid]"
143
+ })
144
+ ```
145
+
146
+ **Start capturing logs:**
147
+ ```
148
+ mcp__xcodebuildmcp__capture_sim_logs({
149
+ simulator_id: "[uuid]",
150
+ bundle_id: "[app.bundle.id]"
151
+ })
152
+ ```
153
+
154
+ </install_launch>
155
+
156
+ ### 5. Test Key Screens
157
+
158
+ <test_screens>
159
+
160
+ For each key screen in the app:
161
+
162
+ **Take screenshot:**
163
+ ```
164
+ mcp__xcodebuildmcp__take_screenshot({
165
+ simulator_id: "[uuid]",
166
+ filename: "screen-[name].png"
167
+ })
168
+ ```
169
+
170
+ **Review screenshot for:**
171
+ - UI elements rendered correctly
172
+ - No error messages visible
173
+ - Expected content displayed
174
+ - Layout looks correct
175
+
176
+ **Check logs for errors:**
177
+ ```
178
+ mcp__xcodebuildmcp__get_sim_logs({ simulator_id: "[uuid]" })
179
+ ```
180
+
181
+ Look for:
182
+ - Crashes
183
+ - Exceptions
184
+ - Error-level log messages
185
+ - Failed network requests
186
+
187
+ </test_screens>
188
+
189
+ ### 6. Human Verification (When Required)
190
+
191
+ <human_verification>
192
+
193
+ Pause for human input when testing touches:
194
+
195
+ | Flow Type | What to Ask |
196
+ |-----------|-------------|
197
+ | Sign in with Apple | "Please complete Sign in with Apple on the simulator" |
198
+ | Push notifications | "Send a test push and confirm it appears" |
199
+ | In-app purchases | "Complete a sandbox purchase" |
200
+ | Camera/Photos | "Grant permissions and verify camera works" |
201
+ | Location | "Allow location access and verify map updates" |
202
+
203
+ Use AskUserQuestion:
204
+ ```markdown
205
+ **Human Verification Needed**
206
+
207
+ This test requires [flow type]. Please:
208
+ 1. [Action to take on simulator]
209
+ 2. [What to verify]
210
+
211
+ Did it work correctly?
212
+ 1. Yes - continue testing
213
+ 2. No - describe the issue
214
+ ```
215
+
216
+ </human_verification>
217
+
218
+ ### 7. Handle Failures
219
+
220
+ <failure_handling>
221
+
222
+ When a test fails:
223
+
224
+ 1. **Document the failure:**
225
+ - Take screenshot of error state
226
+ - Capture console logs
227
+ - Note reproduction steps
228
+
229
+ 2. **Ask user how to proceed:**
230
+ ```markdown
231
+ **Test Failed: [screen/feature]**
232
+
233
+ Issue: [description]
234
+ Logs: [relevant error messages]
235
+
236
+ How to proceed?
237
+ 1. Fix now - I'll help debug and fix
238
+ 2. Create todo - Add to todos/ for later
239
+ 3. Skip - Continue testing other screens
240
+ ```
241
+
242
+ 3. **If "Fix now":**
243
+ - Investigate the issue in code
244
+ - Propose a fix
245
+ - Rebuild and retest
246
+
247
+ 4. **If "Create todo":**
248
+ - Create `{id}-pending-p1-xcode-{description}.md`
249
+ - Continue testing
250
+
251
+ </failure_handling>
252
+
253
+ ### 8. Test Summary
254
+
255
+ <test_summary>
256
+
257
+ After all tests complete, present summary:
258
+
259
+ ```markdown
260
+ ## 📱 Xcode Test Results
261
+
262
+ **Project:** [project name]
263
+ **Scheme:** [scheme name]
264
+ **Simulator:** [simulator name]
265
+
266
+ ### Build: ✅ Success / ❌ Failed
267
+
268
+ ### Screens Tested: [count]
269
+
270
+ | Screen | Status | Notes |
271
+ |--------|--------|-------|
272
+ | Launch | ✅ Pass | |
273
+ | Home | ✅ Pass | |
274
+ | Settings | ❌ Fail | Crash on tap |
275
+ | Profile | ⏭️ Skip | Requires login |
276
+
277
+ ### Console Errors: [count]
278
+ - [List any errors found]
279
+
280
+ ### Human Verifications: [count]
281
+ - Sign in with Apple: ✅ Confirmed
282
+ - Push notifications: ✅ Confirmed
283
+
284
+ ### Failures: [count]
285
+ - Settings screen - crash on navigation
286
+
287
+ ### Created Todos: [count]
288
+ - `006-pending-p1-xcode-settings-crash.md`
289
+
290
+ ### Result: [PASS / FAIL / PARTIAL]
291
+ ```
292
+
293
+ </test_summary>
294
+
295
+ ### 9. Cleanup
296
+
297
+ <cleanup>
298
+
299
+ After testing:
300
+
301
+ **Stop log capture:**
302
+ ```
303
+ mcp__xcodebuildmcp__stop_log_capture({ simulator_id: "[uuid]" })
304
+ ```
305
+
306
+ **Optionally shut down simulator:**
307
+ ```
308
+ mcp__xcodebuildmcp__shutdown_simulator({ simulator_id: "[uuid]" })
309
+ ```
310
+
311
+ </cleanup>
312
+
313
+ ## Quick Usage Examples
314
+
315
+ ```bash
316
+ # Test with default scheme
317
+ /xcode-test
318
+
319
+ # Test specific scheme
320
+ /xcode-test MyApp-Debug
321
+
322
+ # Test after making changes
323
+ /xcode-test current
324
+ ```
325
+
326
+ ## Integration with /review
327
+
328
+ When reviewing PRs that touch iOS code, the `/review` command can spawn this as a subagent:
329
+
330
+ ```
331
+ Task general-purpose("Run /xcode-test for scheme [name]. Build, install on simulator, test key screens, check for crashes.")
332
+ ```
package/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Marcos del Cristo
4
+ Copyright (c) 2025 Kieran Klaassen
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in all
14
+ copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,49 @@
1
+ # Antigravity Cortex
2
+
3
+ The central "brain" and standard library for Antigravity-powered agents. This package distributes shared **Skills**, **Workflows**, and **Rules** that are injected into project workspaces to ensure consistent, high-quality engineering.
4
+
5
+ ## Architecture
6
+
7
+ This package manages the `.agent/` directory in your project using a **Manifest-based Sync** system.
8
+
9
+ * **Skills** (`.agent/skills/`): Capabilities the agent can pull in on demand (e.g., `git-worktree`, `data-migration-expert`).
10
+ * **Workflows** (`.agent/workflows/`): Step-by-step guides for specific tasks (e.g., `/deploy`, `/plan`).
11
+ * **Rules** (`.agent/rules/`): Persistent context and formatting rules (e.g., `00-constitution.md`).
12
+ * **Browser Agent**: Includes `agent-browser` as a native dependency.
13
+
14
+ ## Installation
15
+
16
+ To add Antigravity Cortex to your project:
17
+
18
+ ```bash
19
+ # 1. Install the package (Dev Dependency recommended)
20
+ npm install -D ag-cortex
21
+
22
+ # 2. Initialize the brain
23
+ # This copies the assets to your .agent/ directory and creates a tracking manifest.
24
+ npx ag-cortex install
25
+ ```
26
+
27
+ ## Usage
28
+
29
+ ### Updating Assets
30
+ When a new version of `ag-cortex` is released, update your local assets safely:
31
+
32
+ ```bash
33
+ # 1. Update the package
34
+ npm install -D ag-cortex@latest
35
+
36
+ # 2. Sync the assets
37
+ # This will update modified files and prune orphaned files (keeping your custom files safe).
38
+ npx ag-cortex update
39
+ ```
40
+
41
+ ### Checking Status
42
+ Verify your installation and dependencies:
43
+
44
+ ```bash
45
+ npx ag-cortex doctor
46
+ ```
47
+
48
+ ---
49
+ *Forked from [Compound Engineering Plugin](https://github.com/EveryInc/compound-engineering-plugin)*.
@@ -0,0 +1,54 @@
1
+ #!/usr/bin/env node
2
+
3
+ const { program } = require('commander');
4
+ const { install, update, doctor } = require('../lib/core');
5
+
6
+ // Use dynamic import for chalk since v5 is ESM-only
7
+ // Or use a wrapper. For simplicity in this script, we'll try standard require.
8
+ // If chalk v5+ is pure ESM, we might need to stick to chalk@4 or use dynamic import.
9
+ // Let's use dynamic import pattern or fix chalk version in package.json to ^4.1.2 if we want CommonJS.
10
+ // However, let's try to be modern. We'll wrap in an async IIFE.
11
+
12
+ (async () => {
13
+ const chalk = (await import('chalk')).default;
14
+
15
+ console.log(chalk.bold.blue('🔮 Antigravity Cortex CLI'));
16
+
17
+ program
18
+ .name('ag-cortex')
19
+ .description('Manage Antigravity skills, rules, and workflows')
20
+ .version('0.1.0');
21
+
22
+ program
23
+ .command('install')
24
+ .description('Install Cortex assets into the current project')
25
+ .action(async () => {
26
+ try {
27
+ await install();
28
+ } catch (error) {
29
+ console.error(chalk.red('Installation failed:'), error.message);
30
+ process.exit(1);
31
+ }
32
+ });
33
+
34
+ program
35
+ .command('update')
36
+ .description('Update Cortex assets and prune orphaned files')
37
+ .action(async () => {
38
+ try {
39
+ await update();
40
+ } catch (error) {
41
+ console.error(chalk.red('Update failed:'), error.message);
42
+ process.exit(1);
43
+ }
44
+ });
45
+
46
+ program
47
+ .command('doctor')
48
+ .description('Verify installation and dependencies')
49
+ .action(async () => {
50
+ await doctor();
51
+ });
52
+
53
+ program.parse();
54
+ })();
package/lib/core.js ADDED
@@ -0,0 +1,165 @@
1
+ const fs = require('fs-extra');
2
+ const path = require('path');
3
+ const { execSync } = require('child_process');
4
+
5
+ // Paths
6
+ const PKG_ROOT = path.resolve(__dirname, '..');
7
+ const SOURCE_ASSETS_DIR = path.join(PKG_ROOT, '.agent');
8
+ // When installed in a user project, we assume we are running from node_modules,
9
+ // so the target project root is likely process.cwd()
10
+ const TARGET_ROOT = process.cwd();
11
+ const TARGET_AGENT_DIR = path.join(TARGET_ROOT, '.agent');
12
+ const MANIFEST_FILE = path.join(TARGET_AGENT_DIR, '.ag-cortex-manifest.json');
13
+
14
+ /**
15
+ * Get all files in a directory recursively, returning paths relative to the base dir.
16
+ */
17
+ async function walk(dir, baseDir = dir) {
18
+ let results = [];
19
+ try {
20
+ const list = await fs.readdir(dir);
21
+ for (const file of list) {
22
+ const filePath = path.join(dir, file);
23
+ const stat = await fs.stat(filePath);
24
+ if (stat && stat.isDirectory()) {
25
+ results = results.concat(await walk(filePath, baseDir));
26
+ } else {
27
+ results.push(path.relative(baseDir, filePath));
28
+ }
29
+ }
30
+ } catch (e) {
31
+ if (e.code === 'ENOENT') return [];
32
+ if (e.code === 'EACCES') {
33
+ console.error(chalk.red(` ❌ Permission error accessing: ${dir}`));
34
+ }
35
+ throw e;
36
+ }
37
+ return results;
38
+ }
39
+
40
+ async function install() {
41
+ const chalk = (await import('chalk')).default;
42
+ console.log(chalk.blue(`📦 Installing Cortex assets to ${TARGET_AGENT_DIR}...`));
43
+
44
+ // 1. Ensure source exists
45
+ if (!await fs.pathExists(SOURCE_ASSETS_DIR)) {
46
+ throw new Error(`Source assets not found at ${SOURCE_ASSETS_DIR}. Are you running from the package?`);
47
+ }
48
+
49
+ // 2. Get list of assets to install
50
+ const sourceFiles = await walk(SOURCE_ASSETS_DIR);
51
+
52
+ // 3. Prepare Manifest
53
+ const newManifest = {
54
+ files: sourceFiles,
55
+ updatedAt: new Date().toISOString(),
56
+ version: require('../package.json').version
57
+ };
58
+
59
+ // 4. Copy Files
60
+ for (const file of sourceFiles) {
61
+ const srcPath = path.join(SOURCE_ASSETS_DIR, file);
62
+ const destPath = path.join(TARGET_AGENT_DIR, file);
63
+
64
+ await fs.ensureDir(path.dirname(destPath));
65
+ await fs.copy(srcPath, destPath, { overwrite: true });
66
+ }
67
+ console.log(chalk.green(` ✅ Installed ${sourceFiles.length} files.`));
68
+
69
+ console.log(chalk.green(` ✅ Installed ${sourceFiles.length} files.`));
70
+
71
+ // 5. Write Manifest
72
+ await fs.writeJson(MANIFEST_FILE, newManifest, { spaces: 2 });
73
+ console.log(chalk.blue(` 📄 Manifest written to ${MANIFEST_FILE}`));
74
+
75
+ // 6. Setup Agent Browser
76
+ const os = require('os');
77
+ console.log(chalk.blue(`🌐 Setting up Agent Browser...`));
78
+
79
+ const isLinux = os.platform() === 'linux';
80
+
81
+ try {
82
+ if (isLinux) {
83
+ console.log(chalk.yellow(` 🐧 Linux detected: Attempting to install system dependencies...`));
84
+ console.log(chalk.gray(` (If this fails, you may need to run with sudo)`));
85
+ execSync('npx agent-browser install --with-deps', { stdio: 'inherit', cwd: TARGET_ROOT });
86
+ } else {
87
+ execSync('npx agent-browser install', { stdio: 'inherit', cwd: TARGET_ROOT });
88
+ }
89
+ console.log(chalk.green(` ✅ Agent Browser installed.`));
90
+ } catch (e) {
91
+ if (isLinux) {
92
+ console.warn(chalk.yellow(` ⚠️ Automatic setup failed. You likely need sudo for system dependencies.`));
93
+ console.warn(chalk.bold(` Please run: sudo npx agent-browser install --with-deps`));
94
+ } else {
95
+ console.warn(chalk.yellow(` ⚠️ Agent Browser setup had issues. Try running: npx agent-browser install --with-deps`));
96
+ }
97
+ }
98
+ }
99
+
100
+ async function update() {
101
+ const chalk = (await import('chalk')).default;
102
+ console.log(chalk.blue(`🔄 Updating Cortex assets...`));
103
+
104
+ // 1. Load Old Manifest
105
+ let oldManifest = { files: [] };
106
+ if (await fs.pathExists(MANIFEST_FILE)) {
107
+ try {
108
+ oldManifest = await fs.readJson(MANIFEST_FILE);
109
+ console.log(chalk.gray(` Found existing manifest (${oldManifest.files.length} tracked files)`));
110
+ } catch (e) {
111
+ console.warn(chalk.yellow(` Warning: Could not read manifest. Assuming clean slate.`));
112
+ }
113
+ } else {
114
+ console.log(chalk.yellow(` No manifest found. Treating as clean install (no pruning).`));
115
+ }
116
+
117
+ // 2. Get New Assets List
118
+ if (!await fs.pathExists(SOURCE_ASSETS_DIR)) throw new Error('Source assets missing.');
119
+ const newFiles = await walk(SOURCE_ASSETS_DIR);
120
+ const newFilesSet = new Set(newFiles);
121
+
122
+ // 3. Prune Orphans
123
+ // Orphan = File in oldManifest BUT NOT in newFiles
124
+ let prunedCount = 0;
125
+ for (const oldFile of oldManifest.files) {
126
+ if (!newFilesSet.has(oldFile)) {
127
+ // SECURITY: Prevent path traversal
128
+ if (oldFile.includes('..') || path.isAbsolute(oldFile)) {
129
+ console.warn(chalk.red(` ⚠️ Security Warning: Skipping pruning of unsafe path: ${oldFile}`));
130
+ continue;
131
+ }
132
+
133
+ const orphanPath = path.join(TARGET_AGENT_DIR, oldFile);
134
+ if (await fs.pathExists(orphanPath)) {
135
+ await fs.remove(orphanPath);
136
+ console.log(chalk.red(` 🗑️ Pruned: ${oldFile}`));
137
+ prunedCount++;
138
+ }
139
+ }
140
+ }
141
+ if (prunedCount > 0) console.log(chalk.green(` ✅ Pruned ${prunedCount} orphaned files.`));
142
+
143
+ // 4. Install/Update (Overwrite)
144
+ // Run install to handle the copy and manifest update
145
+ await install();
146
+ }
147
+
148
+ async function doctor() {
149
+ const chalk = (await import('chalk')).default;
150
+ console.log(chalk.bold('🩺 Cortex Doctor'));
151
+
152
+ // Check agent-browser
153
+ try {
154
+ const packageJson = require('../package.json');
155
+ const browserVersion = packageJson.dependencies['agent-browser'] || 'unknown';
156
+ console.log(` ✅ agent-browser dependency: ${browserVersion}`);
157
+ } catch (e) {
158
+ console.log(chalk.red(` ❌ agent-browser check failed: ${e.message}`));
159
+ }
160
+
161
+ console.log(` ✅ Environment: Node ${process.version}`);
162
+ console.log(` ✅ Package Source: ${PKG_ROOT}`);
163
+ }
164
+
165
+ module.exports = { install, update, doctor };
package/package.json ADDED
@@ -0,0 +1,31 @@
1
+ {
2
+ "name": "ag-cortex",
3
+ "version": "0.1.0",
4
+ "description": "Antigravity Cortex - Agentic Workflow Distribution. The central brain and standard library for Antigravity-powered agents.",
5
+ "bin": {
6
+ "ag-cortex": "./bin/ag-cortex.js"
7
+ },
8
+ "files": [
9
+ "bin",
10
+ "lib",
11
+ ".agent"
12
+ ],
13
+ "scripts": {
14
+ "test": "echo \"Error: no test specified\" && exit 1"
15
+ },
16
+ "keywords": [
17
+ "antigravity",
18
+ "cortex",
19
+ "agent",
20
+ "workflows",
21
+ "skills"
22
+ ],
23
+ "author": "Marcos del Cristo",
24
+ "license": "MIT",
25
+ "dependencies": {
26
+ "agent-browser": "^0.8.4",
27
+ "chalk": "^5.0.0",
28
+ "commander": "^11.0.0",
29
+ "fs-extra": "^11.0.0"
30
+ }
31
+ }