foliko 1.0.74 → 1.0.76

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 (238) hide show
  1. package/.agent/.shared/ui-ux-pro-max/data/charts.csv +26 -0
  2. package/.agent/.shared/ui-ux-pro-max/data/colors.csv +97 -0
  3. package/.agent/.shared/ui-ux-pro-max/data/icons.csv +101 -0
  4. package/.agent/.shared/ui-ux-pro-max/data/landing.csv +31 -0
  5. package/.agent/.shared/ui-ux-pro-max/data/products.csv +97 -0
  6. package/.agent/.shared/ui-ux-pro-max/data/prompts.csv +24 -0
  7. package/.agent/.shared/ui-ux-pro-max/data/react-performance.csv +45 -0
  8. package/.agent/.shared/ui-ux-pro-max/data/stacks/flutter.csv +53 -0
  9. package/.agent/.shared/ui-ux-pro-max/data/stacks/html-tailwind.csv +56 -0
  10. package/.agent/.shared/ui-ux-pro-max/data/stacks/jetpack-compose.csv +53 -0
  11. package/.agent/.shared/ui-ux-pro-max/data/stacks/nextjs.csv +53 -0
  12. package/.agent/.shared/ui-ux-pro-max/data/stacks/nuxt-ui.csv +51 -0
  13. package/.agent/.shared/ui-ux-pro-max/data/stacks/nuxtjs.csv +59 -0
  14. package/.agent/.shared/ui-ux-pro-max/data/stacks/react-native.csv +52 -0
  15. package/.agent/.shared/ui-ux-pro-max/data/stacks/react.csv +54 -0
  16. package/.agent/.shared/ui-ux-pro-max/data/stacks/shadcn.csv +61 -0
  17. package/.agent/.shared/ui-ux-pro-max/data/stacks/svelte.csv +54 -0
  18. package/.agent/.shared/ui-ux-pro-max/data/stacks/swiftui.csv +51 -0
  19. package/.agent/.shared/ui-ux-pro-max/data/stacks/vue.csv +50 -0
  20. package/.agent/.shared/ui-ux-pro-max/data/styles.csv +59 -0
  21. package/.agent/.shared/ui-ux-pro-max/data/typography.csv +58 -0
  22. package/.agent/.shared/ui-ux-pro-max/data/ui-reasoning.csv +101 -0
  23. package/.agent/.shared/ui-ux-pro-max/data/ux-guidelines.csv +100 -0
  24. package/.agent/.shared/ui-ux-pro-max/data/web-interface.csv +31 -0
  25. package/.agent/.shared/ui-ux-pro-max/scripts/__pycache__/core.cpython-313.pyc +0 -0
  26. package/.agent/.shared/ui-ux-pro-max/scripts/__pycache__/design_system.cpython-313.pyc +0 -0
  27. package/.agent/.shared/ui-ux-pro-max/scripts/core.py +258 -0
  28. package/.agent/.shared/ui-ux-pro-max/scripts/design_system.py +1067 -0
  29. package/.agent/.shared/ui-ux-pro-max/scripts/search.py +106 -0
  30. package/.agent/ARCHITECTURE.md +288 -0
  31. package/.agent/agents/ambient-agent.md +57 -0
  32. package/.agent/agents/debugger.md +55 -0
  33. package/.agent/agents/email-assistant.md +49 -0
  34. package/.agent/agents/file-manager.md +42 -0
  35. package/.agent/agents/python-developer.md +60 -0
  36. package/.agent/agents/scheduler.md +59 -0
  37. package/.agent/agents/web-developer.md +45 -0
  38. package/.agent/data/default.json +29 -0
  39. package/.agent/data/plugins-state.json +255 -0
  40. package/.agent/mcp_config.json +4 -0
  41. package/.agent/mcp_config_updated.json +12 -0
  42. package/.agent/plugins.json +5 -0
  43. package/.agent/rules/GEMINI.md +273 -0
  44. package/.agent/rules/allow-rule.md +77 -0
  45. package/.agent/rules/log-rule.md +83 -0
  46. package/.agent/rules/security-rule.md +93 -0
  47. package/.agent/scripts/auto_preview.py +148 -0
  48. package/.agent/scripts/checklist.py +217 -0
  49. package/.agent/scripts/session_manager.py +120 -0
  50. package/.agent/scripts/verify_all.py +327 -0
  51. package/.agent/skills/api-patterns/SKILL.md +81 -0
  52. package/.agent/skills/api-patterns/api-style.md +42 -0
  53. package/.agent/skills/api-patterns/auth.md +24 -0
  54. package/.agent/skills/api-patterns/documentation.md +26 -0
  55. package/.agent/skills/api-patterns/graphql.md +41 -0
  56. package/.agent/skills/api-patterns/rate-limiting.md +31 -0
  57. package/.agent/skills/api-patterns/response.md +37 -0
  58. package/.agent/skills/api-patterns/rest.md +40 -0
  59. package/.agent/skills/api-patterns/scripts/api_validator.py +211 -0
  60. package/.agent/skills/api-patterns/security-testing.md +122 -0
  61. package/.agent/skills/api-patterns/trpc.md +41 -0
  62. package/.agent/skills/api-patterns/versioning.md +22 -0
  63. package/.agent/skills/app-builder/SKILL.md +75 -0
  64. package/.agent/skills/app-builder/agent-coordination.md +71 -0
  65. package/.agent/skills/app-builder/feature-building.md +53 -0
  66. package/.agent/skills/app-builder/project-detection.md +34 -0
  67. package/.agent/skills/app-builder/scaffolding.md +118 -0
  68. package/.agent/skills/app-builder/tech-stack.md +40 -0
  69. package/.agent/skills/app-builder/templates/SKILL.md +39 -0
  70. package/.agent/skills/app-builder/templates/astro-static/TEMPLATE.md +76 -0
  71. package/.agent/skills/app-builder/templates/chrome-extension/TEMPLATE.md +92 -0
  72. package/.agent/skills/app-builder/templates/cli-tool/TEMPLATE.md +88 -0
  73. package/.agent/skills/app-builder/templates/electron-desktop/TEMPLATE.md +88 -0
  74. package/.agent/skills/app-builder/templates/express-api/TEMPLATE.md +83 -0
  75. package/.agent/skills/app-builder/templates/flutter-app/TEMPLATE.md +90 -0
  76. package/.agent/skills/app-builder/templates/monorepo-turborepo/TEMPLATE.md +90 -0
  77. package/.agent/skills/app-builder/templates/nextjs-fullstack/TEMPLATE.md +122 -0
  78. package/.agent/skills/app-builder/templates/nextjs-saas/TEMPLATE.md +122 -0
  79. package/.agent/skills/app-builder/templates/nextjs-static/TEMPLATE.md +169 -0
  80. package/.agent/skills/app-builder/templates/nuxt-app/TEMPLATE.md +134 -0
  81. package/.agent/skills/app-builder/templates/python-fastapi/TEMPLATE.md +83 -0
  82. package/.agent/skills/app-builder/templates/react-native-app/TEMPLATE.md +119 -0
  83. package/.agent/skills/architecture/SKILL.md +55 -0
  84. package/.agent/skills/architecture/context-discovery.md +43 -0
  85. package/.agent/skills/architecture/examples.md +94 -0
  86. package/.agent/skills/architecture/pattern-selection.md +68 -0
  87. package/.agent/skills/architecture/patterns-reference.md +50 -0
  88. package/.agent/skills/architecture/trade-off-analysis.md +77 -0
  89. package/.agent/skills/clean-code/SKILL.md +201 -0
  90. package/.agent/skills/doc.md +177 -0
  91. package/.agent/skills/frontend-design/SKILL.md +418 -0
  92. package/.agent/skills/frontend-design/animation-guide.md +331 -0
  93. package/.agent/skills/frontend-design/color-system.md +311 -0
  94. package/.agent/skills/frontend-design/decision-trees.md +418 -0
  95. package/.agent/skills/frontend-design/motion-graphics.md +306 -0
  96. package/.agent/skills/frontend-design/scripts/accessibility_checker.py +183 -0
  97. package/.agent/skills/frontend-design/scripts/ux_audit.py +722 -0
  98. package/.agent/skills/frontend-design/typography-system.md +345 -0
  99. package/.agent/skills/frontend-design/ux-psychology.md +1116 -0
  100. package/.agent/skills/frontend-design/visual-effects.md +383 -0
  101. package/.agent/skills/i18n-localization/SKILL.md +154 -0
  102. package/.agent/skills/i18n-localization/scripts/i18n_checker.py +241 -0
  103. package/.agent/skills/mcp-builder/SKILL.md +176 -0
  104. package/.agent/skills/web-design-guidelines/SKILL.md +57 -0
  105. package/.agent/workflows/brainstorm.md +113 -0
  106. package/.agent/workflows/create.md +59 -0
  107. package/.agent/workflows/debug.md +103 -0
  108. package/.agent/workflows/deploy.md +176 -0
  109. package/.agent/workflows/enhance.md +63 -0
  110. package/.agent/workflows/orchestrate.md +237 -0
  111. package/.agent/workflows/plan.md +89 -0
  112. package/.agent/workflows/preview.md +81 -0
  113. package/.agent/workflows/simple-test.md +42 -0
  114. package/.agent/workflows/status.md +86 -0
  115. package/.agent/workflows/structured-orchestrate.md +180 -0
  116. package/.agent/workflows/test.md +144 -0
  117. package/.agent/workflows/ui-ux-pro-max.md +296 -0
  118. package/.claude/settings.local.json +11 -1
  119. package/.editorconfig +56 -0
  120. package/.husky/pre-commit +4 -0
  121. package/.lintstagedrc +7 -0
  122. package/.prettierignore +29 -0
  123. package/.prettierrc +11 -0
  124. package/CLAUDE.md +2 -0
  125. package/README.md +64 -55
  126. package/SPEC.md +102 -61
  127. package/cli/bin/foliko.js +11 -11
  128. package/cli/src/commands/chat.js +143 -141
  129. package/cli/src/commands/list.js +93 -90
  130. package/cli/src/index.js +75 -75
  131. package/cli/src/ui/chat-ui.js +201 -199
  132. package/cli/src/utils/ansi.js +40 -40
  133. package/cli/src/utils/markdown.js +292 -296
  134. package/docker-compose.yml +1 -1
  135. package/docs/ai-sdk-optimization.md +655 -643
  136. package/docs/features.md +80 -80
  137. package/docs/quick-reference.md +49 -46
  138. package/docs/user-manual.md +411 -380
  139. package/examples/ambient-example.js +194 -196
  140. package/examples/basic.js +50 -45
  141. package/examples/bootstrap.js +121 -112
  142. package/examples/mcp-example.js +19 -16
  143. package/examples/skill-example.js +20 -20
  144. package/examples/test-chat.js +137 -135
  145. package/examples/test-mcp.js +85 -79
  146. package/examples/test-reload.js +59 -61
  147. package/examples/test-telegram.js +50 -50
  148. package/examples/test-tg-bot.js +45 -42
  149. package/examples/test-tg-simple.js +47 -46
  150. package/examples/test-tg.js +62 -62
  151. package/examples/test-think.js +43 -37
  152. package/examples/test-web-plugin.js +103 -98
  153. package/examples/test-weixin-feishu.js +103 -100
  154. package/examples/workflow.js +158 -158
  155. package/package.json +37 -3
  156. package/plugins/ai-plugin.js +102 -100
  157. package/plugins/ambient-agent/EventWatcher.js +113 -0
  158. package/plugins/ambient-agent/ExplorerLoop.js +640 -0
  159. package/plugins/ambient-agent/GoalManager.js +197 -0
  160. package/plugins/ambient-agent/Reflector.js +95 -0
  161. package/plugins/ambient-agent/StateStore.js +90 -0
  162. package/plugins/ambient-agent/constants.js +101 -0
  163. package/plugins/ambient-agent/index.js +579 -0
  164. package/plugins/audit-plugin.js +187 -187
  165. package/plugins/default-plugins.js +662 -649
  166. package/plugins/email/constants.js +64 -0
  167. package/plugins/email/handlers.js +461 -0
  168. package/plugins/email/index.js +278 -0
  169. package/plugins/email/monitor.js +269 -0
  170. package/plugins/email/parser.js +138 -0
  171. package/plugins/email/reply.js +151 -0
  172. package/plugins/email/utils.js +124 -0
  173. package/plugins/feishu-plugin.js +481 -477
  174. package/plugins/file-system-plugin.js +826 -476
  175. package/plugins/install-plugin.js +199 -197
  176. package/plugins/python-executor-plugin.js +367 -365
  177. package/plugins/python-plugin-loader.js +481 -479
  178. package/plugins/rules-plugin.js +294 -292
  179. package/plugins/scheduler-plugin.js +691 -689
  180. package/plugins/session-plugin.js +369 -367
  181. package/plugins/shell-executor-plugin.js +197 -197
  182. package/plugins/storage-plugin.js +240 -238
  183. package/plugins/subagent-plugin.js +845 -785
  184. package/plugins/telegram-plugin.js +482 -475
  185. package/plugins/think-plugin.js +345 -343
  186. package/plugins/tools-plugin.js +196 -194
  187. package/plugins/web-plugin.js +606 -604
  188. package/plugins/weixin-plugin.js +545 -538
  189. package/reports/system-health-report-20260401.md +79 -0
  190. package/skills/ambient-agent/SKILL.md +49 -39
  191. package/skills/foliko-dev/AGENTS.md +64 -61
  192. package/skills/foliko-dev/SKILL.md +125 -119
  193. package/skills/mcp-usage/SKILL.md +19 -17
  194. package/skills/python-plugin-dev/SKILL.md +16 -15
  195. package/skills/skill-guide/SKILL.md +12 -12
  196. package/skills/subagent-guide/SKILL.md +237 -0
  197. package/skills/workflow-guide/SKILL.md +90 -45
  198. package/skills/workflow-troubleshooting/DEBUGGING.md +36 -21
  199. package/skills/workflow-troubleshooting/SKILL.md +156 -79
  200. package/src/capabilities/index.js +11 -11
  201. package/src/capabilities/skill-manager.js +609 -595
  202. package/src/capabilities/workflow-engine.js +1109 -1195
  203. package/src/core/agent-chat.js +882 -735
  204. package/src/core/agent.js +892 -688
  205. package/src/core/framework.js +465 -431
  206. package/src/core/index.js +19 -19
  207. package/src/core/plugin-base.js +219 -219
  208. package/src/core/plugin-manager.js +863 -767
  209. package/src/core/provider.js +114 -111
  210. package/src/core/sub-agent-config.js +264 -0
  211. package/src/core/system-prompt-builder.js +120 -0
  212. package/src/core/tool-registry.js +517 -134
  213. package/src/core/tool-router.js +297 -216
  214. package/src/executors/executor-base.js +12 -12
  215. package/src/executors/mcp-executor.js +741 -729
  216. package/src/index.js +25 -37
  217. package/src/utils/circuit-breaker.js +301 -0
  218. package/src/utils/error-boundary.js +363 -0
  219. package/src/utils/error.js +374 -0
  220. package/src/utils/event-emitter.js +97 -97
  221. package/src/utils/id.js +133 -0
  222. package/src/utils/index.js +217 -3
  223. package/src/utils/logger.js +181 -0
  224. package/src/utils/plugin-helpers.js +90 -0
  225. package/src/utils/retry.js +122 -0
  226. package/src/utils/sandbox.js +292 -0
  227. package/test/tool-registry-validation.test.js +218 -0
  228. package/test_report.md +70 -0
  229. package/website/docs/api.html +169 -107
  230. package/website/docs/configuration.html +296 -144
  231. package/website/docs/plugin-development.html +154 -85
  232. package/website/docs/project-structure.html +110 -109
  233. package/website/docs/skill-development.html +117 -61
  234. package/website/index.html +209 -205
  235. package/website/script.js +136 -133
  236. package/website/styles.css +1 -1
  237. package/plugins/ambient-agent-plugin.js +0 -1565
  238. package/plugins/email.js +0 -1142
@@ -0,0 +1,77 @@
1
+ ---
2
+ id: allow-rule-001
3
+ name: "开发环境例外规则"
4
+ description: "在开发环境中允许特定敏感文件写入"
5
+ version: "1.0.0"
6
+ author: "Development Team"
7
+
8
+ # 触发条件
9
+ trigger:
10
+ type: "on_tool_call"
11
+ conditions:
12
+ - tool_name: "file_write"
13
+ - path_matches: "**/.env.local"
14
+ scope: "global"
15
+
16
+ # 优先级和冲突解决
17
+ priority: 150 # 比安全规则更高的优先级
18
+ conflict_resolution: "allow"
19
+ override_priority: true # 覆盖更高优先级的阻止规则
20
+
21
+ # 执行动作
22
+ steps:
23
+ - type: "allow"
24
+ name: "允许开发环境配置"
25
+ reason: "开发环境需要.local配置文件"
26
+ conditions:
27
+ - type: "javascript"
28
+ expression: "ctx.variables.environment === 'development'"
29
+
30
+ # 验证条件
31
+ conditions:
32
+ - type: "regex"
33
+ field: "tool.args.path"
34
+ pattern: "\\.local$"
35
+ - type: "javascript"
36
+ expression: "ctx.variables.environment === 'development' || ctx.variables.environment === 'test'"
37
+
38
+ # 变量和上下文
39
+ variables:
40
+ environment: "development"
41
+ allowed_users: ["developer", "tester", "admin"]
42
+
43
+ # 日志和监控
44
+ logging:
45
+ level: "info"
46
+ notify: []
47
+ retention_days: 7
48
+ ---
49
+
50
+ # 开发环境例外规则
51
+
52
+ ## 规则说明
53
+
54
+ 此规则为开发环境提供例外,允许写入`.env.local`配置文件。在开发环境中,开发者需要能够创建本地配置文件以覆盖默认设置。
55
+
56
+ ## 适用条件
57
+
58
+ 1. **环境要求**: 仅适用于`development`或`test`环境
59
+ 2. **文件类型**: 仅适用于`.env.local`文件
60
+ 3. **用户权限**: 仅允许特定用户(developer, tester, admin)
61
+
62
+ ## 安全考虑
63
+
64
+ 虽然允许写入本地配置文件,但需要确保:
65
+ - 不包含生产环境密钥
66
+ - 不提交到版本控制系统
67
+ - 定期清理过期配置
68
+
69
+ ## 监控
70
+
71
+ 所有允许的写入操作都会记录日志,供后续审计使用。
72
+
73
+ ## 相关规则
74
+
75
+ - 开发环境安全规则
76
+ - 配置文件管理规则
77
+ - 版本控制排除规则
@@ -0,0 +1,83 @@
1
+ ---
2
+ id: log-rule-001
3
+ name: "工具调用审计规则"
4
+ description: "记录所有工具调用用于审计和监控"
5
+ version: "1.0.0"
6
+ author: "Audit Team"
7
+
8
+ # 触发条件
9
+ trigger:
10
+ type: "on_tool_call"
11
+ conditions: []
12
+ scope: "global"
13
+
14
+ # 优先级和冲突解决
15
+ priority: 10 # 低优先级,不影响执行
16
+ conflict_resolution: "log"
17
+
18
+ # 执行动作
19
+ steps:
20
+ - type: "log"
21
+ name: "记录工具调用"
22
+ logLevel: "info"
23
+ messageTemplate: "工具调用: {{tool.name}} 参数: {{tool.args}} 用户: {{user.id}} 时间: {{timestamp}}"
24
+ fields:
25
+ - "tool.name"
26
+ - "tool.args"
27
+ - "user.id"
28
+ - "session.id"
29
+ - "timestamp"
30
+
31
+ # 验证条件
32
+ conditions: []
33
+
34
+ # 变量和上下文
35
+ variables:
36
+ audit_enabled: true
37
+ retention_period: "90d"
38
+
39
+ # 日志和监控
40
+ logging:
41
+ level: "info"
42
+ notify: ["audit-log"]
43
+ retention_days: 90
44
+ ---
45
+
46
+ # 工具调用审计规则
47
+
48
+ ## 规则说明
49
+
50
+ 此规则记录所有工具调用,用于系统审计、性能监控和故障排查。
51
+
52
+ ## 记录字段
53
+
54
+ 1. **工具名称**: 被调用的工具名称
55
+ 2. **调用参数**: 工具调用的参数(敏感信息会被过滤)
56
+ 3. **用户信息**: 发起调用的用户标识
57
+ 4. **会话信息**: 当前会话标识
58
+ 5. **时间戳**: 调用发生的时间
59
+ 6. **执行结果**: 工具执行的结果状态
60
+
61
+ ## 隐私保护
62
+
63
+ 为保护用户隐私和安全,以下信息会被过滤:
64
+ - 密码、令牌等认证信息
65
+ - 个人身份信息(PII)
66
+ - 敏感业务数据
67
+
68
+ ## 存储策略
69
+
70
+ 审计日志会保留90天,之后自动归档或删除。紧急情况下可以延长保留期。
71
+
72
+ ## 使用场景
73
+
74
+ 1. **安全审计**: 检测异常工具调用模式
75
+ 2. **故障排查**: 分析系统问题和错误
76
+ 3. **性能监控**: 跟踪工具执行时间和频率
77
+ 4. **合规检查**: 满足监管和合规要求
78
+
79
+ ## 相关规则
80
+
81
+ - 隐私保护规则
82
+ - 数据保留规则
83
+ - 异常检测规则
@@ -0,0 +1,93 @@
1
+ ---
2
+ id: security-rule-001
3
+ name: "文件系统安全规则"
4
+ description: "限制对敏感目录和文件的访问"
5
+ version: "1.0.0"
6
+ author: "System Administrator"
7
+
8
+ # 触发条件
9
+ trigger:
10
+ type: "on_tool_call"
11
+ conditions:
12
+ - tool_name: "file_write"
13
+ - path_matches: "**/.env*"
14
+ scope: "global"
15
+
16
+ # 优先级和冲突解决
17
+ priority: 100 # 高优先级
18
+ conflict_resolution: "block"
19
+
20
+ # 执行动作
21
+ steps:
22
+ - type: "block"
23
+ name: "阻止敏感文件写入"
24
+ message: "禁止写入敏感配置文件"
25
+ reason: "安全策略禁止写入.env等敏感配置文件"
26
+ requireApproval: false
27
+
28
+ # 验证条件
29
+ conditions:
30
+ - type: "regex"
31
+ field: "tool.args.path"
32
+ pattern: "^.*/\\.env"
33
+ - type: "regex"
34
+ field: "tool.args.path"
35
+ pattern: "^.*/passwd$"
36
+ - type: "regex"
37
+ field: "tool.args.path"
38
+ pattern: "^.*/shadow$"
39
+ - type: "regex"
40
+ field: "tool.args.path"
41
+ pattern: "^/etc/.*"
42
+ - type: "regex"
43
+ field: "tool.args.path"
44
+ pattern: "^/var/log/.*"
45
+
46
+ # 变量和上下文
47
+ variables:
48
+ allowed_paths: ["/tmp/", "/home/user/", "/var/www/"]
49
+ max_file_size: 10485760
50
+
51
+ # 日志和监控
52
+ logging:
53
+ level: "warn"
54
+ notify: ["security-channel"]
55
+ retention_days: 30
56
+ ---
57
+
58
+ # 文件系统安全规则
59
+
60
+ ## 规则说明
61
+
62
+ 此规则用于保护系统敏感文件,防止未经授权的写入操作。
63
+
64
+ ## 保护范围
65
+
66
+ 1. **配置文件**: 所有`.env`文件(包含环境变量)
67
+ 2. **系统文件**: `/etc/passwd`, `/etc/shadow`等
68
+ 3. **日志文件**: `/var/log/`目录下的文件
69
+ 4. **其他敏感路径**: 根据正则表达式匹配
70
+
71
+ ## 例外情况
72
+
73
+ 以下路径允许写入:
74
+ - `/tmp/` 临时目录
75
+ - `/home/user/` 用户目录
76
+ - `/var/www/` Web根目录
77
+
78
+ ## 审计日志
79
+
80
+ 所有被阻止的写入操作都会记录到安全审计日志中,安全团队会定期审查。
81
+
82
+ ## 紧急绕过
83
+
84
+ 在紧急情况下,可以通过以下方式临时禁用此规则:
85
+ 1. 将规则文件重命名为`.md.disabled`
86
+ 2. 联系安全团队获取临时令牌
87
+ 3. 通过管理界面临时禁用
88
+
89
+ ## 相关规则
90
+
91
+ - 数据加密规则
92
+ - 访问控制规则
93
+ - 审计日志规则
@@ -0,0 +1,148 @@
1
+ #!/usr/bin/env python3
2
+ """
3
+ Auto Preview - Antigravity Kit
4
+ ==============================
5
+ Manages (start/stop/status) the local development server for previewing the application.
6
+
7
+ Usage:
8
+ python .agent/scripts/auto_preview.py start [port]
9
+ python .agent/scripts/auto_preview.py stop
10
+ python .agent/scripts/auto_preview.py status
11
+ """
12
+
13
+ import os
14
+ import sys
15
+ import time
16
+ import json
17
+ import signal
18
+ import argparse
19
+ import subprocess
20
+ from pathlib import Path
21
+
22
+ AGENT_DIR = Path(".agent")
23
+ PID_FILE = AGENT_DIR / "preview.pid"
24
+ LOG_FILE = AGENT_DIR / "preview.log"
25
+
26
+ def get_project_root():
27
+ return Path(".").resolve()
28
+
29
+ def is_running(pid):
30
+ try:
31
+ os.kill(pid, 0)
32
+ return True
33
+ except OSError:
34
+ return False
35
+
36
+ def get_start_command(root):
37
+ pkg_file = root / "package.json"
38
+ if not pkg_file.exists():
39
+ return None
40
+
41
+ with open(pkg_file, 'r') as f:
42
+ data = json.load(f)
43
+
44
+ scripts = data.get("scripts", {})
45
+ if "dev" in scripts:
46
+ return ["npm", "run", "dev"]
47
+ elif "start" in scripts:
48
+ return ["npm", "start"]
49
+ return None
50
+
51
+ def start_server(port=3000):
52
+ if PID_FILE.exists():
53
+ try:
54
+ pid = int(PID_FILE.read_text().strip())
55
+ if is_running(pid):
56
+ print(f"⚠️ Preview already running (PID: {pid})")
57
+ return
58
+ except:
59
+ pass # Invalid PID file
60
+
61
+ root = get_project_root()
62
+ cmd = get_start_command(root)
63
+
64
+ if not cmd:
65
+ print("❌ No 'dev' or 'start' script found in package.json")
66
+ sys.exit(1)
67
+
68
+ # Add port env var if needed (simple heuristic)
69
+ env = os.environ.copy()
70
+ env["PORT"] = str(port)
71
+
72
+ print(f"🚀 Starting preview on port {port}...")
73
+
74
+ with open(LOG_FILE, "w") as log:
75
+ process = subprocess.Popen(
76
+ cmd,
77
+ cwd=str(root),
78
+ stdout=log,
79
+ stderr=log,
80
+ env=env,
81
+ shell=True # Required for npm on windows often, or consistent path handling
82
+ )
83
+
84
+ PID_FILE.write_text(str(process.pid))
85
+ print(f"✅ Preview started! (PID: {process.pid})")
86
+ print(f" Logs: {LOG_FILE}")
87
+ print(f" URL: http://localhost:{port}")
88
+
89
+ def stop_server():
90
+ if not PID_FILE.exists():
91
+ print("ℹ️ No preview server found.")
92
+ return
93
+
94
+ try:
95
+ pid = int(PID_FILE.read_text().strip())
96
+ if is_running(pid):
97
+ # Try gentle kill first
98
+ os.kill(pid, signal.SIGTERM) if sys.platform != 'win32' else subprocess.call(['taskkill', '/F', '/T', '/PID', str(pid)])
99
+ print(f"🛑 Preview stopped (PID: {pid})")
100
+ else:
101
+ print("ℹ️ Process was not running.")
102
+ except Exception as e:
103
+ print(f"❌ Error stopping server: {e}")
104
+ finally:
105
+ if PID_FILE.exists():
106
+ PID_FILE.unlink()
107
+
108
+ def status_server():
109
+ running = False
110
+ pid = None
111
+ url = "Unknown"
112
+
113
+ if PID_FILE.exists():
114
+ try:
115
+ pid = int(PID_FILE.read_text().strip())
116
+ if is_running(pid):
117
+ running = True
118
+ # Heuristic for URL, strictly we should save it
119
+ url = "http://localhost:3000"
120
+ except:
121
+ pass
122
+
123
+ print("\n=== Preview Status ===")
124
+ if running:
125
+ print(f"✅ Status: Running")
126
+ print(f"🔢 PID: {pid}")
127
+ print(f"🌐 URL: {url} (Likely)")
128
+ print(f"📝 Logs: {LOG_FILE}")
129
+ else:
130
+ print("⚪ Status: Stopped")
131
+ print("===================\n")
132
+
133
+ def main():
134
+ parser = argparse.ArgumentParser()
135
+ parser.add_argument("action", choices=["start", "stop", "status"])
136
+ parser.add_argument("port", nargs="?", default="3000")
137
+
138
+ args = parser.parse_args()
139
+
140
+ if args.action == "start":
141
+ start_server(int(args.port))
142
+ elif args.action == "stop":
143
+ stop_server()
144
+ elif args.action == "status":
145
+ status_server()
146
+
147
+ if __name__ == "__main__":
148
+ main()
@@ -0,0 +1,217 @@
1
+ #!/usr/bin/env python3
2
+ """
3
+ Master Checklist Runner - Antigravity Kit
4
+ ==========================================
5
+
6
+ Orchestrates all validation scripts in priority order.
7
+ Use this for incremental validation during development.
8
+
9
+ Usage:
10
+ python scripts/checklist.py . # Run core checks
11
+ python scripts/checklist.py . --url <URL> # Include performance checks
12
+
13
+ Priority Order:
14
+ P0: Security Scan (vulnerabilities, secrets)
15
+ P1: Lint & Type Check (code quality)
16
+ P2: Schema Validation (if database exists)
17
+ P3: Test Runner (unit/integration tests)
18
+ P4: UX Audit (psychology laws, accessibility)
19
+ P5: SEO Check (meta tags, structure)
20
+ P6: Performance (lighthouse - requires URL)
21
+ """
22
+
23
+ import sys
24
+ import subprocess
25
+ import argparse
26
+ from pathlib import Path
27
+ from typing import List, Tuple, Optional
28
+
29
+ # ANSI colors for terminal output
30
+ class Colors:
31
+ HEADER = '\033[95m'
32
+ BLUE = '\033[94m'
33
+ CYAN = '\033[96m'
34
+ GREEN = '\033[92m'
35
+ YELLOW = '\033[93m'
36
+ RED = '\033[91m'
37
+ ENDC = '\033[0m'
38
+ BOLD = '\033[1m'
39
+
40
+ def print_header(text: str):
41
+ print(f"\n{Colors.BOLD}{Colors.CYAN}{'='*60}{Colors.ENDC}")
42
+ print(f"{Colors.BOLD}{Colors.CYAN}{text.center(60)}{Colors.ENDC}")
43
+ print(f"{Colors.BOLD}{Colors.CYAN}{'='*60}{Colors.ENDC}\n")
44
+
45
+ def print_step(text: str):
46
+ print(f"{Colors.BOLD}{Colors.BLUE}🔄 {text}{Colors.ENDC}")
47
+
48
+ def print_success(text: str):
49
+ print(f"{Colors.GREEN}✅ {text}{Colors.ENDC}")
50
+
51
+ def print_warning(text: str):
52
+ print(f"{Colors.YELLOW}⚠️ {text}{Colors.ENDC}")
53
+
54
+ def print_error(text: str):
55
+ print(f"{Colors.RED}❌ {text}{Colors.ENDC}")
56
+
57
+ # Define priority-ordered checks
58
+ CORE_CHECKS = [
59
+ ("Security Scan", ".agent/skills/vulnerability-scanner/scripts/security_scan.py", True),
60
+ ("Lint Check", ".agent/skills/lint-and-validate/scripts/lint_runner.py", True),
61
+ ("Schema Validation", ".agent/skills/database-design/scripts/schema_validator.py", False),
62
+ ("Test Runner", ".agent/skills/testing-patterns/scripts/test_runner.py", False),
63
+ ("UX Audit", ".agent/skills/frontend-design/scripts/ux_audit.py", False),
64
+ ("SEO Check", ".agent/skills/seo-fundamentals/scripts/seo_checker.py", False),
65
+ ]
66
+
67
+ PERFORMANCE_CHECKS = [
68
+ ("Lighthouse Audit", ".agent/skills/performance-profiling/scripts/lighthouse_audit.py", True),
69
+ ("Playwright E2E", ".agent/skills/webapp-testing/scripts/playwright_runner.py", False),
70
+ ]
71
+
72
+ def check_script_exists(script_path: Path) -> bool:
73
+ """Check if script file exists"""
74
+ return script_path.exists() and script_path.is_file()
75
+
76
+ def run_script(name: str, script_path: Path, project_path: str, url: Optional[str] = None) -> dict:
77
+ """
78
+ Run a validation script and capture results
79
+
80
+ Returns:
81
+ dict with keys: name, passed, output, skipped
82
+ """
83
+ if not check_script_exists(script_path):
84
+ print_warning(f"{name}: Script not found, skipping")
85
+ return {"name": name, "passed": True, "output": "", "skipped": True}
86
+
87
+ print_step(f"Running: {name}")
88
+
89
+ # Build command
90
+ cmd = ["python", str(script_path), project_path]
91
+ if url and ("lighthouse" in script_path.name.lower() or "playwright" in script_path.name.lower()):
92
+ cmd.append(url)
93
+
94
+ # Run script
95
+ try:
96
+ result = subprocess.run(
97
+ cmd,
98
+ capture_output=True,
99
+ text=True,
100
+ timeout=300 # 5 minute timeout
101
+ )
102
+
103
+ passed = result.returncode == 0
104
+
105
+ if passed:
106
+ print_success(f"{name}: PASSED")
107
+ else:
108
+ print_error(f"{name}: FAILED")
109
+ if result.stderr:
110
+ print(f" Error: {result.stderr[:200]}")
111
+
112
+ return {
113
+ "name": name,
114
+ "passed": passed,
115
+ "output": result.stdout,
116
+ "error": result.stderr,
117
+ "skipped": False
118
+ }
119
+
120
+ except subprocess.TimeoutExpired:
121
+ print_error(f"{name}: TIMEOUT (>5 minutes)")
122
+ return {"name": name, "passed": False, "output": "", "error": "Timeout", "skipped": False}
123
+
124
+ except Exception as e:
125
+ print_error(f"{name}: ERROR - {str(e)}")
126
+ return {"name": name, "passed": False, "output": "", "error": str(e), "skipped": False}
127
+
128
+ def print_summary(results: List[dict]):
129
+ """Print final summary report"""
130
+ print_header("📊 CHECKLIST SUMMARY")
131
+
132
+ passed_count = sum(1 for r in results if r["passed"] and not r.get("skipped"))
133
+ failed_count = sum(1 for r in results if not r["passed"] and not r.get("skipped"))
134
+ skipped_count = sum(1 for r in results if r.get("skipped"))
135
+
136
+ print(f"Total Checks: {len(results)}")
137
+ print(f"{Colors.GREEN}✅ Passed: {passed_count}{Colors.ENDC}")
138
+ print(f"{Colors.RED}❌ Failed: {failed_count}{Colors.ENDC}")
139
+ print(f"{Colors.YELLOW}⏭️ Skipped: {skipped_count}{Colors.ENDC}")
140
+ print()
141
+
142
+ # Detailed results
143
+ for r in results:
144
+ if r.get("skipped"):
145
+ status = f"{Colors.YELLOW}⏭️ {Colors.ENDC}"
146
+ elif r["passed"]:
147
+ status = f"{Colors.GREEN}✅{Colors.ENDC}"
148
+ else:
149
+ status = f"{Colors.RED}❌{Colors.ENDC}"
150
+
151
+ print(f"{status} {r['name']}")
152
+
153
+ print()
154
+
155
+ if failed_count > 0:
156
+ print_error(f"{failed_count} check(s) FAILED - Please fix before proceeding")
157
+ return False
158
+ else:
159
+ print_success("All checks PASSED ✨")
160
+ return True
161
+
162
+ def main():
163
+ parser = argparse.ArgumentParser(
164
+ description="Run Antigravity Kit validation checklist",
165
+ formatter_class=argparse.RawDescriptionHelpFormatter,
166
+ epilog="""
167
+ Examples:
168
+ python scripts/checklist.py . # Core checks only
169
+ python scripts/checklist.py . --url http://localhost:3000 # Include performance
170
+ """
171
+ )
172
+ parser.add_argument("project", help="Project path to validate")
173
+ parser.add_argument("--url", help="URL for performance checks (lighthouse, playwright)")
174
+ parser.add_argument("--skip-performance", action="store_true", help="Skip performance checks even if URL provided")
175
+
176
+ args = parser.parse_args()
177
+
178
+ project_path = Path(args.project).resolve()
179
+
180
+ if not project_path.exists():
181
+ print_error(f"Project path does not exist: {project_path}")
182
+ sys.exit(1)
183
+
184
+ print_header("🚀 ANTIGRAVITY KIT - MASTER CHECKLIST")
185
+ print(f"Project: {project_path}")
186
+ print(f"URL: {args.url if args.url else 'Not provided (performance checks skipped)'}")
187
+
188
+ results = []
189
+
190
+ # Run core checks
191
+ print_header("📋 CORE CHECKS")
192
+ for name, script_path, required in CORE_CHECKS:
193
+ script = project_path / script_path
194
+ result = run_script(name, script, str(project_path))
195
+ results.append(result)
196
+
197
+ # If required check fails, stop
198
+ if required and not result["passed"] and not result.get("skipped"):
199
+ print_error(f"CRITICAL: {name} failed. Stopping checklist.")
200
+ print_summary(results)
201
+ sys.exit(1)
202
+
203
+ # Run performance checks if URL provided
204
+ if args.url and not args.skip_performance:
205
+ print_header("⚡ PERFORMANCE CHECKS")
206
+ for name, script_path, required in PERFORMANCE_CHECKS:
207
+ script = project_path / script_path
208
+ result = run_script(name, script, str(project_path), args.url)
209
+ results.append(result)
210
+
211
+ # Print summary
212
+ all_passed = print_summary(results)
213
+
214
+ sys.exit(0 if all_passed else 1)
215
+
216
+ if __name__ == "__main__":
217
+ main()