agent-workflow-kit-cli 1.2.0 → 1.2.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.
@@ -8,6 +8,7 @@ import path from "path";
8
8
  import { renderTemplate, readStaticTemplateFile, getStackRules, getStackSkills, } from "../../core/renderer.js";
9
9
  import { updateFileWithBlock, writeRuleWithChunking, } from "../../core/emitter.js";
10
10
  import { analyzeModule } from "../../core/analyzer.js";
11
+ import { updateGitignore } from "./init.js";
11
12
  export async function runAdd(stack, options) {
12
13
  const targetStack = stack.toLowerCase();
13
14
  const validStacks = ["spring-boot", "react-ts", "fastapi", "python-ai"];
@@ -36,26 +37,63 @@ export async function runAdd(stack, options) {
36
37
  console.error(chalk.red(`Error loading template for stack '${targetStack}': ${err instanceof Error ? err.message : String(err)}`));
37
38
  process.exit(1);
38
39
  }
39
- // 3. Write or Update AGENTS.md in the target directory
40
+ // 3. Write or Update AGENTS.md and/or GEMINI.md in the target directory
41
+ const geminiPath = path.join(targetDir, "GEMINI.md");
40
42
  const agentsPath = path.join(targetDir, "AGENTS.md");
41
43
  const moduleAgentsContent = await renderTemplate("common/AGENTS.md.hbs", {
42
44
  stackContent,
43
45
  });
44
- if (options.dryRun) {
45
- console.log(chalk.gray(`[Dry Run] Would write/update AGENTS.md at ${agentsPath}`));
46
+ if (options.agent === "antigravity" || options.agent === "both") {
47
+ if (options.dryRun) {
48
+ console.log(chalk.gray(`[Dry Run] Would write/update GEMINI.md at ${geminiPath}`));
49
+ }
50
+ else {
51
+ try {
52
+ await fs.access(geminiPath);
53
+ await updateFileWithBlock(geminiPath, "STACK_PACK", stackContent);
54
+ console.log(chalk.green(`✔️ Updated STACK_PACK block in ${geminiPath}`));
55
+ }
56
+ catch {
57
+ await fs.mkdir(targetDir, { recursive: true });
58
+ await fs.writeFile(geminiPath, moduleAgentsContent, "utf8");
59
+ console.log(chalk.green(`✔️ Created ${geminiPath}`));
60
+ }
61
+ }
46
62
  }
47
- else {
48
- try {
49
- await fs.access(agentsPath);
50
- await updateFileWithBlock(agentsPath, "STACK_PACK", stackContent);
51
- console.log(chalk.green(`✔️ Updated STACK_PACK block in ${agentsPath}`));
63
+ if (options.agent === "codex" || options.agent === "both") {
64
+ if (options.dryRun) {
65
+ console.log(chalk.gray(`[Dry Run] Would write/update AGENTS.md at ${agentsPath}`));
66
+ }
67
+ else {
68
+ try {
69
+ await fs.access(agentsPath);
70
+ await updateFileWithBlock(agentsPath, "STACK_PACK", stackContent);
71
+ console.log(chalk.green(`✔️ Updated STACK_PACK block in ${agentsPath}`));
72
+ }
73
+ catch {
74
+ await fs.mkdir(targetDir, { recursive: true });
75
+ await fs.writeFile(agentsPath, moduleAgentsContent, "utf8");
76
+ console.log(chalk.green(`✔️ Created ${agentsPath}`));
77
+ }
52
78
  }
53
- catch {
54
- await fs.mkdir(targetDir, { recursive: true });
55
- await fs.writeFile(agentsPath, moduleAgentsContent, "utf8");
56
- console.log(chalk.green(`✔️ Created ${agentsPath}`));
79
+ }
80
+ // Write IDE Rules to target directory
81
+ const ideRulesContent = await renderTemplate("common/ide-rules.hbs", {
82
+ agent: options.agent,
83
+ });
84
+ const ideFiles = [".cursorrules", ".copilot-instructions.md", ".clinerules"];
85
+ for (const file of ideFiles) {
86
+ if (options.dryRun) {
87
+ console.log(chalk.gray(`[Dry Run] Would write IDE rule file to ${path.join(targetDir, file)}`));
88
+ }
89
+ else {
90
+ await fs.writeFile(path.join(targetDir, file), ideRulesContent, "utf8");
57
91
  }
58
92
  }
93
+ if (!options.dryRun) {
94
+ console.log(chalk.green(`✔️ Created IDE prompt anchors at ${targetDir} (.cursorrules, .copilot-instructions.md, .clinerules)`));
95
+ }
96
+ await updateGitignore(targetDir, options.dryRun);
59
97
  // 4. Copy rules and skills for the target stack
60
98
  const stackCtx = analysis[targetStack] || {};
61
99
  // A. Copy Rules
@@ -18,7 +18,8 @@ function printSuccessAndNextSteps(options) {
18
18
  console.log(chalk.bold.cyan("\n👉 Next Steps:"));
19
19
  console.log(chalk.dim("------------------------------------------"));
20
20
  console.log(chalk.white(`1. Open & review the generated guidelines:`));
21
- console.log(chalk.gray(` - Root: ${chalk.underline("AGENTS.md")}`));
21
+ const targetFile = options.agent === "antigravity" ? "GEMINI.md" : "AGENTS.md";
22
+ console.log(chalk.gray(` - Root: ${chalk.underline(targetFile)}`));
22
23
  console.log(chalk.gray(` - Stack rules: ${chalk.underline(".agents/rules/")}`));
23
24
  console.log(chalk.white(`2. Setup automatic git pre-commit hook validation:`));
24
25
  console.log(chalk.cyan(` npx agent-workflow-kit-cli doctor --install-hook`));
@@ -27,6 +28,56 @@ function printSuccessAndNextSteps(options) {
27
28
  console.log(chalk.dim("------------------------------------------\n"));
28
29
  }
29
30
  }
31
+ export async function updateGitignore(targetDir, dryRun) {
32
+ const gitignorePath = path.join(targetDir, ".gitignore");
33
+ const rulesToIgnore = [".cursorrules", ".copilot-instructions.md", ".clinerules"];
34
+ if (dryRun) {
35
+ console.log(chalk.gray(`[Dry Run] Would update .gitignore in ${targetDir} to exclude IDE rule files.`));
36
+ return;
37
+ }
38
+ try {
39
+ let content = "";
40
+ try {
41
+ content = await fs.readFile(gitignorePath, "utf8");
42
+ }
43
+ catch {
44
+ // gitignore does not exist
45
+ }
46
+ const lines = content.split("\n").map((l) => l.trim());
47
+ const missingRules = rulesToIgnore.filter((rule) => !lines.includes(rule));
48
+ if (missingRules.length > 0) {
49
+ const separator = content.length > 0 && !content.endsWith("\n") ? "\n\n" : "";
50
+ const newContent = content +
51
+ separator +
52
+ "# Agent Workflow Kit IDE rules\n" +
53
+ missingRules.join("\n") +
54
+ "\n";
55
+ await fs.writeFile(gitignorePath, newContent, "utf8");
56
+ console.log(chalk.green("✔️ Updated .gitignore to exclude IDE rules."));
57
+ }
58
+ }
59
+ catch (err) {
60
+ console.warn(chalk.yellow(`Could not update .gitignore: ${err instanceof Error ? err.message : String(err)}`));
61
+ }
62
+ }
63
+ async function writeWorkspaceIdeRulesAndGitignore(cwd, options) {
64
+ const ideRulesContent = await renderTemplate("common/ide-rules.hbs", {
65
+ agent: options.agent,
66
+ });
67
+ const ideFiles = [".cursorrules", ".copilot-instructions.md", ".clinerules"];
68
+ for (const file of ideFiles) {
69
+ if (options.dryRun) {
70
+ console.log(chalk.gray(`[Dry Run] Would write root ${file}`));
71
+ }
72
+ else {
73
+ await fs.writeFile(path.join(cwd, file), ideRulesContent, "utf8");
74
+ }
75
+ }
76
+ if (!options.dryRun) {
77
+ console.log(chalk.green("✔️ Created workspace IDE prompt anchors (.cursorrules, .copilot-instructions.md, .clinerules)"));
78
+ }
79
+ await updateGitignore(cwd, options.dryRun);
80
+ }
30
81
  export async function runInit(options) {
31
82
  const cwd = process.cwd();
32
83
  console.log(chalk.bold.cyan("\n🚀 Agent Workflow Kit - Initializing..."));
@@ -47,40 +98,74 @@ export async function runInit(options) {
47
98
  const finalAgentsContent = await renderTemplate("common/AGENTS.md.hbs", {
48
99
  stackContent: "",
49
100
  });
50
- if (options.dryRun) {
51
- console.log(chalk.gray(`[Dry Run] Would write root AGENTS.md`));
101
+ if (options.agent === "antigravity" || options.agent === "both") {
102
+ if (options.dryRun) {
103
+ console.log(chalk.gray(`[Dry Run] Would write root GEMINI.md`));
104
+ }
105
+ else {
106
+ const geminiPath = path.join(cwd, "GEMINI.md");
107
+ await fs.writeFile(geminiPath, finalAgentsContent, "utf8");
108
+ console.log(chalk.green("✔️ Created root GEMINI.md with general guidelines."));
109
+ }
52
110
  }
53
- else {
54
- const agentsPath = path.join(cwd, "AGENTS.md");
55
- await fs.writeFile(agentsPath, finalAgentsContent, "utf8");
56
- console.log(chalk.green("✔️ Created root AGENTS.md with general guidelines."));
111
+ if (options.agent === "codex" || options.agent === "both") {
112
+ if (options.dryRun) {
113
+ console.log(chalk.gray(`[Dry Run] Would write root AGENTS.md`));
114
+ }
115
+ else {
116
+ const agentsPath = path.join(cwd, "AGENTS.md");
117
+ await fs.writeFile(agentsPath, finalAgentsContent, "utf8");
118
+ console.log(chalk.green("✔️ Created root AGENTS.md with general guidelines."));
119
+ }
57
120
  }
121
+ await writeWorkspaceIdeRulesAndGitignore(cwd, options);
58
122
  printSuccessAndNextSteps(options);
59
123
  return;
60
124
  }
61
125
  const isMonorepo = modules.length > 1 || (modules.length === 1 && modules[0].name !== ".");
62
- // Write root AGENTS.md with monorepo details
126
+ // Write root files with monorepo details
63
127
  if (isMonorepo) {
64
128
  let monorepoContent = "### 📦 Monorepo Multi-Module Project Structure\n\nThis repository is configured as a monorepo. Please load and follow the stack-specific guidelines in each subdirectory:\n\n";
65
129
  for (const mod of modules) {
66
- monorepoContent += `- **${mod.name}** (${mod.stacks.join(", ")}): Stack rules and guidelines are located at [${mod.name}/AGENTS.md](file:///${mod.dir.replace(/\\/g, "/")}/AGENTS.md)\n`;
130
+ const isAntigravity = options.agent === "antigravity";
131
+ const targetFileName = isAntigravity ? "GEMINI.md" : "AGENTS.md";
132
+ monorepoContent += `- **${mod.name}** (${mod.stacks.join(", ")}): Stack rules and guidelines are located at [${mod.name}/${targetFileName}](file:///${mod.dir.replace(/\\/g, "/")}/${targetFileName})\n`;
67
133
  }
68
134
  const rootAgentsContent = await renderTemplate("common/AGENTS.md.hbs", {
69
135
  stackContent: monorepoContent.trim(),
70
136
  });
137
+ const rootGeminiPath = path.join(cwd, "GEMINI.md");
71
138
  const rootAgentsPath = path.join(cwd, "AGENTS.md");
72
- if (options.dryRun) {
73
- console.log(chalk.gray(`[Dry Run] Would write root AGENTS.md containing monorepo navigation:\n${monorepoContent}`));
139
+ if (options.agent === "antigravity" || options.agent === "both") {
140
+ if (options.dryRun) {
141
+ console.log(chalk.gray(`[Dry Run] Would write root GEMINI.md containing monorepo navigation:\n${monorepoContent}`));
142
+ }
143
+ else {
144
+ try {
145
+ await fs.access(rootGeminiPath);
146
+ await updateFileWithBlock(rootGeminiPath, "STACK_PACK", monorepoContent.trim());
147
+ console.log(chalk.green("✔️ Updated STACK_PACK block in root GEMINI.md."));
148
+ }
149
+ catch {
150
+ await fs.writeFile(rootGeminiPath, rootAgentsContent, "utf8");
151
+ console.log(chalk.green("✔️ Created root GEMINI.md for monorepo."));
152
+ }
153
+ }
74
154
  }
75
- else {
76
- try {
77
- await fs.access(rootAgentsPath);
78
- await updateFileWithBlock(rootAgentsPath, "STACK_PACK", monorepoContent.trim());
79
- console.log(chalk.green("✔️ Updated STACK_PACK block in root AGENTS.md."));
155
+ if (options.agent === "codex" || options.agent === "both") {
156
+ if (options.dryRun) {
157
+ console.log(chalk.gray(`[Dry Run] Would write root AGENTS.md containing monorepo navigation:\n${monorepoContent}`));
80
158
  }
81
- catch {
82
- await fs.writeFile(rootAgentsPath, rootAgentsContent, "utf8");
83
- console.log(chalk.green("✔️ Created root AGENTS.md for monorepo."));
159
+ else {
160
+ try {
161
+ await fs.access(rootAgentsPath);
162
+ await updateFileWithBlock(rootAgentsPath, "STACK_PACK", monorepoContent.trim());
163
+ console.log(chalk.green("✔️ Updated STACK_PACK block in root AGENTS.md."));
164
+ }
165
+ catch {
166
+ await fs.writeFile(rootAgentsPath, rootAgentsContent, "utf8");
167
+ console.log(chalk.green("✔️ Created root AGENTS.md for monorepo."));
168
+ }
84
169
  }
85
170
  }
86
171
  }
@@ -100,23 +185,42 @@ export async function runInit(options) {
100
185
  }
101
186
  }
102
187
  stackContent = stackContent.trim();
103
- // Render AGENTS.md for this module
188
+ // Render agent files for this module
189
+ const geminiPath = path.join(mod.dir, "GEMINI.md");
104
190
  const agentsPath = path.join(mod.dir, "AGENTS.md");
105
191
  const moduleAgentsContent = await renderTemplate("common/AGENTS.md.hbs", {
106
192
  stackContent,
107
193
  });
108
- if (options.dryRun) {
109
- console.log(chalk.gray(`[Dry Run] Would write AGENTS.md at ${agentsPath}`));
194
+ if (options.agent === "antigravity" || options.agent === "both") {
195
+ if (options.dryRun) {
196
+ console.log(chalk.gray(`[Dry Run] Would write GEMINI.md at ${geminiPath}`));
197
+ }
198
+ else {
199
+ try {
200
+ await fs.access(geminiPath);
201
+ await updateFileWithBlock(geminiPath, "STACK_PACK", stackContent);
202
+ console.log(chalk.green(`✔️ Updated STACK_PACK block in ${mod.name}/GEMINI.md`));
203
+ }
204
+ catch {
205
+ await fs.writeFile(geminiPath, moduleAgentsContent, "utf8");
206
+ console.log(chalk.green(`✔️ Created ${mod.name}/GEMINI.md`));
207
+ }
208
+ }
110
209
  }
111
- else {
112
- try {
113
- await fs.access(agentsPath);
114
- await updateFileWithBlock(agentsPath, "STACK_PACK", stackContent);
115
- console.log(chalk.green(`✔️ Updated STACK_PACK block in ${mod.name}/AGENTS.md`));
210
+ if (options.agent === "codex" || options.agent === "both") {
211
+ if (options.dryRun) {
212
+ console.log(chalk.gray(`[Dry Run] Would write AGENTS.md at ${agentsPath}`));
116
213
  }
117
- catch {
118
- await fs.writeFile(agentsPath, moduleAgentsContent, "utf8");
119
- console.log(chalk.green(`✔️ Created ${mod.name}/AGENTS.md`));
214
+ else {
215
+ try {
216
+ await fs.access(agentsPath);
217
+ await updateFileWithBlock(agentsPath, "STACK_PACK", stackContent);
218
+ console.log(chalk.green(`✔️ Updated STACK_PACK block in ${mod.name}/AGENTS.md`));
219
+ }
220
+ catch {
221
+ await fs.writeFile(agentsPath, moduleAgentsContent, "utf8");
222
+ console.log(chalk.green(`✔️ Created ${mod.name}/AGENTS.md`));
223
+ }
120
224
  }
121
225
  }
122
226
  // Copy common skills for this module
@@ -186,5 +290,7 @@ export async function runInit(options) {
186
290
  }
187
291
  }
188
292
  }
293
+ // Write workspace-level IDE rules and update gitignore
294
+ await writeWorkspaceIdeRulesAndGitignore(cwd, options);
189
295
  printSuccessAndNextSteps(options);
190
296
  }
package/dist/cli/index.js CHANGED
@@ -14,7 +14,7 @@ export function runCli() {
14
14
  program
15
15
  .name("agent-workflow-kit")
16
16
  .description("Generate AI coding workflows/rules/templates for Codex and Antigravity")
17
- .version("1.2.0");
17
+ .version("1.2.1");
18
18
  program
19
19
  .command("init")
20
20
  .description("Initialize agent guidelines and skills for the repository")
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agent-workflow-kit-cli",
3
- "version": "1.2.0",
3
+ "version": "1.2.1",
4
4
  "description": "AI-Ready Repository Workflow Generator & Guideline Optimizer for Codex and Antigravity",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -0,0 +1,12 @@
1
+ # Agent Workflow Kit - IDE System Instructions
2
+
3
+ You are an AI assistant ({{#if (eq agent "antigravity")}}Antigravity{{else}}{{#if (eq agent "codex")}}Codex{{else}}Antigravity / Codex{{/if}}{{/if}}) coding inside this repository. You MUST follow these repository standards for every query:
4
+
5
+ 1. Always check for and follow {{#if (eq agent "antigravity")}}[GEMINI.md](file:///GEMINI.md){{else}}{{#if (eq agent "codex")}}[AGENTS.md](file:///AGENTS.md){{else}}[GEMINI.md](file:///GEMINI.md) (if you are Antigravity) or [AGENTS.md](file:///AGENTS.md) (if you are Codex){{/if}}{{/if}} at the workspace root (or current module workspace) before executing any task.
6
+ 2. Follow the strict 5-Step Execution Workflow:
7
+ - Step 1: Research & Context Analysis (scan workspace, read relevant rules in `.agents/rules/` matching the active stack, e.g. `react-style.md` for React. Do not scan irrelevant files).
8
+ - Step 2: Formulate Implementation Plan (list files to create, modify, or delete).
9
+ - Step 3: Implementation & Clean Coding (maintain type-safety, styles, and layering).
10
+ - Step 4: Verification (run validation commands: compile, lint, test, build).
11
+ - Step 5: Self-Review & QA (review diff, clean logs, summarize edits).
12
+ 3. Check and execute custom skills defined inside `.agents/skills/` (like `/spring-feature` or `/react-feature`) by reading their `SKILL.md` instruction file.