@mison/ag-kit-cn 2.0.1

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 (237) 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/core.py +258 -0
  26. package/.agent/.shared/ui-ux-pro-max/scripts/design_system.py +1067 -0
  27. package/.agent/.shared/ui-ux-pro-max/scripts/search.py +106 -0
  28. package/.agent/ARCHITECTURE.md +285 -0
  29. package/.agent/agents/backend-specialist.md +268 -0
  30. package/.agent/agents/code-archaeologist.md +106 -0
  31. package/.agent/agents/database-architect.md +225 -0
  32. package/.agent/agents/debugger.md +225 -0
  33. package/.agent/agents/devops-engineer.md +242 -0
  34. package/.agent/agents/documentation-writer.md +104 -0
  35. package/.agent/agents/explorer-agent.md +73 -0
  36. package/.agent/agents/frontend-specialist.md +618 -0
  37. package/.agent/agents/game-developer.md +162 -0
  38. package/.agent/agents/mobile-developer.md +382 -0
  39. package/.agent/agents/orchestrator.md +438 -0
  40. package/.agent/agents/penetration-tester.md +188 -0
  41. package/.agent/agents/performance-optimizer.md +187 -0
  42. package/.agent/agents/product-manager.md +112 -0
  43. package/.agent/agents/product-owner.md +95 -0
  44. package/.agent/agents/project-planner.md +405 -0
  45. package/.agent/agents/qa-automation-engineer.md +103 -0
  46. package/.agent/agents/security-auditor.md +170 -0
  47. package/.agent/agents/seo-specialist.md +111 -0
  48. package/.agent/agents/test-engineer.md +158 -0
  49. package/.agent/mcp_config.json +12 -0
  50. package/.agent/rules/GEMINI.md +273 -0
  51. package/.agent/scripts/auto_preview.py +148 -0
  52. package/.agent/scripts/checklist.py +217 -0
  53. package/.agent/scripts/session_manager.py +120 -0
  54. package/.agent/scripts/verify_all.py +327 -0
  55. package/.agent/skills/api-patterns/SKILL.md +84 -0
  56. package/.agent/skills/api-patterns/api-style.md +42 -0
  57. package/.agent/skills/api-patterns/auth.md +24 -0
  58. package/.agent/skills/api-patterns/documentation.md +26 -0
  59. package/.agent/skills/api-patterns/graphql.md +41 -0
  60. package/.agent/skills/api-patterns/rate-limiting.md +31 -0
  61. package/.agent/skills/api-patterns/response.md +37 -0
  62. package/.agent/skills/api-patterns/rest.md +40 -0
  63. package/.agent/skills/api-patterns/scripts/api_validator.py +211 -0
  64. package/.agent/skills/api-patterns/security-testing.md +122 -0
  65. package/.agent/skills/api-patterns/trpc.md +41 -0
  66. package/.agent/skills/api-patterns/versioning.md +22 -0
  67. package/.agent/skills/app-builder/SKILL.md +75 -0
  68. package/.agent/skills/app-builder/agent-coordination.md +74 -0
  69. package/.agent/skills/app-builder/feature-building.md +53 -0
  70. package/.agent/skills/app-builder/project-detection.md +34 -0
  71. package/.agent/skills/app-builder/scaffolding.md +118 -0
  72. package/.agent/skills/app-builder/tech-stack.md +40 -0
  73. package/.agent/skills/app-builder/templates/SKILL.md +39 -0
  74. package/.agent/skills/app-builder/templates/astro-static/TEMPLATE.md +76 -0
  75. package/.agent/skills/app-builder/templates/chrome-extension/TEMPLATE.md +92 -0
  76. package/.agent/skills/app-builder/templates/cli-tool/TEMPLATE.md +88 -0
  77. package/.agent/skills/app-builder/templates/electron-desktop/TEMPLATE.md +88 -0
  78. package/.agent/skills/app-builder/templates/express-api/TEMPLATE.md +83 -0
  79. package/.agent/skills/app-builder/templates/flutter-app/TEMPLATE.md +90 -0
  80. package/.agent/skills/app-builder/templates/monorepo-turborepo/TEMPLATE.md +90 -0
  81. package/.agent/skills/app-builder/templates/nextjs-fullstack/TEMPLATE.md +122 -0
  82. package/.agent/skills/app-builder/templates/nextjs-saas/TEMPLATE.md +122 -0
  83. package/.agent/skills/app-builder/templates/nextjs-static/TEMPLATE.md +169 -0
  84. package/.agent/skills/app-builder/templates/nuxt-app/TEMPLATE.md +134 -0
  85. package/.agent/skills/app-builder/templates/python-fastapi/TEMPLATE.md +83 -0
  86. package/.agent/skills/app-builder/templates/react-native-app/TEMPLATE.md +119 -0
  87. package/.agent/skills/architecture/SKILL.md +57 -0
  88. package/.agent/skills/architecture/context-discovery.md +43 -0
  89. package/.agent/skills/architecture/examples.md +94 -0
  90. package/.agent/skills/architecture/pattern-selection.md +68 -0
  91. package/.agent/skills/architecture/patterns-reference.md +50 -0
  92. package/.agent/skills/architecture/trade-off-analysis.md +77 -0
  93. package/.agent/skills/bash-linux/SKILL.md +201 -0
  94. package/.agent/skills/behavioral-modes/SKILL.md +264 -0
  95. package/.agent/skills/brainstorming/SKILL.md +164 -0
  96. package/.agent/skills/brainstorming/dynamic-questioning.md +359 -0
  97. package/.agent/skills/clean-code/SKILL.md +200 -0
  98. package/.agent/skills/code-review-checklist/SKILL.md +125 -0
  99. package/.agent/skills/database-design/SKILL.md +54 -0
  100. package/.agent/skills/database-design/database-selection.md +43 -0
  101. package/.agent/skills/database-design/indexing.md +39 -0
  102. package/.agent/skills/database-design/migrations.md +50 -0
  103. package/.agent/skills/database-design/optimization.md +36 -0
  104. package/.agent/skills/database-design/orm-selection.md +30 -0
  105. package/.agent/skills/database-design/schema-design.md +56 -0
  106. package/.agent/skills/database-design/scripts/schema_validator.py +172 -0
  107. package/.agent/skills/deployment-procedures/SKILL.md +241 -0
  108. package/.agent/skills/doc.md +177 -0
  109. package/.agent/skills/documentation-templates/SKILL.md +194 -0
  110. package/.agent/skills/frontend-design/SKILL.md +418 -0
  111. package/.agent/skills/frontend-design/animation-guide.md +331 -0
  112. package/.agent/skills/frontend-design/color-system.md +307 -0
  113. package/.agent/skills/frontend-design/decision-trees.md +418 -0
  114. package/.agent/skills/frontend-design/motion-graphics.md +306 -0
  115. package/.agent/skills/frontend-design/scripts/accessibility_checker.py +183 -0
  116. package/.agent/skills/frontend-design/scripts/ux_audit.py +727 -0
  117. package/.agent/skills/frontend-design/typography-system.md +345 -0
  118. package/.agent/skills/frontend-design/ux-psychology.md +1118 -0
  119. package/.agent/skills/frontend-design/visual-effects.md +383 -0
  120. package/.agent/skills/game-development/2d-games/SKILL.md +119 -0
  121. package/.agent/skills/game-development/3d-games/SKILL.md +135 -0
  122. package/.agent/skills/game-development/SKILL.md +167 -0
  123. package/.agent/skills/game-development/game-art/SKILL.md +185 -0
  124. package/.agent/skills/game-development/game-audio/SKILL.md +190 -0
  125. package/.agent/skills/game-development/game-design/SKILL.md +129 -0
  126. package/.agent/skills/game-development/mobile-games/SKILL.md +108 -0
  127. package/.agent/skills/game-development/multiplayer/SKILL.md +132 -0
  128. package/.agent/skills/game-development/pc-games/SKILL.md +144 -0
  129. package/.agent/skills/game-development/vr-ar/SKILL.md +123 -0
  130. package/.agent/skills/game-development/web-games/SKILL.md +150 -0
  131. package/.agent/skills/geo-fundamentals/SKILL.md +155 -0
  132. package/.agent/skills/geo-fundamentals/scripts/geo_checker.py +289 -0
  133. package/.agent/skills/i18n-localization/SKILL.md +154 -0
  134. package/.agent/skills/i18n-localization/scripts/i18n_checker.py +241 -0
  135. package/.agent/skills/intelligent-routing/SKILL.md +335 -0
  136. package/.agent/skills/lint-and-validate/SKILL.md +44 -0
  137. package/.agent/skills/lint-and-validate/scripts/lint_runner.py +184 -0
  138. package/.agent/skills/lint-and-validate/scripts/type_coverage.py +173 -0
  139. package/.agent/skills/mcp-builder/SKILL.md +176 -0
  140. package/.agent/skills/mobile-design/SKILL.md +394 -0
  141. package/.agent/skills/mobile-design/decision-trees.md +516 -0
  142. package/.agent/skills/mobile-design/mobile-backend.md +491 -0
  143. package/.agent/skills/mobile-design/mobile-color-system.md +420 -0
  144. package/.agent/skills/mobile-design/mobile-debugging.md +122 -0
  145. package/.agent/skills/mobile-design/mobile-design-thinking.md +355 -0
  146. package/.agent/skills/mobile-design/mobile-navigation.md +458 -0
  147. package/.agent/skills/mobile-design/mobile-performance.md +767 -0
  148. package/.agent/skills/mobile-design/mobile-testing.md +356 -0
  149. package/.agent/skills/mobile-design/mobile-typography.md +432 -0
  150. package/.agent/skills/mobile-design/platform-android.md +666 -0
  151. package/.agent/skills/mobile-design/platform-ios.md +561 -0
  152. package/.agent/skills/mobile-design/scripts/mobile_audit.py +670 -0
  153. package/.agent/skills/mobile-design/touch-psychology.md +537 -0
  154. package/.agent/skills/nextjs-react-expert/1-async-eliminating-waterfalls.md +311 -0
  155. package/.agent/skills/nextjs-react-expert/2-bundle-bundle-size-optimization.md +241 -0
  156. package/.agent/skills/nextjs-react-expert/3-server-server-side-performance.md +489 -0
  157. package/.agent/skills/nextjs-react-expert/4-client-client-side-data-fetching.md +263 -0
  158. package/.agent/skills/nextjs-react-expert/5-rerender-re-render-optimization.md +581 -0
  159. package/.agent/skills/nextjs-react-expert/6-rendering-rendering-performance.md +431 -0
  160. package/.agent/skills/nextjs-react-expert/7-js-javascript-performance.md +683 -0
  161. package/.agent/skills/nextjs-react-expert/8-advanced-advanced-patterns.md +149 -0
  162. package/.agent/skills/nextjs-react-expert/SKILL.md +286 -0
  163. package/.agent/skills/nextjs-react-expert/scripts/convert_rules.py +222 -0
  164. package/.agent/skills/nextjs-react-expert/scripts/react_performance_checker.py +252 -0
  165. package/.agent/skills/nodejs-best-practices/SKILL.md +333 -0
  166. package/.agent/skills/parallel-agents/SKILL.md +194 -0
  167. package/.agent/skills/performance-profiling/SKILL.md +149 -0
  168. package/.agent/skills/performance-profiling/scripts/lighthouse_audit.py +76 -0
  169. package/.agent/skills/plan-writing/SKILL.md +152 -0
  170. package/.agent/skills/powershell-windows/SKILL.md +166 -0
  171. package/.agent/skills/python-patterns/SKILL.md +441 -0
  172. package/.agent/skills/red-team-tactics/SKILL.md +203 -0
  173. package/.agent/skills/rust-pro/SKILL.md +190 -0
  174. package/.agent/skills/seo-fundamentals/SKILL.md +135 -0
  175. package/.agent/skills/seo-fundamentals/scripts/seo_checker.py +215 -0
  176. package/.agent/skills/server-management/SKILL.md +161 -0
  177. package/.agent/skills/systematic-debugging/SKILL.md +114 -0
  178. package/.agent/skills/tailwind-patterns/SKILL.md +269 -0
  179. package/.agent/skills/tdd-workflow/SKILL.md +149 -0
  180. package/.agent/skills/testing-patterns/SKILL.md +178 -0
  181. package/.agent/skills/testing-patterns/scripts/test_runner.py +219 -0
  182. package/.agent/skills/vulnerability-scanner/SKILL.md +276 -0
  183. package/.agent/skills/vulnerability-scanner/checklists.md +131 -0
  184. package/.agent/skills/vulnerability-scanner/scripts/security_scan.py +459 -0
  185. package/.agent/skills/web-design-guidelines/SKILL.md +57 -0
  186. package/.agent/skills/webapp-testing/SKILL.md +187 -0
  187. package/.agent/skills/webapp-testing/scripts/playwright_runner.py +173 -0
  188. package/.agent/workflows/brainstorm.md +113 -0
  189. package/.agent/workflows/create.md +59 -0
  190. package/.agent/workflows/debug.md +103 -0
  191. package/.agent/workflows/deploy.md +176 -0
  192. package/.agent/workflows/enhance.md +63 -0
  193. package/.agent/workflows/orchestrate.md +242 -0
  194. package/.agent/workflows/plan.md +89 -0
  195. package/.agent/workflows/preview.md +80 -0
  196. package/.agent/workflows/restore-localize-compat.md +525 -0
  197. package/.agent/workflows/status.md +86 -0
  198. package/.agent/workflows/test.md +144 -0
  199. package/.agent/workflows/ui-ux-pro-max.md +295 -0
  200. package/AGENT_FLOW.md +609 -0
  201. package/CHANGELOG.md +68 -0
  202. package/LICENSE +21 -0
  203. package/README.md +260 -0
  204. package/bin/adapters/base.js +63 -0
  205. package/bin/adapters/codex.js +391 -0
  206. package/bin/adapters/gemini.js +137 -0
  207. package/bin/ag-kit.js +1336 -0
  208. package/bin/core/builder.js +80 -0
  209. package/bin/core/generator.js +59 -0
  210. package/bin/core/resource-loader.js +64 -0
  211. package/bin/core/transformer.js +208 -0
  212. package/bin/interactive.js +65 -0
  213. package/bin/utils/atomic-writer.js +97 -0
  214. package/bin/utils/git-helper.js +68 -0
  215. package/bin/utils/managed-block.js +65 -0
  216. package/bin/utils/manifest.js +241 -0
  217. package/bin/utils.js +82 -0
  218. package/docs/codex-rules-template.md +36 -0
  219. package/docs/mapping-spec.md +68 -0
  220. package/docs/multi-target-adapter.md +80 -0
  221. package/docs/official/README.md +53 -0
  222. package/docs/official/antigravity/agent-modes-settings.md +64 -0
  223. package/docs/official/antigravity/rules-workflows.md +96 -0
  224. package/docs/official/antigravity/skills.md +147 -0
  225. package/docs/official/codex/agents-md.md +119 -0
  226. package/docs/official/codex/config-advanced.md +358 -0
  227. package/docs/official/codex/config-basic.md +141 -0
  228. package/docs/official/codex/config-reference.md +223 -0
  229. package/docs/official/codex/config-sample.md +216 -0
  230. package/docs/official/codex/mcp.md +107 -0
  231. package/docs/official/codex/rules.md +79 -0
  232. package/docs/official/codex/skills.md +114 -0
  233. package/docs/official/sources-index.md +32 -0
  234. package/docs/operations.md +145 -0
  235. package/docs/terminology-style-guide.md +69 -0
  236. package/package.json +51 -0
  237. package/scripts/postinstall-check.js +112 -0
@@ -0,0 +1,65 @@
1
+ const fs = require("fs");
2
+ const path = require("path");
3
+
4
+ function escapeRegex(input) {
5
+ return input.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
6
+ }
7
+
8
+ function detectLineEnding(content) {
9
+ return content.includes("\r\n") ? "\r\n" : "\n";
10
+ }
11
+
12
+ function buildMarkers(blockId) {
13
+ const id = String(blockId || "default").trim();
14
+ return {
15
+ begin: `<!-- BEGIN AG-KIT MANAGED BLOCK: ${id} -->`,
16
+ end: `<!-- END AG-KIT MANAGED BLOCK: ${id} -->`,
17
+ };
18
+ }
19
+
20
+ function buildManagedBlock(blockId, body, lineEnding = "\n") {
21
+ const markers = buildMarkers(blockId);
22
+ const normalizedBody = String(body || "").replace(/\r?\n/g, lineEnding).trimEnd();
23
+ return `${markers.begin}${lineEnding}${normalizedBody}${lineEnding}${markers.end}`;
24
+ }
25
+
26
+ function upsertManagedBlock(filePath, blockId, body, options = {}) {
27
+ const dryRun = Boolean(options.dryRun);
28
+ const original = fs.existsSync(filePath) ? fs.readFileSync(filePath, "utf8") : "";
29
+ const lineEnding = detectLineEnding(original);
30
+ const managedBlock = buildManagedBlock(blockId, body, lineEnding);
31
+ const markers = buildMarkers(blockId);
32
+ const blockRegex = new RegExp(
33
+ `${escapeRegex(markers.begin)}[\\s\\S]*?${escapeRegex(markers.end)}`,
34
+ "m",
35
+ );
36
+
37
+ let next = "";
38
+ let action = "unchanged";
39
+
40
+ if (!original) {
41
+ next = `${managedBlock}${lineEnding}`;
42
+ action = "created";
43
+ } else if (blockRegex.test(original)) {
44
+ next = original.replace(blockRegex, managedBlock);
45
+ action = next === original ? "unchanged" : "updated";
46
+ if (next && !/\r?\n$/.test(next)) {
47
+ next += lineEnding;
48
+ }
49
+ } else {
50
+ next = `${original.replace(/\r?\n?$/, "")}${lineEnding}${lineEnding}${managedBlock}${lineEnding}`;
51
+ action = "appended";
52
+ }
53
+
54
+ if (!dryRun && action !== "unchanged") {
55
+ fs.mkdirSync(path.dirname(filePath), { recursive: true });
56
+ fs.writeFileSync(filePath, next, "utf8");
57
+ }
58
+
59
+ return { action };
60
+ }
61
+
62
+ module.exports = {
63
+ buildManagedBlock,
64
+ upsertManagedBlock,
65
+ };
@@ -0,0 +1,241 @@
1
+ const fs = require("fs");
2
+ const path = require("path");
3
+ const crypto = require("crypto");
4
+
5
+ class ManifestManager {
6
+ constructor(manifestPath, options = {}) {
7
+ this.manifestPath = manifestPath;
8
+ this.options = options;
9
+ this.manifest = {
10
+ version: 2,
11
+ target: typeof options.target === "string" ? options.target : "",
12
+ kitVersion: typeof options.kitVersion === "string" ? options.kitVersion : "",
13
+ updatedAt: "",
14
+ files: {},
15
+ };
16
+ }
17
+
18
+ /**
19
+ * Compute SHA-256 hash of a string or buffer
20
+ * @param {string|Buffer} content
21
+ * @returns {string} sha256 hash
22
+ */
23
+ static computeHash(content) {
24
+ return crypto.createHash("sha256").update(content).digest("hex");
25
+ }
26
+
27
+ static normalizeFileEntry(entry) {
28
+ if (typeof entry === "string") {
29
+ return { hash: entry, source: "" };
30
+ }
31
+ if (!entry || typeof entry !== "object") {
32
+ return null;
33
+ }
34
+ const hash = typeof entry.hash === "string" ? entry.hash : "";
35
+ const source = typeof entry.source === "string" ? entry.source : "";
36
+ if (!hash) {
37
+ return null;
38
+ }
39
+ return { hash, source };
40
+ }
41
+
42
+ static extractHash(entry) {
43
+ if (typeof entry === "string") {
44
+ return entry;
45
+ }
46
+ if (entry && typeof entry === "object" && typeof entry.hash === "string") {
47
+ return entry.hash;
48
+ }
49
+ return "";
50
+ }
51
+
52
+ static normalizeManifestShape(input) {
53
+ const output = {
54
+ version: typeof input.version === "number" ? input.version : 2,
55
+ target: typeof input.target === "string" ? input.target : "",
56
+ kitVersion: typeof input.kitVersion === "string" ? input.kitVersion : "",
57
+ updatedAt: typeof input.updatedAt === "string" ? input.updatedAt : "",
58
+ files: {},
59
+ };
60
+
61
+ if (!input.files || typeof input.files !== "object") {
62
+ return output;
63
+ }
64
+
65
+ for (const [relPath, entry] of Object.entries(input.files)) {
66
+ const normalized = ManifestManager.normalizeFileEntry(entry);
67
+ if (!normalized) {
68
+ continue;
69
+ }
70
+ output.files[relPath] = normalized;
71
+ }
72
+
73
+ return output;
74
+ }
75
+
76
+ /**
77
+ * Load manifest from disk
78
+ */
79
+ load() {
80
+ if (fs.existsSync(this.manifestPath)) {
81
+ try {
82
+ const raw = fs.readFileSync(this.manifestPath, "utf8");
83
+ this.manifest = ManifestManager.normalizeManifestShape(JSON.parse(raw));
84
+ } catch (err) {
85
+ this.manifest = {
86
+ version: 2,
87
+ target: typeof this.options.target === "string" ? this.options.target : "",
88
+ kitVersion: typeof this.options.kitVersion === "string" ? this.options.kitVersion : "",
89
+ updatedAt: "",
90
+ files: {},
91
+ };
92
+ }
93
+ }
94
+ return this.manifest;
95
+ }
96
+
97
+ /**
98
+ * Save manifest to disk
99
+ */
100
+ save() {
101
+ this.manifest.updatedAt = new Date().toISOString();
102
+ if (!this.manifest.target && this.options.target) {
103
+ this.manifest.target = this.options.target;
104
+ }
105
+ if (!this.manifest.kitVersion && this.options.kitVersion) {
106
+ this.manifest.kitVersion = this.options.kitVersion;
107
+ }
108
+ const dir = path.dirname(this.manifestPath);
109
+ if (!fs.existsSync(dir)) {
110
+ fs.mkdirSync(dir, { recursive: true });
111
+ }
112
+ fs.writeFileSync(this.manifestPath, `${JSON.stringify(this.manifest, null, 2)}\n`, "utf8");
113
+ }
114
+
115
+ /**
116
+ * Generate manifest entries from a directory recursively
117
+ * @param {string} rootDir Directory to scan
118
+ * @param {string} [baseDir] Base directory for relative paths (default: rootDir)
119
+ * @returns {object} { file: hash } map
120
+ */
121
+ static generateFromDir(rootDir, baseDir = rootDir) {
122
+ const entries = ManifestManager.generateFileEntriesFromDir(rootDir, {
123
+ baseDir,
124
+ });
125
+ const hashes = {};
126
+ for (const [relPath, entry] of Object.entries(entries)) {
127
+ hashes[relPath] = entry.hash;
128
+ }
129
+ return hashes;
130
+ }
131
+
132
+ /**
133
+ * Generate managed file entries from a directory recursively
134
+ * @param {string} rootDir Directory to scan
135
+ * @param {object} options
136
+ * @param {string} [options.baseDir=rootDir] Base directory for relative paths
137
+ * @param {string} [options.sourcePrefix=""] Prefix recorded in `source` field
138
+ * @returns {object} { file: { hash, source } } map
139
+ */
140
+ static generateFileEntriesFromDir(rootDir, options = {}) {
141
+ const baseDir = options.baseDir || rootDir;
142
+ const sourcePrefix = typeof options.sourcePrefix === "string" ? options.sourcePrefix.trim() : "";
143
+ const files = {};
144
+
145
+ function scan(dir) {
146
+ const entries = fs.readdirSync(dir, { withFileTypes: true });
147
+ for (const entry of entries) {
148
+ const fullPath = path.join(dir, entry.name);
149
+ if (entry.isDirectory()) {
150
+ scan(fullPath);
151
+ } else if (entry.isFile()) {
152
+ const content = fs.readFileSync(fullPath);
153
+ const hash = ManifestManager.computeHash(content);
154
+ const relPath = path.relative(baseDir, fullPath).split(path.sep).join("/");
155
+ files[relPath] = {
156
+ hash,
157
+ source: sourcePrefix ? `${sourcePrefix}/${relPath}` : relPath,
158
+ };
159
+ }
160
+ }
161
+ }
162
+
163
+ if (fs.existsSync(rootDir)) {
164
+ scan(rootDir);
165
+ }
166
+ return files;
167
+ }
168
+
169
+ /**
170
+ * Compare existing manifest with current file system state to detect user changes
171
+ * @param {string} projectRoot
172
+ * @returns {object} { modified: [], missing: [], unknown: [] }
173
+ */
174
+ checkDrift(projectRoot) {
175
+ // This checks if the files listed in the manifest (which should match what we installed)
176
+ // still match what is currently on disk.
177
+ // Useful for doctor or update pre-check.
178
+ const drift = {
179
+ modified: [], // Hash mismatch
180
+ missing: [], // File in manifest but not on disk
181
+ };
182
+
183
+ for (const [relPath, entry] of Object.entries(this.manifest.files || {})) {
184
+ const expectedHash = ManifestManager.extractHash(entry);
185
+ if (!expectedHash) {
186
+ continue;
187
+ }
188
+ const absPath = path.join(projectRoot, relPath);
189
+ if (!fs.existsSync(absPath)) {
190
+ drift.missing.push(relPath);
191
+ } else {
192
+ const content = fs.readFileSync(absPath);
193
+ const currentHash = ManifestManager.computeHash(content);
194
+ if (currentHash !== expectedHash) {
195
+ drift.modified.push(relPath);
196
+ }
197
+ }
198
+ }
199
+ return drift;
200
+ }
201
+
202
+ /**
203
+ * Select user-modified files to backup during overwrite:
204
+ * currentHash != manifestHash AND currentHash != incomingHash
205
+ * @param {string} projectRoot
206
+ * @param {object} incomingFiles Next manifest files map
207
+ * @returns {string[]} relative file paths
208
+ */
209
+ collectSmartOverwriteConflicts(projectRoot, incomingFiles = {}) {
210
+ const modified = [];
211
+ const existingFiles = this.manifest.files || {};
212
+
213
+ for (const [relPath, manifestEntry] of Object.entries(existingFiles)) {
214
+ const expectedHash = ManifestManager.extractHash(manifestEntry);
215
+ if (!expectedHash) {
216
+ continue;
217
+ }
218
+
219
+ const absPath = path.join(projectRoot, relPath);
220
+ if (!fs.existsSync(absPath)) {
221
+ continue;
222
+ }
223
+
224
+ const currentHash = ManifestManager.computeHash(fs.readFileSync(absPath));
225
+ if (currentHash === expectedHash) {
226
+ continue;
227
+ }
228
+
229
+ const incomingHash = ManifestManager.extractHash(incomingFiles[relPath]);
230
+ if (incomingHash && currentHash === incomingHash) {
231
+ continue;
232
+ }
233
+
234
+ modified.push(relPath);
235
+ }
236
+
237
+ return modified;
238
+ }
239
+ }
240
+
241
+ module.exports = ManifestManager;
package/bin/utils.js ADDED
@@ -0,0 +1,82 @@
1
+ const { execSync } = require("child_process");
2
+ const fs = require("fs");
3
+ const path = require("path");
4
+ const os = require("os");
5
+
6
+ const REPO_URL = "https://github.com/MisonL/antigravity-kit-cn.git";
7
+
8
+ function parseJsonSafe(raw) {
9
+ try {
10
+ return JSON.parse(raw);
11
+ } catch (err) {
12
+ return null;
13
+ }
14
+ }
15
+
16
+ function readGlobalNpmDependencies() {
17
+ const cmd = "npm ls --global --depth=0 --json --silent";
18
+ let output = "";
19
+
20
+ try {
21
+ output = execSync(cmd, {
22
+ encoding: "utf8",
23
+ stdio: ["ignore", "pipe", "pipe"],
24
+ });
25
+ } catch (err) {
26
+ output = typeof err.stdout === "string" ? err.stdout : "";
27
+ }
28
+
29
+ if (!output || output.trim() === "") {
30
+ return null;
31
+ }
32
+
33
+ const data = parseJsonSafe(output);
34
+ if (!data || typeof data !== "object") {
35
+ return null;
36
+ }
37
+
38
+ const deps = data.dependencies;
39
+ if (!deps || typeof deps !== "object") {
40
+ return {};
41
+ }
42
+
43
+ return deps;
44
+ }
45
+
46
+ function cloneBranchAgentDir(branch, options) {
47
+ const safeBranch = branch.trim();
48
+ if (!/^[A-Za-z0-9._/-]+$/.test(safeBranch)) {
49
+ throw new Error(`非法分支名: ${branch}`);
50
+ }
51
+
52
+ const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), "ag-kit-"));
53
+ const logFn = options && options.logger ? options.logger : console.log;
54
+
55
+ if (!options.quiet) logFn(`📥 正在从 ${REPO_URL} 拉取分支 ${safeBranch} ...`);
56
+
57
+ try {
58
+ execSync(`git clone --depth 1 --branch ${safeBranch} ${REPO_URL} "${tempDir}"`, {
59
+ stdio: options.quiet ? "ignore" : "pipe",
60
+ });
61
+ } catch (err) {
62
+ fs.rmSync(tempDir, { recursive: true, force: true });
63
+ throw new Error(`无法拉取分支 ${safeBranch},请确认分支存在且网络可用`);
64
+ }
65
+
66
+ const clonedAgentDir = path.join(tempDir, ".agent");
67
+ if (!fs.existsSync(clonedAgentDir)) {
68
+ fs.rmSync(tempDir, { recursive: true, force: true });
69
+ throw new Error(`分支 ${safeBranch} 中未找到 .agent 目录`);
70
+ }
71
+
72
+ return {
73
+ agentDir: clonedAgentDir,
74
+ cleanup: () => fs.rmSync(tempDir, { recursive: true, force: true }),
75
+ };
76
+ }
77
+
78
+ module.exports = {
79
+ parseJsonSafe,
80
+ readGlobalNpmDependencies,
81
+ cloneBranchAgentDir
82
+ };
@@ -0,0 +1,36 @@
1
+ # Codex `.rules` 模板(手动配置)
2
+
3
+ > 用途:给 Codex 官方规则引擎提供命令审批策略。
4
+ > 注意:这不是 `antigravity.rules` 的替代品,二者职责不同。
5
+
6
+ ## 路径约定
7
+
8
+ - 全局默认路径:`~/.codex/rules/default.rules`
9
+ - 本项目不会自动写入该文件,请按需手动创建。
10
+
11
+ ## 最小模板(Starlark)
12
+
13
+ ```python
14
+ # default.rules
15
+ # 允许常见只读命令直接执行,其余命令走人工审批
16
+
17
+ load("builtin://rules/rules.star", "prefix_rule")
18
+
19
+ rules = [
20
+ prefix_rule(["ls"], action="allow"),
21
+ prefix_rule(["cat"], action="allow"),
22
+ prefix_rule(["rg"], action="allow"),
23
+ prefix_rule(["git", "status"], action="allow"),
24
+ ]
25
+ ```
26
+
27
+ ## 建议策略
28
+
29
+ 1. 先放行只读命令(`ls`/`cat`/`rg`/`git status`)。
30
+ 2. 对写操作、网络请求、脚本执行保持 `review` 或 `deny`。
31
+ 3. 团队场景下,将策略文件纳入内部安全评审流程。
32
+
33
+ ## 与 `antigravity.rules` 的关系
34
+
35
+ - `antigravity.rules`:本仓库在工作区注入的托管说明内容,用于记录受管资源与运维约束。
36
+ - `.rules`:Codex 官方可执行审批规则(Starlark),影响命令放行策略。
@@ -0,0 +1,68 @@
1
+ # Codex(代码智能体环境)资源映射规范
2
+
3
+ Codex(代码智能体环境)适配器包含一个内置的资源转换层(`bin/core/`),负责将通用的 Agent(智能体)能力描述、Skill(技能)与 Workflow(工作流)转换为 Codex 兼容的标准化格式。
4
+
5
+ ## 转换规则
6
+
7
+ ### 1. Skill(技能)
8
+
9
+ - **源路径**: `.agent/skills/<name>/SKILL.md`
10
+ - **Codex ID(标识)**: `<name>`(保持与上游技能名一致)
11
+ - **目标路径**: `.agents/skills/<name>/SKILL.md`
12
+
13
+ ### 2. Workflow(工作流)
14
+
15
+ - **源路径**: `.agent/workflows/<name>.md`
16
+ - **Codex ID(标识)**: `workflow-<name>`
17
+ - **目标路径**: `.agents/skills/workflow-<name>/SKILL.md`
18
+ - **说明**: 工作流会转换为符合 Codex 规范的 `SKILL.md`(自动补齐 `name` / `description` Frontmatter(文档头元数据))。
19
+ - **冲突处理**: 若生成 ID 与现有 Skill/Workflow 冲突,构建器会自动追加 `-2`、`-3`... 后缀,确保 ID 和目录唯一。
20
+
21
+ ## 托管文件生成
22
+
23
+ ### `codex.json` 元数据
24
+
25
+ 包含版本信息和所有资源的清单映射。
26
+
27
+ ### `AGENTS.md` 规则接入点
28
+
29
+ 自动生成的 Markdown 文件,列出所有 Capabilities(能力)并声明版本。
30
+ 安装/更新时,CLI(命令行界面)会把该内容注入工作区根目录 `AGENTS.md` 的托管区块中(不会覆盖用户自定义内容)。
31
+
32
+ ### `antigravity.rules` 风险控制
33
+
34
+ 自动生成风险控制规则,安装/更新时同样会注入工作区根目录 `antigravity.rules` 的托管区块。
35
+
36
+ > 注意:这里的 `antigravity.rules` 是本项目的托管说明文件,不是 Codex 官方 `.rules` 审批策略文件。
37
+ > 如需配置 Codex 官方审批规则,请单独维护 `~/.codex/rules/default.rules`(参考 `docs/codex-rules-template.md`)。
38
+
39
+ ### `manifest.json` 托管清单
40
+
41
+ 用于完整性与漂移检测,核心结构如下:
42
+
43
+ ```json
44
+ {
45
+ "version": 2,
46
+ "target": "codex",
47
+ "kitVersion": "2.0.1",
48
+ "files": {
49
+ "skills/example-skill/SKILL.md": {
50
+ "hash": "sha256...",
51
+ "source": "bundled/skills/example-skill/SKILL.md"
52
+ }
53
+ }
54
+ }
55
+ ```
56
+
57
+ 覆盖策略:仅当当前文件 hash(哈希)同时满足 `当前文件 hash != manifest hash` 且 `当前文件 hash != 新版本 hash` 时,才会备份并覆盖。
58
+
59
+ ## 动态构建
60
+
61
+ 当使用 `ag-kit init --target codex` 安装旧版 Gemini 结构的仓库时,CLI 会自动触发 Just-in-Time Build(即时构建)流程:
62
+
63
+ 1. 克隆/读取源仓库。
64
+ 2. 识别为 Legacy(旧版)结构(`.agent/skills` 存在但无 `manifest.json`)。
65
+ 3. 在临时目录启动构建流水线。
66
+ 4. 将构建产物安装到项目的 `.agents` 目录(若检测到旧版 `.codex` 会自动迁移/清理)。
67
+
68
+ 此过程对用户透明。
@@ -0,0 +1,80 @@
1
+ # 多目标适配器
2
+
3
+ 当前版本引入多目标适配器架构,支持在同一项目中共存并管理不同类型的 Agent(智能体)模板源。
4
+
5
+ ## 架构概览
6
+
7
+ ```mermaid
8
+ graph TD
9
+ CLI[ag-kit CLI] --> Router[Target Router]
10
+ Router --> |target=gemini| Gemini[GeminiAdapter (.agent)]
11
+ Router --> |target=codex| Codex[CodexAdapter (.agents)]
12
+ ```
13
+
14
+ ## 支持的目标
15
+
16
+ ### 1. Gemini(旧版)
17
+
18
+ - **标识**: `gemini`
19
+ - **存储**: `.agent/`(直连模式)
20
+ - **特点**: 轻量级,直接克隆自 Git 仓库或本地模板。
21
+ - **适用**: 个人开发者、快速原型、不强制版本控制的场景。
22
+
23
+ ### 2. Codex(代码智能体环境)
24
+
25
+ - **标识**: `codex`
26
+ - **存储**:
27
+ - `.agents/`(托管上游,用户不可修改)
28
+ - `.agents-backup/`(发生覆盖冲突时自动备份)
29
+ - `AGENTS.md` / `antigravity.rules`(工作区托管区块注入)
30
+ - **特点**:
31
+ - **Drift Detection(漂移检测)**: 自动识别用户对托管文件的修改。
32
+ - **Atomic Update(原子更新)**: 防止更新中断导致损坏。
33
+ - **资源映射**: 自动将标准 Skill(技能)/Workflow(工作流)转换为 Codex 规范。
34
+ - **遗留迁移**: 自动识别旧版 `.codex/` 并迁移到 `.agents/`。
35
+ - **适用**: 团队协作、生产环境、需要严格版本管理和升级保障的场景。
36
+
37
+ > 说明:`antigravity.rules` 是 Ag-Kit 注入的托管说明内容,不等同于 Codex 官方 `.rules`(命令审批执行规则)。
38
+
39
+ ## 命令行用法
40
+
41
+ CLI(命令行界面)命令如下。
42
+
43
+ ### 安装/初始化
44
+
45
+ ```bash
46
+ # 安装 Gemini
47
+ ag-kit init --target gemini
48
+
49
+ # 安装 Codex
50
+ ag-kit init --target codex
51
+
52
+ # 交互选择目标,TTY(终端)下无默认值
53
+ ag-kit init
54
+
55
+ # 临时目录验证(跳过全局索引登记)
56
+ ag-kit init --target codex --no-index
57
+ ```
58
+
59
+ ### 更新
60
+
61
+ ```bash
62
+ # 更新当前项目(自动检测已安装目标)
63
+ ag-kit update
64
+
65
+ # 强制更新指定目标
66
+ ag-kit update --target codex
67
+
68
+ # 更新但不刷新全局索引
69
+ ag-kit update --target codex --no-index
70
+ ```
71
+
72
+ ### 诊断与修复
73
+
74
+ ```bash
75
+ # 检查所有目标健康状态
76
+ ag-kit doctor
77
+
78
+ # 尝试自动修复
79
+ ag-kit doctor --fix
80
+ ```
@@ -0,0 +1,53 @@
1
+ # 官方文档本地归档
2
+
3
+ 本目录用于保存官方规范文档的本地快照,作为本仓库在 Antigravity + Codex 双适配时的对照基线。
4
+
5
+ - 归档时间:2026-02-12
6
+ - 归档方式:先抓取官方源,再整理为中文 Markdown 版本(不改机制语义)
7
+ - 证据索引:`docs/official/sources-index.md`(记录来源 URL、拉取时间、SHA256)
8
+
9
+ ## Antigravity
10
+
11
+ - `docs/official/antigravity/agent-modes-settings.md`
12
+ - 来源:`https://antigravity.google/docs/agent-modes-settings`
13
+ - 抓取源:`https://antigravity.google/assets/docs/agent/agent-modes-settings.md`
14
+ - `docs/official/antigravity/rules-workflows.md`
15
+ - 来源:`https://antigravity.google/docs/rules-workflows`
16
+ - 抓取源:`https://antigravity.google/assets/docs/agent/rules-workflows.md`
17
+ - `docs/official/antigravity/skills.md`
18
+ - 来源:`https://antigravity.google/docs/skills`
19
+ - 抓取源:`https://antigravity.google/assets/docs/agent/skills.md`
20
+
21
+ ## Codex
22
+
23
+ - `docs/official/codex/config-basic.md`
24
+ - 来源:`https://developers.openai.com/codex/config-basic`
25
+ - 抓取源:`https://developers.openai.com/codex/config-basic.md`
26
+ - `docs/official/codex/config-advanced.md`
27
+ - 来源:`https://developers.openai.com/codex/config-advanced`
28
+ - 抓取源:`https://developers.openai.com/codex/config-advanced.md`
29
+ - `docs/official/codex/config-reference.md`
30
+ - 来源:`https://developers.openai.com/codex/config-reference`
31
+ - 抓取源:`https://developers.openai.com/codex/config-reference.md`
32
+ - `docs/official/codex/config-sample.md`
33
+ - 来源:`https://developers.openai.com/codex/config-sample`
34
+ - 抓取源:`https://developers.openai.com/codex/config-sample.md`
35
+ - `docs/official/codex/rules.md`
36
+ - 来源:`https://developers.openai.com/codex/rules`
37
+ - 抓取源:`https://developers.openai.com/codex/rules.md`
38
+ - `docs/official/codex/agents-md.md`
39
+ - 来源:`https://developers.openai.com/codex/guides/agents-md`
40
+ - 抓取源:`https://developers.openai.com/codex/guides/agents-md.md`
41
+ - `docs/official/codex/mcp.md`
42
+ - 来源:`https://developers.openai.com/codex/mcp`
43
+ - 抓取源:`https://developers.openai.com/codex/mcp.md`
44
+ - `docs/official/codex/skills.md`
45
+ - 来源:`https://developers.openai.com/codex/skills`
46
+ - 抓取源:`https://developers.openai.com/codex/skills.md`
47
+
48
+ ## 更新建议
49
+
50
+ 后续更新时,优先覆盖本目录快照,再做差异评审:
51
+
52
+ 1. 对比上次归档与新版官方文档差异。
53
+ 2. 若差异影响本仓库机制,再同步到 `docs/`、`.agent/` 相关规范文档。
@@ -0,0 +1,64 @@
1
+ ---
2
+ slug: agent-modes-settings
3
+ section: 代理
4
+ title: Agent 模式与设置
5
+ path:
6
+ - 代理
7
+ - 模式与设置
8
+ ---
9
+
10
+ # Agent 模式与设置(中文整理)
11
+
12
+ > 来源:`https://antigravity.google/docs/agent-modes-settings`
13
+ > 同步日期:2026-02-12
14
+ > 说明:本文件为官方内容的中文整理版,采用标准 Markdown 语法。
15
+
16
+ ## 会话级模式
17
+
18
+ 开始新的 Agent 会话时,用户可以选择不同模式:
19
+
20
+ - `Planning`:先规划后执行,适合深度研究、复杂任务、协作任务。该模式下,Agent 会使用任务分组、产出 Artifacts,并在执行前进行更充分的分析与规划。
21
+ - `Fast`:直接执行,适合简单且局部的任务,例如重命名变量、执行少量命令等,强调速度。
22
+
23
+ ## 全局设置
24
+
25
+ 全局设置位于设置面板的 `Agent` 标签页,影响所有会话。重点配置如下。
26
+
27
+ ### Artifact 审阅策略
28
+
29
+ 可选项:
30
+
31
+ - `Always Proceed`:Agent 不等待人工审阅,继续执行。
32
+ - `Request Review`:Agent 在请求审阅后停止,等待用户确认和补充意见。
33
+
34
+ 适用建议:
35
+
36
+ - 需要严格把关实施计划时,使用 `Request Review`。
37
+ - 追求流程速度且信任当前指令时,使用 `Always Proceed`。
38
+
39
+ ### 终端命令自动执行
40
+
41
+ 针对终端命令生成工具:
42
+
43
+ - `Request Review`:默认不自动执行命令(允许名单中的命令可自动执行)。
44
+ - `Always Proceed`:默认自动执行命令(拒绝名单中的命令例外)。
45
+
46
+ 补充规则:
47
+
48
+ - 允许名单(Allow list)和拒绝名单(Deny list)可在 `Agent` 设置中配置。
49
+ - 设置变更仅对后续新消息生效,不影响当前正在进行的回复。
50
+ - 在 Unix shell 中,规则按“命令 token 前缀匹配”。
51
+ - 在 PowerShell 中,规则可匹配命令 token 的任意连续子序列。
52
+
53
+ ### 非工作区文件访问
54
+
55
+ 该选项控制 Agent 是否可访问和编辑当前工作区之外的文件。
56
+
57
+ 默认情况下,Agent 仅能访问:
58
+
59
+ - 当前工作区文件
60
+ - 应用根目录 `~/.antigravity/` 下的 Antigravity 相关数据(如 Artifacts、Knowledge Items)
61
+
62
+ 风险提示:
63
+
64
+ - 开启该能力可能暴露本地敏感信息或密钥,请谨慎使用。