@minhluudev/ai-tools 1.0.21 → 1.0.25

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.
@@ -1,3 +1,4 @@
1
+ import { AGENT_SELECTION_CHOICES, isAgentOptionSelected, toggleAgentOption, toggleAllAgents } from "./agent-selection.js";
1
2
  import { resolveInstallRoot } from "./install.js";
2
3
  import { canRun, createTabbedLayout, DEBOUNCE_MOVE_MS, DEBOUNCE_SELECT_MS, renderBannerHeader, renderKeycaps, renderListRow, renderListContent, renderStepSummary, renderTabBar, selectionArray } from "./tui-utils.js";
3
4
  const TAB_ORDER = ["skills", "locations", "agents", "review"];
@@ -32,32 +33,22 @@ function currentTabItems(state, selectionCatalog) {
32
33
  {
33
34
  id: "global",
34
35
  label: "⊙ Global",
35
- description: "Install into the current user's home directory (~/.claude / ~/.codex).",
36
+ description: "Install into the current user's home directory (~/.claude / ~/.codex / ~/.pi/agent).",
36
37
  kind: "locations"
37
38
  },
38
39
  {
39
40
  id: "local",
40
41
  label: "⊕ Local",
41
- description: "Install into this project's dot directories (.claude / .codex).",
42
+ description: "Install into this project's dot directories (.claude / .codex / .pi).",
42
43
  kind: "locations"
43
44
  }
44
45
  ];
45
46
  }
46
47
  if (state.activeTab === "agents") {
47
- return [
48
- {
49
- id: "codex",
50
- label: "◇ Codex",
51
- description: "Install as Codex skills.",
52
- kind: "agents"
53
- },
54
- {
55
- id: "claude",
56
- label: "◇ Claude",
57
- description: "Install as Claude custom agents.",
58
- kind: "agents"
59
- }
60
- ];
48
+ return AGENT_SELECTION_CHOICES.map((choice) => ({
49
+ ...choice,
50
+ kind: "agents"
51
+ }));
61
52
  }
62
53
  return [
63
54
  {
@@ -88,7 +79,7 @@ function isItemSelected(item, state) {
88
79
  return state.selectedLocations.has(item.id);
89
80
  }
90
81
  if (item.kind === "agents") {
91
- return state.selectedAgents.has(item.id);
82
+ return isAgentOptionSelected(item.id, state.selectedAgents);
92
83
  }
93
84
  return state.reviewAction === item.id;
94
85
  }
@@ -113,13 +104,7 @@ function toggleItem(item, state) {
113
104
  return;
114
105
  }
115
106
  if (item.kind === "agents") {
116
- const agent = item.id;
117
- if (state.selectedAgents.has(agent)) {
118
- state.selectedAgents.delete(agent);
119
- }
120
- else {
121
- state.selectedAgents.add(agent);
122
- }
107
+ toggleAgentOption(state.selectedAgents, item.id);
123
108
  return;
124
109
  }
125
110
  state.reviewAction = item.id;
@@ -372,6 +357,11 @@ export async function runTabbedWizard(selectionCatalog, headerTitle = "Install a
372
357
  if (items.length === 0) {
373
358
  return;
374
359
  }
360
+ if (state.activeTab === "agents") {
361
+ toggleAllAgents(state.selectedAgents);
362
+ render();
363
+ return;
364
+ }
375
365
  const allSelected = items.every((item) => isItemSelected(item, state));
376
366
  for (const item of items) {
377
367
  const selected = isItemSelected(item, state);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@minhluudev/ai-tools",
3
- "version": "1.0.21",
4
- "description": "CLI to install AI skills from GitHub branches into Codex and Claude.",
3
+ "version": "1.0.25",
4
+ "description": "CLI to install AI skills from GitHub branches for Codex, Claude, and Pi.",
5
5
  "license": "MIT",
6
6
  "type": "module",
7
7
  "repository": {
@@ -18,13 +18,15 @@
18
18
  "files": [
19
19
  "dist/src",
20
20
  "selection-catalog.json",
21
- "project-docs-catalog.json",
22
21
  "README.md"
23
22
  ],
24
23
  "scripts": {
25
- "build": "tsc -p tsconfig.json",
24
+ "clean": "node -e \"require('node:fs').rmSync('dist', { recursive: true, force: true })\"",
25
+ "build": "npm run clean && tsc -p tsconfig.json",
26
26
  "prepack": "npm run build",
27
- "test": "npm run build && node --test dist/test/*.test.js"
27
+ "test": "npm run build && node --test dist/test/*.test.js",
28
+ "install:global": "npm pack && npm install -g ./minhluudev-ai-tools-$(npm pkg get version | tr -d '\"').tgz",
29
+ "new-version": "npm version patch"
28
30
  },
29
31
  "publishConfig": {
30
32
  "access": "public"
@@ -39,13 +41,11 @@
39
41
  },
40
42
  "aiTools": {
41
43
  "selectionCatalogPath": "selection-catalog.json",
42
- "projectDocsCatalogPath": "project-docs-catalog.json",
43
44
  "github": {
44
45
  "owner": "minhluudev",
45
46
  "repo": "ai-tools",
46
47
  "defaultBranch": "main",
47
48
  "skillsBranch": "skill-general",
48
- "pluginsBranch": "plugins",
49
49
  "manifestPath": "ai-tools.catalog.json",
50
50
  "excludeBranches": [
51
51
  "main",
@@ -2,46 +2,39 @@
2
2
  "version": 1,
3
3
  "skills": [
4
4
  {
5
- "id": "bugfix",
6
- "label": "Bugfix",
7
- "description": "Trace, isolate, and fix bugs — regressions, runtime errors, flaky issues, and performance defects.",
8
- "sourceBranch": "agent-skills",
9
- "sourcePath": "bugfix"
10
- },
11
- {
12
- "id": "debugger",
13
- "label": "Debugger",
14
- "description": "Investigate code defects without applying a fix — root cause analysis and debugging handoff.",
5
+ "id": "domain-driven-design",
6
+ "label": "Domain Driven Design",
7
+ "description": "Laravel backend module design using DDD layers, Actions, DTOs, repositories, and events.",
15
8
  "sourceBranch": "agent-skills",
16
- "sourcePath": "debugger"
9
+ "sourcePath": "domain-driven-design"
17
10
  },
18
11
  {
19
- "id": "backend-testcase-writer",
20
- "label": "Backend testcase writer",
21
- "description": "Write detailed backend testcase documents for API endpoints, services, repositories, and workers/consumers.",
12
+ "id": "generate-flow",
13
+ "label": "Generate Flow",
14
+ "description": "Trace a feature's data and logic end-to-end through source code layers — from trigger to persistence, event emission, response, or failure.",
22
15
  "sourceBranch": "agent-skills",
23
- "sourcePath": "backend-testcase-writer"
16
+ "sourcePath": "generate-flow"
24
17
  },
25
18
  {
26
- "id": "business-analyst",
27
- "label": "Business analyst",
28
- "description": "Analyze requirements and produce SRS documentation.",
19
+ "id": "git-workflow",
20
+ "label": "Git workflow",
21
+ "description": "GitFlow-style git workflow — committing, branching, merging, PRs, releases, and conflict resolution.",
29
22
  "sourceBranch": "agent-skills",
30
- "sourcePath": "business-analyst"
23
+ "sourcePath": "git-workflow"
31
24
  },
32
25
  {
33
- "id": "domain-driven-design",
34
- "label": "Domain Driven Design",
35
- "description": "Laravel backend module design using DDD layers, Actions, DTOs, repositories, and events.",
26
+ "id": "react-component-generator",
27
+ "label": "React Component Generator",
28
+ "description": "Create or refactor repo-aligned React components under components/**, with index.tsx, controller.ts, and style.module.css conventions.",
36
29
  "sourceBranch": "agent-skills",
37
- "sourcePath": "domain-driven-design"
30
+ "sourcePath": "react-component-generator"
38
31
  },
39
32
  {
40
- "id": "git-workflow",
41
- "label": "Git workflow",
42
- "description": "GitFlow-style git workflow — committing, branching, merging, PRs, releases, and conflict resolution.",
33
+ "id": "refine-antd",
34
+ "label": "Refine + Ant Design",
35
+ "description": "Guides building and modifying admin panels, dashboards, and internal CRUD tools with the Refine framework and Ant Design.",
43
36
  "sourceBranch": "agent-skills",
44
- "sourcePath": "git-workflow"
37
+ "sourcePath": "refine-antd"
45
38
  },
46
39
  {
47
40
  "id": "review-code",
@@ -50,6 +43,13 @@
50
43
  "sourceBranch": "agent-skills",
51
44
  "sourcePath": "review-code"
52
45
  },
46
+ {
47
+ "id": "task-creator",
48
+ "label": "Task Creator",
49
+ "description": "Draft and push tasks/tickets to Jira, Trello, Notion, Linear, Asana, monday.com, or a local file, with an objective estimate and user review before creation.",
50
+ "sourceBranch": "agent-skills",
51
+ "sourcePath": "task-creator"
52
+ },
53
53
  {
54
54
  "id": "team-mini",
55
55
  "label": "Team Mini",
@@ -57,13 +57,6 @@
57
57
  "sourceBranch": "agent-skills",
58
58
  "sourcePath": "team-mini"
59
59
  },
60
- {
61
- "id": "team-full",
62
- "label": "Team Full",
63
- "description": "Full TDD agent team — spec → testcases → tests → implement → verify → review. Leader and Tester agents included.",
64
- "sourceBranch": "agent-skills",
65
- "sourcePath": "team-full"
66
- },
67
60
  {
68
61
  "id": "team-sp",
69
62
  "label": "Team SP",
@@ -72,39 +65,11 @@
72
65
  "sourcePath": "team-sp"
73
66
  },
74
67
  {
75
- "id": "make-task",
76
- "label": "Make Task",
77
- "description": "Create or update structured task documents from Jira, Trello, Notion, Linear, GitHub Issues, or plain descriptions.",
78
- "sourceBranch": "agent-skills",
79
- "sourcePath": "make-task"
80
- },
81
- {
82
- "id": "generate-flow",
83
- "label": "Generate Flow",
84
- "description": "Trace a feature's data and logic end-to-end through source code layers — from trigger to persistence, event emission, response, or failure.",
85
- "sourceBranch": "agent-skills",
86
- "sourcePath": "generate-flow"
87
- },
88
- {
89
- "id": "coding-rules",
90
- "label": "Coding Rules",
91
- "description": "Mandatory coding rules for JavaScript, TypeScript, PHP, ReactJS, Laravel, Docker, and SQL, plus SOLID/OOP/Clean Code baselines.",
92
- "sourceBranch": "agent-skills",
93
- "sourcePath": "coding-rules"
94
- },
95
- {
96
- "id": "react-component-generator",
97
- "label": "React Component Generator",
98
- "description": "Create or refactor repo-aligned React components under components/**, with index.tsx, controller.ts, and style.module.css conventions.",
99
- "sourceBranch": "agent-skills",
100
- "sourcePath": "react-component-generator"
101
- },
102
- {
103
- "id": "vercel-react-best-practices",
104
- "label": "Vercel React Best Practices",
105
- "description": "React and Next.js performance optimization guidelines from Vercel Engineering — 70 rules across waterfalls, bundle size, server/client rendering, re-renders, and JS performance.",
68
+ "id": "testcase-creator",
69
+ "label": "Testcase Creator",
70
+ "description": "Create or expand per-feature Markdown test case suites covering frontend and backend from specifications, designs, and the built-in QA checklists.",
106
71
  "sourceBranch": "agent-skills",
107
- "sourcePath": "vercel-react-best-practices"
72
+ "sourcePath": "testcase-creator"
108
73
  }
109
74
  ]
110
75
  }
@@ -1,417 +0,0 @@
1
- import { mkdtemp, readFile, rm, stat, writeFile } from "node:fs/promises";
2
- import * as os from "node:os";
3
- import * as path from "node:path";
4
- import { spawn } from "node:child_process";
5
- const ICM_INSTALL_COMMAND = "curl -fsSL https://raw.githubusercontent.com/rtk-ai/icm/main/install.sh | sh";
6
- const RTK_INSTALL_COMMAND = "curl -fsSL https://raw.githubusercontent.com/rtk-ai/rtk/refs/heads/master/install.sh | sh";
7
- const ECC_REPO_URL = "https://github.com/affaan-m/ECC.git";
8
- const CODEGRAPH_REPO_URL = "https://github.com/colbymchenry/codegraph";
9
- const ECC_TEMP_DIR_PREFIX = "ai-tools-ecc-";
10
- const ICM_MARKER_START = "<!-- icm:start -->";
11
- const ICM_MARKER_END = "<!-- icm:end -->";
12
- export function detectSupportedHostOs(platform = process.platform) {
13
- if (platform === "darwin") {
14
- return "mac";
15
- }
16
- if (platform === "linux") {
17
- return "linux";
18
- }
19
- return null;
20
- }
21
- function uniq(items) {
22
- return [...new Set(items)];
23
- }
24
- function quickInstallBinaryPath(binaryName) {
25
- return path.join(os.homedir(), ".local", "bin", binaryName);
26
- }
27
- function buildRtkInstallSteps(agents, scope) {
28
- const steps = [
29
- {
30
- id: "rtk-install",
31
- library: "rtk",
32
- phase: "install",
33
- title: "Install RTK binary",
34
- description: "Install the upstream RTK binary with the verified quick installer.",
35
- command: RTK_INSTALL_COMMAND,
36
- runner: "shell"
37
- }
38
- ];
39
- if (agents.includes("claude")) {
40
- steps.push({
41
- id: "rtk-configure-claude",
42
- library: "rtk",
43
- phase: "configure",
44
- title: "Configure RTK for Claude",
45
- description: scope === "global"
46
- ? "Install RTK's Claude-oriented global integration."
47
- : "Install RTK's Claude-oriented local integration for the current project.",
48
- command: scope === "global" ? "rtk init -g" : "rtk init",
49
- runner: "shell"
50
- });
51
- }
52
- if (agents.includes("codex")) {
53
- steps.push({
54
- id: "rtk-configure-codex",
55
- library: "rtk",
56
- phase: "configure",
57
- title: "Configure RTK for Codex",
58
- description: scope === "global"
59
- ? "Install RTK's Codex hook configuration."
60
- : "Install RTK's Codex hook configuration for the current project.",
61
- command: scope === "global" ? "rtk init -g --codex" : "rtk init --codex",
62
- runner: "shell"
63
- });
64
- }
65
- return steps;
66
- }
67
- function buildRtkUninstallSteps(agents, scope) {
68
- const steps = [];
69
- if (agents.includes("claude")) {
70
- steps.push({
71
- id: "rtk-uninstall-claude",
72
- library: "rtk",
73
- phase: "uninstall",
74
- title: "Remove RTK Claude integration",
75
- description: scope === "global"
76
- ? "Remove RTK global artifacts for the default Claude mode."
77
- : "Remove RTK local artifacts for the default Claude mode in the current project.",
78
- command: scope === "global" ? "rtk init -g --uninstall" : "rtk init --uninstall",
79
- runner: "shell"
80
- });
81
- }
82
- if (agents.includes("codex")) {
83
- steps.push({
84
- id: "rtk-uninstall-codex",
85
- library: "rtk",
86
- phase: "uninstall",
87
- title: "Remove RTK Codex integration",
88
- description: scope === "global"
89
- ? "Remove RTK global Codex artifacts."
90
- : "Remove RTK local Codex artifacts in the current project.",
91
- command: scope === "global" ? "rtk init -g --codex --uninstall" : "rtk init --codex --uninstall",
92
- runner: "shell"
93
- });
94
- }
95
- if (scope === "global") {
96
- steps.push({
97
- id: "rtk-remove-binary",
98
- library: "rtk",
99
- phase: "cleanup",
100
- title: "Remove RTK quick-install binary",
101
- description: "Delete the RTK binary only from the standard quick-install path if it exists there.",
102
- command: `remove ${quickInstallBinaryPath("rtk")}`,
103
- runner: "remove-binary",
104
- path: quickInstallBinaryPath("rtk")
105
- });
106
- }
107
- return steps;
108
- }
109
- function buildGlobalIcmModes(agents) {
110
- const modes = ["mcp"];
111
- if (agents.includes("claude")) {
112
- modes.push("skill", "hook");
113
- }
114
- else if (agents.includes("codex")) {
115
- modes.push("hook");
116
- }
117
- return uniq(modes);
118
- }
119
- function buildIcmInstallSteps(agents, scope) {
120
- const selectedAgents = agents.join(" + ");
121
- const steps = [
122
- {
123
- id: "icm-install",
124
- library: "icm",
125
- phase: "install",
126
- title: "Install ICM binary",
127
- description: "Install the upstream ICM binary with the verified quick installer.",
128
- command: ICM_INSTALL_COMMAND,
129
- runner: "shell"
130
- }
131
- ];
132
- if (scope === "local") {
133
- steps.push({
134
- id: "icm-init-cli-local",
135
- library: "icm",
136
- phase: "configure",
137
- title: "Configure ICM project instructions",
138
- description: `Inject ICM instructions for the selected agent set (${selectedAgents}) using upstream per-project mode.`,
139
- command: "icm init --mode cli --per_project",
140
- runner: "shell"
141
- });
142
- return steps;
143
- }
144
- for (const mode of buildGlobalIcmModes(agents)) {
145
- steps.push({
146
- id: `icm-init-${mode}`,
147
- library: "icm",
148
- phase: "configure",
149
- title: `Configure ICM (${mode})`,
150
- description: `Run ICM ${mode} setup for the selected agent set (${selectedAgents}).`,
151
- command: `icm init --mode ${mode}`,
152
- runner: "shell"
153
- });
154
- }
155
- return steps;
156
- }
157
- function buildIcmUninstallSteps(scope) {
158
- if (scope === "local") {
159
- return [{
160
- id: "icm-local-cleanup",
161
- library: "icm",
162
- phase: "cleanup",
163
- title: "Remove ICM project instructions",
164
- description: "Remove only ICM-managed instruction blocks from the current project's local files.",
165
- command: "clean ICM blocks from current project",
166
- runner: "cleanup-icm-local"
167
- }];
168
- }
169
- return [];
170
- }
171
- function buildEccInstallSteps(agents) {
172
- const steps = [];
173
- if (agents.includes("claude")) {
174
- steps.push({
175
- id: "ecc-install-claude",
176
- library: "ecc",
177
- phase: "install",
178
- title: "Set up ECC for Claude",
179
- description: "Clone the upstream ECC repo into a temporary directory, install its dependencies, and run the documented full manual Claude setup.",
180
- command: "temporary clone of affaan-m/ECC -> npm install -> bash ./install.sh --profile full",
181
- runner: "setup-ecc-claude"
182
- });
183
- }
184
- if (agents.includes("codex")) {
185
- steps.push({
186
- id: "ecc-install-codex",
187
- library: "ecc",
188
- phase: "configure",
189
- title: "Set up ECC for Codex",
190
- description: "Clone the upstream ECC repo into a temporary directory, install its dependencies, and run the documented Codex sync script.",
191
- command: "temporary clone of affaan-m/ECC -> npm install -> bash ./scripts/sync-ecc-to-codex.sh",
192
- runner: "setup-ecc-codex"
193
- });
194
- }
195
- return steps;
196
- }
197
- function buildCodegraphInstallSteps() {
198
- return [
199
- {
200
- id: "codegraph-install",
201
- library: "codegraph",
202
- phase: "install",
203
- title: "Install CodeGraph binary",
204
- description: `Install the CodeGraph CLI globally from the upstream GitHub repo (${CODEGRAPH_REPO_URL}).`,
205
- command: `npm install -g ${CODEGRAPH_REPO_URL}`,
206
- runner: "shell"
207
- }
208
- ];
209
- }
210
- function buildCodegraphUninstallSteps() {
211
- return [
212
- {
213
- id: "codegraph-uninstall",
214
- library: "codegraph",
215
- phase: "uninstall",
216
- title: "Uninstall CodeGraph binary",
217
- description: "Remove the globally installed CodeGraph CLI.",
218
- command: "npm uninstall -g codegraph",
219
- runner: "shell"
220
- }
221
- ];
222
- }
223
- export function buildLibInstallPlan(input) {
224
- const agents = uniq(input.agents);
225
- const libraries = uniq(input.libraries);
226
- const hostOs = detectSupportedHostOs(input.platform);
227
- const steps = [];
228
- const notes = [];
229
- for (const library of libraries) {
230
- if (library === "rtk") {
231
- if (input.mode === "install") {
232
- steps.push(...buildRtkInstallSteps(agents, input.scope));
233
- notes.push("RTK rewrites Bash commands. Built-in non-shell tools are not auto-rewritten.");
234
- notes.push("RTK uninstall removes RTK-managed assistant artifacts only; it does not edit unrelated shell or editor settings.");
235
- }
236
- else {
237
- steps.push(...buildRtkUninstallSteps(agents, input.scope));
238
- if (input.scope === "global") {
239
- notes.push("RTK binary cleanup only removes the quick-install path ~/.local/bin/rtk. Homebrew or cargo installs still require manual removal.");
240
- }
241
- else {
242
- notes.push("RTK local uninstall leaves the global binary in place to avoid breaking other projects or global hooks.");
243
- }
244
- }
245
- continue;
246
- }
247
- if (library === "icm") {
248
- if (input.mode === "install") {
249
- steps.push(...buildIcmInstallSteps(agents, input.scope));
250
- if (input.scope === "global") {
251
- notes.push("ICM init auto-detects supported tools on this machine and may update more global configs than the selected agent labels alone imply.");
252
- }
253
- else {
254
- notes.push("ICM local mode uses upstream --per_project CLI injection. Depending on upstream behavior, some global instruction files may still be touched.");
255
- }
256
- }
257
- else {
258
- steps.push(...buildIcmUninstallSteps(input.scope));
259
- if (input.scope === "global") {
260
- notes.push("Automatic global ICM uninstall is intentionally disabled in this CLI because upstream uninstall removes all detected ICM integrations, not only the selected agents.");
261
- notes.push("For safest cleanup, run `icm uninstall --audit` manually, review the plan, then use upstream uninstall yourself if the detected scope is acceptable.");
262
- }
263
- else {
264
- notes.push("ICM local uninstall only strips ICM-managed blocks from project files in the current directory and leaves global ICM config untouched.");
265
- }
266
- }
267
- continue;
268
- }
269
- if (library === "ecc") {
270
- if (input.mode === "install") {
271
- steps.push(...buildEccInstallSteps(agents));
272
- notes.push("ECC install in this CLI clones the upstream repo into a temporary directory and runs the documented repo-based setup flow for each selected agent. It is user-level and not constrained to the selected scope.");
273
- notes.push("If ECC is already installed in Claude via the upstream plugin path, do not run the full installer again here. Upstream warns that stacking both methods can duplicate skills, commands, and hooks.");
274
- notes.push("For Codex, this CLI uses the upstream repo-based sync flow (`npm install && bash scripts/sync-ecc-to-codex.sh`) instead of `npx ecc-install`, because the package name and installer binary are published separately (`ecc-universal` vs `ecc-install`).");
275
- }
276
- else {
277
- notes.push("Automatic ECC uninstall is not supported in this CLI. Upstream documents repo-root lifecycle commands such as `node scripts/uninstall.js --dry-run` followed by `node scripts/uninstall.js` for manual cleanup.");
278
- notes.push("If ECC was installed through the Claude plugin path, remove the plugin first and then delete only the specific ECC rule folders you copied manually.");
279
- }
280
- continue;
281
- }
282
- if (library === "codegraph") {
283
- if (input.mode === "install") {
284
- steps.push(...buildCodegraphInstallSteps());
285
- notes.push("CodeGraph is a project-level indexer. After installing the CLI, run `codegraph init` in each project you want to index — indexing is intentionally per-project and not run automatically here.");
286
- notes.push("The MCP tools (codegraph_explore, codegraph_node) become available only after a project has been indexed with `codegraph init`.");
287
- }
288
- else {
289
- steps.push(...buildCodegraphUninstallSteps());
290
- notes.push("CodeGraph uninstall removes only the global CLI binary. Existing `.codegraph/` index directories in your projects are not removed and can be deleted manually with `rm -rf .codegraph`.");
291
- }
292
- }
293
- }
294
- if (input.mode === "install" && libraries.some((library) => library === "rtk" || library === "icm")) {
295
- notes.unshift("Binary install still uses the upstream installer and writes to the user's bin directory even when scope is local.");
296
- }
297
- if (hostOs && hostOs !== input.os) {
298
- notes.unshift(`Selected OS is ${input.os}, but the current host is ${hostOs}. The installer always runs against the current machine.`);
299
- }
300
- if (!hostOs) {
301
- notes.unshift("This host OS is not one of the supported Mac/Linux targets. The upstream installers may fail.");
302
- }
303
- return {
304
- mode: input.mode,
305
- os: input.os,
306
- hostOs,
307
- scope: input.scope,
308
- agents,
309
- libraries,
310
- steps,
311
- notes
312
- };
313
- }
314
- export async function executeLibInstallPlan(input) {
315
- for (const step of input.plan.steps) {
316
- input.onProgress?.(step);
317
- if (step.runner === "remove-binary") {
318
- if (!step.path) {
319
- throw new Error(`Missing path for step "${step.id}".`);
320
- }
321
- await removeBinaryAtPath(step.path);
322
- continue;
323
- }
324
- if (step.runner === "cleanup-icm-local") {
325
- await cleanupIcmLocalBlocks(input.cwd);
326
- continue;
327
- }
328
- if (step.runner === "setup-ecc-claude") {
329
- await runEccRepoSetup("claude", input.cwd);
330
- continue;
331
- }
332
- if (step.runner === "setup-ecc-codex") {
333
- await runEccRepoSetup("codex", input.cwd);
334
- continue;
335
- }
336
- await runShellCommand(step.command, input.cwd);
337
- }
338
- }
339
- async function runEccRepoSetup(target, cwd) {
340
- const tempRoot = await mkdtemp(path.join(os.tmpdir(), ECC_TEMP_DIR_PREFIX));
341
- try {
342
- await runShellCommand(`git clone --depth 1 ${ECC_REPO_URL} "${tempRoot}"`, cwd);
343
- await runShellCommand("npm install", tempRoot);
344
- if (target === "claude") {
345
- await runShellCommand("bash ./install.sh --profile full", tempRoot);
346
- return;
347
- }
348
- await runShellCommand("bash ./scripts/sync-ecc-to-codex.sh", tempRoot);
349
- }
350
- finally {
351
- await rm(tempRoot, { recursive: true, force: true });
352
- }
353
- }
354
- async function removeBinaryAtPath(targetPath) {
355
- try {
356
- const info = await stat(targetPath);
357
- if (!info.isFile()) {
358
- return;
359
- }
360
- }
361
- catch {
362
- return;
363
- }
364
- await rm(targetPath, { force: true });
365
- }
366
- async function cleanupIcmLocalBlocks(cwd) {
367
- const candidateFiles = [
368
- "CLAUDE.md",
369
- "AGENTS.md",
370
- ".github/copilot-instructions.md",
371
- ".windsurfrules",
372
- ".aider.conventions.md"
373
- ];
374
- for (const relativeFile of candidateFiles) {
375
- const absoluteFile = path.join(cwd, relativeFile);
376
- let content;
377
- try {
378
- content = await readFile(absoluteFile, "utf8");
379
- }
380
- catch {
381
- continue;
382
- }
383
- const cleaned = stripIcmBlocks(content);
384
- if (cleaned === content) {
385
- continue;
386
- }
387
- if (cleaned.trim().length === 0) {
388
- await rm(absoluteFile, { force: true });
389
- continue;
390
- }
391
- await writeFile(absoluteFile, cleaned, "utf8");
392
- }
393
- }
394
- function stripIcmBlocks(content) {
395
- const blockPattern = new RegExp(`\\n?${escapeRegExp(ICM_MARKER_START)}[\\s\\S]*?${escapeRegExp(ICM_MARKER_END)}\\n?`, "g");
396
- const stripped = content.replace(blockPattern, "\n");
397
- return stripped.replace(/\n{3,}/g, "\n\n").trimEnd() + (stripped.endsWith("\n") ? "\n" : "");
398
- }
399
- function escapeRegExp(value) {
400
- return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
401
- }
402
- function runShellCommand(command, cwd) {
403
- return new Promise((resolve, reject) => {
404
- const child = spawn("/bin/sh", ["-lc", command], {
405
- cwd,
406
- stdio: "inherit"
407
- });
408
- child.on("error", reject);
409
- child.on("close", (code) => {
410
- if (code === 0) {
411
- resolve();
412
- return;
413
- }
414
- reject(new Error(`Command failed with exit code ${code}: ${command}`));
415
- });
416
- });
417
- }