polishup-cli 0.1.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.agents/plugins/marketplace.json +20 -0
- package/.antigravity-plugin/plugin.json +12 -0
- package/.claude-plugin/marketplace.json +13 -0
- package/.claude-plugin/plugin.json +12 -0
- package/.codex-plugin/plugin.json +25 -0
- package/.opencode/commands/polishup.md +1 -1
- package/README.md +103 -111
- package/cli/detection.mjs +75 -0
- package/cli/hosts.mjs +11 -1
- package/cli/index.mjs +192 -146
- package/cli/installations.mjs +2 -0
- package/cli/menu.mjs +124 -0
- package/cli/plugins.mjs +61 -0
- package/cli/prompts.mjs +166 -0
- package/cli/update.mjs +3 -2
- package/package.json +68 -53
- package/plugin.json +29 -0
- package/skills/polishup/SKILL.md +1 -1
- package/skills/polishup/agents/openai.yaml +4 -0
- package/skills/polishup/references/colors.md +1 -1
- package/skills/polishup/scripts/color.mjs +1 -1
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "polishup-local",
|
|
3
|
+
"interface": {
|
|
4
|
+
"displayName": "PolishUp"
|
|
5
|
+
},
|
|
6
|
+
"plugins": [
|
|
7
|
+
{
|
|
8
|
+
"name": "polishup",
|
|
9
|
+
"source": {
|
|
10
|
+
"source": "local",
|
|
11
|
+
"path": "./"
|
|
12
|
+
},
|
|
13
|
+
"policy": {
|
|
14
|
+
"installation": "AVAILABLE",
|
|
15
|
+
"authentication": "ON_INSTALL"
|
|
16
|
+
},
|
|
17
|
+
"category": "Productivity"
|
|
18
|
+
}
|
|
19
|
+
]
|
|
20
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://antigravity.google/schemas/v1/plugin.json",
|
|
3
|
+
"name": "polishup",
|
|
4
|
+
"displayName": "PolishUp",
|
|
5
|
+
"version": "0.3.0",
|
|
6
|
+
"description": "An AI agent skill for writing, design, code, and more. It combines task-specific research and practical guidance to create, refine, and review work while reducing generic AI output.",
|
|
7
|
+
"suggestedPrompts": [
|
|
8
|
+
"Use PolishUp to review this draft without changing it.",
|
|
9
|
+
"Use PolishUp to refine this interface while preserving its visual identity.",
|
|
10
|
+
"Use PolishUp to plan a Blender product render using research relevant to my version and delivery requirements."
|
|
11
|
+
]
|
|
12
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "polishup-local",
|
|
3
|
+
"owner": {
|
|
4
|
+
"name": "fachriaziz"
|
|
5
|
+
},
|
|
6
|
+
"plugins": [
|
|
7
|
+
{
|
|
8
|
+
"name": "polishup",
|
|
9
|
+
"source": "./",
|
|
10
|
+
"description": "An AI agent skill for writing, design, code, and more. It combines task-specific research and practical guidance to create, refine, and review work while reducing generic AI output."
|
|
11
|
+
}
|
|
12
|
+
]
|
|
13
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "polishup",
|
|
3
|
+
"displayName": "PolishUp",
|
|
4
|
+
"author": {
|
|
5
|
+
"name": "fachriaziz"
|
|
6
|
+
},
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"homepage": "https://github.com/fachriaziz/polishup",
|
|
9
|
+
"repository": "https://github.com/fachriaziz/polishup",
|
|
10
|
+
"version": "0.3.0",
|
|
11
|
+
"description": "An AI agent skill for writing, design, code, and more. It combines task-specific research and practical guidance to create, refine, and review work while reducing generic AI output."
|
|
12
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "polishup",
|
|
3
|
+
"version": "0.3.0",
|
|
4
|
+
"description": "An AI agent skill for writing, design, code, and more. It combines task-specific research and practical guidance to create, refine, and review work while reducing generic AI output.",
|
|
5
|
+
"skills": "./skills/",
|
|
6
|
+
"author": {
|
|
7
|
+
"name": "fachriaziz"
|
|
8
|
+
},
|
|
9
|
+
"license": "MIT",
|
|
10
|
+
"homepage": "https://github.com/fachriaziz/polishup",
|
|
11
|
+
"repository": "https://github.com/fachriaziz/polishup",
|
|
12
|
+
"interface": {
|
|
13
|
+
"displayName": "PolishUp",
|
|
14
|
+
"developerName": "fachriaziz",
|
|
15
|
+
"category": "Productivity",
|
|
16
|
+
"websiteURL": "https://github.com/fachriaziz/polishup",
|
|
17
|
+
"supportURL": "https://github.com/fachriaziz/polishup/issues",
|
|
18
|
+
"shortDescription": "Better writing, design, code",
|
|
19
|
+
"defaultPrompt": [
|
|
20
|
+
"Use PolishUp to review this draft without changing it.",
|
|
21
|
+
"Use PolishUp to refine this interface while preserving its visual identity.",
|
|
22
|
+
"Use PolishUp to plan a Blender product render using research relevant to my version and delivery requirements."
|
|
23
|
+
]
|
|
24
|
+
}
|
|
25
|
+
}
|
package/README.md
CHANGED
|
@@ -1,177 +1,169 @@
|
|
|
1
1
|
# PolishUp
|
|
2
2
|
|
|
3
|
-
An agent skill for
|
|
3
|
+
An AI agent skill for creating, refining, and reviewing writing, designs, code, and more.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
PolishUp helps reduce common **AI slop**, including generic writing, repetitive designs, unsupported claims, and unnecessarily complex code. It uses relevant guidance and research while respecting your goals and existing project conventions.
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
| --- | --- |
|
|
9
|
-
| [Writing](skills/polishup/references/writing/index.md) | Purpose, evidence, structure, language, voice, accessibility, and revision |
|
|
10
|
-
| [UI/UX Design](skills/polishup/references/ui-ux/index.md) | Research, navigation, interaction, visual design, responsiveness, accessibility, and evaluation |
|
|
11
|
-
| [Code](skills/polishup/references/code/index.md) | Readability, simplicity, correctness, and proportionate verification |
|
|
7
|
+
## What it covers
|
|
12
8
|
|
|
13
|
-
|
|
9
|
+
| Area | Focus |
|
|
10
|
+
| --- | --- |
|
|
11
|
+
| [Writing](skills/polishup/references/writing/index.md) | Clear, specific communication with sound evidence, structure, and an appropriate voice |
|
|
12
|
+
| [UI/UX Design](skills/polishup/references/ui-ux/index.md) | Usable interfaces with coherent visual design, accessible interactions, and responsive layouts |
|
|
13
|
+
| [Code](skills/polishup/references/code/index.md) | Readable, maintainable implementations without unnecessary complexity |
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
For other fields, PolishUp uses task-specific research and checks. Guidance loads on demand, using your agent's available tools without requiring a particular model, framework, MCP server, or hook.
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
An optional [color helper](skills/polishup/references/colors.md) supports contrast checks and palette exploration.
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
npm start
|
|
21
|
-
```
|
|
19
|
+
## What you can do
|
|
22
20
|
|
|
23
|
-
|
|
21
|
+
Ask for an action in your agent's chat. These labels are optional.
|
|
24
22
|
|
|
25
|
-
|
|
23
|
+
| Action | What it does | Example request |
|
|
24
|
+
| --- | --- | --- |
|
|
25
|
+
| Review | Reports findings without editing | "Use PolishUp to review this draft without changing it." |
|
|
26
|
+
| Refine | Improves requested parts while preserving the rest | "Use PolishUp to refine this dashboard. Preserve its visual identity." |
|
|
27
|
+
| Create | Produces new work from your brief | "Use PolishUp to write a product announcement from these facts." |
|
|
28
|
+
| Redesign | Reworks the parts you specify | "Use PolishUp to redesign the settings page, keeping its existing flows." |
|
|
26
29
|
|
|
27
|
-
|
|
30
|
+
## Installation
|
|
28
31
|
|
|
29
|
-
|
|
32
|
+
Requires **Node.js 22 or newer**. Choose either option below and run the installer from the project where you want to use PolishUp.
|
|
30
33
|
|
|
31
|
-
###
|
|
34
|
+
### Run with npx
|
|
32
35
|
|
|
33
|
-
|
|
36
|
+
Use the installer without installing the CLI globally:
|
|
34
37
|
|
|
35
|
-
```
|
|
38
|
+
```sh
|
|
36
39
|
npx polishup-cli
|
|
37
40
|
```
|
|
38
41
|
|
|
39
|
-
|
|
42
|
+
### Install with npm
|
|
40
43
|
|
|
41
|
-
|
|
44
|
+
Install the CLI once, then use the shorter `polishup` command:
|
|
42
45
|
|
|
43
|
-
|
|
46
|
+
```sh
|
|
47
|
+
npm install -g polishup-cli
|
|
48
|
+
polishup
|
|
49
|
+
```
|
|
44
50
|
|
|
45
|
-
|
|
46
|
-
| --- | --- | --- |
|
|
47
|
-
| [Codex](https://developers.openai.com/codex/skills) | `.agents/skills/polishup/` | `~/.agents/skills/polishup/` |
|
|
48
|
-
| [Claude Code](https://code.claude.com/docs/en/skills) | `.claude/skills/polishup/` | `~/.claude/skills/polishup/` |
|
|
49
|
-
| [OpenCode](https://opencode.ai/docs/skills/) | `.opencode/skills/polishup/` | `~/.config/opencode/skills/polishup/` |
|
|
50
|
-
| [Cursor](https://cursor.com/docs/skills) | `.cursor/skills/polishup/` | `~/.cursor/skills/polishup/` |
|
|
51
|
-
| [Oh My Pi (OMP)](https://github.com/can1357/oh-my-pi/blob/main/docs/skills.md) | `.omp/skills/polishup/` | `~/.omp/agent/skills/polishup/` |
|
|
52
|
-
| [Gemini CLI](https://geminicli.com/docs/cli/skills/) | `.gemini/skills/polishup/` | `~/.gemini/skills/polishup/` |
|
|
53
|
-
| [GitHub Copilot](https://docs.github.com/en/copilot/concepts/customizations/agent-skills) | `.github/skills/polishup/` | `~/.copilot/skills/polishup/` |
|
|
54
|
-
| [Antigravity](https://antigravity.google/docs/skills) | `.agents/skills/polishup/` | `~/.gemini/config/skills/polishup/` |
|
|
55
|
-
| [Hermes](https://github.com/NousResearch/hermes-agent/blob/main/agent/skill_utils.py) | `.agents/skills/polishup/` | `<effective Hermes home>/skills/polishup/` |
|
|
51
|
+
Both options open the same installer. Choose your agent, select project or personal installation, and review the destinations before confirming. Installing the CLI alone does not install the skill into your agent. Project installation applies to the nearest Git project, or the current folder when there is no Git repository.
|
|
56
52
|
|
|
57
|
-
|
|
53
|
+
The installer supports Codex, Claude Code, OpenCode, Cursor, Oh My Pi, Gemini CLI, GitHub Copilot, Antigravity, and Hermes, plus custom destinations. It runs on Windows, macOS, and Linux, subject to your agent's platform support.
|
|
58
54
|
|
|
59
|
-
|
|
60
|
-
- Gemini: `<GEMINI_CLI_HOME>/.gemini/skills/polishup/`; relative home overrides resolve from the working directory.
|
|
61
|
-
- OMP: set `PI_CODING_AGENT_DIR` for a custom agent directory, or choose a manual destination when its profile location is unresolved.
|
|
62
|
-
- Hermes: honors `HERMES_HOME` and `HERMES_DATA_DIR_SUFFIX`; default homes are `~/.hermes` on POSIX and `%LOCALAPPDATA%/hermes` on Windows. `--profile` selects an existing named personal profile. Project discovery requires a trusted Git project; installation does not grant trust.
|
|
55
|
+
Reload your agent's skills or start a new session after installation. Discovery and available commands depend on the agent.
|
|
63
56
|
|
|
64
|
-
For
|
|
57
|
+
For a native plugin, use `npx polishup-cli install --plugin --agent codex` or replace `codex` with `claude`. The selected host CLI must be installed. Guided personal setup for these hosts also offers a plugin option.
|
|
65
58
|
|
|
66
|
-
|
|
59
|
+
<details>
|
|
60
|
+
<summary>Other installation methods</summary>
|
|
67
61
|
|
|
68
|
-
###
|
|
62
|
+
### From source
|
|
69
63
|
|
|
70
|
-
|
|
64
|
+
```sh
|
|
65
|
+
git clone https://github.com/fachriaziz/polishup.git
|
|
66
|
+
cd polishup
|
|
67
|
+
npm ci --ignore-scripts
|
|
68
|
+
npm start
|
|
69
|
+
```
|
|
71
70
|
|
|
72
|
-
|
|
73
|
-
| --- | --- |
|
|
74
|
-
| Claude Code | `.claude-plugin/plugin.json`; load locally with `claude --plugin-dir "<path-to-polishup>"` |
|
|
75
|
-
| Codex | Root `plugin.json`, `.codex-plugin/plugin.json`, and `.agents/plugins/marketplace.json`; register the root as a local marketplace, then add `polishup@polishup-local` through the host |
|
|
76
|
-
| Antigravity | `.antigravity-plugin/plugin.json`; use its documented plugin manager |
|
|
77
|
-
| Cursor and OMP | Portable `plugin.json` is present; native plugin installation and activation remain unverified |
|
|
71
|
+
This runs the local installer. Choose personal installation to use PolishUp across your projects. Project installation targets this checkout; to install into another project, run `node "<path-to-polishup>/cli/index.mjs"` from that project's folder.
|
|
78
72
|
|
|
79
|
-
|
|
73
|
+
### Manual installation
|
|
80
74
|
|
|
81
|
-
|
|
75
|
+
Copy the complete `skills/polishup/` folder into your agent's skills directory, keeping its contents and relative paths intact. For example, Claude Code project skills use `.claude/skills/polishup/`.
|
|
82
76
|
|
|
83
|
-
|
|
84
|
-
- "Use PolishUp to refine this interface. Preserve its visual identity."
|
|
85
|
-
- "Use PolishUp to review this function. Report findings without editing it."
|
|
86
|
-
- "Use PolishUp to plan a Blender product render. Research methods for my version and delivery requirements."
|
|
77
|
+
Reading the skill requires no Node.js or Python. The optional color helper requires Node.js 22+. For OpenCode's `/polishup` command, also copy `.opencode/commands/polishup.md` into the matching commands directory; the installer handles this automatically.
|
|
87
78
|
|
|
88
|
-
|
|
79
|
+
### Native plugins
|
|
89
80
|
|
|
90
|
-
|
|
81
|
+
The package includes native plugin manifests and catalogs. `--plugin` delegates installation, updates, and removal to the host's own plugin manager, using the GitHub repository as a persistent source:
|
|
91
82
|
|
|
92
|
-
|
|
|
83
|
+
| Agent | Installation |
|
|
93
84
|
| --- | --- |
|
|
94
|
-
| Codex
|
|
95
|
-
| Claude Code
|
|
96
|
-
|
|
|
97
|
-
| OMP | `/skill:polishup ...` when skill commands are enabled; otherwise request it by name |
|
|
98
|
-
| Hermes | `/skill polishup`, then state the task |
|
|
99
|
-
| Gemini CLI and supported Copilot clients | Request PolishUp by name; approve native activation when prompted |
|
|
100
|
-
|
|
101
|
-
PolishUp requires initial research into applicable methods, quality criteria, and documented failures. Depth follows the task; evidence already checked for it can be reused. Research supports decisions and does not replace checking the actual result. When current research cannot be accessed, the agent must disclose the limitation and avoid unsupported claims.
|
|
85
|
+
| Codex / ChatGPT desktop | `polishup install --plugin --agent codex` |
|
|
86
|
+
| Claude Code | `polishup install --plugin --agent claude` |
|
|
87
|
+
| Antigravity | Install the checkout through its plugin manager |
|
|
102
88
|
|
|
103
|
-
|
|
89
|
+
Codex CLI plugin installation is personal. Claude Code also accepts `--scope project`. Native host policies and permissions remain in effect. Installing locally does not publish PolishUp to the public plugin directory or install it into web/mobile sessions.
|
|
104
90
|
|
|
105
|
-
|
|
91
|
+
For source development, Codex accepts `codex plugin marketplace add "<path-to-polishup>"`, then `codex plugin add polishup@polishup-local`. Claude Code accepts `claude --plugin-dir "<path-to-polishup>"` for a local session.
|
|
106
92
|
|
|
107
|
-
|
|
93
|
+
Use one installation method per agent and scope. Existing standalone copies are preserved; remove the old copy through its installer if you want to use only the plugin. Refresh plugins or restart the host afterward.
|
|
108
94
|
|
|
109
|
-
|
|
110
|
-
git pull
|
|
111
|
-
npm start
|
|
112
|
-
```
|
|
95
|
+
</details>
|
|
113
96
|
|
|
114
|
-
|
|
97
|
+
## Using the skill
|
|
115
98
|
|
|
116
|
-
|
|
99
|
+
These requests go in your agent's chat, not your terminal. You can also use its supported skill shortcuts:
|
|
117
100
|
|
|
118
|
-
|
|
101
|
+
| Agent | Invocation |
|
|
102
|
+
| --- | --- |
|
|
103
|
+
| Codex | `$polishup review ...` |
|
|
104
|
+
| Claude Code, OpenCode, Antigravity | `/polishup review ...` |
|
|
105
|
+
| Cursor | Type `/` and select `polishup` in Agent chat |
|
|
106
|
+
| Oh My Pi | `/skill:polishup ...` when skill commands are enabled |
|
|
107
|
+
| Hermes | `/skill polishup`, then describe the task |
|
|
108
|
+
| Gemini CLI, supported Copilot clients | Request PolishUp by name and approve activation if prompted |
|
|
119
109
|
|
|
120
|
-
|
|
110
|
+
Plugin installations may use a namespaced command. Available shortcuts depend on the agent and installation method.
|
|
121
111
|
|
|
122
|
-
|
|
112
|
+
Default anti-slop rules guide new choices without authorizing unrelated rewrites or redesigns. State any specific style preferences in your request.
|
|
123
113
|
|
|
124
|
-
##
|
|
114
|
+
## CLI commands
|
|
125
115
|
|
|
126
|
-
|
|
116
|
+
Run these commands in your terminal. The examples use the globally installed CLI; with npx, replace `polishup` with `npx polishup-cli`, for example `npx polishup-cli update`.
|
|
127
117
|
|
|
128
|
-
|
|
118
|
+
| Command | Purpose |
|
|
119
|
+
| --- | --- |
|
|
120
|
+
| `polishup` | Open guided installation or manage existing installations |
|
|
121
|
+
| `polishup install` | Start installation setup directly |
|
|
122
|
+
| `polishup install --plugin --agent codex` | Install through Codex's native plugin manager |
|
|
123
|
+
| `polishup update` | Check for a newer published release and update installed skills |
|
|
124
|
+
| `polishup uninstall` | Remove an installer-managed skill installation |
|
|
125
|
+
| `polishup color check <foreground> <background>` | Check a color pair's contrast ratio |
|
|
126
|
+
| `polishup color generate --input <file>` | Generate palette candidates from a JSON file |
|
|
127
|
+
| `polishup --help` | Show installer options and examples |
|
|
128
|
+
| `polishup --version` | Show the CLI version |
|
|
129
129
|
|
|
130
|
-
|
|
131
|
-
node skills/polishup/scripts/color.mjs check "#222222" "#ffffff" --json
|
|
132
|
-
node skills/polishup/scripts/color.mjs generate --input palette.json --preview preview.html --json
|
|
133
|
-
```
|
|
130
|
+
Run installation management commands from the target project. `update` applies the published release to selected skill installations; to also replace your globally installed CLI, rerun `npm install -g polishup-cli`.
|
|
134
131
|
|
|
135
|
-
For
|
|
132
|
+
For native plugins, use `polishup update --plugin --agent codex` or `polishup uninstall --plugin --agent codex`, replacing `codex` with `claude` when appropriate. These use the host's registered Git marketplace and leave the marketplace available after removal. `--dry-run` previews the native commands without executing them.
|
|
136
133
|
|
|
137
|
-
|
|
134
|
+
<details>
|
|
135
|
+
<summary>Optional flags and color examples</summary>
|
|
138
136
|
|
|
139
|
-
|
|
140
|
-
- **Conflict or unsafe path:** inspect local changes and backups. Use the intended physical path instead of a symlink/junction. Do not remove ownership markers or locks to force replacement.
|
|
141
|
-
- **Native discovery unavailable:** provide the installed `SKILL.md` path and ask the agent to read it and only relevant linked references. Supply the texts directly if file access is unavailable. This does not register native discovery.
|
|
142
|
-
- **Windows PowerShell blocks npm:** use `npm.cmd` for development commands; no execution-policy change is needed. Quote paths containing spaces and preserve Unicode filenames.
|
|
143
|
-
- **Custom Hermes path fails:** POSIX variable names are case-sensitive; Windows expansion is case-insensitive. `%NAME%` expansion is Windows-only; `$NAME` and `${NAME}` are also supported. Undefined referenced variables stop installation.
|
|
137
|
+
Choose agents and preview a project installation without writing files:
|
|
144
138
|
|
|
145
|
-
|
|
139
|
+
```sh
|
|
140
|
+
polishup install --agent codex,claude --scope project --dry-run
|
|
141
|
+
```
|
|
146
142
|
|
|
147
|
-
|
|
143
|
+
Use `--scope user` for personal installation, `--plain` for text menus, or `--no-input` with explicit target options for noninteractive use. Run `polishup --help` for custom destinations, Hermes profiles, and replacement options.
|
|
148
144
|
|
|
149
|
-
|
|
145
|
+
Check a color pair:
|
|
150
146
|
|
|
151
|
-
```
|
|
152
|
-
|
|
153
|
-
npm run sync
|
|
154
|
-
npm test
|
|
147
|
+
```sh
|
|
148
|
+
polishup color check "#222222" "#ffffff" --json
|
|
155
149
|
```
|
|
156
150
|
|
|
157
|
-
|
|
151
|
+
Generate a palette from `palette.json`, optionally creating a new preview file:
|
|
158
152
|
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
Inspect the npm payload without publishing:
|
|
162
|
-
|
|
163
|
-
```text
|
|
164
|
-
npm pack --dry-run --json --ignore-scripts
|
|
153
|
+
```sh
|
|
154
|
+
polishup color generate --input palette.json --preview preview.html --json
|
|
165
155
|
```
|
|
166
156
|
|
|
167
|
-
|
|
157
|
+
Read [Color Tools](skills/polishup/references/colors.md) for the JSON format, supported methods, and limits. Color checks do not establish complete accessibility.
|
|
158
|
+
|
|
159
|
+
</details>
|
|
168
160
|
|
|
169
|
-
|
|
161
|
+
For a source checkout, run `git pull`, then `npm ci --ignore-scripts` and `npm start` to apply the updated copy. Update or remove manual and plugin installations through their original installation method.
|
|
170
162
|
|
|
171
|
-
##
|
|
163
|
+
## Help
|
|
172
164
|
|
|
173
|
-
|
|
165
|
+
If the skill is missing, check the installation destination and refresh your agent's skills. For questions or problems, [open an issue](https://github.com/fachriaziz/polishup/issues).
|
|
174
166
|
|
|
175
167
|
## License
|
|
176
168
|
|
|
177
|
-
[MIT](LICENSE)
|
|
169
|
+
[MIT](LICENSE). The color helper includes a [third-party notice](skills/polishup/scripts/NOTICE.txt).
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import os from 'node:os';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
|
|
5
|
+
const COMMANDS = {
|
|
6
|
+
codex: ['codex'], claude: ['claude'], opencode: ['opencode'], cursor: ['cursor', 'cursor-agent'],
|
|
7
|
+
omp: ['omp'], gemini: ['gemini'], copilot: ['copilot'], antigravity: ['agy', 'antigravity'], hermes: ['hermes'],
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export function detectHarnesses({ home = os.homedir(), cwd = process.cwd(), env = process.env, platform = process.platform } = {}, { fileSystem = fs } = {}) {
|
|
11
|
+
const windows = platform === 'win32';
|
|
12
|
+
const paths = windows ? path.win32 : path.posix;
|
|
13
|
+
const get = name => env[name] ?? (windows ? Object.entries(env).find(([key]) => key.toLowerCase() === name.toLowerCase())?.[1] : undefined);
|
|
14
|
+
const kind = (file, directory = false) => {
|
|
15
|
+
try { const stat = fileSystem.statSync(file); return directory ? stat.isDirectory() : stat.isFile(); }
|
|
16
|
+
catch { return false; }
|
|
17
|
+
};
|
|
18
|
+
const executable = file => {
|
|
19
|
+
if (!kind(file)) return false;
|
|
20
|
+
if (windows) return true;
|
|
21
|
+
try { fileSystem.accessSync(file, fs.constants.X_OK); return true; }
|
|
22
|
+
catch { return false; }
|
|
23
|
+
};
|
|
24
|
+
const directories = (get('PATH') || '').split(windows ? ';' : ':')
|
|
25
|
+
.map(value => value.trim().replace(/^"(.*)"$/, '$1')).filter(value => paths.isAbsolute(value));
|
|
26
|
+
const extensions = windows ? (get('PATHEXT') || '.COM;.EXE;.BAT;.CMD').split(';')
|
|
27
|
+
.filter(value => /^\.[a-z0-9]+$/i.test(value)).map(value => value.toLowerCase()) : [''];
|
|
28
|
+
const find = commands => {
|
|
29
|
+
for (const directory of directories) for (const command of commands) for (const extension of extensions) {
|
|
30
|
+
const file = paths.join(directory, `${command}${extension}`);
|
|
31
|
+
if (executable(file)) return file;
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
const configured = value => value ? paths.resolve(cwd, value) : undefined;
|
|
35
|
+
const local = get('LOCALAPPDATA') || paths.join(home, 'AppData', 'Local');
|
|
36
|
+
const programFiles = [get('ProgramFiles'), get('ProgramFiles(x86)')].filter(Boolean);
|
|
37
|
+
const results = {};
|
|
38
|
+
for (const [agent, commands] of Object.entries(COMMANDS)) {
|
|
39
|
+
let evidence = find(commands);
|
|
40
|
+
// `agent` is a generic name: only accept an identifiable Cursor installation path.
|
|
41
|
+
if (!evidence && agent === 'cursor') {
|
|
42
|
+
const launcher = find(['agent']);
|
|
43
|
+
if (launcher) {
|
|
44
|
+
try { if (/cursor[-_ ]?agent|[\\/]cursor[\\/]/i.test(fileSystem.realpathSync(launcher))) evidence = launcher; }
|
|
45
|
+
catch { /* A broken or unreadable launcher is not detected. */ }
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
const appFiles = windows ? {
|
|
49
|
+
cursor: [paths.join(local, 'Programs', 'cursor', 'Cursor.exe'), ...programFiles.map(root => paths.join(root, 'Cursor', 'Cursor.exe'))],
|
|
50
|
+
antigravity: [paths.join(local, 'agy', 'bin', 'agy.exe')],
|
|
51
|
+
} : {};
|
|
52
|
+
if (!evidence) evidence = (appFiles[agent] || []).find(executable);
|
|
53
|
+
if (!evidence && platform === 'darwin' && agent === 'cursor') {
|
|
54
|
+
evidence = ['/Applications/Cursor.app', paths.join(home, 'Applications', 'Cursor.app')].find(file => kind(file, true));
|
|
55
|
+
}
|
|
56
|
+
if (evidence) { results[agent] = { status: 'detected', evidence }; continue; }
|
|
57
|
+
const own = name => [paths.join(cwd, name), paths.join(home, name)];
|
|
58
|
+
const configDirectories = {
|
|
59
|
+
codex: [configured(get('CODEX_HOME')), ...own('.codex')],
|
|
60
|
+
claude: [configured(get('CLAUDE_CONFIG_DIR')), ...own('.claude')],
|
|
61
|
+
opencode: [configured(get('OPENCODE_CONFIG_DIR')), ...own('.opencode'), paths.join(get('XDG_CONFIG_HOME') || paths.join(home, '.config'), 'opencode')],
|
|
62
|
+
cursor: own('.cursor'), omp: [configured(get('PI_CODING_AGENT_DIR')), ...own('.omp')],
|
|
63
|
+
gemini: [], copilot: [paths.join(home, '.copilot')],
|
|
64
|
+
antigravity: [paths.join(home, '.gemini', 'config'), paths.join(home, '.gemini', 'antigravity')],
|
|
65
|
+
hermes: [configured(get('HERMES_HOME')), windows ? paths.join(local, `hermes${get('HERMES_DATA_DIR_SUFFIX') || ''}`) : paths.join(home, `.hermes${get('HERMES_DATA_DIR_SUFFIX') || ''}`)],
|
|
66
|
+
};
|
|
67
|
+
evidence = configDirectories[agent].filter(Boolean).find(file => kind(file, true));
|
|
68
|
+
if (!evidence && agent === 'gemini') {
|
|
69
|
+
evidence = [paths.join(cwd, '.gemini', 'settings.json'), paths.resolve(cwd, get('GEMINI_CLI_HOME') || home, '.gemini', 'settings.json')].find(file => kind(file));
|
|
70
|
+
}
|
|
71
|
+
if (!evidence && agent === 'copilot') evidence = [paths.join(cwd, '.github', 'copilot-instructions.md')].find(file => kind(file));
|
|
72
|
+
results[agent] = evidence ? { status: 'configured', evidence } : { status: 'not-detected' };
|
|
73
|
+
}
|
|
74
|
+
return results;
|
|
75
|
+
}
|
package/cli/hosts.mjs
CHANGED
|
@@ -22,7 +22,7 @@ export function getStorageGroup(agent, scope) {
|
|
|
22
22
|
const PROFILE_NAME = /^[a-z0-9][a-z0-9_-]{0,63}$/;
|
|
23
23
|
const RESERVED_PROFILES = new Set(['hermes', 'default', 'test', 'tmp', 'root', 'sudo']);
|
|
24
24
|
|
|
25
|
-
function projectRootFor(cwd) {
|
|
25
|
+
export function projectRootFor(cwd) {
|
|
26
26
|
let current = path.resolve(cwd);
|
|
27
27
|
while (true) {
|
|
28
28
|
if (fs.existsSync(path.join(current, '.git'))) return current;
|
|
@@ -88,6 +88,16 @@ function hermesTargetHome({ home, env, cwd, platform, profile }) {
|
|
|
88
88
|
return { home: defaultHome, profile: 'default' };
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
+
export function hermesProfiles({ home = os.homedir(), env = process.env, cwd = process.cwd(), platform = process.platform } = {}) {
|
|
92
|
+
const configured = hermesTargetHome({ home, env, cwd, platform }).home;
|
|
93
|
+
const root = path.basename(path.dirname(configured)) === 'profiles' ? path.dirname(path.dirname(configured)) : configured;
|
|
94
|
+
try {
|
|
95
|
+
return fs.readdirSync(path.join(root, 'profiles'), { withFileTypes: true })
|
|
96
|
+
.filter(entry => entry.isDirectory() && PROFILE_NAME.test(entry.name) && !RESERVED_PROFILES.has(entry.name))
|
|
97
|
+
.map(entry => entry.name).sort();
|
|
98
|
+
} catch (error) { if (error.code === 'ENOENT') return []; throw error; }
|
|
99
|
+
}
|
|
100
|
+
|
|
91
101
|
export function getTarget({ agent, scope, cwd = process.cwd(), home = os.homedir(), env = process.env, profile, platform = process.platform }) {
|
|
92
102
|
const definition = HOSTS[agent];
|
|
93
103
|
if (!definition) throw new Error(`Unknown agent: ${agent}`);
|