@kitnai/cli 0.1.18 → 0.1.20
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 +118 -513
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -330,7 +330,7 @@ async function resolveDependencies(names, fetchItem) {
|
|
|
330
330
|
const visited = /* @__PURE__ */ new Set();
|
|
331
331
|
const items = /* @__PURE__ */ new Map();
|
|
332
332
|
const edges = [];
|
|
333
|
-
async function
|
|
333
|
+
async function resolve(name) {
|
|
334
334
|
if (visited.has(name)) return;
|
|
335
335
|
visited.add(name);
|
|
336
336
|
const item = await fetchItem(name);
|
|
@@ -338,11 +338,11 @@ async function resolveDependencies(names, fetchItem) {
|
|
|
338
338
|
const deps = item.registryDependencies ?? [];
|
|
339
339
|
for (const dep of deps) {
|
|
340
340
|
edges.push([dep, name]);
|
|
341
|
-
await
|
|
341
|
+
await resolve(dep);
|
|
342
342
|
}
|
|
343
343
|
}
|
|
344
344
|
for (const name of names) {
|
|
345
|
-
await
|
|
345
|
+
await resolve(name);
|
|
346
346
|
}
|
|
347
347
|
return topologicalSort(items, edges);
|
|
348
348
|
}
|
|
@@ -1086,8 +1086,7 @@ async function addCommand(components, opts) {
|
|
|
1086
1086
|
[
|
|
1087
1087
|
`import { ai } from "./${baseDir.replace(/^src\//, "")}/plugin";`,
|
|
1088
1088
|
``,
|
|
1089
|
-
`app.route("/api", ai.router)
|
|
1090
|
-
`await ai.initialize();`
|
|
1089
|
+
`app.route("/api", ai.router);`
|
|
1091
1090
|
].join("\n"),
|
|
1092
1091
|
"Add this to your server entry point"
|
|
1093
1092
|
);
|
|
@@ -1142,7 +1141,6 @@ async function addCommand(components, opts) {
|
|
|
1142
1141
|
hints.push(pc3.dim(` import { ai } from "./${baseDir.replace(/^src\//, "")}/plugin";`));
|
|
1143
1142
|
hints.push(pc3.dim(``));
|
|
1144
1143
|
hints.push(pc3.dim(` app.route("/api", ai.router);`));
|
|
1145
|
-
hints.push(pc3.dim(` await ai.initialize();`));
|
|
1146
1144
|
hints.push("");
|
|
1147
1145
|
}
|
|
1148
1146
|
if (hints.length > 0) {
|
|
@@ -1279,8 +1277,7 @@ async function initCommand(opts = {}) {
|
|
|
1279
1277
|
[
|
|
1280
1278
|
`import { ai } from "./${baseDir.replace(/^src\//, "")}/plugin";`,
|
|
1281
1279
|
``,
|
|
1282
|
-
`app.route("/api", ai.router)
|
|
1283
|
-
`await ai.initialize();`
|
|
1280
|
+
`app.route("/api", ai.router);`
|
|
1284
1281
|
].join("\n"),
|
|
1285
1282
|
"Add this to your server entry point:"
|
|
1286
1283
|
);
|
|
@@ -1303,7 +1300,7 @@ var init_init = __esm({
|
|
|
1303
1300
|
init_tsconfig_patcher();
|
|
1304
1301
|
init_barrel_manager();
|
|
1305
1302
|
init_add();
|
|
1306
|
-
PLUGIN_TEMPLATE = `import { createAIPlugin } from "@kitn/
|
|
1303
|
+
PLUGIN_TEMPLATE = `import { createAIPlugin } from "@kitn/routes";
|
|
1307
1304
|
import { registerWithPlugin } from "./index.js";
|
|
1308
1305
|
|
|
1309
1306
|
export const ai = createAIPlugin({
|
|
@@ -1657,433 +1654,23 @@ var init_update = __esm({
|
|
|
1657
1654
|
}
|
|
1658
1655
|
});
|
|
1659
1656
|
|
|
1660
|
-
// src/registry/build-output.ts
|
|
1661
|
-
import { readdir, writeFile as writeFile9, mkdir as mkdir5, access as access4 } from "fs/promises";
|
|
1662
|
-
import { join as join11, resolve } from "path";
|
|
1663
|
-
async function fileExists(path) {
|
|
1664
|
-
try {
|
|
1665
|
-
await access4(path);
|
|
1666
|
-
return true;
|
|
1667
|
-
} catch {
|
|
1668
|
-
return false;
|
|
1669
|
-
}
|
|
1670
|
-
}
|
|
1671
|
-
async function walkForRegistryJson(dir) {
|
|
1672
|
-
const results = [];
|
|
1673
|
-
let entries;
|
|
1674
|
-
try {
|
|
1675
|
-
entries = await readdir(dir, { withFileTypes: true });
|
|
1676
|
-
} catch {
|
|
1677
|
-
return results;
|
|
1678
|
-
}
|
|
1679
|
-
if (await fileExists(join11(dir, "registry.json"))) {
|
|
1680
|
-
results.push(dir);
|
|
1681
|
-
return results;
|
|
1682
|
-
}
|
|
1683
|
-
for (const entry of entries) {
|
|
1684
|
-
if (entry.isDirectory() && !SKIP_DIRS.has(entry.name)) {
|
|
1685
|
-
const subResults = await walkForRegistryJson(join11(dir, entry.name));
|
|
1686
|
-
results.push(...subResults);
|
|
1687
|
-
}
|
|
1688
|
-
}
|
|
1689
|
-
return results;
|
|
1690
|
-
}
|
|
1691
|
-
async function scanForComponents(cwd, paths) {
|
|
1692
|
-
const resolvedCwd = resolve(cwd);
|
|
1693
|
-
if (paths && paths.length > 0) {
|
|
1694
|
-
const results = [];
|
|
1695
|
-
for (const p13 of paths) {
|
|
1696
|
-
const absPath = resolve(resolvedCwd, p13);
|
|
1697
|
-
if (await fileExists(join11(absPath, "registry.json"))) {
|
|
1698
|
-
results.push(absPath);
|
|
1699
|
-
continue;
|
|
1700
|
-
}
|
|
1701
|
-
let entries;
|
|
1702
|
-
try {
|
|
1703
|
-
entries = await readdir(absPath, { withFileTypes: true });
|
|
1704
|
-
} catch {
|
|
1705
|
-
continue;
|
|
1706
|
-
}
|
|
1707
|
-
for (const entry of entries) {
|
|
1708
|
-
if (entry.isDirectory()) {
|
|
1709
|
-
const subDir = join11(absPath, entry.name);
|
|
1710
|
-
if (await fileExists(join11(subDir, "registry.json"))) {
|
|
1711
|
-
results.push(subDir);
|
|
1712
|
-
}
|
|
1713
|
-
}
|
|
1714
|
-
}
|
|
1715
|
-
}
|
|
1716
|
-
return results;
|
|
1717
|
-
}
|
|
1718
|
-
return walkForRegistryJson(resolvedCwd);
|
|
1719
|
-
}
|
|
1720
|
-
function parseVersionFromFilename(name, componentName) {
|
|
1721
|
-
const prefix = `${componentName}@`;
|
|
1722
|
-
const suffix = ".json";
|
|
1723
|
-
if (name.startsWith(prefix) && name.endsWith(suffix)) {
|
|
1724
|
-
return name.slice(prefix.length, -suffix.length);
|
|
1725
|
-
}
|
|
1726
|
-
return null;
|
|
1727
|
-
}
|
|
1728
|
-
async function writeRegistryOutput(outputDir, items) {
|
|
1729
|
-
const written = [];
|
|
1730
|
-
const skipped = [];
|
|
1731
|
-
const resolvedOutput = resolve(outputDir);
|
|
1732
|
-
const indexItems = [];
|
|
1733
|
-
for (const item of items) {
|
|
1734
|
-
const dir = typeToDir[item.type];
|
|
1735
|
-
const typeDir = join11(resolvedOutput, dir);
|
|
1736
|
-
await mkdir5(typeDir, { recursive: true });
|
|
1737
|
-
const itemJson = JSON.stringify(item, null, 2);
|
|
1738
|
-
const latestPath = join11(typeDir, `${item.name}.json`);
|
|
1739
|
-
const latestRelative = `${dir}/${item.name}.json`;
|
|
1740
|
-
await writeFile9(latestPath, itemJson, "utf-8");
|
|
1741
|
-
written.push(latestRelative);
|
|
1742
|
-
if (item.version) {
|
|
1743
|
-
const versionedFilename = `${item.name}@${item.version}.json`;
|
|
1744
|
-
const versionedPath = join11(typeDir, versionedFilename);
|
|
1745
|
-
const versionedRelative = `${dir}/${versionedFilename}`;
|
|
1746
|
-
if (await fileExists(versionedPath)) {
|
|
1747
|
-
skipped.push(versionedRelative);
|
|
1748
|
-
} else {
|
|
1749
|
-
await writeFile9(versionedPath, itemJson, "utf-8");
|
|
1750
|
-
written.push(versionedRelative);
|
|
1751
|
-
}
|
|
1752
|
-
}
|
|
1753
|
-
const versions = [];
|
|
1754
|
-
let entries;
|
|
1755
|
-
try {
|
|
1756
|
-
entries = await readdir(typeDir);
|
|
1757
|
-
} catch {
|
|
1758
|
-
entries = [];
|
|
1759
|
-
}
|
|
1760
|
-
for (const filename of entries) {
|
|
1761
|
-
const ver = parseVersionFromFilename(filename, item.name);
|
|
1762
|
-
if (ver) {
|
|
1763
|
-
versions.push(ver);
|
|
1764
|
-
}
|
|
1765
|
-
}
|
|
1766
|
-
versions.sort();
|
|
1767
|
-
indexItems.push({
|
|
1768
|
-
name: item.name,
|
|
1769
|
-
type: item.type,
|
|
1770
|
-
description: item.description,
|
|
1771
|
-
...item.registryDependencies && item.registryDependencies.length > 0 && {
|
|
1772
|
-
registryDependencies: item.registryDependencies
|
|
1773
|
-
},
|
|
1774
|
-
...item.categories && item.categories.length > 0 && { categories: item.categories },
|
|
1775
|
-
...item.version && { version: item.version },
|
|
1776
|
-
...versions.length > 0 && { versions },
|
|
1777
|
-
...item.updatedAt && { updatedAt: item.updatedAt }
|
|
1778
|
-
});
|
|
1779
|
-
}
|
|
1780
|
-
const index = {
|
|
1781
|
-
version: "1",
|
|
1782
|
-
items: indexItems
|
|
1783
|
-
};
|
|
1784
|
-
const indexPath = join11(resolvedOutput, "registry.json");
|
|
1785
|
-
await writeFile9(indexPath, JSON.stringify(index, null, 2), "utf-8");
|
|
1786
|
-
written.push("registry.json");
|
|
1787
|
-
return { written, skipped };
|
|
1788
|
-
}
|
|
1789
|
-
var SKIP_DIRS;
|
|
1790
|
-
var init_build_output = __esm({
|
|
1791
|
-
"src/registry/build-output.ts"() {
|
|
1792
|
-
"use strict";
|
|
1793
|
-
init_schema();
|
|
1794
|
-
SKIP_DIRS = /* @__PURE__ */ new Set([
|
|
1795
|
-
"node_modules",
|
|
1796
|
-
"dist",
|
|
1797
|
-
".git",
|
|
1798
|
-
"r",
|
|
1799
|
-
"test",
|
|
1800
|
-
"tests",
|
|
1801
|
-
".claude"
|
|
1802
|
-
]);
|
|
1803
|
-
}
|
|
1804
|
-
});
|
|
1805
|
-
|
|
1806
|
-
// src/registry/builder.ts
|
|
1807
|
-
import { readFile as readFile9, readdir as readdir2 } from "fs/promises";
|
|
1808
|
-
import { join as join12, relative as relative5 } from "path";
|
|
1809
|
-
function isExcludedDevDep(name) {
|
|
1810
|
-
return EXCLUDED_DEV_DEPS.has(name) || name.startsWith("@types/");
|
|
1811
|
-
}
|
|
1812
|
-
function stripScope(name) {
|
|
1813
|
-
const match = name.match(/^@[^/]+\/(.+)$/);
|
|
1814
|
-
return match ? match[1] : name;
|
|
1815
|
-
}
|
|
1816
|
-
async function readTsFiles(dir, baseDir, exclude) {
|
|
1817
|
-
const results = [];
|
|
1818
|
-
const entries = await readdir2(dir, { withFileTypes: true });
|
|
1819
|
-
for (const entry of entries) {
|
|
1820
|
-
const fullPath = join12(dir, entry.name);
|
|
1821
|
-
const relPath = relative5(baseDir, fullPath);
|
|
1822
|
-
if (entry.isDirectory()) {
|
|
1823
|
-
const nested = await readTsFiles(fullPath, baseDir, exclude);
|
|
1824
|
-
results.push(...nested);
|
|
1825
|
-
} else if (entry.isFile() && entry.name.endsWith(".ts")) {
|
|
1826
|
-
if (exclude.includes(relPath)) {
|
|
1827
|
-
continue;
|
|
1828
|
-
}
|
|
1829
|
-
const content = await readFile9(fullPath, "utf-8");
|
|
1830
|
-
results.push({ relativePath: relPath, content });
|
|
1831
|
-
}
|
|
1832
|
-
}
|
|
1833
|
-
return results;
|
|
1834
|
-
}
|
|
1835
|
-
async function buildComponent(componentDir) {
|
|
1836
|
-
let rawConfig;
|
|
1837
|
-
try {
|
|
1838
|
-
rawConfig = await readFile9(join12(componentDir, "registry.json"), "utf-8");
|
|
1839
|
-
} catch {
|
|
1840
|
-
throw new Error(
|
|
1841
|
-
`No registry.json found in ${componentDir}. Every component must have a registry.json file.`
|
|
1842
|
-
);
|
|
1843
|
-
}
|
|
1844
|
-
let config;
|
|
1845
|
-
try {
|
|
1846
|
-
config = componentConfigSchema.parse(JSON.parse(rawConfig));
|
|
1847
|
-
} catch (err) {
|
|
1848
|
-
throw new Error(
|
|
1849
|
-
`Invalid registry.json in ${componentDir}: ${err instanceof Error ? err.message : String(err)}`
|
|
1850
|
-
);
|
|
1851
|
-
}
|
|
1852
|
-
let pkg = null;
|
|
1853
|
-
try {
|
|
1854
|
-
const rawPkg = await readFile9(join12(componentDir, "package.json"), "utf-8");
|
|
1855
|
-
pkg = JSON.parse(rawPkg);
|
|
1856
|
-
} catch {
|
|
1857
|
-
}
|
|
1858
|
-
const name = config.name ?? (pkg?.name ? stripScope(pkg.name) : void 0);
|
|
1859
|
-
const version = config.version ?? pkg?.version;
|
|
1860
|
-
const description = config.description ?? pkg?.description;
|
|
1861
|
-
if (!name) {
|
|
1862
|
-
throw new Error(
|
|
1863
|
-
`Component in ${componentDir} is missing a name. Provide "name" in registry.json or have a package.json with a "name" field.`
|
|
1864
|
-
);
|
|
1865
|
-
}
|
|
1866
|
-
if (!description) {
|
|
1867
|
-
throw new Error(
|
|
1868
|
-
`Component in ${componentDir} is missing a description. Provide "description" in registry.json or have a package.json with a "description" field.`
|
|
1869
|
-
);
|
|
1870
|
-
}
|
|
1871
|
-
let dependencies = config.dependencies;
|
|
1872
|
-
let devDependencies = config.devDependencies;
|
|
1873
|
-
if (pkg && !config.dependencies) {
|
|
1874
|
-
const deps = [];
|
|
1875
|
-
if (pkg.dependencies) {
|
|
1876
|
-
for (const [depName, depVersion] of Object.entries(pkg.dependencies)) {
|
|
1877
|
-
if (depVersion !== "workspace:*") {
|
|
1878
|
-
deps.push(depName);
|
|
1879
|
-
}
|
|
1880
|
-
}
|
|
1881
|
-
}
|
|
1882
|
-
if (pkg.peerDependencies) {
|
|
1883
|
-
for (const [depName, depVersion] of Object.entries(pkg.peerDependencies)) {
|
|
1884
|
-
if (depVersion !== "workspace:*") {
|
|
1885
|
-
deps.push(depName);
|
|
1886
|
-
}
|
|
1887
|
-
}
|
|
1888
|
-
}
|
|
1889
|
-
if (deps.length > 0) {
|
|
1890
|
-
dependencies = deps;
|
|
1891
|
-
}
|
|
1892
|
-
}
|
|
1893
|
-
if (pkg && !config.devDependencies) {
|
|
1894
|
-
const devDeps = [];
|
|
1895
|
-
if (pkg.devDependencies) {
|
|
1896
|
-
for (const depName of Object.keys(pkg.devDependencies)) {
|
|
1897
|
-
if (!isExcludedDevDep(depName)) {
|
|
1898
|
-
devDeps.push(depName);
|
|
1899
|
-
}
|
|
1900
|
-
}
|
|
1901
|
-
}
|
|
1902
|
-
if (devDeps.length > 0) {
|
|
1903
|
-
devDependencies = devDeps;
|
|
1904
|
-
}
|
|
1905
|
-
}
|
|
1906
|
-
const isPackage = config.type === "kitn:package";
|
|
1907
|
-
const dirPrefix = config.installDir ?? typeToDir[config.type];
|
|
1908
|
-
let files;
|
|
1909
|
-
if (isPackage) {
|
|
1910
|
-
const sourceDir = config.sourceDir ?? "src";
|
|
1911
|
-
const sourcePath = join12(componentDir, sourceDir);
|
|
1912
|
-
const exclude = config.exclude ?? [];
|
|
1913
|
-
let tsFiles;
|
|
1914
|
-
try {
|
|
1915
|
-
tsFiles = await readTsFiles(sourcePath, sourcePath, exclude);
|
|
1916
|
-
} catch {
|
|
1917
|
-
throw new Error(
|
|
1918
|
-
`Cannot read source directory "${sourceDir}" in ${componentDir}. Make sure it exists.`
|
|
1919
|
-
);
|
|
1920
|
-
}
|
|
1921
|
-
files = tsFiles.map((f) => ({
|
|
1922
|
-
path: `${dirPrefix}/${f.relativePath}`,
|
|
1923
|
-
content: f.content,
|
|
1924
|
-
type: config.type
|
|
1925
|
-
}));
|
|
1926
|
-
} else {
|
|
1927
|
-
if (!config.files || config.files.length === 0) {
|
|
1928
|
-
throw new Error(
|
|
1929
|
-
`Component "${name}" (type: ${config.type}) has no "files" array in registry.json. Standalone components must list their source files.`
|
|
1930
|
-
);
|
|
1931
|
-
}
|
|
1932
|
-
files = await Promise.all(
|
|
1933
|
-
config.files.map(async (filePath) => {
|
|
1934
|
-
const fullPath = join12(componentDir, filePath);
|
|
1935
|
-
let content;
|
|
1936
|
-
try {
|
|
1937
|
-
content = await readFile9(fullPath, "utf-8");
|
|
1938
|
-
} catch {
|
|
1939
|
-
throw new Error(
|
|
1940
|
-
`Cannot read file "${filePath}" referenced in registry.json for component "${name}". Make sure the file exists at ${fullPath}.`
|
|
1941
|
-
);
|
|
1942
|
-
}
|
|
1943
|
-
return {
|
|
1944
|
-
path: `${dirPrefix}/${filePath}`,
|
|
1945
|
-
content,
|
|
1946
|
-
type: config.type
|
|
1947
|
-
};
|
|
1948
|
-
})
|
|
1949
|
-
);
|
|
1950
|
-
}
|
|
1951
|
-
const item = {
|
|
1952
|
-
name,
|
|
1953
|
-
type: config.type,
|
|
1954
|
-
description,
|
|
1955
|
-
files
|
|
1956
|
-
};
|
|
1957
|
-
if (version) item.version = version;
|
|
1958
|
-
if (dependencies && dependencies.length > 0) item.dependencies = dependencies;
|
|
1959
|
-
if (devDependencies && devDependencies.length > 0) item.devDependencies = devDependencies;
|
|
1960
|
-
if (config.registryDependencies && config.registryDependencies.length > 0) {
|
|
1961
|
-
item.registryDependencies = config.registryDependencies;
|
|
1962
|
-
}
|
|
1963
|
-
if (config.envVars) item.envVars = config.envVars;
|
|
1964
|
-
if (config.tsconfig) item.tsconfig = config.tsconfig;
|
|
1965
|
-
if (config.docs) item.docs = config.docs;
|
|
1966
|
-
if (config.categories && config.categories.length > 0) item.categories = config.categories;
|
|
1967
|
-
if (config.changelog && config.changelog.length > 0) item.changelog = config.changelog;
|
|
1968
|
-
if (isPackage && config.installDir) item.installDir = config.installDir;
|
|
1969
|
-
try {
|
|
1970
|
-
return registryItemSchema.parse(item);
|
|
1971
|
-
} catch (err) {
|
|
1972
|
-
throw new Error(
|
|
1973
|
-
`Built component "${name}" failed validation: ${err instanceof Error ? err.message : String(err)}`
|
|
1974
|
-
);
|
|
1975
|
-
}
|
|
1976
|
-
}
|
|
1977
|
-
var EXCLUDED_DEV_DEPS;
|
|
1978
|
-
var init_builder = __esm({
|
|
1979
|
-
"src/registry/builder.ts"() {
|
|
1980
|
-
"use strict";
|
|
1981
|
-
init_schema();
|
|
1982
|
-
EXCLUDED_DEV_DEPS = /* @__PURE__ */ new Set([
|
|
1983
|
-
"typescript",
|
|
1984
|
-
"@types/bun",
|
|
1985
|
-
"@types/node",
|
|
1986
|
-
"tsup",
|
|
1987
|
-
"vitest",
|
|
1988
|
-
"jest",
|
|
1989
|
-
"@types/jest"
|
|
1990
|
-
]);
|
|
1991
|
-
}
|
|
1992
|
-
});
|
|
1993
|
-
|
|
1994
|
-
// src/commands/build.ts
|
|
1995
|
-
var build_exports = {};
|
|
1996
|
-
__export(build_exports, {
|
|
1997
|
-
buildCommand: () => buildCommand
|
|
1998
|
-
});
|
|
1999
|
-
import * as p8 from "@clack/prompts";
|
|
2000
|
-
import pc7 from "picocolors";
|
|
2001
|
-
import { resolve as resolve2, relative as relative6 } from "path";
|
|
2002
|
-
async function buildCommand(paths, opts) {
|
|
2003
|
-
p8.intro(pc7.bgCyan(pc7.black(" kitn build ")));
|
|
2004
|
-
const cwd = process.cwd();
|
|
2005
|
-
const outputDir = resolve2(cwd, opts.output ?? "dist/r");
|
|
2006
|
-
const s = p8.spinner();
|
|
2007
|
-
s.start("Scanning for components...");
|
|
2008
|
-
const componentDirs = await scanForComponents(cwd, paths.length > 0 ? paths : void 0);
|
|
2009
|
-
if (componentDirs.length === 0) {
|
|
2010
|
-
s.stop("No components found");
|
|
2011
|
-
p8.log.info(
|
|
2012
|
-
`No directories with ${pc7.bold("registry.json")} found. Run ${pc7.bold("kitn create")} to scaffold a component.`
|
|
2013
|
-
);
|
|
2014
|
-
return;
|
|
2015
|
-
}
|
|
2016
|
-
s.stop(`Found ${componentDirs.length} component(s)`);
|
|
2017
|
-
p8.log.message(componentDirs.map((dir) => ` ${pc7.dim(relative6(cwd, dir))}`).join("\n"));
|
|
2018
|
-
s.start("Building components...");
|
|
2019
|
-
const items = [];
|
|
2020
|
-
const errors = [];
|
|
2021
|
-
for (const dir of componentDirs) {
|
|
2022
|
-
try {
|
|
2023
|
-
const item = await buildComponent(dir);
|
|
2024
|
-
items.push(item);
|
|
2025
|
-
} catch (err) {
|
|
2026
|
-
errors.push({ dir: relative6(cwd, dir), error: err.message });
|
|
2027
|
-
}
|
|
2028
|
-
}
|
|
2029
|
-
if (errors.length > 0) {
|
|
2030
|
-
s.stop(pc7.red(`Build failed with ${errors.length} error(s)`));
|
|
2031
|
-
p8.log.error(errors.map(({ dir, error }) => `${pc7.bold(dir)}: ${error}`).join("\n"));
|
|
2032
|
-
process.exit(1);
|
|
2033
|
-
}
|
|
2034
|
-
const { written, skipped } = await writeRegistryOutput(outputDir, items);
|
|
2035
|
-
s.stop(pc7.green(`Built ${items.length} component(s)`));
|
|
2036
|
-
if (written.length > 0) {
|
|
2037
|
-
p8.log.success(`Wrote ${written.length} file(s):
|
|
2038
|
-
` + written.map((f) => ` ${pc7.green("+")} ${f}`).join("\n"));
|
|
2039
|
-
}
|
|
2040
|
-
if (skipped.length > 0) {
|
|
2041
|
-
p8.log.info(`Skipped ${skipped.length} file(s) (already exist):
|
|
2042
|
-
` + skipped.map((f) => ` ${pc7.dim("-")} ${f}`).join("\n"));
|
|
2043
|
-
}
|
|
2044
|
-
p8.outro(`Output: ${pc7.cyan(relative6(cwd, outputDir) || ".")}`);
|
|
2045
|
-
}
|
|
2046
|
-
var init_build = __esm({
|
|
2047
|
-
"src/commands/build.ts"() {
|
|
2048
|
-
"use strict";
|
|
2049
|
-
init_build_output();
|
|
2050
|
-
init_builder();
|
|
2051
|
-
}
|
|
2052
|
-
});
|
|
2053
|
-
|
|
2054
1657
|
// src/commands/create.ts
|
|
2055
1658
|
var create_exports = {};
|
|
2056
1659
|
__export(create_exports, {
|
|
2057
1660
|
createCommand: () => createCommand,
|
|
2058
|
-
|
|
1661
|
+
createComponentInProject: () => createComponentInProject
|
|
2059
1662
|
});
|
|
2060
|
-
import * as
|
|
2061
|
-
import
|
|
2062
|
-
import { join as
|
|
2063
|
-
import {
|
|
1663
|
+
import * as p8 from "@clack/prompts";
|
|
1664
|
+
import pc7 from "picocolors";
|
|
1665
|
+
import { join as join11, relative as relative4 } from "path";
|
|
1666
|
+
import { existsSync as existsSync3 } from "fs";
|
|
1667
|
+
import { readFile as readFile8, writeFile as writeFile9, mkdir as mkdir5 } from "fs/promises";
|
|
2064
1668
|
function toCamelCase(str) {
|
|
2065
1669
|
return str.replace(/-([a-z])/g, (_, c) => c.toUpperCase());
|
|
2066
1670
|
}
|
|
2067
1671
|
function toTitleCase(str) {
|
|
2068
1672
|
return str.split("-").map((w) => w.charAt(0).toUpperCase() + w.slice(1)).join(" ");
|
|
2069
1673
|
}
|
|
2070
|
-
function generateRegistryJson(type, name, sourceFile) {
|
|
2071
|
-
const base = {
|
|
2072
|
-
$schema: "https://kitn.dev/schema/registry.json",
|
|
2073
|
-
name,
|
|
2074
|
-
type: `kitn:${type}`,
|
|
2075
|
-
version: "0.1.0",
|
|
2076
|
-
description: "",
|
|
2077
|
-
files: [sourceFile],
|
|
2078
|
-
categories: []
|
|
2079
|
-
};
|
|
2080
|
-
if (type === "tool") {
|
|
2081
|
-
base.dependencies = ["ai", "zod"];
|
|
2082
|
-
} else if (type === "agent" || type === "storage") {
|
|
2083
|
-
base.dependencies = [];
|
|
2084
|
-
}
|
|
2085
|
-
return base;
|
|
2086
|
-
}
|
|
2087
1674
|
function generateAgentSource(name) {
|
|
2088
1675
|
const camel = toCamelCase(name);
|
|
2089
1676
|
return `import { registerAgent } from "@kitn/core";
|
|
@@ -2106,7 +1693,7 @@ import { z } from "zod";
|
|
|
2106
1693
|
|
|
2107
1694
|
export const ${camel} = tool({
|
|
2108
1695
|
description: "",
|
|
2109
|
-
|
|
1696
|
+
inputSchema: z.object({
|
|
2110
1697
|
input: z.string().describe("Input parameter"),
|
|
2111
1698
|
}),
|
|
2112
1699
|
execute: async ({ input }) => {
|
|
@@ -2145,34 +1732,28 @@ export function ${camel}(config?: Record<string, unknown>): StorageProvider {
|
|
|
2145
1732
|
}
|
|
2146
1733
|
`;
|
|
2147
1734
|
}
|
|
2148
|
-
async function
|
|
2149
|
-
try {
|
|
2150
|
-
const { stat: stat2 } = await import("fs/promises");
|
|
2151
|
-
const s = await stat2(path);
|
|
2152
|
-
return s.isDirectory();
|
|
2153
|
-
} catch {
|
|
2154
|
-
return false;
|
|
2155
|
-
}
|
|
2156
|
-
}
|
|
2157
|
-
async function createComponent(type, name, opts) {
|
|
1735
|
+
async function createComponentInProject(type, name, opts) {
|
|
2158
1736
|
if (!VALID_TYPES.includes(type)) {
|
|
2159
1737
|
throw new Error(
|
|
2160
1738
|
`Invalid component type: "${type}". Valid types: ${VALID_TYPES.join(", ")}`
|
|
2161
1739
|
);
|
|
2162
1740
|
}
|
|
2163
1741
|
const cwd = opts?.cwd ?? process.cwd();
|
|
2164
|
-
const
|
|
2165
|
-
if (
|
|
2166
|
-
throw new Error(
|
|
1742
|
+
const config = await readConfig(cwd);
|
|
1743
|
+
if (!config) {
|
|
1744
|
+
throw new Error(
|
|
1745
|
+
`No kitn.json found in ${cwd}. Run ${pc7.bold("kitn init")} first.`
|
|
1746
|
+
);
|
|
2167
1747
|
}
|
|
2168
|
-
await mkdir6(dir, { recursive: true });
|
|
2169
1748
|
const validType = type;
|
|
2170
|
-
const
|
|
2171
|
-
const
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
)
|
|
1749
|
+
const kitnType = typeToKitnType[validType];
|
|
1750
|
+
const fileName = validType === "skill" ? `${name}.md` : `${name}.ts`;
|
|
1751
|
+
const filePath = join11(cwd, getInstallPath(config, kitnType, fileName));
|
|
1752
|
+
const dummyContent = "";
|
|
1753
|
+
const status = await checkFileStatus(filePath, dummyContent);
|
|
1754
|
+
if (status !== "new" /* New */) {
|
|
1755
|
+
throw new Error(`File already exists: ${filePath}`);
|
|
1756
|
+
}
|
|
2176
1757
|
let source;
|
|
2177
1758
|
switch (validType) {
|
|
2178
1759
|
case "agent":
|
|
@@ -2188,31 +1769,59 @@ async function createComponent(type, name, opts) {
|
|
|
2188
1769
|
source = generateStorageSource(name);
|
|
2189
1770
|
break;
|
|
2190
1771
|
}
|
|
2191
|
-
await
|
|
2192
|
-
|
|
1772
|
+
await writeComponentFile(filePath, source);
|
|
1773
|
+
let barrelUpdated = false;
|
|
1774
|
+
if (BARREL_TYPES.includes(validType)) {
|
|
1775
|
+
const baseDir = config.aliases.base ?? "src/ai";
|
|
1776
|
+
const barrelPath = join11(cwd, baseDir, "index.ts");
|
|
1777
|
+
let barrelContent;
|
|
1778
|
+
if (existsSync3(barrelPath)) {
|
|
1779
|
+
barrelContent = await readFile8(barrelPath, "utf-8");
|
|
1780
|
+
} else {
|
|
1781
|
+
barrelContent = createBarrelFile();
|
|
1782
|
+
await mkdir5(join11(cwd, baseDir), { recursive: true });
|
|
1783
|
+
}
|
|
1784
|
+
const importPath = "./" + relative4(join11(cwd, baseDir), filePath).replace(/\.ts$/, ".js");
|
|
1785
|
+
const updatedBarrel = addImportToBarrel(barrelContent, importPath);
|
|
1786
|
+
if (updatedBarrel !== barrelContent) {
|
|
1787
|
+
await writeFile9(barrelPath, updatedBarrel);
|
|
1788
|
+
barrelUpdated = true;
|
|
1789
|
+
}
|
|
1790
|
+
}
|
|
1791
|
+
return { filePath, barrelUpdated };
|
|
2193
1792
|
}
|
|
2194
1793
|
async function createCommand(type, name) {
|
|
2195
|
-
|
|
1794
|
+
p8.intro(pc7.bgCyan(pc7.black(" kitn create ")));
|
|
2196
1795
|
try {
|
|
2197
|
-
const {
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
|
|
1796
|
+
const { filePath, barrelUpdated } = await createComponentInProject(type, name);
|
|
1797
|
+
p8.log.success(`Created ${pc7.bold(type)} component ${pc7.cyan(name)}`);
|
|
1798
|
+
p8.log.message(` ${pc7.green("+")} ${filePath}`);
|
|
1799
|
+
if (barrelUpdated) {
|
|
1800
|
+
p8.log.message(` ${pc7.green("+")} barrel file updated`);
|
|
2201
1801
|
}
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
`Edit ${pc8.cyan(`${name}/${editFile}`)}, then run ${pc8.bold("kitn build")}`
|
|
1802
|
+
p8.outro(
|
|
1803
|
+
`Edit ${pc7.cyan(filePath)} to customize your ${type}.`
|
|
2205
1804
|
);
|
|
2206
1805
|
} catch (err) {
|
|
2207
|
-
|
|
1806
|
+
p8.log.error(err.message);
|
|
2208
1807
|
process.exit(1);
|
|
2209
1808
|
}
|
|
2210
1809
|
}
|
|
2211
|
-
var VALID_TYPES;
|
|
1810
|
+
var VALID_TYPES, typeToKitnType, BARREL_TYPES;
|
|
2212
1811
|
var init_create = __esm({
|
|
2213
1812
|
"src/commands/create.ts"() {
|
|
2214
1813
|
"use strict";
|
|
1814
|
+
init_config();
|
|
1815
|
+
init_file_writer();
|
|
1816
|
+
init_barrel_manager();
|
|
2215
1817
|
VALID_TYPES = ["agent", "tool", "skill", "storage"];
|
|
1818
|
+
typeToKitnType = {
|
|
1819
|
+
agent: "kitn:agent",
|
|
1820
|
+
tool: "kitn:tool",
|
|
1821
|
+
skill: "kitn:skill",
|
|
1822
|
+
storage: "kitn:storage"
|
|
1823
|
+
};
|
|
1824
|
+
BARREL_TYPES = ["agent", "tool", "skill"];
|
|
2216
1825
|
}
|
|
2217
1826
|
});
|
|
2218
1827
|
|
|
@@ -2221,31 +1830,31 @@ var info_exports = {};
|
|
|
2221
1830
|
__export(info_exports, {
|
|
2222
1831
|
infoCommand: () => infoCommand
|
|
2223
1832
|
});
|
|
2224
|
-
import * as
|
|
2225
|
-
import
|
|
1833
|
+
import * as p9 from "@clack/prompts";
|
|
1834
|
+
import pc8 from "picocolors";
|
|
2226
1835
|
async function infoCommand(component) {
|
|
2227
1836
|
const cwd = process.cwd();
|
|
2228
1837
|
const config = await readConfig(cwd);
|
|
2229
1838
|
if (!config) {
|
|
2230
|
-
|
|
1839
|
+
p9.log.error("No kitn.json found. Run `kitn init` first.");
|
|
2231
1840
|
process.exit(1);
|
|
2232
1841
|
}
|
|
2233
1842
|
const ref = parseComponentRef(component);
|
|
2234
1843
|
const fetcher = new RegistryFetcher(config.registries);
|
|
2235
|
-
const s =
|
|
1844
|
+
const s = p9.spinner();
|
|
2236
1845
|
s.start("Fetching component info...");
|
|
2237
1846
|
let index;
|
|
2238
1847
|
try {
|
|
2239
1848
|
index = await fetcher.fetchIndex(ref.namespace);
|
|
2240
1849
|
} catch (err) {
|
|
2241
|
-
s.stop(
|
|
2242
|
-
|
|
1850
|
+
s.stop(pc8.red("Failed to fetch registry"));
|
|
1851
|
+
p9.log.error(err.message);
|
|
2243
1852
|
process.exit(1);
|
|
2244
1853
|
}
|
|
2245
1854
|
const indexItem = index.items.find((i) => i.name === ref.name);
|
|
2246
1855
|
if (!indexItem) {
|
|
2247
|
-
s.stop(
|
|
2248
|
-
|
|
1856
|
+
s.stop(pc8.red("Component not found"));
|
|
1857
|
+
p9.log.error(`Component '${ref.name}' not found in registry.`);
|
|
2249
1858
|
process.exit(1);
|
|
2250
1859
|
}
|
|
2251
1860
|
const dir = typeToDir[indexItem.type];
|
|
@@ -2253,8 +1862,8 @@ async function infoCommand(component) {
|
|
|
2253
1862
|
try {
|
|
2254
1863
|
item = await fetcher.fetchItem(ref.name, dir, ref.namespace, ref.version);
|
|
2255
1864
|
} catch (err) {
|
|
2256
|
-
s.stop(
|
|
2257
|
-
|
|
1865
|
+
s.stop(pc8.red("Failed to fetch component"));
|
|
1866
|
+
p9.log.error(err.message);
|
|
2258
1867
|
process.exit(1);
|
|
2259
1868
|
}
|
|
2260
1869
|
s.stop("Component found");
|
|
@@ -2262,62 +1871,62 @@ async function infoCommand(component) {
|
|
|
2262
1871
|
const typeName = indexItem.type.replace("kitn:", "");
|
|
2263
1872
|
console.log();
|
|
2264
1873
|
console.log(
|
|
2265
|
-
` ${
|
|
1874
|
+
` ${pc8.bold(item.name)} ${pc8.cyan(`v${version}`)}${" ".repeat(Math.max(1, 40 - item.name.length - version.length - 2))}${pc8.dim(ref.namespace)}`
|
|
2266
1875
|
);
|
|
2267
|
-
console.log(` ${
|
|
1876
|
+
console.log(` ${pc8.dim(item.description)}`);
|
|
2268
1877
|
console.log();
|
|
2269
|
-
console.log(` ${
|
|
1878
|
+
console.log(` ${pc8.dim("Type:")} ${typeName}`);
|
|
2270
1879
|
if (item.dependencies?.length) {
|
|
2271
1880
|
console.log(
|
|
2272
|
-
` ${
|
|
1881
|
+
` ${pc8.dim("Dependencies:")} ${item.dependencies.join(", ")}`
|
|
2273
1882
|
);
|
|
2274
1883
|
}
|
|
2275
1884
|
if (item.registryDependencies?.length) {
|
|
2276
1885
|
console.log(
|
|
2277
|
-
` ${
|
|
1886
|
+
` ${pc8.dim("Registry deps:")} ${item.registryDependencies.join(", ")}`
|
|
2278
1887
|
);
|
|
2279
1888
|
}
|
|
2280
1889
|
if (item.categories?.length) {
|
|
2281
1890
|
console.log(
|
|
2282
|
-
` ${
|
|
1891
|
+
` ${pc8.dim("Categories:")} ${item.categories.join(", ")}`
|
|
2283
1892
|
);
|
|
2284
1893
|
}
|
|
2285
1894
|
if (item.updatedAt) {
|
|
2286
|
-
console.log(` ${
|
|
1895
|
+
console.log(` ${pc8.dim("Updated:")} ${item.updatedAt}`);
|
|
2287
1896
|
}
|
|
2288
1897
|
const versions = indexItem.versions;
|
|
2289
1898
|
if (versions?.length) {
|
|
2290
|
-
console.log(` ${
|
|
1899
|
+
console.log(` ${pc8.dim("Versions:")} ${versions.join(", ")}`);
|
|
2291
1900
|
}
|
|
2292
1901
|
if (item.changelog?.length) {
|
|
2293
1902
|
console.log();
|
|
2294
|
-
console.log(` ${
|
|
1903
|
+
console.log(` ${pc8.bold("Changelog:")}`);
|
|
2295
1904
|
for (const entry of item.changelog) {
|
|
2296
|
-
const tag = entry.type === "feature" ?
|
|
1905
|
+
const tag = entry.type === "feature" ? pc8.green(entry.type) : entry.type === "fix" ? pc8.yellow(entry.type) : entry.type === "breaking" ? pc8.red(entry.type) : pc8.dim(entry.type);
|
|
2297
1906
|
console.log(
|
|
2298
|
-
` ${
|
|
1907
|
+
` ${pc8.cyan(entry.version)} ${pc8.dim(entry.date)} ${tag} ${entry.note}`
|
|
2299
1908
|
);
|
|
2300
1909
|
}
|
|
2301
1910
|
}
|
|
2302
1911
|
console.log();
|
|
2303
1912
|
const fileCount = item.files.length;
|
|
2304
|
-
console.log(` ${
|
|
1913
|
+
console.log(` ${pc8.bold(`Files:`)} ${pc8.dim(`(${fileCount})`)}`);
|
|
2305
1914
|
const maxShown = 10;
|
|
2306
1915
|
for (const file of item.files.slice(0, maxShown)) {
|
|
2307
|
-
console.log(` ${
|
|
1916
|
+
console.log(` ${pc8.dim(file.path)}`);
|
|
2308
1917
|
}
|
|
2309
1918
|
if (fileCount > maxShown) {
|
|
2310
|
-
console.log(` ${
|
|
1919
|
+
console.log(` ${pc8.dim(`... and ${fileCount - maxShown} more`)}`);
|
|
2311
1920
|
}
|
|
2312
1921
|
const installed = config.installed?.[item.name];
|
|
2313
1922
|
if (installed) {
|
|
2314
1923
|
console.log();
|
|
2315
1924
|
console.log(
|
|
2316
|
-
` ${
|
|
1925
|
+
` ${pc8.green("Installed")} ${pc8.dim(`v${installed.version}`)}`
|
|
2317
1926
|
);
|
|
2318
1927
|
if (version !== installed.version) {
|
|
2319
1928
|
console.log(
|
|
2320
|
-
` ${
|
|
1929
|
+
` ${pc8.yellow("Update available:")} ${pc8.dim(`v${installed.version}`)} \u2192 ${pc8.cyan(`v${version}`)}`
|
|
2321
1930
|
);
|
|
2322
1931
|
}
|
|
2323
1932
|
}
|
|
@@ -2338,26 +1947,26 @@ var check_exports = {};
|
|
|
2338
1947
|
__export(check_exports, {
|
|
2339
1948
|
checkCommand: () => checkCommand
|
|
2340
1949
|
});
|
|
2341
|
-
import * as
|
|
2342
|
-
import
|
|
1950
|
+
import * as p10 from "@clack/prompts";
|
|
1951
|
+
import pc9 from "picocolors";
|
|
2343
1952
|
async function checkCommand(currentVersion) {
|
|
2344
|
-
|
|
2345
|
-
|
|
2346
|
-
const s =
|
|
1953
|
+
p10.intro(pc9.bgCyan(pc9.black(" kitn check ")));
|
|
1954
|
+
p10.log.info(`kitn v${currentVersion}`);
|
|
1955
|
+
const s = p10.spinner();
|
|
2347
1956
|
s.start("Checking for updates...");
|
|
2348
1957
|
const latest = await fetchLatestVersion();
|
|
2349
1958
|
if (!latest) {
|
|
2350
|
-
s.stop(
|
|
2351
|
-
|
|
1959
|
+
s.stop(pc9.yellow("Could not reach the npm registry"));
|
|
1960
|
+
p10.outro("Try again later.");
|
|
2352
1961
|
return;
|
|
2353
1962
|
}
|
|
2354
1963
|
if (isNewer(latest, currentVersion)) {
|
|
2355
|
-
s.stop(
|
|
2356
|
-
|
|
1964
|
+
s.stop(pc9.yellow(`Update available: ${currentVersion} \u2192 ${latest}`));
|
|
1965
|
+
p10.log.message(` Run: ${pc9.cyan("npm i -g @kitnai/cli")}`);
|
|
2357
1966
|
} else {
|
|
2358
|
-
s.stop(
|
|
1967
|
+
s.stop(pc9.green("You're on the latest version"));
|
|
2359
1968
|
}
|
|
2360
|
-
|
|
1969
|
+
p10.outro("");
|
|
2361
1970
|
}
|
|
2362
1971
|
var init_check = __esm({
|
|
2363
1972
|
"src/commands/check.ts"() {
|
|
@@ -2373,8 +1982,8 @@ __export(registry_exports, {
|
|
|
2373
1982
|
registryListCommand: () => registryListCommand,
|
|
2374
1983
|
registryRemoveCommand: () => registryRemoveCommand
|
|
2375
1984
|
});
|
|
2376
|
-
import * as
|
|
2377
|
-
import
|
|
1985
|
+
import * as p11 from "@clack/prompts";
|
|
1986
|
+
import pc10 from "picocolors";
|
|
2378
1987
|
async function registryAddCommand(namespace, url, opts = {}) {
|
|
2379
1988
|
const cwd = opts.cwd ?? process.cwd();
|
|
2380
1989
|
const config = await readConfig(cwd);
|
|
@@ -2400,10 +2009,10 @@ async function registryAddCommand(namespace, url, opts = {}) {
|
|
|
2400
2009
|
config.registries[namespace] = url;
|
|
2401
2010
|
}
|
|
2402
2011
|
await writeConfig(cwd, config);
|
|
2403
|
-
|
|
2404
|
-
|
|
2405
|
-
if (opts.homepage)
|
|
2406
|
-
if (opts.description)
|
|
2012
|
+
p11.log.success(`Added registry ${pc10.bold(namespace)}`);
|
|
2013
|
+
p11.log.message(pc10.dim(` ${url}`));
|
|
2014
|
+
if (opts.homepage) p11.log.message(pc10.dim(` Homepage: ${opts.homepage}`));
|
|
2015
|
+
if (opts.description) p11.log.message(pc10.dim(` ${opts.description}`));
|
|
2407
2016
|
}
|
|
2408
2017
|
async function registryRemoveCommand(namespace, opts = {}) {
|
|
2409
2018
|
const cwd = opts.cwd ?? process.cwd();
|
|
@@ -2425,10 +2034,10 @@ async function registryRemoveCommand(namespace, opts = {}) {
|
|
|
2425
2034
|
}
|
|
2426
2035
|
delete config.registries[namespace];
|
|
2427
2036
|
await writeConfig(cwd, config);
|
|
2428
|
-
|
|
2037
|
+
p11.log.success(`Removed registry ${pc10.bold(namespace)}`);
|
|
2429
2038
|
if (affectedComponents.length > 0) {
|
|
2430
|
-
|
|
2431
|
-
` + affectedComponents.map((name) => ` ${
|
|
2039
|
+
p11.log.warn(`${affectedComponents.length} installed component(s) referenced this registry:
|
|
2040
|
+
` + affectedComponents.map((name) => ` ${pc10.yellow("!")} ${name}`).join("\n"));
|
|
2432
2041
|
}
|
|
2433
2042
|
return { affectedComponents };
|
|
2434
2043
|
}
|
|
@@ -2443,15 +2052,15 @@ async function registryListCommand(opts = {}) {
|
|
|
2443
2052
|
return { namespace, url, homepage, description };
|
|
2444
2053
|
});
|
|
2445
2054
|
if (entries.length === 0) {
|
|
2446
|
-
|
|
2055
|
+
p11.log.message(pc10.dim(" No registries configured."));
|
|
2447
2056
|
} else {
|
|
2448
2057
|
const lines = [];
|
|
2449
2058
|
for (const { namespace, url, homepage, description } of entries) {
|
|
2450
|
-
lines.push(` ${
|
|
2059
|
+
lines.push(` ${pc10.bold(namespace.padEnd(16))} ${pc10.dim(url)}`);
|
|
2451
2060
|
if (description) lines.push(` ${" ".repeat(16)} ${description}`);
|
|
2452
|
-
if (homepage) lines.push(` ${" ".repeat(16)} ${
|
|
2061
|
+
if (homepage) lines.push(` ${" ".repeat(16)} ${pc10.dim(homepage)}`);
|
|
2453
2062
|
}
|
|
2454
|
-
|
|
2063
|
+
p11.log.message(lines.join("\n"));
|
|
2455
2064
|
}
|
|
2456
2065
|
return entries;
|
|
2457
2066
|
}
|
|
@@ -2465,7 +2074,7 @@ var init_registry = __esm({
|
|
|
2465
2074
|
// src/index.ts
|
|
2466
2075
|
init_update_check();
|
|
2467
2076
|
import { Command } from "commander";
|
|
2468
|
-
var VERSION = true ? "0.1.
|
|
2077
|
+
var VERSION = true ? "0.1.20" : "0.0.0-dev";
|
|
2469
2078
|
var printUpdateNotice = startUpdateCheck(VERSION);
|
|
2470
2079
|
var program = new Command().name("kitn").description("Install AI agent components from the kitn registry").version(VERSION);
|
|
2471
2080
|
program.command("init").description("Initialize kitn in your project").option("-r, --runtime <runtime>", "runtime to use (bun, node, deno)").option("-b, --base <path>", "base directory for components (default: src/ai)").option("-y, --yes", "accept all defaults without prompting").action(async (opts) => {
|
|
@@ -2492,10 +2101,6 @@ program.command("update").description("Update installed components to latest reg
|
|
|
2492
2101
|
const { updateCommand: updateCommand2 } = await Promise.resolve().then(() => (init_update(), update_exports));
|
|
2493
2102
|
await updateCommand2(components);
|
|
2494
2103
|
});
|
|
2495
|
-
program.command("build").description("Build registry JSON from components with registry.json files").argument("[paths...]", "directories to build (default: scan from cwd)").option("-o, --output <dir>", "output directory", "dist/r").action(async (paths, opts) => {
|
|
2496
|
-
const { buildCommand: buildCommand2 } = await Promise.resolve().then(() => (init_build(), build_exports));
|
|
2497
|
-
await buildCommand2(paths, opts);
|
|
2498
|
-
});
|
|
2499
2104
|
program.command("create").description("Scaffold a new kitn component").argument("<type>", "component type (agent, tool, skill, storage)").argument("<name>", "component name").action(async (type, name) => {
|
|
2500
2105
|
const { createCommand: createCommand2 } = await Promise.resolve().then(() => (init_create(), create_exports));
|
|
2501
2106
|
await createCommand2(type, name);
|