devfactory 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.d.ts +1 -0
- package/dist/index.js +209 -0
- package/package.json +44 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
18
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
19
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
20
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
21
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
22
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
23
|
+
mod
|
|
24
|
+
));
|
|
25
|
+
|
|
26
|
+
// src/index.ts
|
|
27
|
+
var import_commander = require("commander");
|
|
28
|
+
var import_fs = __toESM(require("fs"));
|
|
29
|
+
var import_path = __toESM(require("path"));
|
|
30
|
+
var import_os = __toESM(require("os"));
|
|
31
|
+
var import_adm_zip = __toESM(require("adm-zip"));
|
|
32
|
+
var import_node_fetch = __toESM(require("node-fetch"));
|
|
33
|
+
var import_chalk = __toESM(require("chalk"));
|
|
34
|
+
var import_ora = __toESM(require("ora"));
|
|
35
|
+
var program = new import_commander.Command();
|
|
36
|
+
var CONFIG_DIR = import_path.default.join(import_os.default.homedir(), ".devfactory");
|
|
37
|
+
var CONFIG_FILE = import_path.default.join(CONFIG_DIR, "config.json");
|
|
38
|
+
var API_URL = process.env.DEVFACTORY_API_URL || "http://localhost:8787/registry";
|
|
39
|
+
var LOGO = `
|
|
40
|
+
${import_chalk.default.bold.blue("\u{1F680} DEVFACTORY CLI")} ${import_chalk.default.dim("v1.0.0")}
|
|
41
|
+
${import_chalk.default.blue("\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500")}
|
|
42
|
+
`;
|
|
43
|
+
function getConfig() {
|
|
44
|
+
if (import_fs.default.existsSync(CONFIG_FILE)) {
|
|
45
|
+
try {
|
|
46
|
+
return JSON.parse(import_fs.default.readFileSync(CONFIG_FILE, "utf-8"));
|
|
47
|
+
} catch (e) {
|
|
48
|
+
return {};
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return {};
|
|
52
|
+
}
|
|
53
|
+
function saveConfig(config) {
|
|
54
|
+
if (!import_fs.default.existsSync(CONFIG_DIR)) {
|
|
55
|
+
import_fs.default.mkdirSync(CONFIG_DIR, { recursive: true });
|
|
56
|
+
}
|
|
57
|
+
import_fs.default.writeFileSync(CONFIG_FILE, JSON.stringify(config, null, 2));
|
|
58
|
+
}
|
|
59
|
+
function getHeaders() {
|
|
60
|
+
const config = getConfig();
|
|
61
|
+
const headers = {
|
|
62
|
+
"User-Agent": "devfactory-cli/1.0.0"
|
|
63
|
+
};
|
|
64
|
+
if (config.apiKey) {
|
|
65
|
+
headers["Authorization"] = `Bearer ${config.apiKey}`;
|
|
66
|
+
}
|
|
67
|
+
return headers;
|
|
68
|
+
}
|
|
69
|
+
program.name("devfactory").description("Le compagnon CLI pour vos agents Genius").version("1.0.0");
|
|
70
|
+
program.command("login").description("Connectez-vous \xE0 votre compte DevFactory").argument("<key>", "Votre cl\xE9 d'API Genius (gns_...)").action(async (key) => {
|
|
71
|
+
console.log(LOGO);
|
|
72
|
+
const spinner = (0, import_ora.default)("V\xE9rification de la cl\xE9...").start();
|
|
73
|
+
const config = getConfig();
|
|
74
|
+
config.apiKey = key;
|
|
75
|
+
saveConfig(config);
|
|
76
|
+
spinner.succeed(import_chalk.default.green.bold("\u2713 Connexion r\xE9ussie !"));
|
|
77
|
+
console.log(`
|
|
78
|
+
${import_chalk.default.dim("Cl\xE9 sauvegard\xE9e :")} ${import_chalk.default.blue(CONFIG_FILE)}`);
|
|
79
|
+
console.log(` ${import_chalk.default.dim("Vous pouvez maintenant installer des agents priv\xE9s.")}
|
|
80
|
+
`);
|
|
81
|
+
});
|
|
82
|
+
program.command("search").description("Recherchez des agents sur la marketplace").argument("[query]", "Terme de recherche", "").action(async (query) => {
|
|
83
|
+
console.log(LOGO);
|
|
84
|
+
const spinner = (0, import_ora.default)(query ? `Recherche pour "${query}"...` : "Chargement des agents...").start();
|
|
85
|
+
try {
|
|
86
|
+
const res = await (0, import_node_fetch.default)(`${API_URL}/search?q=${encodeURIComponent(query)}`, { headers: getHeaders() });
|
|
87
|
+
if (!res.ok) throw new Error(`Erreur API : ${res.status}`);
|
|
88
|
+
const { agents } = await res.json();
|
|
89
|
+
spinner.stop();
|
|
90
|
+
if (agents.length === 0) {
|
|
91
|
+
console.log(import_chalk.default.yellow(" Aucun agent trouv\xE9. Essayez un autre mot-cl\xE9 !"));
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
console.log(import_chalk.default.bold(` ${agents.length} agent(s) trouv\xE9(s) :
|
|
95
|
+
`));
|
|
96
|
+
agents.forEach((a) => {
|
|
97
|
+
const visibility = a.visibility === "protected" ? import_chalk.default.yellow(" [Auth required]") : "";
|
|
98
|
+
console.log(` ${import_chalk.default.blue.bold("\u25C6 " + a.slug)} ${visibility}`);
|
|
99
|
+
console.log(` ${import_chalk.default.dim(a.description || "Aucune description")}`);
|
|
100
|
+
console.log(` ${import_chalk.default.magenta("\u2B07 " + a.downloads)} ${import_chalk.default.yellow("\u2B50 " + a.stars)}
|
|
101
|
+
`);
|
|
102
|
+
});
|
|
103
|
+
console.log(import_chalk.default.dim(" Utilisez 'devfactory add <slug>' pour installer un agent."));
|
|
104
|
+
} catch (error) {
|
|
105
|
+
spinner.fail(import_chalk.default.red(`Erreur de recherche : ${error.message}`));
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
program.command("add").description("Installez un agent Genius localement").argument("<slug>", "Slug de l'agent \xE0 installer").action(async (slug) => {
|
|
109
|
+
console.log(LOGO);
|
|
110
|
+
const spinner = (0, import_ora.default)(`Pr\xE9paration de l'installation de ${import_chalk.default.bold(slug)}...`).start();
|
|
111
|
+
try {
|
|
112
|
+
const headers = getHeaders();
|
|
113
|
+
spinner.text = `T\xE9l\xE9chargement du bundle ${import_chalk.default.bold(slug)}...`;
|
|
114
|
+
const res = await (0, import_node_fetch.default)(`${API_URL}/agents/${slug}/download`, { headers });
|
|
115
|
+
if (!res.ok) {
|
|
116
|
+
if (res.status === 401 || res.status === 403) {
|
|
117
|
+
spinner.fail(import_chalk.default.red.bold("Acc\xE8s refus\xE9 !"));
|
|
118
|
+
console.log(`
|
|
119
|
+
${import_chalk.default.yellow("\u26A0 Cet agent n\xE9cessite une authentification.")}`);
|
|
120
|
+
console.log(` ${import_chalk.default.dim("Lancez")} ${import_chalk.default.bold("devfactory login <votre_cl\xE9>")} ${import_chalk.default.dim("pour continuer.")}
|
|
121
|
+
`);
|
|
122
|
+
} else if (res.status === 404) {
|
|
123
|
+
spinner.fail(import_chalk.default.red(`Agent "${slug}" introuvable.`));
|
|
124
|
+
} else {
|
|
125
|
+
spinner.fail(import_chalk.default.red(`Erreur ${res.status} lors du t\xE9l\xE9chargement.`));
|
|
126
|
+
}
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
const buffer = await res.buffer();
|
|
130
|
+
spinner.text = "Configuration du projet...";
|
|
131
|
+
const targetDir = import_path.default.join(process.cwd(), ".claude");
|
|
132
|
+
if (!import_fs.default.existsSync(targetDir)) {
|
|
133
|
+
import_fs.default.mkdirSync(targetDir, { recursive: true });
|
|
134
|
+
}
|
|
135
|
+
spinner.text = "Extraction des fichiers...";
|
|
136
|
+
const zip = new import_adm_zip.default(buffer);
|
|
137
|
+
zip.extractAllTo(targetDir, true);
|
|
138
|
+
spinner.succeed(import_chalk.default.green.bold(`\u2713 Agent "${slug}" install\xE9 avec succ\xE8s !`));
|
|
139
|
+
console.log(`
|
|
140
|
+
${import_chalk.default.dim("Emplacement :")} ${import_chalk.default.blue(import_path.default.join(targetDir, "agent.md"))}`);
|
|
141
|
+
console.log(` ${import_chalk.default.dim("Vous pouvez maintenant utiliser cet agent avec Claude Code.")}
|
|
142
|
+
`);
|
|
143
|
+
} catch (error) {
|
|
144
|
+
spinner.fail(import_chalk.default.red(`Erreur d'installation : ${error.message}`));
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
program.command("info").description("Affiche les d\xE9tails d'un agent (Readme, auteur, stats)").argument("<slug>", "Slug de l'agent").action(async (slug) => {
|
|
148
|
+
console.log(LOGO);
|
|
149
|
+
const spinner = (0, import_ora.default)(`R\xE9cup\xE9ration des infos pour ${import_chalk.default.bold(slug)}...`).start();
|
|
150
|
+
try {
|
|
151
|
+
const res = await (0, import_node_fetch.default)(`${API_URL}/agents/${slug}`, { headers: getHeaders() });
|
|
152
|
+
if (!res.ok) {
|
|
153
|
+
if (res.status === 404) spinner.fail(import_chalk.default.red(`Agent "${slug}" introuvable.`));
|
|
154
|
+
else spinner.fail(import_chalk.default.red(`Erreur ${res.status}`));
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
const { agent } = await res.json();
|
|
158
|
+
spinner.stop();
|
|
159
|
+
console.log(` ${import_chalk.default.blue.bold("\u25C6 " + agent.slug.toUpperCase())}`);
|
|
160
|
+
console.log(` ${import_chalk.default.dim("\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501")}`);
|
|
161
|
+
console.log(` ${import_chalk.default.bold("Description :")} ${agent.description || "Aucune"}`);
|
|
162
|
+
console.log(` ${import_chalk.default.bold("Auteur :")} ${agent.user?.name || "Anonyme"}`);
|
|
163
|
+
console.log(` ${import_chalk.default.bold("Cat\xE9gorie :")} ${import_chalk.default.cyan(agent.category || "G\xE9n\xE9ral")}`);
|
|
164
|
+
console.log(` ${import_chalk.default.bold("Visibilit\xE9 :")} ${agent.visibility}`);
|
|
165
|
+
console.log(` ${import_chalk.default.bold("Stats :")} ${import_chalk.default.magenta("\u2B07 " + agent.downloads)} downloads ${import_chalk.default.yellow("\u2B50 " + agent.stars)} stars`);
|
|
166
|
+
if (agent.readme) {
|
|
167
|
+
console.log(`
|
|
168
|
+
${import_chalk.default.bold.underline("README :")}`);
|
|
169
|
+
console.log(agent.readme.split("\n").map((line) => " " + line).join("\n"));
|
|
170
|
+
}
|
|
171
|
+
console.log(`
|
|
172
|
+
${import_chalk.default.dim("Pour installer :")} ${import_chalk.default.bold(`devfactory add ${agent.slug}`)}
|
|
173
|
+
`);
|
|
174
|
+
} catch (error) {
|
|
175
|
+
spinner.fail(import_chalk.default.red(`Erreur : ${error.message}`));
|
|
176
|
+
}
|
|
177
|
+
});
|
|
178
|
+
program.command("list").description("Affiche les agents install\xE9s dans ce projet").action(() => {
|
|
179
|
+
console.log(LOGO);
|
|
180
|
+
const targetDir = import_path.default.join(process.cwd(), ".claude");
|
|
181
|
+
const agentsDir = import_path.default.join(targetDir, "agents");
|
|
182
|
+
if (!import_fs.default.existsSync(targetDir)) {
|
|
183
|
+
console.log(import_chalk.default.yellow(" Aucun dossier .claude d\xE9tect\xE9 dans ce projet."));
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
console.log(import_chalk.default.bold(" Agents install\xE9s localement :\n"));
|
|
187
|
+
const files = [];
|
|
188
|
+
if (import_fs.default.existsSync(targetDir)) {
|
|
189
|
+
import_fs.default.readdirSync(targetDir).forEach((f) => {
|
|
190
|
+
if (f.endsWith(".md") && f !== "agent.md") files.push(f);
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
if (import_fs.default.existsSync(agentsDir)) {
|
|
194
|
+
import_fs.default.readdirSync(agentsDir).forEach((f) => {
|
|
195
|
+
if (f.endsWith(".md")) files.push(f);
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
if (import_fs.default.existsSync(import_path.default.join(targetDir, "agent.md"))) {
|
|
199
|
+
console.log(` ${import_chalk.default.green("\u25CF")} ${import_chalk.default.bold("agent.md")} ${import_chalk.default.dim("(Agent principal)")}`);
|
|
200
|
+
}
|
|
201
|
+
files.forEach((f) => {
|
|
202
|
+
console.log(` ${import_chalk.default.green("\u25CF")} ${import_chalk.default.bold(f)}`);
|
|
203
|
+
});
|
|
204
|
+
if (files.length === 0 && !import_fs.default.existsSync(import_path.default.join(targetDir, "agent.md"))) {
|
|
205
|
+
console.log(import_chalk.default.dim(" Aucun agent trouv\xE9 dans .claude/"));
|
|
206
|
+
}
|
|
207
|
+
console.log("");
|
|
208
|
+
});
|
|
209
|
+
program.parse(process.argv);
|
package/package.json
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "devfactory",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "CLI officiel de DevFactory pour installer des agents Genius localement",
|
|
5
|
+
"bin": {
|
|
6
|
+
"devfactory": "./dist/index.js"
|
|
7
|
+
},
|
|
8
|
+
"files": [
|
|
9
|
+
"dist"
|
|
10
|
+
],
|
|
11
|
+
"publishConfig": {
|
|
12
|
+
"access": "public"
|
|
13
|
+
},
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": "git+https://gitlab.com/wassim/genius.git"
|
|
17
|
+
},
|
|
18
|
+
"keywords": [
|
|
19
|
+
"devfactory",
|
|
20
|
+
"ai-agents",
|
|
21
|
+
"claude",
|
|
22
|
+
"cli"
|
|
23
|
+
],
|
|
24
|
+
"scripts": {
|
|
25
|
+
"build": "tsup src/index.ts --format cjs --dts",
|
|
26
|
+
"dev": "tsup src/index.ts --format cjs --watch",
|
|
27
|
+
"type-check": "tsc --noEmit",
|
|
28
|
+
"lint": "eslint src"
|
|
29
|
+
},
|
|
30
|
+
"dependencies": {
|
|
31
|
+
"commander": "^12.0.0",
|
|
32
|
+
"adm-zip": "^0.5.10",
|
|
33
|
+
"chalk": "^4.1.2",
|
|
34
|
+
"ora": "^5.4.1",
|
|
35
|
+
"node-fetch": "^2.7.0"
|
|
36
|
+
},
|
|
37
|
+
"devDependencies": {
|
|
38
|
+
"@types/node": "^20.11.0",
|
|
39
|
+
"@types/adm-zip": "^0.5.5",
|
|
40
|
+
"@types/node-fetch": "^2.6.11",
|
|
41
|
+
"tsup": "^8.0.2",
|
|
42
|
+
"typescript": "^5.7.0"
|
|
43
|
+
}
|
|
44
|
+
}
|