@zhixuan92/multi-model-agent 3.0.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.
Files changed (169) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +217 -0
  3. package/dist/cli/index.d.ts +61 -0
  4. package/dist/cli/index.d.ts.map +1 -0
  5. package/dist/cli/index.js +252 -0
  6. package/dist/cli/index.js.map +1 -0
  7. package/dist/cli/install-skill.d.ts +158 -0
  8. package/dist/cli/install-skill.d.ts.map +1 -0
  9. package/dist/cli/install-skill.js +425 -0
  10. package/dist/cli/install-skill.js.map +1 -0
  11. package/dist/cli/print-token.d.ts +18 -0
  12. package/dist/cli/print-token.d.ts.map +1 -0
  13. package/dist/cli/print-token.js +60 -0
  14. package/dist/cli/print-token.js.map +1 -0
  15. package/dist/cli/serve.d.ts +44 -0
  16. package/dist/cli/serve.d.ts.map +1 -0
  17. package/dist/cli/serve.js +61 -0
  18. package/dist/cli/serve.js.map +1 -0
  19. package/dist/cli/status.d.ts +49 -0
  20. package/dist/cli/status.d.ts.map +1 -0
  21. package/dist/cli/status.js +155 -0
  22. package/dist/cli/status.js.map +1 -0
  23. package/dist/http/async-dispatch.d.ts +32 -0
  24. package/dist/http/async-dispatch.d.ts.map +1 -0
  25. package/dist/http/async-dispatch.js +53 -0
  26. package/dist/http/async-dispatch.js.map +1 -0
  27. package/dist/http/auth.d.ts +26 -0
  28. package/dist/http/auth.d.ts.map +1 -0
  29. package/dist/http/auth.js +64 -0
  30. package/dist/http/auth.js.map +1 -0
  31. package/dist/http/cwd-validator.d.ts +11 -0
  32. package/dist/http/cwd-validator.d.ts.map +1 -0
  33. package/dist/http/cwd-validator.js +115 -0
  34. package/dist/http/cwd-validator.js.map +1 -0
  35. package/dist/http/errors.d.ts +4 -0
  36. package/dist/http/errors.d.ts.map +1 -0
  37. package/dist/http/errors.js +9 -0
  38. package/dist/http/errors.js.map +1 -0
  39. package/dist/http/execution-context.d.ts +15 -0
  40. package/dist/http/execution-context.d.ts.map +1 -0
  41. package/dist/http/execution-context.js +35 -0
  42. package/dist/http/execution-context.js.map +1 -0
  43. package/dist/http/handler-deps.d.ts +16 -0
  44. package/dist/http/handler-deps.d.ts.map +1 -0
  45. package/dist/http/handler-deps.js +2 -0
  46. package/dist/http/handler-deps.js.map +1 -0
  47. package/dist/http/handlers/control/batch.d.ts +24 -0
  48. package/dist/http/handlers/control/batch.d.ts.map +1 -0
  49. package/dist/http/handlers/control/batch.js +81 -0
  50. package/dist/http/handlers/control/batch.js.map +1 -0
  51. package/dist/http/handlers/control/clarifications.d.ts +19 -0
  52. package/dist/http/handlers/control/clarifications.d.ts.map +1 -0
  53. package/dist/http/handlers/control/clarifications.js +58 -0
  54. package/dist/http/handlers/control/clarifications.js.map +1 -0
  55. package/dist/http/handlers/control/context-blocks.d.ts +22 -0
  56. package/dist/http/handlers/control/context-blocks.d.ts.map +1 -0
  57. package/dist/http/handlers/control/context-blocks.js +88 -0
  58. package/dist/http/handlers/control/context-blocks.js.map +1 -0
  59. package/dist/http/handlers/introspection/health.d.ts +13 -0
  60. package/dist/http/handlers/introspection/health.d.ts.map +1 -0
  61. package/dist/http/handlers/introspection/health.js +17 -0
  62. package/dist/http/handlers/introspection/health.js.map +1 -0
  63. package/dist/http/handlers/introspection/status.d.ts +26 -0
  64. package/dist/http/handlers/introspection/status.d.ts.map +1 -0
  65. package/dist/http/handlers/introspection/status.js +136 -0
  66. package/dist/http/handlers/introspection/status.js.map +1 -0
  67. package/dist/http/handlers/introspection/tools-list.d.ts +9 -0
  68. package/dist/http/handlers/introspection/tools-list.d.ts.map +1 -0
  69. package/dist/http/handlers/introspection/tools-list.js +28 -0
  70. package/dist/http/handlers/introspection/tools-list.js.map +1 -0
  71. package/dist/http/handlers/tools/audit.d.ts +4 -0
  72. package/dist/http/handlers/tools/audit.d.ts.map +1 -0
  73. package/dist/http/handlers/tools/audit.js +39 -0
  74. package/dist/http/handlers/tools/audit.js.map +1 -0
  75. package/dist/http/handlers/tools/debug.d.ts +4 -0
  76. package/dist/http/handlers/tools/debug.d.ts.map +1 -0
  77. package/dist/http/handlers/tools/debug.js +39 -0
  78. package/dist/http/handlers/tools/debug.js.map +1 -0
  79. package/dist/http/handlers/tools/delegate.d.ts +4 -0
  80. package/dist/http/handlers/tools/delegate.d.ts.map +1 -0
  81. package/dist/http/handlers/tools/delegate.js +57 -0
  82. package/dist/http/handlers/tools/delegate.js.map +1 -0
  83. package/dist/http/handlers/tools/execute-plan.d.ts +4 -0
  84. package/dist/http/handlers/tools/execute-plan.d.ts.map +1 -0
  85. package/dist/http/handlers/tools/execute-plan.js +39 -0
  86. package/dist/http/handlers/tools/execute-plan.js.map +1 -0
  87. package/dist/http/handlers/tools/retry.d.ts +4 -0
  88. package/dist/http/handlers/tools/retry.d.ts.map +1 -0
  89. package/dist/http/handlers/tools/retry.js +52 -0
  90. package/dist/http/handlers/tools/retry.js.map +1 -0
  91. package/dist/http/handlers/tools/review.d.ts +4 -0
  92. package/dist/http/handlers/tools/review.d.ts.map +1 -0
  93. package/dist/http/handlers/tools/review.js +39 -0
  94. package/dist/http/handlers/tools/review.js.map +1 -0
  95. package/dist/http/handlers/tools/verify.d.ts +4 -0
  96. package/dist/http/handlers/tools/verify.d.ts.map +1 -0
  97. package/dist/http/handlers/tools/verify.js +39 -0
  98. package/dist/http/handlers/tools/verify.js.map +1 -0
  99. package/dist/http/loopback.d.ts +17 -0
  100. package/dist/http/loopback.d.ts.map +1 -0
  101. package/dist/http/loopback.js +43 -0
  102. package/dist/http/loopback.js.map +1 -0
  103. package/dist/http/middleware/body-reader.d.ts +16 -0
  104. package/dist/http/middleware/body-reader.d.ts.map +1 -0
  105. package/dist/http/middleware/body-reader.js +44 -0
  106. package/dist/http/middleware/body-reader.js.map +1 -0
  107. package/dist/http/project-registry.d.ts +54 -0
  108. package/dist/http/project-registry.d.ts.map +1 -0
  109. package/dist/http/project-registry.js +132 -0
  110. package/dist/http/project-registry.js.map +1 -0
  111. package/dist/http/router.d.ts +14 -0
  112. package/dist/http/router.d.ts.map +1 -0
  113. package/dist/http/router.js +41 -0
  114. package/dist/http/router.js.map +1 -0
  115. package/dist/http/server.d.ts +16 -0
  116. package/dist/http/server.d.ts.map +1 -0
  117. package/dist/http/server.js +235 -0
  118. package/dist/http/server.js.map +1 -0
  119. package/dist/http/types.d.ts +9 -0
  120. package/dist/http/types.d.ts.map +1 -0
  121. package/dist/http/types.js +2 -0
  122. package/dist/http/types.js.map +1 -0
  123. package/dist/index.d.ts +2 -0
  124. package/dist/index.d.ts.map +1 -0
  125. package/dist/index.js +2 -0
  126. package/dist/index.js.map +1 -0
  127. package/dist/install/claude-code.d.ts +43 -0
  128. package/dist/install/claude-code.d.ts.map +1 -0
  129. package/dist/install/claude-code.js +65 -0
  130. package/dist/install/claude-code.js.map +1 -0
  131. package/dist/install/codex-cli.d.ts +39 -0
  132. package/dist/install/codex-cli.d.ts.map +1 -0
  133. package/dist/install/codex-cli.js +318 -0
  134. package/dist/install/codex-cli.js.map +1 -0
  135. package/dist/install/cursor.d.ts +72 -0
  136. package/dist/install/cursor.d.ts.map +1 -0
  137. package/dist/install/cursor.js +81 -0
  138. package/dist/install/cursor.js.map +1 -0
  139. package/dist/install/gemini-cli.d.ts +66 -0
  140. package/dist/install/gemini-cli.d.ts.map +1 -0
  141. package/dist/install/gemini-cli.js +111 -0
  142. package/dist/install/gemini-cli.js.map +1 -0
  143. package/dist/install/include-utils.d.ts +27 -0
  144. package/dist/install/include-utils.d.ts.map +1 -0
  145. package/dist/install/include-utils.js +90 -0
  146. package/dist/install/include-utils.js.map +1 -0
  147. package/dist/install/manifest.d.ts +90 -0
  148. package/dist/install/manifest.d.ts.map +1 -0
  149. package/dist/install/manifest.js +200 -0
  150. package/dist/install/manifest.js.map +1 -0
  151. package/dist/openapi.d.ts +15 -0
  152. package/dist/openapi.d.ts.map +1 -0
  153. package/dist/openapi.js +314 -0
  154. package/dist/openapi.js.map +1 -0
  155. package/dist/skills/_shared/auth.md +32 -0
  156. package/dist/skills/_shared/error-handling.md +31 -0
  157. package/dist/skills/_shared/polling.md +40 -0
  158. package/dist/skills/_shared/response-shape.md +46 -0
  159. package/dist/skills/mma-audit/SKILL.md +55 -0
  160. package/dist/skills/mma-clarifications/SKILL.md +68 -0
  161. package/dist/skills/mma-context-blocks/SKILL.md +69 -0
  162. package/dist/skills/mma-debug/SKILL.md +59 -0
  163. package/dist/skills/mma-delegate/SKILL.md +63 -0
  164. package/dist/skills/mma-execute-plan/SKILL.md +63 -0
  165. package/dist/skills/mma-retry/SKILL.md +54 -0
  166. package/dist/skills/mma-review/SKILL.md +55 -0
  167. package/dist/skills/mma-verify/SKILL.md +57 -0
  168. package/dist/skills/multi-model-agent/SKILL.md +55 -0
  169. package/package.json +60 -0
@@ -0,0 +1,158 @@
1
+ import type { Client } from '../install/manifest.js';
2
+ export type { Client } from '../install/manifest.js';
3
+ export { ALL_CLIENTS, detectClients } from '../install/manifest.js';
4
+ export declare const SUPPORTED_SKILLS: readonly ["multi-model-agent", "mma-delegate", "mma-audit", "mma-review", "mma-verify", "mma-debug", "mma-execute-plan", "mma-retry", "mma-context-blocks", "mma-clarifications"];
5
+ /** Thrown when a passed `--target` value is not a known client. */
6
+ export declare class UnknownTargetError extends Error {
7
+ readonly code: "unknown_target";
8
+ constructor(target: string, valid: readonly Client[]);
9
+ }
10
+ /** Thrown when a skill's SKILL.md cannot be read from the bundled skills directory. */
11
+ export declare class SkillNotFoundError extends Error {
12
+ readonly code: "skill_not_found";
13
+ constructor(skillName: string, checkedPath: string);
14
+ }
15
+ /**
16
+ * Return the absolute path to the skills root directory.
17
+ *
18
+ * The skills root is the directory containing per-skill sub-directories
19
+ * (e.g. `<root>/mma-delegate/SKILL.md`). In production this resolves to
20
+ * `packages/server/src/skills/`. During tests the caller can pass a custom
21
+ * `skillsRoot` to read from a temp fixture instead.
22
+ */
23
+ export declare function getSkillsRoot(skillsRoot?: string): string;
24
+ /**
25
+ * Read the content of a skill's SKILL.md file.
26
+ * Returns null if the file does not exist.
27
+ * Propagates permission errors and other I/O problems so callers can
28
+ * distinguish "skill not found" from "can't access skill".
29
+ */
30
+ export declare function readSkillContent(skillName: string, skillsRoot?: string): string | null;
31
+ /**
32
+ * Write a skill's SKILL.md content to the target client's skill directory.
33
+ * Dispatches to the appropriate writer based on `target`.
34
+ *
35
+ * @param skillName The skill name (used in paths and warnings).
36
+ * @param content Raw SKILL.md content (may contain @include directives).
37
+ * @param target The AI client to install the skill for.
38
+ * @param homeDir Home directory (replaces os.homedir()).
39
+ * @param skillsRoot Root of the skills directory (for @include resolution).
40
+ * @param version Skill version string (used by Gemini extension manifest).
41
+ * @param cwd Current working directory (used by Cursor; defaults to process.cwd()).
42
+ * @param force If true, overwrite existing Cursor file without warning.
43
+ */
44
+ export declare function writeSkillToClient(skillName: string, content: string, target: Client, homeDir: string, skillsRoot: string, version?: string, cwd?: string, force?: boolean): void;
45
+ /**
46
+ * Remove a skill's files from the target client's skill directory.
47
+ * Dispatches to the appropriate remover based on `target`.
48
+ *
49
+ * @param skillName The skill name (used for claude-code path resolution).
50
+ * @param target The AI client to uninstall the skill from.
51
+ * @param homeDir Home directory (replaces os.homedir()).
52
+ * @param cwd Current working directory (used by Cursor; defaults to process.cwd()).
53
+ */
54
+ export declare function removeSkillFromClient(skillName: string, target: Client, homeDir: string, cwd?: string): void;
55
+ export interface InstallResult {
56
+ skill: string;
57
+ action: 'installed' | 'uninstalled';
58
+ /** Targets for which the operation succeeded. */
59
+ targets: Client[];
60
+ /** Targets that were skipped (dry-run, unknown, or not applicable). */
61
+ skipped: Client[];
62
+ /** Files would be written but were not (dry-run mode). */
63
+ dryRun: boolean;
64
+ }
65
+ /**
66
+ * Return codes for `main()`.
67
+ * Exported so callers (e.g. the CLI dispatcher in cli/index.ts) can pass the
68
+ * code to `exit()` without calling `process.exit()` directly.
69
+ */
70
+ export declare const ExitCode: Readonly<{
71
+ SUCCESS: 0;
72
+ ERR_INVALID_ARGS: 1;
73
+ ERR_SKILL_NOT_FOUND: 2;
74
+ ERR_UNKNOWN_SKILL: 3;
75
+ ERR_NO_TARGETS: 4;
76
+ ERR_WRITER_NOT_IMPLEMENTED: 5;
77
+ ERR_UNKNOWN_TARGET: 7;
78
+ ERR_UNKNOWN: 8;
79
+ }>;
80
+ /**
81
+ * Install a skill to the specified client targets.
82
+ * - dryRun=true: checks skill existence; does NOT write files or update manifest.
83
+ * - dryRun=false: writes files via the per-client writers.
84
+ */
85
+ export declare function doInstall(skillName: string, targets: Client[], opts: {
86
+ dryRun: boolean;
87
+ homeDir: string;
88
+ skillsRoot?: string;
89
+ version?: string;
90
+ cwd?: string;
91
+ force?: boolean;
92
+ }): InstallResult;
93
+ /**
94
+ * Uninstall a skill from the specified client targets.
95
+ * - dryRun=true: resolves targets; does NOT remove files or update manifest.
96
+ * - dryRun=false: removes files via the per-client removers.
97
+ */
98
+ export declare function doUninstall(skillName: string, targets: Client[], opts: {
99
+ dryRun: boolean;
100
+ homeDir: string;
101
+ cwd?: string;
102
+ }): InstallResult;
103
+ export interface ParsedArgs {
104
+ skill: string | null;
105
+ /** Explicit --config path, or null if not specified. */
106
+ configPath: string | null;
107
+ uninstall: boolean;
108
+ dryRun: boolean;
109
+ json: boolean;
110
+ targets: Client[] | null;
111
+ allTargets: boolean;
112
+ }
113
+ /**
114
+ * Parse CLI arguments for `install-skill`.
115
+ *
116
+ * NOTE: `stopEarly` is deliberately NOT set on minimist. `stopEarly: true`
117
+ * causes options after the first positional argument to be treated as positional
118
+ * tail, which would misparse a call like:
119
+ * mmagent install-skill mma-delegate --json
120
+ * (--json would be captured in `_` instead of setting the `json` flag).
121
+ * Instead we let minimist consume all arguments normally.
122
+ */
123
+ export declare function parseArgs(argv: string[]): ParsedArgs;
124
+ /**
125
+ * Resolve the target client list.
126
+ * Priority:
127
+ * 1. explicit `--target` arguments (validated against known clients)
128
+ * 2. `--all-targets` → all four known clients
129
+ * 3. auto-detect based on `homeDir`
130
+ *
131
+ * Explicit targets are de-duplicated while preserving order of first occurrence.
132
+ *
133
+ * @throws UnknownTargetError if an explicit target is not a known client.
134
+ */
135
+ export declare function resolveTargets(explicitTargets: Client[] | null, allTargets: boolean, homeDir: string): Client[];
136
+ export interface MainDeps {
137
+ /** Override argv (defaults to process.argv.slice(2)). */
138
+ argv?: string[];
139
+ /** Home directory (defaults to os.homedir()). */
140
+ homeDir?: string;
141
+ /** Package version string for manifest entries (defaults to '0.0.0'). */
142
+ version?: string;
143
+ /** Override skills root for testing. */
144
+ skillsRoot?: string;
145
+ /** Injectable stdout writer. */
146
+ stdout?: (s: string) => boolean;
147
+ /** Injectable stderr writer. */
148
+ stderr?: (s: string) => boolean;
149
+ }
150
+ /**
151
+ * Main entry point for `mmagent install-skill`.
152
+ *
153
+ * Returns an exit code (one of `ExitCode.*`) instead of calling `process.exit()`
154
+ * directly, so the CLI dispatcher in `cli/index.ts` can control the exit
155
+ * decision and make the function fully unit-testable.
156
+ */
157
+ export declare function main(deps?: MainDeps): Promise<number>;
158
+ //# sourceMappingURL=install-skill.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"install-skill.d.ts","sourceRoot":"","sources":["../../src/cli/install-skill.ts"],"names":[],"mappings":"AAuBA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAQrD,YAAY,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAEpE,eAAO,MAAM,gBAAgB,mLAWnB,CAAC;AAIX,mEAAmE;AACnE,qBAAa,kBAAmB,SAAQ,KAAK;IAC3C,QAAQ,CAAC,IAAI,EAAG,gBAAgB,CAAU;gBAC9B,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,MAAM,EAAE;CAGrD;AAED,uFAAuF;AACvF,qBAAa,kBAAmB,SAAQ,KAAK;IAC3C,QAAQ,CAAC,IAAI,EAAG,iBAAiB,CAAU;gB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M,KAAK,OAAO,CAAC;CACjC;AAED;;;;;;GAMG;AACH,wBAAsB,IAAI,CAAC,IAAI,GAAE,QAAa,GAAG,OAAO,CAAC,MAAM,CAAC,CAwF/D"}
@@ -0,0 +1,425 @@
1
+ /**
2
+ * `mmagent install-skill` CLI command.
3
+ *
4
+ * Syntax:
5
+ * mmagent install-skill [--uninstall] [--dry-run] [--json]
6
+ * [--target=claude-code|gemini|codex|cursor]
7
+ * [--all-targets] [skill-name]
8
+ *
9
+ * Skills are sourced from packages/server/src/skills/<skill-name>/SKILL.md.
10
+ * install-skill copies the SKILL.md to the appropriate per-client location
11
+ * and records the installation in the manifest (~/.multi-model/install-manifest.json).
12
+ *
13
+ * Task 9.4 scope: CLI scaffolding, manifest read/append-entry/remove-entry,
14
+ * auto-detection scaffolding, dry-run mode.
15
+ * Tasks 9.5–9.8: Individual client writers.
16
+ * Task 9.9: Uninstall wires all removers.
17
+ */
18
+ import fs from 'node:fs';
19
+ import path from 'node:path';
20
+ import os from 'node:os';
21
+ import { fileURLToPath } from 'node:url';
22
+ import minimist from 'minimist';
23
+ import * as manifest from '../install/manifest.js';
24
+ import { ALL_CLIENTS, detectClients } from '../install/manifest.js';
25
+ import { installClaudeCode, uninstallClaudeCode } from '../install/claude-code.js';
26
+ import { installGeminiCli, uninstallGeminiCli } from '../install/gemini-cli.js';
27
+ import { installCodexCli, uninstallCodexCli } from '../install/codex-cli.js';
28
+ import { installCursor, uninstallCursor } from '../install/cursor.js';
29
+ export { ALL_CLIENTS, detectClients } from '../install/manifest.js';
30
+ export const SUPPORTED_SKILLS = [
31
+ 'multi-model-agent',
32
+ 'mma-delegate',
33
+ 'mma-audit',
34
+ 'mma-review',
35
+ 'mma-verify',
36
+ 'mma-debug',
37
+ 'mma-execute-plan',
38
+ 'mma-retry',
39
+ 'mma-context-blocks',
40
+ 'mma-clarifications',
41
+ ];
42
+ // ─── Custom errors ────────────────────────────────────────────────────────────
43
+ /** Thrown when a passed `--target` value is not a known client. */
44
+ export class UnknownTargetError extends Error {
45
+ code = 'unknown_target';
46
+ constructor(target, valid) {
47
+ super(`Unknown target: ${target}. Valid: ${valid.join(', ')}`);
48
+ }
49
+ }
50
+ /** Thrown when a skill's SKILL.md cannot be read from the bundled skills directory. */
51
+ export class SkillNotFoundError extends Error {
52
+ code = 'skill_not_found';
53
+ constructor(skillName, checkedPath) {
54
+ super(`Skill '${skillName}' not found. ` +
55
+ `Checked: ${checkedPath}. ` +
56
+ `Available skills: ${SUPPORTED_SKILLS.join(', ')}`);
57
+ }
58
+ }
59
+ // ─── Skills root ────────────────────────────────────────────────────────────
60
+ /** Resolved path to the bundled skills directory. Can be overridden for testing. */
61
+ const DEFAULT_SKILLS_ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..', 'skills');
62
+ /**
63
+ * Return the absolute path to the skills root directory.
64
+ *
65
+ * The skills root is the directory containing per-skill sub-directories
66
+ * (e.g. `<root>/mma-delegate/SKILL.md`). In production this resolves to
67
+ * `packages/server/src/skills/`. During tests the caller can pass a custom
68
+ * `skillsRoot` to read from a temp fixture instead.
69
+ */
70
+ export function getSkillsRoot(skillsRoot) {
71
+ return skillsRoot ?? DEFAULT_SKILLS_ROOT;
72
+ }
73
+ /**
74
+ * Read the content of a skill's SKILL.md file.
75
+ * Returns null if the file does not exist.
76
+ * Propagates permission errors and other I/O problems so callers can
77
+ * distinguish "skill not found" from "can't access skill".
78
+ */
79
+ export function readSkillContent(skillName, skillsRoot) {
80
+ const skillFile = path.join(getSkillsRoot(skillsRoot), skillName, 'SKILL.md');
81
+ try {
82
+ return fs.readFileSync(skillFile, 'utf-8');
83
+ }
84
+ catch (err) {
85
+ if (err.code === 'ENOENT')
86
+ return null;
87
+ throw err;
88
+ }
89
+ }
90
+ // ─── Per-client writer/remover dispatch ───────────────────────────────────────
91
+ /**
92
+ * Write a skill's SKILL.md content to the target client's skill directory.
93
+ * Dispatches to the appropriate writer based on `target`.
94
+ *
95
+ * @param skillName The skill name (used in paths and warnings).
96
+ * @param content Raw SKILL.md content (may contain @include directives).
97
+ * @param target The AI client to install the skill for.
98
+ * @param homeDir Home directory (replaces os.homedir()).
99
+ * @param skillsRoot Root of the skills directory (for @include resolution).
100
+ * @param version Skill version string (used by Gemini extension manifest).
101
+ * @param cwd Current working directory (used by Cursor; defaults to process.cwd()).
102
+ * @param force If true, overwrite existing Cursor file without warning.
103
+ */
104
+ export function writeSkillToClient(skillName, content, target, homeDir, skillsRoot, version = '0.0.0', cwd = process.cwd(), force = false) {
105
+ switch (target) {
106
+ case 'claude-code':
107
+ installClaudeCode({ skillName, content, homeDir, skillsRoot });
108
+ break;
109
+ case 'gemini':
110
+ installGeminiCli({ skillName, content, skillVersion: version, homeDir, skillsRoot });
111
+ break;
112
+ case 'codex':
113
+ installCodexCli({ skillName, content, homeDir, skillsRoot });
114
+ break;
115
+ case 'cursor':
116
+ installCursor({ content, cwd, homeDir, skillsRoot, force });
117
+ break;
118
+ default: {
119
+ const _exhaustive = target;
120
+ throw new Error(`install-skill: unknown target: ${_exhaustive}`);
121
+ }
122
+ }
123
+ }
124
+ /**
125
+ * Remove a skill's files from the target client's skill directory.
126
+ * Dispatches to the appropriate remover based on `target`.
127
+ *
128
+ * @param skillName The skill name (used for claude-code path resolution).
129
+ * @param target The AI client to uninstall the skill from.
130
+ * @param homeDir Home directory (replaces os.homedir()).
131
+ * @param cwd Current working directory (used by Cursor; defaults to process.cwd()).
132
+ */
133
+ export function removeSkillFromClient(skillName, target, homeDir, cwd = process.cwd()) {
134
+ switch (target) {
135
+ case 'claude-code':
136
+ uninstallClaudeCode(skillName, homeDir);
137
+ break;
138
+ case 'gemini':
139
+ uninstallGeminiCli(homeDir);
140
+ break;
141
+ case 'codex':
142
+ uninstallCodexCli(homeDir);
143
+ break;
144
+ case 'cursor':
145
+ uninstallCursor(cwd);
146
+ break;
147
+ default: {
148
+ const _exhaustive = target;
149
+ throw new Error(`install-skill: unknown target: ${_exhaustive}`);
150
+ }
151
+ }
152
+ }
153
+ /**
154
+ * Return codes for `main()`.
155
+ * Exported so callers (e.g. the CLI dispatcher in cli/index.ts) can pass the
156
+ * code to `exit()` without calling `process.exit()` directly.
157
+ */
158
+ export const ExitCode = Object.freeze({
159
+ SUCCESS: 0,
160
+ ERR_INVALID_ARGS: 1,
161
+ ERR_SKILL_NOT_FOUND: 2,
162
+ ERR_UNKNOWN_SKILL: 3,
163
+ ERR_NO_TARGETS: 4,
164
+ ERR_WRITER_NOT_IMPLEMENTED: 5,
165
+ ERR_UNKNOWN_TARGET: 7,
166
+ ERR_UNKNOWN: 8,
167
+ });
168
+ // ─── Core logic ─────────────────────────────────────────────────────────────
169
+ /**
170
+ * Install a skill to the specified client targets.
171
+ * - dryRun=true: checks skill existence; does NOT write files or update manifest.
172
+ * - dryRun=false: writes files via the per-client writers.
173
+ */
174
+ export function doInstall(skillName, targets, opts) {
175
+ const checkedPath = path.join(getSkillsRoot(opts.skillsRoot), skillName, 'SKILL.md');
176
+ const content = readSkillContent(skillName, opts.skillsRoot);
177
+ if (!content) {
178
+ throw new SkillNotFoundError(skillName, checkedPath);
179
+ }
180
+ const skillsRoot = getSkillsRoot(opts.skillsRoot);
181
+ const version = opts.version ?? '0.0.0';
182
+ const cwd = opts.cwd ?? process.cwd();
183
+ const installed = [];
184
+ const skipped = [];
185
+ for (const target of targets) {
186
+ if (opts.dryRun) {
187
+ // In dry-run: record target as skipped (would write), not installed
188
+ skipped.push(target);
189
+ }
190
+ else {
191
+ writeSkillToClient(skillName, content, target, opts.homeDir, skillsRoot, version, cwd, opts.force);
192
+ installed.push(target);
193
+ }
194
+ }
195
+ return { skill: skillName, action: 'installed', targets: installed, skipped, dryRun: opts.dryRun };
196
+ }
197
+ /**
198
+ * Uninstall a skill from the specified client targets.
199
+ * - dryRun=true: resolves targets; does NOT remove files or update manifest.
200
+ * - dryRun=false: removes files via the per-client removers.
201
+ */
202
+ export function doUninstall(skillName, targets, opts) {
203
+ const cwd = opts.cwd ?? process.cwd();
204
+ const installed = [];
205
+ const skipped = [];
206
+ for (const target of targets) {
207
+ if (opts.dryRun) {
208
+ skipped.push(target);
209
+ }
210
+ else {
211
+ removeSkillFromClient(skillName, target, opts.homeDir, cwd);
212
+ installed.push(target);
213
+ }
214
+ }
215
+ return { skill: skillName, action: 'uninstalled', targets: installed, skipped, dryRun: opts.dryRun };
216
+ }
217
+ /**
218
+ * Parse CLI arguments for `install-skill`.
219
+ *
220
+ * NOTE: `stopEarly` is deliberately NOT set on minimist. `stopEarly: true`
221
+ * causes options after the first positional argument to be treated as positional
222
+ * tail, which would misparse a call like:
223
+ * mmagent install-skill mma-delegate --json
224
+ * (--json would be captured in `_` instead of setting the `json` flag).
225
+ * Instead we let minimist consume all arguments normally.
226
+ */
227
+ export function parseArgs(argv) {
228
+ const args = minimist(argv, {
229
+ string: ['target', 'skill', 'config'],
230
+ boolean: ['uninstall', 'dry-run', 'json', 'all-targets'],
231
+ alias: {
232
+ u: 'uninstall',
233
+ j: 'json',
234
+ t: 'target',
235
+ c: 'config',
236
+ },
237
+ // stopEarly is NOT set — see note above.
238
+ });
239
+ const skill = args._[0] ?? null;
240
+ const configPath = typeof args['config'] === 'string' && args['config'].length > 0
241
+ ? args['config']
242
+ : null;
243
+ const uninstall = args['uninstall'] === true;
244
+ const dryRun = args['dry-run'] === true;
245
+ const json = args['json'] === true;
246
+ const allTargets = args['all-targets'] === true;
247
+ let targets = null;
248
+ if (args.target) {
249
+ const t = Array.isArray(args.target) ? args.target : [args.target];
250
+ targets = t.map((s) => s);
251
+ }
252
+ return { skill, configPath, uninstall, dryRun, json, targets, allTargets };
253
+ }
254
+ /**
255
+ * Resolve the target client list.
256
+ * Priority:
257
+ * 1. explicit `--target` arguments (validated against known clients)
258
+ * 2. `--all-targets` → all four known clients
259
+ * 3. auto-detect based on `homeDir`
260
+ *
261
+ * Explicit targets are de-duplicated while preserving order of first occurrence.
262
+ *
263
+ * @throws UnknownTargetError if an explicit target is not a known client.
264
+ */
265
+ export function resolveTargets(explicitTargets, allTargets, homeDir) {
266
+ if (allTargets)
267
+ return [...ALL_CLIENTS];
268
+ if (explicitTargets !== null) {
269
+ const seen = new Set();
270
+ const deduped = [];
271
+ for (const t of explicitTargets) {
272
+ if (!ALL_CLIENTS.includes(t)) {
273
+ throw new UnknownTargetError(t, ALL_CLIENTS);
274
+ }
275
+ if (!seen.has(t)) {
276
+ seen.add(t);
277
+ deduped.push(t);
278
+ }
279
+ }
280
+ return deduped;
281
+ }
282
+ return detectClients(homeDir);
283
+ }
284
+ // ─── Output helpers ─────────────────────────────────────────────────────────
285
+ /**
286
+ * Print an error message.
287
+ * Both branches write through the injectable `stderr` writer for testability.
288
+ */
289
+ function printError(stderr, json, code, message, stdout) {
290
+ if (json) {
291
+ // JSON error output goes to stdout so callers can parse it
292
+ const out = stdout ?? process.stdout.write.bind(process.stdout);
293
+ out(JSON.stringify({ error: code, message }) + '\n');
294
+ }
295
+ else {
296
+ stderr(message + '\n');
297
+ }
298
+ }
299
+ /**
300
+ * Print a success result.
301
+ * All output goes through the injectable `stdout` writer for testability.
302
+ */
303
+ function printResult(stdout, result, json, manifestUpdated) {
304
+ if (json) {
305
+ stdout(JSON.stringify(result) + '\n');
306
+ }
307
+ else {
308
+ const verb = result.action === 'installed' ? 'Installed' : 'Uninstalled';
309
+ const targetStr = result.targets.length > 0 ? ` → ${result.targets.join(', ')}` : '';
310
+ const skippedStr = result.skipped.length > 0 ? ` (dry-run: ${result.skipped.join(', ')})` : '';
311
+ let line = `${verb} '${result.skill}'${targetStr}${skippedStr}\n`;
312
+ if (manifestUpdated) {
313
+ line += 'Manifest updated.\n';
314
+ }
315
+ stdout(line);
316
+ }
317
+ }
318
+ /**
319
+ * Main entry point for `mmagent install-skill`.
320
+ *
321
+ * Returns an exit code (one of `ExitCode.*`) instead of calling `process.exit()`
322
+ * directly, so the CLI dispatcher in `cli/index.ts` can control the exit
323
+ * decision and make the function fully unit-testable.
324
+ */
325
+ export async function main(deps = {}) {
326
+ const argv = deps.argv ?? process.argv.slice(2);
327
+ const homeDir = deps.homeDir ?? os.homedir();
328
+ const version = deps.version ?? '0.0.0';
329
+ const stdout = deps.stdout ?? process.stdout.write.bind(process.stdout);
330
+ const stderr = deps.stderr ?? process.stderr.write.bind(process.stderr);
331
+ const { skill, uninstall, dryRun, json, targets: explicitTargets, allTargets } = parseArgs(argv);
332
+ // ── 1. Validate skill name ──────────────────────────────────────────────────
333
+ if (!skill) {
334
+ const msg = 'Usage: mmagent install-skill [--uninstall] [--dry-run] [--json] [--target=<client>] [--all-targets] <skill-name>\n' +
335
+ 'Skills: ' + SUPPORTED_SKILLS.join(', ');
336
+ printError(stderr, json, 'missing_skill_name', msg, stdout);
337
+ return ExitCode.ERR_INVALID_ARGS;
338
+ }
339
+ if (!SUPPORTED_SKILLS.includes(skill)) {
340
+ const msg = `Unknown skill '${skill}'. Available: ${SUPPORTED_SKILLS.join(', ')}`;
341
+ printError(stderr, json, 'unknown_skill', msg, stdout);
342
+ return ExitCode.ERR_UNKNOWN_SKILL;
343
+ }
344
+ // ── 2. Resolve targets (may throw UnknownTargetError) ──────────────────────
345
+ let resolvedTargets;
346
+ try {
347
+ resolvedTargets = resolveTargets(explicitTargets, allTargets, homeDir);
348
+ }
349
+ catch (err) {
350
+ if (err instanceof UnknownTargetError) {
351
+ printError(stderr, json, err.code, err.message, stdout);
352
+ return ExitCode.ERR_UNKNOWN_TARGET;
353
+ }
354
+ throw err;
355
+ }
356
+ // ── 3. Check that at least one target is available ─────────────────────────
357
+ if (resolvedTargets.length === 0) {
358
+ if (json) {
359
+ stdout(JSON.stringify({ skill, action: uninstall ? 'uninstalled' : 'installed', targets: [], skipped: [] }) + '\n');
360
+ }
361
+ else {
362
+ stdout('No clients detected. Use --target or --all-targets to specify targets.\n');
363
+ }
364
+ return ExitCode.ERR_NO_TARGETS;
365
+ }
366
+ // ── 4. Run install/uninstall ──────────────────────────────────────────────
367
+ const opts = { dryRun, homeDir, version, skillsRoot: deps.skillsRoot };
368
+ let result;
369
+ try {
370
+ result = uninstall
371
+ ? doUninstall(skill, resolvedTargets, opts)
372
+ : doInstall(skill, resolvedTargets, opts);
373
+ }
374
+ catch (err) {
375
+ if (err instanceof SkillNotFoundError) {
376
+ printError(stderr, json, err.code, err.message, stdout);
377
+ return ExitCode.ERR_SKILL_NOT_FOUND;
378
+ }
379
+ const msg = err instanceof Error ? err.message : String(err);
380
+ if (msg.includes('client writers are not yet implemented') ||
381
+ msg.includes('client removers are not yet implemented')) {
382
+ printError(stderr, json, 'writer_not_implemented', msg, stdout);
383
+ return ExitCode.ERR_WRITER_NOT_IMPLEMENTED;
384
+ }
385
+ printError(stderr, json, 'unknown', msg, stdout);
386
+ return ExitCode.ERR_UNKNOWN;
387
+ }
388
+ // ── 5. Update manifest (only when not in dry-run mode) ─────────────────────
389
+ let manifestUpdated = false;
390
+ if (!dryRun) {
391
+ if (uninstall) {
392
+ manifest.removeEntry(skill, resolvedTargets, homeDir);
393
+ }
394
+ else {
395
+ manifest.appendEntry(skill, version, resolvedTargets, homeDir);
396
+ }
397
+ manifestUpdated = true;
398
+ }
399
+ printResult(stdout, result, json, manifestUpdated);
400
+ return ExitCode.SUCCESS;
401
+ }
402
+ // ── Bootstrap ──────────────────────────────────────────────────────────────
403
+ /**
404
+ * Robust main-module detection (matching the pattern used in cli/index.ts).
405
+ * Tests import main() directly and pass MainDeps; this function only gates
406
+ * the direct-execution bootstrap so the CLI binary can call main().
407
+ */
408
+ function isMain() {
409
+ try {
410
+ const argv1 = process.argv[1];
411
+ if (!argv1)
412
+ return false;
413
+ const thisFile = import.meta.url.startsWith('file://')
414
+ ? fileURLToPath(import.meta.url)
415
+ : path.resolve(import.meta.url);
416
+ return path.resolve(argv1) === thisFile;
417
+ }
418
+ catch {
419
+ return false;
420
+ }
421
+ }
422
+ if (isMain()) {
423
+ main().then((code) => process.exit(code));
424
+ }
425
+ //# sourceMappingURL=install-skill.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"install-skill.js","sourceRoot":"","sources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AO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAED,IAAI,MAAM,EAAE,EAAE,CAAC;IACb,IAAI,EAAE,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;AAC5C,CAAC"}
@@ -0,0 +1,18 @@
1
+ export interface PrintTokenDeps {
2
+ /** Home directory (defaults to os.homedir()). */
3
+ homeDir?: string;
4
+ /** Token file path (already expanded). Overrides config discovery. */
5
+ tokenFile?: string;
6
+ /** Environment variable accessor. Defaults to process.env. */
7
+ env?: Record<string, string | undefined>;
8
+ /** Write to stdout. Defaults to process.stdout.write. */
9
+ stdout?: (s: string) => boolean;
10
+ /** Write to stderr. Defaults to process.stderr.write. */
11
+ stderr?: (s: string) => boolean;
12
+ }
13
+ /**
14
+ * Read the bearer token and print it to stdout.
15
+ * Returns 0 on success, 1 on error.
16
+ */
17
+ export declare function printToken(deps?: PrintTokenDeps): number;
18
+ //# sourceMappingURL=print-token.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"print-token.d.ts","sourceRoot":"","sources":["../../src/cli/print-token.ts"],"names":[],"mappings":"AAoBA,MAAM,WAAW,cAAc;IAC7B,iDAAiD;IACjD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,sEAAsE;IACtE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,8DAA8D;IAC9D,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;IACzC,yDAAyD;IACzD,MAAM,CAAC,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC;IAChC,yDAAyD;IACzD,MAAM,CAAC,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC;CACjC;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,IAAI,GAAE,cAAmB,GAAG,MAAM,CAsC5D"}