@kanonak-protocol/cli 6.0.1 → 6.1.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.
@@ -8,10 +8,8 @@
8
8
  * publisher/package/instance
9
9
  * publisher/package@version/instance
10
10
  *
11
- * The optional `instanceName` selects a specific named entity inside
12
- * the package (e.g. one Skill out of several). When omitted, callers
13
- * that act on instances (like `kanonak skill add`) operate on every
14
- * instance of the relevant type.
11
+ * The optional `instanceName` names one entity inside the package.
12
+ * `kanonak install` works on whole packages and rejects it with a hint.
15
13
  */
16
14
  export interface PackageRef {
17
15
  publisher: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kanonak-protocol/cli",
3
- "version": "6.0.1",
3
+ "version": "6.1.0",
4
4
  "description": "Command-line tool for the Kanonak Protocol — validate, resolve, preview, and publish semantic ontology packages.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -35,15 +35,15 @@
35
35
  "semantic-web"
36
36
  ],
37
37
  "dependencies": {
38
- "@kanonak-protocol/sdk": "^6.0.1",
39
- "@kanonak-protocol/types": "^6.0.1",
40
- "commander": "^13.0.0",
41
- "js-yaml": "^4.1.1"
38
+ "@kanonak-protocol/sdk": "^6.1.0",
39
+ "@kanonak-protocol/types": "^6.1.0",
40
+ "commander": "^13.0.0"
42
41
  },
43
42
  "devDependencies": {
44
43
  "@kanonak-protocol/expression": "^1.1.0",
45
44
  "@types/js-yaml": "^4.0.9",
46
45
  "@types/node": "^20.0.0",
46
+ "js-yaml": "^4.1.1",
47
47
  "rimraf": "^5.0.0",
48
48
  "tsup": "^8.5.1",
49
49
  "tsx": "^4.19.0",
@@ -1,19 +0,0 @@
1
- import type { DeploymentContext, DeploymentHandler, DeployedInstance, OperationContext } from '../capabilities/DeploymentHandlerRegistry.js';
2
- /**
3
- * Deployment handler for the `AgentInstanceDeployment` DeploymentTarget.
4
- *
5
- * Transforms `kanonak.org/agents/Agent` instances into the target
6
- * client's on-disk file format (markdown-with-frontmatter for
7
- * Claude Code and Gemini CLI, TOML for Codex) and writes each one
8
- * into the directory declared by the named Client instance selected
9
- * via the `--client` option (defaulting to the "agents"
10
- * cross-client layout).
11
- */
12
- export declare class AgentDeploymentHandler implements DeploymentHandler {
13
- private readonly parser;
14
- private readonly objectParser;
15
- private readonly runner;
16
- deploy(context: DeploymentContext): Promise<void>;
17
- undeploy(name: string, context: OperationContext): Promise<void>;
18
- list(context: OperationContext): Promise<DeployedInstance[]>;
19
- }
@@ -1,15 +0,0 @@
1
- export interface AgentLockEntry {
2
- publisher: string;
3
- package_: string;
4
- version: string;
5
- resolved: string;
6
- integrity: string;
7
- fileName: string;
8
- }
9
- export interface AgentLockFile {
10
- version: string;
11
- lastUpdated: string;
12
- agents: Record<string, AgentLockEntry>;
13
- }
14
- export declare function loadAgentLock(agentsDir: string): AgentLockFile;
15
- export declare function saveAgentLock(agentsDir: string, lock: AgentLockFile): void;
@@ -1,23 +0,0 @@
1
- import type { IKanonakDocumentRepository } from '@kanonak-protocol/sdk';
2
- export type AgentFileFormat = 'markdown-frontmatter' | 'toml';
3
- export interface AgentPathOptions {
4
- client?: string;
5
- scope?: string;
6
- }
7
- export interface ResolvedAgentDeployment {
8
- agentsDir: string;
9
- format: AgentFileFormat;
10
- fileExtension: string;
11
- }
12
- export declare function detectClient(): string | undefined;
13
- /**
14
- * Resolve the agent deployment settings for the requested client
15
- * and scope: the target directory plus the on-disk format to write.
16
- *
17
- * Goes through the SDK object model: agent-skills is parsed, Client
18
- * instances are looked up by clientId, the selected Client's
19
- * projectAgentDir / userAgentDir and agentFileFormat are read, and
20
- * the AgentFileFormat reference is followed to extract the local
21
- * name (markdown-frontmatter / toml).
22
- */
23
- export declare function resolveAgentDeployment(options: AgentPathOptions, repository: IKanonakDocumentRepository): Promise<ResolvedAgentDeployment>;
@@ -1,61 +0,0 @@
1
- import { KanonakParser } from '@kanonak-protocol/sdk';
2
- import type { IKanonakDocumentRepository } from '@kanonak-protocol/sdk';
3
- import { FileCache } from '../cache/FileCache.js';
4
- import { EntityUri } from '@kanonak-protocol/sdk/uri-helpers';
5
- /**
6
- * Canonical URIs from the kanonak.org/capabilities ontology that the CLI
7
- * dispatches against. Version is intentionally omitted from matching so
8
- * the CLI accepts any backwards-compatible minor version.
9
- */
10
- export declare const CAPABILITIES_PUB = "kanonak.org";
11
- export declare const CAPABILITIES_PKG = "capabilities";
12
- export declare const CAPABILITY_CLASS_URI: EntityUri;
13
- /**
14
- * A loaded command argument definition.
15
- */
16
- export interface LoadedArgument {
17
- argumentName: string;
18
- required: boolean;
19
- isOption: boolean;
20
- defaultValue?: string;
21
- }
22
- /**
23
- * A loaded subcommand definition. `actionKey` is the canonical URI of
24
- * the Action this subcommand performs, formatted as
25
- * `publisher/package/name` (version omitted). The command registrar
26
- * dispatches by this key.
27
- */
28
- export interface LoadedCommand {
29
- subcommandName: string;
30
- description: string;
31
- arguments: LoadedArgument[];
32
- actionKey: string;
33
- }
34
- /**
35
- * A fully loaded capability with its command structure.
36
- * All identifier fields are canonical URI keys — not local names.
37
- */
38
- export interface LoadedCapability {
39
- commandName: string;
40
- description: string;
41
- managesTypeKey: string;
42
- deploymentTargetKey: string;
43
- commands: LoadedCommand[];
44
- publisher: string;
45
- package_: string;
46
- version: string;
47
- }
48
- /**
49
- * Load all installed capabilities from the capability store.
50
- *
51
- * Reads `capabilities.lock`, looks up each capability's cached
52
- * document, parses it through `KanonakObjectParser.parseKanonaks`
53
- * against a `SingleDocumentRepository` that delegates import
54
- * resolution to the given broader repo, then walks the resulting
55
- * `SubjectKanonak.statement[]` tree to extract the Capability
56
- * instance and its subcommands.
57
- *
58
- * Every identifier returned is a canonical URI key — alias handling
59
- * happens inside the SDK, never in this file.
60
- */
61
- export declare function loadInstalledCapabilities(fileCache: FileCache, parser: KanonakParser, repository: IKanonakDocumentRepository): Promise<LoadedCapability[]>;
@@ -1,30 +0,0 @@
1
- /**
2
- * Entry in the capabilities lock file tracking an installed capability.
3
- */
4
- export interface CapabilityStoreEntry {
5
- publisher: string;
6
- package_: string;
7
- version: string;
8
- resolved: string;
9
- integrity: string;
10
- }
11
- /**
12
- * The capabilities lock file structure.
13
- */
14
- export interface CapabilityStoreFile {
15
- version: string;
16
- lastUpdated: string;
17
- capabilities: Record<string, CapabilityStoreEntry>;
18
- }
19
- /**
20
- * Get the path to the global capabilities lock file.
21
- */
22
- export declare function getCapabilityStorePath(): string;
23
- /**
24
- * Load the capabilities lock file.
25
- */
26
- export declare function loadCapabilityStore(): CapabilityStoreFile;
27
- /**
28
- * Save the capabilities lock file.
29
- */
30
- export declare function saveCapabilityStore(store: CapabilityStoreFile): void;
@@ -1,12 +0,0 @@
1
- import { Command } from 'commander';
2
- import type { LoadedCapability } from './CapabilityLoader.js';
3
- import type { GenericCapabilityHandler } from './GenericCapabilityHandler.js';
4
- /**
5
- * Register Commander.js commands dynamically from loaded capability
6
- * definitions. For each installed capability, create a command group
7
- * named after its `commandName` property and attach each subcommand
8
- * with its declared positional and option arguments. All routing is
9
- * done through the Action URI each subcommand's `performs:` resolves
10
- * to.
11
- */
12
- export declare function registerCapabilityCommands(program: Command, capabilities: LoadedCapability[], handler: GenericCapabilityHandler): void;
@@ -1,69 +0,0 @@
1
- import type { IKanonakDocumentRepository, SubjectKanonak, Kanonak } from '@kanonak-protocol/sdk';
2
- /**
3
- * Information about a deployed instance.
4
- */
5
- export interface DeployedInstance {
6
- name: string;
7
- publisher: string;
8
- package_: string;
9
- version: string;
10
- path: string;
11
- }
12
- /**
13
- * Context passed to a deployment handler for a `deploy` call.
14
- *
15
- * `instances` is the list of `SubjectKanonak`s (each one is an
16
- * instance of the capability's `managesType`) to deploy. `allKanonaks`
17
- * is the full parsed kanonak list from the source document — handlers
18
- * use it to follow references (e.g. a skill's `license` reference to
19
- * the actual `License` subject for its `spdxId`).
20
- *
21
- * `repository` is the broader repository (local cache + HTTP) that the
22
- * handler can use to fetch entities from other packages when needed
23
- * (e.g. a `Tool` instance or `Client` instance defined in
24
- * `agent-skills`).
25
- */
26
- export interface DeploymentContext {
27
- instances: SubjectKanonak[];
28
- allKanonaks: Kanonak[];
29
- repository: IKanonakDocumentRepository;
30
- options: Record<string, string>;
31
- }
32
- /**
33
- * Context passed to a deployment handler for lifecycle operations
34
- * that are NOT about deploying a fresh instance (undeploy, list).
35
- * Carries the broader repository so handlers can still resolve
36
- * ontology entities like `Client` for per-product skill paths.
37
- */
38
- export interface OperationContext {
39
- repository: IKanonakDocumentRepository;
40
- options: Record<string, string>;
41
- }
42
- /**
43
- * Handler that deploys/undeploys instances of a managed type to the
44
- * local system.
45
- *
46
- * Each `DeploymentTarget` instance in the `kanonak.org/capabilities`
47
- * ontology has a matching handler in the `DeploymentHandlerRegistry`,
48
- * keyed by the target's canonical URI string
49
- * (`{publisher}/{package}/{name}`).
50
- */
51
- export interface DeploymentHandler {
52
- deploy(context: DeploymentContext): Promise<void>;
53
- undeploy(name: string, context: OperationContext): Promise<void>;
54
- list(context: OperationContext): Promise<DeployedInstance[]>;
55
- }
56
- /**
57
- * Registry that maps a DeploymentTarget URI key to its handler.
58
- *
59
- * The URI key is the canonical `{publisher}/{package}/{name}` string
60
- * of a named DeploymentTarget instance (e.g.
61
- * `kanonak.org/capabilities/AgentSkillDeployment`). Version is not
62
- * part of the key: new compatible versions of the ontology continue
63
- * to dispatch to the same handler.
64
- */
65
- export declare class DeploymentHandlerRegistry {
66
- private readonly handlers;
67
- register(targetUriKey: string, handler: DeploymentHandler): void;
68
- get(targetUriKey: string): DeploymentHandler | null;
69
- }
@@ -1,87 +0,0 @@
1
- import { KanonakParser, PublisherIndex } from '@kanonak-protocol/sdk';
2
- import type { AuthenticatedFetchFn, IKanonakDocumentRepository } from '@kanonak-protocol/sdk';
3
- import { FileCache } from '../cache/FileCache.js';
4
- import type { LoadedCapability } from './CapabilityLoader.js';
5
- import type { DeploymentHandlerRegistry } from './DeploymentHandlerRegistry.js';
6
- /**
7
- * Generic command handler that implements the standard Action set
8
- * (fetchAndDeploy, removeDeployed, listDeployed, updateDeployed,
9
- * searchAvailable, showInfo) in a type-agnostic way.
10
- *
11
- * The handler is parameterized by the LoadedCapability — specifically
12
- * its URI-keyed `managesTypeKey` and `deploymentTargetKey` — so the
13
- * same implementation supports any capability whose ontology resolves
14
- * cleanly through the SDK object model.
15
- */
16
- export declare class GenericCapabilityHandler {
17
- private readonly fileCache;
18
- private readonly parser;
19
- private readonly publisherIndex;
20
- private readonly fetchFn;
21
- private readonly handlerRegistry;
22
- private readonly repository;
23
- private readonly objectParser;
24
- constructor(fileCache: FileCache, parser: KanonakParser, publisherIndex: PublisherIndex, fetchFn: AuthenticatedFetchFn, handlerRegistry: DeploymentHandlerRegistry, repository: IKanonakDocumentRepository);
25
- /**
26
- * Fetch a package and deploy instances of the capability's managed
27
- * type. If the parsed reference includes an `instanceName`, only
28
- * that one instance is deployed; otherwise every matching instance
29
- * in the package is deployed.
30
- *
31
- * Resolution order for `packageRef`:
32
- * 1. Literal local file path (`./skill.kan.yml`, `C:\…\skill.kan.yml`,
33
- * or any existing path ending in `.kan.yml`) — read it directly
34
- * through the SDK parser, no workspace/cache/HTTP lookup.
35
- * 2. `publisher/package[@version][/instance]` URI — resolved
36
- * against the workspace + global cache repository tiers first,
37
- * falling back to the publisher's HTTP origin only when nothing
38
- * local matches. This makes `<cap> add` work for skills/agents
39
- * that the user has authored locally and not yet published.
40
- */
41
- add(capability: LoadedCapability, packageRef: string, options: Record<string, string>): Promise<void>;
42
- /**
43
- * Try to load `packageRef` as a literal local file path. Recognizes
44
- * any string that points to an existing file (typically with a
45
- * `.kan.yml` suffix). Returns `undefined` for anything that doesn't
46
- * look like a path — the caller falls back to URI-form parsing.
47
- *
48
- * Parsing goes through `KanonakParser.parse`; namespace metadata is
49
- * pulled directly from the parsed document so publisher/package/
50
- * version come from the file's own declarations rather than any
51
- * heuristic on the path.
52
- */
53
- private tryLoadFromLocalFile;
54
- /**
55
- * Shared deployment path used by both the URI-form `add()` and the
56
- * local-file-path form. Parses the document through the SDK object
57
- * model, finds matching instances of the capability's managed type,
58
- * and dispatches to the deployment handler keyed by deploymentTarget.
59
- *
60
- * `description` is the human-readable source label (a package URI
61
- * or `local file <path>`) used in the user-facing output and error
62
- * messages — keeping the URI flow's wording stable.
63
- */
64
- private deployFromDoc;
65
- /**
66
- * A publisher's OWN packages as pinned by its served `kanonak.lock` (keys
67
- * under `<publisher>/`). The lock-derived package list — there is no index
68
- * enumeration. Empty when the publisher serves no lock.
69
- */
70
- private lockedOwnPackages;
71
- /**
72
- * On a "package not found" error, scan the publisher's pinned packages for
73
- * approximate name matches and print up to 5 suggestions. Helps users recover
74
- * from typos and from passing a 3-segment URI to `add`.
75
- */
76
- private printPackageSuggestions;
77
- remove(capability: LoadedCapability, name: string, options: Record<string, string>): Promise<void>;
78
- list(capability: LoadedCapability, options: Record<string, string>): Promise<void>;
79
- update(capability: LoadedCapability, name: string | undefined, options: Record<string, string>): Promise<void>;
80
- /**
81
- * Search a publisher's package index for any package that contains
82
- * instances of this capability's `managesType`.
83
- */
84
- search(capability: LoadedCapability, options: Record<string, string>): Promise<void>;
85
- info(capability: LoadedCapability, name: string, options: Record<string, string>): Promise<void>;
86
- private requireHandler;
87
- }
@@ -1,9 +0,0 @@
1
- import { Command } from 'commander';
2
- /**
3
- * Create the built-in "capability" command group.
4
- *
5
- * This is the bootstrap mechanism — always available, not dynamically
6
- * loaded. Used to install, remove, and list capabilities that extend
7
- * the CLI.
8
- */
9
- export declare function capabilityCommand(): Command;
@@ -1,18 +0,0 @@
1
- import type { DeploymentContext, DeploymentHandler, DeployedInstance, OperationContext } from '../capabilities/DeploymentHandlerRegistry.js';
2
- /**
3
- * Deployment handler for the `AgentSkillDeployment` DeploymentTarget.
4
- *
5
- * Transforms `kanonak.org/agent-skills/Skill` instances into SKILL.md
6
- * files and places them in the directory declared by the named
7
- * Client instance selected via the `--client` option (defaulting to
8
- * the "agents" cross-client layout). All path resolution and
9
- * reference following goes through the SDK object model.
10
- */
11
- export declare class SkillDeploymentHandler implements DeploymentHandler {
12
- private readonly parser;
13
- private readonly objectParser;
14
- private readonly runner;
15
- deploy(context: DeploymentContext): Promise<void>;
16
- undeploy(name: string, context: OperationContext): Promise<void>;
17
- list(context: OperationContext): Promise<DeployedInstance[]>;
18
- }
@@ -1,26 +0,0 @@
1
- /**
2
- * Entry in the skills lock file tracking an installed skill.
3
- */
4
- export interface SkillLockEntry {
5
- publisher: string;
6
- package_: string;
7
- version: string;
8
- resolved: string;
9
- integrity: string;
10
- }
11
- /**
12
- * The skills lock file structure.
13
- */
14
- export interface SkillLockFile {
15
- version: string;
16
- lastUpdated: string;
17
- skills: Record<string, SkillLockEntry>;
18
- }
19
- /**
20
- * Load the skills lock file from a skills directory.
21
- */
22
- export declare function loadSkillLock(skillsDir: string): SkillLockFile;
23
- /**
24
- * Save the skills lock file to a skills directory.
25
- */
26
- export declare function saveSkillLock(skillsDir: string, lock: SkillLockFile): void;
@@ -1,48 +0,0 @@
1
- import type { IKanonakDocumentRepository } from '@kanonak-protocol/sdk';
2
- /**
3
- * Options for resolving skill discovery paths.
4
- */
5
- export interface SkillPathOptions {
6
- /**
7
- * clientId of a named Client instance in the agent-skills ontology
8
- * (e.g. "agents", "claude-code"). When omitted, the CLI first tries
9
- * `detectClient()` on process env vars, then falls back to the
10
- * "agents" cross-client default.
11
- */
12
- client?: string;
13
- /** "project" (default) or "user". */
14
- scope?: string;
15
- }
16
- /**
17
- * Resolve the skills directory for the requested client and scope.
18
- *
19
- * This goes through the SDK object model: the agent-skills ontology
20
- * is parsed, Client instances are looked up by URI, and the matching
21
- * Client's `projectSkillDir` or `userSkillDir` is read. No hardcoded
22
- * path templates, no alias string-stripping — the installer adapts
23
- * to whatever named Client instances exist in the ontology at
24
- * runtime.
25
- */
26
- export declare function resolveSkillsDir(options: SkillPathOptions, repository: IKanonakDocumentRepository): Promise<string>;
27
- /**
28
- * Resolve the directory for a specific skill by name.
29
- */
30
- export declare function resolveSkillDir(skillName: string, options: SkillPathOptions, repository: IKanonakDocumentRepository): Promise<string>;
31
- /**
32
- * Resolve the file name to use inside a skill directory for the
33
- * configured Client. Pulled from the Client's `skillFileName` property
34
- * in agent-skills@1.2.0+. Defaults to `SKILL.md` when the Client
35
- * predates the property or doesn't declare it explicitly — which
36
- * matches the Agent Skills convention every shipped Client follows.
37
- */
38
- export declare function resolveSkillFileName(options: SkillPathOptions, repository: IKanonakDocumentRepository): Promise<string>;
39
- /**
40
- * Auto-detect the current AI agent client from environment variables.
41
- * Returns a clientId matching a named Client instance in the
42
- * agent-skills ontology, or undefined when nothing is detected.
43
- *
44
- * Matches the default Client instances declared in
45
- * kanonak.org/agent-skills@1.1.0. Extend this mapping when adding
46
- * new named Client instances with their own env-var signature.
47
- */
48
- export declare function detectClient(): string | undefined;