@zhixuan92/multi-model-agent 5.0.2 → 5.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -23
- package/dist/cli/index.d.ts +62 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +345 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/info.d.ts +22 -0
- package/dist/cli/info.d.ts.map +1 -0
- package/dist/cli/info.js +100 -0
- package/dist/cli/info.js.map +1 -0
- package/dist/cli/logs.d.ts +15 -0
- package/dist/cli/logs.d.ts.map +1 -0
- package/dist/cli/logs.js +102 -0
- package/dist/cli/logs.js.map +1 -0
- package/dist/cli/print-token.d.ts +18 -0
- package/dist/cli/print-token.d.ts.map +1 -0
- package/dist/cli/print-token.js +60 -0
- package/dist/cli/print-token.js.map +1 -0
- package/dist/cli/serve.d.ts +28 -0
- package/dist/cli/serve.d.ts.map +1 -0
- package/dist/cli/serve.js +405 -0
- package/dist/cli/serve.js.map +1 -0
- package/dist/cli/status.d.ts +49 -0
- package/dist/cli/status.d.ts.map +1 -0
- package/dist/cli/status.js +155 -0
- package/dist/cli/status.js.map +1 -0
- package/dist/cli/sync-skills.d.ts +58 -0
- package/dist/cli/sync-skills.d.ts.map +1 -0
- package/dist/cli/sync-skills.js +266 -0
- package/dist/cli/sync-skills.js.map +1 -0
- package/dist/cli/telemetry.d.ts +10 -0
- package/dist/cli/telemetry.d.ts.map +1 -0
- package/dist/cli/telemetry.js +161 -0
- package/dist/cli/telemetry.js.map +1 -0
- package/dist/cli/toggle.d.ts +26 -0
- package/dist/cli/toggle.d.ts.map +1 -0
- package/dist/cli/toggle.js +185 -0
- package/dist/cli/toggle.js.map +1 -0
- package/dist/http/async-dispatch.d.ts +44 -0
- package/dist/http/async-dispatch.d.ts.map +1 -0
- package/dist/http/async-dispatch.js +175 -0
- package/dist/http/async-dispatch.js.map +1 -0
- package/dist/http/auth.d.ts +20 -0
- package/dist/http/auth.d.ts.map +1 -0
- package/dist/http/auth.js +56 -0
- package/dist/http/auth.js.map +1 -0
- package/dist/http/canonicalize-file-paths.d.ts +8 -0
- package/dist/http/canonicalize-file-paths.d.ts.map +1 -0
- package/dist/http/canonicalize-file-paths.js +43 -0
- package/dist/http/canonicalize-file-paths.js.map +1 -0
- package/dist/http/cwd-validator.d.ts +11 -0
- package/dist/http/cwd-validator.d.ts.map +1 -0
- package/dist/http/cwd-validator.js +130 -0
- package/dist/http/cwd-validator.js.map +1 -0
- package/dist/http/errors.d.ts +4 -0
- package/dist/http/errors.d.ts.map +1 -0
- package/dist/http/errors.js +9 -0
- package/dist/http/errors.js.map +1 -0
- package/dist/http/execution-context.d.ts +18 -0
- package/dist/http/execution-context.d.ts.map +1 -0
- package/dist/http/execution-context.js +61 -0
- package/dist/http/execution-context.js.map +1 -0
- package/dist/http/handler-deps.d.ts +19 -0
- package/dist/http/handler-deps.d.ts.map +1 -0
- package/dist/http/handler-deps.js +2 -0
- package/dist/http/handler-deps.js.map +1 -0
- package/dist/http/handlers/control/batch-slice.d.ts +4 -0
- package/dist/http/handlers/control/batch-slice.d.ts.map +1 -0
- package/dist/http/handlers/control/batch-slice.js +40 -0
- package/dist/http/handlers/control/batch-slice.js.map +1 -0
- package/dist/http/handlers/control/batch.d.ts +23 -0
- package/dist/http/handlers/control/batch.d.ts.map +1 -0
- package/dist/http/handlers/control/batch.js +332 -0
- package/dist/http/handlers/control/batch.js.map +1 -0
- package/dist/http/handlers/control/context-blocks.d.ts +22 -0
- package/dist/http/handlers/control/context-blocks.d.ts.map +1 -0
- package/dist/http/handlers/control/context-blocks.js +111 -0
- package/dist/http/handlers/control/context-blocks.js.map +1 -0
- package/dist/http/handlers/introspection/health.d.ts +20 -0
- package/dist/http/handlers/introspection/health.d.ts.map +1 -0
- package/dist/http/handlers/introspection/health.js +18 -0
- package/dist/http/handlers/introspection/health.js.map +1 -0
- package/dist/http/handlers/introspection/status.d.ts +26 -0
- package/dist/http/handlers/introspection/status.d.ts.map +1 -0
- package/dist/http/handlers/introspection/status.js +136 -0
- package/dist/http/handlers/introspection/status.js.map +1 -0
- package/dist/http/handlers/tools/audit.d.ts +4 -0
- package/dist/http/handlers/tools/audit.d.ts.map +1 -0
- package/dist/http/handlers/tools/audit.js +43 -0
- package/dist/http/handlers/tools/audit.js.map +1 -0
- package/dist/http/handlers/tools/debug.d.ts +4 -0
- package/dist/http/handlers/tools/debug.d.ts.map +1 -0
- package/dist/http/handlers/tools/debug.js +43 -0
- package/dist/http/handlers/tools/debug.js.map +1 -0
- package/dist/http/handlers/tools/delegate.d.ts +4 -0
- package/dist/http/handlers/tools/delegate.d.ts.map +1 -0
- package/dist/http/handlers/tools/delegate.js +43 -0
- package/dist/http/handlers/tools/delegate.js.map +1 -0
- package/dist/http/handlers/tools/execute-plan.d.ts +4 -0
- package/dist/http/handlers/tools/execute-plan.d.ts.map +1 -0
- package/dist/http/handlers/tools/execute-plan.js +45 -0
- package/dist/http/handlers/tools/execute-plan.js.map +1 -0
- package/dist/http/handlers/tools/investigate.d.ts +4 -0
- package/dist/http/handlers/tools/investigate.d.ts.map +1 -0
- package/dist/http/handlers/tools/investigate.js +64 -0
- package/dist/http/handlers/tools/investigate.js.map +1 -0
- package/dist/http/handlers/tools/journal-recall.d.ts +4 -0
- package/dist/http/handlers/tools/journal-recall.d.ts.map +1 -0
- package/dist/http/handlers/tools/journal-recall.js +40 -0
- package/dist/http/handlers/tools/journal-recall.js.map +1 -0
- package/dist/http/handlers/tools/journal-record.d.ts +12 -0
- package/dist/http/handlers/tools/journal-record.d.ts.map +1 -0
- package/dist/http/handlers/tools/journal-record.js +43 -0
- package/dist/http/handlers/tools/journal-record.js.map +1 -0
- package/dist/http/handlers/tools/research.d.ts +4 -0
- package/dist/http/handlers/tools/research.d.ts.map +1 -0
- package/dist/http/handlers/tools/research.js +64 -0
- package/dist/http/handlers/tools/research.js.map +1 -0
- package/dist/http/handlers/tools/retry.d.ts +4 -0
- package/dist/http/handlers/tools/retry.d.ts.map +1 -0
- package/dist/http/handlers/tools/retry.js +49 -0
- package/dist/http/handlers/tools/retry.js.map +1 -0
- package/dist/http/handlers/tools/review.d.ts +4 -0
- package/dist/http/handlers/tools/review.d.ts.map +1 -0
- package/dist/http/handlers/tools/review.js +43 -0
- package/dist/http/handlers/tools/review.js.map +1 -0
- package/dist/http/middleware/body-reader.d.ts +16 -0
- package/dist/http/middleware/body-reader.d.ts.map +1 -0
- package/dist/http/middleware/body-reader.js +44 -0
- package/dist/http/middleware/body-reader.js.map +1 -0
- package/dist/http/middleware/caller-identity.d.ts +16 -0
- package/dist/http/middleware/caller-identity.d.ts.map +1 -0
- package/dist/http/middleware/caller-identity.js +16 -0
- package/dist/http/middleware/caller-identity.js.map +1 -0
- package/dist/http/middleware/decompress.d.ts +14 -0
- package/dist/http/middleware/decompress.d.ts.map +1 -0
- package/dist/http/middleware/decompress.js +51 -0
- package/dist/http/middleware/decompress.js.map +1 -0
- package/dist/http/project-registry.d.ts +54 -0
- package/dist/http/project-registry.d.ts.map +1 -0
- package/dist/http/project-registry.js +130 -0
- package/dist/http/project-registry.js.map +1 -0
- package/dist/http/request-observability.d.ts +8 -0
- package/dist/http/request-observability.d.ts.map +1 -0
- package/dist/http/request-observability.js +20 -0
- package/dist/http/request-observability.js.map +1 -0
- package/dist/http/request-pipeline.d.ts +16 -0
- package/dist/http/request-pipeline.d.ts.map +1 -0
- package/dist/http/request-pipeline.js +144 -0
- package/dist/http/request-pipeline.js.map +1 -0
- package/dist/http/server.d.ts +17 -0
- package/dist/http/server.d.ts.map +1 -0
- package/dist/http/server.js +300 -0
- package/dist/http/server.js.map +1 -0
- package/dist/http/types.d.ts +20 -0
- package/dist/http/types.d.ts.map +1 -0
- package/dist/http/types.js +2 -0
- package/dist/http/types.js.map +1 -0
- package/dist/skill-install/disabled-state.d.ts +35 -0
- package/dist/skill-install/disabled-state.d.ts.map +1 -0
- package/dist/skill-install/disabled-state.js +96 -0
- package/dist/skill-install/disabled-state.js.map +1 -0
- package/dist/skill-install/discover.d.ts +29 -0
- package/dist/skill-install/discover.d.ts.map +1 -0
- package/dist/skill-install/discover.js +104 -0
- package/dist/skill-install/discover.js.map +1 -0
- package/dist/skill-install/include-utils.d.ts +27 -0
- package/dist/skill-install/include-utils.d.ts.map +1 -0
- package/dist/skill-install/include-utils.js +90 -0
- package/dist/skill-install/include-utils.js.map +1 -0
- package/dist/skill-install/manifest.d.ts +82 -0
- package/dist/skill-install/manifest.d.ts.map +1 -0
- package/dist/skill-install/manifest.js +215 -0
- package/dist/skill-install/manifest.js.map +1 -0
- package/dist/skill-install/skill-installer-common.d.ts +26 -0
- package/dist/skill-install/skill-installer-common.d.ts.map +1 -0
- package/dist/skill-install/skill-installer-common.js +139 -0
- package/dist/skill-install/skill-installer-common.js.map +1 -0
- package/dist/skill-install/skill-installers/claude-code.d.ts +43 -0
- package/dist/skill-install/skill-installers/claude-code.d.ts.map +1 -0
- package/dist/skill-install/skill-installers/claude-code.js +65 -0
- package/dist/skill-install/skill-installers/claude-code.js.map +1 -0
- package/dist/skill-install/skill-installers/codex-cli.d.ts +27 -0
- package/dist/skill-install/skill-installers/codex-cli.d.ts.map +1 -0
- package/dist/skill-install/skill-installers/codex-cli.js +84 -0
- package/dist/skill-install/skill-installers/codex-cli.js.map +1 -0
- package/dist/skill-install/skill-installers/cursor.d.ts +72 -0
- package/dist/skill-install/skill-installers/cursor.d.ts.map +1 -0
- package/dist/skill-install/skill-installers/cursor.js +81 -0
- package/dist/skill-install/skill-installers/cursor.js.map +1 -0
- package/dist/skill-install/skill-installers/gemini-cli.d.ts +50 -0
- package/dist/skill-install/skill-installers/gemini-cli.d.ts.map +1 -0
- package/dist/skill-install/skill-installers/gemini-cli.js +72 -0
- package/dist/skill-install/skill-installers/gemini-cli.js.map +1 -0
- package/dist/skill-install/skill-manifest-sync.d.ts +11 -0
- package/dist/skill-install/skill-manifest-sync.d.ts.map +1 -0
- package/dist/skill-install/skill-manifest-sync.js +65 -0
- package/dist/skill-install/skill-manifest-sync.js.map +1 -0
- package/dist/skills/_shared/auth.md +41 -0
- package/dist/skills/_shared/error-handling.md +31 -0
- package/dist/skills/_shared/polling.md +88 -0
- package/dist/skills/_shared/response-shape.md +55 -0
- package/dist/skills/_shared/review-policy.md +15 -0
- package/dist/skills/mma-audit/SKILL.md +270 -0
- package/dist/skills/mma-context-blocks/SKILL.md +148 -0
- package/dist/skills/mma-debug/SKILL.md +208 -0
- package/dist/skills/mma-delegate/SKILL.md +216 -0
- package/dist/skills/mma-execute-plan/SKILL.md +214 -0
- package/dist/skills/mma-explore/SKILL.md +190 -0
- package/dist/skills/mma-investigate/SKILL.md +258 -0
- package/dist/skills/mma-journal-recall/SKILL.md +242 -0
- package/dist/skills/mma-journal-record/SKILL.md +202 -0
- package/dist/skills/mma-research/SKILL.md +223 -0
- package/dist/skills/mma-retry/SKILL.md +221 -0
- package/dist/skills/mma-review/SKILL.md +209 -0
- package/dist/skills/multi-model-agent/SKILL.md +206 -0
- package/dist/telemetry/consent.d.ts +4 -0
- package/dist/telemetry/consent.d.ts.map +1 -0
- package/dist/telemetry/consent.js +40 -0
- package/dist/telemetry/consent.js.map +1 -0
- package/dist/telemetry/flusher.d.ts +19 -0
- package/dist/telemetry/flusher.d.ts.map +1 -0
- package/dist/telemetry/flusher.js +277 -0
- package/dist/telemetry/flusher.js.map +1 -0
- package/dist/telemetry/generation.d.ts +9 -0
- package/dist/telemetry/generation.d.ts.map +1 -0
- package/dist/telemetry/generation.js +33 -0
- package/dist/telemetry/generation.js.map +1 -0
- package/dist/telemetry/identity.d.ts +9 -0
- package/dist/telemetry/identity.d.ts.map +1 -0
- package/dist/telemetry/identity.js +35 -0
- package/dist/telemetry/identity.js.map +1 -0
- package/dist/telemetry/install-id.d.ts +13 -0
- package/dist/telemetry/install-id.d.ts.map +1 -0
- package/dist/telemetry/install-id.js +49 -0
- package/dist/telemetry/install-id.js.map +1 -0
- package/dist/telemetry/install-meta.d.ts +10 -0
- package/dist/telemetry/install-meta.d.ts.map +1 -0
- package/dist/telemetry/install-meta.js +15 -0
- package/dist/telemetry/install-meta.js.map +1 -0
- package/dist/telemetry/queue.d.ts +35 -0
- package/dist/telemetry/queue.d.ts.map +1 -0
- package/dist/telemetry/queue.js +287 -0
- package/dist/telemetry/queue.js.map +1 -0
- package/dist/telemetry/recorder.d.ts +39 -0
- package/dist/telemetry/recorder.d.ts.map +1 -0
- package/dist/telemetry/recorder.js +173 -0
- package/dist/telemetry/recorder.js.map +1 -0
- package/package.json +43 -24
- package/scripts/postinstall.js +36 -0
- package/bin/mmagent.mjs +0 -47
- package/postinstall.mjs +0 -8
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* disabled-state.ts — the persistent "skills disabled" sentinel.
|
|
3
|
+
*
|
|
4
|
+
* `mmagent disable` writes this file; `sync-skills` (and the npm postinstall
|
|
5
|
+
* hook that shells out to it) consults it so an upgrade never silently
|
|
6
|
+
* reinstalls skills the user deliberately turned off. `mmagent enable` clears
|
|
7
|
+
* the relevant targets and, when none remain, deletes the file.
|
|
8
|
+
*
|
|
9
|
+
* Stored at ~/.multi-model/skills-disabled.json — the same directory as the
|
|
10
|
+
* install manifest and auth token, with matching 0o700/0o600 permissions.
|
|
11
|
+
*
|
|
12
|
+
* The sentinel is target-aware: it records *which* clients are disabled so a
|
|
13
|
+
* `disable --target=cursor` does not block syncing claude-code.
|
|
14
|
+
*/
|
|
15
|
+
import * as fs from 'node:fs';
|
|
16
|
+
import * as path from 'node:path';
|
|
17
|
+
import { z } from 'zod';
|
|
18
|
+
import { ALL_CLIENTS, manifestDir } from './manifest.js';
|
|
19
|
+
const DISABLED_NAME = 'skills-disabled.json';
|
|
20
|
+
// Derive the client enum from ALL_CLIENTS so a new client never silently
|
|
21
|
+
// fails sentinel validation. z.enum needs a non-empty literal tuple.
|
|
22
|
+
const clientEnum = z.enum(ALL_CLIENTS);
|
|
23
|
+
const disabledStateSchema = z.object({
|
|
24
|
+
version: z.literal(1),
|
|
25
|
+
disabledAt: z.number().int().nonnegative(),
|
|
26
|
+
cliVersion: z.string(),
|
|
27
|
+
targets: z.array(clientEnum),
|
|
28
|
+
});
|
|
29
|
+
/** Full path to the sentinel file. */
|
|
30
|
+
export function disabledStatePath(homeDir) {
|
|
31
|
+
return path.join(manifestDir(homeDir), DISABLED_NAME);
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Read and validate the sentinel. Returns null when absent, unreadable, or
|
|
35
|
+
* structurally invalid — a malformed sentinel must never wedge sync-skills.
|
|
36
|
+
*/
|
|
37
|
+
export function readDisabledState(homeDir) {
|
|
38
|
+
try {
|
|
39
|
+
const raw = fs.readFileSync(disabledStatePath(homeDir), 'utf-8');
|
|
40
|
+
const parsed = disabledStateSchema.safeParse(JSON.parse(raw));
|
|
41
|
+
return parsed.success ? parsed.data : null;
|
|
42
|
+
}
|
|
43
|
+
catch {
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
/** The set of currently-disabled clients (empty when the sentinel is absent). */
|
|
48
|
+
export function disabledTargets(homeDir) {
|
|
49
|
+
return readDisabledState(homeDir)?.targets ?? [];
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Mark `targets` as disabled, unioned with any already-disabled clients.
|
|
53
|
+
* Returns the resulting disabled set (stable ALL_CLIENTS order).
|
|
54
|
+
*/
|
|
55
|
+
export function addDisabledTargets(homeDir, targets, cliVersion) {
|
|
56
|
+
const current = new Set(disabledTargets(homeDir));
|
|
57
|
+
for (const t of targets)
|
|
58
|
+
current.add(t);
|
|
59
|
+
const merged = ALL_CLIENTS.filter((c) => current.has(c));
|
|
60
|
+
writeDisabledState(homeDir, {
|
|
61
|
+
version: 1,
|
|
62
|
+
disabledAt: Date.now(),
|
|
63
|
+
cliVersion,
|
|
64
|
+
targets: merged,
|
|
65
|
+
});
|
|
66
|
+
return merged;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Clear `targets` from the disabled set. Deletes the sentinel file entirely
|
|
70
|
+
* once nothing remains disabled. Returns the still-disabled set.
|
|
71
|
+
*/
|
|
72
|
+
export function clearDisabledTargets(homeDir, targets) {
|
|
73
|
+
const existing = readDisabledState(homeDir);
|
|
74
|
+
if (existing === null)
|
|
75
|
+
return [];
|
|
76
|
+
const remaining = existing.targets.filter((t) => !targets.includes(t));
|
|
77
|
+
if (remaining.length === 0) {
|
|
78
|
+
try {
|
|
79
|
+
fs.rmSync(disabledStatePath(homeDir), { force: true });
|
|
80
|
+
}
|
|
81
|
+
catch {
|
|
82
|
+
/* best effort — an absent file is the desired end state anyway */
|
|
83
|
+
}
|
|
84
|
+
return [];
|
|
85
|
+
}
|
|
86
|
+
writeDisabledState(homeDir, { ...existing, targets: remaining });
|
|
87
|
+
return remaining;
|
|
88
|
+
}
|
|
89
|
+
function writeDisabledState(homeDir, state) {
|
|
90
|
+
fs.mkdirSync(manifestDir(homeDir), { recursive: true, mode: 0o700 });
|
|
91
|
+
fs.writeFileSync(disabledStatePath(homeDir), JSON.stringify(state, null, 2) + '\n', {
|
|
92
|
+
encoding: 'utf-8',
|
|
93
|
+
mode: 0o600,
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
//# sourceMappingURL=disabled-state.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"disabled-state.js","sourceRoot":"","sources":["../../src/skill-install/disabled-state.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,WAAW,EAAE,WAAW,EAAe,MAAM,eAAe,CAAC;AAEtE,MAAM,aAAa,GAAG,sBAAsB,CAAC;AAE7C,yEAAyE;AACzE,qEAAqE;AACrE,MAAM,UAAU,GAAG,CAAC,CAA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,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;IACrE,EAAE,CAAC,aAAa,CAAC,iBAAiB,CAAC,OAAO,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,GAAG,IAAI,EAAE;QAClF,QAAQ,EAAE,OAAO;QACjB,IAAI,EAAE,KAAK;KACZ,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { Client } from './manifest.js';
|
|
2
|
+
export declare const SUPPORTED_SKILLS: readonly ["multi-model-agent", "mma-delegate", "mma-audit", "mma-review", "mma-debug", "mma-execute-plan", "mma-retry", "mma-context-blocks", "mma-investigate", "mma-research", "mma-explore", "mma-journal-record", "mma-journal-recall"];
|
|
3
|
+
/** Thrown when a skill's SKILL.md cannot be read from the bundled skills directory. */
|
|
4
|
+
export declare class SkillNotFoundError extends Error {
|
|
5
|
+
readonly code: "skill_not_found";
|
|
6
|
+
constructor(skillName: string, checkedPath: string);
|
|
7
|
+
}
|
|
8
|
+
export declare function skillsRootCandidates(here: string): string[];
|
|
9
|
+
export declare function pickSkillsRoot(here: string, exists?: (p: string) => boolean): string;
|
|
10
|
+
/**
|
|
11
|
+
* Return the absolute path to the skills root directory. Production: the
|
|
12
|
+
* bundled `packages/server/src/skills/` (or its dist mirror). Tests pass
|
|
13
|
+
* a fixture path explicitly.
|
|
14
|
+
*/
|
|
15
|
+
export declare function getSkillsRoot(skillsRoot?: string): string;
|
|
16
|
+
/**
|
|
17
|
+
* Read the content of a skill's SKILL.md file. Returns null if the file
|
|
18
|
+
* does not exist; propagates other I/O errors so callers can distinguish
|
|
19
|
+
* "skill not found" from "can't access skill".
|
|
20
|
+
*/
|
|
21
|
+
export declare function readSkillContent(skillName: string, skillsRoot?: string): string | null;
|
|
22
|
+
/**
|
|
23
|
+
* Return the per-client install directories where skills are written as
|
|
24
|
+
* subdirectories. Only includes clients that use the per-skill directory
|
|
25
|
+
* model (claude-code and codex). Gemini and Cursor bundle skills into a
|
|
26
|
+
* single file/extension and are not included.
|
|
27
|
+
*/
|
|
28
|
+
export declare function discoverPerClientInstallDirs(homeDir?: string): Partial<Record<Client, string>>;
|
|
29
|
+
//# sourceMappingURL=discover.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"discover.d.ts","sourceRoot":"","sources":["../../src/skill-install/discover.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAE5C,eAAO,MAAM,gBAAgB,6OAcnB,CAAC;AAEX,uFAAuF;AACvF,qBAAa,kBAAmB,SAAQ,KAAK;IAC3C,QAAQ,CAAC,IAAI,EAAG,iBAAiB,CAAU;gBAC/B,SAAS,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM;CAOnD;AAYD,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAgB3D;AAED,wBAAgB,cAAc,CAC5B,IAAI,EAAE,MAAM,EACZ,MAAM,GAAE,CAAC,CAAC,EAAE,MAAM,KAAK,OAAuB,GAC7C,MAAM,CAMR;AAID;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,CAEzD;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAQtF;AAED;;;;;GAKG;AACH,wBAAgB,4BAA4B,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAM9F"}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
// Skill discovery — locates packaged SKILL.md files on disk and reads them.
|
|
2
|
+
// Extracted from cli/install-skill.ts as part of Ch 7 Task 39.
|
|
3
|
+
import fs from 'node:fs';
|
|
4
|
+
import os from 'node:os';
|
|
5
|
+
import path from 'node:path';
|
|
6
|
+
import { fileURLToPath } from 'node:url';
|
|
7
|
+
export const SUPPORTED_SKILLS = [
|
|
8
|
+
'multi-model-agent',
|
|
9
|
+
'mma-delegate',
|
|
10
|
+
'mma-audit',
|
|
11
|
+
'mma-review',
|
|
12
|
+
'mma-debug',
|
|
13
|
+
'mma-execute-plan',
|
|
14
|
+
'mma-retry',
|
|
15
|
+
'mma-context-blocks',
|
|
16
|
+
'mma-investigate',
|
|
17
|
+
'mma-research',
|
|
18
|
+
'mma-explore',
|
|
19
|
+
'mma-journal-record',
|
|
20
|
+
'mma-journal-recall',
|
|
21
|
+
];
|
|
22
|
+
/** Thrown when a skill's SKILL.md cannot be read from the bundled skills directory. */
|
|
23
|
+
export class SkillNotFoundError extends Error {
|
|
24
|
+
code = 'skill_not_found';
|
|
25
|
+
constructor(skillName, checkedPath) {
|
|
26
|
+
super(`Skill '${skillName}' not found. ` +
|
|
27
|
+
`Checked: ${checkedPath}. ` +
|
|
28
|
+
`Available skills: ${SUPPORTED_SKILLS.join(', ')}`);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
// Discover.ts lives in `packages/core/src/tool-surface/` (or its dist mirror).
|
|
32
|
+
// Skills are bundled by the server package at `packages/server/src/skills/`
|
|
33
|
+
// (copied to `packages/server/dist/skills/` at build time, then shipped on
|
|
34
|
+
// the `@zhixuan92/multi-model-agent` npm package as `dist/skills/`).
|
|
35
|
+
// Probe candidates for both monorepo dev layouts and the two npm-installed
|
|
36
|
+
// layouts (hoisted siblings, or core nested under server).
|
|
37
|
+
//
|
|
38
|
+
// Exported (and parameterized on `here` + `exists`) so the candidate logic
|
|
39
|
+
// can be unit-tested against fixtures that mimic each layout — the v4.0.1
|
|
40
|
+
// regression was a missing prod candidate.
|
|
41
|
+
export function skillsRootCandidates(here) {
|
|
42
|
+
return [
|
|
43
|
+
// Dev source: packages/core/src/tool-surface -> packages/server/src/skills
|
|
44
|
+
path.resolve(here, '..', '..', '..', 'server', 'src', 'skills'),
|
|
45
|
+
// Dev built: packages/core/dist/tool-surface -> packages/server/dist/skills
|
|
46
|
+
path.resolve(here, '..', '..', '..', 'server', 'dist', 'skills'),
|
|
47
|
+
// npm install (hoisted): node_modules/@zhixuan92/multi-model-agent-core/dist/tool-surface
|
|
48
|
+
// -> node_modules/@zhixuan92/multi-model-agent/dist/skills
|
|
49
|
+
path.resolve(here, '..', '..', '..', 'multi-model-agent', 'dist', 'skills'),
|
|
50
|
+
// npm install (core nested under server):
|
|
51
|
+
// .../multi-model-agent/node_modules/@zhixuan92/multi-model-agent-core/dist/tool-surface
|
|
52
|
+
// -> .../multi-model-agent/dist/skills
|
|
53
|
+
path.resolve(here, '..', '..', '..', '..', '..', 'dist', 'skills'),
|
|
54
|
+
// Last-resort fallback for any caller that bundles skills inside core.
|
|
55
|
+
path.resolve(here, '..', 'skills'),
|
|
56
|
+
];
|
|
57
|
+
}
|
|
58
|
+
export function pickSkillsRoot(here, exists = fs.existsSync) {
|
|
59
|
+
const candidates = skillsRootCandidates(here);
|
|
60
|
+
for (const c of candidates) {
|
|
61
|
+
if (exists(c))
|
|
62
|
+
return c;
|
|
63
|
+
}
|
|
64
|
+
return candidates[0];
|
|
65
|
+
}
|
|
66
|
+
const DEFAULT_SKILLS_ROOT = pickSkillsRoot(path.dirname(fileURLToPath(import.meta.url)));
|
|
67
|
+
/**
|
|
68
|
+
* Return the absolute path to the skills root directory. Production: the
|
|
69
|
+
* bundled `packages/server/src/skills/` (or its dist mirror). Tests pass
|
|
70
|
+
* a fixture path explicitly.
|
|
71
|
+
*/
|
|
72
|
+
export function getSkillsRoot(skillsRoot) {
|
|
73
|
+
return skillsRoot ?? DEFAULT_SKILLS_ROOT;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Read the content of a skill's SKILL.md file. Returns null if the file
|
|
77
|
+
* does not exist; propagates other I/O errors so callers can distinguish
|
|
78
|
+
* "skill not found" from "can't access skill".
|
|
79
|
+
*/
|
|
80
|
+
export function readSkillContent(skillName, skillsRoot) {
|
|
81
|
+
const skillFile = path.join(getSkillsRoot(skillsRoot), skillName, 'SKILL.md');
|
|
82
|
+
try {
|
|
83
|
+
return fs.readFileSync(skillFile, 'utf-8');
|
|
84
|
+
}
|
|
85
|
+
catch (err) {
|
|
86
|
+
if (err.code === 'ENOENT')
|
|
87
|
+
return null;
|
|
88
|
+
throw err;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Return the per-client install directories where skills are written as
|
|
93
|
+
* subdirectories. Only includes clients that use the per-skill directory
|
|
94
|
+
* model (claude-code and codex). Gemini and Cursor bundle skills into a
|
|
95
|
+
* single file/extension and are not included.
|
|
96
|
+
*/
|
|
97
|
+
export function discoverPerClientInstallDirs(homeDir) {
|
|
98
|
+
const h = homeDir ?? os.homedir();
|
|
99
|
+
return {
|
|
100
|
+
'claude-code': path.join(h, '.claude', 'skills'),
|
|
101
|
+
'codex': path.join(h, '.codex', 'skills'),
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
//# sourceMappingURL=discover.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"discover.js","sourceRoot":"","sources":["../../src/skill-install/discover.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,+DAA+D;AAC/D,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAGzC,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,mBAAmB;IACnB,cAAc;IACd,WAAW;IACX,YAAY;IACZ,WAAW;IACX,kBAAkB;IAClB,WAAW;IACX,oBAAoB;IACpB,iBAAiB;IACjB,cAAc;IACd,aAAa;IACb,oBAAoB;IACpB,oBAAoB;CACZ,CAAC;AAEX,uFAAuF;AACvF,MAAM,OAAO,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include _shared/<path>` directives in `content`.
|
|
3
|
+
*
|
|
4
|
+
* Each line matching `@include _shared/<path>` (space after `@include`) is
|
|
5
|
+
* replaced with the full content of `<skillsRoot>/_shared/<path>`.
|
|
6
|
+
*
|
|
7
|
+
* Security constraints:
|
|
8
|
+
* - Only paths beginning with `_shared/` are accepted.
|
|
9
|
+
* - The resolved path must stay within `<skillsRoot>/_shared/`.
|
|
10
|
+
* Path traversal attempts are rejected with a warning and the directive
|
|
11
|
+
* line is dropped.
|
|
12
|
+
*
|
|
13
|
+
* If a shared file is missing (ENOENT):
|
|
14
|
+
* - A warning is written to stderr.
|
|
15
|
+
* - The include line is removed from the output (not preserved).
|
|
16
|
+
* - Processing continues for remaining directives.
|
|
17
|
+
*
|
|
18
|
+
* Other I/O errors (permission denied, EISDIR, etc.) are re-thrown so the
|
|
19
|
+
* caller can distinguish them from a simple missing-file case.
|
|
20
|
+
*
|
|
21
|
+
* @param skillContext Used in warning messages to identify the skill context.
|
|
22
|
+
* @param content Raw skill content (may contain @include directives).
|
|
23
|
+
* @param skillsRoot Root directory containing `_shared/` sub-directory.
|
|
24
|
+
* @returns The content with directives inlined.
|
|
25
|
+
*/
|
|
26
|
+
export declare function inlineIncludes(skillContext: string, content: string, skillsRoot: string): string;
|
|
27
|
+
//# sourceMappingURL=include-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"include-utils.d.ts","sourceRoot":"","sources":["../../src/skill-install/include-utils.ts"],"names":[],"mappings":"AAiBA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,cAAc,CAC5B,YAAY,EAAE,MAAM,EACpB,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,MAAM,GACjB,MAAM,CA6DR"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared include-inlining utilities for skill writers.
|
|
3
|
+
*
|
|
4
|
+
* Provides a common implementation for `@include _shared/<path>` directive
|
|
5
|
+
* processing, used by all skill writers (Claude Code, Cursor, etc.).
|
|
6
|
+
*
|
|
7
|
+
* @module
|
|
8
|
+
*/
|
|
9
|
+
import fs from 'node:fs';
|
|
10
|
+
import path from 'node:path';
|
|
11
|
+
/**
|
|
12
|
+
* Regex matching a line that starts with `@include ` (exact space after
|
|
13
|
+
* `@include`) followed by a relative path.
|
|
14
|
+
*/
|
|
15
|
+
const INCLUDE_RE = /^@include\s+(.+)$/;
|
|
16
|
+
/**
|
|
17
|
+
* Inline `@include _shared/<path>` directives in `content`.
|
|
18
|
+
*
|
|
19
|
+
* Each line matching `@include _shared/<path>` (space after `@include`) is
|
|
20
|
+
* replaced with the full content of `<skillsRoot>/_shared/<path>`.
|
|
21
|
+
*
|
|
22
|
+
* Security constraints:
|
|
23
|
+
* - Only paths beginning with `_shared/` are accepted.
|
|
24
|
+
* - The resolved path must stay within `<skillsRoot>/_shared/`.
|
|
25
|
+
* Path traversal attempts are rejected with a warning and the directive
|
|
26
|
+
* line is dropped.
|
|
27
|
+
*
|
|
28
|
+
* If a shared file is missing (ENOENT):
|
|
29
|
+
* - A warning is written to stderr.
|
|
30
|
+
* - The include line is removed from the output (not preserved).
|
|
31
|
+
* - Processing continues for remaining directives.
|
|
32
|
+
*
|
|
33
|
+
* Other I/O errors (permission denied, EISDIR, etc.) are re-thrown so the
|
|
34
|
+
* caller can distinguish them from a simple missing-file case.
|
|
35
|
+
*
|
|
36
|
+
* @param skillContext Used in warning messages to identify the skill context.
|
|
37
|
+
* @param content Raw skill content (may contain @include directives).
|
|
38
|
+
* @param skillsRoot Root directory containing `_shared/` sub-directory.
|
|
39
|
+
* @returns The content with directives inlined.
|
|
40
|
+
*/
|
|
41
|
+
export function inlineIncludes(skillContext, content, skillsRoot) {
|
|
42
|
+
const lines = content.split('\n');
|
|
43
|
+
const result = [];
|
|
44
|
+
for (const line of lines) {
|
|
45
|
+
const match = INCLUDE_RE.exec(line);
|
|
46
|
+
if (!match) {
|
|
47
|
+
result.push(line);
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
|
+
const relativePath = match[1] ?? '';
|
|
51
|
+
// Security: only accept paths beginning with `_shared/`
|
|
52
|
+
if (!relativePath.startsWith('_shared/')) {
|
|
53
|
+
process.stderr.write(`Warning: ${skillContext}: @include path must start with ` +
|
|
54
|
+
`"_shared/": ${relativePath}\n`);
|
|
55
|
+
// Directive line is dropped — do not push anything.
|
|
56
|
+
continue;
|
|
57
|
+
}
|
|
58
|
+
// Security: reject path traversal attempts
|
|
59
|
+
const resolvedPath = path.resolve(skillsRoot, relativePath);
|
|
60
|
+
const sharedDir = path.resolve(skillsRoot, '_shared');
|
|
61
|
+
if (!resolvedPath.startsWith(sharedDir + path.sep) &&
|
|
62
|
+
resolvedPath !== sharedDir) {
|
|
63
|
+
process.stderr.write(`Warning: ${skillContext}: @include path rejected ` +
|
|
64
|
+
`(path traversal): ${relativePath}\n`);
|
|
65
|
+
// Directive line is dropped.
|
|
66
|
+
continue;
|
|
67
|
+
}
|
|
68
|
+
const sharedFilePath = path.join(skillsRoot, relativePath);
|
|
69
|
+
try {
|
|
70
|
+
const sharedContent = fs.readFileSync(sharedFilePath, 'utf-8');
|
|
71
|
+
result.push(sharedContent);
|
|
72
|
+
}
|
|
73
|
+
catch (err) {
|
|
74
|
+
const nodeErr = err;
|
|
75
|
+
if (nodeErr.code === 'ENOENT') {
|
|
76
|
+
// Missing shared file — warn and drop the directive line.
|
|
77
|
+
const detail = err instanceof Error ? err.message : String(err);
|
|
78
|
+
process.stderr.write(`Warning: ${skillContext}: shared file not found: ` +
|
|
79
|
+
`${sharedFilePath} (referenced by @include ${relativePath}) — ${detail}\n`);
|
|
80
|
+
// Line is dropped — do not push anything.
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
// Permission errors, EISDIR, etc. — re-throw so the caller notices.
|
|
84
|
+
throw err;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
return result.join('\n');
|
|
89
|
+
}
|
|
90
|
+
//# sourceMappingURL=include-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"include-utils.js","sourceRoot":"","sources":["../../src/skill-install/include-utils.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B;;;GAGG;AACH,MAAM,UAAU,GAAG,mBAAmB,CAAC;AAEvC;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,UAAU,cAAc,CAC5B,YAAoB,EACpB,OAAe,EACf,UAAkB;IAElB,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAClC,MAAM,MAAM,GAAa,EAAE,CAAC;IAE5B,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,MAAM,KAAK,GAAG,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACpC,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAClB,SAAS;QACX,CAAC;QAED,MAAM,YAAY,GAAG,KAAK,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;QAEpC,wDAAwD;QACxD,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;YACzC,OAAO,CAAC,MAAM,CAAC,KAAK,CAClB,YAAY,YAAY,kCAAkC;gBAC1D,eAAe,YAAY,IAAI,CAChC,CAAC;YACF,oDAAoD;YACpD,SAAS;QACX,CAAC;QAED,2CAA2C;QAC3C,MAAM,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,YAAY,CAAC,CAAC;QAC5D,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,SAAS,CAAC,CAAC;QACtD,IACE,CAAC,YAAY,CAAC,UAAU,CAAC,SAAS,GAAG,IAAI,CAAC,GAAG,CAAC;YAC9C,YAAY,KAAK,SAAS,EAC1B,CAAC;YACD,OAAO,CAAC,MAAM,CAAC,KAAK,CAClB,YAAY,YAAY,2BAA2B;gBACnD,qBAAqB,YAAY,IAAI,CACtC,CAAC;YACF,6BAA6B;YAC7B,SAAS;QACX,CAAC;QAED,MAAM,cAAc,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,YAAY,CAAC,CAAC;QAE3D,IAAI,CAAC;YACH,MAAM,aAAa,GAAG,EAAE,CAAC,YAAY,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC;YAC/D,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QAC7B,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,MAAM,OAAO,GAAG,GAA4B,CAAC;YAC7C,IAAI,OAAO,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;gBAC9B,0DAA0D;gBAC1D,MAAM,MAAM,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;gBAChE,OAAO,CAAC,MAAM,CAAC,KAAK,CAClB,YAAY,YAAY,2BAA2B;oBACnD,GAAG,cAAc,4BAA4B,YAAY,OAAO,MAAM,IAAI,CAC3E,CAAC;gBACF,0CAA0C;YAC5C,CAAC;iBAAM,CAAC;gBACN,oEAAoE;gBACpE,MAAM,GAAG,CAAC;YACZ,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC3B,CAAC"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/** Union of all supported AI client targets. */
|
|
3
|
+
export type Client = 'claude-code' | 'gemini' | 'codex' | 'cursor';
|
|
4
|
+
/** All known client values — used for --all-targets and target validation. */
|
|
5
|
+
export declare const ALL_CLIENTS: readonly Client[];
|
|
6
|
+
/**
|
|
7
|
+
* Detect which AI client directories exist in the home directory.
|
|
8
|
+
* Checks for evidence of each known client:
|
|
9
|
+
* - claude-code: ~/.claude/ directory present (installs skills under ~/.claude/skills/)
|
|
10
|
+
* - gemini: ~/.gemini/extensions/ directory present
|
|
11
|
+
* - codex: ~/.codex/ directory present (installs skills under ~/.codex/skills/)
|
|
12
|
+
* - cursor: ~/.cursor/rules/ directory present
|
|
13
|
+
*
|
|
14
|
+
* The claude-code check deliberately accepts ~/.claude/ as sufficient signal
|
|
15
|
+
* even when ~/.claude/skills/ does not yet exist (fresh install with no skills).
|
|
16
|
+
*/
|
|
17
|
+
export declare function detectClients(homeDir: string): Client[];
|
|
18
|
+
declare const manifestEntrySchema: z.ZodObject<{
|
|
19
|
+
name: z.ZodString;
|
|
20
|
+
skillVersion: z.ZodString;
|
|
21
|
+
installedAt: z.ZodNumber;
|
|
22
|
+
targets: z.ZodArray<z.ZodEnum<{
|
|
23
|
+
gemini: "gemini";
|
|
24
|
+
"claude-code": "claude-code";
|
|
25
|
+
cursor: "cursor";
|
|
26
|
+
codex: "codex";
|
|
27
|
+
}>>;
|
|
28
|
+
}, z.core.$strip>;
|
|
29
|
+
declare const installManifestSchema: z.ZodObject<{
|
|
30
|
+
version: z.ZodLiteral<2>;
|
|
31
|
+
entries: z.ZodArray<z.ZodObject<{
|
|
32
|
+
name: z.ZodString;
|
|
33
|
+
skillVersion: z.ZodString;
|
|
34
|
+
installedAt: z.ZodNumber;
|
|
35
|
+
targets: z.ZodArray<z.ZodEnum<{
|
|
36
|
+
gemini: "gemini";
|
|
37
|
+
"claude-code": "claude-code";
|
|
38
|
+
cursor: "cursor";
|
|
39
|
+
codex: "codex";
|
|
40
|
+
}>>;
|
|
41
|
+
}, z.core.$strip>>;
|
|
42
|
+
}, z.core.$strip>;
|
|
43
|
+
export type InstallManifest = z.infer<typeof installManifestSchema>;
|
|
44
|
+
export type ManifestEntry = z.infer<typeof manifestEntrySchema>;
|
|
45
|
+
/** Thrown when the manifest declares a version newer than this mmagent supports. */
|
|
46
|
+
export declare class FutureManifestError extends Error {
|
|
47
|
+
constructor(version: number);
|
|
48
|
+
}
|
|
49
|
+
/** Thrown when the manifest JSON parses but fails Zod structural validation. */
|
|
50
|
+
export declare class ManifestSchemaValidationError extends Error {
|
|
51
|
+
constructor(manifestPath: string, issues: z.ZodError);
|
|
52
|
+
}
|
|
53
|
+
/** The directory where the manifest file lives. */
|
|
54
|
+
export declare function manifestDir(homeDir?: string): string;
|
|
55
|
+
/** Full path to the manifest file. */
|
|
56
|
+
export declare function manifestPath(homeDir?: string): string;
|
|
57
|
+
/**
|
|
58
|
+
* Return all manifest entries, newest-first.
|
|
59
|
+
*/
|
|
60
|
+
export declare function listEntries(homeDir?: string): ManifestEntry[];
|
|
61
|
+
/**
|
|
62
|
+
* Append (or update) the entry for `skillName`.
|
|
63
|
+
*
|
|
64
|
+
* - New entry: creates with de-duplicated `newTargets`.
|
|
65
|
+
* - Existing entry: merges `newTargets` into existing targets (no duplicates),
|
|
66
|
+
* refreshes `version` and `installedAt`.
|
|
67
|
+
*
|
|
68
|
+
* In both paths the stored `targets` array is a fresh copy — caller mutations
|
|
69
|
+
* after the call do not affect the in-memory object or persisted manifest.
|
|
70
|
+
*
|
|
71
|
+
* Returns the resulting entry.
|
|
72
|
+
*/
|
|
73
|
+
export declare function appendEntry(skillName: string, skillVersion: string, newTargets: Client[], homeDir?: string): ManifestEntry;
|
|
74
|
+
/**
|
|
75
|
+
* Remove `targets` from the entry for `skillName`.
|
|
76
|
+
* If `targets` is omitted or empty, removes the entire entry.
|
|
77
|
+
* Returns the removed targets (or all targets for a full removal),
|
|
78
|
+
* or an empty array if the skill wasn't in the manifest.
|
|
79
|
+
*/
|
|
80
|
+
export declare function removeEntry(skillName: string, targets?: Client[], homeDir?: string): Client[];
|
|
81
|
+
export {};
|
|
82
|
+
//# sourceMappingURL=manifest.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manifest.d.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