@nexaduo/marc 26.1125.4 → 26.1125.6

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 CHANGED
@@ -33,6 +33,8 @@ Then open any repository in your harness and run `/marc:tech-lead`.
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
35
  | `--dry-run` | Print the plan and change nothing (`install` still runs the read-only `plugin list` first) |
36
+ | `--force` | `install`/`update` only: re-register a mismatched nexaduo marketplace (see below). The plan names the registration it removes |
37
+ | `--force-local` | With `--force`: also replace a local-checkout or unverifiable registration (a possible dev clone) |
36
38
  | `--yes` | Skip the confirmation prompt. Required for `install`, `update` and `uninstall` when not in a terminal; `doctor` and `--dry-run` never need it |
37
39
 
38
40
  ## What it does, and what it doesn't
@@ -45,15 +47,36 @@ Then open any repository in your harness and run `/marc:tech-lead`.
45
47
  - Antigravity installs from a shallow clone of the release tag, checked against
46
48
  the commit embedded in this package, then deletes the clone.
47
49
  - `uninstall` never removes a marketplace registration.
50
+ - Without `--force`, a nexaduo marketplace registered from another source is
51
+ refused with a manual remedy and left untouched. A Claude registration by git
52
+ URL (`https://github.com/NexaDuo/mARC.git`) counts as the right source. A Codex
53
+ entry that lists only `name` and `root` (seen on Windows) cannot be verified: it
54
+ is reported as `registered from local root <root>` and the result says
55
+ `not installed` when mARC is absent.
56
+ - `--force` re-registers it: the plan (also in `--dry-run`) shows the found source
57
+ and the exact `marketplace remove nexaduo`, `marketplace add NexaDuo/mARC` and
58
+ reinstall commands, and nothing runs before your confirmation (`--yes` works
59
+ without a terminal). Only `nexaduo` and `marc@nexaduo` are touched; if more than
60
+ one nexaduo registration is listed it refuses. A foreign or pinned source needs
61
+ only `--force`; a local-checkout or unverifiable source also needs
62
+ `--force-local`. The registration is re-read after you confirm and nothing is
63
+ removed if it changed. If `add` fails the old source is not restored, the later
64
+ harnesses skip their remove, and the exact retry commands are printed.
48
65
  - `install` never upgrades an existing install. If the installed version differs
49
66
  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.
67
+ - `doctor` changes nothing and exits non-zero when it finds drift. Claude
68
+ `project` and `local` rows add the project they belong to as an extra field
69
+ (`~/repos/app` under your home directory, otherwise the absolute path). A harness whose only
70
+ problem is an older version, or a marketplace catalog still tracking `main`,
71
+ is `STALE`: run `npx @nexaduo/marc update`. `FAILED` means something else is
72
+ wrong (marketplace missing or drifted, plugin missing, release source
73
+ unverifiable, a native CLI error) and wins over `STALE`.
51
74
 
52
75
  ## Versions
53
76
 
54
77
  Each npm version embeds one mARC release tag. A tag `vYY.M.D[.N]` (no leading
55
78
  zeros) maps to npm `YY.(M*100+D).N`, where a missing `.N` is `0`. For example,
56
- `v26.11.25.4` is `26.1125.4` and `v26.12.1` is `26.1201.0`.
79
+ `v26.11.25.5` is `26.1125.5` and `v26.12.1` is `26.1201.0`.
57
80
 
58
81
  What a given package version pins:
59
82
 
@@ -70,6 +93,19 @@ trusted publisher is bound (#426); until then npm may lag the git tag. `npx` doe
70
93
  `npm audit signatures` in a project that depends on the package; pinning an
71
94
  exact version then keeps you on the release you checked.
72
95
 
96
+ ## Console colors
97
+
98
+ Output is colored only when stdout is a terminal. Piped, redirected and CI
99
+ output is plain text with no escape sequences, identical to earlier releases.
100
+
101
+ - `NO_COLOR=1` (any non-empty value) turns color off.
102
+ - `FORCE_COLOR=1|2|3` turns it on even when piped (`2` implies 256 colors, `3`
103
+ truecolor); `FORCE_COLOR=0` turns it off. `NO_COLOR` wins over `FORCE_COLOR`.
104
+ - Truecolor is used when `COLORTERM` is `truecolor` or `24bit`, 256 colors when
105
+ `TERM` contains `256color`, otherwise 16 colors. `TERM=dumb` and legacy
106
+ Windows consoles stay plain.
107
+ - `COLORFGBG` ending in `7` or `15` selects a light-background palette.
108
+
73
109
  ## Links
74
110
 
75
111
  - Source, docs and issues: https://github.com/NexaDuo/mARC
package/lib/lists.js CHANGED
@@ -32,6 +32,7 @@ export function parsePlugins(harness, output) {
32
32
  }).filter(p => p.installed !== false).map(p => ({
33
33
  version: p.version, scope: p.scope || '', projectPath: p.projectPath,
34
34
  enabled: p.enabled, source: p.source, installedFrom: p.installedFrom,
35
+ ...(p.marketplaceSource !== undefined && { marketplaceSource: p.marketplaceSource }),
35
36
  }));
36
37
  }
37
38
 
@@ -63,24 +64,89 @@ export function marketplaceMatches(harness, market) {
63
64
  // matching source alone cannot prove that their registration is unpinned.
64
65
  if (marketplacePinned(market)) return false;
65
66
  if (harness === 'claude' && source === 'github') return market.repo === 'NexaDuo/mARC';
67
+ if (harness === 'claude' && source === 'git') return REPOS.has(market.url ?? market.repo);
66
68
  if (typeof source === 'string') return harness !== 'codex' &&
67
69
  (source === 'NexaDuo/mARC' || source === 'GitHub: NexaDuo/mARC');
68
70
  if (!source || typeof source !== 'object') return false;
69
71
  if (harness === 'codex') return (source.sourceType ?? source.source) === 'git' &&
70
72
  REPOS.has(source.sourceType ? source.source : source.url);
73
+ if (harness === 'claude' && source.source === 'git') return REPOS.has(source.url ?? source.repo);
71
74
  return source.source === 'github' && source.repo === 'NexaDuo/mARC';
72
75
  }
73
76
 
77
+ const TYPE_TAGS = new Set(['github', 'git', 'directory', 'local', 'file', 'url', 'git-subdir']);
78
+ const LOCAL_TYPES = new Set(['directory', 'local', 'file']);
79
+ // Source value only: root/installLocation/path are catalog cache paths and
80
+ // never describe where the registration came from.
81
+ export function sourceParts(row) {
82
+ const raw = row.marketplaceSource ?? row.source;
83
+ let type, value;
84
+ if (raw && typeof raw === 'object') {
85
+ type = raw.sourceType ?? raw.source;
86
+ value = raw.sourceType ? raw.source : raw.repo ?? raw.url;
87
+ } else if (typeof raw === 'string' && (row.repo ?? row.url) !== undefined) { type = raw; value = row.repo ?? row.url; }
88
+ else if (typeof raw === 'string') { if (TYPE_TAGS.has(raw)) type = raw; else value = raw; }
89
+ return { type: typeof type === 'string' ? type : undefined, value: typeof value === 'string' ? value : undefined, hasSource: raw != null };
90
+ }
91
+
92
+ export const looksLocal = v => /^Local: /.test(v) || /^file:/i.test(v) || /^(?:\/|\.\.?(?:[\/\\]|$)|~)/.test(v) ||
93
+ /^[A-Za-z]:[\\/]/.test(v) || v.startsWith('\\\\');
94
+
95
+ // One classifier for doctor, install and update --force. Checked in order,
96
+ // deny by default: match | pinned | local | foreign-remote | unverifiable.
97
+ export function classifyMarketplace(harness, row) {
98
+ if (marketplaceMatches(harness, row)) return { kind: 'match' };
99
+ const { type, value, hasSource } = sourceParts(row);
100
+ const t = String(type ?? '').toLowerCase(), v = (value ?? '').trim();
101
+ const repoId = v.replace(/^GitHub: /, '').split('#')[0];
102
+ if (marketplacePinned(row) && REPOS.has(repoId) && !LOCAL_TYPES.has(t)) return { kind: 'pinned', reason: 'pinned ref' };
103
+ if (LOCAL_TYPES.has(t) || looksLocal(v)) return { kind: 'local', reason: 'local checkout' };
104
+ if (/^(?:https|ssh):\/\/\S+$/i.test(v) || /^[\w.-]+@[\w.-]+:\S+$/.test(v) || /^(?:GitHub: )?[\w.-]+\/[\w.-]+$/.test(v)) {
105
+ return { kind: 'foreign-remote', reason: 'foreign source' };
106
+ }
107
+ const missing = !hasSource ? 'marketplaceSource' : value === undefined || !v ?
108
+ (t === 'github' ? 'repo' : t === 'git' ? 'url' : 'source') : undefined;
109
+ return { kind: 'unverifiable', reason: `unverifiable source (${missing ? `missing ${missing}` : 'unrecognized form'})`, missing };
110
+ }
111
+
112
+ // Codex 0.171 on Windows omits marketplaceSource from `marketplace list`;
113
+ // `plugin list` joins by marketplace name and may still carry it.
114
+ export function enrichMarketplaces(harness, markets, rows) {
115
+ if (harness !== 'codex') return markets;
116
+ const src = rows.find(r => r.marketplaceSource && typeof r.marketplaceSource === 'object')?.marketplaceSource;
117
+ return markets.map(m => src && m.marketplaceSource === undefined && m.source === undefined ? { ...m, marketplaceSource: src } : m);
118
+ }
119
+
74
120
  // Human-readable "sourceType: X, source: Y" for a marketplace row, with control
75
121
  // characters stripped (native CLI output is untrusted text).
122
+ // One redaction for every place a native source value is printed: controls
123
+ // stripped, URL/scp userinfo replaced, query VALUES replaced. Everything else,
124
+ // including the #fragment (a pin), is kept verbatim. Local paths are kept
125
+ // as-is (a "#" or "?" can be part of a directory name).
126
+ export function redactSource(value) {
127
+ const v = String(value ?? '').replace(/[\p{Cc}\p{Cf}\u2028\u2029]/gu, '');
128
+ if (looksLocal(v)) return v;
129
+ const hash = v.indexOf('#');
130
+ let head = hash < 0 ? v : v.slice(0, hash);
131
+ const frag = hash < 0 ? '' : v.slice(hash);
132
+ head = head.replace(/^([a-z][a-z0-9+.-]*:\/\/)(?!git@)[^/]*@/i, '$1***@')
133
+ // scp-style tok@host:path; the conventional "git" user is not a credential
134
+ .replace(/^(?!git@)(?![a-z][a-z0-9+.-]*:\/\/)[^\s/@:]+@(?=[\w.-]+:)/i, '***@')
135
+ .replace(/([?&;][^=&;]*=)[^&;]*/g, '$1***');
136
+ return head + frag;
137
+ }
138
+
139
+ // Human-readable "sourceType: X, source: Y" for a marketplace row (native CLI
140
+ // output is untrusted text).
76
141
  export function describeSource(market) {
77
- const clean = v => String(v ?? '').replace(/[\p{Cc}\p{Cf}\u2028\u2029]/gu, '').slice(0, 200);
142
+ const clean = v => redactSource(v).slice(0, 200);
78
143
  const raw = market.marketplaceSource ?? market.source;
79
144
  let type, value;
80
145
  if (raw && typeof raw === 'object') {
81
146
  type = raw.sourceType ?? raw.source;
82
147
  value = raw.sourceType ? raw.source : raw.repo ?? raw.url ?? raw.path;
83
148
  } else if (market.repo ?? market.url ?? market.path) { type = raw; value = market.repo ?? market.url ?? market.path; }
149
+ else if (raw == null && typeof market.root === 'string') return `registered from local root ${clean(market.root)}`;
84
150
  else value = raw;
85
151
  return [type != null && `sourceType: ${clean(type)}`, `source: ${clean(value) || 'unknown'}`].filter(Boolean).join(', ');
86
152
  }
package/lib/main.js CHANGED
@@ -5,7 +5,9 @@ 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 { safeVersion, parsePlugins, describeSource, parseMarketplaces, marketplaceWarnings, marketplaceMatches, sourceHasPointer, readCatalogSource } from './lists.js';
8
+ import { createStyle, stripControls } from './style.js';
9
+ import { safeVersion, parsePlugins, describeSource, parseMarketplaces, marketplaceWarnings, marketplaceMatches, sourceHasPointer, readCatalogSource,
10
+ classifyMarketplace, sourceParts, looksLocal, redactSource, enrichMarketplaces } from './lists.js';
9
11
 
10
12
  export const HARNESSES = ['claude', 'copilot', 'codex', 'agy'];
11
13
  const SCOPES = ['user', 'project', 'local'];
@@ -13,12 +15,16 @@ const SLUG = 'NexaDuo/mARC';
13
15
  const ID = 'marc@nexaduo';
14
16
  const HELP = `Usage: marc install|update|doctor|uninstall [--yes] [--dry-run]
15
17
  [--harness claude|copilot|codex|agy]... [--scope user|project|local]
16
- [--version <embedded-tag>]
18
+ [--version <embedded-tag>] [--force [--force-local]]
17
19
  No --harness: use every harness found on PATH. Node >=20 required.
18
20
  install reads the native plugin list (read-only) before consent, also in --dry-run, and again after installing.
19
21
  install never upgrades: an existing install that differs from this release is reported STALE (run update).
20
22
  --scope applies to Claude only. Non-TTY install/update/uninstall requires --yes
21
23
  (doctor and --dry-run never change anything and need no --yes).
24
+ --force (install/update): re-register a mismatched or stale nexaduo marketplace. The plan shows the
25
+ registration it removes, then runs: marketplace remove nexaduo, marketplace add NexaDuo/mARC,
26
+ reinstall marc@nexaduo. Only nexaduo is touched. A local or unverifiable source also needs
27
+ --force-local. Without --force a mismatch is refused with a manual remedy.
22
28
  The package release selects the tag; another tag prints its npx command.`;
23
29
 
24
30
  export function parseArgs(argv) {
@@ -28,6 +34,8 @@ export function parseArgs(argv) {
28
34
  for (let i = 1; i < argv.length; i++) {
29
35
  const flag = argv[i];
30
36
  if (flag === '--yes') opts.yes = true;
37
+ else if (flag === '--force') opts.force = true;
38
+ else if (flag === '--force-local') opts.forceLocal = true;
31
39
  else if (flag === '--dry-run') opts.dryRun = true;
32
40
  else if (['--harness', '--scope', '--version'].includes(flag)) {
33
41
  const value = argv[++i];
@@ -43,6 +51,8 @@ export function parseArgs(argv) {
43
51
  }
44
52
  } else throw new Error(`Unknown option: ${flag}`);
45
53
  }
54
+ if (opts.forceLocal && !opts.force) throw new Error('--force-local requires --force');
55
+ if (opts.force && !['install', 'update'].includes(opts.command)) throw new Error('--force applies to install and update only');
46
56
  if (opts.scope && !SCOPES.includes(opts.scope)) throw new Error('Unknown Claude scope');
47
57
  if (opts.scope && opts.harnesses.length && !opts.harnesses.includes('claude')) throw new Error('--scope requires Claude');
48
58
  return opts;
@@ -154,11 +164,78 @@ export async function installAgy({ run, release, tmpRoot }) {
154
164
  }
155
165
  }
156
166
 
157
- function manualRemedy(h, log, scope = 'user') {
158
- log(`${h}: Manual remedy (review first; this removes the marketplace registration):`);
159
- log(`${h} plugin marketplace remove nexaduo`);
160
- log(`${h} plugin marketplace add NexaDuo/mARC`);
161
- log(`${h} plugin ${h === 'codex' ? 'add' : 'install'} marc@nexaduo${h === 'claude' ? ` --scope ${scope}` : ''}`);
167
+ // Console output. Plain mode forwards every message to `log` unchanged and
168
+ // adds nothing; color mode re-lays the same text out with headings, prompts
169
+ // and a result table. Every colored fragment goes through style.paint.
170
+ export function makeOut(log, st) {
171
+ const p = st.paint;
172
+ const pending = new Map();
173
+ const last = new Map();
174
+ let buffering = false, group = null;
175
+ const put = (h, text) => {
176
+ if (buffering) { if (!pending.has(h)) pending.set(h, []); pending.get(h).push(text); return; }
177
+ if (h !== group) { if (group !== null) log(''); log(p('harness', `# ${h}`)); group = h; }
178
+ log(text);
179
+ };
180
+ const MARK = { info: '* ', dim: '* ', warn: '! ', error: 'x ' };
181
+ const pad = (v, n) => String(v) + ' '.repeat(Math.max(0, n - String(v).length));
182
+ return {
183
+ header(release, command) {
184
+ if (!st.enabled) return log(`mARC ${release.tag} (${release.npm}); ${command}`);
185
+ log(`${p('brand', 'mARC')} ${p('tag', release.tag)} ${p('dim', `(${release.npm})`)}; ${p('strong', command)}`);
186
+ },
187
+ note(text) { if (st.enabled) { log(p('dim', `* ${text}`)); log(''); } },
188
+ cmdLine(text) { log(st.enabled ? `${p('dim', '$ ')}${p('cmd', text)}` : text); },
189
+ begin(harnesses) { if (st.enabled) { buffering = true; for (const h of harnesses) pending.set(h, []); } },
190
+ flush() {
191
+ last.clear(); // pre-consent lines must not become a result detail
192
+ if (!buffering) return;
193
+ buffering = false;
194
+ for (const [h, lines] of pending) for (const l of lines) put(h, l);
195
+ pending.clear();
196
+ },
197
+ // role: info | dim | warn | error | cmd
198
+ line(h, role, text) {
199
+ if (role !== 'cmd') last.set(h, text);
200
+ if (!st.enabled) return log(text);
201
+ put(h, role === 'cmd' ? ` ${p('dim', '$ ')}${p('cmd', text)}` : ` ${p(role, MARK[role] + text)}`);
202
+ },
203
+ alt(h, plain, role, text) { this.line(h, role, st.enabled ? text : plain); },
204
+ remedy(h, title, cmds) {
205
+ if (!st.enabled) { log(title); for (const c of cmds) log(c); return; }
206
+ put(h, ` ${p('remedy', `+- ${title}`)}`);
207
+ for (const c of cmds) put(h, ` ${p('remedy', '|')} ${p('dim', '$ ')}${p('cmd', c)}`);
208
+ put(h, ` ${p('remedy', '+-')}`);
209
+ },
210
+ row(h, cols, drift, project) {
211
+ const extra = project === undefined ? '' : stripControls(project);
212
+ if (!st.enabled) return log(cols.join('\t') + (drift ? '\tDRIFT' : '') + (extra ? `\t${extra}` : ''));
213
+ const widths = [7, 10, 7, 8];
214
+ // Every column is painted (so sanitized) and padded on its stripped length.
215
+ const cell = (c, n, role) => p(role, pad(stripControls(c), n));
216
+ const body = cols.slice(1).map((c, i) => cell(c, widths[i + 1], 'info')).join(' ');
217
+ put(h, ` ${cell(cols[0], widths[0], 'harness')} ${body}${drift ? ` ${p('drift', 'DRIFT')}` : extra ? ` ${' '.repeat(5)}` : ''}${extra ? ` ${p('info', extra)}` : ''}`.trimEnd());
218
+ },
219
+ detail(h) { const t = last.get(h) || 'done';
220
+ return t.startsWith(`${h}: `) ? t.slice(h.length + 2) : t; },
221
+ results(list) {
222
+ if (!st.enabled) { for (const { harness, state } of list) log(`${harness}: ${state}`); return; }
223
+ log('');
224
+ log(p('dim', '* result'));
225
+ log(p('dim', ` ${pad('HARNESS', 7)} ${pad('STATUS', 6)} DETAIL`));
226
+ for (const { harness, state, detail } of list) {
227
+ log(` ${p('harness', pad(harness, 7))} ${p(state === 'OK' ? 'ok' : state === 'STALE' ? 'stale' : 'failed', pad(state, 6))} ${p('info', detail)}`);
228
+ }
229
+ },
230
+ };
231
+ }
232
+
233
+ function manualRemedy(h, out, scope = 'user') {
234
+ out.remedy(h, `${h}: Manual remedy (review first; this removes the marketplace registration):`, [
235
+ `${h} plugin marketplace remove nexaduo`,
236
+ `${h} plugin marketplace add NexaDuo/mARC`,
237
+ `${h} plugin ${h === 'codex' ? 'add' : 'install'} marc@nexaduo${h === 'claude' ? ` --scope ${scope}` : ''}`,
238
+ ]);
162
239
  }
163
240
 
164
241
  const sameVersion = (version, release) => `v${String(version).replace(/^v/, '')}` === release.tag;
@@ -183,58 +260,308 @@ function versionState(rows, release) {
183
260
  return { found: found.join(', '), stale: rows.some(r => !r.version || !sameVersion(r.version, release)) };
184
261
  }
185
262
 
186
- async function doctor(h, run, release, log, scope) {
263
+ // Project column for Claude project/local rows: ~-relative under home, else
264
+ // absolute. Control characters are stripped. Path semantics follow the injected
265
+ // platform (path.win32 vs path.posix), not the host, and the ~-relative form
266
+ // always uses forward slashes ("~/repos/app") on every platform.
267
+ export function displayProject(projectPath, home, platform = process.platform) {
268
+ if (typeof projectPath !== 'string' || !projectPath) return '-';
269
+ const P = platform === 'win32' ? path.win32 : path.posix;
270
+ const clean = stripControls(projectPath);
271
+ if (!clean) return '-';
272
+ const h = typeof home === 'string' ? stripControls(home) : '';
273
+ // A filesystem-root home would turn every path into "~/..."; print absolute.
274
+ if (h && P.dirname(h) !== h && P.isAbsolute(clean)) {
275
+ const rel = P.relative(h, clean);
276
+ if (rel === '') return '~';
277
+ if (rel !== '..' && !rel.startsWith(`..${P.sep}`) && !P.isAbsolute(rel)) return `~/${rel.split(P.sep).join('/')}`;
278
+ }
279
+ return clean;
280
+ }
281
+
282
+ // Returns { state: OK|STALE|FAILED, detail }. STALE: the only problems are a
283
+ // version mismatch and/or a catalog that tracks main. Anything else is FAILED.
284
+ async function doctor(h, run, release, out, scope, home, platform) {
187
285
  const rows = parsePlugins(h, await run(h, listArgs(h))).filter(p => h !== 'claude' || !scope || p.scope === scope);
188
- let drift = !rows.length;
189
- if (!rows.length) log(`${h}\tmissing\t-`);
286
+ let failed = !rows.length, stale = false;
287
+ if (!rows.length) out.alt(h, `${h}\tmissing\t-`, 'error', `${h}: missing`);
190
288
  for (const row of rows) {
191
289
  const match = sameVersion(row.version, release);
192
- log(`${h}\t${safeVersion(row.version)}\t${row.scope || '-'}\t${row.enabled === false ? 'disabled' : 'enabled'}${match ? '' : '\tDRIFT'}`);
193
- drift ||= !match;
290
+ const project = h === 'claude' && ['project', 'local'].includes(row.scope) ? displayProject(row.projectPath, home, platform) : undefined;
291
+ out.row(h, [h, safeVersion(row.version), row.scope || '-', row.enabled === false ? 'disabled' : 'enabled'], !match, project);
292
+ if (!row.version || !String(row.version).trim()) { out.line(h, 'warn', `${h}: version unreported`); failed = true; }
293
+ else stale ||= !match;
194
294
  }
195
295
  if (h !== 'agy') {
196
- const markets = parseMarketplaces(h, await run(h, ['plugin', 'marketplace', 'list', '--json']));
296
+ const markets = enrichMarketplaces(h, parseMarketplaces(h, await run(h, MLIST)), rows);
197
297
  const warnings = marketplaceWarnings(markets, h);
198
- for (const warning of warnings) { log(`${h}: ${warning}`); drift = true; }
199
- if (warnings.length) manualRemedy(h, log, scope);
298
+ for (const warning of warnings) { out.line(h, 'warn', `${h}: ${warning}`); failed = true; }
299
+ if (warnings.length) manualRemedy(h, out, scope);
200
300
  if (['codex', 'copilot'].includes(h) && markets.some(m => marketplaceMatches(h, m))) {
201
- log(`${h}: pin state unverifiable from native list`);
301
+ out.line(h, 'dim', `${h}: pin state unverifiable from native list`);
202
302
  }
203
- if (!markets.length) { log(`${h}: nexaduo marketplace missing`); drift = true; }
303
+ if (!markets.length) { out.line(h, 'warn', `${h}: nexaduo marketplace missing`); failed = true; }
204
304
  const source = await readCatalogSource(h, markets, rows);
205
305
  const sources = source !== null ? [source] : rows.map(r => r.source).filter(Boolean);
206
306
  if (!sources.length) {
207
- log(`${h}: catalog pointer unavailable in native lists; cannot verify release source`);
208
- drift = true;
307
+ out.line(h, 'warn', `${h}: catalog pointer unavailable in native lists; cannot verify release source`);
308
+ failed = true;
209
309
  } else if (!sources.every(s => sourceHasPointer(s, release.tag, h))) {
210
- log(`${h}: main-tracking with no matching release pointer; upgrade the marketplace catalog`);
211
- drift = true;
310
+ // STALE only when the source matches the expected release source in every
311
+ // field except ref; anything else (foreign repo/type/path) is FAILED.
312
+ if (sources.every(s => s !== null && typeof s === 'object' && sourceHasPointer({ ...s, ref: release.tag }, release.tag, h))) {
313
+ out.line(h, 'warn', `${h}: main-tracking with no matching release pointer; upgrade the marketplace catalog`);
314
+ stale = true;
315
+ } else {
316
+ out.line(h, 'warn', `${h}: marketplace source does not match the expected release source`);
317
+ failed = true;
318
+ }
319
+ }
320
+ }
321
+ if (failed) {
322
+ const detail = rows.length ? 'drift' : `plugin missing; run \`npx @nexaduo/marc install\``;
323
+ if (!rows.length) out.line(h, 'warn', `${h}: run \`npx @nexaduo/marc install\``);
324
+ return { state: 'FAILED', detail };
325
+ }
326
+ if (stale) {
327
+ out.line(h, 'warn', `${h}: out of date; run \`npx @nexaduo/marc update\``);
328
+ return { state: 'STALE', detail: 'out of date; run `npx @nexaduo/marc update`' };
329
+ }
330
+ return { state: 'OK', detail: 'in sync' };
331
+ }
332
+
333
+ // ---- --force: re-register a mismatched nexaduo marketplace (#440) ----
334
+ // Every argv below is a constant: nothing from native output reaches a command.
335
+ const MLIST = ['plugin', 'marketplace', 'list', '--json'];
336
+ const REMOVE = ['plugin', 'marketplace', 'remove', 'nexaduo'];
337
+ const ADD = ['plugin', 'marketplace', 'add', SLUG];
338
+ const installArgs = (h, scope) => ['plugin', h === 'codex' ? 'add' : 'install', ID, ...(h === 'claude' ? scopeArgs(scope) : [])];
339
+ const settingsFile = scope => scope === 'local' ? 'settings.local.json' : 'settings.json';
340
+ const canon = v => Array.isArray(v) ? `[${v.map(canon).join(',')}]` : v && typeof v === 'object' ?
341
+ `{${Object.keys(v).sort().map(k => `${JSON.stringify(k)}:${canon(v[k])}`).join(',')}}` : JSON.stringify(v);
342
+ const clip = s => s.length > 200 ? `${s.slice(0, 200)}${String.fromCharCode(0x2026)}` : s;
343
+
344
+ // Found-source text for plans: controls stripped, URL credentials redacted,
345
+ // ?query values redacted, local paths via displayProject, visibly truncated.
346
+ export function describeForPlan(row, home, platform) {
347
+ const { type, value, hasSource } = sourceParts(row);
348
+ if (!hasSource) {
349
+ return typeof row.root === 'string' ? clip(`registered from local root ${displayProject(row.root, home, platform)}`) :
350
+ 'source: unknown (missing marketplaceSource)';
351
+ }
352
+ let v = stripControls(value ?? (typeof row.path === 'string' ? row.path : ''));
353
+ if (looksLocal(v)) v = displayProject(v.replace(/^Local: /, ''), home, platform);
354
+ else v = redactSource(v);
355
+ return [type != null && `sourceType: ${clip(stripControls(type))}`, `source: ${clip(v) || 'unknown'}`].filter(Boolean).join(', ');
356
+ }
357
+
358
+ async function reinstallTargets(h, opts, rows, cwd, home, platform) {
359
+ const targets = new Map(), skipped = [];
360
+ const add = (scope, dir, disabled) => {
361
+ const key = `${scope}\0${dir ? path.resolve(dir) : ''}`;
362
+ const t = targets.get(key) ?? { scope, cwd: dir, disabled: false };
363
+ t.disabled ||= disabled; targets.set(key, t);
364
+ };
365
+ if (h !== 'claude') return { targets: [{ disabled: rows.some(r => r.enabled === false) }], skipped };
366
+ for (const row of rows) {
367
+ const scope = row.scope || 'user', disabled = row.enabled === false;
368
+ if (!SCOPES.includes(scope)) { skipped.push({ text: `skipped unknown scope ${stripControls(scope)}` }); continue; }
369
+ if (scope === 'user') { add('user', undefined, disabled); continue; }
370
+ try {
371
+ if (typeof row.projectPath !== 'string' || !path.isAbsolute(row.projectPath)) throw new Error('invalid project path');
372
+ if (!(await stat(row.projectPath)).isDirectory()) throw new Error('project path is not a directory');
373
+ add(scope, row.projectPath, disabled);
374
+ } catch (e) { skipped.push({ scope, text: `skipped ${scope} scope at ${displayProject(row.projectPath, home, platform)}: ${e.message}` }); }
375
+ }
376
+ if (opts.command === 'install' || opts.scope || !targets.size) {
377
+ const scope = opts.scope || 'user';
378
+ add(scope, scope === 'user' ? undefined : cwd, false);
379
+ }
380
+ return { targets: [...targets.values()], skipped };
381
+ }
382
+
383
+ // Read-only, before consent (also --dry-run and update). Decides per harness.
384
+ async function forcePreRead(h, { opts, run, cwd, home, platform, release }) {
385
+ let rows, markets;
386
+ try {
387
+ rows = parsePlugins(h, await run(h, listArgs(h)));
388
+ markets = parseMarketplaces(h, await run(h, MLIST));
389
+ } catch (error) { return { action: 'error', error }; }
390
+ if (!markets.length) return { action: 'none', rows };
391
+ if (markets.length > 1) return { action: 'refuse', rows, message: `--force refused: ${markets.length} nexaduo registrations are listed; remove them manually` };
392
+ const row = enrichMarketplaces(h, markets, rows)[0];
393
+ const cls = classifyMarketplace(h, row), desc = describeForPlan(row, home, platform);
394
+ const base = { rows, desc, cls, rawCanon: canon(markets) };
395
+ if (cls.kind === 'match') {
396
+ if (opts.command !== 'install') return { ...base, action: 'none', note: 'registration matches; nothing to remove' };
397
+ const mine = installedRows(h, rows, opts.scope || 'user', cwd);
398
+ if (!mine.length) return { ...base, action: 'none' };
399
+ return versionState(mine, release).stale ? { ...base, action: 'update', note: 'registration matches; updating the stale install' } :
400
+ { ...base, action: 'none', note: 'nothing to do' };
401
+ }
402
+ if (['local', 'unverifiable'].includes(cls.kind) && !opts.forceLocal) {
403
+ return { ...base, action: 'refuse', message: `--force refused: ${cls.reason}; add --force-local to replace it (found ${desc}); registration preserved` };
404
+ }
405
+ return { ...base, action: 'replace', ...(await reinstallTargets(h, opts, rows, cwd, home, platform)) };
406
+ }
407
+
408
+ const updateArgs = (h, scope) => [['plugin', 'marketplace', h === 'codex' ? 'upgrade' : 'update', 'nexaduo'],
409
+ h === 'claude' ? ['plugin', 'update', ID, ...scopeArgs(scope)] : ['plugin', h === 'codex' ? 'add' : 'update', h === 'codex' ? ID : 'marc']];
410
+
411
+ const isPresent = (h, rows, t) => h !== 'claude' ? rows.length > 0 : rows.some(r => (r.scope || 'user') === t.scope &&
412
+ (t.scope === 'user' || (typeof r.projectPath === 'string' && samePath(r.projectPath, t.cwd))));
413
+ // A target is reinstalled when absent or when it is the requested install scope;
414
+ // a survivor in any other scope is updated instead.
415
+ const bindModes = (h, rows, targets, opts) => targets.map(t => ({ t, install: !isPresent(h, rows, t) ||
416
+ (opts.command === 'install' && (h !== 'claude' || t.scope === (opts.scope || 'user'))) }));
417
+ const bindCmds = (h, xs, opts, withMarket = true) => [
418
+ ...(withMarket && opts.command === 'update' && xs.some(x => !x.install) ? [`${h} ${updateArgs(h, 'user')[0].join(' ')}`] : []),
419
+ ...xs.map(x => `${h} ${(x.install ? installArgs(h, x.t.scope) : updateArgs(h, x.t.scope)[1]).join(' ')}`)];
420
+
421
+ // Plan lines that replace a harness's static plan() lines.
422
+ function forceLines(h, f, opts, home, platform) {
423
+ const cmd = text => ({ role: 'cmd', text });
424
+ if (f.action === 'refuse') return [{ role: 'warn', text: `${h}: ${f.message}` }];
425
+ if (f.action === 'update') return [...updateArgs(h, opts.scope || 'user').map(a => cmd(`${h} ${a.join(' ')}`)), cmd(`${h} ${listArgs(h).join(' ')}`)];
426
+ const L = [{ role: 'warn', text: `${h}: --force will REMOVE marketplace nexaduo (found ${f.desc}; reason: ${f.cls.reason})` },
427
+ cmd(`${h} ${REMOVE.join(' ')}`), cmd(`${h} ${ADD.join(' ')}`)];
428
+ const modes = bindModes(h, f.rows ?? [], f.targets, opts);
429
+ if (opts.command === 'update' && modes.some(x => !x.install)) L.push(cmd(`${h} ${updateArgs(h, 'user')[0].join(' ')}`));
430
+ for (const { t, install } of modes) {
431
+ const where = t.cwd ? `cwd ${displayProject(t.cwd, home, platform)}` : '';
432
+ const inst = `${h} ${installArgs(h, t.scope).join(' ')}`;
433
+ if (install) L.push(cmd(`${inst}${where ? ` (${where}, if missing after add)` : ''}`));
434
+ else {
435
+ L.push(cmd(`${h} ${updateArgs(h, t.scope)[1].join(' ')} (${where ? `${where}; ` : ''}if marc is still installed after the add)`));
436
+ L.push(cmd(`${inst} (${where ? `${where}; ` : ''}instead, if marc is gone after the add)`));
437
+ }
438
+ }
439
+ for (const t of f.targets) if (t.disabled && h === 'claude') L.push(cmd(`${h} plugin disable ${ID} ${scopeArgs(t.scope).join(' ')}`));
440
+ for (const t of f.targets) if (t.cwd) L.push({ role: 'warn', text: `Claude may edit ${displayProject(path.join(t.cwd, '.claude', settingsFile(t.scope)), home, platform)} (${t.scope} scope)` });
441
+ if (h !== 'claude' && f.targets.some(t => t.disabled)) L.push({ role: 'warn', text: `${h}: marc was disabled; re-disable it after the reinstall` });
442
+ for (const s of f.skipped) L.push({ role: 'warn', text: `${h}: warning: ${s.text}` });
443
+ L.push(cmd(`${h} ${listArgs(h).join(' ')}`));
444
+ return L;
445
+ }
446
+
447
+ // remove -> verify gone -> add -> bring installs onto the new source. Never
448
+ // rolls back: restoring would re-add the old, possibly hostile, source. Once
449
+ // the remove has succeeded, ANY later failure sets ctx.aborted (later
450
+ // harnesses skip their remove), prints the previous registration and a
451
+ // constant retry block.
452
+ async function forceReplace({ h, f, run, out, ctx, report, opts, cwd, home, platform }) {
453
+ if (ctx.aborted) throw new Error('skipped: earlier forced re-registration failed; nothing removed');
454
+ const listed = async () => parseMarketplaces(h, await run(h, MLIST));
455
+ if (canon(await listed()) !== f.rawCanon) throw new Error('registration changed since the plan was shown; nothing removed');
456
+ try { await run(h, REMOVE); } catch (e) { throw new Error(`marketplace remove failed (${e.message}); registration preserved`); }
457
+ const installs = ts => ts.map(t => `${h} ${installArgs(h, t.scope).join(' ')}`);
458
+ let retry = [`${h} ${ADD.join(' ')}`, ...installs(f.targets)];
459
+ let title = `${h}: nexaduo is now unregistered; retry (review first):`;
460
+ // Commands that could not be completed (skipped scope, failed re-disable).
461
+ const leftover = f.skipped.filter(s => s.scope).map(s => `${h} ${installArgs(h, s.scope).join(' ')}`);
462
+ // Nothing installs or updates until nexaduo is proven to be the one NexaDuo/mARC row.
463
+ const prove = (markets, rows, when) => {
464
+ const mk = enrichMarketplaces(h, markets, rows);
465
+ const cls = mk.length === 1 ? classifyMarketplace(h, mk[0]) : { kind: 'many', reason: `${mk.length} registrations` };
466
+ if (cls.kind === 'match') return;
467
+ title = `${h}: nexaduo is not registered from ${SLUG} ${when}; retry (review first):`;
468
+ retry = [`${h} ${REMOVE.join(' ')}`, `${h} ${ADD.join(' ')}`, ...installs(f.targets)];
469
+ throw new Error(`nexaduo is not a verified ${SLUG} registration ${when} (${cls.reason})`);
470
+ };
471
+ try {
472
+ if ((await listed()).length) throw new Error('nexaduo is still listed after marketplace remove; not adding');
473
+ try { await run(h, ADD); } catch { throw new Error('nexaduo is now unregistered: marketplace add failed'); }
474
+ const added = await listed();
475
+ if (!added.length) throw new Error('nexaduo is now unregistered: marketplace add failed');
476
+ let rows = parsePlugins(h, await run(h, listArgs(h)));
477
+ prove(added, rows, 'after add');
478
+ title = `${h}: failed after re-registration; retry (review first):`;
479
+ retry = installs(f.targets);
480
+ // Installs that survived the remove still point at the old source: the
481
+ // requested install scope is re-run, surviving update scopes are updated.
482
+ const todo = bindModes(h, rows, f.targets, opts);
483
+ let failed = f.skipped.length > 0;
484
+ const ready = [];
485
+ for (const x of todo) {
486
+ try {
487
+ if (x.t.cwd && !(await stat(x.t.cwd)).isDirectory()) throw new Error('project path is not a directory');
488
+ ready.push(x);
489
+ } catch (e) {
490
+ out.line(h, 'warn', `${h}: warning: skipped ${x.t.scope} scope at ${displayProject(x.t.cwd, home, platform)}: ${e.message}`);
491
+ failed = true; leftover.push(...bindCmds(h, [x], opts, false));
492
+ }
493
+ }
494
+ retry = bindCmds(h, ready, opts);
495
+ const options = t => t.cwd ? { cwd: t.cwd } : undefined;
496
+ if (opts.command === 'update' && ready.some(x => !x.install)) {
497
+ try { await run(h, updateArgs(h, opts.scope || 'user')[0]); } catch (e) { throw new Error(`marketplace update failed (${e.message}); the marketplace is registered`); }
498
+ }
499
+ for (const [i, { t, install }] of ready.entries()) {
500
+ const argv = install ? installArgs(h, t.scope) : updateArgs(h, t.scope)[1];
501
+ try { await run(h, argv, options(t)); } catch (e) {
502
+ retry = bindCmds(h, ready.slice(i), opts);
503
+ throw new Error(`${install ? 'reinstall' : 'update'} of ${ID} failed (${e.message}); the marketplace is registered`);
504
+ }
505
+ if (install && t.disabled && h === 'claude') {
506
+ try { await run(h, ['plugin', 'disable', ID, ...scopeArgs(t.scope)], options(t)); } catch (e) {
507
+ out.line(h, 'warn', `${h}: warning: could not re-disable ${t.scope} scope: ${e.message}`);
508
+ failed = true; leftover.push(`${h} plugin disable ${ID} ${scopeArgs(t.scope).join(' ')}`);
509
+ }
510
+ }
212
511
  }
512
+ rows = parsePlugins(h, await run(h, listArgs(h)));
513
+ prove(await listed(), rows, 'after the reinstall');
514
+ const after = opts.command === 'install' || opts.scope ? installedRows(h, rows, opts.scope || 'user', cwd) : rows;
515
+ if (!after.length) throw new Error('marc is not listed after install');
516
+ if (leftover.length) out.remedy(h, `${h}: incomplete; run these manually, in the matching project directory for project/local scopes (review first):`, [...new Set(leftover)]);
517
+ return { outcome: report(after), failed };
518
+ } catch (e) {
519
+ ctx.aborted = true;
520
+ out.line(h, 'warn', `${h}: previous registration was: ${f.desc}`);
521
+ out.remedy(h, title, [...new Set([...retry, ...leftover])]);
522
+ throw e;
213
523
  }
214
- return drift ? 1 : 0;
215
524
  }
216
525
 
217
526
  export async function main(argv, { release, run = createRunner(), log = console.log,
218
- isTTY = Boolean(process.stdin.isTTY), discover = h => resolveExecutable(h), confirm, cwd = process.cwd(), tmpRoot } = {}) {
527
+ isTTY = Boolean(process.stdin.isTTY), discover = h => resolveExecutable(h), confirm, cwd = process.cwd(), tmpRoot,
528
+ env = process.env, platform = process.platform,
529
+ home = (platform === 'win32' ? env.USERPROFILE || env.HOME : env.HOME || env.USERPROFILE) || os.homedir(), stdoutIsTTY = Boolean(process.stdout.isTTY),
530
+ style = createStyle({ env, isTTY: stdoutIsTTY, platform }) } = {}) {
219
531
  const opts = parseArgs(argv);
220
532
  if (opts.help) { log(HELP); return 0; }
221
533
  if (tagToNpm(release.tag) !== release.npm) throw new Error('Invalid embedded release version');
222
534
  if (opts.version && opts.version !== release.tag) {
223
535
  const mapped = tagToNpm(opts.version);
224
536
  const rest = argv.filter((v, i) => v !== '--version' && argv[i - 1] !== '--version');
225
- log(`Use npx @nexaduo/marc@${mapped} ${rest.join(' ')}`);
537
+ makeOut(log, style).cmdLine(`Use npx @nexaduo/marc@${mapped} ${rest.join(' ')}`);
226
538
  return 1;
227
539
  }
228
540
  if (!opts.yes && !isTTY && !opts.dryRun && opts.command !== 'doctor') throw new Error('Non-TTY execution requires --yes');
229
541
  if (!opts.harnesses.length) opts.harnesses = HARNESSES.filter(h => { try { discover(h); return true; } catch { return false; } });
230
542
  if (!opts.harnesses.length) throw new Error('No supported harness found on PATH');
231
543
  if (opts.scope && !opts.harnesses.includes('claude')) throw new Error('--scope requires Claude');
232
- log(`mARC ${release.tag} (${release.npm}); ${opts.command}`);
544
+ const out = makeOut(log, style);
545
+ out.header(release, opts.command);
546
+ if (opts.dryRun) out.note('dry run: no changes will be made');
547
+ else if (style.enabled) log('');
548
+ out.begin(opts.harnesses);
549
+ const fstate = new Map(), ctx = { aborted: false };
550
+ if (opts.force) for (const h of opts.harnesses.filter(x => x !== 'agy')) {
551
+ fstate.set(h, await forcePreRead(h, { opts, run, cwd, home, platform, release }));
552
+ }
233
553
  for (const p of plan(opts)) {
234
- for (const args of p.commands) log(`${p.harness} ${args.join(' ')}`);
554
+ const f = fstate.get(p.harness);
555
+ if (opts.force && p.harness === 'agy') out.line('agy', 'info', 'agy: --force not applicable');
556
+ if (f?.note) out.line(p.harness, 'info', `${p.harness}: --force: ${f.note}`);
557
+ if (f?.action === 'error') out.line(p.harness, 'warn', `${p.harness}: --force: cannot read registration state: ${f.error.message}`);
558
+ if (['replace', 'refuse', 'update'].includes(f?.action)) {
559
+ for (const l of forceLines(p.harness, f, opts, home, platform)) out.line(p.harness, l.role, l.text);
560
+ } else for (const args of p.commands) out.line(p.harness, 'cmd', `${p.harness} ${args.join(' ')}`);
235
561
  }
562
+ const replacing = h => fstate.get(h)?.action === 'replace';
236
563
  let status = 0, claudeRows, claudeError;
237
- if (opts.command === 'update' && opts.harnesses.includes('claude')) {
564
+ if (opts.command === 'update' && opts.harnesses.includes('claude') && !replacing('claude')) {
238
565
  try {
239
566
  const installed = parsePlugins('claude', await run('claude', listArgs('claude')));
240
567
  claudeRows = installed.filter(row => !opts.scope || row.scope === opts.scope);
@@ -245,37 +572,69 @@ export async function main(argv, { release, run = createRunner(), log = console.
245
572
  for (const row of claudeRows) if (row.scope !== 'user') {
246
573
  const target = row.projectPath || cwd;
247
574
  if (!path.isAbsolute(target)) throw new Error('Claude: invalid project path');
248
- log(`Claude will edit ${path.join(target, '.claude', row.scope === 'local' ? 'settings.local.json' : 'settings.json')}`);
575
+ out.line('claude', 'warn', `Claude will edit ${path.join(target, '.claude', row.scope === 'local' ? 'settings.local.json' : 'settings.json')}`);
249
576
  }
250
- } catch (e) { claudeError = e; status = 1; log(`claude: ${e.message}`); }
251
- } else if (opts.harnesses.includes('claude') && opts.command !== 'doctor') {
577
+ } catch (e) { claudeError = e; status = 1; out.line('claude', 'error', `claude: ${e.message}`); }
578
+ } else if (opts.harnesses.includes('claude') && opts.command !== 'doctor' && !replacing('claude')) {
252
579
  const scope = opts.scope || 'user';
253
- if (scope !== 'user') log(`Claude may edit ${path.join(cwd, '.claude', scope === 'local' ? 'settings.local.json' : 'settings.json')} (${scope} scope)`);
580
+ if (scope !== 'user') out.line('claude', 'warn', `Claude may edit ${path.join(cwd, '.claude', scope === 'local' ? 'settings.local.json' : 'settings.json')} (${scope} scope)`);
254
581
  }
255
582
  const preRead = new Map();
256
- if (opts.command === 'install') for (const h of opts.harnesses.filter(x => x !== 'agy')) {
583
+ if (opts.command === 'install') for (const h of opts.harnesses.filter(x => x !== 'agy' && !replacing(x))) {
257
584
  // Read-only: installed rows decide whether install has anything to do.
258
585
  try { preRead.set(h, { rows: installedRows(h, parsePlugins(h, await run(h, listArgs(h))), opts.scope || 'user', cwd) }); }
259
586
  catch (e) { preRead.set(h, { error: e }); }
260
587
  }
588
+ out.flush();
261
589
  if (opts.dryRun) return status;
262
590
  if (!opts.yes && opts.command !== 'doctor') {
263
591
  let accepted;
264
- if (confirm) accepted = await confirm();
592
+ const removes = [...fstate.values()].filter(f => f.action === 'replace').length;
593
+ const question = removes ? `Run this plan? It removes ${removes} marketplace registration(s)` : 'Run this plan?';
594
+ if (confirm) accepted = await confirm(question);
265
595
  else {
266
596
  const rl = createInterface({ input: process.stdin, output: process.stdout });
267
- try { accepted = /^y(es)?$/i.test((await rl.question('Run this plan? [y/N] ')).trim()); } finally { rl.close(); }
597
+ try { accepted = /^y(es)?$/i.test((await rl.question(`${question} ${style.paint('dim', '[y/N]')} `)).trim()); } finally { rl.close(); }
268
598
  }
269
599
  if (!accepted) return 1;
270
600
  }
271
601
  const results = [];
272
602
  for (const h of opts.harnesses) {
273
- let failed = false, outcome;
603
+ let failed = false, outcome, threw = false, detail, notInstalled = false;
604
+ const f = fstate.get(h);
605
+ const report = rows => {
606
+ if (rows.some(r => r.enabled === false)) out.line(h, 'warn', `${h}: marc is installed but disabled`);
607
+ const { found, stale } = versionState(rows, release);
608
+ if (stale) {
609
+ out.line(h, 'warn', `${h}: already installed at ${found} (launcher release ${release.tag}); run \`npx @nexaduo/marc update\``);
610
+ return 'STALE';
611
+ }
612
+ out.line(h, 'info', `${h}: already installed at ${found}`);
613
+ return 'OK';
614
+ };
274
615
  try {
275
616
  if (opts.command === 'doctor') {
276
- failed = Boolean(await doctor(h, run, release, log, opts.scope));
617
+ const d = await doctor(h, run, release, out, opts.scope, home, platform);
618
+ outcome = d.state === 'FAILED' ? undefined : d.state; failed = d.state === 'FAILED'; detail = d.detail;
277
619
  } else if (h === 'agy' && ['install', 'update'].includes(opts.command)) {
278
620
  await installAgy({ run, release, tmpRoot });
621
+ } else if (f?.action === 'error') {
622
+ throw f.error;
623
+ } else if (f?.action === 'refuse') {
624
+ manualRemedy(h, out, opts.scope);
625
+ if (!installedRows(h, f.rows ?? [], opts.scope || 'user', cwd).length) { notInstalled = true; out.line(h, 'info', `${h}: marc not installed`); }
626
+ throw new Error(f.message);
627
+ } else if (f?.action === 'replace') {
628
+ const r = await forceReplace({ h, f, run, out, ctx, report, opts, cwd, home, platform });
629
+ outcome = r.outcome; failed = r.failed;
630
+ } else if (f?.action === 'update') {
631
+ const scope = opts.scope || 'user';
632
+ const [market, plugin] = updateArgs(h, scope);
633
+ await run(h, market);
634
+ await run(h, plugin, scope === 'user' || h !== 'claude' ? undefined : { cwd });
635
+ const after = installedRows(h, parsePlugins(h, await run(h, listArgs(h))), scope, cwd);
636
+ if (!after.length) throw new Error('marc is not listed after update');
637
+ outcome = report(after);
279
638
  } else if (h === 'claude' && opts.command === 'update') {
280
639
  if (claudeError) throw claudeError;
281
640
  const scopes = [...new Set(claudeRows.map(p => p.scope))];
@@ -293,7 +652,7 @@ export async function main(argv, { release, run = createRunner(), log = console.
293
652
  if (!(await stat(target.cwd)).isDirectory()) throw new Error('project path is not a directory');
294
653
  await run(h, ['plugin', 'update', ID, ...scopeArgs(target.scope)], { cwd: target.cwd });
295
654
  } catch (e) {
296
- log(`claude: warning: skipped ${target.scope} scope at ${target.cwd}: ${e.message}`);
655
+ out.line('claude', 'warn', `claude: warning: skipped ${target.scope} scope at ${target.cwd}: ${e.message}`);
297
656
  failed = true;
298
657
  }
299
658
  }
@@ -301,26 +660,17 @@ export async function main(argv, { release, run = createRunner(), log = console.
301
660
  const pre = preRead.get(h);
302
661
  if (pre.error) throw pre.error;
303
662
  const scope = opts.scope || 'user';
304
- const markets = parseMarketplaces(h, await run(h, ['plugin', 'marketplace', 'list', '--json']));
663
+ const markets = enrichMarketplaces(h, parseMarketplaces(h, await run(h, MLIST)), pre.rows);
305
664
  if (markets.length && !markets.every(m => marketplaceMatches(h, m))) {
306
- manualRemedy(h, log, opts.scope);
665
+ manualRemedy(h, out, opts.scope);
666
+ if (!pre.rows.length) { notInstalled = true; out.line(h, 'info', `${h}: marc not installed`); }
307
667
  const found = markets.map(describeSource).join('; ');
308
- throw new Error(`nexaduo is registered from a different or unverified source (found ${found}); registration preserved`);
668
+ throw new Error(`nexaduo is registered from a different or unverified source (${found.startsWith('registered ') ? '' : 'found '}${found}); registration preserved`);
309
669
  }
310
- const report = rows => {
311
- if (rows.some(r => r.enabled === false)) log(`${h}: marc is installed but disabled`);
312
- const { found, stale } = versionState(rows, release);
313
- if (stale) {
314
- log(`${h}: already installed at ${found} (launcher release ${release.tag}); run \`npx @nexaduo/marc update\``);
315
- return 'STALE';
316
- }
317
- log(`${h}: already installed at ${found}`);
318
- return 'OK';
319
- };
320
670
  if (pre.rows.length) outcome = report(pre.rows);
321
671
  else {
322
672
  if (!markets.length) await run(h, ['plugin', 'marketplace', 'add', SLUG]);
323
- else log(`${h}: nexaduo already registered from ${SLUG}; skipping add`);
673
+ else out.line(h, 'dim', `${h}: nexaduo already registered from ${SLUG}; skipping add`);
324
674
  await run(h, ['plugin', h === 'codex' ? 'add' : 'install', ID, ...(h === 'claude' ? scopeArgs(scope) : [])]);
325
675
  const after = installedRows(h, parsePlugins(h, await run(h, listArgs(h))), scope, cwd);
326
676
  if (!after.length) throw new Error('marc is not listed after install');
@@ -329,11 +679,11 @@ export async function main(argv, { release, run = createRunner(), log = console.
329
679
  } else {
330
680
  for (const args of plan({ ...opts, harnesses: [h] })[0].commands) await run(h, args);
331
681
  }
332
- } catch (e) { log(`${h}: ${e.message}`); failed = true; }
682
+ } catch (e) { out.line(h, 'error', `${h}: ${e.message}`); failed = true; threw = true; }
333
683
  const state = failed ? 'FAILED' : outcome || 'OK';
334
- results.push({ harness: h, state });
684
+ results.push({ harness: h, state, detail: notInstalled ? `not installed; ${out.detail(h)}` : opts.command === 'doctor' && !threw ? detail : out.detail(h) });
335
685
  if (state !== 'OK') status = 1;
336
686
  }
337
- for (const { harness, state } of results) log(`${harness}: ${state}`);
687
+ out.results(results);
338
688
  return status;
339
689
  }
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
@@ -1,11 +1,13 @@
1
1
  {
2
2
  "name": "@nexaduo/marc",
3
- "version": "26.1125.4",
3
+ "version": "26.1125.6",
4
4
  "description": "Install and update mARC through native harness plugin CLIs",
5
5
  "type": "module",
6
6
  "bin": {"marc": "bin/marc.js"},
7
7
  "engines": {"node": ">=20"},
8
8
  "files": ["bin/", "lib/", "release.json", "LICENSE", "README.md"],
9
9
  "repository": {"type": "git", "url": "git+https://github.com/NexaDuo/mARC.git", "directory": "launcher"},
10
+ "homepage": "https://marc.nexaduo.com/",
11
+ "bugs": {"url": "https://github.com/NexaDuo/mARC/issues"},
10
12
  "license": "MIT"
11
13
  }
package/release.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "tag": "v26.11.25.4",
3
- "sha": "9bc9282fc2ebda73cf5d5dcf71bab18bf1fd5fc2",
4
- "npm": "26.1125.4"
2
+ "tag": "v26.11.25.6",
3
+ "sha": "4033446b1ecf5d7a855fa555e14d1a2145fb3997",
4
+ "npm": "26.1125.6"
5
5
  }