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.
@@ -0,0 +1,166 @@
1
+ import { createInterface } from 'node:readline';
2
+ import { styleText } from 'node:util';
3
+
4
+ const enabled = value => Boolean(value && value !== '0' && value !== 'false');
5
+ const cancelled = () => new Error('Cancelled.');
6
+ export const BACK = Symbol('back');
7
+
8
+ export async function createPrompts({ input = process.stdin, output = process.stdout, env = process.env, plain = false, noInput = false } = {}) {
9
+ const interactive = Boolean(input.isTTY && !noInput && !enabled(env.CI));
10
+ let rich, core;
11
+ if (interactive && output.isTTY && !plain && !env.NO_COLOR && env.TERM !== 'dumb' && !enabled(env.ACCESSIBLE)) {
12
+ try { rich = await import('@clack/prompts'); core = await import('@clack/core'); }
13
+ catch (error) {
14
+ if (error.code !== 'ERR_MODULE_NOT_FOUND' || !error.message.includes('@clack/prompts')) throw error;
15
+ output.write('Using text menus. Run npm ci in the checkout to enable keyboard menus.\n');
16
+ }
17
+ }
18
+ let reader, lines, aborted = false, activeBack = false;
19
+ const write = message => output.write(`${message}\n`);
20
+ const interrupt = () => { aborted = true; reader?.close(); };
21
+ const plainEscape = (_value, key) => {
22
+ if (activeBack && key?.name === 'escape') {
23
+ reader.write(null, { ctrl: true, name: 'u' });
24
+ reader.emit('line', BACK);
25
+ }
26
+ };
27
+ const terminal = Boolean(input.isTTY && output.isTTY && typeof input.setRawMode === 'function');
28
+ const footer = (kind, back) => [
29
+ ...(kind !== 'text' ? [rich ? '↑/↓: Move' : 'Numbers: Select'] : []),
30
+ ...(kind === 'multi' && rich ? ['Space: Select'] : []),
31
+ 'Enter: Continue', ...(back ? [terminal || rich ? 'Esc: Back' : kind === 'text' ? ':back: Back' : 'b: Back'] : []), 'Ctrl+C: Cancel',
32
+ ];
33
+ const ask = async (message, back = false) => {
34
+ if (!interactive) throw new Error('Supply --agent and --scope outside an interactive terminal, or when input is disabled.');
35
+ if (aborted) throw cancelled();
36
+ if (!reader) {
37
+ reader = createInterface({ input, output,
38
+ terminal, crlfDelay: Infinity, escapeCodeTimeout: 50 });
39
+ lines = reader[Symbol.asyncIterator]();
40
+ reader.on('SIGINT', interrupt);
41
+ process.on('SIGINT', interrupt);
42
+ input.on('keypress', plainEscape);
43
+ }
44
+ activeBack = back;
45
+ if (reader.terminal) { reader.setPrompt(`${message}: `); reader.prompt(); }
46
+ else output.write(`${message}: `);
47
+ const result = await lines.next();
48
+ activeBack = false;
49
+ if (result.done || aborted) throw cancelled();
50
+ return result.value === BACK ? BACK : result.value.trim();
51
+ };
52
+ const result = async (run, back = false) => {
53
+ let goBack = false;
54
+ const keypress = (_value, key) => { goBack = key?.name === 'escape'; };
55
+ if (back) input.on('keypress', keypress);
56
+ try {
57
+ const value = await run();
58
+ if (rich.isCancel(value)) { if (back && goBack) return BACK; throw cancelled(); }
59
+ return value;
60
+ } finally { input.removeListener('keypress', keypress); }
61
+ };
62
+ const options = choices => choices.map(({ value, label, hint }) => ({ value, label, ...(hint ? { hint } : {}) }));
63
+ const richPrompt = async ({ kind, message, choices, back, initialValue, initialValues, validate }) => {
64
+ const paint = (format, text) => styleText(format, text, { validateStream: false });
65
+ const Prompt = kind === 'text' ? core.TextPrompt : kind === 'multi' ? core.MultiSelectPrompt : core.SelectPrompt;
66
+ const instructions = rich.formatInstructionFooter(output, footer(kind, back), true);
67
+ const controller = new AbortController();
68
+ const abort = () => controller.abort();
69
+ const endKey = (_value, key) => { if (key?.ctrl && key.name === 'd') queueMicrotask(abort); };
70
+ const prompt = new Prompt({ input, output, signal: controller.signal, ...(choices ? { options: options(choices) } : {}),
71
+ initialValue, initialValues, defaultValue: kind === 'text' ? initialValue : undefined,
72
+ validate: validate || (kind === 'multi' ? value => value?.length ? undefined : 'Select at least one harness.' : undefined),
73
+ render() {
74
+ const title = `${rich.symbol(this.state)} ${message}\n`;
75
+ if (this.state === 'submit' || this.state === 'cancel') {
76
+ const summary = kind === 'text' ? this.value || '' : choices.filter(choice => kind === 'multi'
77
+ ? this.value?.includes(choice.value) : choice.value === this.value).map(choice => choice.label).join(', ');
78
+ return `${title}${rich.S_BAR} ${paint('dim', summary)}`;
79
+ }
80
+ const body = kind === 'text' ? [this.userInputWithCursor] : rich.limitOptions({
81
+ options: this.options, cursor: this.cursor, output, columnPadding: 3, rowPadding: instructions.length + 4,
82
+ style: (choice, focused) => {
83
+ const selected = kind === 'multi' && this.value?.includes(choice.value);
84
+ const marker = kind === 'multi' ? selected ? rich.S_CHECKBOX_SELECTED : rich.S_CHECKBOX_INACTIVE
85
+ : focused ? rich.S_RADIO_ACTIVE : rich.S_RADIO_INACTIVE;
86
+ const row = `${marker} ${choice.label}${focused && choice.hint ? ` (${choice.hint})` : ''}`;
87
+ return focused ? paint(['cyanBright', 'bold'], `> ${row}`) : ` ${paint(selected ? 'green' : 'dim', row)}`;
88
+ },
89
+ });
90
+ const error = this.state === 'error' ? String(this.error).split('\n').map(line => `${rich.S_BAR} ${paint('yellow', line)}`) : [];
91
+ return [title.trimEnd(), ...body.map(line => `${rich.S_BAR} ${line}`), ...error, ...instructions].join('\n');
92
+ },
93
+ });
94
+ input.once('end', abort);
95
+ input.once('close', abort);
96
+ input.on('keypress', endKey);
97
+ try {
98
+ if (input.readableEnded || input.destroyed) abort();
99
+ return await prompt.prompt();
100
+ } finally {
101
+ input.removeListener('end', abort);
102
+ input.removeListener('close', abort);
103
+ input.removeListener('keypress', endKey);
104
+ }
105
+ };
106
+ const choose = async (message, choices, { multiple = false, back = false, initialValue, initialValues = [] } = {}) => {
107
+ if (!choices.length) throw new Error('No available choices. Supply an explicit target instead.');
108
+ if (!interactive) throw new Error('Supply --agent and --scope outside an interactive terminal.');
109
+ if (rich) {
110
+ return result(() => richPrompt({ kind: multiple ? 'multi' : 'select', message, choices, back, initialValue, initialValues }), back);
111
+ }
112
+ write(message);
113
+ choices.forEach((item, i) => write(` ${i + 1}. ${item.label}${item.hint ? ` (${item.hint})` : ''}${(multiple ? initialValues.includes(item.value) : item.value === initialValue) ? ' [selected]' : ''}`));
114
+ if (multiple ? initialValues.length : initialValue !== undefined) write('Enter keeps the previous selection.');
115
+ write(footer(multiple ? 'multi' : 'select', back).join(' | '));
116
+ while (true) {
117
+ const answer = await ask(multiple ? 'Choose numbers separated by commas' : 'Choose a number', back);
118
+ if (answer === BACK) return BACK;
119
+ if (back && /^(b|:back)$/i.test(answer)) return BACK;
120
+ if (/^(q|:cancel)$/i.test(answer)) throw cancelled();
121
+ if (!answer && (multiple ? initialValues.length : initialValue !== undefined)) return multiple ? [...initialValues] : initialValue;
122
+ const parts = answer.split(',').map(part => part.trim());
123
+ const indexes = parts.map(part => Number(part) - 1);
124
+ if (parts.every(part => /^[1-9]\d*$/.test(part)) && (multiple || parts.length === 1) &&
125
+ new Set(indexes).size === indexes.length && indexes.every(index => index < choices.length)) {
126
+ const values = indexes.map(index => choices[index].value);
127
+ return multiple ? values : values[0];
128
+ }
129
+ write(`Enter ${multiple ? 'valid, distinct numbers' : 'a valid number'} from 1 to ${choices.length}, or press Ctrl+C to cancel.`);
130
+ }
131
+ };
132
+ return {
133
+ interactive,
134
+ intro(message) { if (interactive) { if (rich) rich.intro(message, { output }); else write(`${message}\n`); } },
135
+ choose,
136
+ multi(message, choices, options = {}) { return choose(message, choices, { ...options, multiple: true }); },
137
+ async text(message, { validate = value => value ? undefined : 'Enter a value.', back = false, initialValue } = {}) {
138
+ const check = value => value === ':cancel' || (back && value === ':back') ? undefined : validate(value);
139
+ if (rich) {
140
+ const value = await result(() => richPrompt({ kind: 'text', message, initialValue, validate: check, back }), back);
141
+ if (value === BACK || (back && value === ':back')) return BACK;
142
+ if (value === ':cancel') throw cancelled();
143
+ return value;
144
+ }
145
+ write(message);
146
+ write(footer('text', back).join(' | '));
147
+ while (true) {
148
+ const value = await ask(`Path${initialValue ? ` [${initialValue}]` : ''}`, back);
149
+ if (value === BACK) return BACK;
150
+ const answer = value || initialValue || '';
151
+ if (back && answer === ':back') return BACK;
152
+ if (answer === ':cancel') throw cancelled();
153
+ const error = validate(answer);
154
+ if (!error) return answer;
155
+ write(error);
156
+ }
157
+ },
158
+ close() {
159
+ reader?.close();
160
+ input.pause();
161
+ input.unref?.();
162
+ input.removeListener('keypress', plainEscape);
163
+ process.removeListener('SIGINT', interrupt);
164
+ },
165
+ };
166
+ }
package/cli/update.mjs CHANGED
@@ -24,10 +24,11 @@ export function updateInvocation(version, args, npmCli) {
24
24
  `--package=${PACKAGE_NAME}@${version}`, '--', 'polishup', 'update', ...args] };
25
25
  }
26
26
 
27
- export function forwardedTargetArgs({ agent, agents, scope, profile, destination, replace = false }) {
27
+ export function forwardedTargetArgs({ agent, agents, scope, profile, destination, replace = false, plain = false, noInput = false }) {
28
28
  const selected = agents ?? (agent ? [agent] : []);
29
29
  return ['--agent', selected.join(','), '--scope', scope, ...(profile ? ['--profile', profile] : []),
30
- ...(destination ? ['--destination', destination] : []), ...(replace ? ['--replace'] : [])];
30
+ ...(destination ? ['--destination', destination] : []), ...(replace ? ['--replace'] : []),
31
+ ...(plain ? ['--plain'] : []), ...(noInput ? ['--no-input'] : [])];
31
32
  }
32
33
 
33
34
  function findNpmCli(env) {
package/package.json CHANGED
@@ -1,53 +1,68 @@
1
- {
2
- "name": "polishup-cli",
3
- "version": "0.1.0",
4
- "description": "Research-informed guidance for better AI work across writing, design, code, and more.",
5
- "author": "fachriaziz",
6
- "homepage": "https://github.com/fachriaziz/polishup#readme",
7
- "repository": {
8
- "type": "git",
9
- "url": "git+https://github.com/fachriaziz/polishup.git"
10
- },
11
- "bugs": {
12
- "url": "https://github.com/fachriaziz/polishup/issues"
13
- },
14
- "keywords": [
15
- "agent-skills",
16
- "ai-agents",
17
- "writing",
18
- "ui-ux",
19
- "code-quality"
20
- ],
21
- "license": "MIT",
22
- "publishConfig": {
23
- "registry": "https://registry.npmjs.org/"
24
- },
25
- "type": "module",
26
- "bin": {
27
- "polishup": "cli/index.mjs"
28
- },
29
- "engines": {
30
- "node": ">=22"
31
- },
32
- "files": [
33
- "skills/polishup/SKILL.md",
34
- "skills/polishup/LICENSE.txt",
35
- "skills/polishup/references/",
36
- "skills/polishup/scripts/",
37
- ".opencode/commands/polishup.md",
38
- "cli/index.mjs",
39
- "cli/hosts.mjs",
40
- "cli/installations.mjs",
41
- "cli/update.mjs"
42
- ],
43
- "scripts": {
44
- "start": "node cli/index.mjs",
45
- "test": "npm run check && node --test tests/*.test.mjs",
46
- "sync": "node scripts/prepare-tools.mjs && node scripts/export-native.mjs",
47
- "check": "node scripts/prepare-tools.mjs --check && node scripts/export-native.mjs --check"
48
- },
49
- "devDependencies": {
50
- "colorjs.io": "0.7.1",
51
- "esbuild": "0.28.2"
52
- }
53
- }
1
+ {
2
+ "name": "polishup-cli",
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
+ "author": "fachriaziz",
6
+ "homepage": "https://github.com/fachriaziz/polishup#readme",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/fachriaziz/polishup.git"
10
+ },
11
+ "bugs": {
12
+ "url": "https://github.com/fachriaziz/polishup/issues"
13
+ },
14
+ "keywords": [
15
+ "agent-skills",
16
+ "ai-agents",
17
+ "writing",
18
+ "ui-ux",
19
+ "code-quality"
20
+ ],
21
+ "license": "MIT",
22
+ "publishConfig": {
23
+ "registry": "https://registry.npmjs.org/"
24
+ },
25
+ "type": "module",
26
+ "bin": {
27
+ "polishup": "cli/index.mjs"
28
+ },
29
+ "engines": {
30
+ "node": ">=22"
31
+ },
32
+ "files": [
33
+ "skills/polishup/SKILL.md",
34
+ "skills/polishup/LICENSE.txt",
35
+ "skills/polishup/agents/",
36
+ "skills/polishup/references/",
37
+ "skills/polishup/scripts/",
38
+ ".opencode/commands/polishup.md",
39
+ "plugin.json",
40
+ ".codex-plugin/plugin.json",
41
+ ".claude-plugin/plugin.json",
42
+ ".claude-plugin/marketplace.json",
43
+ ".antigravity-plugin/plugin.json",
44
+ ".agents/plugins/marketplace.json",
45
+ "cli/index.mjs",
46
+ "cli/hosts.mjs",
47
+ "cli/detection.mjs",
48
+ "cli/menu.mjs",
49
+ "cli/prompts.mjs",
50
+ "cli/plugins.mjs",
51
+ "cli/installations.mjs",
52
+ "cli/update.mjs"
53
+ ],
54
+ "scripts": {
55
+ "start": "node cli/index.mjs",
56
+ "test": "npm run check && node --test tests/*.test.mjs",
57
+ "sync": "node scripts/prepare-tools.mjs && node scripts/export-native.mjs",
58
+ "check": "node scripts/prepare-tools.mjs --check && node scripts/export-native.mjs --check"
59
+ },
60
+ "devDependencies": {
61
+ "colorjs.io": "0.7.1",
62
+ "esbuild": "0.28.2"
63
+ },
64
+ "dependencies": {
65
+ "@clack/core": "1.6.0",
66
+ "@clack/prompts": "1.9.0"
67
+ }
68
+ }
package/plugin.json ADDED
@@ -0,0 +1,29 @@
1
+ {
2
+ "$schema": "https://agent-plugins.org/schemas/1.0.0/plugin.schema.json",
3
+ "name": "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
+ "extensions": {
13
+ "com.openai": {
14
+ "interface": {
15
+ "displayName": "PolishUp",
16
+ "developerName": "fachriaziz",
17
+ "category": "Productivity",
18
+ "websiteURL": "https://github.com/fachriaziz/polishup",
19
+ "supportURL": "https://github.com/fachriaziz/polishup/issues",
20
+ "shortDescription": "Better writing, design, code",
21
+ "defaultPrompt": [
22
+ "Use PolishUp to review this draft without changing it.",
23
+ "Use PolishUp to refine this interface while preserving its visual identity.",
24
+ "Use PolishUp to plan a Blender product render using research relevant to my version and delivery requirements."
25
+ ]
26
+ }
27
+ }
28
+ }
29
+ }
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: polishup
3
3
  license: MIT
4
- description: Guide creation, refinement, and review of deliverables using task-specific research and professional quality criteria. Use when drafting, designing, implementing, editing, debugging, or evaluating work across fields. Includes specialized Writing, UI/UX, and Code references; other fields use task-specific research. Not for casual conversation, standalone factual questions or calculations, or isolated word translations.
4
+ description: Create, refine, review, or redesign work using task-specific research and practical guidance. Use when writing, editing, designing, implementing, debugging, or reviewing work, including tasks outside the bundled Writing, UI/UX, and Code guidance. Not for casual conversation, standalone factual questions, simple calculations, or single-word translations.
5
5
  metadata:
6
6
  version: "0.1"
7
7
  ---
@@ -0,0 +1,4 @@
1
+ interface:
2
+ display_name: "PolishUp"
3
+ short_description: "Better writing, design, code"
4
+ default_prompt: "Use $polishup for this task, preserving the requested scope and existing conventions."
@@ -13,7 +13,7 @@ node "<absolute-skill-path>/scripts/color.mjs" check "#222222" "#ffffff" --json
13
13
  node "<absolute-skill-path>/scripts/color.mjs" generate --input "<palette.json>" --json
14
14
  ```
15
15
 
16
- Keep caller-relative input paths relative to the caller. Do not assume package-cache locations. `node "<package>/cli/index.mjs" color ...` is an optional wrapper over the same prepared implementation. The current private package is unpublished; do not fetch an unrelated registry package named PolishUp. Complete manual, native and installer copies carry the helper; reading instructions alone does not supply file access or a runtime.
16
+ Keep caller-relative input paths relative to the caller. Do not assume package-cache locations. The optional `polishup-cli` package exposes the same helper through `polishup color ...` or `node "<package>/cli/index.mjs" color ...`. Complete manual, native and installer copies carry the helper; reading instructions alone does not supply file access or a runtime.
17
17
 
18
18
  ## Check a pair
19
19
 
@@ -5605,7 +5605,7 @@ async function runColorCommand(args) {
5605
5605
  var toolVersion, engineVersion, init_color2 = __esm({
5606
5606
  "cli/color.mjs"() {
5607
5607
  init_src();
5608
- toolVersion = "0.1.0", engineVersion = "0.7.1";
5608
+ toolVersion = "0.3.0", engineVersion = "0.7.1";
5609
5609
  }
5610
5610
  });
5611
5611