@michaelhartmayer/agentctl 1.1.0 → 1.1.4
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 +136 -17
- package/dist/ctl.js +175 -228
- package/dist/effects.js +61 -0
- package/dist/fs-utils.js +26 -19
- package/dist/index.js +266 -227
- package/dist/logic/ctl.js +173 -0
- package/dist/logic/index.js +79 -0
- package/dist/logic/install.js +60 -0
- package/dist/logic/manifest.js +8 -0
- package/dist/logic/resolve.js +73 -0
- package/dist/logic/skills.js +20 -0
- package/dist/logic/utils.js +31 -0
- package/dist/manifest.js +17 -1
- package/dist/resolve.js +30 -76
- package/dist/skills.js +11 -23
- package/package.json +1 -1
- package/dist/package.json +0 -60
- package/dist/src/ctl.js +0 -316
- package/dist/src/fs-utils.js +0 -35
- package/dist/src/index.js +0 -351
- package/dist/src/manifest.js +0 -19
- package/dist/src/resolve.js +0 -112
- package/dist/src/skills.js +0 -39
package/dist/effects.js
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.execute = execute;
|
|
7
|
+
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
8
|
+
const skills_1 = require("./skills");
|
|
9
|
+
const child_process_1 = require("child_process");
|
|
10
|
+
const util_1 = __importDefault(require("util"));
|
|
11
|
+
const execFileAsync = util_1.default.promisify(child_process_1.execFile);
|
|
12
|
+
/**
|
|
13
|
+
* THE EXECUTOR: The only part of the app that actually "does" things.
|
|
14
|
+
* It's a simple, dumb loop.
|
|
15
|
+
*/
|
|
16
|
+
async function execute(effects) {
|
|
17
|
+
for (const effect of effects) {
|
|
18
|
+
switch (effect.type) {
|
|
19
|
+
case 'writeFile':
|
|
20
|
+
await fs_extra_1.default.writeFile(effect.path, effect.content);
|
|
21
|
+
break;
|
|
22
|
+
case 'writeJson':
|
|
23
|
+
await fs_extra_1.default.writeJson(effect.path, effect.content, { spaces: 2 });
|
|
24
|
+
break;
|
|
25
|
+
case 'mkdir':
|
|
26
|
+
await fs_extra_1.default.ensureDir(effect.path);
|
|
27
|
+
break;
|
|
28
|
+
case 'chmod':
|
|
29
|
+
await fs_extra_1.default.chmod(effect.path, effect.mode);
|
|
30
|
+
break;
|
|
31
|
+
case 'move':
|
|
32
|
+
await fs_extra_1.default.move(effect.src, effect.dest);
|
|
33
|
+
break;
|
|
34
|
+
case 'copy':
|
|
35
|
+
await fs_extra_1.default.copy(effect.src, effect.dest, effect.options);
|
|
36
|
+
break;
|
|
37
|
+
case 'remove':
|
|
38
|
+
await fs_extra_1.default.remove(effect.path);
|
|
39
|
+
break;
|
|
40
|
+
case 'log':
|
|
41
|
+
console.log(effect.message);
|
|
42
|
+
break;
|
|
43
|
+
case 'installSkill': {
|
|
44
|
+
const p = await (0, skills_1.copySkill)(effect.targetDir, effect.agent);
|
|
45
|
+
console.log(`Installed skill for ${effect.agent} at ${p}`);
|
|
46
|
+
break;
|
|
47
|
+
}
|
|
48
|
+
case 'spawn': {
|
|
49
|
+
const child = (0, child_process_1.spawn)(effect.command, effect.options);
|
|
50
|
+
if (effect.onExit) {
|
|
51
|
+
child.on('exit', effect.onExit);
|
|
52
|
+
}
|
|
53
|
+
break;
|
|
54
|
+
}
|
|
55
|
+
case 'gitClone': {
|
|
56
|
+
await execFileAsync('git', ['clone', '--depth', '1', effect.url, effect.dest]);
|
|
57
|
+
break;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
package/dist/fs-utils.js
CHANGED
|
@@ -1,4 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
2
16
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
17
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
18
|
};
|
|
@@ -6,30 +20,23 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
20
|
exports.getGlobalRoot = getGlobalRoot;
|
|
7
21
|
exports.getAntigravityGlobalRoot = getAntigravityGlobalRoot;
|
|
8
22
|
exports.findLocalRoot = findLocalRoot;
|
|
9
|
-
const path_1 = __importDefault(require("path"));
|
|
10
23
|
const os_1 = __importDefault(require("os"));
|
|
11
24
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
25
|
+
const utils_1 = require("./logic/utils");
|
|
26
|
+
__exportStar(require("./logic/utils"), exports);
|
|
27
|
+
function getRealContext() {
|
|
28
|
+
return {
|
|
29
|
+
platform: process.platform,
|
|
30
|
+
env: process.env,
|
|
31
|
+
homedir: process.env.HOME || process.env.USERPROFILE || os_1.default.homedir()
|
|
32
|
+
};
|
|
33
|
+
}
|
|
12
34
|
function getGlobalRoot() {
|
|
13
|
-
|
|
14
|
-
return path_1.default.join(process.env.APPDATA || path_1.default.join(os_1.default.homedir(), 'AppData', 'Roaming'), 'agentctl');
|
|
15
|
-
}
|
|
16
|
-
return path_1.default.join(os_1.default.homedir(), '.config', 'agentctl');
|
|
35
|
+
return utils_1.UtilsLogic.getGlobalRoot(getRealContext());
|
|
17
36
|
}
|
|
18
37
|
function getAntigravityGlobalRoot() {
|
|
19
|
-
return
|
|
38
|
+
return utils_1.UtilsLogic.getAntigravityGlobalRoot(getRealContext());
|
|
20
39
|
}
|
|
21
40
|
function findLocalRoot(cwd = process.cwd()) {
|
|
22
|
-
|
|
23
|
-
const root = path_1.default.parse(current).root;
|
|
24
|
-
// Safety break and root check
|
|
25
|
-
// Using for(;;) to avoid no-constant-condition
|
|
26
|
-
for (;;) {
|
|
27
|
-
if (fs_extra_1.default.existsSync(path_1.default.join(current, '.agentctl'))) {
|
|
28
|
-
return current;
|
|
29
|
-
}
|
|
30
|
-
if (current === root) {
|
|
31
|
-
return null;
|
|
32
|
-
}
|
|
33
|
-
current = path_1.default.dirname(current);
|
|
34
|
-
}
|
|
41
|
+
return utils_1.UtilsLogic.findLocalRoot(cwd, fs_extra_1.default.existsSync);
|
|
35
42
|
}
|