@skaile/workspaces 1.4.0 → 1.6.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/CHANGELOG.md +326 -0
- package/dist/app-sdk/index.js +241 -55
- package/dist/app-sdk/index.js.map +1 -1
- package/dist/app-sdk/src/app.d.ts +55 -4
- package/dist/app-sdk/src/app.d.ts.map +1 -1
- package/dist/app-sdk/src/connection-params.d.ts +117 -0
- package/dist/app-sdk/src/connection-params.d.ts.map +1 -0
- package/dist/app-sdk/src/index.d.ts +3 -2
- package/dist/app-sdk/src/index.d.ts.map +1 -1
- package/dist/app-sdk/src/transport.d.ts +9 -0
- package/dist/app-sdk/src/transport.d.ts.map +1 -1
- package/dist/app-sdk/src/ws-transport.d.ts +18 -2
- package/dist/app-sdk/src/ws-transport.d.ts.map +1 -1
- package/dist/{asset-feeds-NG5TKB3V.js → asset-feeds-T35ELX2O.js} +9 -9
- package/dist/{asset-feeds-NG5TKB3V.js.map → asset-feeds-T35ELX2O.js.map} +1 -1
- package/dist/asset-manager/index.js +11 -6
- package/dist/asset-manager/installer.js +5 -5
- package/dist/asset-manager/src/index.d.ts.map +1 -1
- package/dist/{chunk-BE5KTS2L.js → chunk-2DWXGUZA.js} +2 -2
- package/dist/{chunk-BE5KTS2L.js.map → chunk-2DWXGUZA.js.map} +1 -1
- package/dist/{chunk-XBG2YDQQ.js → chunk-2ZMO4CFG.js} +3 -3
- package/dist/{chunk-XBG2YDQQ.js.map → chunk-2ZMO4CFG.js.map} +1 -1
- package/dist/{chunk-X57AMTAH.js → chunk-3CHARYD4.js} +16 -7
- package/dist/chunk-3CHARYD4.js.map +1 -0
- package/dist/{chunk-LCTRCWBK.js → chunk-6NR2BEIY.js} +4 -4
- package/dist/{chunk-LCTRCWBK.js.map → chunk-6NR2BEIY.js.map} +1 -1
- package/dist/{chunk-JZPEEMIM.js → chunk-BEO6KN7P.js} +5 -5
- package/dist/{chunk-JZPEEMIM.js.map → chunk-BEO6KN7P.js.map} +1 -1
- package/dist/{chunk-AAGD2J4H.js → chunk-CBA2XIBF.js} +33 -15
- package/dist/chunk-CBA2XIBF.js.map +1 -0
- package/dist/{chunk-GWDZW44L.js → chunk-DMG6NJH7.js} +4 -4
- package/dist/{chunk-GWDZW44L.js.map → chunk-DMG6NJH7.js.map} +1 -1
- package/dist/{chunk-HWTQ6HPO.js → chunk-FDE7XRQA.js} +56 -8
- package/dist/chunk-FDE7XRQA.js.map +1 -0
- package/dist/{chunk-26YCXWCU.js → chunk-HY33RMEA.js} +3 -3
- package/dist/{chunk-26YCXWCU.js.map → chunk-HY33RMEA.js.map} +1 -1
- package/dist/chunk-J5TI55E7.js +203 -0
- package/dist/chunk-J5TI55E7.js.map +1 -0
- package/dist/chunk-JIDKX7GC.js +122 -0
- package/dist/chunk-JIDKX7GC.js.map +1 -0
- package/dist/{chunk-BDUANIAR.js → chunk-KEQ4GLVM.js} +3 -3
- package/dist/{chunk-BDUANIAR.js.map → chunk-KEQ4GLVM.js.map} +1 -1
- package/dist/{chunk-DNFIKRO6.js → chunk-KMY7HVQ6.js} +3 -3
- package/dist/{chunk-DNFIKRO6.js.map → chunk-KMY7HVQ6.js.map} +1 -1
- package/dist/{chunk-B6SSXVF2.js → chunk-MZV6WCF3.js} +81 -49
- package/dist/chunk-MZV6WCF3.js.map +1 -0
- package/dist/{chunk-DZCK7GRW.js → chunk-P4VHQA4N.js} +22 -6
- package/dist/chunk-P4VHQA4N.js.map +1 -0
- package/dist/{chunk-OSCJRUKM.js → chunk-RDYOU6N6.js} +2 -2
- package/dist/{chunk-OSCJRUKM.js.map → chunk-RDYOU6N6.js.map} +1 -1
- package/dist/{chunk-77OXU44H.js → chunk-RSYV7XEN.js} +13 -7
- package/dist/chunk-RSYV7XEN.js.map +1 -0
- package/dist/{chunk-OUWNTFDG.js → chunk-UQKYT4V6.js} +38 -6
- package/dist/chunk-UQKYT4V6.js.map +1 -0
- package/dist/chunk-WYGXYGJH.js +688 -0
- package/dist/chunk-WYGXYGJH.js.map +1 -0
- package/dist/{chunk-TJRWGMD2.js → chunk-ZBZQC5R7.js} +3 -3
- package/dist/{chunk-TJRWGMD2.js.map → chunk-ZBZQC5R7.js.map} +1 -1
- package/dist/cli/index.js +259 -192
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/src/commands/catalog.d.ts +18 -0
- package/dist/cli/src/commands/catalog.d.ts.map +1 -1
- package/dist/cli/src/commands/library-cmd.d.ts +2 -2
- package/dist/cli/src/commands/library-cmd.d.ts.map +1 -1
- package/dist/cli/src/commands/library-publish.d.ts +53 -0
- package/dist/cli/src/commands/library-publish.d.ts.map +1 -0
- package/dist/cli/src/commands/preset-cmd.d.ts +6 -0
- package/dist/cli/src/commands/preset-cmd.d.ts.map +1 -1
- package/dist/cli/src/commands/preset-export.d.ts +10 -1
- package/dist/cli/src/commands/preset-export.d.ts.map +1 -1
- package/dist/cli/src/commands/project.d.ts.map +1 -1
- package/dist/cli/src/commands/publish-core.d.ts +75 -0
- package/dist/cli/src/commands/publish-core.d.ts.map +1 -0
- package/dist/cli/src/commands/run.d.ts.map +1 -1
- package/dist/cli/src/commands/source-manifest-publish.d.ts +82 -0
- package/dist/cli/src/commands/source-manifest-publish.d.ts.map +1 -0
- package/dist/cli/src/commands/source-manifest.d.ts +65 -6
- package/dist/cli/src/commands/source-manifest.d.ts.map +1 -1
- package/dist/cli/src/commands/source.d.ts +13 -0
- package/dist/cli/src/commands/source.d.ts.map +1 -1
- package/dist/cli/src/commands/store.d.ts.map +1 -1
- package/dist/cli/src/driver-error.d.ts +12 -0
- package/dist/cli/src/driver-error.d.ts.map +1 -0
- package/dist/cli/src/open-library.d.ts +4 -0
- package/dist/cli/src/open-library.d.ts.map +1 -1
- package/dist/cli/src/store-auth.d.ts +42 -0
- package/dist/cli/src/store-auth.d.ts.map +1 -0
- package/dist/cli/src/store-client.d.ts +20 -22
- package/dist/cli/src/store-client.d.ts.map +1 -1
- package/dist/cli/src/store-publisher.d.ts +91 -0
- package/dist/cli/src/store-publisher.d.ts.map +1 -0
- package/dist/connectors/config.js +5 -5
- package/dist/connectors/index.js +6 -6
- package/dist/core/index.js +4 -4
- package/dist/core/publish-manifest.js +1 -1
- package/dist/core/runtime-assets.js +3 -3
- package/dist/core/src/cache-paths.d.ts +17 -0
- package/dist/core/src/cache-paths.d.ts.map +1 -1
- package/dist/core/src/index.d.ts +2 -2
- package/dist/core/src/index.d.ts.map +1 -1
- package/dist/core/src/publish-manifest.d.ts.map +1 -1
- package/dist/core/src/repo-manager.d.ts +13 -2
- package/dist/core/src/repo-manager.d.ts.map +1 -1
- package/dist/core/src/walker.d.ts +10 -0
- package/dist/core/src/walker.d.ts.map +1 -1
- package/dist/core/workspace-config.js +2 -2
- package/dist/deploy/index.js +4 -4
- package/dist/discovery/index.js +2 -2
- package/dist/discovery/src/discover-manifest.d.ts.map +1 -1
- package/dist/discovery/src/discover.d.ts +17 -4
- package/dist/discovery/src/discover.d.ts.map +1 -1
- package/dist/discovery/src/index.d.ts +1 -1
- package/dist/discovery/src/index.d.ts.map +1 -1
- package/dist/discovery/src/reference-lint.d.ts +7 -0
- package/dist/discovery/src/reference-lint.d.ts.map +1 -1
- package/dist/discovery/src/source-config.d.ts +28 -0
- package/dist/discovery/src/source-config.d.ts.map +1 -1
- package/dist/discovery/src/tree-entries.d.ts.map +1 -1
- package/dist/{ensure-sources-CHC7X7AJ.js → ensure-sources-QDVFUIUP.js} +14 -9
- package/dist/ensure-sources-QDVFUIUP.js.map +1 -0
- package/dist/factory-assets/connectors/box.js +6 -6
- package/dist/factory-assets/connectors/deploy.js +6 -6
- package/dist/factory-assets/connectors/devserver.js +6 -6
- package/dist/factory-assets/connectors/flow/adapter.js +6 -6
- package/dist/factory-assets/connectors/flow/engine.js +4 -4
- package/dist/factory-assets/connectors/flow/run-flow.js +7 -7
- package/dist/factory-assets/connectors/flow.js +6 -6
- package/dist/factory-assets/connectors/git.js +6 -6
- package/dist/factory-assets/connectors/gmail.js +6 -6
- package/dist/factory-assets/connectors/googledrive.js +6 -6
- package/dist/factory-assets/connectors/local.js +6 -6
- package/dist/factory-assets/connectors/mattermost.js +6 -6
- package/dist/factory-assets/connectors/memory.js +6 -6
- package/dist/factory-assets/connectors/minio.js +6 -6
- package/dist/factory-assets/connectors/postgres.js +6 -6
- package/dist/factory-assets/connectors/s3.js +6 -6
- package/dist/factory-assets/connectors/sharepoint.js +6 -6
- package/dist/factory-assets/connectors/sqlite.js +6 -6
- package/dist/factory-assets/connectors/static-server.js +6 -6
- package/dist/factory-assets/connectors/tunnel.js +6 -6
- package/dist/factory-assets/connectors/webdav.js +6 -6
- package/dist/factory-assets/connectors/xstate-store.js +6 -6
- package/dist/factory-assets/connectors/xstate.js +6 -6
- package/dist/{flows-CGOCUNO6.js → flows-MRVXTYWC.js} +3 -3
- package/dist/{flows-CGOCUNO6.js.map → flows-MRVXTYWC.js.map} +1 -1
- package/dist/{helpers-GWG4CYYC.js → helpers-TF7GCBRQ.js} +14 -9
- package/dist/{helpers-GWG4CYYC.js.map → helpers-TF7GCBRQ.js.map} +1 -1
- package/dist/library/index.js +6 -6
- package/dist/library/install.js +4 -4
- package/dist/library/src/index.d.ts +2 -2
- package/dist/library/src/index.d.ts.map +1 -1
- package/dist/library/src/local/local-catalog-source.d.ts +12 -1
- package/dist/library/src/local/local-catalog-source.d.ts.map +1 -1
- package/dist/library/src/sync/manifest-writeback.d.ts +36 -0
- package/dist/library/src/sync/manifest-writeback.d.ts.map +1 -1
- package/dist/library-publish-K5IBE44D.js +249 -0
- package/dist/library-publish-K5IBE44D.js.map +1 -0
- package/dist/{open-library-37PXN6MK.js → open-library-4HMIDK3N.js} +13 -13
- package/dist/{open-library-37PXN6MK.js.map → open-library-4HMIDK3N.js.map} +1 -1
- package/dist/{paths-UVOHWUPY.js → paths-P3DWFUPS.js} +7 -7
- package/dist/{paths-UVOHWUPY.js.map → paths-P3DWFUPS.js.map} +1 -1
- package/dist/{plugin-store-EIMVEH3O.js → plugin-store-S7OMGI7N.js} +6 -6
- package/dist/{plugin-store-EIMVEH3O.js.map → plugin-store-S7OMGI7N.js.map} +1 -1
- package/dist/runner/index.js +8 -8
- package/dist/runner/src/agent.d.ts.map +1 -1
- package/dist/runner/src/capability-registry.d.ts +21 -2
- package/dist/runner/src/capability-registry.d.ts.map +1 -1
- package/dist/sdk/asset-manager.js +11 -6
- package/dist/sdk/core.js +4 -4
- package/dist/sdk/flow.js +4 -4
- package/dist/sdk/index.js +8 -8
- package/dist/sdk/runner.js +8 -8
- package/dist/{setup-DINVR6ZQ.js → setup-2CCS63L6.js} +6 -6
- package/dist/{setup-DINVR6ZQ.js.map → setup-2CCS63L6.js.map} +1 -1
- package/dist/source-LOAM7IIQ.js +30 -0
- package/dist/{source-RXAHIGMD.js.map → source-LOAM7IIQ.js.map} +1 -1
- package/dist/source-manifest-publish-TGVZ6KMC.js +228 -0
- package/dist/source-manifest-publish-TGVZ6KMC.js.map +1 -0
- package/dist/tui/index.js +8 -8
- package/dist/workspace-plugin/adapters/mcp.js +1 -1
- package/dist/workspace-plugin/adapters/omp.js +3 -3
- package/dist/workspace-plugin/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-77OXU44H.js.map +0 -1
- package/dist/chunk-AAGD2J4H.js.map +0 -1
- package/dist/chunk-B6SSXVF2.js.map +0 -1
- package/dist/chunk-BJHZHNKR.js +0 -93
- package/dist/chunk-BJHZHNKR.js.map +0 -1
- package/dist/chunk-DZCK7GRW.js.map +0 -1
- package/dist/chunk-HWTQ6HPO.js.map +0 -1
- package/dist/chunk-OUWNTFDG.js.map +0 -1
- package/dist/chunk-QM2TT2PJ.js +0 -385
- package/dist/chunk-QM2TT2PJ.js.map +0 -1
- package/dist/chunk-X57AMTAH.js.map +0 -1
- package/dist/ensure-sources-CHC7X7AJ.js.map +0 -1
- package/dist/source-RXAHIGMD.js +0 -30
- package/dist/store-client-T3F663YG.js +0 -15
- package/dist/store-client-T3F663YG.js.map +0 -1
package/dist/chunk-QM2TT2PJ.js
DELETED
|
@@ -1,385 +0,0 @@
|
|
|
1
|
-
import { openLibraryManager, createFullRegistry } from './chunk-77OXU44H.js';
|
|
2
|
-
import { logInfo, logWarn, logErr, logOk, S } from './chunk-DNFIKRO6.js';
|
|
3
|
-
import { LocalCatalogSource } from './chunk-HWTQ6HPO.js';
|
|
4
|
-
import { WorkspaceYamlEditor } from './chunk-26YCXWCU.js';
|
|
5
|
-
import { getGlobalCacheDir, sourceCacheKey, sourceShortName, findWorkspaceRoot, workspaceConfigFilename } from './chunk-OUWNTFDG.js';
|
|
6
|
-
import { spawnSync } from 'child_process';
|
|
7
|
-
import { existsSync, mkdirSync, rmSync, renameSync } from 'fs';
|
|
8
|
-
import * as path from 'path';
|
|
9
|
-
import * as p from '@clack/prompts';
|
|
10
|
-
import { Command } from 'commander';
|
|
11
|
-
|
|
12
|
-
// cli/src/commands/source-manifest.ts
|
|
13
|
-
var NOT_WIRED_MSG = "`skaile source manifest *` is scaffolded but not yet wired. Server-side endpoint (`POST /sources/<id>/manifest`) lands in a follow-up PR.";
|
|
14
|
-
function notWired(verb) {
|
|
15
|
-
logErr(`${NOT_WIRED_MSG} (verb: source manifest ${verb})`);
|
|
16
|
-
process.exit(2);
|
|
17
|
-
}
|
|
18
|
-
function addSourceManifestCommands(src) {
|
|
19
|
-
const manifest = src.command("manifest").description("Sidecar manifest lifecycle for a source");
|
|
20
|
-
manifest.command("init <src>").description("Start a sidecar manifest for a source").action(() => notWired("init"));
|
|
21
|
-
manifest.command("edit <src>").description("Open the sidecar manifest in $EDITOR").action(() => notWired("edit"));
|
|
22
|
-
manifest.command("rebuild <src>").description("Re-derive the manifest after an upstream change").option("--merge", "Merge with existing entries instead of overwriting", false).action(() => notWired("rebuild"));
|
|
23
|
-
manifest.command("verify <src>").description("Verify hashes, deps, and schema").option("--strict", "Fail on advisory checks", false).action(() => notWired("verify"));
|
|
24
|
-
manifest.command("publish <src>").description("Register the manifest in the store (provenance=curator)").action(() => notWired("publish"));
|
|
25
|
-
manifest.command("propose <src>").description("Open a PR to upstream with the sidecar manifest").action(() => notWired("propose"));
|
|
26
|
-
manifest.command("yank <src>").description("Retract a published manifest from the remote store").option("--version <v>", "Version to yank").action(() => notWired("yank"));
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
// cli/src/commands/source.ts
|
|
30
|
-
function sourceClonePath(key) {
|
|
31
|
-
return path.join(getGlobalCacheDir(), key);
|
|
32
|
-
}
|
|
33
|
-
var SKAILE_MANIFEST_FILENAME = "skaile.manifest.yaml";
|
|
34
|
-
var LEGACY_SOURCE_CONFIG_FILENAME = ".skaile-source.yaml";
|
|
35
|
-
function indexingHadFailures(result) {
|
|
36
|
-
return result.errors.length > 0;
|
|
37
|
-
}
|
|
38
|
-
function legacySourceConfigHint(dest) {
|
|
39
|
-
const hasLegacy = existsSync(path.join(dest, LEGACY_SOURCE_CONFIG_FILENAME));
|
|
40
|
-
const hasManifest = existsSync(path.join(dest, SKAILE_MANIFEST_FILENAME));
|
|
41
|
-
if (hasLegacy && !hasManifest) {
|
|
42
|
-
return `This source ships a legacy ${LEGACY_SOURCE_CONFIG_FILENAME} but no ${SKAILE_MANIFEST_FILENAME}; its declared publisher is ignored and assets are published under their first path segment. Add a ${SKAILE_MANIFEST_FILENAME} (\`skaile source manifest init\`) to set the publisher and asset inventory.`;
|
|
43
|
-
}
|
|
44
|
-
return void 0;
|
|
45
|
-
}
|
|
46
|
-
function normalizeSourceUrl(input) {
|
|
47
|
-
const s = input.trim();
|
|
48
|
-
if (/^(?:https?|git|ssh|file):\/\//.test(s) || /^git@/.test(s)) return s;
|
|
49
|
-
const repo = s.replace(/\.git$/, "");
|
|
50
|
-
if (/^[\w.-]+\/[\w.-]+$/.test(repo)) return `git@github.com:${repo}.git`;
|
|
51
|
-
if (/^[\w.-]+$/.test(repo)) return `git@github.com:skaile-ai/${repo}.git`;
|
|
52
|
-
return s;
|
|
53
|
-
}
|
|
54
|
-
function sourceMatchesKey(entry, key) {
|
|
55
|
-
if (entry.url === key) return true;
|
|
56
|
-
if (sourceCacheKey(entry.url) === key || sourceShortName(entry.url) === key) return true;
|
|
57
|
-
return entry.url === normalizeSourceUrl(key);
|
|
58
|
-
}
|
|
59
|
-
function findCacheKeyCollision(sources, url) {
|
|
60
|
-
const key = sourceCacheKey(url);
|
|
61
|
-
return sources.find((s) => s.url !== url && sourceCacheKey(s.url) === key);
|
|
62
|
-
}
|
|
63
|
-
function requireProjectYamlPath() {
|
|
64
|
-
const root = findWorkspaceRoot(process.cwd());
|
|
65
|
-
if (!root) {
|
|
66
|
-
logErr(
|
|
67
|
-
"No skaile.yaml found in the current directory or any parent. Run `skaile init` first."
|
|
68
|
-
);
|
|
69
|
-
process.exit(1);
|
|
70
|
-
}
|
|
71
|
-
return path.join(root, workspaceConfigFilename());
|
|
72
|
-
}
|
|
73
|
-
function readProjectSources(yamlPath) {
|
|
74
|
-
if (!existsSync(yamlPath)) return [];
|
|
75
|
-
try {
|
|
76
|
-
return WorkspaceYamlEditor.load(yamlPath).getSources();
|
|
77
|
-
} catch (err) {
|
|
78
|
-
logErr(`Could not read ${yamlPath}: ${err instanceof Error ? err.message : String(err)}`);
|
|
79
|
-
process.exit(1);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
function ensureClone(entry, opts = {}) {
|
|
83
|
-
const dest = sourceClonePath(sourceCacheKey(entry.url));
|
|
84
|
-
let backup;
|
|
85
|
-
if (existsSync(dest)) {
|
|
86
|
-
if (!opts.force) return false;
|
|
87
|
-
backup = `${dest}.bak`;
|
|
88
|
-
rmSync(backup, { recursive: true, force: true });
|
|
89
|
-
renameSync(dest, backup);
|
|
90
|
-
}
|
|
91
|
-
mkdirSync(path.dirname(dest), { recursive: true });
|
|
92
|
-
const args = ["clone", entry.url, dest];
|
|
93
|
-
if (entry.pin) args.splice(1, 0, "--branch", entry.pin);
|
|
94
|
-
const clone = spawnSync("git", args, { stdio: "inherit" });
|
|
95
|
-
if (clone.status !== 0) {
|
|
96
|
-
if (backup) {
|
|
97
|
-
rmSync(dest, { recursive: true, force: true });
|
|
98
|
-
renameSync(backup, dest);
|
|
99
|
-
}
|
|
100
|
-
logErr(`git clone failed for ${entry.url}`);
|
|
101
|
-
process.exit(1);
|
|
102
|
-
}
|
|
103
|
-
if (backup) rmSync(backup, { recursive: true, force: true });
|
|
104
|
-
return true;
|
|
105
|
-
}
|
|
106
|
-
async function refreshManifestCache(entry, includeDev = false) {
|
|
107
|
-
const { manager, library, close } = await openLibraryManager();
|
|
108
|
-
try {
|
|
109
|
-
const name = sourceShortName(entry.url);
|
|
110
|
-
const dest = sourceClonePath(sourceCacheKey(entry.url));
|
|
111
|
-
const existing = (await manager.listLibraries()).find((l) => l.name === name);
|
|
112
|
-
const lib = existing ?? await manager.addLibrary({
|
|
113
|
-
name,
|
|
114
|
-
path: dest,
|
|
115
|
-
backend: "git",
|
|
116
|
-
backendConfig: { url: entry.url, branch: entry.pin ?? "main", authHint: "ssh" },
|
|
117
|
-
ownership: "reader"
|
|
118
|
-
});
|
|
119
|
-
const catalog = new LocalCatalogSource(library, lib.id, dest, createFullRegistry());
|
|
120
|
-
const result = await catalog.sync({ includeDev });
|
|
121
|
-
await library.syncSource(lib.id);
|
|
122
|
-
return result;
|
|
123
|
-
} finally {
|
|
124
|
-
close();
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
async function autoSyncForSearch(projectDir) {
|
|
128
|
-
const root = findWorkspaceRoot(projectDir);
|
|
129
|
-
if (!root) return false;
|
|
130
|
-
if (readProjectSources(path.join(root, workspaceConfigFilename())).length === 0) return false;
|
|
131
|
-
logInfo("sources not synced \u2014 syncing now\u2026");
|
|
132
|
-
const { synced } = await syncProjectSources(projectDir);
|
|
133
|
-
return synced > 0;
|
|
134
|
-
}
|
|
135
|
-
async function syncProjectSources(projectDir, opts = {}) {
|
|
136
|
-
const root = findWorkspaceRoot(projectDir) ?? projectDir;
|
|
137
|
-
const sources = readProjectSources(path.join(root, workspaceConfigFilename()));
|
|
138
|
-
let synced = 0;
|
|
139
|
-
let failed = 0;
|
|
140
|
-
for (const entry of sources) {
|
|
141
|
-
const slug = sourceShortName(entry.url);
|
|
142
|
-
const dest = sourceClonePath(sourceCacheKey(entry.url));
|
|
143
|
-
try {
|
|
144
|
-
if (!existsSync(dest)) {
|
|
145
|
-
mkdirSync(path.dirname(dest), { recursive: true });
|
|
146
|
-
const args = ["clone", entry.url, dest];
|
|
147
|
-
if (entry.pin) args.splice(1, 0, "--branch", entry.pin);
|
|
148
|
-
const clone = spawnSync("git", args, { stdio: "ignore" });
|
|
149
|
-
if (clone.status !== 0) {
|
|
150
|
-
logWarn(`${slug}: git clone failed, skipping.`);
|
|
151
|
-
failed++;
|
|
152
|
-
continue;
|
|
153
|
-
}
|
|
154
|
-
} else {
|
|
155
|
-
const pull = spawnSync("git", ["pull", "--ff-only"], { cwd: dest, stdio: "ignore" });
|
|
156
|
-
if (pull.status !== 0) {
|
|
157
|
-
logWarn(`${slug}: git pull failed, skipping manifest refresh.`);
|
|
158
|
-
failed++;
|
|
159
|
-
continue;
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
const result = await refreshManifestCache(entry, opts.dev);
|
|
163
|
-
for (const err of result.errors) logWarn(`${slug}: ${err}`);
|
|
164
|
-
synced++;
|
|
165
|
-
} catch (err) {
|
|
166
|
-
logWarn(`${slug}: sync failed \u2014 ${err instanceof Error ? err.message : String(err)}`);
|
|
167
|
-
failed++;
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
return { total: sources.length, synced, failed };
|
|
171
|
-
}
|
|
172
|
-
async function dropManifestCache(url, purgeClone) {
|
|
173
|
-
const name = sourceShortName(url);
|
|
174
|
-
const { manager, close } = await openLibraryManager();
|
|
175
|
-
try {
|
|
176
|
-
const existing = (await manager.listLibraries()).find((l) => l.name === name);
|
|
177
|
-
if (existing) {
|
|
178
|
-
await manager.removeLibrary(name, { purge: false });
|
|
179
|
-
}
|
|
180
|
-
} finally {
|
|
181
|
-
close();
|
|
182
|
-
}
|
|
183
|
-
if (purgeClone) {
|
|
184
|
-
const dest = sourceClonePath(sourceCacheKey(url));
|
|
185
|
-
if (existsSync(dest)) rmSync(dest, { recursive: true, force: true });
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
function makeSourceCommand() {
|
|
189
|
-
const cmd = new Command("source").description(
|
|
190
|
-
"Manage github sources for the current project (recorded in skaile.yaml)"
|
|
191
|
-
);
|
|
192
|
-
cmd.command("add <source>").description(
|
|
193
|
-
"Clone a github repo and register it in this project's skaile.yaml. <source> may be a full git URL, an owner/repo shorthand, or a bare name (\u2192 git@github.com:skaile-ai/<name>.git)."
|
|
194
|
-
).option("--name <slug>", "[deprecated] no-op \u2014 the source entry stores only the URL").option("--pin <ref>", "Pin a branch, tag, or 40-char SHA").option("--branch <branch>", "[deprecated] alias for --pin").option("--force", "Remove an existing clone and re-clone", false).option("--dev", "Also index dev-only assets under the source's dev_paths", false).action(
|
|
195
|
-
async (source, opts) => {
|
|
196
|
-
const url = normalizeSourceUrl(source);
|
|
197
|
-
const yamlPath = requireProjectYamlPath();
|
|
198
|
-
const collision = findCacheKeyCollision(readProjectSources(yamlPath), url);
|
|
199
|
-
if (collision) {
|
|
200
|
-
logErr(
|
|
201
|
-
`"${url}" maps to the same cache key (${sourceCacheKey(url)}) as already-registered "${collision.url}". Remove that source first (skaile source remove) or re-use its exact URL to update it.`
|
|
202
|
-
);
|
|
203
|
-
process.exitCode = 1;
|
|
204
|
-
return;
|
|
205
|
-
}
|
|
206
|
-
if (opts.name) {
|
|
207
|
-
logWarn(
|
|
208
|
-
"the --name flag is deprecated; the source entry now stores only the URL (the cache slug is derived from it)."
|
|
209
|
-
);
|
|
210
|
-
}
|
|
211
|
-
const pin = opts.pin ?? opts.branch;
|
|
212
|
-
const slug = sourceShortName(url);
|
|
213
|
-
const entry = { url };
|
|
214
|
-
if (pin) entry.pin = pin;
|
|
215
|
-
const dest = sourceClonePath(sourceCacheKey(url));
|
|
216
|
-
const preexisting = existsSync(dest);
|
|
217
|
-
const cloned = ensureClone(entry, { force: opts.force });
|
|
218
|
-
if (!cloned) {
|
|
219
|
-
logOk(`Reusing cached clone at ${dest}`);
|
|
220
|
-
} else if (preexisting) {
|
|
221
|
-
logOk(`Re-cloned ${url} \u2192 ${dest}`);
|
|
222
|
-
} else {
|
|
223
|
-
logOk(`Cloned ${url} \u2192 ${dest}`);
|
|
224
|
-
}
|
|
225
|
-
const editor = WorkspaceYamlEditor.load(yamlPath);
|
|
226
|
-
editor.setSource(entry);
|
|
227
|
-
editor.save();
|
|
228
|
-
const result = await refreshManifestCache(entry, opts.dev);
|
|
229
|
-
const failed = indexingHadFailures(result);
|
|
230
|
-
const indexedMsg = `Indexed ${result.assetsUpdated} of ${result.assetsFound} asset(s) from "${slug}".`;
|
|
231
|
-
if (failed) {
|
|
232
|
-
logWarn(indexedMsg);
|
|
233
|
-
} else {
|
|
234
|
-
logOk(indexedMsg);
|
|
235
|
-
}
|
|
236
|
-
for (const err of result.errors) logWarn(err);
|
|
237
|
-
const legacyHint = legacySourceConfigHint(dest);
|
|
238
|
-
if (legacyHint) logWarn(legacyHint);
|
|
239
|
-
const where = path.relative(process.cwd(), yamlPath);
|
|
240
|
-
if (failed) {
|
|
241
|
-
logWarn(
|
|
242
|
-
`Source "${slug}" registered in ${where}, but ${result.errors.length} asset(s) failed to index (see above). Fix the cause, then re-run \`skaile source sync ${slug}\`.`
|
|
243
|
-
);
|
|
244
|
-
process.exitCode = 1;
|
|
245
|
-
} else {
|
|
246
|
-
logOk(`Source "${slug}" registered in ${where}.`);
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
);
|
|
250
|
-
cmd.command("list").description("List sources registered in this project's skaile.yaml").option("--json", "Output as JSON").action(async (opts) => {
|
|
251
|
-
const yamlPath = requireProjectYamlPath();
|
|
252
|
-
const sources = readProjectSources(yamlPath);
|
|
253
|
-
if (opts.json) return console.log(JSON.stringify(sources, null, 2));
|
|
254
|
-
if (sources.length === 0) {
|
|
255
|
-
logInfo("No sources in skaile.yaml. Run `skaile source add <git-url>` to register one.");
|
|
256
|
-
return;
|
|
257
|
-
}
|
|
258
|
-
console.log();
|
|
259
|
-
console.log(S.heading(" Sources"));
|
|
260
|
-
for (const s of sources) {
|
|
261
|
-
const slug = sourceShortName(s.url);
|
|
262
|
-
const cached = existsSync(sourceClonePath(sourceCacheKey(s.url))) ? "" : S.warn(" (not cached)");
|
|
263
|
-
console.log(` ${S.cmd(slug.padEnd(24))} ${S.dim(s.url)}${cached}`);
|
|
264
|
-
}
|
|
265
|
-
console.log(`
|
|
266
|
-
${S.dim(`${sources.length} source(s)`)}
|
|
267
|
-
`);
|
|
268
|
-
});
|
|
269
|
-
cmd.command("show <name-or-url>").description("Show details for a source (matched by URL or derived slug)").action(async (key) => {
|
|
270
|
-
const yamlPath = requireProjectYamlPath();
|
|
271
|
-
const entry = readProjectSources(yamlPath).find((s) => sourceMatchesKey(s, key));
|
|
272
|
-
if (!entry) {
|
|
273
|
-
logErr(`No source matching "${key}" in ${yamlPath}.`);
|
|
274
|
-
process.exit(1);
|
|
275
|
-
}
|
|
276
|
-
const slug = sourceShortName(entry.url);
|
|
277
|
-
const clonePath = sourceClonePath(sourceCacheKey(entry.url));
|
|
278
|
-
console.log(
|
|
279
|
-
JSON.stringify(
|
|
280
|
-
{
|
|
281
|
-
...entry,
|
|
282
|
-
slug,
|
|
283
|
-
clonePath,
|
|
284
|
-
cached: existsSync(clonePath)
|
|
285
|
-
},
|
|
286
|
-
null,
|
|
287
|
-
2
|
|
288
|
-
)
|
|
289
|
-
);
|
|
290
|
-
});
|
|
291
|
-
cmd.command("remove <name-or-url>").description("Remove a source from this project's skaile.yaml (matched by URL or slug)").option("--purge", "Also delete the cached clone from ~/.skaile/cache/sources/", false).action(async (key, opts) => {
|
|
292
|
-
const yamlPath = requireProjectYamlPath();
|
|
293
|
-
const editor = WorkspaceYamlEditor.load(yamlPath);
|
|
294
|
-
const match = editor.getSources().find((s) => sourceMatchesKey(s, key));
|
|
295
|
-
if (!match) {
|
|
296
|
-
logErr(`No source matching "${key}" in ${yamlPath}.`);
|
|
297
|
-
process.exit(1);
|
|
298
|
-
}
|
|
299
|
-
const slug = sourceShortName(match.url);
|
|
300
|
-
editor.removeSource(match.url);
|
|
301
|
-
editor.save();
|
|
302
|
-
await dropManifestCache(match.url, opts.purge);
|
|
303
|
-
logOk(
|
|
304
|
-
opts.purge ? `Removed source "${slug}" and purged its clone.` : `Removed source "${slug}" from skaile.yaml (clone left in ~/.skaile/cache/sources/).`
|
|
305
|
-
);
|
|
306
|
-
});
|
|
307
|
-
cmd.command("sync [name]").description("Pull upstream changes and refresh the manifest cache").option("--dev", "Also index dev-only assets under each source's dev_paths", false).option("--all", "Sync every source without prompting", false).action(async (key, opts) => {
|
|
308
|
-
const yamlPath = requireProjectYamlPath();
|
|
309
|
-
const sources = readProjectSources(yamlPath);
|
|
310
|
-
if (sources.length === 0) {
|
|
311
|
-
logInfo("No sources in skaile.yaml.");
|
|
312
|
-
return;
|
|
313
|
-
}
|
|
314
|
-
let targets;
|
|
315
|
-
if (key) {
|
|
316
|
-
targets = sources.filter((s) => sourceMatchesKey(s, key));
|
|
317
|
-
if (targets.length === 0) {
|
|
318
|
-
logInfo(`No source matching "${key}".`);
|
|
319
|
-
return;
|
|
320
|
-
}
|
|
321
|
-
} else if (opts.all || sources.length === 1 || !process.stdin.isTTY) {
|
|
322
|
-
targets = sources;
|
|
323
|
-
} else {
|
|
324
|
-
const selected = await p.multiselect({
|
|
325
|
-
message: "Select sources to sync",
|
|
326
|
-
options: sources.map((s) => ({
|
|
327
|
-
value: s.url,
|
|
328
|
-
label: sourceShortName(s.url),
|
|
329
|
-
hint: s.url
|
|
330
|
-
})),
|
|
331
|
-
required: true
|
|
332
|
-
});
|
|
333
|
-
if (p.isCancel(selected)) {
|
|
334
|
-
p.cancel("Cancelled.");
|
|
335
|
-
return;
|
|
336
|
-
}
|
|
337
|
-
const picked = new Set(selected);
|
|
338
|
-
targets = sources.filter((s) => picked.has(s.url));
|
|
339
|
-
}
|
|
340
|
-
for (const entry of targets) {
|
|
341
|
-
const slug = sourceShortName(entry.url);
|
|
342
|
-
const dest = sourceClonePath(sourceCacheKey(entry.url));
|
|
343
|
-
if (!existsSync(dest)) {
|
|
344
|
-
ensureClone(entry);
|
|
345
|
-
logOk(`${slug}: cloned to ${dest}.`);
|
|
346
|
-
} else {
|
|
347
|
-
const pull = spawnSync("git", ["pull", "--ff-only"], { cwd: dest, stdio: "inherit" });
|
|
348
|
-
if (pull.status !== 0) {
|
|
349
|
-
logWarn(`${slug}: git pull failed, skipping manifest refresh.`);
|
|
350
|
-
continue;
|
|
351
|
-
}
|
|
352
|
-
}
|
|
353
|
-
const result = await refreshManifestCache(entry, opts.dev);
|
|
354
|
-
const failed = indexingHadFailures(result);
|
|
355
|
-
const indexedMsg = `${slug}: indexed ${result.assetsUpdated} of ${result.assetsFound} asset(s).`;
|
|
356
|
-
if (failed) {
|
|
357
|
-
logWarn(indexedMsg);
|
|
358
|
-
process.exitCode = 1;
|
|
359
|
-
} else {
|
|
360
|
-
logOk(indexedMsg);
|
|
361
|
-
}
|
|
362
|
-
for (const err of result.errors) logWarn(`${slug}: ${err}`);
|
|
363
|
-
const legacyHint = legacySourceConfigHint(dest);
|
|
364
|
-
if (legacyHint) logWarn(`${slug}: ${legacyHint}`);
|
|
365
|
-
}
|
|
366
|
-
});
|
|
367
|
-
cmd.command("patch <ref>").description("Extract an asset for editing against the source").action((_ref) => {
|
|
368
|
-
logErr(
|
|
369
|
-
"`skaile source patch` is scaffolded but not yet wired. The patch flow lands in a follow-up PR."
|
|
370
|
-
);
|
|
371
|
-
process.exit(2);
|
|
372
|
-
});
|
|
373
|
-
cmd.command("propose <ref>").description("Open a PR with the patch against the source upstream").action((_ref) => {
|
|
374
|
-
logErr(
|
|
375
|
-
"`skaile source propose` is scaffolded but not yet wired. The propose flow lands in a follow-up PR."
|
|
376
|
-
);
|
|
377
|
-
process.exit(2);
|
|
378
|
-
});
|
|
379
|
-
addSourceManifestCommands(cmd);
|
|
380
|
-
return cmd;
|
|
381
|
-
}
|
|
382
|
-
|
|
383
|
-
export { autoSyncForSearch, findCacheKeyCollision, indexingHadFailures, legacySourceConfigHint, makeSourceCommand, normalizeSourceUrl, sourceClonePath, sourceMatchesKey, syncProjectSources };
|
|
384
|
-
//# sourceMappingURL=chunk-QM2TT2PJ.js.map
|
|
385
|
-
//# sourceMappingURL=chunk-QM2TT2PJ.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../cli/src/commands/source-manifest.ts","../cli/src/commands/source.ts"],"names":[],"mappings":";;;;;;;;;;;;AAeA,IAAM,aAAA,GACJ,2IAAA;AAGF,SAAS,SAAS,IAAA,EAAqB;AACrC,EAAA,MAAA,CAAO,CAAA,EAAG,aAAa,CAAA,wBAAA,EAA2B,IAAI,CAAA,CAAA,CAAG,CAAA;AACzD,EAAA,OAAA,CAAQ,KAAK,CAAC,CAAA;AAChB;AAOO,SAAS,0BAA0B,GAAA,EAAoB;AAC5D,EAAA,MAAM,WAAW,GAAA,CAAI,OAAA,CAAQ,UAAU,CAAA,CAAE,YAAY,yCAAyC,CAAA;AAE9F,EAAA,QAAA,CACG,OAAA,CAAQ,YAAY,CAAA,CACpB,WAAA,CAAY,uCAAuC,EACnD,MAAA,CAAO,MAAM,QAAA,CAAS,MAAM,CAAC,CAAA;AAEhC,EAAA,QAAA,CACG,OAAA,CAAQ,YAAY,CAAA,CACpB,WAAA,CAAY,sCAAsC,EAClD,MAAA,CAAO,MAAM,QAAA,CAAS,MAAM,CAAC,CAAA;AAEhC,EAAA,QAAA,CACG,OAAA,CAAQ,eAAe,CAAA,CACvB,WAAA,CAAY,iDAAiD,CAAA,CAC7D,MAAA,CAAO,SAAA,EAAW,oDAAA,EAAsD,KAAK,CAAA,CAC7E,MAAA,CAAO,MAAM,QAAA,CAAS,SAAS,CAAC,CAAA;AAEnC,EAAA,QAAA,CACG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,CAAA,IAAA,EAAO,OAAO,WAAW,CAAA,UAAA,CAAA;AACpF,MAAA,IAAI,MAAA,EAAQ;AACV,QAAA,OAAA,CAAQ,UAAU,CAAA;AAClB,QAAA,OAAA,CAAQ,QAAA,GAAW,CAAA;AAAA,MACrB,CAAA,MAAO;AACL,QAAA,KAAA,CAAM,UAAU,CAAA;AAAA,MAClB;AACA,MAAA,KAAA,MAAW,GAAA,IAAO,OAAO,MAAA,EAAQ,OAAA,CAAQ,GAAG,IAAI,CAAA,EAAA,EAAK,GAAG,CAAA,CAAE,CAAA;AAC1D,MAAA,MAAM,UAAA,GAAa,uBAAuB,IAAI,CAAA;AAC9C,MAAA,IAAI,YAAY,OAAA,CAAQ,CAAA,EAAG,IAAI,CAAA,EAAA,EAAK,UAAU,CAAA,CAAE,CAAA;AAAA,IAClD;AAAA,EACF,CAAC,CAAA;AAGH,EAAA,GAAA,CACG,OAAA,CAAQ,aAAa,CAAA,CACrB,WAAA,CAAY,iDAAiD,CAAA,CAC7D,MAAA,CAAO,CAAC,IAAA,KAAiB;AACxB,IAAA,MAAA;AAAA,MACE;AAAA,KAEF;AACA,IAAA,OAAA,CAAQ,KAAK,CAAC,CAAA;AAAA,EAChB,CAAC,CAAA;AAEH,EAAA,GAAA,CACG,OAAA,CAAQ,eAAe,CAAA,CACvB,WAAA,CAAY,sDAAsD,CAAA,CAClE,MAAA,CAAO,CAAC,IAAA,KAAiB;AACxB,IAAA,MAAA;AAAA,MACE;AAAA,KAEF;AACA,IAAA,OAAA,CAAQ,KAAK,CAAC,CAAA;AAAA,EAChB,CAAC,CAAA;AAGH,EAAA,yBAAA,CAA0B,GAAG,CAAA;AAE7B,EAAA,OAAO,GAAA;AACT","file":"chunk-QM2TT2PJ.js","sourcesContent":["/**\n * `skaile source manifest …` — sidecar manifest lifecycle, refactored under\n * the `source` noun (was `source sidecar …`).\n *\n * The verbs are stubs for now — the real wiring lands when the publish path\n * through `POST /sources/<id>/manifest` is finalised on the store backend.\n * Each subcommand exits with code 2 plus a clear \"not yet wired\" hint so\n * smoke tests can verify the surface without depending on the server.\n *\n * @docLink cli/commands/source#manifest\n */\n\nimport type { Command } from \"commander\";\nimport { logErr } from \"../helpers.ts\";\n\nconst NOT_WIRED_MSG =\n \"`skaile source manifest *` is scaffolded but not yet wired. \" +\n \"Server-side endpoint (`POST /sources/<id>/manifest`) lands in a follow-up PR.\";\n\nfunction notWired(verb: string): never {\n logErr(`${NOT_WIRED_MSG} (verb: source manifest ${verb})`);\n process.exit(2);\n}\n\n/**\n * Append the `manifest` sub-tree to a `source` command.\n *\n * Called from `makeSourceCommand()` in `source.ts`.\n */\nexport function addSourceManifestCommands(src: Command): void {\n const manifest = src.command(\"manifest\").description(\"Sidecar manifest lifecycle for a source\");\n\n manifest\n .command(\"init <src>\")\n .description(\"Start a sidecar manifest for a source\")\n .action(() => notWired(\"init\"));\n\n manifest\n .command(\"edit <src>\")\n .description(\"Open the sidecar manifest in $EDITOR\")\n .action(() => notWired(\"edit\"));\n\n manifest\n .command(\"rebuild <src>\")\n .description(\"Re-derive the manifest after an upstream change\")\n .option(\"--merge\", \"Merge with existing entries instead of overwriting\", false)\n .action(() => notWired(\"rebuild\"));\n\n manifest\n .command(\"verify <src>\")\n .description(\"Verify hashes, deps, and schema\")\n .option(\"--strict\", \"Fail on advisory checks\", false)\n .action(() => notWired(\"verify\"));\n\n manifest\n .command(\"publish <src>\")\n .description(\"Register the manifest in the store (provenance=curator)\")\n .action(() => notWired(\"publish\"));\n\n manifest\n .command(\"propose <src>\")\n .description(\"Open a PR to upstream with the sidecar manifest\")\n .action(() => notWired(\"propose\"));\n\n manifest\n .command(\"yank <src>\")\n .description(\"Retract a published manifest from the remote store\")\n .option(\"--version <v>\", \"Version to yank\")\n .action(() => notWired(\"yank\"));\n}\n","/**\n * `skaile source …` — manage github sources for the current project.\n *\n * A *source* is a third-party github repo of AI assets. The project's\n * `skaile.yaml` `sources:` array is the source of truth for which sources\n * this project uses. The clone itself lives at\n * `~/.skaile/cache/sources/<host>/<owner>/<repo>/` (machine-global cache, shared\n * across projects, URL-keyed so cross-org repos never collide), and the manifest is\n * mirrored into `~/.skaile/index.db` (machine-global manifest cache).\n *\n * @docLink cli/commands/source\n */\n\nimport { spawnSync } from \"node:child_process\";\nimport { existsSync, mkdirSync, renameSync, rmSync } from \"node:fs\";\nimport * as path from \"node:path\";\nimport {\n findWorkspaceRoot,\n getGlobalCacheDir,\n type SourceEntry,\n sourceCacheKey,\n sourceShortName,\n WorkspaceYamlEditor,\n workspaceConfigFilename,\n} from \"@skaile/workspaces/core\";\nimport { LocalCatalogSource } from \"@skaile/workspaces/library\";\nimport * as p from \"@clack/prompts\";\nimport { Command } from \"commander\";\nimport { logErr, logInfo, logOk, logWarn, S } from \"../helpers.ts\";\nimport { openLibraryManager } from \"../open-library.ts\";\nimport { createFullRegistry } from \"../open-registry.ts\";\nimport { addSourceManifestCommands } from \"./source-manifest.ts\";\n\n/**\n * Clone dir for one source cache key (`<host>/<owner>/<repo>`). Exported for the\n * cache-path regression test. Callers pass `sourceCacheKey(url)`.\n */\nexport function sourceClonePath(key: string): string {\n return path.join(getGlobalCacheDir(), key);\n}\n\nconst SKAILE_MANIFEST_FILENAME = \"skaile.manifest.yaml\";\nconst LEGACY_SOURCE_CONFIG_FILENAME = \".skaile-source.yaml\";\n\n/**\n * Whether a manifest-cache refresh actually failed to index something. Keyed on\n * `errors`, NOT on `assetsUpdated < assetsFound`: the discovery walk counts\n * presets (and other intentionally-not-cataloged kinds) toward `assetsFound` but\n * never upserts them, so a source shipping a `.preset.yaml` would otherwise read\n * as a partial failure — false `! N asset(s) failed to index` + exit 1 — with\n * zero real errors.\n */\nexport function indexingHadFailures(result: { errors: string[] }): boolean {\n return result.errors.length > 0;\n}\n\n/**\n * A clone that ships only the legacy `.skaile-source.yaml` (no\n * `skaile.manifest.yaml`) has its declared `publisher_default` silently ignored\n * — discovery only reads `skaile.manifest.yaml`, so publisher resolution falls\n * back to the first path segment. Surface a hint so the author can fix it.\n */\nexport function legacySourceConfigHint(dest: string): string | undefined {\n const hasLegacy = existsSync(path.join(dest, LEGACY_SOURCE_CONFIG_FILENAME));\n const hasManifest = existsSync(path.join(dest, SKAILE_MANIFEST_FILENAME));\n if (hasLegacy && !hasManifest) {\n return (\n `This source ships a legacy ${LEGACY_SOURCE_CONFIG_FILENAME} but no ` +\n `${SKAILE_MANIFEST_FILENAME}; its declared publisher is ignored and assets ` +\n `are published under their first path segment. Add a ${SKAILE_MANIFEST_FILENAME} ` +\n `(\\`skaile source manifest init\\`) to set the publisher and asset inventory.`\n );\n }\n return undefined;\n}\n\n/**\n * Normalize a `source add` argument into a clonable git URL. Full URLs and\n * scp-style (`git@host:…`) specs pass through unchanged; an `owner/repo`\n * shorthand and a bare repo name expand to GitHub over SSH — a bare name\n * defaults to the `skaile-ai` org (`git@github.com:skaile-ai/<name>.git`).\n */\nexport function normalizeSourceUrl(input: string): string {\n const s = input.trim();\n if (/^(?:https?|git|ssh|file):\\/\\//.test(s) || /^git@/.test(s)) return s;\n const repo = s.replace(/\\.git$/, \"\");\n if (/^[\\w.-]+\\/[\\w.-]+$/.test(repo)) return `git@github.com:${repo}.git`;\n if (/^[\\w.-]+$/.test(repo)) return `git@github.com:skaile-ai/${repo}.git`;\n return s;\n}\n\n/**\n * Match a stored source against a user-supplied key. Mirrors the shortcut\n * expansion `source add` applies (`normalizeSourceUrl`) so any form that `add`\n * accepted — bare name, `owner/repo`, `.git`-suffixed, full URL — also resolves\n * at `sync`/`show`/`remove` time, not just the raw stored URL or derived slug.\n */\nexport function sourceMatchesKey(entry: SourceEntry, key: string): boolean {\n if (entry.url === key) return true;\n if (sourceCacheKey(entry.url) === key || sourceShortName(entry.url) === key) return true;\n return entry.url === normalizeSourceUrl(key);\n}\n\n/**\n * Find an already-registered source that maps to the same cache key as `url`\n * but is stored under a *different* URL string (e.g. the `.git`-suffixed or\n * scp form of the same remote). Two such entries would fight over one clone\n * dir, so `source add` rejects the ambiguity. Returns the colliding entry, or\n * `undefined` when the URL is unique or only matches an exact-string duplicate\n * (which `setSource` updates in place).\n */\nexport function findCacheKeyCollision(\n sources: SourceEntry[],\n url: string,\n): SourceEntry | undefined {\n const key = sourceCacheKey(url);\n return sources.find((s) => s.url !== url && sourceCacheKey(s.url) === key);\n}\n\nfunction requireProjectYamlPath(): string {\n const root = findWorkspaceRoot(process.cwd());\n if (!root) {\n logErr(\n \"No skaile.yaml found in the current directory or any parent. \" + \"Run `skaile init` first.\",\n );\n process.exit(1);\n }\n return path.join(root, workspaceConfigFilename());\n}\n\nfunction readProjectSources(yamlPath: string): SourceEntry[] {\n if (!existsSync(yamlPath)) return [];\n try {\n return WorkspaceYamlEditor.load(yamlPath).getSources();\n } catch (err) {\n logErr(`Could not read ${yamlPath}: ${err instanceof Error ? err.message : String(err)}`);\n process.exit(1);\n }\n}\n\n/**\n * Clone the source if its clone directory does not yet exist. When `force` is\n * set, the existing clone is replaced by a fresh checkout. Returns true when a\n * clone happened. The cache slug is derived from the URL.\n *\n * A `--force` re-clone moves the old clone aside first and only deletes it once\n * the fresh clone succeeds — so a failed re-clone restores the previous clone\n * rather than leaving the source registered with no cache behind it.\n */\nfunction ensureClone(entry: SourceEntry, opts: { force?: boolean } = {}): boolean {\n const dest = sourceClonePath(sourceCacheKey(entry.url));\n let backup: string | undefined;\n if (existsSync(dest)) {\n if (!opts.force) return false;\n backup = `${dest}.bak`;\n rmSync(backup, { recursive: true, force: true });\n renameSync(dest, backup);\n }\n mkdirSync(path.dirname(dest), { recursive: true });\n const args = [\"clone\", entry.url, dest];\n // `pin` may be a branch/tag; pass it as the clone branch when present.\n if (entry.pin) args.splice(1, 0, \"--branch\", entry.pin);\n const clone = spawnSync(\"git\", args, { stdio: \"inherit\" });\n if (clone.status !== 0) {\n if (backup) {\n rmSync(dest, { recursive: true, force: true });\n renameSync(backup, dest);\n }\n logErr(`git clone failed for ${entry.url}`);\n process.exit(1);\n }\n if (backup) rmSync(backup, { recursive: true, force: true });\n return true;\n}\n\n/**\n * Refresh the machine-global manifest cache for `entry` by running discovery\n * and upserting AssetDefinitions into `~/.skaile/index.db`. Creates the\n * libraries-table cache row if missing (ownership: reader = cache state).\n */\nasync function refreshManifestCache(\n entry: SourceEntry,\n includeDev = false,\n): Promise<{\n assetsFound: number;\n assetsUpdated: number;\n errors: string[];\n}> {\n const { manager, library, close } = await openLibraryManager();\n try {\n const name = sourceShortName(entry.url);\n const dest = sourceClonePath(sourceCacheKey(entry.url));\n const existing = (await manager.listLibraries()).find((l) => l.name === name);\n const lib =\n existing ??\n (await manager.addLibrary({\n name,\n path: dest,\n backend: \"git\",\n backendConfig: { url: entry.url, branch: entry.pin ?? \"main\", authHint: \"ssh\" },\n ownership: \"reader\",\n }));\n const catalog = new LocalCatalogSource(library, lib.id, dest, createFullRegistry());\n const result = await catalog.sync({ includeDev });\n await library.syncSource(lib.id);\n return result;\n } finally {\n close();\n }\n}\n\n/**\n * Auto-sync hook for `skaile search` on an unsynced workspace. Clones/pulls and\n * re-indexes every source declared in the project's `skaile.yaml`, then returns\n * whether the manifest cache may have changed (caller re-queries on `true`).\n *\n * Unlike `source sync`, this degrades gracefully — a clone/pull/index failure is\n * logged and skipped (never `process.exit`) so a failed auto-sync falls back to\n * the \"run sync first\" hint rather than killing the search. Returns `false`\n * (silently, no announce) when no sources are declared. Callers must guard\n * air-gapped mode themselves — this always touches the network.\n */\nexport async function autoSyncForSearch(projectDir: string): Promise<boolean> {\n const root = findWorkspaceRoot(projectDir);\n if (!root) return false;\n if (readProjectSources(path.join(root, workspaceConfigFilename())).length === 0) return false;\n\n logInfo(\"sources not synced — syncing now…\");\n const { synced } = await syncProjectSources(projectDir);\n return synced > 0;\n}\n\n/**\n * Clone-or-pull every source declared in the project's `skaile.yaml`, then\n * refresh its manifest cache. Shared by `autoSyncForSearch` and `skaile update`\n * (the latter offers it behind a confirm) so a re-deploy can see upstream\n * commits — `update` re-deploys against the local source cache, which is\n * otherwise frozen at the commit captured when the source was first cloned.\n *\n * Graceful by design: a clone/pull/index failure for one source is logged and\n * skipped (never `process.exit`), so a single bad remote can't abort the run.\n * Existing clones are advanced with `git pull --ff-only` (no `--depth=1`, unlike\n * the installer's `pullRepo`, so it fast-forwards instead of tripping the\n * shallow-divergence path). Returns a count summary for the caller to report.\n */\nexport async function syncProjectSources(\n projectDir: string,\n opts: { dev?: boolean } = {},\n): Promise<{ total: number; synced: number; failed: number }> {\n const root = findWorkspaceRoot(projectDir) ?? projectDir;\n const sources = readProjectSources(path.join(root, workspaceConfigFilename()));\n let synced = 0;\n let failed = 0;\n for (const entry of sources) {\n const slug = sourceShortName(entry.url);\n const dest = sourceClonePath(sourceCacheKey(entry.url));\n try {\n // Quiet git — the sync is a preparatory step; keep progress bars out of\n // the foreground output (spinner / install result).\n if (!existsSync(dest)) {\n mkdirSync(path.dirname(dest), { recursive: true });\n const args = [\"clone\", entry.url, dest];\n if (entry.pin) args.splice(1, 0, \"--branch\", entry.pin);\n const clone = spawnSync(\"git\", args, { stdio: \"ignore\" });\n if (clone.status !== 0) {\n logWarn(`${slug}: git clone failed, skipping.`);\n failed++;\n continue;\n }\n } else {\n const pull = spawnSync(\"git\", [\"pull\", \"--ff-only\"], { cwd: dest, stdio: \"ignore\" });\n if (pull.status !== 0) {\n logWarn(`${slug}: git pull failed, skipping manifest refresh.`);\n failed++;\n continue;\n }\n }\n const result = await refreshManifestCache(entry, opts.dev);\n for (const err of result.errors) logWarn(`${slug}: ${err}`);\n synced++;\n } catch (err) {\n logWarn(`${slug}: sync failed — ${err instanceof Error ? err.message : String(err)}`);\n failed++;\n }\n }\n return { total: sources.length, synced, failed };\n}\n\n/** Remove the libraries-table cache row and (optionally) the clone bytes. */\nasync function dropManifestCache(url: string, purgeClone: boolean): Promise<void> {\n const name = sourceShortName(url);\n const { manager, close } = await openLibraryManager();\n try {\n const existing = (await manager.listLibraries()).find((l) => l.name === name);\n if (existing) {\n await manager.removeLibrary(name, { purge: false });\n }\n } finally {\n close();\n }\n if (purgeClone) {\n const dest = sourceClonePath(sourceCacheKey(url));\n if (existsSync(dest)) rmSync(dest, { recursive: true, force: true });\n }\n}\n\nexport function makeSourceCommand(): Command {\n const cmd = new Command(\"source\").description(\n \"Manage github sources for the current project (recorded in skaile.yaml)\",\n );\n\n // ── source add ──────────────────────────────────────────────────────────\n cmd\n .command(\"add <source>\")\n .description(\n \"Clone a github repo and register it in this project's skaile.yaml. \" +\n \"<source> may be a full git URL, an owner/repo shorthand, or a bare \" +\n \"name (→ git@github.com:skaile-ai/<name>.git).\",\n )\n .option(\"--name <slug>\", \"[deprecated] no-op — the source entry stores only the URL\")\n .option(\"--pin <ref>\", \"Pin a branch, tag, or 40-char SHA\")\n .option(\"--branch <branch>\", \"[deprecated] alias for --pin\")\n .option(\"--force\", \"Remove an existing clone and re-clone\", false)\n .option(\"--dev\", \"Also index dev-only assets under the source's dev_paths\", false)\n .action(\n async (\n source: string,\n opts: {\n name?: string;\n pin?: string;\n branch?: string;\n force?: boolean;\n dev?: boolean;\n },\n ) => {\n const url = normalizeSourceUrl(source);\n const yamlPath = requireProjectYamlPath();\n\n // A different URL string that maps to the same cache key (e.g. the\n // `.git`-suffixed or scp form of an already-registered remote) would\n // fight over one clone dir. setSource only dedupes exact strings, so\n // reject the ambiguous collision here instead of silently shadowing.\n const collision = findCacheKeyCollision(readProjectSources(yamlPath), url);\n if (collision) {\n logErr(\n `\"${url}\" maps to the same cache key (${sourceCacheKey(url)}) as ` +\n `already-registered \"${collision.url}\". Remove that source first ` +\n `(skaile source remove) or re-use its exact URL to update it.`,\n );\n process.exitCode = 1;\n return;\n }\n\n if (opts.name) {\n logWarn(\n \"the --name flag is deprecated; the source entry now stores only the URL \" +\n \"(the cache slug is derived from it).\",\n );\n }\n const pin = opts.pin ?? opts.branch;\n const slug = sourceShortName(url);\n const entry: SourceEntry = { url };\n if (pin) entry.pin = pin;\n\n const dest = sourceClonePath(sourceCacheKey(url));\n const preexisting = existsSync(dest);\n // Clone/validate the repo BEFORE touching skaile.yaml — a failed clone\n // (repo not found, bad URL, network error) hard-exits in ensureClone, so\n // the entry is only ever recorded once the source is known-good.\n const cloned = ensureClone(entry, { force: opts.force });\n if (!cloned) {\n logOk(`Reusing cached clone at ${dest}`);\n } else if (preexisting) {\n logOk(`Re-cloned ${url} → ${dest}`);\n } else {\n logOk(`Cloned ${url} → ${dest}`);\n }\n\n const editor = WorkspaceYamlEditor.load(yamlPath);\n editor.setSource(entry);\n editor.save();\n\n const result = await refreshManifestCache(entry, opts.dev);\n const failed = indexingHadFailures(result);\n const indexedMsg = `Indexed ${result.assetsUpdated} of ${result.assetsFound} asset(s) from \"${slug}\".`;\n if (failed) {\n logWarn(indexedMsg);\n } else {\n logOk(indexedMsg);\n }\n for (const err of result.errors) logWarn(err);\n\n const legacyHint = legacySourceConfigHint(dest);\n if (legacyHint) logWarn(legacyHint);\n\n const where = path.relative(process.cwd(), yamlPath);\n if (failed) {\n // The entry IS recorded in skaile.yaml, but indexing did not fully\n // succeed — don't present it as a clean success.\n logWarn(\n `Source \"${slug}\" registered in ${where}, but ${result.errors.length} ` +\n `asset(s) failed to index (see above). Fix the cause, then re-run ` +\n `\\`skaile source sync ${slug}\\`.`,\n );\n process.exitCode = 1;\n } else {\n logOk(`Source \"${slug}\" registered in ${where}.`);\n }\n },\n );\n\n // ── source list ─────────────────────────────────────────────────────────\n cmd\n .command(\"list\")\n .description(\"List sources registered in this project's skaile.yaml\")\n .option(\"--json\", \"Output as JSON\")\n .action(async (opts: { json?: boolean }) => {\n const yamlPath = requireProjectYamlPath();\n const sources = readProjectSources(yamlPath);\n if (opts.json) return console.log(JSON.stringify(sources, null, 2));\n if (sources.length === 0) {\n logInfo(\"No sources in skaile.yaml. Run `skaile source add <git-url>` to register one.\");\n return;\n }\n console.log();\n console.log(S.heading(\" Sources\"));\n for (const s of sources) {\n const slug = sourceShortName(s.url);\n const cached = existsSync(sourceClonePath(sourceCacheKey(s.url)))\n ? \"\"\n : S.warn(\" (not cached)\");\n console.log(` ${S.cmd(slug.padEnd(24))} ${S.dim(s.url)}${cached}`);\n }\n console.log(`\\n ${S.dim(`${sources.length} source(s)`)}\\n`);\n });\n\n // ── source show ─────────────────────────────────────────────────────────\n cmd\n .command(\"show <name-or-url>\")\n .description(\"Show details for a source (matched by URL or derived slug)\")\n .action(async (key: string) => {\n const yamlPath = requireProjectYamlPath();\n const entry = readProjectSources(yamlPath).find((s) => sourceMatchesKey(s, key));\n if (!entry) {\n logErr(`No source matching \"${key}\" in ${yamlPath}.`);\n process.exit(1);\n }\n const slug = sourceShortName(entry.url);\n const clonePath = sourceClonePath(sourceCacheKey(entry.url));\n console.log(\n JSON.stringify(\n {\n ...entry,\n slug,\n clonePath,\n cached: existsSync(clonePath),\n },\n null,\n 2,\n ),\n );\n });\n\n // ── source remove ───────────────────────────────────────────────────────\n cmd\n .command(\"remove <name-or-url>\")\n .description(\"Remove a source from this project's skaile.yaml (matched by URL or slug)\")\n .option(\"--purge\", \"Also delete the cached clone from ~/.skaile/cache/sources/\", false)\n .action(async (key: string, opts: { purge: boolean }) => {\n const yamlPath = requireProjectYamlPath();\n const editor = WorkspaceYamlEditor.load(yamlPath);\n // Resolve to the stored URL (entries are keyed by url in the editor).\n const match = editor.getSources().find((s) => sourceMatchesKey(s, key));\n if (!match) {\n logErr(`No source matching \"${key}\" in ${yamlPath}.`);\n process.exit(1);\n }\n const slug = sourceShortName(match.url);\n editor.removeSource(match.url);\n editor.save();\n await dropManifestCache(match.url, opts.purge);\n logOk(\n opts.purge\n ? `Removed source \"${slug}\" and purged its clone.`\n : `Removed source \"${slug}\" from skaile.yaml (clone left in ~/.skaile/cache/sources/).`,\n );\n });\n\n // ── source sync ─────────────────────────────────────────────────────────\n cmd\n .command(\"sync [name]\")\n .description(\"Pull upstream changes and refresh the manifest cache\")\n .option(\"--dev\", \"Also index dev-only assets under each source's dev_paths\", false)\n .option(\"--all\", \"Sync every source without prompting\", false)\n .action(async (key: string | undefined, opts: { dev?: boolean; all?: boolean }) => {\n const yamlPath = requireProjectYamlPath();\n const sources = readProjectSources(yamlPath);\n if (sources.length === 0) {\n logInfo(\"No sources in skaile.yaml.\");\n return;\n }\n\n let targets: SourceEntry[];\n if (key) {\n targets = sources.filter((s) => sourceMatchesKey(s, key));\n if (targets.length === 0) {\n logInfo(`No source matching \"${key}\".`);\n return;\n }\n } else if (opts.all || sources.length === 1 || !process.stdin.isTTY) {\n // --all, a single source, or a non-interactive shell: sync everything.\n targets = sources;\n } else {\n const selected = await p.multiselect({\n message: \"Select sources to sync\",\n options: sources.map((s) => ({\n value: s.url,\n label: sourceShortName(s.url),\n hint: s.url,\n })),\n required: true,\n });\n if (p.isCancel(selected)) {\n p.cancel(\"Cancelled.\");\n return;\n }\n const picked = new Set(selected as string[]);\n targets = sources.filter((s) => picked.has(s.url));\n }\n for (const entry of targets) {\n const slug = sourceShortName(entry.url);\n const dest = sourceClonePath(sourceCacheKey(entry.url));\n if (!existsSync(dest)) {\n ensureClone(entry);\n logOk(`${slug}: cloned to ${dest}.`);\n } else {\n const pull = spawnSync(\"git\", [\"pull\", \"--ff-only\"], { cwd: dest, stdio: \"inherit\" });\n if (pull.status !== 0) {\n logWarn(`${slug}: git pull failed, skipping manifest refresh.`);\n continue;\n }\n }\n const result = await refreshManifestCache(entry, opts.dev);\n const failed = indexingHadFailures(result);\n const indexedMsg = `${slug}: indexed ${result.assetsUpdated} of ${result.assetsFound} asset(s).`;\n if (failed) {\n logWarn(indexedMsg);\n process.exitCode = 1;\n } else {\n logOk(indexedMsg);\n }\n for (const err of result.errors) logWarn(`${slug}: ${err}`);\n const legacyHint = legacySourceConfigHint(dest);\n if (legacyHint) logWarn(`${slug}: ${legacyHint}`);\n }\n });\n\n // ── source patch / propose (stubs) ──────────────────────────────────────\n cmd\n .command(\"patch <ref>\")\n .description(\"Extract an asset for editing against the source\")\n .action((_ref: string) => {\n logErr(\n \"`skaile source patch` is scaffolded but not yet wired. \" +\n \"The patch flow lands in a follow-up PR.\",\n );\n process.exit(2);\n });\n\n cmd\n .command(\"propose <ref>\")\n .description(\"Open a PR with the patch against the source upstream\")\n .action((_ref: string) => {\n logErr(\n \"`skaile source propose` is scaffolded but not yet wired. \" +\n \"The propose flow lands in a follow-up PR.\",\n );\n process.exit(2);\n });\n\n // ── source manifest * ───────────────────────────────────────────────────\n addSourceManifestCommands(cmd);\n\n return cmd;\n}\n"]}
|