@ai-primitives-hub/cli 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commands/apply.d.ts.map +1 -1
- package/dist/commands/apply.js +11 -1
- package/dist/commands/apply.js.map +1 -1
- package/dist/commands/bundle-build.d.ts.map +1 -1
- package/dist/commands/bundle-build.js +8 -23
- package/dist/commands/bundle-build.js.map +1 -1
- package/dist/commands/completion.d.ts +24 -1
- package/dist/commands/completion.d.ts.map +1 -1
- package/dist/commands/completion.js +113 -211
- package/dist/commands/completion.js.map +1 -1
- package/dist/commands/doctor.d.ts.map +1 -1
- package/dist/commands/doctor.js +13 -2
- package/dist/commands/doctor.js.map +1 -1
- package/dist/commands/hub-replicate.d.ts +29 -0
- package/dist/commands/hub-replicate.d.ts.map +1 -0
- package/dist/commands/hub-replicate.js +93 -0
- package/dist/commands/hub-replicate.js.map +1 -0
- package/dist/commands/hub.d.ts +8 -0
- package/dist/commands/hub.d.ts.map +1 -1
- package/dist/commands/hub.js +192 -28
- package/dist/commands/hub.js.map +1 -1
- package/dist/commands/index-build.d.ts +1 -0
- package/dist/commands/index-build.d.ts.map +1 -1
- package/dist/commands/index-build.js +4 -0
- package/dist/commands/index-build.js.map +1 -1
- package/dist/commands/index-harvest.d.ts +5 -0
- package/dist/commands/index-harvest.d.ts.map +1 -1
- package/dist/commands/index-harvest.js +37 -12
- package/dist/commands/index-harvest.js.map +1 -1
- package/dist/commands/index-search.d.ts.map +1 -1
- package/dist/commands/index-search.js +2 -2
- package/dist/commands/index-search.js.map +1 -1
- package/dist/commands/init.d.ts +1 -1
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +37 -13
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/install.d.ts +36 -4
- package/dist/commands/install.d.ts.map +1 -1
- package/dist/commands/install.js +327 -48
- package/dist/commands/install.js.map +1 -1
- package/dist/commands/profile.d.ts +11 -6
- package/dist/commands/profile.d.ts.map +1 -1
- package/dist/commands/profile.js +184 -57
- package/dist/commands/profile.js.map +1 -1
- package/dist/commands/registry.d.ts +15 -0
- package/dist/commands/registry.d.ts.map +1 -0
- package/dist/commands/registry.js +117 -0
- package/dist/commands/registry.js.map +1 -0
- package/dist/commands/source.d.ts +3 -0
- package/dist/commands/source.d.ts.map +1 -1
- package/dist/commands/source.js +38 -5
- package/dist/commands/source.js.map +1 -1
- package/dist/commands/uninstall.d.ts.map +1 -1
- package/dist/commands/uninstall.js +8 -5
- package/dist/commands/uninstall.js.map +1 -1
- package/dist/commands/update.d.ts.map +1 -1
- package/dist/commands/update.js +149 -41
- package/dist/commands/update.js.map +1 -1
- package/dist/doctor/diagnostics.d.ts +24 -1
- package/dist/doctor/diagnostics.d.ts.map +1 -1
- package/dist/doctor/diagnostics.js +77 -16
- package/dist/doctor/diagnostics.js.map +1 -1
- package/dist/framework/cli.d.ts.map +1 -1
- package/dist/framework/cli.js +12 -2
- package/dist/framework/cli.js.map +1 -1
- package/dist/framework/command-paths.d.ts +33 -0
- package/dist/framework/command-paths.d.ts.map +1 -0
- package/dist/framework/command-paths.js +45 -0
- package/dist/framework/command-paths.js.map +1 -0
- package/dist/framework/hub-manager.d.ts.map +1 -1
- package/dist/framework/hub-manager.js +19 -1
- package/dist/framework/hub-manager.js.map +1 -1
- package/dist/framework/index.d.ts +1 -0
- package/dist/framework/index.d.ts.map +1 -1
- package/dist/framework/index.js +4 -1
- package/dist/framework/index.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +2 -111
- package/dist/main.js.map +1 -1
- package/package.json +8 -9
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apply.d.ts","sourceRoot":"","sources":["../../src/commands/apply.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,OAAO,KAAK,EACV,UAAU,EACV,aAAa,EACd,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,OAAO,EAKR,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,KAAK,OAAO,EAEZ,KAAK,YAAY,EAElB,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"apply.d.ts","sourceRoot":"","sources":["../../src/commands/apply.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,OAAO,KAAK,EACV,UAAU,EACV,aAAa,EACd,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,OAAO,EAKR,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,KAAK,OAAO,EAEZ,KAAK,YAAY,EAElB,MAAM,cAAc,CAAC;AAOtB;;GAEG;AACH,UAAU,mBAAmB;IAC3B,GAAG,EAAE,OAAO,CAAC;IACb,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,MAAM,CAAC,EAAE,aAAa,CAAC;CACxB;AAED;;GAEG;AACH,qBAAa,YAAa,SAAQ,OAAO;IACvC,gBAAuB,KAAK,aAAe;IAE3C,gBAAuB,KAAK,4BAczB;IAEI,MAAM,EAAsC,YAAY,GAAG,SAAS,CAAC;IACrE,MAAM,UAAsC;IAC5C,cAAc,EAAG,mBAAmB,CAAC;IAE/B,OAAO,IAAI,OAAO,CAAC,MAAM,CAAC;CAgFxC"}
|
package/dist/commands/apply.js
CHANGED
|
@@ -68,7 +68,17 @@ class ApplyCommand extends framework_1.Command {
|
|
|
68
68
|
hint: 'Run `ai-primitives-hub target add <name> --type <kind>` to configure a target.'
|
|
69
69
|
}));
|
|
70
70
|
}
|
|
71
|
-
|
|
71
|
+
let activation;
|
|
72
|
+
try {
|
|
73
|
+
activation = await (0, profile_1.runProfileActivation)(ctx, built, cur.hubId, profile, targets);
|
|
74
|
+
}
|
|
75
|
+
catch (err) {
|
|
76
|
+
if (err instanceof framework_2.RegistryError) {
|
|
77
|
+
return (0, framework_1.failWith)(ctx, fmt, 'apply', err);
|
|
78
|
+
}
|
|
79
|
+
throw err;
|
|
80
|
+
}
|
|
81
|
+
const { state, written, failures } = activation;
|
|
72
82
|
const status = failures.length === 0 ? 'ok' : 'warning';
|
|
73
83
|
(0, framework_2.formatOutput)({
|
|
74
84
|
ctx,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apply.js","sourceRoot":"","sources":["../../src/commands/apply.ts"],"names":[],"mappings":";;;AAyBA,4CAMsB;AACtB,4CAKsB;AACtB,
|
|
1
|
+
{"version":3,"file":"apply.js","sourceRoot":"","sources":["../../src/commands/apply.ts"],"names":[],"mappings":";;;AAyBA,4CAMsB;AACtB,4CAKsB;AACtB,uCAImB;AAWnB;;GAEG;AACH,MAAa,YAAa,SAAQ,mBAAO;IAChC,MAAM,CAAU,KAAK,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC;IAEpC,MAAM,CAAU,KAAK,GAAG,mBAAO,CAAC,KAAK,CAAC;QAC3C,WAAW,EAAE,2EAA2E;QACxF,QAAQ,EAAE,kBAAkB;QAC5B,OAAO,EAAE;;;;;;;;;;KAUR;KACF,CAAC,CAAC;IAEI,MAAM,GAAG,kBAAM,CAAC,MAAM,CAAC,IAAI,EAAE,UAAU,CAA6B,CAAC;IACrE,MAAM,GAAG,kBAAM,CAAC,OAAO,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC;IAC5C,cAAc,CAAuB;IAErC,KAAK,CAAC,OAAO;QAClB,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC,cAAc,CAAC;QAClD,MAAM,GAAG,GAAG,IAAI,CAAC,MAAM,IAAI,MAAM,CAAC;QAClC,MAAM,KAAK,GAAG,IAAA,qBAAW,EAAC,GAAG,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;QAE7C,MAAM,SAAS,GAAG,MAAM,KAAK,CAAC,WAAW,CAAC,OAAO,EAAE,CAAC;QACpD,MAAM,GAAG,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC;QACzB,IAAI,CAAC,GAAG,EAAE,CAAC;YACT,OAAO,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,CAAC,QAAQ,KAAK,CAAC,CAAC,MAAM,MAAM,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS;YAC3G,YAAY,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,iBAAiB,CAAC,CAAC,KAAK,gBAAgB,CAAC,CAAC,SAAS,KAAK;kBACzE,cAAc,CAAC,GAAG,IAAI,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI;kBAChE,cAAc,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI;kBACnD,CAAC,CAAC,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC;oBACtB,CAAC,CAAC,gBAAgB,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,SAAS,CAAC,CAAC,QAAQ,KAAK,CAAC,CAAC,MAAM,MAAM,CAAC,CAAC,MAAM,IAAI,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE;oBACtG,CAAC,CAAC,EAAE,CAAC;SACV,CAAC,CAAC;QACH,OAAO,QAAQ,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACvC,CAAC;;AAtGH,oCAuGC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bundle-build.d.ts","sourceRoot":"","sources":["../../src/commands/bundle-build.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"bundle-build.d.ts","sourceRoot":"","sources":["../../src/commands/bundle-build.ts"],"names":[],"mappings":"AAwCA,OAAO,EACL,OAAO,EACP,KAAK,OAAO,EAGZ,KAAK,YAAY,EAGlB,MAAM,cAAc,CAAC;AA0GtB;;GAEG;AACH,qBAAa,kBAAmB,SAAQ,OAAO;IAC7C,gBAAuB,KAAK,aAAyB;IAErD,gBAAuB,KAAK,4BAazB;IAEI,MAAM,EAAsC,YAAY,GAAG,SAAS,CAAC;IACrE,cAAc,qBAAsC;IACpD,OAAO,qBAA8B;IACrC,MAAM,qBAA8B;IACpC,QAAQ,qBAAgC;IACxC,cAAc,EAAG;QAAE,GAAG,EAAE,OAAO,CAAA;KAAE,CAAC;IAE5B,OAAO,IAAI,OAAO,CAAC,MAAM,CAAC;CA2ExC"}
|
|
@@ -60,9 +60,9 @@ exports.BundleBuildCommand = void 0;
|
|
|
60
60
|
const node_fs_1 = require("node:fs");
|
|
61
61
|
const fs = __importStar(require("node:fs/promises"));
|
|
62
62
|
const path = __importStar(require("node:path"));
|
|
63
|
+
const app_1 = require("@ai-primitives-hub/app");
|
|
63
64
|
const core_1 = require("@ai-primitives-hub/core");
|
|
64
65
|
const infra_1 = require("@ai-primitives-hub/infra");
|
|
65
|
-
const collection_scripts_1 = require("@prompt-registry/collection-scripts");
|
|
66
66
|
const archiver_1 = __importDefault(require("archiver"));
|
|
67
67
|
const framework_1 = require("../framework");
|
|
68
68
|
const bundle_manifest_1 = require("./bundle-manifest");
|
|
@@ -185,26 +185,11 @@ class BundleBuildCommand extends framework_1.Command {
|
|
|
185
185
|
// injected working directories (Context invariant).
|
|
186
186
|
const outDirRel = this.outDir ?? 'dist';
|
|
187
187
|
const outDir = path.isAbsolute(outDirRel) ? outDirRel : path.join(cwd, outDirRel);
|
|
188
|
-
const warnings =
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
collectionFile,
|
|
194
|
-
version
|
|
195
|
-
});
|
|
196
|
-
}
|
|
197
|
-
catch (err) {
|
|
198
|
-
if (!(0, collection_scripts_1.isMissingSourceLicenseError)(err)) {
|
|
199
|
-
throw err;
|
|
200
|
-
}
|
|
201
|
-
releasePlan = (0, collection_scripts_1.createLegacyReleaseManifestPlan)({
|
|
202
|
-
repoRoot: cwd,
|
|
203
|
-
collectionFile,
|
|
204
|
-
version
|
|
205
|
-
});
|
|
206
|
-
warnings.push(collection_scripts_1.LEGACY_RELEASE_WARNING);
|
|
207
|
-
}
|
|
188
|
+
const { plan: releasePlan, warnings } = await (0, app_1.planBundleRelease)({
|
|
189
|
+
repoRoot: cwd,
|
|
190
|
+
collectionFile,
|
|
191
|
+
version
|
|
192
|
+
});
|
|
208
193
|
const collectionId = String(releasePlan.manifest.id);
|
|
209
194
|
if (typeof collectionId !== 'string' || collectionId.length === 0) {
|
|
210
195
|
throw new framework_1.RegistryError({
|
|
@@ -212,11 +197,11 @@ class BundleBuildCommand extends framework_1.Command {
|
|
|
212
197
|
message: 'collection.id is required'
|
|
213
198
|
});
|
|
214
199
|
}
|
|
215
|
-
const bundleId = (0,
|
|
200
|
+
const bundleId = (0, core_1.generateBundleId)(repoSlug, collectionId, version);
|
|
216
201
|
const collectionOutDir = path.join(outDir, collectionId);
|
|
217
202
|
await ctx.fs.mkdir(collectionOutDir, { recursive: true });
|
|
218
203
|
const standaloneManifestPath = path.join(collectionOutDir, 'deployment-manifest.yml');
|
|
219
|
-
const manifestYaml = (0,
|
|
204
|
+
const manifestYaml = (0, core_1.serializeReleaseManifest)(releasePlan.manifest);
|
|
220
205
|
await ctx.fs.writeFile(standaloneManifestPath, manifestYaml);
|
|
221
206
|
const zipPath = path.join(collectionOutDir, `${collectionId}.bundle.zip`);
|
|
222
207
|
await createDeterministicZip({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bundle-build.js","sourceRoot":"","sources":["../../src/commands/bundle-build.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;GAcG;AACH,qEAAqE;AACrE,6EAA6E;AAC7E,4DAA4D;AAC5D,iFAAiF;AACjF,uCAAuC;AACvC,qCAIiB;AACjB,qDAAuC;AACvC,gDAAkC;AAClC,
|
|
1
|
+
{"version":3,"file":"bundle-build.js","sourceRoot":"","sources":["../../src/commands/bundle-build.ts"],"names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AO,EAAE,CAAC,CAAC;AAClF,CAAC,CAAC"}
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* `ai-primitives-hub completion` — shell completion script generator.
|
|
3
3
|
*
|
|
4
|
-
* Generates bash and zsh completion scripts that can be sourced.
|
|
4
|
+
* Generates bash and zsh completion scripts that can be sourced. Both
|
|
5
|
+
* scripts derive their command/subcommand candidates from
|
|
6
|
+
* `getCommandPaths(this)` — the same command registry (`commands/registry.ts`)
|
|
7
|
+
* that clipanion dispatches against — so newly registered commands and
|
|
8
|
+
* subcommands are completed automatically, with no separate list to
|
|
9
|
+
* keep in sync.
|
|
5
10
|
* @module commands/completion
|
|
6
11
|
*/
|
|
7
12
|
import { Command } from '../framework';
|
|
@@ -12,7 +17,25 @@ export declare class CompletionCommand extends Command {
|
|
|
12
17
|
static readonly paths: string[][];
|
|
13
18
|
static readonly usage: import("clipanion").Usage;
|
|
14
19
|
shell: string | undefined;
|
|
20
|
+
/**
|
|
21
|
+
* Generate a bash completion script.
|
|
22
|
+
*
|
|
23
|
+
* The generated script embeds `paths` as a flat array literal and
|
|
24
|
+
* walks it generically at completion time: for the word currently
|
|
25
|
+
* being completed (`cword`), it matches every earlier word against
|
|
26
|
+
* each path's corresponding prefix and offers the next token of any
|
|
27
|
+
* path that matches. This covers every registered command and
|
|
28
|
+
* subcommand at any depth without per-command branches.
|
|
29
|
+
* @param paths Full set of registered command paths.
|
|
30
|
+
*/
|
|
15
31
|
private generateBashCompletion;
|
|
32
|
+
/**
|
|
33
|
+
* Generate a zsh completion script.
|
|
34
|
+
*
|
|
35
|
+
* Uses the same path-matching algorithm as the bash generator,
|
|
36
|
+
* adapted to zsh's 1-based `$words`/`$CURRENT` completion variables.
|
|
37
|
+
* @param paths Full set of registered command paths.
|
|
38
|
+
*/
|
|
16
39
|
private generateZshCompletion;
|
|
17
40
|
execute(): Promise<number | void>;
|
|
18
41
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"completion.d.ts","sourceRoot":"","sources":["../../src/commands/completion.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"completion.d.ts","sourceRoot":"","sources":["../../src/commands/completion.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,EACL,OAAO,EAIR,MAAM,cAAc,CAAC;AAuBtB;;GAEG;AACH,qBAAa,iBAAkB,SAAQ,OAAO;IAC5C,gBAAuB,KAAK,aAAoB;IAEhD,gBAAuB,KAAK,4BAiBzB;IAEI,KAAK,qBAA4B;IAExC;;;;;;;;;;OAUG;IACH,OAAO,CAAC,sBAAsB;IA2C9B;;;;;;OAMG;IACH,OAAO,CAAC,qBAAqB;IA8CtB,OAAO,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;CAmBzC"}
|
|
@@ -4,10 +4,33 @@ exports.CompletionCommand = void 0;
|
|
|
4
4
|
/**
|
|
5
5
|
* `ai-primitives-hub completion` — shell completion script generator.
|
|
6
6
|
*
|
|
7
|
-
* Generates bash and zsh completion scripts that can be sourced.
|
|
7
|
+
* Generates bash and zsh completion scripts that can be sourced. Both
|
|
8
|
+
* scripts derive their command/subcommand candidates from
|
|
9
|
+
* `getCommandPaths(this)` — the same command registry (`commands/registry.ts`)
|
|
10
|
+
* that clipanion dispatches against — so newly registered commands and
|
|
11
|
+
* subcommands are completed automatically, with no separate list to
|
|
12
|
+
* keep in sync.
|
|
8
13
|
* @module commands/completion
|
|
9
14
|
*/
|
|
10
15
|
const framework_1 = require("../framework");
|
|
16
|
+
/**
|
|
17
|
+
* Single-quote `text` for safe embedding in POSIX shell source, escaping
|
|
18
|
+
* any embedded single quotes. Applied to every command-path literal
|
|
19
|
+
* before it is written into a generated (and later sourced) completion
|
|
20
|
+
* script — `defineCommand()` is a public framework API, so a path
|
|
21
|
+
* segment can contain arbitrary text and must never be trusted to be
|
|
22
|
+
* shell-safe on its own.
|
|
23
|
+
* @param text Raw text to embed as a shell string literal.
|
|
24
|
+
* @returns `text` wrapped in single quotes, safe to splice into shell source.
|
|
25
|
+
*/
|
|
26
|
+
const shellQuote = (text) => `'${text.replace(/'/g, String.raw `'\''`)}'`;
|
|
27
|
+
/**
|
|
28
|
+
* Render a flat path list as a shell array literal, one quoted,
|
|
29
|
+
* space-joined path per line (e.g. `'index shortlist new'`).
|
|
30
|
+
* @param paths Command paths, e.g. `[['index', 'search'], ['search']]`.
|
|
31
|
+
* @param indent Leading whitespace applied to each literal line.
|
|
32
|
+
*/
|
|
33
|
+
const renderPathLiterals = (paths, indent) => paths.map((path) => `${indent}${shellQuote(path.join(' '))}`).join('\n');
|
|
11
34
|
/**
|
|
12
35
|
* Completion command class.
|
|
13
36
|
*/
|
|
@@ -17,7 +40,7 @@ class CompletionCommand extends framework_1.Command {
|
|
|
17
40
|
description: 'Generate shell completion script for bash or zsh.',
|
|
18
41
|
category: 'Configure & Debug',
|
|
19
42
|
details: `
|
|
20
|
-
Usage: ai-primitives-hub completion <shell>
|
|
43
|
+
Usage: ai-primitives-hub completion --shell <shell>
|
|
21
44
|
|
|
22
45
|
Generates a shell completion script for the specified shell.
|
|
23
46
|
Output the script to a file and source it in your shell configuration.
|
|
@@ -26,234 +49,112 @@ class CompletionCommand extends framework_1.Command {
|
|
|
26
49
|
--shell <shell> Shell type: bash or zsh (required)
|
|
27
50
|
|
|
28
51
|
Examples:
|
|
29
|
-
ai-primitives-hub completion bash > ~/.local/share/bash-completion/completions/ai-primitives-hub
|
|
30
|
-
ai-primitives-hub completion zsh > ~/.zsh/completion/_ai-primitives-hub
|
|
31
|
-
source <(ai-primitives-hub completion bash)
|
|
52
|
+
ai-primitives-hub completion --shell bash > ~/.local/share/bash-completion/completions/ai-primitives-hub
|
|
53
|
+
ai-primitives-hub completion --shell zsh > ~/.zsh/completion/_ai-primitives-hub
|
|
54
|
+
source <(ai-primitives-hub completion --shell bash)
|
|
32
55
|
`
|
|
33
56
|
});
|
|
34
57
|
shell = framework_1.Option.String('--shell');
|
|
35
|
-
|
|
58
|
+
/**
|
|
59
|
+
* Generate a bash completion script.
|
|
60
|
+
*
|
|
61
|
+
* The generated script embeds `paths` as a flat array literal and
|
|
62
|
+
* walks it generically at completion time: for the word currently
|
|
63
|
+
* being completed (`cword`), it matches every earlier word against
|
|
64
|
+
* each path's corresponding prefix and offers the next token of any
|
|
65
|
+
* path that matches. This covers every registered command and
|
|
66
|
+
* subcommand at any depth without per-command branches.
|
|
67
|
+
* @param paths Full set of registered command paths.
|
|
68
|
+
*/
|
|
69
|
+
generateBashCompletion(paths) {
|
|
36
70
|
return `# bash completion for ai-primitives-hub
|
|
37
71
|
_ai_primitives_hub_completion() {
|
|
38
72
|
local cur words cword
|
|
39
73
|
_init_completion || return
|
|
40
74
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
# Index subcommands
|
|
45
|
-
local index_commands="bench build eval export harvest report search shortlist stats"
|
|
46
|
-
|
|
47
|
-
# Hub subcommands
|
|
48
|
-
local hub_commands="add create list refresh remove sync use"
|
|
49
|
-
|
|
50
|
-
# Profile subcommands
|
|
51
|
-
local profile_commands="activate create deactivate list publish show current edit"
|
|
52
|
-
|
|
53
|
-
# Source subcommands
|
|
54
|
-
local source_commands="add list remove"
|
|
55
|
-
|
|
56
|
-
# Target subcommands
|
|
57
|
-
local target_commands="add list remove types"
|
|
58
|
-
|
|
59
|
-
# Collection subcommands
|
|
60
|
-
local collection_commands="affected create list validate"
|
|
61
|
-
|
|
62
|
-
# Config subcommands
|
|
63
|
-
local config_commands="get list"
|
|
64
|
-
|
|
65
|
-
# Index shortlist subcommands
|
|
66
|
-
local shortlist_commands="add list new remove"
|
|
75
|
+
local -a __aiph_paths=(
|
|
76
|
+
${renderPathLiterals(paths, ' ')}
|
|
77
|
+
)
|
|
67
78
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
if [[ \${cword} -eq 2 ]]; then
|
|
96
|
-
COMPREPLY=($(compgen -W "$target_commands" -- "$cur"))
|
|
97
|
-
fi
|
|
98
|
-
;;
|
|
99
|
-
collection)
|
|
100
|
-
if [[ \${cword} -eq 2 ]]; then
|
|
101
|
-
COMPREPLY=($(compgen -W "$collection_commands" -- "$cur"))
|
|
102
|
-
fi
|
|
103
|
-
;;
|
|
104
|
-
config)
|
|
105
|
-
if [[ \${cword} -eq 2 ]]; then
|
|
106
|
-
COMPREPLY=($(compgen -W "$config_commands" -- "$cur"))
|
|
107
|
-
fi
|
|
108
|
-
;;
|
|
109
|
-
shortlist)
|
|
110
|
-
if [[ \${cword} -eq 2 ]]; then
|
|
111
|
-
COMPREPLY=($(compgen -W "$shortlist_commands" -- "$cur"))
|
|
112
|
-
fi
|
|
113
|
-
;;
|
|
114
|
-
*)
|
|
115
|
-
# File completion for arguments
|
|
116
|
-
COMPREPLY=($(compgen -f -- "$cur"))
|
|
117
|
-
;;
|
|
118
|
-
esac
|
|
79
|
+
local -a __aiph_candidates=()
|
|
80
|
+
local __aiph_path_str
|
|
81
|
+
for __aiph_path_str in "\${__aiph_paths[@]}"; do
|
|
82
|
+
local -a __aiph_tokens=($__aiph_path_str)
|
|
83
|
+
if (( \${#__aiph_tokens[@]} >= cword )); then
|
|
84
|
+
local __aiph_match=1
|
|
85
|
+
local __aiph_i
|
|
86
|
+
for (( __aiph_i = 0; __aiph_i < cword - 1; __aiph_i++ )); do
|
|
87
|
+
if [[ "\${__aiph_tokens[__aiph_i]}" != "\${words[__aiph_i + 1]}" ]]; then
|
|
88
|
+
__aiph_match=0
|
|
89
|
+
break
|
|
90
|
+
fi
|
|
91
|
+
done
|
|
92
|
+
if [[ \${__aiph_match} -eq 1 ]]; then
|
|
93
|
+
local __aiph_cand="\${__aiph_tokens[cword - 1]}"
|
|
94
|
+
if [[ " \${__aiph_candidates[*]} " != *" \${__aiph_cand} "* ]]; then
|
|
95
|
+
__aiph_candidates+=("\${__aiph_cand}")
|
|
96
|
+
fi
|
|
97
|
+
fi
|
|
98
|
+
fi
|
|
99
|
+
done
|
|
100
|
+
|
|
101
|
+
if (( \${#__aiph_candidates[@]} > 0 )); then
|
|
102
|
+
COMPREPLY=($(compgen -W "\${__aiph_candidates[*]}" -- "$cur"))
|
|
103
|
+
else
|
|
104
|
+
COMPREPLY=($(compgen -f -- "$cur"))
|
|
105
|
+
fi
|
|
119
106
|
}
|
|
120
107
|
|
|
121
108
|
complete -F _ai_primitives_hub_completion ai-primitives-hub
|
|
122
109
|
`;
|
|
123
110
|
}
|
|
124
|
-
|
|
111
|
+
/**
|
|
112
|
+
* Generate a zsh completion script.
|
|
113
|
+
*
|
|
114
|
+
* Uses the same path-matching algorithm as the bash generator,
|
|
115
|
+
* adapted to zsh's 1-based `$words`/`$CURRENT` completion variables.
|
|
116
|
+
* @param paths Full set of registered command paths.
|
|
117
|
+
*/
|
|
118
|
+
generateZshCompletion(paths) {
|
|
125
119
|
return `#compdef ai-primitives-hub
|
|
126
120
|
|
|
127
121
|
_ai_primitives_hub() {
|
|
128
|
-
local -a
|
|
129
|
-
|
|
130
|
-
'
|
|
131
|
-
'collection:Manage collections'
|
|
132
|
-
'completion:Generate shell completion script'
|
|
133
|
-
'config:Read or list config values'
|
|
134
|
-
'discover:Discover relevant Copilot resources'
|
|
135
|
-
'doctor:Run environment self-checks'
|
|
136
|
-
'explain:Print documentation for error codes'
|
|
137
|
-
'hub:Manage hub configuration'
|
|
138
|
-
'index:Index and search primitives'
|
|
139
|
-
'init:Bootstrap a project'
|
|
140
|
-
'install:Install bundles to targets'
|
|
141
|
-
'plugins:List ai-primitives-hub plugins'
|
|
142
|
-
'profile:Manage profiles'
|
|
143
|
-
'skill:Manage agent skills'
|
|
144
|
-
'source:Manage sources'
|
|
145
|
-
'status:Show configuration state'
|
|
146
|
-
'target:Manage install targets'
|
|
147
|
-
'uninstall:Remove bundles from targets'
|
|
148
|
-
'update:Check for bundle updates'
|
|
149
|
-
'bundle:Build and manage bundles'
|
|
150
|
-
'version:Compute collection versions'
|
|
122
|
+
local -a __aiph_paths
|
|
123
|
+
__aiph_paths=(
|
|
124
|
+
${renderPathLiterals(paths, ' ')}
|
|
151
125
|
)
|
|
152
126
|
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
127
|
+
local -a __aiph_candidates
|
|
128
|
+
__aiph_candidates=()
|
|
129
|
+
local -a __aiph_tokens
|
|
130
|
+
local __aiph_path_str
|
|
131
|
+
local __aiph_match
|
|
132
|
+
local __aiph_i
|
|
133
|
+
local __aiph_cand
|
|
134
|
+
for __aiph_path_str in "\${__aiph_paths[@]}"; do
|
|
135
|
+
__aiph_tokens=(\${=__aiph_path_str})
|
|
136
|
+
if (( \${#__aiph_tokens} >= CURRENT - 1 )); then
|
|
137
|
+
__aiph_match=1
|
|
138
|
+
for (( __aiph_i = 1; __aiph_i <= CURRENT - 2; __aiph_i++ )); do
|
|
139
|
+
if [[ "\${__aiph_tokens[__aiph_i]}" != "\${words[__aiph_i + 1]}" ]]; then
|
|
140
|
+
__aiph_match=0
|
|
141
|
+
break
|
|
142
|
+
fi
|
|
143
|
+
done
|
|
144
|
+
if (( __aiph_match )); then
|
|
145
|
+
__aiph_cand="\${__aiph_tokens[CURRENT - 1]}"
|
|
146
|
+
if [[ " \${(j: :)__aiph_candidates} " != *" \${__aiph_cand} "* ]]; then
|
|
147
|
+
__aiph_candidates+=("\${__aiph_cand}")
|
|
148
|
+
fi
|
|
149
|
+
fi
|
|
150
|
+
fi
|
|
151
|
+
done
|
|
152
|
+
|
|
153
|
+
if (( \${#__aiph_candidates} > 0 )); then
|
|
154
|
+
compadd -a __aiph_candidates
|
|
155
|
+
else
|
|
156
|
+
_files
|
|
156
157
|
fi
|
|
157
|
-
|
|
158
|
-
case $words[1] in
|
|
159
|
-
index)
|
|
160
|
-
local -a index_commands
|
|
161
|
-
index_commands=(
|
|
162
|
-
'bench:Run search microbenchmark'
|
|
163
|
-
'build:Build primitive index'
|
|
164
|
-
'eval:Run relevance eval'
|
|
165
|
-
'export:Export shortlist as profile'
|
|
166
|
-
'harvest:Fetch and write primitive index'
|
|
167
|
-
'report:Render harvest report'
|
|
168
|
-
'search:Search primitive index'
|
|
169
|
-
'shortlist:Manage shortlists'
|
|
170
|
-
'stats:Show index statistics'
|
|
171
|
-
)
|
|
172
|
-
if [[ CURRENT -eq 2 ]]; then
|
|
173
|
-
_describe 'index command' index_commands
|
|
174
|
-
fi
|
|
175
|
-
;;
|
|
176
|
-
hub)
|
|
177
|
-
local -a hub_commands
|
|
178
|
-
hub_commands=(
|
|
179
|
-
'add:Import a hub'
|
|
180
|
-
'create:Scaffold hub-config.yml'
|
|
181
|
-
'list:List imported hubs'
|
|
182
|
-
'refresh:Sync active hub'
|
|
183
|
-
'remove:Remove a hub'
|
|
184
|
-
'sync:Re-fetch and sync hub'
|
|
185
|
-
'use:Set/clear active hub'
|
|
186
|
-
)
|
|
187
|
-
if [[ CURRENT -eq 2 ]]; then
|
|
188
|
-
_describe 'hub command' hub_commands
|
|
189
|
-
fi
|
|
190
|
-
;;
|
|
191
|
-
profile)
|
|
192
|
-
local -a profile_commands
|
|
193
|
-
profile_commands=(
|
|
194
|
-
'activate:Activate a profile'
|
|
195
|
-
'create:Create local profile'
|
|
196
|
-
'current:Show current profile'
|
|
197
|
-
'deactivate:Deactivate profile'
|
|
198
|
-
'edit:Edit a profile'
|
|
199
|
-
'list:List profiles'
|
|
200
|
-
'publish:Publish profile to hub'
|
|
201
|
-
'show:Show profile details'
|
|
202
|
-
)
|
|
203
|
-
if [[ CURRENT -eq 2 ]]; then
|
|
204
|
-
_describe 'profile command' profile_commands
|
|
205
|
-
fi
|
|
206
|
-
;;
|
|
207
|
-
source)
|
|
208
|
-
local -a source_commands
|
|
209
|
-
source_commands=(
|
|
210
|
-
'add:Add detached source'
|
|
211
|
-
'list:List sources'
|
|
212
|
-
'remove:Remove source'
|
|
213
|
-
)
|
|
214
|
-
if [[ CURRENT -eq 2 ]]; then
|
|
215
|
-
_describe 'source command' source_commands
|
|
216
|
-
fi
|
|
217
|
-
;;
|
|
218
|
-
target)
|
|
219
|
-
local -a target_commands
|
|
220
|
-
target_commands=(
|
|
221
|
-
'add:Register install target'
|
|
222
|
-
'list:List configured targets'
|
|
223
|
-
'remove:Remove target'
|
|
224
|
-
'types:List target types'
|
|
225
|
-
)
|
|
226
|
-
if [[ CURRENT -eq 2 ]]; then
|
|
227
|
-
_describe 'target command' target_commands
|
|
228
|
-
fi
|
|
229
|
-
;;
|
|
230
|
-
collection)
|
|
231
|
-
local -a collection_commands
|
|
232
|
-
collection_commands=(
|
|
233
|
-
'affected:Print overlapping collections'
|
|
234
|
-
'create:Create collection'
|
|
235
|
-
'list:List collections'
|
|
236
|
-
'validate:Validate collections'
|
|
237
|
-
)
|
|
238
|
-
if [[ CURRENT -eq 2 ]]; then
|
|
239
|
-
_describe 'collection command' collection_commands
|
|
240
|
-
fi
|
|
241
|
-
;;
|
|
242
|
-
config)
|
|
243
|
-
local -a config_commands
|
|
244
|
-
config_commands=(
|
|
245
|
-
'get:Read config value'
|
|
246
|
-
'list:Print resolved config'
|
|
247
|
-
)
|
|
248
|
-
if [[ CURRENT -eq 2 ]]; then
|
|
249
|
-
_describe 'config command' config_commands
|
|
250
|
-
fi
|
|
251
|
-
;;
|
|
252
|
-
*)
|
|
253
|
-
# File completion
|
|
254
|
-
_files
|
|
255
|
-
;;
|
|
256
|
-
esac
|
|
257
158
|
}
|
|
258
159
|
|
|
259
160
|
_ai_primitives_hub
|
|
@@ -270,7 +171,8 @@ _ai_primitives_hub
|
|
|
270
171
|
ctx.stderr.write(`Error: Unsupported shell "${shell}". Use "bash" or "zsh".\n`);
|
|
271
172
|
return Promise.resolve(1);
|
|
272
173
|
}
|
|
273
|
-
const
|
|
174
|
+
const paths = (0, framework_1.getCommandPaths)(this);
|
|
175
|
+
const script = shell === 'bash' ? this.generateBashCompletion(paths) : this.generateZshCompletion(paths);
|
|
274
176
|
ctx.stdout.write(script);
|
|
275
177
|
return Promise.resolve(0);
|
|
276
178
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"completion.js","sourceRoot":"","sources":["../../src/commands/completion.ts"],"names":[],"mappings":";;;AAAA;;;;;GAKG;AACH,
|
|
1
|
+
{"version":3,"file":"completion.js","sourceRoot":"","sources":["../../src/commands/completion.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;GAUG;AACH,4CAKsB;AAEtB;;;;;;;;;GASG;AACH,MAAM,UAAU,GAAG,CAAC,IAAY,EAAU,EAAE,CAAC,IAAI,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,GAAG,CAAA,MAAM,CAAC,GAAG,CAAC;AAEzF;;;;;GAKG;AACH,MAAM,kBAAkB,GAAG,CAAC,KAAiB,EAAE,MAAc,EAAU,EAAE,CACvE,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,GAAG,MAAM,GAAG,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAE3E;;GAEG;AACH,MAAa,iBAAkB,SAAQ,mBAAO;IACrC,MAAM,CAAU,KAAK,GAAG,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC;IAEzC,MAAM,CAAU,KAAK,GAAG,mBAAO,CAAC,KAAK,CAAC;QAC3C,WAAW,EAAE,mDAAmD;QAChE,QAAQ,EAAE,mBAAmB;QAC7B,OAAO,EAAE;;;;;;;;;;;;;KAaR;KACF,CAAC,CAAC;IAEI,KAAK,GAAG,kBAAM,CAAC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H,8CAsJC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"doctor.d.ts","sourceRoot":"","sources":["../../src/commands/doctor.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"doctor.d.ts","sourceRoot":"","sources":["../../src/commands/doctor.ts"],"names":[],"mappings":"AA4BA,OAAO,EACL,OAAO,EACP,KAAK,OAAO,EAMb,MAAM,cAAc,CAAC;AAiCtB;;GAEG;AACH,uBAAe,iBAAkB,SAAQ,OAAO;IACvC,cAAc,EAAG;QAAE,GAAG,EAAE,OAAO,CAAA;KAAE,CAAC;IAElC,MAAM,qBAAgC;IACtC,OAAO,UAAyC;CACxD;AAED;;GAEG;AACH,qBAAa,aAAc,SAAQ,iBAAiB;IAClD,gBAAuB,KAAK,aAAgB;IAE5C,gBAAuB,KAAK,4BAkBzB;IAEU,OAAO,IAAI,OAAO,CAAC,MAAM,CAAC;CAgBxC;AAED;;GAEG;AACH,qBAAa,wBAAyB,SAAQ,iBAAiB;IAC7D,gBAAuB,KAAK,aAA+B;IAE3D,gBAAuB,KAAK,4BAwBzB;IAEI,eAAe,UAA+C;IAExD,OAAO,IAAI,OAAO,CAAC,MAAM,CAAC;CAoBxC"}
|
package/dist/commands/doctor.js
CHANGED
|
@@ -272,10 +272,21 @@ const checkProjectConfig = async (ctx, verbose) => {
|
|
|
272
272
|
const { file, exists } = await (0, infra_1.findProjectConfigPath)({ cwd, fs: ctx.fs });
|
|
273
273
|
log(logs, 'output', `file: ${file}, exists: ${exists ? 'true' : 'false'}`);
|
|
274
274
|
if (!exists) {
|
|
275
|
+
const targets = await (0, framework_1.loadTargets)(ctx);
|
|
276
|
+
if (targets.length > 0) {
|
|
277
|
+
const targetNames = targets.map((target) => target.name).join(', ');
|
|
278
|
+
return {
|
|
279
|
+
name: 'project-config',
|
|
280
|
+
status: 'ok',
|
|
281
|
+
detail: `No project config found. Using target${targets.length === 1 ? '' : 's'} from user config: ${targetNames}.`,
|
|
282
|
+
logs
|
|
283
|
+
};
|
|
284
|
+
}
|
|
275
285
|
return {
|
|
276
286
|
name: 'project-config',
|
|
277
287
|
status: 'warn',
|
|
278
|
-
detail: `No
|
|
288
|
+
detail: `No project config found from ${cwd} upward. User-scoped installs do not need one.`
|
|
289
|
+
+ ' For repository installs, run `ai-primitives-hub target add <name> --type <kind> --scope repository`.',
|
|
279
290
|
logs
|
|
280
291
|
};
|
|
281
292
|
}
|
|
@@ -306,7 +317,7 @@ const checkProjectConfig = async (ctx, verbose) => {
|
|
|
306
317
|
const checkTargets = async (ctx, verbose) => {
|
|
307
318
|
const logs = createLogger(verbose);
|
|
308
319
|
try {
|
|
309
|
-
const targets = await (0,
|
|
320
|
+
const targets = await (0, framework_1.loadTargets)(ctx);
|
|
310
321
|
log(logs, 'output', `targets: ${targets.map((t) => `${t.name}(${t.type})`).join(', ')}`);
|
|
311
322
|
if (targets.length === 0) {
|
|
312
323
|
return {
|