@michaelhartmayer/agentctl 1.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.
package/dist/index.js ADDED
@@ -0,0 +1,313 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
4
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
5
+ return new (P || (P = Promise))(function (resolve, reject) {
6
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
7
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
8
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
9
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
10
+ });
11
+ };
12
+ var __importDefault = (this && this.__importDefault) || function (mod) {
13
+ return (mod && mod.__esModule) ? mod : { "default": mod };
14
+ };
15
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ const commander_1 = require("commander");
17
+ const path_1 = __importDefault(require("path"));
18
+ require("fs-extra");
19
+ const ctl_1 = require("./ctl");
20
+ const resolve_1 = require("./resolve");
21
+ const child_process_1 = require("child_process");
22
+ const chalk_1 = __importDefault(require("chalk"));
23
+ const program = new commander_1.Command();
24
+ program
25
+ .name('agentctl')
26
+ .description('Agent Controller CLI - Unified control plane for humans and agents')
27
+ .version('1.0.0')
28
+ .allowUnknownOption()
29
+ .helpOption(false) // Disable default help to allow pass-through
30
+ .argument('[command...]', 'Command to run')
31
+ .action((args, _options, _command) => __awaiter(void 0, void 0, void 0, function* () {
32
+ // If no args, check for help flag or just show help
33
+ if (!args || args.length === 0) {
34
+ // If they passed --help or -h, show help. If no args at all, show help.
35
+ // Since we ate options, we check raw args or just treat empty args as help.
36
+ // command.opts() won't have help if we disabled it?
37
+ // Actually, if we disable helpOption, --help becomes an unknown option or arg.
38
+ // Let's check process.argv for -h or --help if args is empty?
39
+ // "agentctl --help" -> args=[], options might contain help if we didn't disable it?
40
+ // With helpOption(false), --help is just a flag in argv.
41
+ // If args is empty and we see help flag, show help.
42
+ if (process.argv.includes('--help') || process.argv.includes('-h') || process.argv.length <= 2) {
43
+ program.help();
44
+ return;
45
+ }
46
+ }
47
+ // If args are present, we try to resolve.
48
+ // BUT, "agentctl --help" will result in args being empty if it's parsed as option?
49
+ // Wait, if helpOption(false), then --help is an unknown option.
50
+ // If allowUnknownOption is true, it might not be in 'args' if it looks like a flag.
51
+ // Let's rely on resolveCommand. passed args are variadic.
52
+ // However, "agentctl dev --help" -> args=["dev", "--help"]?
53
+ // My repro says yes: [ 'dev-tools', 'gh', '--help' ].
54
+ // So for "agentctl --help", args might be ["--help"].
55
+ if (args.length === 1 && (args[0] === '--help' || args[0] === '-h')) {
56
+ program.help();
57
+ return;
58
+ }
59
+ // Bypass for ctl subcommand if it slipped through (shouldn't if registered)
60
+ if (args[0] === 'ctl')
61
+ return;
62
+ try {
63
+ // resolveCommand needs to handle flags in args if they are part of the path?
64
+ // No, flags usually come after. resolveCommand stops at first non-matching path part?
65
+ // resolveCommand logic: iterates args.
66
+ // "dev-tools gh --help" -> path "dev-tools gh", remaining "--help"
67
+ const result = yield (0, resolve_1.resolveCommand)(args);
68
+ if (!result) {
69
+ // If not found, and they asked for help, show root help?
70
+ // Or if they just typed a wrong command.
71
+ if (args.includes('--help') || args.includes('-h')) {
72
+ // Try to show help for the partial command?
73
+ // For now, just show root list/help or error.
74
+ // If it's "agentctl dev --help" and "dev" is a group, resolveCommand SHOULD return the group.
75
+ }
76
+ console.error(chalk_1.default.red(`Command '${args.join(' ')}' not found.`));
77
+ console.log(`Run ${chalk_1.default.cyan('agentctl list')} to see available commands.`);
78
+ process.exit(1);
79
+ }
80
+ const { manifest, args: remainingArgs, scope } = result;
81
+ if (manifest.run) {
82
+ // ... run logic ...
83
+ // remainingArgs should contain --help if it was passed.
84
+ const cmdDir = path_1.default.dirname(result.manifestPath);
85
+ let runCmd = manifest.run;
86
+ // Resolve relative path
87
+ if (runCmd.startsWith('./') || runCmd.startsWith('.\\')) {
88
+ runCmd = path_1.default.resolve(cmdDir, runCmd);
89
+ }
90
+ // Interpolate {{DIR}}
91
+ runCmd = runCmd.replace(/{{DIR}}/g, cmdDir);
92
+ const fullCommand = `${runCmd} ${remainingArgs.join(' ')}`;
93
+ console.log(chalk_1.default.dim(`[${scope}] Running: ${fullCommand}`));
94
+ const child = (0, child_process_1.spawn)(fullCommand, {
95
+ cwd: process.cwd(), // Execute in CWD as discussed
96
+ shell: true,
97
+ stdio: 'inherit',
98
+ env: Object.assign(Object.assign({}, process.env), { AGENTCTL_SCOPE: scope })
99
+ });
100
+ child.on('exit', (code) => {
101
+ process.exit(code || 0);
102
+ });
103
+ }
104
+ else {
105
+ // Group
106
+ console.log(chalk_1.default.blue(chalk_1.default.bold(`${manifest.name}`)));
107
+ console.log(manifest.description || 'No description');
108
+ console.log('\nSubcommands:');
109
+ const all = yield (0, ctl_1.list)();
110
+ const prefix = result.cmdPath + ' ';
111
+ // Filter logic roughly for direct children
112
+ const depth = result.cmdPath.split(' ').length;
113
+ const children = all.filter(c => c.path.startsWith(prefix) && c.path !== result.cmdPath);
114
+ const direct = children.filter(c => c.path.split(' ').length === depth + 1);
115
+ if (direct.length === 0 && children.length === 0) {
116
+ console.log(chalk_1.default.dim(' (No subcommands found)'));
117
+ }
118
+ for (const child of direct) {
119
+ console.log(` ${child.path.split(' ').pop()}\t${chalk_1.default.dim(child.description)}`);
120
+ }
121
+ }
122
+ }
123
+ catch (e) {
124
+ if (e instanceof Error) {
125
+ console.error(chalk_1.default.red(e.message));
126
+ }
127
+ else {
128
+ console.error(chalk_1.default.red('An unknown error occurred'));
129
+ }
130
+ process.exit(1);
131
+ }
132
+ }));
133
+ const ctl = program.command('ctl')
134
+ .description('Agent Controller Management - Create, organizing, and managing commands');
135
+ // --- Lifecycle Commands ---
136
+ // We'll stick to flat list but with good descriptions.
137
+ // Helper for consistent error handling
138
+ // Helper for consistent error handling
139
+ const withErrorHandling = (fn) => {
140
+ return (...args) => __awaiter(void 0, void 0, void 0, function* () {
141
+ try {
142
+ yield fn(...args);
143
+ }
144
+ catch (e) {
145
+ if (e instanceof Error) {
146
+ console.error(chalk_1.default.red(e.message));
147
+ }
148
+ else {
149
+ console.error(chalk_1.default.red(String(e)));
150
+ }
151
+ process.exit(1);
152
+ }
153
+ });
154
+ };
155
+ ctl.command('scaffold')
156
+ .description('Create a new capped command with a script file')
157
+ .argument('<path...>', 'Command path segments (e.g., "dev start")')
158
+ .addHelpText('after', `
159
+ Examples:
160
+ $ agentctl ctl scaffold dev start
161
+ $ agentctl ctl scaffold sys backup
162
+ `)
163
+ .action(withErrorHandling((pathParts) => __awaiter(void 0, void 0, void 0, function* () {
164
+ yield (0, ctl_1.scaffold)(pathParts);
165
+ })));
166
+ ctl.command('alias')
167
+ .description('Create a new capped command that runs an inline shell command')
168
+ .argument('<args...>', 'Name parts followed by target (e.g., "tools" "gh" "gh")')
169
+ .action(withErrorHandling((args) => __awaiter(void 0, void 0, void 0, function* () {
170
+ if (args.length < 2) {
171
+ console.error('Usage: ctl alias <name...> <target>');
172
+ process.exit(1);
173
+ }
174
+ const target = args.pop();
175
+ const name = args;
176
+ yield (0, ctl_1.alias)(name, target);
177
+ })))
178
+ .addHelpText('after', `
179
+ Examples:
180
+ $ agentctl ctl alias tools gh "gh"
181
+ $ agentctl ctl alias dev build "npm run build"
182
+ `);
183
+ ctl.command('group')
184
+ .description('Create a new command group (namespace)')
185
+ .argument('<path...>', 'Group path (e.g., "dev")')
186
+ .addHelpText('after', `
187
+ Examples:
188
+ $ agentctl ctl group dev
189
+ $ agentctl ctl group tools
190
+ `)
191
+ .action(withErrorHandling((parts) => __awaiter(void 0, void 0, void 0, function* () {
192
+ yield (0, ctl_1.group)(parts);
193
+ })));
194
+ ctl.command('rm')
195
+ .description('Remove a command or group permanently')
196
+ .argument('<path...>', 'Command path to remove')
197
+ .option('--global', 'Remove from global scope')
198
+ .addHelpText('after', `
199
+ Examples:
200
+ $ agentctl ctl rm dev start
201
+ $ agentctl ctl rm tools --global
202
+ `)
203
+ .action(withErrorHandling((parts, opts) => __awaiter(void 0, void 0, void 0, function* () {
204
+ yield (0, ctl_1.rm)(parts, { global: opts.global });
205
+ })));
206
+ ctl.command('mv')
207
+ .description('Move a command or group to a new path')
208
+ .argument('<src>', 'Source path (quoted string or single token)')
209
+ .argument('<dest>', 'Destination path')
210
+ .option('--global', 'Move command in global scope')
211
+ .addHelpText('after', `
212
+ Examples:
213
+ $ agentctl ctl mv "dev start" "dev boot"
214
+ $ agentctl ctl mv tools/gh tools/github --global
215
+ `)
216
+ .action(withErrorHandling((src, dest, opts) => __awaiter(void 0, void 0, void 0, function* () {
217
+ yield (0, ctl_1.mv)(src.split(' '), dest.split(' '), { global: opts.global });
218
+ })));
219
+ // --- Introspection ---
220
+ ctl.command('list')
221
+ .description('List all available commands across local and global scopes')
222
+ .action(withErrorHandling(() => __awaiter(void 0, void 0, void 0, function* () {
223
+ const items = yield (0, ctl_1.list)();
224
+ console.log('TYPE SCOPE COMMAND DESCRIPTION');
225
+ for (const item of items) {
226
+ console.log(`${item.type.padEnd(9)} ${item.scope.padEnd(9)} ${item.path.padEnd(19)} ${item.description}`);
227
+ }
228
+ })));
229
+ ctl.command('inspect')
230
+ .description('Inspect the internal manifest and details of a command')
231
+ .argument('<path...>', 'Command path to inspect')
232
+ .action(withErrorHandling((parts) => __awaiter(void 0, void 0, void 0, function* () {
233
+ const info = yield (0, ctl_1.inspect)(parts);
234
+ if (info) {
235
+ console.log(JSON.stringify(info, null, 2));
236
+ }
237
+ else {
238
+ console.error('Command not found');
239
+ process.exit(1);
240
+ }
241
+ })));
242
+ // --- Scoping ---
243
+ ctl.command('global')
244
+ .description('Push a local command to the global scope')
245
+ .argument('<path...>', 'Local command path')
246
+ .option('--move', 'Move instead of copy')
247
+ .option('--copy', 'Copy (default)')
248
+ .addHelpText('after', `
249
+ Examples:
250
+ $ agentctl ctl global sys --move
251
+ $ agentctl ctl global tools --copy
252
+ `)
253
+ .action(withErrorHandling((parts, opts) => __awaiter(void 0, void 0, void 0, function* () {
254
+ yield (0, ctl_1.pushGlobal)(parts, { move: opts.move, copy: opts.copy || !opts.move });
255
+ })));
256
+ ctl.command('local')
257
+ .description('Pull a global command to the local scope')
258
+ .argument('<path...>', 'Global command path')
259
+ .option('--move', 'Move instead of copy')
260
+ .option('--copy', 'Copy (default)')
261
+ .addHelpText('after', `
262
+ Examples:
263
+ $ agentctl ctl local tools --copy
264
+ `)
265
+ .action(withErrorHandling((parts, opts) => __awaiter(void 0, void 0, void 0, function* () {
266
+ yield (0, ctl_1.pullLocal)(parts, { move: opts.move, copy: opts.copy || !opts.move });
267
+ })));
268
+ // --- Agent Integration ---
269
+ // We attach this to the root `ctl` as options or a sub-command?
270
+ // Original code had it as options on `ctl`. We can make it a command for better help.
271
+ // But sticking to options maintains compatibility. We'll improve the option help.
272
+ ctl.option('--install-skill <agent>', 'Install skill for agent (cursor, antigravity, agentsmd, gemini)')
273
+ .option('--global', 'Install skill globally (for supported agents)')
274
+ .addHelpText('after', `
275
+ Examples:
276
+ $ agentctl ctl --install-skill cursor
277
+ $ agentctl ctl --install-skill antigravity --global
278
+ $ agentctl ctl --install-skill gemini
279
+ `)
280
+ .action(withErrorHandling((op, command) => __awaiter(void 0, void 0, void 0, function* () {
281
+ const opts = ctl.opts();
282
+ if (opts.installSkill) {
283
+ yield (0, ctl_1.installSkill)(opts.installSkill, { global: opts.global });
284
+ }
285
+ else {
286
+ // If no subcmd and no option, show help
287
+ if (command.args.length === 0) {
288
+ ctl.help();
289
+ }
290
+ }
291
+ })));
292
+ // Inject dynamic commands into root help
293
+ // We need to do this before parsing
294
+ (() => __awaiter(void 0, void 0, void 0, function* () {
295
+ try {
296
+ const allCommands = yield (0, ctl_1.list)();
297
+ const topLevel = allCommands.filter(c => !c.path.includes(' ')); // Only top level
298
+ if (topLevel.length > 0) {
299
+ const lines = [''];
300
+ lines.push('User Commands:');
301
+ for (const cmd of topLevel) {
302
+ // simple padding
303
+ lines.push(` ${cmd.path.padEnd(27)}${cmd.description}`);
304
+ }
305
+ lines.push('');
306
+ program.addHelpText('after', lines.join('\n'));
307
+ }
308
+ }
309
+ catch (_a) {
310
+ // Ignore errors during help generation (e.g. if not initialized)
311
+ }
312
+ program.parse(process.argv);
313
+ }))();
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.readManifest = readManifest;
16
+ exports.isCappedManifest = isCappedManifest;
17
+ const fs_extra_1 = __importDefault(require("fs-extra"));
18
+ function readManifest(p) {
19
+ return __awaiter(this, void 0, void 0, function* () {
20
+ try {
21
+ return yield fs_extra_1.default.readJson(p);
22
+ }
23
+ catch (_a) {
24
+ return null;
25
+ }
26
+ });
27
+ }
28
+ function isCappedManifest(m) {
29
+ return !!m.run || m.type === 'scaffold' || m.type === 'alias';
30
+ }
@@ -0,0 +1,123 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.resolveCommand = resolveCommand;
16
+ const path_1 = __importDefault(require("path"));
17
+ const fs_extra_1 = __importDefault(require("fs-extra"));
18
+ const fs_utils_1 = require("./fs-utils");
19
+ const manifest_1 = require("./manifest");
20
+ function resolveCommand(args_1) {
21
+ return __awaiter(this, arguments, void 0, function* (args, options = {}) {
22
+ const cwd = options.cwd || process.cwd();
23
+ const localRoot = !options.global ? (0, fs_utils_1.findLocalRoot)(cwd) : null;
24
+ const globalRoot = options.globalDir || (0, fs_utils_1.getGlobalRoot)();
25
+ const localAgentctl = localRoot ? path_1.default.join(localRoot, '.agentctl') : null;
26
+ let currentMatch = null;
27
+ // Iterate through args to find longest match
28
+ for (let i = 0; i < args.length; i++) {
29
+ // Path corresponding to args[0..i]
30
+ const currentArgs = args.slice(0, i + 1);
31
+ const relPath = currentArgs.join(path_1.default.sep);
32
+ const cmdPath = currentArgs.join(' ');
33
+ const localPath = localAgentctl ? path_1.default.join(localAgentctl, relPath) : null;
34
+ const globalPath = path_1.default.join(globalRoot, relPath);
35
+ let localManifest = null;
36
+ let globalManifest = null;
37
+ // check local
38
+ if (localPath && (yield fs_extra_1.default.pathExists(localPath))) {
39
+ const mPath = path_1.default.join(localPath, 'manifest.json');
40
+ if (yield fs_extra_1.default.pathExists(mPath)) {
41
+ localManifest = yield (0, manifest_1.readManifest)(mPath);
42
+ }
43
+ if (!localManifest && (yield fs_extra_1.default.stat(localPath)).isDirectory()) {
44
+ // Implicit group
45
+ localManifest = { name: args[i], type: 'group' };
46
+ }
47
+ }
48
+ // check global
49
+ if (yield fs_extra_1.default.pathExists(globalPath)) {
50
+ const mPath = path_1.default.join(globalPath, 'manifest.json');
51
+ if (yield fs_extra_1.default.pathExists(mPath)) {
52
+ globalManifest = yield (0, manifest_1.readManifest)(mPath);
53
+ }
54
+ if (!globalManifest && (yield fs_extra_1.default.stat(globalPath)).isDirectory()) {
55
+ globalManifest = { name: args[i], type: 'group' };
56
+ }
57
+ }
58
+ if (!localManifest && !globalManifest) {
59
+ break;
60
+ }
61
+ const remainingArgs = args.slice(i + 1);
62
+ // Priority logic
63
+ // 1. Local Capped -> Return Match immediately.
64
+ if (localManifest && (0, manifest_1.isCappedManifest)(localManifest)) {
65
+ return {
66
+ manifest: localManifest,
67
+ manifestPath: path_1.default.join(localPath, 'manifest.json'),
68
+ args: remainingArgs,
69
+ scope: 'local',
70
+ cmdPath
71
+ };
72
+ }
73
+ // 2. Global Capped
74
+ if (globalManifest && (0, manifest_1.isCappedManifest)(globalManifest)) {
75
+ // Check if shadowed by Local Group
76
+ if (localManifest) {
77
+ // Local exists (must be group since checked capped above).
78
+ // Shadowed. Treat as Local Group.
79
+ currentMatch = {
80
+ manifest: localManifest,
81
+ manifestPath: path_1.default.join(localPath, 'manifest.json'),
82
+ args: remainingArgs,
83
+ scope: 'local',
84
+ cmdPath
85
+ };
86
+ }
87
+ else {
88
+ // Not shadowed. Global Capped wins. Return immediately.
89
+ return {
90
+ manifest: globalManifest,
91
+ manifestPath: path_1.default.join(globalPath, 'manifest.json'),
92
+ args: remainingArgs,
93
+ scope: 'global',
94
+ cmdPath
95
+ };
96
+ }
97
+ }
98
+ else {
99
+ // Neither is capped. Both are groups (or one is).
100
+ // Local wins if exists.
101
+ if (localManifest) {
102
+ currentMatch = {
103
+ manifest: localManifest,
104
+ manifestPath: path_1.default.join(localPath, 'manifest.json'),
105
+ args: remainingArgs,
106
+ scope: 'local',
107
+ cmdPath
108
+ };
109
+ }
110
+ else {
111
+ currentMatch = {
112
+ manifest: globalManifest,
113
+ manifestPath: path_1.default.join(globalPath, 'manifest.json'),
114
+ args: remainingArgs,
115
+ scope: 'global',
116
+ cmdPath
117
+ };
118
+ }
119
+ }
120
+ }
121
+ return currentMatch;
122
+ });
123
+ }
package/dist/skills.js ADDED
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.SUPPORTED_AGENTS = void 0;
16
+ exports.copySkill = copySkill;
17
+ const path_1 = __importDefault(require("path"));
18
+ const fs_extra_1 = __importDefault(require("fs-extra"));
19
+ exports.SUPPORTED_AGENTS = ['cursor', 'antigravity', 'agentsmd', 'gemini'];
20
+ function copySkill(targetDir, agent) {
21
+ return __awaiter(this, void 0, void 0, function* () {
22
+ // We assume the skill file is located at ../skills/agentctl/SKILL.md relative to specific dist/src/ location
23
+ // Or we find it in the project root if running from source.
24
+ // In production (dist), structure might be:
25
+ // dist/index.js
26
+ // skills/agentctl/SKILL.md (if we copy it to dist)
27
+ // Let's try to locate the source SKILL.md
28
+ // If we are in /src, it is in ../skills/agentctl/SKILL.md
29
+ // If we are in /dist/src (tsc default?), it depends on build.
30
+ // Robust finding:
31
+ let sourcePath = path_1.default.resolve(__dirname, '../../skills/agentctl/SKILL.md');
32
+ if (!fs_extra_1.default.existsSync(sourcePath)) {
33
+ // Try looking in src check (dev mode)
34
+ sourcePath = path_1.default.resolve(__dirname, '../skills/agentctl/SKILL.md');
35
+ }
36
+ if (!fs_extra_1.default.existsSync(sourcePath)) {
37
+ // Fallback for when running from dist/src
38
+ sourcePath = path_1.default.resolve(__dirname, '../../../skills/agentctl/SKILL.md');
39
+ }
40
+ if (!fs_extra_1.default.existsSync(sourcePath)) {
41
+ throw new Error(`Could not locate source SKILL.md. Checked: ${path_1.default.resolve(__dirname, '../../skills/agentctl/SKILL.md')}`);
42
+ }
43
+ yield fs_extra_1.default.ensureDir(targetDir);
44
+ // Determine filename
45
+ const filename = agent === 'cursor' ? 'agentctl.md' : 'SKILL.md';
46
+ const targetFile = path_1.default.join(targetDir, filename);
47
+ yield fs_extra_1.default.copy(sourcePath, targetFile, { overwrite: true });
48
+ return targetFile;
49
+ });
50
+ }
package/package.json ADDED
@@ -0,0 +1,49 @@
1
+ {
2
+ "name": "@michaelhartmayer/agentctl",
3
+ "publishConfig": {
4
+ "access": "public"
5
+ },
6
+ "description": "Agent Controller - A unified interface for humans and AI agents",
7
+ "version": "1.0.0",
8
+ "main": "dist/index.js",
9
+ "bin": {
10
+ "agentctl": "./dist/index.js"
11
+ },
12
+ "scripts": {
13
+ "build": "tsc",
14
+ "test": "vitest run",
15
+ "test:watch": "vitest",
16
+ "lint": "eslint src tests",
17
+ "register:path": "node scripts/register-path.js",
18
+ "unregister:path": "node scripts/unregister-path.js",
19
+ "prepublishOnly": "npm run build && npm run test",
20
+ "prepare": "husky"
21
+ },
22
+ "keywords": [
23
+ "cli",
24
+ "agent",
25
+ "ai",
26
+ "automation",
27
+ "framework"
28
+ ],
29
+ "author": "Michael Hartmayer",
30
+ "license": "MIT",
31
+ "dependencies": {
32
+ "chalk": "^4.1.2",
33
+ "commander": "^14.0.3",
34
+ "fs-extra": "^11.3.3"
35
+ },
36
+ "devDependencies": {
37
+ "@types/fs-extra": "^11.0.4",
38
+ "@types/node": "^25.2.3",
39
+ "@typescript-eslint/eslint-plugin": "^8.55.0",
40
+ "@typescript-eslint/parser": "^8.55.0",
41
+ "@vitest/coverage-v8": "^4.0.18",
42
+ "eslint": "^8.57.1",
43
+ "eslint-plugin-eslint-comments": "^3.2.0",
44
+ "husky": "^9.1.7",
45
+ "ts-node": "^10.9.2",
46
+ "typescript": "^5.9.3",
47
+ "vitest": "^4.0.18"
48
+ }
49
+ }
@@ -0,0 +1,32 @@
1
+ const { execSync } = require('child_process');
2
+ const path = require('path');
3
+ const fs = require('fs');
4
+
5
+ const binDir = path.resolve(__dirname, '..');
6
+
7
+ // Create wrapper scripts for direct execution
8
+ const cmdContent = `@echo off\r\nnode "%~dp0\\dist\\index.js" %*`;
9
+ fs.writeFileSync(path.join(binDir, 'agentctl.cmd'), cmdContent);
10
+
11
+ if (process.platform === 'win32') {
12
+ try {
13
+ const currentPath = execSync('powershell -Command "[Environment]::GetEnvironmentVariable(\'Path\', \'User\')"').toString().trim();
14
+ if (!currentPath.includes(binDir)) {
15
+ const newPath = currentPath + (currentPath.endsWith(';') ? '' : ';') + binDir;
16
+ // Use setx for persistence but beware truncation. Powershell is safer for full string.
17
+ // But setx /M needs admin. User path doesn't.
18
+ // Powershell approach:
19
+ const psCommand = `[Environment]::SetEnvironmentVariable('Path', '${newPath}', 'User')`;
20
+ execSync(`powershell -Command "${psCommand}"`);
21
+ console.log(`Successfully added ${binDir} to User PATH.`);
22
+ console.log('You may need to restart your terminal/shell for changes to take effect.');
23
+ } else {
24
+ console.log(`${binDir} is already in User PATH.`);
25
+ }
26
+ } catch (error) {
27
+ console.error('Failed to register path:', error.message);
28
+ process.exit(1);
29
+ }
30
+ } else {
31
+ console.log('Path registration script currently supports Windows only.');
32
+ }
@@ -0,0 +1,30 @@
1
+ const { execSync } = require('child_process');
2
+ const path = require('path');
3
+ const fs = require('fs');
4
+
5
+ const binDir = path.resolve(__dirname, '..');
6
+
7
+ if (process.platform === 'win32') {
8
+ try {
9
+ const currentPath = execSync('powershell -Command "[Environment]::GetEnvironmentVariable(\'Path\', \'User\')"').toString().trim();
10
+ if (currentPath.includes(binDir)) {
11
+ // split by ; to safely remove exactly our path
12
+ const paths = currentPath.split(';').filter(p => p && path.resolve(p) !== binDir);
13
+ const newPath = paths.join(';');
14
+
15
+ const psCommand = `[Environment]::SetEnvironmentVariable('Path', '${newPath}', 'User')`;
16
+ execSync(`powershell -Command "${psCommand}"`);
17
+ console.log(`Successfully removed ${binDir} from User PATH.`);
18
+ } else {
19
+ console.log(`${binDir} is not in User PATH.`);
20
+ }
21
+ } catch (error) {
22
+ console.error('Failed to unregister path:', error.message);
23
+ process.exit(1);
24
+ }
25
+ }
26
+
27
+ // Clean up wrapper
28
+ if (fs.existsSync(path.join(binDir, 'agentctl.cmd'))) {
29
+ fs.unlinkSync(path.join(binDir, 'agentctl.cmd'));
30
+ }