@polardbx/pxbaas 0.1.0-beta.1 → 0.1.0-beta.10
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/README.md +224 -0
- package/dist/app/local-index.d.ts +70 -0
- package/dist/app/local-index.d.ts.map +1 -0
- package/dist/app/local-index.js +140 -0
- package/dist/app/local-index.js.map +1 -0
- package/dist/app/preflight.d.ts +24 -1
- package/dist/app/preflight.d.ts.map +1 -1
- package/dist/app/preflight.js +47 -11
- package/dist/app/preflight.js.map +1 -1
- package/dist/app/spec-lint.d.ts.map +1 -1
- package/dist/app/spec-lint.js +16 -0
- package/dist/app/spec-lint.js.map +1 -1
- package/dist/app/templates.d.ts +24 -0
- package/dist/app/templates.d.ts.map +1 -1
- package/dist/app/templates.js.map +1 -1
- package/dist/cli/help-guides.d.ts +17 -0
- package/dist/cli/help-guides.d.ts.map +1 -0
- package/dist/cli/help-guides.js +132 -0
- package/dist/cli/help-guides.js.map +1 -0
- package/dist/cli/root.d.ts.map +1 -1
- package/dist/cli/root.js +6 -0
- package/dist/cli/root.js.map +1 -1
- package/dist/commands/app/index.d.ts.map +1 -1
- package/dist/commands/app/index.js +687 -47
- package/dist/commands/app/index.js.map +1 -1
- package/dist/commands/completion/index.d.ts.map +1 -1
- package/dist/commands/completion/index.js +5 -1
- package/dist/commands/completion/index.js.map +1 -1
- package/dist/commands/data/index.d.ts +52 -0
- package/dist/commands/data/index.d.ts.map +1 -1
- package/dist/commands/data/index.js +201 -39
- package/dist/commands/data/index.js.map +1 -1
- package/dist/commands/db/index.d.ts +15 -0
- package/dist/commands/db/index.d.ts.map +1 -1
- package/dist/commands/db/index.js +200 -55
- package/dist/commands/db/index.js.map +1 -1
- package/dist/commands/functions/new.d.ts +4 -0
- package/dist/commands/functions/new.d.ts.map +1 -1
- package/dist/commands/functions/new.js +24 -9
- package/dist/commands/functions/new.js.map +1 -1
- package/dist/commands/gen/index.d.ts.map +1 -1
- package/dist/commands/gen/index.js +13 -10
- package/dist/commands/gen/index.js.map +1 -1
- package/dist/commands/guide/index.d.ts +8 -0
- package/dist/commands/guide/index.d.ts.map +1 -0
- package/dist/commands/guide/index.js +20 -0
- package/dist/commands/guide/index.js.map +1 -0
- package/dist/commands/instance/index.d.ts.map +1 -1
- package/dist/commands/instance/index.js +120 -0
- package/dist/commands/instance/index.js.map +1 -1
- package/dist/commands/login/index.d.ts.map +1 -1
- package/dist/commands/login/index.js +23 -63
- package/dist/commands/login/index.js.map +1 -1
- package/dist/commands/profile/import-env.d.ts +7 -2
- package/dist/commands/profile/import-env.d.ts.map +1 -1
- package/dist/commands/profile/import-env.js +141 -16
- package/dist/commands/profile/import-env.js.map +1 -1
- package/dist/commands/profile/index.d.ts.map +1 -1
- package/dist/commands/profile/index.js +16 -1
- package/dist/commands/profile/index.js.map +1 -1
- package/dist/commands/skill/index.d.ts.map +1 -1
- package/dist/commands/skill/index.js +89 -14
- package/dist/commands/skill/index.js.map +1 -1
- package/dist/commands/storage/index.d.ts.map +1 -1
- package/dist/commands/storage/index.js +209 -7
- package/dist/commands/storage/index.js.map +1 -1
- package/dist/commands/tenant/index.d.ts +19 -0
- package/dist/commands/tenant/index.d.ts.map +1 -0
- package/dist/commands/tenant/index.js +667 -0
- package/dist/commands/tenant/index.js.map +1 -0
- package/dist/commands/whoami/index.js +19 -0
- package/dist/commands/whoami/index.js.map +1 -1
- package/dist/credentials/credential-store.d.ts +30 -1
- package/dist/credentials/credential-store.d.ts.map +1 -1
- package/dist/credentials/credential-store.js +114 -12
- package/dist/credentials/credential-store.js.map +1 -1
- package/dist/credentials/env-file.d.ts +48 -7
- package/dist/credentials/env-file.d.ts.map +1 -1
- package/dist/credentials/env-file.js +91 -16
- package/dist/credentials/env-file.js.map +1 -1
- package/dist/credentials/index.d.ts +2 -0
- package/dist/credentials/index.d.ts.map +1 -1
- package/dist/credentials/index.js +2 -0
- package/dist/credentials/index.js.map +1 -1
- package/dist/credentials/jwt-introspect.d.ts +7 -0
- package/dist/credentials/jwt-introspect.d.ts.map +1 -1
- package/dist/credentials/jwt-introspect.js.map +1 -1
- package/dist/credentials/masker.d.ts +3 -0
- package/dist/credentials/masker.d.ts.map +1 -1
- package/dist/credentials/masker.js +3 -0
- package/dist/credentials/masker.js.map +1 -1
- package/dist/credentials/profile.d.ts +12 -0
- package/dist/credentials/profile.d.ts.map +1 -1
- package/dist/credentials/profile.js +23 -0
- package/dist/credentials/profile.js.map +1 -1
- package/dist/credentials/tty-guard.d.ts +10 -0
- package/dist/credentials/tty-guard.d.ts.map +1 -1
- package/dist/credentials/tty-guard.js +32 -0
- package/dist/credentials/tty-guard.js.map +1 -1
- package/dist/db/apply-schema.d.ts +98 -11
- package/dist/db/apply-schema.d.ts.map +1 -1
- package/dist/db/apply-schema.js +247 -80
- package/dist/db/apply-schema.js.map +1 -1
- package/dist/db/introspect.d.ts +54 -0
- package/dist/db/introspect.d.ts.map +1 -0
- package/dist/db/introspect.js +140 -0
- package/dist/db/introspect.js.map +1 -0
- package/dist/db/sql-file.d.ts +55 -0
- package/dist/db/sql-file.d.ts.map +1 -1
- package/dist/db/sql-file.js +417 -0
- package/dist/db/sql-file.js.map +1 -1
- package/dist/instance/zero-whitelist.d.ts +39 -0
- package/dist/instance/zero-whitelist.d.ts.map +1 -0
- package/dist/instance/zero-whitelist.js +67 -0
- package/dist/instance/zero-whitelist.js.map +1 -0
- package/dist/main.js +26 -3
- package/dist/main.js.map +1 -1
- package/dist/skill/agents-md.d.ts +25 -0
- package/dist/skill/agents-md.d.ts.map +1 -0
- package/dist/skill/agents-md.js +62 -0
- package/dist/skill/agents-md.js.map +1 -0
- package/dist/skill/hosts.d.ts +31 -7
- package/dist/skill/hosts.d.ts.map +1 -1
- package/dist/skill/hosts.js +65 -7
- package/dist/skill/hosts.js.map +1 -1
- package/dist/skill/installer.d.ts +15 -3
- package/dist/skill/installer.d.ts.map +1 -1
- package/dist/skill/installer.js +62 -24
- package/dist/skill/installer.js.map +1 -1
- package/dist/tenant/bundle.d.ts +66 -0
- package/dist/tenant/bundle.d.ts.map +1 -0
- package/dist/tenant/bundle.js +132 -0
- package/dist/tenant/bundle.js.map +1 -0
- package/dist/tenant/guide.d.ts +50 -0
- package/dist/tenant/guide.d.ts.map +1 -0
- package/dist/tenant/guide.js +152 -0
- package/dist/tenant/guide.js.map +1 -0
- package/dist/tenant/probe.d.ts +65 -0
- package/dist/tenant/probe.d.ts.map +1 -0
- package/dist/tenant/probe.js +159 -0
- package/dist/tenant/probe.js.map +1 -0
- package/dist/tenant/verify.d.ts +37 -0
- package/dist/tenant/verify.d.ts.map +1 -0
- package/dist/tenant/verify.js +132 -0
- package/dist/tenant/verify.js.map +1 -0
- package/dist/version.d.ts +29 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +65 -0
- package/dist/version.js.map +1 -0
- package/package.json +3 -3
- package/skills/pxbaas-app-spec/SKILL.md +4 -2
- package/skills/pxbaas-app-spec/references/deploy-options.md +3 -2
- package/skills/pxbaas-app-spec/references/runtime-contract.md +2 -2
- package/skills/pxbaas-app-spec/references/templates-examples.md +7 -4
- package/skills/pxbaas-cli/SKILL.md +26 -8
- package/skills/pxbaas-cli/references/app-deploy.md +46 -3
- package/skills/pxbaas-cli/references/auth-and-credentials.md +30 -2
- package/skills/pxbaas-cli/references/data-postgrest.md +19 -3
- package/skills/pxbaas-cli/references/db-and-meta.md +17 -0
- package/skills/pxbaas-cli/references/multi-tenant-apps.md +35 -4
- package/skills/pxbaas-cli/references/provision.md +16 -1
- package/skills/pxbaas-cli/references/safety-and-two-phase.md +42 -13
- package/skills/pxbaas-cli/references/tenant-admin.md +122 -0
- package/skills/pxbaas-cli/references/troubleshooting.md +4 -1
- package/templates/webapp/csr-bff/db/rls.json +13 -0
- package/templates/webapp/csr-bff/db/schema.sql +8 -28
- package/templates/webapp/manifest.json +131 -8
- package/templates/webapp/react-vite-hono/backend/index.ts +21 -4
- package/templates/webapp/ssr-blog/db/rls.json +13 -0
- package/templates/webapp/ssr-blog/db/schema.sql +8 -28
- package/templates/webapp/ssr-hono/backend/index.ts +50 -31
- package/templates/webapp/ssr-shop/db/rls.json +16 -0
- package/templates/webapp/ssr-shop/db/schema.sql +12 -42
- package/dist/commands/login/login.d.ts +0 -3
- package/dist/commands/login/login.d.ts.map +0 -1
- package/dist/commands/login/login.js +0 -185
- package/dist/commands/login/login.js.map +0 -1
- /package/templates/webapp/vanilla-static/frontend/{app.js → dist/app.js} +0 -0
- /package/templates/webapp/vanilla-static/frontend/{index.html → dist/index.html} +0 -0
- /package/templates/webapp/vanilla-static/frontend/{style.css → dist/style.css} +0 -0
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Zero whitelist self-service helpers (CLI side).
|
|
3
|
+
*
|
|
4
|
+
* The whitelist API authenticates with a Studio-credential HASH (not the pxz_token
|
|
5
|
+
* ownership cookie) and addresses the instance by its cloud id (`pxsp-*`), so this
|
|
6
|
+
* module turns a locally-bound Zero record into the (cloudInstanceId, studioHash)
|
|
7
|
+
* pair the driver needs — and enforces the "Zero instances only" guard.
|
|
8
|
+
*
|
|
9
|
+
* The dashboard password and its derived sha256("supabase:"+password) are NEVER
|
|
10
|
+
* returned in any printable field; only the opaque `studioHash` is handed to the
|
|
11
|
+
* driver. See references/provision.md and the pxbaas-cli SKILL safety rules.
|
|
12
|
+
*/
|
|
13
|
+
import { createHash } from 'node:crypto';
|
|
14
|
+
import { ZeroDriver } from '@polardbx/pxbaas-client';
|
|
15
|
+
import { ProfileManager } from '../credentials/profile.js';
|
|
16
|
+
import { ZeroStore } from './zero-store.js';
|
|
17
|
+
/**
|
|
18
|
+
* sha256hex("<user>:<password>"), UTF-8, no trailing newline. Equivalent to the
|
|
19
|
+
* password — never log or persist it. `user` is fixed to `supabase` by the API.
|
|
20
|
+
*/
|
|
21
|
+
export function studioCredentialHash(password, user = 'supabase') {
|
|
22
|
+
return createHash('sha256').update(`${user}:${password}`, 'utf8').digest('hex');
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Resolve which Zero instance a `whitelist get|add` targets.
|
|
26
|
+
*
|
|
27
|
+
* - `opts.id` (an `sbx_*` ownership id) selects explicitly.
|
|
28
|
+
* - Otherwise the current profile is used and MUST be `source === 'zero'`.
|
|
29
|
+
*
|
|
30
|
+
* Throws a plain Error (clear, user-facing) when the target is not a locally-bound
|
|
31
|
+
* Zero instance or has no stored dashboard password — the whitelist surface is
|
|
32
|
+
* Zero-only by design.
|
|
33
|
+
*/
|
|
34
|
+
export async function resolveWhitelistTarget(opts) {
|
|
35
|
+
const store = new ZeroStore();
|
|
36
|
+
let record;
|
|
37
|
+
if (opts.id) {
|
|
38
|
+
record = await store.getInstance(opts.id);
|
|
39
|
+
if (!record) {
|
|
40
|
+
throw new Error(`No Zero instance '${opts.id}' bound on this machine. Whitelist management is only available for Zero-provisioned instances.`);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
const current = await new ProfileManager().getCurrentProfile();
|
|
45
|
+
if (!current) {
|
|
46
|
+
throw new Error('No active profile. Run `pxbaas provision` to claim a Zero instance first.');
|
|
47
|
+
}
|
|
48
|
+
if (current.source !== 'zero') {
|
|
49
|
+
throw new Error(`Whitelist management is only available for Zero-provisioned instances; current profile '${current.name}' is not a Zero instance (source='${current.source ?? 'login'}').`);
|
|
50
|
+
}
|
|
51
|
+
record =
|
|
52
|
+
(current.zeroInstanceId ? await store.getInstance(current.zeroInstanceId) : null) ??
|
|
53
|
+
(await store.findInstanceByProfile(current.name));
|
|
54
|
+
if (!record) {
|
|
55
|
+
throw new Error(`Zero instance for profile '${current.name}' is not bound locally; cannot authenticate the whitelist API.`);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
if (!record.dashboardPassword) {
|
|
59
|
+
throw new Error('This Zero instance has no stored dashboard password, so the whitelist API cannot be authenticated. Re-provision from this machine (`pxbaas provision`).');
|
|
60
|
+
}
|
|
61
|
+
return {
|
|
62
|
+
record,
|
|
63
|
+
cloudInstanceId: ZeroDriver.cloudInstanceId(record.endpoint),
|
|
64
|
+
studioHash: studioCredentialHash(record.dashboardPassword),
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=zero-whitelist.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"zero-whitelist.js","sourceRoot":"","sources":["../../src/instance/zero-whitelist.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAE,SAAS,EAA2B,MAAM,iBAAiB,CAAC;AAErE;;;GAGG;AACH,MAAM,UAAU,oBAAoB,CAAC,QAAgB,EAAE,IAAI,GAAG,UAAU;IACtE,OAAO,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,GAAG,IAAI,IAAI,QAAQ,EAAE,EAAE,MAAM,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAClF,CAAC;AAUD;;;;;;;;;GASG;AACH,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAAC,IAAgC;IAC3E,MAAM,KAAK,GAAG,IAAI,SAAS,EAAE,CAAC;IAC9B,IAAI,MAAiC,CAAC;IAEtC,IAAI,IAAI,CAAC,EAAE,EAAE,CAAC;QACZ,MAAM,GAAG,MAAM,KAAK,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAC1C,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,MAAM,IAAI,KAAK,CAAC,qBAAqB,IAAI,CAAC,EAAE,iGAAiG,CAAC,CAAC;QACjJ,CAAC;IACH,CAAC;SAAM,CAAC;QACN,MAAM,OAAO,GAAG,MAAM,IAAI,cAAc,EAAE,CAAC,iBAAiB,EAAE,CAAC;QAC/D,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,MAAM,IAAI,KAAK,CAAC,2EAA2E,CAAC,CAAC;QAC/F,CAAC;QACD,IAAI,OAAO,CAAC,MAAM,KAAK,MAAM,EAAE,CAAC;YAC9B,MAAM,IAAI,KAAK,CAAC,2FAA2F,OAAO,CAAC,IAAI,qCAAqC,OAAO,CAAC,MAAM,IAAI,OAAO,KAAK,CAAC,CAAC;QAC9L,CAAC;QACD,MAAM;YACJ,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,MAAM,KAAK,CAAC,WAAW,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;gBACjF,CAAC,MAAM,KAAK,CAAC,qBAAqB,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;QACpD,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,MAAM,IAAI,KAAK,CAAC,8BAA8B,OAAO,CAAC,IAAI,gEAAgE,CAAC,CAAC;QAC9H,CAAC;IACH,CAAC;IAED,IAAI,CAAC,MAAM,CAAC,iBAAiB,EAAE,CAAC;QAC9B,MAAM,IAAI,KAAK,CAAC,yJAAyJ,CAAC,CAAC;IAC7K,CAAC;IAED,OAAO;QACL,MAAM;QACN,eAAe,EAAE,UAAU,CAAC,eAAe,CAAC,MAAM,CAAC,QAAQ,CAAC;QAC5D,UAAU,EAAE,oBAAoB,CAAC,MAAM,CAAC,iBAAiB,CAAC;KAC3D,CAAC;AACJ,CAAC"}
|
package/dist/main.js
CHANGED
|
@@ -1,15 +1,22 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { program } from 'commander';
|
|
3
3
|
import { registerCommands } from './cli/root.js';
|
|
4
|
-
import {
|
|
4
|
+
import { TOP_LEVEL_AGENT_GUIDE } from './cli/help-guides.js';
|
|
5
|
+
import { ProfileManager, isProfileCreatingCommand, setCliProfileOverrideGlobal, } from './credentials/profile.js';
|
|
6
|
+
import { resolvePackageVersion } from './version.js';
|
|
5
7
|
// Global options
|
|
6
8
|
program
|
|
7
9
|
.name('pxbaas')
|
|
8
10
|
.description('PolarDB-X BaaS CLI')
|
|
9
|
-
.
|
|
11
|
+
// Read from package.json at runtime: a hardcoded string here reported
|
|
12
|
+
// `0.0.0-dev` for every build, so `--version` could never identify a release.
|
|
13
|
+
.version(resolvePackageVersion())
|
|
10
14
|
.option('--json', 'Output in JSON format')
|
|
11
15
|
.option('--profile <name>', 'Use specific profile')
|
|
12
|
-
.option('--debug', 'Enable debug output')
|
|
16
|
+
.option('--debug', 'Enable debug output')
|
|
17
|
+
// Discoverability for coding agents: the full develop-and-deploy workflow
|
|
18
|
+
// lives under `pxbaas app --help`; keep this pointer to three lines.
|
|
19
|
+
.addHelpText('after', TOP_LEVEL_AGENT_GUIDE);
|
|
13
20
|
// Register all commands
|
|
14
21
|
registerCommands(program);
|
|
15
22
|
// `--profile` is a program-level option, so commander only parses it when given
|
|
@@ -25,6 +32,15 @@ const declareProfileOption = (cmd) => {
|
|
|
25
32
|
cmd.commands.forEach(declareProfileOption);
|
|
26
33
|
};
|
|
27
34
|
declareProfileOption(program);
|
|
35
|
+
/** Full command path of the action command (e.g. ['profile','import']), program name excluded. */
|
|
36
|
+
const commandPathOf = (actionCommand) => {
|
|
37
|
+
const parts = [];
|
|
38
|
+
for (let c = actionCommand; c && c !== program; c = c.parent) {
|
|
39
|
+
if (c.name())
|
|
40
|
+
parts.unshift(c.name());
|
|
41
|
+
}
|
|
42
|
+
return parts;
|
|
43
|
+
};
|
|
28
44
|
// Resolve --profile once, before any command runs: validate it exists (fail loudly
|
|
29
45
|
// instead of silently falling back to the current profile) and publish it as a
|
|
30
46
|
// process-wide override. Never persisted — `profile ls` current marker is untouched.
|
|
@@ -32,6 +48,13 @@ program.hook('preAction', async (_thisCommand, actionCommand) => {
|
|
|
32
48
|
const requested = (actionCommand.opts().profile ?? program.opts().profile);
|
|
33
49
|
if (!requested)
|
|
34
50
|
return;
|
|
51
|
+
// `login` / `profile import` write the named profile, so an unknown name is their
|
|
52
|
+
// precondition, not an error. Still publish the override: the command must read and
|
|
53
|
+
// write that exact profile rather than whatever happens to be current.
|
|
54
|
+
if (isProfileCreatingCommand(commandPathOf(actionCommand))) {
|
|
55
|
+
setCliProfileOverrideGlobal(requested);
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
35
58
|
const manager = new ProfileManager();
|
|
36
59
|
const known = await manager.listProfiles();
|
|
37
60
|
if (!known.some((p) => p.name === requested)) {
|
package/dist/main.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.js","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,OAAO,EAAW,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"main.js","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,OAAO,EAAW,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,EACL,cAAc,EACd,wBAAwB,EACxB,2BAA2B,GAC5B,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAErD,iBAAiB;AACjB,OAAO;KACJ,IAAI,CAAC,QAAQ,CAAC;KACd,WAAW,CAAC,oBAAoB,CAAC;IAClC,sEAAsE;IACtE,8EAA8E;KAC7E,OAAO,CAAC,qBAAqB,EAAE,CAAC;KAChC,MAAM,CAAC,QAAQ,EAAE,uBAAuB,CAAC;KACzC,MAAM,CAAC,kBAAkB,EAAE,sBAAsB,CAAC;KAClD,MAAM,CAAC,SAAS,EAAE,qBAAqB,CAAC;IACzC,0EAA0E;IAC1E,qEAAqE;KACpE,WAAW,CAAC,OAAO,E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ClF,oFAAoF;IACpF,uEAAuE;IACvE,IAAI,wBAAwB,CAAC,aAAa,CAAC,aAAa,CAAC,CAAC,EAAE,CAAC;QAC3D,2BAA2B,CAAC,SAAS,CAAC,CAAC;QACvC,OAAO;IACT,CAAC;IACD,MAAM,OAAO,GAAG,IAAI,cAAc,EAAE,CAAC;IACrC,MAAM,KAAK,GAAG,MAAM,OAAO,CAAC,YAAY,EAAE,CAAC;IAC3C,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,SAAS,CAAC,EAAE,CAAC;QAC7C,MAAM,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,QAAQ,CAAC;QAC9D,OAAO,CAAC,KAAK,CACX,uBAAuB,SAAS,0BAA0B,KAAK,EAAE,CAClE,CAAC;QACF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;IACD,2BAA2B,CAAC,SAAS,CAAC,CAAC;AACzC,CAAC,CAAC,CAAC;AAEH,kBAAkB;AAClB,OAAO,CAAC,KAAK,EAAE,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Managed AGENTS.md block for agents without a SKILL.md convention.
|
|
3
|
+
*
|
|
4
|
+
* Cloud agents (Devin, Jules, Copilot coding agent) and guideline-only tools
|
|
5
|
+
* (Junie, Comate, CodeArts, Windsurf, Kiro steering) read repository-level
|
|
6
|
+
* AGENTS.md. `pxbaas skill install --scope project --agents-md` writes a small
|
|
7
|
+
* marker-delimited block pointing at the exported skill directories and
|
|
8
|
+
* `pxbaas guide`. Everything outside the markers is never touched, and the
|
|
9
|
+
* block is idempotently replaced on re-install.
|
|
10
|
+
*/
|
|
11
|
+
export declare const AGENTS_MD_FILE = "AGENTS.md";
|
|
12
|
+
export declare const BEGIN_MARKER = "<!-- BEGIN pxbaas-skills (managed by pxbaas skill install; do not edit) -->";
|
|
13
|
+
export declare const END_MARKER = "<!-- END pxbaas-skills -->";
|
|
14
|
+
export declare function renderBlock(lines: string[]): string;
|
|
15
|
+
export declare function upsertAgentsMdBlock(projectRoot: string, lines: string[]): Promise<{
|
|
16
|
+
path: string;
|
|
17
|
+
created: boolean;
|
|
18
|
+
}>;
|
|
19
|
+
export declare function removeAgentsMdBlock(projectRoot: string): Promise<{
|
|
20
|
+
path: string;
|
|
21
|
+
removed: boolean;
|
|
22
|
+
deletedFile: boolean;
|
|
23
|
+
}>;
|
|
24
|
+
export declare function agentsMdBlockPresent(projectRoot: string): Promise<boolean>;
|
|
25
|
+
//# sourceMappingURL=agents-md.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agents-md.d.ts","sourceRoot":"","sources":["../../src/skill/agents-md.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAMH,eAAO,MAAM,cAAc,cAAc,CAAC;AAC1C,eAAO,MAAM,YAAY,gFACsD,CAAC;AAChF,eAAO,MAAM,UAAU,+BAA+B,CAAC;AAUvD,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,CAEnD;AAED,wBAAsB,mBAAmB,CACvC,WAAW,EAAE,MAAM,EACnB,KAAK,EAAE,MAAM,EAAE,GACd,OAAO,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,CAAC,CAa7C;AAED,wBAAsB,mBAAmB,CACvC,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,OAAO,CAAC;IAAC,WAAW,EAAE,OAAO,CAAA;CAAE,CAAC,CAYnE;AAED,wBAAsB,oBAAoB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAKhF"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Managed AGENTS.md block for agents without a SKILL.md convention.
|
|
3
|
+
*
|
|
4
|
+
* Cloud agents (Devin, Jules, Copilot coding agent) and guideline-only tools
|
|
5
|
+
* (Junie, Comate, CodeArts, Windsurf, Kiro steering) read repository-level
|
|
6
|
+
* AGENTS.md. `pxbaas skill install --scope project --agents-md` writes a small
|
|
7
|
+
* marker-delimited block pointing at the exported skill directories and
|
|
8
|
+
* `pxbaas guide`. Everything outside the markers is never touched, and the
|
|
9
|
+
* block is idempotently replaced on re-install.
|
|
10
|
+
*/
|
|
11
|
+
import { readFile, writeFile, rm } from 'node:fs/promises';
|
|
12
|
+
import { existsSync } from 'node:fs';
|
|
13
|
+
import { join } from 'node:path';
|
|
14
|
+
export const AGENTS_MD_FILE = 'AGENTS.md';
|
|
15
|
+
export const BEGIN_MARKER = '<!-- BEGIN pxbaas-skills (managed by pxbaas skill install; do not edit) -->';
|
|
16
|
+
export const END_MARKER = '<!-- END pxbaas-skills -->';
|
|
17
|
+
function escapeRe(s) {
|
|
18
|
+
return s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
19
|
+
}
|
|
20
|
+
function blockRegex() {
|
|
21
|
+
return new RegExp(`\\n*${escapeRe(BEGIN_MARKER)}[\\s\\S]*?${escapeRe(END_MARKER)}\\n*`);
|
|
22
|
+
}
|
|
23
|
+
export function renderBlock(lines) {
|
|
24
|
+
return [BEGIN_MARKER, ...lines, END_MARKER].join('\n');
|
|
25
|
+
}
|
|
26
|
+
export async function upsertAgentsMdBlock(projectRoot, lines) {
|
|
27
|
+
const path = join(projectRoot, AGENTS_MD_FILE);
|
|
28
|
+
const block = renderBlock(lines);
|
|
29
|
+
if (!existsSync(path)) {
|
|
30
|
+
await writeFile(path, `${block}\n`, 'utf8');
|
|
31
|
+
return { path, created: true };
|
|
32
|
+
}
|
|
33
|
+
const content = await readFile(path, 'utf8');
|
|
34
|
+
const updated = blockRegex().test(content)
|
|
35
|
+
? content.replace(blockRegex(), `${block}\n`)
|
|
36
|
+
: `${content.replace(/\s*$/, '')}\n\n${block}\n`;
|
|
37
|
+
await writeFile(path, updated, 'utf8');
|
|
38
|
+
return { path, created: false };
|
|
39
|
+
}
|
|
40
|
+
export async function removeAgentsMdBlock(projectRoot) {
|
|
41
|
+
const path = join(projectRoot, AGENTS_MD_FILE);
|
|
42
|
+
if (!existsSync(path))
|
|
43
|
+
return { path, removed: false, deletedFile: false };
|
|
44
|
+
const content = await readFile(path, 'utf8');
|
|
45
|
+
if (!blockRegex().test(content))
|
|
46
|
+
return { path, removed: false, deletedFile: false };
|
|
47
|
+
const stripped = content.replace(blockRegex(), '');
|
|
48
|
+
if (stripped.trim() === '') {
|
|
49
|
+
await rm(path);
|
|
50
|
+
return { path, removed: true, deletedFile: true };
|
|
51
|
+
}
|
|
52
|
+
await writeFile(path, stripped, 'utf8');
|
|
53
|
+
return { path, removed: true, deletedFile: false };
|
|
54
|
+
}
|
|
55
|
+
export async function agentsMdBlockPresent(projectRoot) {
|
|
56
|
+
const path = join(projectRoot, AGENTS_MD_FILE);
|
|
57
|
+
if (!existsSync(path))
|
|
58
|
+
return false;
|
|
59
|
+
const content = await readFile(path, 'utf8');
|
|
60
|
+
return blockRegex().test(content);
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=agents-md.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agents-md.js","sourceRoot":"","sources":["../../src/skill/agents-md.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,MAAM,CAAC,MAAM,cAAc,GAAG,WAAW,CAAC;AAC1C,MAAM,CAAC,MAAM,YAAY,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,EAAE,MAAM,CAAC,CAAC;IAC7C,OAAO,UAAU,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;AACpC,CAAC"}
|
package/dist/skill/hosts.d.ts
CHANGED
|
@@ -2,20 +2,44 @@
|
|
|
2
2
|
* Skill host mapping & detection.
|
|
3
3
|
*
|
|
4
4
|
* Mirrors the ctxdb0 `#skillTarget` convention: each supported Agent host keeps
|
|
5
|
-
* its skills under `~/.<host>/skills/<skill>/`.
|
|
6
|
-
*
|
|
5
|
+
* its skills under `~/.<host>/skills/<skill>/`. User-level hosts are verified
|
|
6
|
+
* against vendor docs; unverified locations are NOT hardcoded here.
|
|
7
|
+
*
|
|
8
|
+
* Two install scopes exist:
|
|
9
|
+
* - `user` (default): the per-host directory under $HOME.
|
|
10
|
+
* - `project`: the repository-level convention (e.g. `.agents/skills`), so the
|
|
11
|
+
* skills travel with the code and cloud agents cloning the repo pick them up.
|
|
12
|
+
*
|
|
13
|
+
* The vendor-neutral key `agents` maps to `~/.agents/skills` / `.agents/skills`,
|
|
14
|
+
* which Codex scans and Copilot reads. It is intentionally excluded from `--all`
|
|
15
|
+
* (install it explicitly) to avoid duplicate copies next to per-host installs.
|
|
7
16
|
*/
|
|
8
|
-
export type HostName = 'qoder' | 'claude' | 'cursor' | 'qwen' | 'hermes';
|
|
9
|
-
/** Hosts supported by `pxbaas skill install
|
|
17
|
+
export type HostName = 'qoder' | 'claude' | 'cursor' | 'qwen' | 'hermes' | 'codex' | 'gemini' | 'copilot' | 'qwenworkcn' | 'agents';
|
|
18
|
+
/** Hosts supported by `pxbaas skill install --scope user`. */
|
|
10
19
|
export declare const SUPPORTED_HOSTS: HostName[];
|
|
20
|
+
/** Neutral locations: never installed by `--all`, only by explicit `--host`. */
|
|
21
|
+
export declare const ALL_EXCLUDED_HOSTS: HostName[];
|
|
22
|
+
/**
|
|
23
|
+
* Host keys accepted for `--scope project`. Some (trae/codebuddy/cline) publish
|
|
24
|
+
* only a repository-level convention, so they are project-scope only.
|
|
25
|
+
* Every path below is taken from vendor documentation; do not add guesses.
|
|
26
|
+
*/
|
|
27
|
+
export type ProjectHost = 'claude' | 'qwen' | 'codex' | 'agents' | 'gemini' | 'copilot' | 'trae' | 'codebuddy' | 'cline';
|
|
28
|
+
export declare const PROJECT_HOSTS: ProjectHost[];
|
|
29
|
+
/** Repository-relative skills directory per project-scope host. */
|
|
30
|
+
export declare const PROJECT_SKILL_DIR: Record<ProjectHost, string>;
|
|
11
31
|
export declare function isHostName(value: string): value is HostName;
|
|
12
|
-
|
|
32
|
+
export declare function isProjectHost(value: string): value is ProjectHost;
|
|
33
|
+
/** `~/.<host>/skills` root for a user-scope host. */
|
|
13
34
|
export declare function hostSkillsRoot(host: HostName, homeDir: string): string;
|
|
14
|
-
/** Full target directory for
|
|
35
|
+
/** Full target directory for a skill under a user-scope host. */
|
|
15
36
|
export declare function hostSkillDir(host: HostName, homeDir: string, skillName?: string): string;
|
|
37
|
+
/** Repository-level skills root for a project-scope host. */
|
|
38
|
+
export declare function projectSkillsRoot(host: ProjectHost, projectRoot: string): string;
|
|
16
39
|
/**
|
|
17
40
|
* Detect which supported hosts already have a `~/.<host>` directory, i.e. hosts
|
|
18
|
-
* the user plausibly uses. Used for auto-selection and `--all
|
|
41
|
+
* the user plausibly uses. Used for auto-selection and `--all` (which further
|
|
42
|
+
* excludes ALL_EXCLUDED_HOSTS at the caller).
|
|
19
43
|
*/
|
|
20
44
|
export declare function detectInstalledHosts(homeDir: string): HostName[];
|
|
21
45
|
//# sourceMappingURL=hosts.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hosts.d.ts","sourceRoot":"","sources":["../../src/skill/hosts.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"hosts.d.ts","sourceRoot":"","sources":["../../src/skill/hosts.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAKH,MAAM,MAAM,QAAQ,GAChB,OAAO,GACP,QAAQ,G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eps
|
|
5
|
-
* its skills under `~/.<host>/skills/<skill>/`.
|
|
6
|
-
*
|
|
5
|
+
* its skills under `~/.<host>/skills/<skill>/`. User-level hosts are verified
|
|
6
|
+
* against vendor docs; unverified locations are NOT hardcoded here.
|
|
7
|
+
*
|
|
8
|
+
* Two install scopes exist:
|
|
9
|
+
* - `user` (default): the per-host directory under $HOME.
|
|
10
|
+
* - `project`: the repository-level convention (e.g. `.agents/skills`), so the
|
|
11
|
+
* skills travel with the code and cloud agents cloning the repo pick them up.
|
|
12
|
+
*
|
|
13
|
+
* The vendor-neutral key `agents` maps to `~/.agents/skills` / `.agents/skills`,
|
|
14
|
+
* which Codex scans and Copilot reads. It is intentionally excluded from `--all`
|
|
15
|
+
* (install it explicitly) to avoid duplicate copies next to per-host installs.
|
|
7
16
|
*/
|
|
8
17
|
import { existsSync } from 'node:fs';
|
|
9
18
|
import { join } from 'node:path';
|
|
10
|
-
/** Hosts supported by `pxbaas skill install
|
|
11
|
-
export const SUPPORTED_HOSTS = [
|
|
19
|
+
/** Hosts supported by `pxbaas skill install --scope user`. */
|
|
20
|
+
export const SUPPORTED_HOSTS = [
|
|
21
|
+
'qoder',
|
|
22
|
+
'claude',
|
|
23
|
+
'cursor',
|
|
24
|
+
'qwen',
|
|
25
|
+
'hermes',
|
|
26
|
+
'codex',
|
|
27
|
+
'gemini',
|
|
28
|
+
'copilot',
|
|
29
|
+
'qwenworkcn',
|
|
30
|
+
'agents',
|
|
31
|
+
];
|
|
32
|
+
/** Neutral locations: never installed by `--all`, only by explicit `--host`. */
|
|
33
|
+
export const ALL_EXCLUDED_HOSTS = ['agents'];
|
|
12
34
|
/** Host name -> the dot-directory under $HOME that hosts its config/skills. */
|
|
13
35
|
const HOST_DIR = {
|
|
14
36
|
qoder: '.qoder',
|
|
@@ -16,21 +38,57 @@ const HOST_DIR = {
|
|
|
16
38
|
cursor: '.cursor',
|
|
17
39
|
qwen: '.qwen',
|
|
18
40
|
hermes: '.hermes',
|
|
41
|
+
codex: '.codex',
|
|
42
|
+
gemini: '.gemini',
|
|
43
|
+
copilot: '.copilot',
|
|
44
|
+
qwenworkcn: '.qwenworkcn',
|
|
45
|
+
agents: '.agents',
|
|
46
|
+
};
|
|
47
|
+
export const PROJECT_HOSTS = [
|
|
48
|
+
'claude',
|
|
49
|
+
'qwen',
|
|
50
|
+
'codex',
|
|
51
|
+
'agents',
|
|
52
|
+
'gemini',
|
|
53
|
+
'copilot',
|
|
54
|
+
'trae',
|
|
55
|
+
'codebuddy',
|
|
56
|
+
'cline',
|
|
57
|
+
];
|
|
58
|
+
/** Repository-relative skills directory per project-scope host. */
|
|
59
|
+
export const PROJECT_SKILL_DIR = {
|
|
60
|
+
claude: '.claude/skills',
|
|
61
|
+
qwen: '.qwen/skills',
|
|
62
|
+
codex: '.agents/skills',
|
|
63
|
+
agents: '.agents/skills',
|
|
64
|
+
gemini: '.gemini/skills',
|
|
65
|
+
copilot: '.github/skills',
|
|
66
|
+
trae: '.trae/skills',
|
|
67
|
+
codebuddy: '.codebuddy/skills',
|
|
68
|
+
cline: '.cline/skills',
|
|
19
69
|
};
|
|
20
70
|
export function isHostName(value) {
|
|
21
71
|
return SUPPORTED_HOSTS.includes(value);
|
|
22
72
|
}
|
|
23
|
-
|
|
73
|
+
export function isProjectHost(value) {
|
|
74
|
+
return PROJECT_HOSTS.includes(value);
|
|
75
|
+
}
|
|
76
|
+
/** `~/.<host>/skills` root for a user-scope host. */
|
|
24
77
|
export function hostSkillsRoot(host, homeDir) {
|
|
25
78
|
return join(homeDir, HOST_DIR[host], 'skills');
|
|
26
79
|
}
|
|
27
|
-
/** Full target directory for
|
|
80
|
+
/** Full target directory for a skill under a user-scope host. */
|
|
28
81
|
export function hostSkillDir(host, homeDir, skillName = 'pxbaas-cli') {
|
|
29
82
|
return join(hostSkillsRoot(host, homeDir), skillName);
|
|
30
83
|
}
|
|
84
|
+
/** Repository-level skills root for a project-scope host. */
|
|
85
|
+
export function projectSkillsRoot(host, projectRoot) {
|
|
86
|
+
return join(projectRoot, PROJECT_SKILL_DIR[host]);
|
|
87
|
+
}
|
|
31
88
|
/**
|
|
32
89
|
* Detect which supported hosts already have a `~/.<host>` directory, i.e. hosts
|
|
33
|
-
* the user plausibly uses. Used for auto-selection and `--all
|
|
90
|
+
* the user plausibly uses. Used for auto-selection and `--all` (which further
|
|
91
|
+
* excludes ALL_EXCLUDED_HOSTS at the caller).
|
|
34
92
|
*/
|
|
35
93
|
export function detectInstalledHosts(homeDir) {
|
|
36
94
|
return SUPPORTED_HOSTS.filter((host) => existsSync(join(homeDir, HOST_DIR[host])));
|
package/dist/skill/hosts.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hosts.js","sourceRoot":"","sources":["../../src/skill/hosts.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"hosts.js","sourceRoot":"","sources":["../../src/skill/hosts.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAcjC,8DAA8D;AAC9D,MAAM,CAAC,MAAM,eAAe,GAAe;IACzC,OAAO;IACP,QAAQ;IACR,QAAQ;IACR,MAAM;IACN,QAAQ;IACR,OAAO;IACP,QAAQ;IACR,SAAS;IACT,YAAY;IACZ,QAAQ;CACT,CAAC;AAEF,gFAAgF;AAChF,MAAM,CAAC,MAAM,kBAAkB,GAAe,CAAC,QAAQ,CAAC,CAAC;AAEzD,+EAA+E;AAC/E,MAAM,QAAQ,GAA6B;IACzC,KAAK,EAAE,QAAQ;IACf,MAAM,EAAE,SAAS;IACjB,MAAM,EAAE,SAAS;IACjB,IAAI,EAAE,OAAO;IACb,MAAM,EAAE,SAAS;IACjB,KAAK,EAAE,QAAQ;IACf,MAAM,EAAE,SAAS;IACjB,OAAO,EAAE,UAAU;IACnB,UAAU,EAAE,aAAa;IACzB,MA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,OAAe;IAClD,OAAO,eAAe,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;AACrF,CAAC"}
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* Layout: each host has a skills root (`~/.<host>/skills`); every bundled skill is
|
|
10
10
|
* installed into `<skillsRoot>/<skillName>/` with its own fail-closed owner marker.
|
|
11
11
|
*/
|
|
12
|
-
|
|
12
|
+
export type InstallScope = 'user' | 'project';
|
|
13
13
|
export type InstallStatus = 'installed' | 'updated' | 'skipped-foreign' | 'dry-run' | 'error';
|
|
14
14
|
export type RemoveStatus = 'removed' | 'not-installed' | 'skipped-foreign' | 'dry-run' | 'error';
|
|
15
15
|
export type ListStatus = 'installed' | 'not-installed' | 'foreign';
|
|
@@ -18,6 +18,7 @@ export interface SkillResult {
|
|
|
18
18
|
skill: string;
|
|
19
19
|
targetDir: string;
|
|
20
20
|
status: InstallStatus | RemoveStatus | ListStatus;
|
|
21
|
+
scope?: InstallScope;
|
|
21
22
|
filesWritten?: string[];
|
|
22
23
|
skillVersion?: string;
|
|
23
24
|
installedAt?: string;
|
|
@@ -30,6 +31,8 @@ export interface SkillManagerOptions {
|
|
|
30
31
|
skillsRoot?: string;
|
|
31
32
|
/** CLI version stamped into markers (defaults to readCliVersion()). */
|
|
32
33
|
cliVersion?: string;
|
|
34
|
+
/** Repository root for `--scope project` targets (defaults to process.cwd()). */
|
|
35
|
+
projectRoot?: string;
|
|
33
36
|
}
|
|
34
37
|
export interface InstallOptions {
|
|
35
38
|
dryRun?: boolean;
|
|
@@ -46,11 +49,13 @@ export interface RemoveOptions {
|
|
|
46
49
|
export interface ResolvedTarget {
|
|
47
50
|
host: string;
|
|
48
51
|
destRoot: string;
|
|
52
|
+
scope: InstallScope;
|
|
49
53
|
}
|
|
50
54
|
export declare class SkillManager {
|
|
51
55
|
private readonly homeDir;
|
|
52
56
|
private readonly skillsRoot;
|
|
53
57
|
private readonly cliVersion;
|
|
58
|
+
private readonly projectRoot;
|
|
54
59
|
private skillsCache;
|
|
55
60
|
constructor(options?: SkillManagerOptions);
|
|
56
61
|
/** Async factory that resolves the CLI version from package.json. */
|
|
@@ -61,14 +66,17 @@ export declare class SkillManager {
|
|
|
61
66
|
/**
|
|
62
67
|
* Resolve which host skills-roots to act on.
|
|
63
68
|
* - `--dir` wins (single custom skills-root, host label "custom")
|
|
64
|
-
* - `--
|
|
69
|
+
* - `--scope project` requires `--host` (a ProjectHost) or `--dir`; `--all` is
|
|
70
|
+
* user-scope only because writing every vendor repo directory is spammy
|
|
71
|
+
* - `--all` (user scope) → every detected host except ALL_EXCLUDED_HOSTS
|
|
65
72
|
* - `--host <h>` → that host
|
|
66
73
|
* - none → auto-detect: exactly one detected host is used; 0 or >1 is an error
|
|
67
74
|
*/
|
|
68
75
|
resolveTargets(opts: {
|
|
69
|
-
host?:
|
|
76
|
+
host?: string;
|
|
70
77
|
all?: boolean;
|
|
71
78
|
dir?: string;
|
|
79
|
+
scope?: InstallScope;
|
|
72
80
|
}): ResolvedTarget[];
|
|
73
81
|
/** Install all (or selected) bundled skills into each target's skills root. */
|
|
74
82
|
install(targets: ResolvedTarget[], options?: InstallOptions): Promise<SkillResult[]>;
|
|
@@ -77,6 +85,10 @@ export declare class SkillManager {
|
|
|
77
85
|
list(options?: {
|
|
78
86
|
skills?: string[];
|
|
79
87
|
}): Promise<SkillResult[]>;
|
|
88
|
+
/** Report install state of bundled skills in repository-level directories. */
|
|
89
|
+
listProject(options?: {
|
|
90
|
+
skills?: string[];
|
|
91
|
+
}): Promise<SkillResult[]>;
|
|
80
92
|
private listOne;
|
|
81
93
|
/**
|
|
82
94
|
* Remove bundled skills from each target. Only removes directories owned by
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"installer.d.ts","sourceRoot":"","sources":["../../src/skill/installer.ts"],"names":[],"mappings":"AAAA;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