@nexaduo/marc 26.1125.3 → 26.1125.5
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/README.md +26 -5
- package/lib/lists.js +18 -0
- package/lib/main.js +210 -42
- package/lib/style.js +72 -0
- package/package.json +1 -1
- package/release.json +3 -3
package/README.md
CHANGED
|
@@ -32,7 +32,7 @@ Then open any repository in your harness and run `/marc:tech-lead`.
|
|
|
32
32
|
| `--harness <claude\|copilot\|codex\|agy>` | Act only on the named harness; repeat for several. Default: every harness on `PATH` |
|
|
33
33
|
| `--scope <user\|project\|local>` | Claude Code only: the scope to install, update or uninstall |
|
|
34
34
|
| `--version <tag>` | Must equal the release embedded in this package; otherwise prints the matching `npx` command and exits |
|
|
35
|
-
| `--dry-run` | Print the plan and change nothing |
|
|
35
|
+
| `--dry-run` | Print the plan and change nothing (`install` still runs the read-only `plugin list` first) |
|
|
36
36
|
| `--yes` | Skip the confirmation prompt. Required for `install`, `update` and `uninstall` when not in a terminal; `doctor` and `--dry-run` never need it |
|
|
37
37
|
|
|
38
38
|
## What it does, and what it doesn't
|
|
@@ -45,13 +45,21 @@ Then open any repository in your harness and run `/marc:tech-lead`.
|
|
|
45
45
|
- Antigravity installs from a shallow clone of the release tag, checked against
|
|
46
46
|
the commit embedded in this package, then deletes the clone.
|
|
47
47
|
- `uninstall` never removes a marketplace registration.
|
|
48
|
-
- `
|
|
48
|
+
- `install` never upgrades an existing install. If the installed version differs
|
|
49
|
+
from the launcher release it prints `STALE` and exits non-zero; run `update`.
|
|
50
|
+
- `doctor` changes nothing and exits non-zero when it finds drift. Claude
|
|
51
|
+
`project` and `local` rows add the project they belong to as an extra field
|
|
52
|
+
(`~/repos/app` under your home directory, otherwise the absolute path). A harness whose only
|
|
53
|
+
problem is an older version, or a marketplace catalog still tracking `main`,
|
|
54
|
+
is `STALE`: run `npx @nexaduo/marc update`. `FAILED` means something else is
|
|
55
|
+
wrong (marketplace missing or drifted, plugin missing, release source
|
|
56
|
+
unverifiable, a native CLI error) and wins over `STALE`.
|
|
49
57
|
|
|
50
58
|
## Versions
|
|
51
59
|
|
|
52
60
|
Each npm version embeds one mARC release tag. A tag `vYY.M.D[.N]` (no leading
|
|
53
61
|
zeros) maps to npm `YY.(M*100+D).N`, where a missing `.N` is `0`. For example,
|
|
54
|
-
`v26.11.25.
|
|
62
|
+
`v26.11.25.5` is `26.1125.5` and `v26.12.1` is `26.1201.0`.
|
|
55
63
|
|
|
56
64
|
What a given package version pins:
|
|
57
65
|
|
|
@@ -63,11 +71,24 @@ What a given package version pins:
|
|
|
63
71
|
|
|
64
72
|
Use the latest package to keep every harness on the same release.
|
|
65
73
|
|
|
66
|
-
Releases
|
|
67
|
-
|
|
74
|
+
Releases are published from GitHub Actions with npm provenance once the npm
|
|
75
|
+
trusted publisher is bound (#426); until then npm may lag the git tag. `npx` does not verify provenance for you. To check it, run
|
|
68
76
|
`npm audit signatures` in a project that depends on the package; pinning an
|
|
69
77
|
exact version then keeps you on the release you checked.
|
|
70
78
|
|
|
79
|
+
## Console colors
|
|
80
|
+
|
|
81
|
+
Output is colored only when stdout is a terminal. Piped, redirected and CI
|
|
82
|
+
output is plain text with no escape sequences, identical to earlier releases.
|
|
83
|
+
|
|
84
|
+
- `NO_COLOR=1` (any non-empty value) turns color off.
|
|
85
|
+
- `FORCE_COLOR=1|2|3` turns it on even when piped (`2` implies 256 colors, `3`
|
|
86
|
+
truecolor); `FORCE_COLOR=0` turns it off. `NO_COLOR` wins over `FORCE_COLOR`.
|
|
87
|
+
- Truecolor is used when `COLORTERM` is `truecolor` or `24bit`, 256 colors when
|
|
88
|
+
`TERM` contains `256color`, otherwise 16 colors. `TERM=dumb` and legacy
|
|
89
|
+
Windows consoles stay plain.
|
|
90
|
+
- `COLORFGBG` ending in `7` or `15` selects a light-background palette.
|
|
91
|
+
|
|
71
92
|
## Links
|
|
72
93
|
|
|
73
94
|
- Source, docs and issues: https://github.com/NexaDuo/mARC
|
package/lib/lists.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
const VERSION = /\b(?:v)?([0-9]{2}\.[0-9]{1,2}\.[0-9]{1,2}(?:\.[0-9]+)?)\b/;
|
|
2
|
+
// Native CLI output is untrusted: print only a VERSION-shaped value.
|
|
3
|
+
export const safeVersion = v => /^v?[0-9]{2}\.[0-9]{1,2}\.[0-9]{1,2}(?:\.[0-9]+)?$/.test(String(v ?? '')) ? String(v).replace(/^v/, '') : 'unknown';
|
|
2
4
|
const stripAnsi = s => s.replace(/\x1b\[[0-9;]*m/g, '');
|
|
3
5
|
|
|
4
6
|
export function parsePlugins(harness, output) {
|
|
@@ -14,6 +16,8 @@ export function parsePlugins(harness, output) {
|
|
|
14
16
|
if (!version) throw new Error('Cannot read Copilot plugin version');
|
|
15
17
|
result.push({ version, scope: '', enabled: !/disabled|enabled:\s*false/i.test(block), source: block.match(/Source:\s*(.+)/i)?.[1] });
|
|
16
18
|
}
|
|
19
|
+
// Other plugins listed (name@market headers) but not mARC: nothing installed.
|
|
20
|
+
if (!result.length && blocks.some(b => /^.*\b[A-Za-z0-9_.-]+@[A-Za-z0-9_.-]+\b/.test(b))) return [];
|
|
17
21
|
if (!result.length && !/plugins?\s*:\s*0/i.test(text)) throw new Error('Unrecognized Copilot plugin list');
|
|
18
22
|
return result;
|
|
19
23
|
}
|
|
@@ -67,6 +71,20 @@ export function marketplaceMatches(harness, market) {
|
|
|
67
71
|
return source.source === 'github' && source.repo === 'NexaDuo/mARC';
|
|
68
72
|
}
|
|
69
73
|
|
|
74
|
+
// Human-readable "sourceType: X, source: Y" for a marketplace row, with control
|
|
75
|
+
// characters stripped (native CLI output is untrusted text).
|
|
76
|
+
export function describeSource(market) {
|
|
77
|
+
const clean = v => String(v ?? '').replace(/[\p{Cc}\p{Cf}\u2028\u2029]/gu, '').slice(0, 200);
|
|
78
|
+
const raw = market.marketplaceSource ?? market.source;
|
|
79
|
+
let type, value;
|
|
80
|
+
if (raw && typeof raw === 'object') {
|
|
81
|
+
type = raw.sourceType ?? raw.source;
|
|
82
|
+
value = raw.sourceType ? raw.source : raw.repo ?? raw.url ?? raw.path;
|
|
83
|
+
} else if (market.repo ?? market.url ?? market.path) { type = raw; value = market.repo ?? market.url ?? market.path; }
|
|
84
|
+
else value = raw;
|
|
85
|
+
return [type != null && `sourceType: ${clean(type)}`, `source: ${clean(value) || 'unknown'}`].filter(Boolean).join(', ');
|
|
86
|
+
}
|
|
87
|
+
|
|
70
88
|
export function marketplaceWarnings(marketplaces, harness) {
|
|
71
89
|
const warnings = [];
|
|
72
90
|
if (marketplaces.some(marketplacePinned)) warnings.push('legacy-pinned marketplace; manual re-registration required');
|
package/lib/main.js
CHANGED
|
@@ -5,7 +5,8 @@ import path from 'node:path';
|
|
|
5
5
|
import { createInterface } from 'node:readline/promises';
|
|
6
6
|
import { createRunner, resolveExecutable, safeValue } from './process.js';
|
|
7
7
|
import { tagToNpm } from './version.js';
|
|
8
|
-
import {
|
|
8
|
+
import { createStyle, stripControls } from './style.js';
|
|
9
|
+
import { safeVersion, parsePlugins, describeSource, parseMarketplaces, marketplaceWarnings, marketplaceMatches, sourceHasPointer, readCatalogSource } from './lists.js';
|
|
9
10
|
|
|
10
11
|
export const HARNESSES = ['claude', 'copilot', 'codex', 'agy'];
|
|
11
12
|
const SCOPES = ['user', 'project', 'local'];
|
|
@@ -15,6 +16,8 @@ const HELP = `Usage: marc install|update|doctor|uninstall [--yes] [--dry-run]
|
|
|
15
16
|
[--harness claude|copilot|codex|agy]... [--scope user|project|local]
|
|
16
17
|
[--version <embedded-tag>]
|
|
17
18
|
No --harness: use every harness found on PATH. Node >=20 required.
|
|
19
|
+
install reads the native plugin list (read-only) before consent, also in --dry-run, and again after installing.
|
|
20
|
+
install never upgrades: an existing install that differs from this release is reported STALE (run update).
|
|
18
21
|
--scope applies to Claude only. Non-TTY install/update/uninstall requires --yes
|
|
19
22
|
(doctor and --dry-run never change anything and need no --yes).
|
|
20
23
|
The package release selects the tag; another tag prints its npx command.`;
|
|
@@ -61,8 +64,9 @@ export function plan(opts) {
|
|
|
61
64
|
}
|
|
62
65
|
else if (h === 'agy' && opts.command !== 'uninstall') commands.push(['plugin', 'list', '--json'], ['<verified shallow tag clone and reinstall; preserve enablement>']);
|
|
63
66
|
else if (opts.command === 'install') {
|
|
64
|
-
commands.push(['plugin', 'marketplace', 'list', '--json'], ['plugin', 'marketplace', 'add', SLUG]);
|
|
67
|
+
commands.push(listArgs(h), ['plugin', 'marketplace', 'list', '--json'], ['plugin', 'marketplace', 'add', SLUG]);
|
|
65
68
|
commands.push(['plugin', h === 'codex' ? 'add' : 'install', ID, ...(h === 'claude' ? scopeArgs(opts.scope || 'user') : [])]);
|
|
69
|
+
commands.push(listArgs(h)); // re-list after install to confirm the version
|
|
66
70
|
} else if (opts.command === 'update') {
|
|
67
71
|
if (h === 'claude') commands.push(listArgs(h));
|
|
68
72
|
commands.push(['plugin', 'marketplace', h === 'codex' ? 'upgrade' : 'update', 'nexaduo']);
|
|
@@ -151,62 +155,197 @@ export async function installAgy({ run, release, tmpRoot }) {
|
|
|
151
155
|
}
|
|
152
156
|
}
|
|
153
157
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
158
|
+
// Console output. Plain mode forwards every message to `log` unchanged and
|
|
159
|
+
// adds nothing; color mode re-lays the same text out with headings, prompts
|
|
160
|
+
// and a result table. Every colored fragment goes through style.paint.
|
|
161
|
+
export function makeOut(log, st) {
|
|
162
|
+
const p = st.paint;
|
|
163
|
+
const pending = new Map();
|
|
164
|
+
const last = new Map();
|
|
165
|
+
let buffering = false, group = null;
|
|
166
|
+
const put = (h, text) => {
|
|
167
|
+
if (buffering) { if (!pending.has(h)) pending.set(h, []); pending.get(h).push(text); return; }
|
|
168
|
+
if (h !== group) { if (group !== null) log(''); log(p('harness', `# ${h}`)); group = h; }
|
|
169
|
+
log(text);
|
|
170
|
+
};
|
|
171
|
+
const MARK = { info: '* ', dim: '* ', warn: '! ', error: 'x ' };
|
|
172
|
+
const pad = (v, n) => String(v) + ' '.repeat(Math.max(0, n - String(v).length));
|
|
173
|
+
return {
|
|
174
|
+
header(release, command) {
|
|
175
|
+
if (!st.enabled) return log(`mARC ${release.tag} (${release.npm}); ${command}`);
|
|
176
|
+
log(`${p('brand', 'mARC')} ${p('tag', release.tag)} ${p('dim', `(${release.npm})`)}; ${p('strong', command)}`);
|
|
177
|
+
},
|
|
178
|
+
note(text) { if (st.enabled) { log(p('dim', `* ${text}`)); log(''); } },
|
|
179
|
+
cmdLine(text) { log(st.enabled ? `${p('dim', '$ ')}${p('cmd', text)}` : text); },
|
|
180
|
+
begin(harnesses) { if (st.enabled) { buffering = true; for (const h of harnesses) pending.set(h, []); } },
|
|
181
|
+
flush() {
|
|
182
|
+
last.clear(); // pre-consent lines must not become a result detail
|
|
183
|
+
if (!buffering) return;
|
|
184
|
+
buffering = false;
|
|
185
|
+
for (const [h, lines] of pending) for (const l of lines) put(h, l);
|
|
186
|
+
pending.clear();
|
|
187
|
+
},
|
|
188
|
+
// role: info | dim | warn | error | cmd
|
|
189
|
+
line(h, role, text) {
|
|
190
|
+
if (role !== 'cmd') last.set(h, text);
|
|
191
|
+
if (!st.enabled) return log(text);
|
|
192
|
+
put(h, role === 'cmd' ? ` ${p('dim', '$ ')}${p('cmd', text)}` : ` ${p(role, MARK[role] + text)}`);
|
|
193
|
+
},
|
|
194
|
+
alt(h, plain, role, text) { this.line(h, role, st.enabled ? text : plain); },
|
|
195
|
+
remedy(h, title, cmds) {
|
|
196
|
+
if (!st.enabled) { log(title); for (const c of cmds) log(c); return; }
|
|
197
|
+
put(h, ` ${p('remedy', `+- ${title}`)}`);
|
|
198
|
+
for (const c of cmds) put(h, ` ${p('remedy', '|')} ${p('dim', '$ ')}${p('cmd', c)}`);
|
|
199
|
+
put(h, ` ${p('remedy', '+-')}`);
|
|
200
|
+
},
|
|
201
|
+
row(h, cols, drift, project) {
|
|
202
|
+
const extra = project === undefined ? '' : stripControls(project);
|
|
203
|
+
if (!st.enabled) return log(cols.join('\t') + (drift ? '\tDRIFT' : '') + (extra ? `\t${extra}` : ''));
|
|
204
|
+
const widths = [7, 10, 7, 8];
|
|
205
|
+
// Every column is painted (so sanitized) and padded on its stripped length.
|
|
206
|
+
const cell = (c, n, role) => p(role, pad(stripControls(c), n));
|
|
207
|
+
const body = cols.slice(1).map((c, i) => cell(c, widths[i + 1], 'info')).join(' ');
|
|
208
|
+
put(h, ` ${cell(cols[0], widths[0], 'harness')} ${body}${drift ? ` ${p('drift', 'DRIFT')}` : extra ? ` ${' '.repeat(5)}` : ''}${extra ? ` ${p('info', extra)}` : ''}`.trimEnd());
|
|
209
|
+
},
|
|
210
|
+
detail(h) { const t = last.get(h) || 'done';
|
|
211
|
+
return t.startsWith(`${h}: `) ? t.slice(h.length + 2) : t; },
|
|
212
|
+
results(list) {
|
|
213
|
+
if (!st.enabled) { for (const { harness, state } of list) log(`${harness}: ${state}`); return; }
|
|
214
|
+
log('');
|
|
215
|
+
log(p('dim', '* result'));
|
|
216
|
+
log(p('dim', ` ${pad('HARNESS', 7)} ${pad('STATUS', 6)} DETAIL`));
|
|
217
|
+
for (const { harness, state, detail } of list) {
|
|
218
|
+
log(` ${p('harness', pad(harness, 7))} ${p(state === 'OK' ? 'ok' : state === 'STALE' ? 'stale' : 'failed', pad(state, 6))} ${p('info', detail)}`);
|
|
219
|
+
}
|
|
220
|
+
},
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
function manualRemedy(h, out, scope = 'user') {
|
|
225
|
+
out.remedy(h, `${h}: Manual remedy (review first; this removes the marketplace registration):`, [
|
|
226
|
+
`${h} plugin marketplace remove nexaduo`,
|
|
227
|
+
`${h} plugin marketplace add NexaDuo/mARC`,
|
|
228
|
+
`${h} plugin ${h === 'codex' ? 'add' : 'install'} marc@nexaduo${h === 'claude' ? ` --scope ${scope}` : ''}`,
|
|
229
|
+
]);
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
const sameVersion = (version, release) => `v${String(version).replace(/^v/, '')}` === release.tag;
|
|
233
|
+
|
|
234
|
+
// Rows that count as "already installed" for this request. Claude is
|
|
235
|
+
// scope-aware; project/local rows from other repos never count.
|
|
236
|
+
function samePath(a, b) {
|
|
237
|
+
try { return realpathSync.native(a) === realpathSync.native(b); }
|
|
238
|
+
catch { return path.resolve(a) === path.resolve(b); }
|
|
239
|
+
}
|
|
240
|
+
function installedRows(h, rows, scope, cwd) {
|
|
241
|
+
if (h !== 'claude') return rows;
|
|
242
|
+
// A Claude row with no scope field is a user-scope install.
|
|
243
|
+
return rows.filter(r => (r.scope || 'user') === scope && (scope === 'user' ||
|
|
244
|
+
(typeof r.projectPath === 'string' && path.isAbsolute(r.projectPath) && samePath(r.projectPath, cwd))));
|
|
159
245
|
}
|
|
160
246
|
|
|
161
|
-
|
|
247
|
+
// Compare installed rows with the launcher release. Returns the versions found
|
|
248
|
+
// and whether any of them differs.
|
|
249
|
+
function versionState(rows, release) {
|
|
250
|
+
const found = [...new Set(rows.map(r => safeVersion(r.version)))];
|
|
251
|
+
return { found: found.join(', '), stale: rows.some(r => !r.version || !sameVersion(r.version, release)) };
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
// Project column for Claude project/local rows: ~-relative under home, else
|
|
255
|
+
// absolute. Control characters are stripped. Path semantics follow the injected
|
|
256
|
+
// platform (path.win32 vs path.posix), not the host, and the ~-relative form
|
|
257
|
+
// always uses forward slashes ("~/repos/app") on every platform.
|
|
258
|
+
export function displayProject(projectPath, home, platform = process.platform) {
|
|
259
|
+
if (typeof projectPath !== 'string' || !projectPath) return '-';
|
|
260
|
+
const P = platform === 'win32' ? path.win32 : path.posix;
|
|
261
|
+
const clean = stripControls(projectPath);
|
|
262
|
+
if (!clean) return '-';
|
|
263
|
+
const h = typeof home === 'string' ? stripControls(home) : '';
|
|
264
|
+
// A filesystem-root home would turn every path into "~/..."; print absolute.
|
|
265
|
+
if (h && P.dirname(h) !== h && P.isAbsolute(clean)) {
|
|
266
|
+
const rel = P.relative(h, clean);
|
|
267
|
+
if (rel === '') return '~';
|
|
268
|
+
if (rel !== '..' && !rel.startsWith(`..${P.sep}`) && !P.isAbsolute(rel)) return `~/${rel.split(P.sep).join('/')}`;
|
|
269
|
+
}
|
|
270
|
+
return clean;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
// Returns { state: OK|STALE|FAILED, detail }. STALE: the only problems are a
|
|
274
|
+
// version mismatch and/or a catalog that tracks main. Anything else is FAILED.
|
|
275
|
+
async function doctor(h, run, release, out, scope, home, platform) {
|
|
162
276
|
const rows = parsePlugins(h, await run(h, listArgs(h))).filter(p => h !== 'claude' || !scope || p.scope === scope);
|
|
163
|
-
let
|
|
164
|
-
if (!rows.length)
|
|
277
|
+
let failed = !rows.length, stale = false;
|
|
278
|
+
if (!rows.length) out.alt(h, `${h}\tmissing\t-`, 'error', `${h}: missing`);
|
|
165
279
|
for (const row of rows) {
|
|
166
|
-
const match =
|
|
167
|
-
|
|
168
|
-
|
|
280
|
+
const match = sameVersion(row.version, release);
|
|
281
|
+
const project = h === 'claude' && ['project', 'local'].includes(row.scope) ? displayProject(row.projectPath, home, platform) : undefined;
|
|
282
|
+
out.row(h, [h, safeVersion(row.version), row.scope || '-', row.enabled === false ? 'disabled' : 'enabled'], !match, project);
|
|
283
|
+
if (!row.version || !String(row.version).trim()) { out.line(h, 'warn', `${h}: version unreported`); failed = true; }
|
|
284
|
+
else stale ||= !match;
|
|
169
285
|
}
|
|
170
286
|
if (h !== 'agy') {
|
|
171
287
|
const markets = parseMarketplaces(h, await run(h, ['plugin', 'marketplace', 'list', '--json']));
|
|
172
288
|
const warnings = marketplaceWarnings(markets, h);
|
|
173
|
-
for (const warning of warnings) {
|
|
174
|
-
if (warnings.length) manualRemedy(h,
|
|
289
|
+
for (const warning of warnings) { out.line(h, 'warn', `${h}: ${warning}`); failed = true; }
|
|
290
|
+
if (warnings.length) manualRemedy(h, out, scope);
|
|
175
291
|
if (['codex', 'copilot'].includes(h) && markets.some(m => marketplaceMatches(h, m))) {
|
|
176
|
-
|
|
292
|
+
out.line(h, 'dim', `${h}: pin state unverifiable from native list`);
|
|
177
293
|
}
|
|
178
|
-
if (!markets.length) {
|
|
294
|
+
if (!markets.length) { out.line(h, 'warn', `${h}: nexaduo marketplace missing`); failed = true; }
|
|
179
295
|
const source = await readCatalogSource(h, markets, rows);
|
|
180
296
|
const sources = source !== null ? [source] : rows.map(r => r.source).filter(Boolean);
|
|
181
297
|
if (!sources.length) {
|
|
182
|
-
|
|
183
|
-
|
|
298
|
+
out.line(h, 'warn', `${h}: catalog pointer unavailable in native lists; cannot verify release source`);
|
|
299
|
+
failed = true;
|
|
184
300
|
} else if (!sources.every(s => sourceHasPointer(s, release.tag, h))) {
|
|
185
|
-
|
|
186
|
-
|
|
301
|
+
// STALE only when the source matches the expected release source in every
|
|
302
|
+
// field except ref; anything else (foreign repo/type/path) is FAILED.
|
|
303
|
+
if (sources.every(s => s !== null && typeof s === 'object' && sourceHasPointer({ ...s, ref: release.tag }, release.tag, h))) {
|
|
304
|
+
out.line(h, 'warn', `${h}: main-tracking with no matching release pointer; upgrade the marketplace catalog`);
|
|
305
|
+
stale = true;
|
|
306
|
+
} else {
|
|
307
|
+
out.line(h, 'warn', `${h}: marketplace source does not match the expected release source`);
|
|
308
|
+
failed = true;
|
|
309
|
+
}
|
|
187
310
|
}
|
|
188
311
|
}
|
|
189
|
-
|
|
312
|
+
if (failed) {
|
|
313
|
+
const detail = rows.length ? 'drift' : `plugin missing; run \`npx @nexaduo/marc install\``;
|
|
314
|
+
if (!rows.length) out.line(h, 'warn', `${h}: run \`npx @nexaduo/marc install\``);
|
|
315
|
+
return { state: 'FAILED', detail };
|
|
316
|
+
}
|
|
317
|
+
if (stale) {
|
|
318
|
+
out.line(h, 'warn', `${h}: out of date; run \`npx @nexaduo/marc update\``);
|
|
319
|
+
return { state: 'STALE', detail: 'out of date; run `npx @nexaduo/marc update`' };
|
|
320
|
+
}
|
|
321
|
+
return { state: 'OK', detail: 'in sync' };
|
|
190
322
|
}
|
|
191
323
|
|
|
192
324
|
export async function main(argv, { release, run = createRunner(), log = console.log,
|
|
193
|
-
isTTY = Boolean(process.stdin.isTTY), discover = h => resolveExecutable(h), confirm, cwd = process.cwd(), tmpRoot
|
|
325
|
+
isTTY = Boolean(process.stdin.isTTY), discover = h => resolveExecutable(h), confirm, cwd = process.cwd(), tmpRoot,
|
|
326
|
+
env = process.env, platform = process.platform,
|
|
327
|
+
home = (platform === 'win32' ? env.USERPROFILE || env.HOME : env.HOME || env.USERPROFILE) || os.homedir(), stdoutIsTTY = Boolean(process.stdout.isTTY),
|
|
328
|
+
style = createStyle({ env, isTTY: stdoutIsTTY, platform }) } = {}) {
|
|
194
329
|
const opts = parseArgs(argv);
|
|
195
330
|
if (opts.help) { log(HELP); return 0; }
|
|
196
331
|
if (tagToNpm(release.tag) !== release.npm) throw new Error('Invalid embedded release version');
|
|
197
332
|
if (opts.version && opts.version !== release.tag) {
|
|
198
333
|
const mapped = tagToNpm(opts.version);
|
|
199
334
|
const rest = argv.filter((v, i) => v !== '--version' && argv[i - 1] !== '--version');
|
|
200
|
-
log(`Use npx @nexaduo/marc@${mapped} ${rest.join(' ')}`);
|
|
335
|
+
makeOut(log, style).cmdLine(`Use npx @nexaduo/marc@${mapped} ${rest.join(' ')}`);
|
|
201
336
|
return 1;
|
|
202
337
|
}
|
|
203
338
|
if (!opts.yes && !isTTY && !opts.dryRun && opts.command !== 'doctor') throw new Error('Non-TTY execution requires --yes');
|
|
204
339
|
if (!opts.harnesses.length) opts.harnesses = HARNESSES.filter(h => { try { discover(h); return true; } catch { return false; } });
|
|
205
340
|
if (!opts.harnesses.length) throw new Error('No supported harness found on PATH');
|
|
206
341
|
if (opts.scope && !opts.harnesses.includes('claude')) throw new Error('--scope requires Claude');
|
|
207
|
-
|
|
342
|
+
const out = makeOut(log, style);
|
|
343
|
+
out.header(release, opts.command);
|
|
344
|
+
if (opts.dryRun) out.note('dry run: no changes will be made');
|
|
345
|
+
else if (style.enabled) log('');
|
|
346
|
+
out.begin(opts.harnesses);
|
|
208
347
|
for (const p of plan(opts)) {
|
|
209
|
-
for (const args of p.commands)
|
|
348
|
+
for (const args of p.commands) out.line(p.harness, 'cmd', `${p.harness} ${args.join(' ')}`);
|
|
210
349
|
}
|
|
211
350
|
let status = 0, claudeRows, claudeError;
|
|
212
351
|
if (opts.command === 'update' && opts.harnesses.includes('claude')) {
|
|
@@ -220,29 +359,37 @@ export async function main(argv, { release, run = createRunner(), log = console.
|
|
|
220
359
|
for (const row of claudeRows) if (row.scope !== 'user') {
|
|
221
360
|
const target = row.projectPath || cwd;
|
|
222
361
|
if (!path.isAbsolute(target)) throw new Error('Claude: invalid project path');
|
|
223
|
-
|
|
362
|
+
out.line('claude', 'warn', `Claude will edit ${path.join(target, '.claude', row.scope === 'local' ? 'settings.local.json' : 'settings.json')}`);
|
|
224
363
|
}
|
|
225
|
-
} catch (e) { claudeError = e; status = 1;
|
|
364
|
+
} catch (e) { claudeError = e; status = 1; out.line('claude', 'error', `claude: ${e.message}`); }
|
|
226
365
|
} else if (opts.harnesses.includes('claude') && opts.command !== 'doctor') {
|
|
227
366
|
const scope = opts.scope || 'user';
|
|
228
|
-
if (scope !== 'user')
|
|
367
|
+
if (scope !== 'user') out.line('claude', 'warn', `Claude may edit ${path.join(cwd, '.claude', scope === 'local' ? 'settings.local.json' : 'settings.json')} (${scope} scope)`);
|
|
368
|
+
}
|
|
369
|
+
const preRead = new Map();
|
|
370
|
+
if (opts.command === 'install') for (const h of opts.harnesses.filter(x => x !== 'agy')) {
|
|
371
|
+
// Read-only: installed rows decide whether install has anything to do.
|
|
372
|
+
try { preRead.set(h, { rows: installedRows(h, parsePlugins(h, await run(h, listArgs(h))), opts.scope || 'user', cwd) }); }
|
|
373
|
+
catch (e) { preRead.set(h, { error: e }); }
|
|
229
374
|
}
|
|
375
|
+
out.flush();
|
|
230
376
|
if (opts.dryRun) return status;
|
|
231
377
|
if (!opts.yes && opts.command !== 'doctor') {
|
|
232
378
|
let accepted;
|
|
233
379
|
if (confirm) accepted = await confirm();
|
|
234
380
|
else {
|
|
235
381
|
const rl = createInterface({ input: process.stdin, output: process.stdout });
|
|
236
|
-
try { accepted = /^y(es)?$/i.test((await rl.question(
|
|
382
|
+
try { accepted = /^y(es)?$/i.test((await rl.question(`Run this plan? ${style.paint('dim', '[y/N]')} `)).trim()); } finally { rl.close(); }
|
|
237
383
|
}
|
|
238
384
|
if (!accepted) return 1;
|
|
239
385
|
}
|
|
240
386
|
const results = [];
|
|
241
387
|
for (const h of opts.harnesses) {
|
|
242
|
-
let failed = false;
|
|
388
|
+
let failed = false, outcome, threw = false, detail;
|
|
243
389
|
try {
|
|
244
390
|
if (opts.command === 'doctor') {
|
|
245
|
-
|
|
391
|
+
const d = await doctor(h, run, release, out, opts.scope, home, platform);
|
|
392
|
+
outcome = d.state === 'FAILED' ? undefined : d.state; failed = d.state === 'FAILED'; detail = d.detail;
|
|
246
393
|
} else if (h === 'agy' && ['install', 'update'].includes(opts.command)) {
|
|
247
394
|
await installAgy({ run, release, tmpRoot });
|
|
248
395
|
} else if (h === 'claude' && opts.command === 'update') {
|
|
@@ -262,26 +409,47 @@ export async function main(argv, { release, run = createRunner(), log = console.
|
|
|
262
409
|
if (!(await stat(target.cwd)).isDirectory()) throw new Error('project path is not a directory');
|
|
263
410
|
await run(h, ['plugin', 'update', ID, ...scopeArgs(target.scope)], { cwd: target.cwd });
|
|
264
411
|
} catch (e) {
|
|
265
|
-
|
|
412
|
+
out.line('claude', 'warn', `claude: warning: skipped ${target.scope} scope at ${target.cwd}: ${e.message}`);
|
|
266
413
|
failed = true;
|
|
267
414
|
}
|
|
268
415
|
}
|
|
269
416
|
} else if (opts.command === 'install') {
|
|
417
|
+
const pre = preRead.get(h);
|
|
418
|
+
if (pre.error) throw pre.error;
|
|
419
|
+
const scope = opts.scope || 'user';
|
|
270
420
|
const markets = parseMarketplaces(h, await run(h, ['plugin', 'marketplace', 'list', '--json']));
|
|
271
421
|
if (markets.length && !markets.every(m => marketplaceMatches(h, m))) {
|
|
272
|
-
manualRemedy(h,
|
|
273
|
-
|
|
422
|
+
manualRemedy(h, out, opts.scope);
|
|
423
|
+
const found = markets.map(describeSource).join('; ');
|
|
424
|
+
throw new Error(`nexaduo is registered from a different or unverified source (found ${found}); registration preserved`);
|
|
425
|
+
}
|
|
426
|
+
const report = rows => {
|
|
427
|
+
if (rows.some(r => r.enabled === false)) out.line(h, 'warn', `${h}: marc is installed but disabled`);
|
|
428
|
+
const { found, stale } = versionState(rows, release);
|
|
429
|
+
if (stale) {
|
|
430
|
+
out.line(h, 'warn', `${h}: already installed at ${found} (launcher release ${release.tag}); run \`npx @nexaduo/marc update\``);
|
|
431
|
+
return 'STALE';
|
|
432
|
+
}
|
|
433
|
+
out.line(h, 'info', `${h}: already installed at ${found}`);
|
|
434
|
+
return 'OK';
|
|
435
|
+
};
|
|
436
|
+
if (pre.rows.length) outcome = report(pre.rows);
|
|
437
|
+
else {
|
|
438
|
+
if (!markets.length) await run(h, ['plugin', 'marketplace', 'add', SLUG]);
|
|
439
|
+
else out.line(h, 'dim', `${h}: nexaduo already registered from ${SLUG}; skipping add`);
|
|
440
|
+
await run(h, ['plugin', h === 'codex' ? 'add' : 'install', ID, ...(h === 'claude' ? scopeArgs(scope) : [])]);
|
|
441
|
+
const after = installedRows(h, parsePlugins(h, await run(h, listArgs(h))), scope, cwd);
|
|
442
|
+
if (!after.length) throw new Error('marc is not listed after install');
|
|
443
|
+
outcome = report(after);
|
|
274
444
|
}
|
|
275
|
-
if (!markets.length) await run(h, ['plugin', 'marketplace', 'add', SLUG]);
|
|
276
|
-
else log(`${h}: nexaduo already registered from ${SLUG}; skipping add`);
|
|
277
|
-
await run(h, ['plugin', h === 'codex' ? 'add' : 'install', ID, ...(h === 'claude' ? scopeArgs(opts.scope || 'user') : [])]);
|
|
278
445
|
} else {
|
|
279
446
|
for (const args of plan({ ...opts, harnesses: [h] })[0].commands) await run(h, args);
|
|
280
447
|
}
|
|
281
|
-
} catch (e) {
|
|
282
|
-
|
|
283
|
-
|
|
448
|
+
} catch (e) { out.line(h, 'error', `${h}: ${e.message}`); failed = true; threw = true; }
|
|
449
|
+
const state = failed ? 'FAILED' : outcome || 'OK';
|
|
450
|
+
results.push({ harness: h, state, detail: opts.command === 'doctor' && !threw ? detail : out.detail(h) });
|
|
451
|
+
if (state !== 'OK') status = 1;
|
|
284
452
|
}
|
|
285
|
-
|
|
453
|
+
out.results(results);
|
|
286
454
|
return status;
|
|
287
455
|
}
|
package/lib/style.js
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
// Console styling for the launcher. SGR sequences are only ever built from the
|
|
2
|
+
// constants below and a closed role enum; text is never interpolated into them.
|
|
3
|
+
// Plain mode (color off) returns text unchanged and adds no decoration.
|
|
4
|
+
|
|
5
|
+
// role: [truecolor rgb, 256-color index, 16-color code, light-profile code, bold]
|
|
6
|
+
const ROLES = {
|
|
7
|
+
brand: [[255, 106, 193], 205, '95', '35', true],
|
|
8
|
+
tag: [[94, 241, 255], 87, '96', '36', false],
|
|
9
|
+
dim: [[169, 169, 214], 146, '2', '2', false],
|
|
10
|
+
harness: [[184, 146, 255], 141, '94', '34', true],
|
|
11
|
+
cmd: [[94, 241, 255], 87, '96', '36', false],
|
|
12
|
+
ok: [[124, 255, 178], 121, '92', '32', true],
|
|
13
|
+
stale: [[255, 212, 121], 222, '93', '33', true],
|
|
14
|
+
failed: [[255, 106, 193], 205, '95', '35', true],
|
|
15
|
+
error: [[255, 106, 193], 205, '95', '35', true],
|
|
16
|
+
warn: [[255, 212, 121], 222, '93', '33', false],
|
|
17
|
+
remedy: [[255, 212, 121], 222, '93', '33', true],
|
|
18
|
+
drift: [[255, 212, 121], 222, '93', '33', true],
|
|
19
|
+
strong: null, // bold, default foreground
|
|
20
|
+
info: null, // terminal default foreground and weight
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
// C0 (incl. ESC, TAB, CR, LF), DEL, C1, and bidi/invisible format controls.
|
|
24
|
+
// eslint-disable-next-line no-control-regex
|
|
25
|
+
const UNSAFE = /[\u0000-\u001f\u007f-\u009f\u061c\u180e\u200b-\u200f\u2028-\u202e\u2060-\u2064\u2066-\u2069\ufeff]/g;
|
|
26
|
+
export const stripControls = text => String(text ?? '').replace(UNSAFE, '');
|
|
27
|
+
|
|
28
|
+
const ON = v => v !== undefined && v !== '' && v !== '0' && v !== 'false';
|
|
29
|
+
|
|
30
|
+
export function colorDepth(env = {}) {
|
|
31
|
+
const ct = String(env.COLORTERM || '').toLowerCase();
|
|
32
|
+
if (ct === 'truecolor' || ct === '24bit') return 24;
|
|
33
|
+
if (/256color/i.test(String(env.TERM || ''))) return 8;
|
|
34
|
+
return 4;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export function createStyle({ env = process.env, isTTY = Boolean(process.stdout.isTTY), platform = process.platform } = {}) {
|
|
38
|
+
const winVt = Boolean(env.WT_SESSION || env.ANSICON || env.ConEMUANSI === 'ON' || env.TERM_PROGRAM);
|
|
39
|
+
const force = env.FORCE_COLOR;
|
|
40
|
+
let enabled, depth = colorDepth(env);
|
|
41
|
+
if (env.NO_COLOR) enabled = false; // any non-empty value
|
|
42
|
+
else if (force !== undefined && force !== '') {
|
|
43
|
+
enabled = ON(force);
|
|
44
|
+
if (force === '2' && depth < 8) depth = 8;
|
|
45
|
+
if (force === '3') depth = 24;
|
|
46
|
+
} else enabled = Boolean(isTTY) && env.TERM !== 'dumb' && (platform !== 'win32' || winVt);
|
|
47
|
+
// Legacy conhost (no VT hint) cannot be assumed to do more than 16 colors.
|
|
48
|
+
if (enabled && platform === 'win32' && !winVt) depth = 4;
|
|
49
|
+
if (enabled && platform === 'win32' && !env.WT_SESSION && depth === 24) depth = 8;
|
|
50
|
+
const light = enabled && /(?:^|;)(?:7|15)$/.test(String(env.COLORFGBG || ''));
|
|
51
|
+
const code = role => {
|
|
52
|
+
if (!Object.hasOwn(ROLES, role)) throw new Error(`Unknown style role: ${role}`);
|
|
53
|
+
const spec = ROLES[role];
|
|
54
|
+
if (role === 'strong') return '1';
|
|
55
|
+
if (!spec) return '';
|
|
56
|
+
const [rgb, c256, c16, cLight, bold] = spec;
|
|
57
|
+
if (light) return `${bold ? '1;' : ''}${cLight}`;
|
|
58
|
+
const b = bold ? '1;' : '';
|
|
59
|
+
if (depth >= 24) return `${b}38;2;${rgb.join(';')}`;
|
|
60
|
+
if (depth >= 8) return `${b}38;5;${c256}`;
|
|
61
|
+
return bold ? `1;${c16}` : c16;
|
|
62
|
+
};
|
|
63
|
+
const paint = (role, text) => {
|
|
64
|
+
if (!enabled) { if (!Object.hasOwn(ROLES, role)) throw new Error(`Unknown style role: ${role}`); return text; }
|
|
65
|
+
const clean = stripControls(text);
|
|
66
|
+
const sgr = code(role);
|
|
67
|
+
return sgr ? `\x1b[${sgr}m${clean}\x1b[0m` : clean;
|
|
68
|
+
};
|
|
69
|
+
// Decoration lines exist only in color mode.
|
|
70
|
+
const deco = lines => enabled ? lines : [];
|
|
71
|
+
return { enabled, depth: depth >= 24 ? 24 : depth >= 8 ? 8 : 4, light, paint, deco };
|
|
72
|
+
}
|
package/package.json
CHANGED
package/release.json
CHANGED