@minhluudev/ai-tools 1.0.22 → 1.0.26

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.
@@ -1,155 +0,0 @@
1
- import { mkdtemp, rm } from "node:fs/promises";
2
- import * as os from "node:os";
3
- import * as path from "node:path";
4
- import { spawn } from "node:child_process";
5
- const LUMIN_PLUGIN_ENTRY = "plugins/lumin";
6
- const LUMIN_MARKETPLACE_ENTRY = ".agents/plugins";
7
- const LUMIN_TEMP_DIR_PREFIX = "ai-tools-plugin-lumin-";
8
- function uniq(items) {
9
- return [...new Set(items)];
10
- }
11
- function buildLuminSteps(input) {
12
- const steps = [];
13
- const notes = [
14
- "Lumin is loaded from the repository's dedicated plugins branch at install time.",
15
- "Lumin installs in global mode only through this CLI.",
16
- "The plugin installs namespaced host skills and an instruction layer so Codex and Claude can apply Lumin skills by context."
17
- ];
18
- for (const agent of uniq(input.agents)) {
19
- if (agent === "claude") {
20
- steps.push({
21
- id: `lumin-${input.mode}-claude`,
22
- plugin: "lumin",
23
- agent,
24
- phase: input.mode,
25
- title: `${input.mode === "install" ? "Install" : "Uninstall"} Lumin for Claude`,
26
- description: `${input.mode === "install" ? "Install" : "Remove"} Lumin in the user's Claude home directories.`,
27
- command: `sh plugins/lumin/scripts/${input.mode}-claude.sh --global`,
28
- runner: input.mode === "install" ? "setup-lumin-claude" : "remove-lumin-claude",
29
- });
30
- continue;
31
- }
32
- steps.push({
33
- id: `lumin-${input.mode}-codex`,
34
- plugin: "lumin",
35
- agent,
36
- phase: input.mode,
37
- title: `${input.mode === "install" ? "Install" : "Uninstall"} Lumin for Codex`,
38
- description: `${input.mode === "install" ? "Install" : "Remove"} the Lumin Codex plugin and global auto skill surface in the user's home directory.`,
39
- command: `sh plugins/lumin/scripts/${input.mode}-codex.sh`,
40
- runner: input.mode === "install" ? "setup-lumin-codex" : "remove-lumin-codex"
41
- });
42
- }
43
- if (steps.some((step) => step.agent === "codex")) {
44
- notes.push("Codex registration, auto skills, and the Lumin instruction layer are installed under the user's home directory.");
45
- }
46
- if (steps.some((step) => step.agent === "claude")) {
47
- notes.push("Claude install adds `/lumin:<skill>` commands and also installs `~/.agents/skills/lumin-*` for auto-apply behavior.");
48
- }
49
- return { steps, notes };
50
- }
51
- export function buildPluginInstallPlan(input) {
52
- const plugins = uniq(input.plugins);
53
- const agents = uniq(input.agents);
54
- const steps = [];
55
- const notes = [];
56
- for (const plugin of plugins) {
57
- if (plugin !== "lumin") {
58
- continue;
59
- }
60
- const lumin = buildLuminSteps({
61
- mode: input.mode,
62
- agents
63
- });
64
- steps.push(...lumin.steps);
65
- notes.push(...lumin.notes);
66
- }
67
- return {
68
- mode: input.mode,
69
- agents,
70
- plugins,
71
- sourceBranch: input.sourceBranch,
72
- steps,
73
- notes: uniq(notes)
74
- };
75
- }
76
- async function prepareLuminPluginRepo(input) {
77
- const archivePath = await input.client.getArchive({
78
- branch: input.branch,
79
- sha: "latest"
80
- });
81
- const tempRoot = await mkdtemp(path.join(os.tmpdir(), LUMIN_TEMP_DIR_PREFIX));
82
- try {
83
- const pluginRoot = await input.client.extractArchiveEntry({
84
- archivePath,
85
- entryPath: LUMIN_PLUGIN_ENTRY,
86
- destinationDir: tempRoot
87
- });
88
- await input.client.extractArchiveEntry({
89
- archivePath,
90
- entryPath: LUMIN_MARKETPLACE_ENTRY,
91
- destinationDir: tempRoot
92
- });
93
- return {
94
- pluginRoot,
95
- cleanup: async () => {
96
- await rm(tempRoot, { recursive: true, force: true });
97
- }
98
- };
99
- }
100
- catch (error) {
101
- await rm(tempRoot, { recursive: true, force: true });
102
- throw error;
103
- }
104
- }
105
- function runShellCommand(command, cwd) {
106
- return new Promise((resolve, reject) => {
107
- const child = spawn("/bin/sh", ["-lc", command], {
108
- cwd,
109
- stdio: "inherit"
110
- });
111
- child.on("error", reject);
112
- child.on("close", (code) => {
113
- if (code === 0) {
114
- resolve();
115
- return;
116
- }
117
- reject(new Error(`Command failed with exit code ${code}: ${command}`));
118
- });
119
- });
120
- }
121
- export async function executePluginInstallPlan(input) {
122
- let luminRepo = null;
123
- try {
124
- for (const step of input.plan.steps) {
125
- input.onProgress?.(step);
126
- if (step.plugin !== "lumin") {
127
- continue;
128
- }
129
- if (!luminRepo) {
130
- luminRepo = await prepareLuminPluginRepo({
131
- client: input.client,
132
- branch: input.plan.sourceBranch
133
- });
134
- }
135
- const scriptsDir = path.join(luminRepo.pluginRoot, "scripts");
136
- const codexGlobalRoot = os.homedir();
137
- if (step.runner === "setup-lumin-claude") {
138
- await runShellCommand(`sh "${path.join(scriptsDir, "install-claude.sh")}" --global`, luminRepo.pluginRoot);
139
- continue;
140
- }
141
- if (step.runner === "remove-lumin-claude") {
142
- await runShellCommand(`sh "${path.join(scriptsDir, "uninstall-claude.sh")}" --global`, luminRepo.pluginRoot);
143
- continue;
144
- }
145
- if (step.runner === "setup-lumin-codex") {
146
- await runShellCommand(`sh "${path.join(scriptsDir, "install-codex.sh")}"`, codexGlobalRoot);
147
- continue;
148
- }
149
- await runShellCommand(`sh "${path.join(scriptsDir, "uninstall-codex.sh")}"`, codexGlobalRoot);
150
- }
151
- }
152
- finally {
153
- await luminRepo?.cleanup();
154
- }
155
- }
@@ -1,45 +0,0 @@
1
- import { readFile } from "node:fs/promises";
2
- import * as path from "node:path";
3
- import { normalizeManifestPath } from "./paths.js";
4
- function validateSkillEntry(rawEntry, index) {
5
- if (!rawEntry || typeof rawEntry !== "object") {
6
- throw new Error(`Project docs catalog skill #${index + 1} must be an object.`);
7
- }
8
- const entry = rawEntry;
9
- if (typeof entry.id !== "string" || entry.id.trim() === "") {
10
- throw new Error(`Project docs catalog skill #${index + 1} is missing a valid id.`);
11
- }
12
- if (typeof entry.label !== "string" || entry.label.trim() === "") {
13
- throw new Error(`Project docs catalog skill "${entry.id}" is missing a valid label.`);
14
- }
15
- const sourceBranch = typeof entry.sourceBranch === "string" && entry.sourceBranch.trim() !== ""
16
- ? entry.sourceBranch.trim()
17
- : undefined;
18
- const sourcePath = typeof entry.sourcePath === "string" && entry.sourcePath.trim() !== ""
19
- ? normalizeManifestPath(entry.sourcePath, `${entry.id}.sourcePath`)
20
- : undefined;
21
- return {
22
- id: entry.id.trim(),
23
- label: entry.label.trim(),
24
- description: typeof entry.description === "string" && entry.description.trim() !== ""
25
- ? entry.description.trim()
26
- : "",
27
- sourceBranch,
28
- sourcePath
29
- };
30
- }
31
- export async function loadProjectDocsCatalog(config) {
32
- const catalogPath = path.join(config.packageRoot, config.projectDocsCatalogPath);
33
- const rawCatalogText = await readFile(catalogPath, "utf8");
34
- const rawCatalog = JSON.parse(rawCatalogText);
35
- if (rawCatalog.version !== 1) {
36
- throw new Error(`Project docs catalog "${config.projectDocsCatalogPath}" must use version 1.`);
37
- }
38
- if (!Array.isArray(rawCatalog.skills)) {
39
- throw new Error(`Project docs catalog "${config.projectDocsCatalogPath}" must contain a skills array.`);
40
- }
41
- return {
42
- version: 1,
43
- skills: rawCatalog.skills.map((entry, index) => validateSkillEntry(entry, index))
44
- };
45
- }