polishup-cli 0.0.0-stage → 0.2.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/.opencode/commands/polishup.md +6 -0
- package/LICENSE +21 -0
- package/README.md +167 -3
- package/cli/detection.mjs +75 -0
- package/cli/hosts.mjs +181 -0
- package/cli/index.mjs +264 -0
- package/cli/installations.mjs +300 -0
- package/cli/menu.mjs +124 -0
- package/cli/prompts.mjs +166 -0
- package/cli/update.mjs +58 -0
- package/package.json +60 -6
- package/skills/polishup/LICENSE.txt +21 -0
- package/skills/polishup/SKILL.md +84 -0
- package/skills/polishup/references/code/implementation.md +43 -0
- package/skills/polishup/references/code/index.md +13 -0
- package/skills/polishup/references/code/rules.md +24 -0
- package/skills/polishup/references/colors.md +65 -0
- package/skills/polishup/references/research.md +50 -0
- package/skills/polishup/references/tools.md +57 -0
- package/skills/polishup/references/ui-ux/accessibility.md +136 -0
- package/skills/polishup/references/ui-ux/art-direction.md +127 -0
- package/skills/polishup/references/ui-ux/audio-and-video.md +121 -0
- package/skills/polishup/references/ui-ux/data-visualization.md +130 -0
- package/skills/polishup/references/ui-ux/design-ethics.md +98 -0
- package/skills/polishup/references/ui-ux/design-evaluation.md +123 -0
- package/skills/polishup/references/ui-ux/design-systems.md +110 -0
- package/skills/polishup/references/ui-ux/foundations.md +23 -0
- package/skills/polishup/references/ui-ux/index.md +29 -0
- package/skills/polishup/references/ui-ux/information-architecture.md +132 -0
- package/skills/polishup/references/ui-ux/interaction-design.md +155 -0
- package/skills/polishup/references/ui-ux/motion-design.md +110 -0
- package/skills/polishup/references/ui-ux/performance.md +109 -0
- package/skills/polishup/references/ui-ux/responsive-design.md +98 -0
- package/skills/polishup/references/ui-ux/rules.md +36 -0
- package/skills/polishup/references/ui-ux/ux-research.md +110 -0
- package/skills/polishup/references/ui-ux/visual-design.md +147 -0
- package/skills/polishup/references/writing/accessibility-and-inclusion.md +57 -0
- package/skills/polishup/references/writing/content-and-evidence.md +83 -0
- package/skills/polishup/references/writing/content-structure.md +94 -0
- package/skills/polishup/references/writing/foundations.md +19 -0
- package/skills/polishup/references/writing/index.md +17 -0
- package/skills/polishup/references/writing/language-and-style.md +83 -0
- package/skills/polishup/references/writing/multilingual-writing.md +51 -0
- package/skills/polishup/references/writing/purpose-audience-context.md +72 -0
- package/skills/polishup/references/writing/review-and-revision.md +81 -0
- package/skills/polishup/references/writing/rules.md +26 -0
- package/skills/polishup/references/writing/voice-and-tone.md +72 -0
- package/skills/polishup/scripts/NOTICE.txt +27 -0
- package/skills/polishup/scripts/color.mjs +5626 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 fachriaziz
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,167 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
# PolishUp
|
|
2
|
+
|
|
3
|
+
An agent skill for writing, design, code, and more.
|
|
4
|
+
|
|
5
|
+
PolishUp is an agent skill for creating, refining, and reviewing work. It helps address **AI slop**: generic writing, repetitive interface designs, unsupported claims, and unnecessarily complicated code.
|
|
6
|
+
|
|
7
|
+
It uses relevant research and professional guidance while respecting your goals and existing project conventions.
|
|
8
|
+
|
|
9
|
+
## What it covers
|
|
10
|
+
|
|
11
|
+
| Area | Focus |
|
|
12
|
+
| --- | --- |
|
|
13
|
+
| [Writing](skills/polishup/references/writing/index.md) | Clear, specific communication with sound evidence, structure, and an appropriate voice |
|
|
14
|
+
| [UI/UX Design](skills/polishup/references/ui-ux/index.md) | Usable interfaces with coherent visual design, accessible interactions, and responsive layouts |
|
|
15
|
+
| [Code](skills/polishup/references/code/index.md) | Readable, maintainable implementations without unnecessary complexity |
|
|
16
|
+
|
|
17
|
+
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.
|
|
18
|
+
|
|
19
|
+
An optional [color helper](skills/polishup/references/colors.md) supports contrast checks and palette exploration.
|
|
20
|
+
|
|
21
|
+
## Installation
|
|
22
|
+
|
|
23
|
+
Requires **Node.js 22 or newer**. Choose either option below and run the installer from the project where you want to use PolishUp.
|
|
24
|
+
|
|
25
|
+
### Run with npx
|
|
26
|
+
|
|
27
|
+
Use the installer without installing the CLI globally:
|
|
28
|
+
|
|
29
|
+
```sh
|
|
30
|
+
npx polishup-cli
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### Install with npm
|
|
34
|
+
|
|
35
|
+
Install the CLI once, then use the shorter `polishup` command:
|
|
36
|
+
|
|
37
|
+
```sh
|
|
38
|
+
npm install -g polishup-cli
|
|
39
|
+
polishup
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
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.
|
|
43
|
+
|
|
44
|
+
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.
|
|
45
|
+
|
|
46
|
+
Reload your agent's skills or start a new session after installation. Discovery and available commands depend on the agent.
|
|
47
|
+
|
|
48
|
+
<details>
|
|
49
|
+
<summary>Other installation methods</summary>
|
|
50
|
+
|
|
51
|
+
### From source
|
|
52
|
+
|
|
53
|
+
```sh
|
|
54
|
+
git clone https://github.com/fachriaziz/polishup.git
|
|
55
|
+
cd polishup
|
|
56
|
+
npm ci --ignore-scripts
|
|
57
|
+
npm start
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
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.
|
|
61
|
+
|
|
62
|
+
### Manual installation
|
|
63
|
+
|
|
64
|
+
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/`.
|
|
65
|
+
|
|
66
|
+
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.
|
|
67
|
+
|
|
68
|
+
### Native plugins
|
|
69
|
+
|
|
70
|
+
The source checkout also includes native plugin manifests. These are separate from the npm skill installer:
|
|
71
|
+
|
|
72
|
+
| Agent | Installation |
|
|
73
|
+
| --- | --- |
|
|
74
|
+
| Claude Code | Load the checkout with `claude --plugin-dir "<path-to-polishup>"` |
|
|
75
|
+
| Codex | Add the checkout as a local plugin marketplace, then install `polishup@polishup-local` |
|
|
76
|
+
| Antigravity | Install the checkout through its plugin manager |
|
|
77
|
+
|
|
78
|
+
Use one installation method per agent and scope to avoid duplicate copies.
|
|
79
|
+
|
|
80
|
+
</details>
|
|
81
|
+
|
|
82
|
+
## Using the skill
|
|
83
|
+
|
|
84
|
+
In your agent's chat, name PolishUp and describe the task:
|
|
85
|
+
|
|
86
|
+
```text
|
|
87
|
+
Use PolishUp to write a product announcement from these facts.
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
```text
|
|
91
|
+
Use PolishUp to refine this dashboard. Preserve its visual identity and workflows.
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
```text
|
|
95
|
+
Use PolishUp to review this function for unnecessary complexity. Report findings without editing it.
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
Ask it to create new work, refine existing work, review without editing, or redesign specified parts. Refinement preserves existing meaning, identity, and behavior outside the requested changes.
|
|
99
|
+
|
|
100
|
+
These requests go in your agent's chat, not your terminal. You can also use its supported skill shortcuts:
|
|
101
|
+
|
|
102
|
+
| Agent | Invocation |
|
|
103
|
+
| --- | --- |
|
|
104
|
+
| Codex | `$polishup review ...` |
|
|
105
|
+
| Claude Code, OpenCode, Antigravity | `/polishup review ...` |
|
|
106
|
+
| Cursor | Type `/` and select `polishup` in Agent chat |
|
|
107
|
+
| Oh My Pi | `/skill:polishup ...` when skill commands are enabled |
|
|
108
|
+
| Hermes | `/skill polishup`, then describe the task |
|
|
109
|
+
| Gemini CLI, supported Copilot clients | Request PolishUp by name and approve activation if prompted |
|
|
110
|
+
|
|
111
|
+
Plugin installations may use a namespaced command. Available shortcuts depend on the agent and installation method.
|
|
112
|
+
|
|
113
|
+
Default anti-slop rules guide new choices without authorizing unrelated rewrites or redesigns. State any specific style preferences in your request.
|
|
114
|
+
|
|
115
|
+
## CLI commands
|
|
116
|
+
|
|
117
|
+
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`.
|
|
118
|
+
|
|
119
|
+
| Command | Purpose |
|
|
120
|
+
| --- | --- |
|
|
121
|
+
| `polishup` | Open guided installation or manage existing installations |
|
|
122
|
+
| `polishup install` | Start installation setup directly |
|
|
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
|
+
|
|
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`.
|
|
131
|
+
|
|
132
|
+
<details>
|
|
133
|
+
<summary>Optional flags and color examples</summary>
|
|
134
|
+
|
|
135
|
+
Choose agents and preview a project installation without writing files:
|
|
136
|
+
|
|
137
|
+
```sh
|
|
138
|
+
polishup install --agent codex,claude --scope project --dry-run
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
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.
|
|
142
|
+
|
|
143
|
+
Check a color pair:
|
|
144
|
+
|
|
145
|
+
```sh
|
|
146
|
+
polishup color check "#222222" "#ffffff" --json
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
Generate a palette from `palette.json`, optionally creating a new preview file:
|
|
150
|
+
|
|
151
|
+
```sh
|
|
152
|
+
polishup color generate --input palette.json --preview preview.html --json
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
Read [Color Tools](skills/polishup/references/colors.md) for the JSON format, supported methods, and limits. Color checks do not establish complete accessibility.
|
|
156
|
+
|
|
157
|
+
</details>
|
|
158
|
+
|
|
159
|
+
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.
|
|
160
|
+
|
|
161
|
+
## Help
|
|
162
|
+
|
|
163
|
+
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).
|
|
164
|
+
|
|
165
|
+
## License
|
|
166
|
+
|
|
167
|
+
[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
ADDED
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import os from 'node:os';
|
|
3
|
+
import { createHash } from 'node:crypto';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
|
|
6
|
+
export const HOSTS = {
|
|
7
|
+
codex: { projectDir: '.agents', label: 'Codex', invocation: '$polishup review ...' },
|
|
8
|
+
claude: { projectDir: '.claude', label: 'Claude Code', invocation: '/polishup review ...' },
|
|
9
|
+
opencode: { projectDir: '.opencode', label: 'OpenCode', invocation: '/polishup review ...' },
|
|
10
|
+
cursor: { projectDir: '.cursor', label: 'Cursor', invocation: '/polishup review ... (select the skill in Agent chat)' },
|
|
11
|
+
omp: { projectDir: '.omp', label: 'Oh My Pi (OMP)', invocation: '/skill:polishup review ... (when skill commands are enabled)' },
|
|
12
|
+
gemini: { projectDir: '.gemini', label: 'Gemini CLI', invocation: 'Use the polishup skill to review ...; approve native activation when prompted.' },
|
|
13
|
+
copilot: { projectDir: '.github', label: 'GitHub Copilot', invocation: 'Use the polishup skill to review ...' },
|
|
14
|
+
antigravity: { projectDir: '.agents', label: 'Antigravity', invocation: '/polishup review ...' },
|
|
15
|
+
hermes: { projectDir: '.agents', label: 'Hermes', invocation: '/skill polishup (then state the task and target)' },
|
|
16
|
+
manual: { label: 'Manual destination', invocation: 'Read the installed SKILL.md and follow its linked references.' },
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export function getStorageGroup(agent, scope) {
|
|
20
|
+
return scope === 'project' && HOSTS[agent]?.projectDir === '.agents' ? 'agents-project' : `${agent}-${scope}`;
|
|
21
|
+
}
|
|
22
|
+
const PROFILE_NAME = /^[a-z0-9][a-z0-9_-]{0,63}$/;
|
|
23
|
+
const RESERVED_PROFILES = new Set(['hermes', 'default', 'test', 'tmp', 'root', 'sudo']);
|
|
24
|
+
|
|
25
|
+
export function projectRootFor(cwd) {
|
|
26
|
+
let current = path.resolve(cwd);
|
|
27
|
+
while (true) {
|
|
28
|
+
if (fs.existsSync(path.join(current, '.git'))) return current;
|
|
29
|
+
const parent = path.dirname(current);
|
|
30
|
+
if (parent === current) return path.resolve(cwd);
|
|
31
|
+
current = parent;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function expandHome(value, home) {
|
|
36
|
+
return value === '~' || value.startsWith(`~${path.sep}`) || value.startsWith('~/') || value.startsWith('~\\')
|
|
37
|
+
? path.join(home, value.slice(2))
|
|
38
|
+
: value;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function expandHermesPath(value, { home, env, cwd, platform }) {
|
|
42
|
+
let unresolved = false;
|
|
43
|
+
const expanded = expandHome(value, home).replace(/%([^%]+)%|\$\{([^}]+)\}|\$([A-Za-z0-9_]+)/g, (match, win, braced, plain) => {
|
|
44
|
+
if (win && platform !== 'win32') return match;
|
|
45
|
+
const key = win || braced || plain;
|
|
46
|
+
const result = env[key] ?? (platform === 'win32'
|
|
47
|
+
? Object.entries(env).find(([name]) => name.toLowerCase() === key.toLowerCase())?.[1]
|
|
48
|
+
: undefined);
|
|
49
|
+
if (result === undefined) { unresolved = true; return match; }
|
|
50
|
+
return result;
|
|
51
|
+
});
|
|
52
|
+
if (unresolved) throw new Error('HERMES_HOME contains an environment variable that is not set.');
|
|
53
|
+
return path.resolve(cwd, expanded);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function hermesDefaultHome({ home, env, platform }) {
|
|
57
|
+
const suffix = env.HERMES_DATA_DIR_SUFFIX || '';
|
|
58
|
+
if (platform === 'win32') {
|
|
59
|
+
const local = env.LOCALAPPDATA || path.join(home, 'AppData', 'Local');
|
|
60
|
+
return path.join(local, `hermes${suffix}`);
|
|
61
|
+
}
|
|
62
|
+
return path.join(home, `.hermes${suffix}`);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function relativeName(root, candidate, leaf) {
|
|
66
|
+
const rel = path.relative(path.resolve(root), path.resolve(candidate));
|
|
67
|
+
const parts = rel.split(path.sep);
|
|
68
|
+
return parts.length === 2 && parts[0] === leaf ? parts[1] : null;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function hermesTargetHome({ home, env, cwd, platform, profile }) {
|
|
72
|
+
const defaultHome = hermesDefaultHome({ home, env, platform });
|
|
73
|
+
const configuredHome = env.HERMES_HOME?.trim()
|
|
74
|
+
? expandHermesPath(env.HERMES_HOME.trim(), { home, env, cwd, platform })
|
|
75
|
+
: defaultHome;
|
|
76
|
+
const configuredProfileRoot = path.basename(path.dirname(configuredHome)) === 'profiles'
|
|
77
|
+
? path.dirname(path.dirname(configuredHome))
|
|
78
|
+
: configuredHome;
|
|
79
|
+
if (profile) {
|
|
80
|
+
if (!PROFILE_NAME.test(profile) || RESERVED_PROFILES.has(profile)) throw new Error('Invalid Hermes profile name. Use an existing lowercase profile name of up to 64 characters.');
|
|
81
|
+
const profileHome = path.join(configuredProfileRoot, 'profiles', profile);
|
|
82
|
+
if (!fs.statSync(profileHome, { throwIfNoEntry: false })?.isDirectory()) {
|
|
83
|
+
throw new Error(`Hermes profile "${profile}" does not exist at ${profileHome}.`);
|
|
84
|
+
}
|
|
85
|
+
return { home: profileHome, profile };
|
|
86
|
+
}
|
|
87
|
+
if (env.HERMES_HOME?.trim()) return { home: configuredHome, profile: relativeName(configuredProfileRoot, configuredHome, 'profiles') || (path.resolve(configuredHome) === path.resolve(defaultHome) ? 'default' : 'custom') };
|
|
88
|
+
return { home: defaultHome, profile: 'default' };
|
|
89
|
+
}
|
|
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
|
+
|
|
101
|
+
export function getTarget({ agent, scope, cwd = process.cwd(), home = os.homedir(), env = process.env, profile, platform = process.platform }) {
|
|
102
|
+
const definition = HOSTS[agent];
|
|
103
|
+
if (!definition) throw new Error(`Unknown agent: ${agent}`);
|
|
104
|
+
if (agent === 'manual') throw new Error('Use getManualTarget with an explicit manual destination.');
|
|
105
|
+
if (!['project', 'user'].includes(scope)) throw new Error(`Unknown scope: ${scope}`);
|
|
106
|
+
if (profile && agent !== 'hermes') throw new Error('--profile only applies to Hermes.');
|
|
107
|
+
|
|
108
|
+
const projectRoot = projectRootFor(cwd);
|
|
109
|
+
const base = scope === 'project' ? projectRoot : path.resolve(home);
|
|
110
|
+
let configRoot, effectiveProfile = null;
|
|
111
|
+
if (scope === 'project') {
|
|
112
|
+
if (agent === 'hermes' && !fs.existsSync(path.join(projectRoot, '.git'))) {
|
|
113
|
+
throw new Error('Hermes project skills require a Git project root. Use user scope or initialize/review the project repository first.');
|
|
114
|
+
}
|
|
115
|
+
configRoot = path.join(base, definition.projectDir || '.agents');
|
|
116
|
+
} else if (agent === 'codex') {
|
|
117
|
+
if (env.CODEX_HOME) {
|
|
118
|
+
const codexHome = path.resolve(env.CODEX_HOME);
|
|
119
|
+
if (!fs.statSync(codexHome, { throwIfNoEntry: false })?.isDirectory()) {
|
|
120
|
+
throw new Error(`CODEX_HOME must name an existing directory: ${codexHome}`);
|
|
121
|
+
}
|
|
122
|
+
configRoot = codexHome;
|
|
123
|
+
} else configRoot = path.join(base, '.agents');
|
|
124
|
+
} else if (agent === 'claude') {
|
|
125
|
+
configRoot = path.resolve(env.CLAUDE_CONFIG_DIR || path.join(base, '.claude'));
|
|
126
|
+
} else if (agent === 'opencode') {
|
|
127
|
+
configRoot = path.resolve(env.OPENCODE_CONFIG_DIR || path.join(env.XDG_CONFIG_HOME || path.join(base, '.config'), 'opencode'));
|
|
128
|
+
} else if (agent === 'antigravity') {
|
|
129
|
+
configRoot = path.join(base, '.gemini', 'config');
|
|
130
|
+
} else if (agent === 'cursor' || agent === 'copilot') {
|
|
131
|
+
configRoot = path.join(base, agent === 'cursor' ? '.cursor' : '.copilot');
|
|
132
|
+
} else if (agent === 'gemini') {
|
|
133
|
+
configRoot = path.resolve(cwd, env.GEMINI_CLI_HOME || base, '.gemini');
|
|
134
|
+
} else if (agent === 'omp') {
|
|
135
|
+
if (!env.PI_CODING_AGENT_DIR && (env.OMP_PROFILE || env.PI_PROFILE || env.PI_CONFIG_DIR || (platform === 'linux' && env.XDG_DATA_HOME))) {
|
|
136
|
+
throw new Error('OMP uses a custom profile or data directory. Set PI_CODING_AGENT_DIR to the effective agent directory, or use --agent manual --destination <effective-agent-dir>/skills/polishup.');
|
|
137
|
+
}
|
|
138
|
+
configRoot = path.resolve(expandHome(env.PI_CODING_AGENT_DIR || path.join(base, '.omp', 'agent'), base));
|
|
139
|
+
} else {
|
|
140
|
+
const resolved = hermesTargetHome({ home: base, env, cwd, platform, profile });
|
|
141
|
+
configRoot = resolved.home;
|
|
142
|
+
effectiveProfile = resolved.profile;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
const storageGroup = getStorageGroup(agent, scope);
|
|
146
|
+
const target = {
|
|
147
|
+
agent, scope, profile: effectiveProfile, projectRoot, configRoot,
|
|
148
|
+
skillDir: path.join(configRoot, 'skills', 'polishup'),
|
|
149
|
+
stateRoot: path.join(configRoot, '.polishup'),
|
|
150
|
+
storageGroup,
|
|
151
|
+
consumer: { agent, scope, profile: effectiveProfile },
|
|
152
|
+
invocation: definition.invocation,
|
|
153
|
+
discoveryNote: agent === 'hermes' && scope === 'project'
|
|
154
|
+
? 'Hermes loads project skills only from trusted Git projects. This installer does not grant trust.'
|
|
155
|
+
: null,
|
|
156
|
+
commandFile: agent === 'opencode' ? path.join(configRoot, 'commands', 'polishup.md') : null,
|
|
157
|
+
};
|
|
158
|
+
return target;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
export function getManualTarget({ destination, scope, cwd = process.cwd(), home = os.homedir(), platform = process.platform }) {
|
|
162
|
+
if (typeof destination !== 'string' || !destination.trim()) throw new Error('Manual installation requires --destination <path>.');
|
|
163
|
+
if (!['project', 'user'].includes(scope)) throw new Error('Manual destination requires --scope project or user.');
|
|
164
|
+
const skillDir = path.resolve(cwd, destination.trim());
|
|
165
|
+
const name = path.basename(skillDir);
|
|
166
|
+
if ((platform === 'win32' ? name.toLowerCase() : name) !== 'polishup') throw new Error('The manual destination must name the final `polishup` skill folder.');
|
|
167
|
+
const projectRoot = projectRootFor(cwd);
|
|
168
|
+
const stateBase = scope === 'project' ? projectRoot : path.resolve(home);
|
|
169
|
+
const key = createHash('sha256').update(platform === 'win32' ? skillDir.toLowerCase() : skillDir).digest('hex').slice(0, 24);
|
|
170
|
+
const profileKey = platform === 'win32' ? skillDir.toLowerCase() : skillDir;
|
|
171
|
+
return {
|
|
172
|
+
agent: 'manual', scope, profile: profileKey, projectRoot,
|
|
173
|
+
configRoot: path.dirname(skillDir), skillDir,
|
|
174
|
+
stateRoot: path.join(stateBase, '.polishup', 'manual', key),
|
|
175
|
+
storageGroup: `manual-${scope}`,
|
|
176
|
+
consumer: { agent: 'manual', scope, profile: profileKey },
|
|
177
|
+
invocation: HOSTS.manual.invocation,
|
|
178
|
+
discoveryNote: 'The skill is outside a harness-managed default location. Load the displayed SKILL.md path manually.',
|
|
179
|
+
commandFile: null,
|
|
180
|
+
};
|
|
181
|
+
}
|