@pulsemcp/air-sdk 0.0.11 → 0.0.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/init-from-repo.d.ts +93 -0
- package/dist/init-from-repo.d.ts.map +1 -0
- package/dist/init-from-repo.js +265 -0
- package/dist/init-from-repo.js.map +1 -0
- package/dist/init.d.ts +1 -4
- package/dist/init.d.ts.map +1 -1
- package/dist/init.js +3 -29
- package/dist/init.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -6,6 +6,8 @@ export { validateFile } from "./validate.js";
|
|
|
6
6
|
export type { ValidateFileOptions, ValidateFileResult } from "./validate.js";
|
|
7
7
|
export { initConfig } from "./init.js";
|
|
8
8
|
export type { InitConfigOptions, InitConfigResult } from "./init.js";
|
|
9
|
+
export { initFromRepo, smartInit, InitFromRepoError } from "./init-from-repo.js";
|
|
10
|
+
export type { InitFromRepoOptions, InitFromRepoResult, InitFromRepoErrorCode, DiscoveredArtifact, SmartInitResult, } from "./init-from-repo.js";
|
|
9
11
|
export { listArtifacts, VALID_ARTIFACT_TYPES } from "./list.js";
|
|
10
12
|
export type { ArtifactType, ListArtifactsOptions, ListArtifactsResult } from "./list.js";
|
|
11
13
|
export { startSession } from "./start.js";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,aAAa,EACb,qBAAqB,EACrB,cAAc,EACd,gBAAgB,EAChB,cAAc,EACd,aAAa,EACb,cAAc,EAEd,YAAY,EAEZ,aAAa,EACb,aAAa,EACb,UAAU,EACV,gBAAgB,EAChB,qBAAqB,EACrB,iBAAiB,EACjB,iBAAiB,GAClB,MAAM,oBAAoB,CAAC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E,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAErE,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACjF,YAAY,EACV,mBAAmB,EACnB,kBAAkB,EAClB,qBAAqB,EACrB,kBAAkB,EAClB,eAAe,GAChB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AAChE,YAAY,EAAE,YAAY,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAEzF,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,YAAY,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAE1E,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,YAAY,EACV,qBAAqB,EACrB,oBAAoB,GACrB,MAAM,cAAc,CAAC;AAGtB,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACjD,YAAY,EACV,wBAAwB,EACxB,uBAAuB,GACxB,MAAM,cAAc,CAAC;AAGtB,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,YAAY,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAG9D,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,YAAY,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAGlE,OAAO,EACL,kBAAkB,EAClB,wBAAwB,EACxB,qBAAqB,GACtB,MAAM,sBAAsB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -13,6 +13,7 @@ export { normalizeGitUrl, detectRoot } from "./root-detection.js";
|
|
|
13
13
|
// High-level operations
|
|
14
14
|
export { validateFile } from "./validate.js";
|
|
15
15
|
export { initConfig } from "./init.js";
|
|
16
|
+
export { initFromRepo, smartInit, InitFromRepoError } from "./init-from-repo.js";
|
|
16
17
|
export { listArtifacts, VALID_ARTIFACT_TYPES } from "./list.js";
|
|
17
18
|
export { startSession } from "./start.js";
|
|
18
19
|
export { prepareSession } from "./prepare.js";
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,iDAAiD;AACjD,OAAO;AACL,oBAAoB;AACpB,aAAa,EACb,qBAAqB,EACrB,cAAc,EACd,gBAAgB,EAChB,cAAc,EACd,aAAa,EACb,cAAc;AACd,aAAa;AACb,YAAY;AACZ,UAAU;AACV,aAAa,EACb,aAAa,EACb,UAAU,EACV,gBAAgB,EAChB,qBAAqB,EACrB,iBAAiB,EACjB,iBAAiB,GAClB,MAAM,oBAAoB,CAAC;AAoC5B,mBAAmB;AACnB,OAAO,EAAE,WAAW,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAE3E,iBAAiB;AACjB,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAElE,wBAAwB;AACxB,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAG7C,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAGvC,OAAO,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AAGhE,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAG1C,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAM9C,sBAAsB;AACtB,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAMjD,mBAAmB;AACnB,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAGvD,mBAAmB;AACnB,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAGtD,oBAAoB;AACpB,OAAO,EACL,kBAAkB,EAClB,wBAAwB,EACxB,qBAAqB,GACtB,MAAM,sBAAsB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,iDAAiD;AACjD,OAAO;AACL,oBAAoB;AACpB,aAAa,EACb,qBAAqB,EACrB,cAAc,EACd,gBAAgB,EAChB,cAAc,EACd,aAAa,EACb,cAAc;AACd,aAAa;AACb,YAAY;AACZ,UAAU;AACV,aAAa,EACb,aAAa,EACb,UAAU,EACV,gBAAgB,EAChB,qBAAqB,EACrB,iBAAiB,EACjB,iBAAiB,GAClB,MAAM,oBAAoB,CAAC;AAoC5B,mBAAmB;AACnB,OAAO,EAAE,WAAW,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAE3E,iBAAiB;AACjB,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAElE,wBAAwB;AACxB,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAG7C,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAGvC,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AASjF,OAAO,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AAGhE,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAG1C,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAM9C,sBAAsB;AACtB,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAMjD,mBAAmB;AACnB,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAGvD,mBAAmB;AACnB,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAGtD,oBAAoB;AACpB,OAAO,EACL,kBAAkB,EAClB,wBAAwB,EACxB,qBAAqB,GACtB,MAAM,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { type SchemaType } from "@pulsemcp/air-core";
|
|
2
|
+
/** Error codes for `initFromRepo` failures. */
|
|
3
|
+
export type InitFromRepoErrorCode = "EXISTS" | "NO_GIT" | "NO_REMOTE" | "NO_GITHUB" | "NO_ARTIFACTS";
|
|
4
|
+
/**
|
|
5
|
+
* Typed error thrown by `initFromRepo` for classifiable failure conditions.
|
|
6
|
+
* Consumers can switch on `code` instead of matching error messages.
|
|
7
|
+
*/
|
|
8
|
+
export declare class InitFromRepoError extends Error {
|
|
9
|
+
readonly code: InitFromRepoErrorCode;
|
|
10
|
+
constructor(message: string, code: InitFromRepoErrorCode);
|
|
11
|
+
}
|
|
12
|
+
export interface InitFromRepoOptions {
|
|
13
|
+
/** Working directory (must be inside a git repo). Defaults to process.cwd(). */
|
|
14
|
+
cwd?: string;
|
|
15
|
+
/** Path for the generated air.json. Defaults to ~/.air/air.json. */
|
|
16
|
+
path?: string;
|
|
17
|
+
/** Overwrite existing air.json if it exists. */
|
|
18
|
+
force?: boolean;
|
|
19
|
+
}
|
|
20
|
+
export interface DiscoveredArtifact {
|
|
21
|
+
/** Artifact type (skills, references, mcp, etc.) */
|
|
22
|
+
type: SchemaType;
|
|
23
|
+
/** Path relative to repo root. */
|
|
24
|
+
repoPath: string;
|
|
25
|
+
/** Generated github:// URI. */
|
|
26
|
+
uri: string;
|
|
27
|
+
}
|
|
28
|
+
export interface InitFromRepoResult {
|
|
29
|
+
/** Absolute path to the created air.json. */
|
|
30
|
+
airJsonPath: string;
|
|
31
|
+
/** Absolute path to the AIR config directory. */
|
|
32
|
+
airDir: string;
|
|
33
|
+
/** GitHub owner/repo detected from git remote. */
|
|
34
|
+
repo: string;
|
|
35
|
+
/** Branch used for github:// URIs. */
|
|
36
|
+
branch: string;
|
|
37
|
+
/** Discovered artifact files grouped by type. */
|
|
38
|
+
discovered: DiscoveredArtifact[];
|
|
39
|
+
/** Whether an existing config was overwritten. */
|
|
40
|
+
overwritten: boolean;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Parse a git remote URL and extract the GitHub owner/repo.
|
|
44
|
+
* Supports HTTPS and SSH formats.
|
|
45
|
+
*
|
|
46
|
+
* @returns "owner/repo" string
|
|
47
|
+
* @throws Error if the URL is not a github.com URL
|
|
48
|
+
*/
|
|
49
|
+
export declare function parseGitHubRemote(remoteUrl: string): string;
|
|
50
|
+
/**
|
|
51
|
+
* Detect the default branch name for the remote.
|
|
52
|
+
*
|
|
53
|
+
* Tries `git symbolic-ref refs/remotes/origin/HEAD` first,
|
|
54
|
+
* then checks for common branch names (main, master).
|
|
55
|
+
* Falls back to "main".
|
|
56
|
+
*/
|
|
57
|
+
export declare function detectDefaultBranch(cwd: string): string;
|
|
58
|
+
/**
|
|
59
|
+
* Discover AIR artifact index files in the git repository.
|
|
60
|
+
*
|
|
61
|
+
* Lists tracked JSON files via `git ls-files`, detects their schema type
|
|
62
|
+
* by filename, and validates them against the schema. Returns only files
|
|
63
|
+
* that are valid artifact indexes.
|
|
64
|
+
*/
|
|
65
|
+
export declare function discoverArtifacts(repoRoot: string, repo: string, branch: string): DiscoveredArtifact[];
|
|
66
|
+
/**
|
|
67
|
+
* Initialize an AIR config from artifact files discovered in a git repository.
|
|
68
|
+
*
|
|
69
|
+
* Scans the git repo for artifact index files (skills.json, mcp.json, etc.),
|
|
70
|
+
* detects the GitHub remote, and generates an air.json with github:// URIs
|
|
71
|
+
* pointing to the repository's default branch.
|
|
72
|
+
*
|
|
73
|
+
* @throws Error if not in a git repo, no GitHub remote, no artifacts found,
|
|
74
|
+
* or air.json already exists (unless force is true).
|
|
75
|
+
*/
|
|
76
|
+
export declare function initFromRepo(options?: InitFromRepoOptions): InitFromRepoResult;
|
|
77
|
+
/** Result from `smartInit` — discriminated by `mode`. */
|
|
78
|
+
export type SmartInitResult = ({
|
|
79
|
+
mode: "repo";
|
|
80
|
+
} & InitFromRepoResult) | {
|
|
81
|
+
mode: "blank";
|
|
82
|
+
airJsonPath: string;
|
|
83
|
+
airDir: string;
|
|
84
|
+
};
|
|
85
|
+
/**
|
|
86
|
+
* High-level init that tries repo-based discovery first and falls back to
|
|
87
|
+
* blank scaffolding when no git context or artifacts are available.
|
|
88
|
+
*
|
|
89
|
+
* @throws InitFromRepoError with code "EXISTS" if config exists and force is false.
|
|
90
|
+
* @throws Error for unexpected failures.
|
|
91
|
+
*/
|
|
92
|
+
export declare function smartInit(options?: InitFromRepoOptions): SmartInitResult;
|
|
93
|
+
//# sourceMappingURL=init-from-repo.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init-from-repo.d.ts","sourceRoot":"","sources":["../src/init-from-repo.ts"],"names":[],"mappings":"AASA,OAAO,EAKL,KAAK,UAAU,EAChB,MAAM,oBAAoB,CAAC;AAQ5B,+CAA+C;AAC/C,MAAM,MAAM,qBAAqB,GAC7B,QAAQ,GACR,QAAQ,GACR,WAAW,GACX,WAAW,GACX,cAAc,CAAC;AAEnB;;;GAGG;AACH,qBAAa,iBAAkB,SAAQ,KAAK;aAGxB,IAAI,EAAE,qBAAqB;gBAD3C,OAAO,EAAE,MAAM,EACC,IAAI,EAAE,qBAAqB;CAK9C;AAED,MAAM,WAAW,mBAAmB;IAClC,gFAAgF;IAChF,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,oEAAoE;IACpE,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,gDAAgD;IAChD,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,MAAM,WAAW,kBAAkB;IACjC,oDAAoD;IACpD,IAAI,EAAE,UAAU,CAAC;IACjB,kCAAkC;IAClC,QAAQ,EAAE,MAAM,CAAC;IACjB,+BAA+B;IAC/B,GAAG,EAAE,MAAM,CAAC;CACb;AAED,MAAM,WAAW,kBAAkB;IACjC,6CAA6C;IAC7C,WAAW,EAAE,MAAM,CAAC;IACpB,iDAAiD;IACjD,MAAM,EAAE,MAAM,CAAC;IACf,kDAAkD;IAClD,IAAI,EAAE,MAAM,CAAC;IACb,sCAAsC;IACtC,MAAM,EAAE,MAAM,CAAC;IACf,iDAAiD;IACjD,UAAU,EAAE,kBAAkB,EAAE,CAAC;IACjC,kDAAkD;IAClD,WAAW,EAAE,OAAO,CAAC;CACtB;AAaD;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAiB3D;AAaD;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAiCvD;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAC/B,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,GACb,kBAAkB,EAAE,CA8CtB;AAED;;;;;;;;;GASG;AACH,wBAAgB,YAAY,CAC1B,OAAO,CAAC,EAAE,mBAAmB,GAC5B,kBAAkB,CAiGpB;AAED,yDAAyD;AACzD,MAAM,MAAM,eAAe,GACvB,CAAC;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG,kBAAkB,CAAC,GACvC;IACE,IAAI,EAAE,OAAO,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEN;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,OAAO,CAAC,EAAE,mBAAmB,GAAG,eAAe,CAuBxE"}
|
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
import { execFileSync } from "child_process";
|
|
2
|
+
import { readFileSync, existsSync, writeFileSync, mkdirSync, unlinkSync, } from "fs";
|
|
3
|
+
import { resolve, dirname } from "path";
|
|
4
|
+
import { getDefaultAirJsonPath, detectSchemaType, getAllSchemaTypes, validateJson, } from "@pulsemcp/air-core";
|
|
5
|
+
import { initConfig } from "./init.js";
|
|
6
|
+
/** Artifact types that map to air.json properties (all schema types except "air"). */
|
|
7
|
+
const ARTIFACT_TYPES = getAllSchemaTypes().filter((t) => t !== "air");
|
|
8
|
+
/**
|
|
9
|
+
* Typed error thrown by `initFromRepo` for classifiable failure conditions.
|
|
10
|
+
* Consumers can switch on `code` instead of matching error messages.
|
|
11
|
+
*/
|
|
12
|
+
export class InitFromRepoError extends Error {
|
|
13
|
+
code;
|
|
14
|
+
constructor(message, code) {
|
|
15
|
+
super(message);
|
|
16
|
+
this.code = code;
|
|
17
|
+
this.name = "InitFromRepoError";
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Get the git repository root directory.
|
|
22
|
+
*/
|
|
23
|
+
function getRepoRoot(cwd) {
|
|
24
|
+
return execFileSync("git", ["rev-parse", "--show-toplevel"], {
|
|
25
|
+
cwd,
|
|
26
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
27
|
+
encoding: "utf-8",
|
|
28
|
+
}).trim();
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Parse a git remote URL and extract the GitHub owner/repo.
|
|
32
|
+
* Supports HTTPS and SSH formats.
|
|
33
|
+
*
|
|
34
|
+
* @returns "owner/repo" string
|
|
35
|
+
* @throws Error if the URL is not a github.com URL
|
|
36
|
+
*/
|
|
37
|
+
export function parseGitHubRemote(remoteUrl) {
|
|
38
|
+
const trimmed = remoteUrl.trim();
|
|
39
|
+
// SSH: git@github.com:owner/repo.git
|
|
40
|
+
const sshMatch = trimmed.match(/^git@github\.com:(.+?)(?:\.git)?$/);
|
|
41
|
+
if (sshMatch)
|
|
42
|
+
return sshMatch[1];
|
|
43
|
+
// HTTPS: https://github.com/owner/repo.git
|
|
44
|
+
const httpsMatch = trimmed.match(/^https?:\/\/github\.com\/(.+?)(?:\.git)?$/);
|
|
45
|
+
if (httpsMatch)
|
|
46
|
+
return httpsMatch[1];
|
|
47
|
+
throw new Error(`Could not parse GitHub owner/repo from remote URL: "${trimmed}"\n` +
|
|
48
|
+
`Expected a github.com URL (HTTPS or SSH).`);
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Get the git remote URL for the given remote name.
|
|
52
|
+
*/
|
|
53
|
+
function getRemoteUrl(cwd, remote = "origin") {
|
|
54
|
+
return execFileSync("git", ["remote", "get-url", remote], {
|
|
55
|
+
cwd,
|
|
56
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
57
|
+
encoding: "utf-8",
|
|
58
|
+
}).trim();
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Detect the default branch name for the remote.
|
|
62
|
+
*
|
|
63
|
+
* Tries `git symbolic-ref refs/remotes/origin/HEAD` first,
|
|
64
|
+
* then checks for common branch names (main, master).
|
|
65
|
+
* Falls back to "main".
|
|
66
|
+
*/
|
|
67
|
+
export function detectDefaultBranch(cwd) {
|
|
68
|
+
// Try symbolic-ref (works when remote HEAD is set)
|
|
69
|
+
try {
|
|
70
|
+
const ref = execFileSync("git", ["symbolic-ref", "refs/remotes/origin/HEAD"], {
|
|
71
|
+
cwd,
|
|
72
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
73
|
+
encoding: "utf-8",
|
|
74
|
+
}).trim();
|
|
75
|
+
const branch = ref.replace(/^refs\/remotes\/origin\//, "");
|
|
76
|
+
if (branch)
|
|
77
|
+
return branch;
|
|
78
|
+
}
|
|
79
|
+
catch {
|
|
80
|
+
// Ignore — try fallbacks
|
|
81
|
+
}
|
|
82
|
+
// Probe common branch names
|
|
83
|
+
for (const branch of ["main", "master"]) {
|
|
84
|
+
try {
|
|
85
|
+
execFileSync("git", ["rev-parse", "--verify", `origin/${branch}`], {
|
|
86
|
+
cwd,
|
|
87
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
88
|
+
encoding: "utf-8",
|
|
89
|
+
});
|
|
90
|
+
return branch;
|
|
91
|
+
}
|
|
92
|
+
catch {
|
|
93
|
+
// continue
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
return "main";
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Discover AIR artifact index files in the git repository.
|
|
100
|
+
*
|
|
101
|
+
* Lists tracked JSON files via `git ls-files`, detects their schema type
|
|
102
|
+
* by filename, and validates them against the schema. Returns only files
|
|
103
|
+
* that are valid artifact indexes.
|
|
104
|
+
*/
|
|
105
|
+
export function discoverArtifacts(repoRoot, repo, branch) {
|
|
106
|
+
let output;
|
|
107
|
+
try {
|
|
108
|
+
output = execFileSync("git", ["ls-files", "--", "*.json"], {
|
|
109
|
+
cwd: repoRoot,
|
|
110
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
111
|
+
encoding: "utf-8",
|
|
112
|
+
}).trim();
|
|
113
|
+
}
|
|
114
|
+
catch {
|
|
115
|
+
return [];
|
|
116
|
+
}
|
|
117
|
+
if (!output)
|
|
118
|
+
return [];
|
|
119
|
+
const jsonFiles = output.split("\n").filter(Boolean);
|
|
120
|
+
const discovered = [];
|
|
121
|
+
for (const file of jsonFiles) {
|
|
122
|
+
// Skip files in node_modules or hidden directories (root or nested)
|
|
123
|
+
if (file.includes("node_modules/") || /(?:^|\/)\./.test(file))
|
|
124
|
+
continue;
|
|
125
|
+
const schemaType = detectSchemaType(file);
|
|
126
|
+
// Skip non-artifact files and air.json configs
|
|
127
|
+
if (!schemaType || schemaType === "air")
|
|
128
|
+
continue;
|
|
129
|
+
if (!ARTIFACT_TYPES.includes(schemaType))
|
|
130
|
+
continue;
|
|
131
|
+
// Validate the file actually matches the schema
|
|
132
|
+
const filePath = resolve(repoRoot, file);
|
|
133
|
+
try {
|
|
134
|
+
const content = readFileSync(filePath, "utf-8");
|
|
135
|
+
const data = JSON.parse(content);
|
|
136
|
+
const result = validateJson(data, schemaType);
|
|
137
|
+
if (!result.valid)
|
|
138
|
+
continue;
|
|
139
|
+
}
|
|
140
|
+
catch {
|
|
141
|
+
continue;
|
|
142
|
+
}
|
|
143
|
+
discovered.push({
|
|
144
|
+
type: schemaType,
|
|
145
|
+
repoPath: file,
|
|
146
|
+
uri: `github://${repo}@${branch}/${file}`,
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
return discovered;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Initialize an AIR config from artifact files discovered in a git repository.
|
|
153
|
+
*
|
|
154
|
+
* Scans the git repo for artifact index files (skills.json, mcp.json, etc.),
|
|
155
|
+
* detects the GitHub remote, and generates an air.json with github:// URIs
|
|
156
|
+
* pointing to the repository's default branch.
|
|
157
|
+
*
|
|
158
|
+
* @throws Error if not in a git repo, no GitHub remote, no artifacts found,
|
|
159
|
+
* or air.json already exists (unless force is true).
|
|
160
|
+
*/
|
|
161
|
+
export function initFromRepo(options) {
|
|
162
|
+
const cwd = options?.cwd ?? process.cwd();
|
|
163
|
+
const airJsonPath = options?.path ?? getDefaultAirJsonPath();
|
|
164
|
+
const force = options?.force ?? false;
|
|
165
|
+
const airDir = dirname(airJsonPath);
|
|
166
|
+
// Check for existing config
|
|
167
|
+
const overwritten = existsSync(airJsonPath);
|
|
168
|
+
if (overwritten && !force) {
|
|
169
|
+
throw new InitFromRepoError(`${airJsonPath} already exists.`, "EXISTS");
|
|
170
|
+
}
|
|
171
|
+
// Get repo root
|
|
172
|
+
let repoRoot;
|
|
173
|
+
try {
|
|
174
|
+
repoRoot = getRepoRoot(cwd);
|
|
175
|
+
}
|
|
176
|
+
catch {
|
|
177
|
+
throw new InitFromRepoError("Not inside a git repository. Run this command from within a git repo " +
|
|
178
|
+
"that contains AIR artifact index files.", "NO_GIT");
|
|
179
|
+
}
|
|
180
|
+
// Get GitHub remote
|
|
181
|
+
let remoteUrl;
|
|
182
|
+
try {
|
|
183
|
+
remoteUrl = getRemoteUrl(cwd);
|
|
184
|
+
}
|
|
185
|
+
catch {
|
|
186
|
+
throw new InitFromRepoError("No git remote named 'origin' found. " +
|
|
187
|
+
"Add a GitHub remote with: git remote add origin <url>", "NO_REMOTE");
|
|
188
|
+
}
|
|
189
|
+
let repo;
|
|
190
|
+
try {
|
|
191
|
+
repo = parseGitHubRemote(remoteUrl);
|
|
192
|
+
}
|
|
193
|
+
catch (err) {
|
|
194
|
+
throw new InitFromRepoError(err instanceof Error ? err.message : String(err), "NO_GITHUB");
|
|
195
|
+
}
|
|
196
|
+
const branch = detectDefaultBranch(cwd);
|
|
197
|
+
const discovered = discoverArtifacts(repoRoot, repo, branch);
|
|
198
|
+
if (discovered.length === 0) {
|
|
199
|
+
throw new InitFromRepoError("No AIR artifact index files found in this repository.\n" +
|
|
200
|
+
"Expected files like skills.json, mcp.json, references.json, etc.", "NO_ARTIFACTS");
|
|
201
|
+
}
|
|
202
|
+
// Group URIs by artifact type
|
|
203
|
+
const grouped = {};
|
|
204
|
+
for (const artifact of discovered) {
|
|
205
|
+
if (!grouped[artifact.type]) {
|
|
206
|
+
grouped[artifact.type] = [];
|
|
207
|
+
}
|
|
208
|
+
grouped[artifact.type].push(artifact.uri);
|
|
209
|
+
}
|
|
210
|
+
// Derive config name from repo name
|
|
211
|
+
const repoName = repo.split("/")[1] || "my-config";
|
|
212
|
+
const configName = repoName.replace(/[^a-zA-Z0-9_-]/g, "-");
|
|
213
|
+
// Build air.json
|
|
214
|
+
const airJson = {
|
|
215
|
+
name: configName,
|
|
216
|
+
extensions: ["@pulsemcp/air-provider-github"],
|
|
217
|
+
};
|
|
218
|
+
for (const type of ARTIFACT_TYPES) {
|
|
219
|
+
if (grouped[type]) {
|
|
220
|
+
airJson[type] = grouped[type];
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
// Write config
|
|
224
|
+
mkdirSync(airDir, { recursive: true });
|
|
225
|
+
writeFileSync(airJsonPath, JSON.stringify(airJson, null, 2) + "\n");
|
|
226
|
+
return {
|
|
227
|
+
airJsonPath,
|
|
228
|
+
airDir,
|
|
229
|
+
repo,
|
|
230
|
+
branch,
|
|
231
|
+
discovered,
|
|
232
|
+
overwritten,
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* High-level init that tries repo-based discovery first and falls back to
|
|
237
|
+
* blank scaffolding when no git context or artifacts are available.
|
|
238
|
+
*
|
|
239
|
+
* @throws InitFromRepoError with code "EXISTS" if config exists and force is false.
|
|
240
|
+
* @throws Error for unexpected failures.
|
|
241
|
+
*/
|
|
242
|
+
export function smartInit(options) {
|
|
243
|
+
const force = options?.force ?? false;
|
|
244
|
+
try {
|
|
245
|
+
const result = initFromRepo(options);
|
|
246
|
+
return { mode: "repo", ...result };
|
|
247
|
+
}
|
|
248
|
+
catch (err) {
|
|
249
|
+
if (!(err instanceof InitFromRepoError))
|
|
250
|
+
throw err;
|
|
251
|
+
// Config already exists — don't silently fall back
|
|
252
|
+
if (err.code === "EXISTS")
|
|
253
|
+
throw err;
|
|
254
|
+
// Fallback conditions: no git, no remote, non-GitHub remote, no artifacts
|
|
255
|
+
if (force) {
|
|
256
|
+
const targetPath = options?.path ?? getDefaultAirJsonPath();
|
|
257
|
+
if (existsSync(targetPath)) {
|
|
258
|
+
unlinkSync(targetPath);
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
const result = initConfig({ path: options?.path });
|
|
262
|
+
return { mode: "blank", ...result };
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
//# sourceMappingURL=init-from-repo.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init-from-repo.js","sourceRoot":"","sources":["../src/init-from-repo.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EACL,YAAY,EACZ,UAAU,EACV,aAAa,EACb,SAAS,EACT,UAAU,GACX,MAAM,IAAI,CAAC;AACZ,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AACxC,OAAO,EACL,qBAAqB,EACrB,gBAAgB,EAChB,iBAAiB,EACjB,YAAY,GAEb,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAEvC,sFAAsF;AACtF,MAAM,cAAc,GAAG,iBAAiB,EAAE,CAAC,MAAM,CAC/C,CAAC,CAAC,EAAmC,EAAE,CAAC,CAAC,KAAK,KAAK,CACpD,CAAC;AAUF;;;GAGG;A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
7
7
|
airJsonPath: string;
|
|
8
8
|
/** Absolute path to the AIR config directory. */
|
|
9
9
|
airDir: string;
|
|
10
|
-
/** List of files in the config directory (relative to airDir). */
|
|
11
|
-
files: string[];
|
|
12
10
|
}
|
|
13
11
|
/**
|
|
14
12
|
* Initialize a new AIR configuration directory.
|
|
15
13
|
*
|
|
16
|
-
* Creates air.json
|
|
17
|
-
* path (defaults to ~/.air/).
|
|
14
|
+
* Creates a minimal air.json at the specified path (defaults to ~/.air/).
|
|
18
15
|
*
|
|
19
16
|
* @throws Error if air.json already exists at the target path.
|
|
20
17
|
*/
|
package/dist/init.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../src/init.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,iBAAiB;IAChC,4DAA4D;IAC5D,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,gBAAgB;IAC/B,6CAA6C;IAC7C,WAAW,EAAE,MAAM,CAAC;IACpB,iDAAiD;IACjD,MAAM,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../src/init.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,iBAAiB;IAChC,4DAA4D;IAC5D,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,gBAAgB;IAC/B,6CAA6C;IAC7C,WAAW,EAAE,MAAM,CAAC;IACpB,iDAAiD;IACjD,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,OAAO,CAAC,EAAE,iBAAiB,GAAG,gBAAgB,CAiBxE"}
|
package/dist/init.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { writeFileSync, existsSync, mkdirSync } from "fs";
|
|
2
|
-
import {
|
|
2
|
+
import { dirname } from "path";
|
|
3
3
|
import { getDefaultAirJsonPath } from "@pulsemcp/air-core";
|
|
4
4
|
/**
|
|
5
5
|
* Initialize a new AIR configuration directory.
|
|
6
6
|
*
|
|
7
|
-
* Creates air.json
|
|
8
|
-
* path (defaults to ~/.air/).
|
|
7
|
+
* Creates a minimal air.json at the specified path (defaults to ~/.air/).
|
|
9
8
|
*
|
|
10
9
|
* @throws Error if air.json already exists at the target path.
|
|
11
10
|
*/
|
|
@@ -18,33 +17,8 @@ export function initConfig(options) {
|
|
|
18
17
|
mkdirSync(airDir, { recursive: true });
|
|
19
18
|
const airJson = {
|
|
20
19
|
name: "my-config",
|
|
21
|
-
description: "",
|
|
22
|
-
skills: ["./skills/skills.json"],
|
|
23
|
-
references: ["./references/references.json"],
|
|
24
|
-
mcp: ["./mcp/mcp.json"],
|
|
25
|
-
plugins: ["./plugins/plugins.json"],
|
|
26
|
-
roots: ["./roots/roots.json"],
|
|
27
|
-
hooks: ["./hooks/hooks.json"],
|
|
28
20
|
};
|
|
29
|
-
const emptyIndex = () => "{}\n";
|
|
30
21
|
writeFileSync(airJsonPath, JSON.stringify(airJson, null, 2) + "\n");
|
|
31
|
-
|
|
32
|
-
["skills/skills.json", emptyIndex()],
|
|
33
|
-
["references/references.json", emptyIndex()],
|
|
34
|
-
["mcp/mcp.json", emptyIndex()],
|
|
35
|
-
["plugins/plugins.json", emptyIndex()],
|
|
36
|
-
["roots/roots.json", emptyIndex()],
|
|
37
|
-
["hooks/hooks.json", emptyIndex()],
|
|
38
|
-
];
|
|
39
|
-
const files = ["air.json"];
|
|
40
|
-
for (const [filename, content] of indexFiles) {
|
|
41
|
-
const filePath = resolve(airDir, filename);
|
|
42
|
-
mkdirSync(dirname(filePath), { recursive: true });
|
|
43
|
-
if (!existsSync(filePath)) {
|
|
44
|
-
writeFileSync(filePath, content);
|
|
45
|
-
}
|
|
46
|
-
files.push(filename);
|
|
47
|
-
}
|
|
48
|
-
return { airJsonPath, airDir, files };
|
|
22
|
+
return { airJsonPath, airDir };
|
|
49
23
|
}
|
|
50
24
|
//# sourceMappingURL=init.js.map
|
package/dist/init.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.js","sourceRoot":"","sources":["../src/init.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,IAAI,CAAC;AAC1D,OAAO,EAAE,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"init.js","sourceRoot":"","sources":["../src/init.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,IAAI,CAAC;AAC1D,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAC/B,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAc3D;;;;;;GAMG;AACH,MAAM,UAAU,UAAU,CAAC,OAA2B;IACpD,MAAM,WAAW,GAAG,OAAO,EAAE,IAAI,IAAI,qBAAqB,EAAE,CAAC;IAC7D,MAAM,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;IAEpC,IAAI,UAAU,CAAC,WAAW,CAAC,EAAE,CAAC;QAC5B,MAAM,IAAI,KAAK,CAAC,GAAG,WAAW,kBAAkB,CAAC,CAAC;IACpD,CAAC;IAED,SAAS,CAAC,MAAM,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAEvC,MAAM,OAAO,GAAG;QACd,IAAI,EAAE,WAAW;KAClB,CAAC;IAEF,aAAa,CAAC,WAAW,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC;IAEpE,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,CAAC;AACjC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pulsemcp/air-sdk",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.12",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"lint": "tsc --noEmit"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@pulsemcp/air-core": "0.0.
|
|
32
|
+
"@pulsemcp/air-core": "0.0.12"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@types/node": "^22.10.0",
|