@nexaduo/marc 26.1125.5 → 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 +17 -0
- package/lib/lists.js +67 -1
- package/lib/main.js +257 -23
- package/package.json +3 -1
- package/release.json +3 -3
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,6 +47,21 @@ 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
67
|
- `doctor` changes nothing and exits non-zero when it finds drift. Claude
|
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 =>
|
|
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
|
@@ -6,7 +6,8 @@ import { createInterface } from 'node:readline/promises';
|
|
|
6
6
|
import { createRunner, resolveExecutable, safeValue } from './process.js';
|
|
7
7
|
import { tagToNpm } from './version.js';
|
|
8
8
|
import { createStyle, stripControls } from './style.js';
|
|
9
|
-
import { safeVersion, parsePlugins, describeSource, parseMarketplaces, marketplaceWarnings, marketplaceMatches, sourceHasPointer, readCatalogSource
|
|
9
|
+
import { safeVersion, parsePlugins, describeSource, parseMarketplaces, marketplaceWarnings, marketplaceMatches, sourceHasPointer, readCatalogSource,
|
|
10
|
+
classifyMarketplace, sourceParts, looksLocal, redactSource, enrichMarketplaces } from './lists.js';
|
|
10
11
|
|
|
11
12
|
export const HARNESSES = ['claude', 'copilot', 'codex', 'agy'];
|
|
12
13
|
const SCOPES = ['user', 'project', 'local'];
|
|
@@ -14,12 +15,16 @@ const SLUG = 'NexaDuo/mARC';
|
|
|
14
15
|
const ID = 'marc@nexaduo';
|
|
15
16
|
const HELP = `Usage: marc install|update|doctor|uninstall [--yes] [--dry-run]
|
|
16
17
|
[--harness claude|copilot|codex|agy]... [--scope user|project|local]
|
|
17
|
-
[--version <embedded-tag>]
|
|
18
|
+
[--version <embedded-tag>] [--force [--force-local]]
|
|
18
19
|
No --harness: use every harness found on PATH. Node >=20 required.
|
|
19
20
|
install reads the native plugin list (read-only) before consent, also in --dry-run, and again after installing.
|
|
20
21
|
install never upgrades: an existing install that differs from this release is reported STALE (run update).
|
|
21
22
|
--scope applies to Claude only. Non-TTY install/update/uninstall requires --yes
|
|
22
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.
|
|
23
28
|
The package release selects the tag; another tag prints its npx command.`;
|
|
24
29
|
|
|
25
30
|
export function parseArgs(argv) {
|
|
@@ -29,6 +34,8 @@ export function parseArgs(argv) {
|
|
|
29
34
|
for (let i = 1; i < argv.length; i++) {
|
|
30
35
|
const flag = argv[i];
|
|
31
36
|
if (flag === '--yes') opts.yes = true;
|
|
37
|
+
else if (flag === '--force') opts.force = true;
|
|
38
|
+
else if (flag === '--force-local') opts.forceLocal = true;
|
|
32
39
|
else if (flag === '--dry-run') opts.dryRun = true;
|
|
33
40
|
else if (['--harness', '--scope', '--version'].includes(flag)) {
|
|
34
41
|
const value = argv[++i];
|
|
@@ -44,6 +51,8 @@ export function parseArgs(argv) {
|
|
|
44
51
|
}
|
|
45
52
|
} else throw new Error(`Unknown option: ${flag}`);
|
|
46
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');
|
|
47
56
|
if (opts.scope && !SCOPES.includes(opts.scope)) throw new Error('Unknown Claude scope');
|
|
48
57
|
if (opts.scope && opts.harnesses.length && !opts.harnesses.includes('claude')) throw new Error('--scope requires Claude');
|
|
49
58
|
return opts;
|
|
@@ -284,7 +293,7 @@ async function doctor(h, run, release, out, scope, home, platform) {
|
|
|
284
293
|
else stale ||= !match;
|
|
285
294
|
}
|
|
286
295
|
if (h !== 'agy') {
|
|
287
|
-
const markets = parseMarketplaces(h, await run(h,
|
|
296
|
+
const markets = enrichMarketplaces(h, parseMarketplaces(h, await run(h, MLIST)), rows);
|
|
288
297
|
const warnings = marketplaceWarnings(markets, h);
|
|
289
298
|
for (const warning of warnings) { out.line(h, 'warn', `${h}: ${warning}`); failed = true; }
|
|
290
299
|
if (warnings.length) manualRemedy(h, out, scope);
|
|
@@ -321,6 +330,199 @@ async function doctor(h, run, release, out, scope, home, platform) {
|
|
|
321
330
|
return { state: 'OK', detail: 'in sync' };
|
|
322
331
|
}
|
|
323
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
|
+
}
|
|
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;
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
|
|
324
526
|
export async function main(argv, { release, run = createRunner(), log = console.log,
|
|
325
527
|
isTTY = Boolean(process.stdin.isTTY), discover = h => resolveExecutable(h), confirm, cwd = process.cwd(), tmpRoot,
|
|
326
528
|
env = process.env, platform = process.platform,
|
|
@@ -344,11 +546,22 @@ export async function main(argv, { release, run = createRunner(), log = console.
|
|
|
344
546
|
if (opts.dryRun) out.note('dry run: no changes will be made');
|
|
345
547
|
else if (style.enabled) log('');
|
|
346
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
|
+
}
|
|
347
553
|
for (const p of plan(opts)) {
|
|
348
|
-
|
|
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(' ')}`);
|
|
349
561
|
}
|
|
562
|
+
const replacing = h => fstate.get(h)?.action === 'replace';
|
|
350
563
|
let status = 0, claudeRows, claudeError;
|
|
351
|
-
if (opts.command === 'update' && opts.harnesses.includes('claude')) {
|
|
564
|
+
if (opts.command === 'update' && opts.harnesses.includes('claude') && !replacing('claude')) {
|
|
352
565
|
try {
|
|
353
566
|
const installed = parsePlugins('claude', await run('claude', listArgs('claude')));
|
|
354
567
|
claudeRows = installed.filter(row => !opts.scope || row.scope === opts.scope);
|
|
@@ -362,12 +575,12 @@ export async function main(argv, { release, run = createRunner(), log = console.
|
|
|
362
575
|
out.line('claude', 'warn', `Claude will edit ${path.join(target, '.claude', row.scope === 'local' ? 'settings.local.json' : 'settings.json')}`);
|
|
363
576
|
}
|
|
364
577
|
} catch (e) { claudeError = e; status = 1; out.line('claude', 'error', `claude: ${e.message}`); }
|
|
365
|
-
} else if (opts.harnesses.includes('claude') && opts.command !== 'doctor') {
|
|
578
|
+
} else if (opts.harnesses.includes('claude') && opts.command !== 'doctor' && !replacing('claude')) {
|
|
366
579
|
const scope = opts.scope || 'user';
|
|
367
580
|
if (scope !== 'user') out.line('claude', 'warn', `Claude may edit ${path.join(cwd, '.claude', scope === 'local' ? 'settings.local.json' : 'settings.json')} (${scope} scope)`);
|
|
368
581
|
}
|
|
369
582
|
const preRead = new Map();
|
|
370
|
-
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))) {
|
|
371
584
|
// Read-only: installed rows decide whether install has anything to do.
|
|
372
585
|
try { preRead.set(h, { rows: installedRows(h, parsePlugins(h, await run(h, listArgs(h))), opts.scope || 'user', cwd) }); }
|
|
373
586
|
catch (e) { preRead.set(h, { error: e }); }
|
|
@@ -376,22 +589,52 @@ export async function main(argv, { release, run = createRunner(), log = console.
|
|
|
376
589
|
if (opts.dryRun) return status;
|
|
377
590
|
if (!opts.yes && opts.command !== 'doctor') {
|
|
378
591
|
let accepted;
|
|
379
|
-
|
|
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);
|
|
380
595
|
else {
|
|
381
596
|
const rl = createInterface({ input: process.stdin, output: process.stdout });
|
|
382
|
-
try { accepted = /^y(es)?$/i.test((await rl.question(
|
|
597
|
+
try { accepted = /^y(es)?$/i.test((await rl.question(`${question} ${style.paint('dim', '[y/N]')} `)).trim()); } finally { rl.close(); }
|
|
383
598
|
}
|
|
384
599
|
if (!accepted) return 1;
|
|
385
600
|
}
|
|
386
601
|
const results = [];
|
|
387
602
|
for (const h of opts.harnesses) {
|
|
388
|
-
let failed = false, outcome, threw = false, detail;
|
|
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
|
+
};
|
|
389
615
|
try {
|
|
390
616
|
if (opts.command === 'doctor') {
|
|
391
617
|
const d = await doctor(h, run, release, out, opts.scope, home, platform);
|
|
392
618
|
outcome = d.state === 'FAILED' ? undefined : d.state; failed = d.state === 'FAILED'; detail = d.detail;
|
|
393
619
|
} else if (h === 'agy' && ['install', 'update'].includes(opts.command)) {
|
|
394
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);
|
|
395
638
|
} else if (h === 'claude' && opts.command === 'update') {
|
|
396
639
|
if (claudeError) throw claudeError;
|
|
397
640
|
const scopes = [...new Set(claudeRows.map(p => p.scope))];
|
|
@@ -417,22 +660,13 @@ export async function main(argv, { release, run = createRunner(), log = console.
|
|
|
417
660
|
const pre = preRead.get(h);
|
|
418
661
|
if (pre.error) throw pre.error;
|
|
419
662
|
const scope = opts.scope || 'user';
|
|
420
|
-
const markets = parseMarketplaces(h, await run(h,
|
|
663
|
+
const markets = enrichMarketplaces(h, parseMarketplaces(h, await run(h, MLIST)), pre.rows);
|
|
421
664
|
if (markets.length && !markets.every(m => marketplaceMatches(h, m))) {
|
|
422
665
|
manualRemedy(h, out, opts.scope);
|
|
666
|
+
if (!pre.rows.length) { notInstalled = true; out.line(h, 'info', `${h}: marc not installed`); }
|
|
423
667
|
const found = markets.map(describeSource).join('; ');
|
|
424
|
-
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`);
|
|
425
669
|
}
|
|
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
670
|
if (pre.rows.length) outcome = report(pre.rows);
|
|
437
671
|
else {
|
|
438
672
|
if (!markets.length) await run(h, ['plugin', 'marketplace', 'add', SLUG]);
|
|
@@ -447,7 +681,7 @@ export async function main(argv, { release, run = createRunner(), log = console.
|
|
|
447
681
|
}
|
|
448
682
|
} catch (e) { out.line(h, 'error', `${h}: ${e.message}`); failed = true; threw = true; }
|
|
449
683
|
const state = failed ? 'FAILED' : outcome || 'OK';
|
|
450
|
-
results.push({ harness: h, state, detail: opts.command === 'doctor' && !threw ? detail : out.detail(h) });
|
|
684
|
+
results.push({ harness: h, state, detail: notInstalled ? `not installed; ${out.detail(h)}` : opts.command === 'doctor' && !threw ? detail : out.detail(h) });
|
|
451
685
|
if (state !== 'OK') status = 1;
|
|
452
686
|
}
|
|
453
687
|
out.results(results);
|
package/package.json
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nexaduo/marc",
|
|
3
|
-
"version": "26.1125.
|
|
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