@orchagent/cli 0.2.17 → 0.2.18
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/commands/index.js +2 -0
- package/dist/commands/info.js +2 -12
- package/dist/commands/tree.js +81 -0
- package/dist/lib/agent-ref.js +13 -0
- package/package.json +1 -1
package/dist/commands/index.js
CHANGED
|
@@ -19,6 +19,7 @@ const github_1 = require("./github");
|
|
|
19
19
|
const doctor_1 = require("./doctor");
|
|
20
20
|
const status_1 = require("./status");
|
|
21
21
|
const workspace_1 = require("./workspace");
|
|
22
|
+
const tree_1 = require("./tree");
|
|
22
23
|
function registerCommands(program) {
|
|
23
24
|
(0, login_1.registerLoginCommand)(program);
|
|
24
25
|
(0, whoami_1.registerWhoamiCommand)(program);
|
|
@@ -38,4 +39,5 @@ function registerCommands(program) {
|
|
|
38
39
|
(0, doctor_1.registerDoctorCommand)(program);
|
|
39
40
|
(0, status_1.registerStatusCommand)(program);
|
|
40
41
|
(0, workspace_1.registerWorkspaceCommand)(program);
|
|
42
|
+
(0, tree_1.registerTreeCommand)(program);
|
|
41
43
|
}
|
package/dist/commands/info.js
CHANGED
|
@@ -3,17 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.registerInfoCommand = registerInfoCommand;
|
|
4
4
|
const config_1 = require("../lib/config");
|
|
5
5
|
const api_1 = require("../lib/api");
|
|
6
|
-
const
|
|
7
|
-
const DEFAULT_VERSION = 'latest';
|
|
8
|
-
function parseAgentRef(value) {
|
|
9
|
-
const [ref, versionPart] = value.split('@');
|
|
10
|
-
const version = versionPart?.trim() || DEFAULT_VERSION;
|
|
11
|
-
const segments = ref.split('/');
|
|
12
|
-
if (segments.length === 2) {
|
|
13
|
-
return { org: segments[0], agent: segments[1], version };
|
|
14
|
-
}
|
|
15
|
-
throw new errors_1.CliError('Invalid agent reference. Use org/agent format (e.g., joe/leak-finder)');
|
|
16
|
-
}
|
|
6
|
+
const agent_ref_1 = require("../lib/agent-ref");
|
|
17
7
|
function formatSchema(schema, indent = ' ') {
|
|
18
8
|
const lines = [];
|
|
19
9
|
const props = schema.properties || {};
|
|
@@ -112,7 +102,7 @@ function registerInfoCommand(program) {
|
|
|
112
102
|
.option('--json', 'Output as JSON')
|
|
113
103
|
.action(async (agentArg, options) => {
|
|
114
104
|
const config = await (0, config_1.getResolvedConfig)();
|
|
115
|
-
const { org, agent, version } = parseAgentRef(agentArg);
|
|
105
|
+
const { org, agent, version } = (0, agent_ref_1.parseAgentRef)(agentArg);
|
|
116
106
|
// Fetch agent metadata
|
|
117
107
|
const agentData = await downloadAgentWithFallback(config, org, agent, version);
|
|
118
108
|
if (options.json) {
|
|
@@ -0,0 +1,81 @@
|
|
|
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.registerTreeCommand = registerTreeCommand;
|
|
7
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
8
|
+
const config_1 = require("../lib/config");
|
|
9
|
+
const api_1 = require("../lib/api");
|
|
10
|
+
const agent_ref_1 = require("../lib/agent-ref");
|
|
11
|
+
const errors_1 = require("../lib/errors");
|
|
12
|
+
function registerTreeCommand(program) {
|
|
13
|
+
program
|
|
14
|
+
.command('tree <agent>')
|
|
15
|
+
.description('Show dependency tree for an agent')
|
|
16
|
+
.option('--json', 'Output as JSON')
|
|
17
|
+
.option('--no-color', 'Disable colored output')
|
|
18
|
+
.action(async (agentArg, options) => {
|
|
19
|
+
const config = await (0, config_1.getResolvedConfig)();
|
|
20
|
+
if (!config.apiKey) {
|
|
21
|
+
throw new errors_1.CliError('Authentication required. Run: orch login');
|
|
22
|
+
}
|
|
23
|
+
const { org, agent, version } = (0, agent_ref_1.parseAgentRef)(agentArg);
|
|
24
|
+
const tree = await (0, api_1.request)(config, 'GET', `/agents/${org}/${agent}/${version}/tree`);
|
|
25
|
+
if (options.json) {
|
|
26
|
+
console.log(JSON.stringify(tree, null, 2));
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
const useColor = options.color !== false;
|
|
30
|
+
console.log();
|
|
31
|
+
console.log(formatTree(tree, useColor));
|
|
32
|
+
console.log();
|
|
33
|
+
console.log(`Summary: ${tree.summary.total_agents} agents, ` +
|
|
34
|
+
`${tree.summary.total_skills} skills, ` +
|
|
35
|
+
`max depth ${tree.summary.max_depth}`);
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
function formatTree(tree, useColor) {
|
|
39
|
+
const lines = [];
|
|
40
|
+
const rootNode = {
|
|
41
|
+
agent: tree.agent,
|
|
42
|
+
accessible: true,
|
|
43
|
+
type: tree.type,
|
|
44
|
+
skills: tree.skills,
|
|
45
|
+
skills_locked: tree.skills_locked,
|
|
46
|
+
dependencies: tree.dependencies,
|
|
47
|
+
};
|
|
48
|
+
formatNode(rootNode, '', true, true, lines, useColor);
|
|
49
|
+
return lines.join('\n');
|
|
50
|
+
}
|
|
51
|
+
function formatNode(node, prefix, isLast, isRoot, lines, useColor) {
|
|
52
|
+
const connector = isRoot ? '' : isLast ? '└── ' : '├── ';
|
|
53
|
+
const childPrefix = isRoot ? '' : prefix + (isLast ? ' ' : '│ ');
|
|
54
|
+
// Format agent line
|
|
55
|
+
let agentStr = node.agent;
|
|
56
|
+
if (!node.accessible) {
|
|
57
|
+
agentStr = useColor ? chalk_1.default.dim(agentStr) : `(${agentStr})`;
|
|
58
|
+
}
|
|
59
|
+
if (node.skills_locked && useColor) {
|
|
60
|
+
agentStr = agentStr + chalk_1.default.yellow(' 🔒');
|
|
61
|
+
}
|
|
62
|
+
lines.push(prefix + connector + agentStr);
|
|
63
|
+
// Format skills
|
|
64
|
+
const allChildren = [
|
|
65
|
+
...node.skills.map(s => ({ type: 'skill', value: s })),
|
|
66
|
+
...node.dependencies.map(d => ({ type: 'dep', value: d })),
|
|
67
|
+
];
|
|
68
|
+
allChildren.forEach((child, idx) => {
|
|
69
|
+
const isLastChild = idx === allChildren.length - 1;
|
|
70
|
+
const childConnector = isLastChild ? '└── ' : '├── ';
|
|
71
|
+
if (child.type === 'skill') {
|
|
72
|
+
const skillStr = useColor
|
|
73
|
+
? chalk_1.default.magenta(child.value) + chalk_1.default.dim(' (skill)')
|
|
74
|
+
: `${child.value} (skill)`;
|
|
75
|
+
lines.push(childPrefix + childConnector + skillStr);
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
formatNode(child.value, childPrefix, isLastChild, false, lines, useColor);
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseAgentRef = parseAgentRef;
|
|
4
|
+
const errors_1 = require("./errors");
|
|
5
|
+
function parseAgentRef(value, defaultVersion = 'latest') {
|
|
6
|
+
const [ref, versionPart] = value.split('@');
|
|
7
|
+
const version = versionPart?.trim() || defaultVersion;
|
|
8
|
+
const segments = ref.split('/');
|
|
9
|
+
if (segments.length === 2) {
|
|
10
|
+
return { org: segments[0], agent: segments[1], version };
|
|
11
|
+
}
|
|
12
|
+
throw new errors_1.CliError('Invalid agent reference. Use org/agent[@version] format');
|
|
13
|
+
}
|