@hasna/instructions 0.4.31 → 0.4.33
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/cli/index.js +49 -6
- package/dist/data/config-store.d.ts +1 -0
- package/dist/data/config-store.d.ts.map +1 -1
- package/dist/index.js +48 -6
- package/dist/mcp/index.js +50 -7
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -13649,17 +13649,55 @@ class CloudConfigStore {
|
|
|
13649
13649
|
params.set("limit", String(normalized.limit));
|
|
13650
13650
|
params.set("cursor", String(normalized.cursor));
|
|
13651
13651
|
const qs = params.toString();
|
|
13652
|
-
const {
|
|
13653
|
-
if (
|
|
13652
|
+
const { data } = await this.requestProfileRoute(idOrSlug, (profileId) => `/profiles/${encodeURIComponent(profileId)}${qs ? `?${qs}` : ""}`, (value) => Boolean(value?.profile));
|
|
13653
|
+
if (!data?.profile)
|
|
13654
13654
|
throw new ProfileNotFoundError(idOrSlug);
|
|
13655
13655
|
return parseBoundedOrLegacyPage(data.configs, data.profile.configs, normalized, "profile membership");
|
|
13656
13656
|
}
|
|
13657
13657
|
async getProfileConfigBindings(idOrSlug) {
|
|
13658
|
-
const { status, data } = await this.
|
|
13659
|
-
if (status === 404
|
|
13658
|
+
const { status, data } = await this.requestProfileRoute(idOrSlug, (profileId) => `/profiles/${encodeURIComponent(profileId)}/bindings`, (value) => Array.isArray(value?.bindings));
|
|
13659
|
+
if (status === 404) {
|
|
13660
|
+
const profile = await this.getProfile(idOrSlug);
|
|
13661
|
+
const configs = await this.getProfileConfigs(idOrSlug);
|
|
13662
|
+
return configs.map((config, sort_order) => ({
|
|
13663
|
+
profile_id: profile.id,
|
|
13664
|
+
config_id: config.id,
|
|
13665
|
+
sort_order,
|
|
13666
|
+
binding: legacyProfileConfigBinding()
|
|
13667
|
+
}));
|
|
13668
|
+
}
|
|
13669
|
+
if (!data || !Array.isArray(data.bindings))
|
|
13660
13670
|
throw new ProfileNotFoundError(idOrSlug);
|
|
13661
13671
|
return data.bindings;
|
|
13662
13672
|
}
|
|
13673
|
+
async requestProfileRoute(idOrSlug, pathForId, isUsable) {
|
|
13674
|
+
const attempted = new Set;
|
|
13675
|
+
const request = async (profileId) => {
|
|
13676
|
+
attempted.add(profileId);
|
|
13677
|
+
return this.request("GET", pathForId(profileId), undefined, { allow404: true });
|
|
13678
|
+
};
|
|
13679
|
+
const first = await request(idOrSlug);
|
|
13680
|
+
if (first.status !== 404) {
|
|
13681
|
+
if (isUsable(first.data))
|
|
13682
|
+
return first;
|
|
13683
|
+
throw new CloudHttpError(502, "profile follow-up returned an invalid response", first.data);
|
|
13684
|
+
}
|
|
13685
|
+
const profiles = await this.listProfiles();
|
|
13686
|
+
const profile = profiles.find((candidate) => candidate.id === idOrSlug || candidate.slug === idOrSlug);
|
|
13687
|
+
if (!profile)
|
|
13688
|
+
throw new ProfileNotFoundError(idOrSlug);
|
|
13689
|
+
for (const candidate of [profile.id, profile.slug]) {
|
|
13690
|
+
if (attempted.has(candidate))
|
|
13691
|
+
continue;
|
|
13692
|
+
const response = await request(candidate);
|
|
13693
|
+
if (response.status !== 404) {
|
|
13694
|
+
if (isUsable(response.data))
|
|
13695
|
+
return response;
|
|
13696
|
+
throw new CloudHttpError(502, "profile follow-up returned an invalid response", response.data);
|
|
13697
|
+
}
|
|
13698
|
+
}
|
|
13699
|
+
return { status: 404, data: null };
|
|
13700
|
+
}
|
|
13663
13701
|
async createProfile(input) {
|
|
13664
13702
|
const { data } = await this.request("POST", "/profiles", input, {
|
|
13665
13703
|
idempotent: true
|
|
@@ -13688,8 +13726,12 @@ class CloudConfigStore {
|
|
|
13688
13726
|
await this.request("DELETE", `/profiles/${encodeURIComponent(profileIdOrSlug)}/configs/${encodeURIComponent(configId)}`, undefined, { allow404: true });
|
|
13689
13727
|
}
|
|
13690
13728
|
async getProfileAssetBindings(profileIdOrSlug) {
|
|
13691
|
-
const { status, data } = await this.
|
|
13692
|
-
if (status === 404
|
|
13729
|
+
const { status, data } = await this.requestProfileRoute(profileIdOrSlug, (profileId) => `/profiles/${encodeURIComponent(profileId)}/assets`, (value) => Array.isArray(value?.assets));
|
|
13730
|
+
if (status === 404) {
|
|
13731
|
+
await this.getProfile(profileIdOrSlug);
|
|
13732
|
+
return [];
|
|
13733
|
+
}
|
|
13734
|
+
if (!data || !Array.isArray(data.assets))
|
|
13693
13735
|
throw new ProfileNotFoundError(profileIdOrSlug);
|
|
13694
13736
|
return data.assets;
|
|
13695
13737
|
}
|
|
@@ -13789,6 +13831,7 @@ var init_config_store = __esm(() => {
|
|
|
13789
13831
|
init_database();
|
|
13790
13832
|
init_types();
|
|
13791
13833
|
init_bounded_read();
|
|
13834
|
+
init_instruction_graph();
|
|
13792
13835
|
CloudHttpError = class CloudHttpError extends Error {
|
|
13793
13836
|
status;
|
|
13794
13837
|
body;
|
|
@@ -151,6 +151,7 @@ export declare class CloudConfigStore implements ConfigStore {
|
|
|
151
151
|
getProfileConfigs(idOrSlug: string): Promise<Config[]>;
|
|
152
152
|
getProfileConfigsPage(idOrSlug: string, options?: BoundedReadOptions): Promise<BoundedReadPage<Config>>;
|
|
153
153
|
getProfileConfigBindings(idOrSlug: string): Promise<ProfileConfigBinding[]>;
|
|
154
|
+
private requestProfileRoute;
|
|
154
155
|
createProfile(input: CreateProfileInput): Promise<Profile>;
|
|
155
156
|
updateProfile(idOrSlug: string, input: UpdateProfileInput): Promise<Profile>;
|
|
156
157
|
deleteProfile(idOrSlug: string): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config-store.d.ts","sourceRoot":"","sources":["../../src/data/config-store.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAuC3C,OAAO,EAAkF,KAAK,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAEvI,OAAO,KAAK,EACV,MAAM,EACN,YAAY,EACZ,cAAc,EACd,iBAAiB,EACjB,kBAAkB,EAClB,OAAO,EACP,cAAc,EACd,OAAO,EACP,kBAAkB,EAClB,eAAe,EACf,qBAAqB,EACrB,iBAAiB,EACjB,kBAAkB,EAClB,oBAAoB,EACpB,wBAAwB,EACxB,mBAAmB,EACnB,uBAAuB,EACxB,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"config-store.d.ts","sourceRoot":"","sources":["../../src/data/config-store.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAuC3C,OAAO,EAAkF,KAAK,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAEvI,OAAO,KAAK,EACV,MAAM,EACN,YAAY,EACZ,cAAc,EACd,iBAAiB,EACjB,kBAAkB,EAClB,OAAO,EACP,cAAc,EACd,OAAO,EACP,kBAAkB,EAClB,eAAe,EACf,qBAAqB,EACrB,iBAAiB,EACjB,kBAAkB,EAClB,oBAAoB,EACpB,wBAAwB,EACxB,mBAAmB,EACnB,uBAAuB,EACxB,MAAM,mBAAmB,CAAC;AAI3B,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,qBAAa,cAAe,SAAQ,KAAK;IAC3B,QAAQ,CAAC,MAAM,EAAE,MAAM;IAAmB,QAAQ,CAAC,IAAI,CAAC,EAAE,OAAO;gBAAxD,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAW,IAAI,CAAC,EAAE,OAAO,YAAA;CAI9E;AAiED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,OAAO,GAAG,GAAG,IAAI,cAAc,CAEpE;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,GAAE,MAAM,CAAC,UAAwB,GAAG,MAAM,CAmBzF;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CA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EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;IASjD,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAM7B;AAED,+EAA+E;AAC/E,wBAAgB,kBAAkB,CAAC,GAAG,GAAE,MAAM,CAAC,UAAwB,GAAG,WAAW,CAGpF"}
|
package/dist/index.js
CHANGED
|
@@ -11657,17 +11657,55 @@ class CloudConfigStore {
|
|
|
11657
11657
|
params.set("limit", String(normalized.limit));
|
|
11658
11658
|
params.set("cursor", String(normalized.cursor));
|
|
11659
11659
|
const qs = params.toString();
|
|
11660
|
-
const {
|
|
11661
|
-
if (
|
|
11660
|
+
const { data } = await this.requestProfileRoute(idOrSlug, (profileId) => `/profiles/${encodeURIComponent(profileId)}${qs ? `?${qs}` : ""}`, (value) => Boolean(value?.profile));
|
|
11661
|
+
if (!data?.profile)
|
|
11662
11662
|
throw new ProfileNotFoundError(idOrSlug);
|
|
11663
11663
|
return parseBoundedOrLegacyPage(data.configs, data.profile.configs, normalized, "profile membership");
|
|
11664
11664
|
}
|
|
11665
11665
|
async getProfileConfigBindings(idOrSlug) {
|
|
11666
|
-
const { status, data } = await this.
|
|
11667
|
-
if (status === 404
|
|
11666
|
+
const { status, data } = await this.requestProfileRoute(idOrSlug, (profileId) => `/profiles/${encodeURIComponent(profileId)}/bindings`, (value) => Array.isArray(value?.bindings));
|
|
11667
|
+
if (status === 404) {
|
|
11668
|
+
const profile = await this.getProfile(idOrSlug);
|
|
11669
|
+
const configs = await this.getProfileConfigs(idOrSlug);
|
|
11670
|
+
return configs.map((config, sort_order) => ({
|
|
11671
|
+
profile_id: profile.id,
|
|
11672
|
+
config_id: config.id,
|
|
11673
|
+
sort_order,
|
|
11674
|
+
binding: legacyProfileConfigBinding()
|
|
11675
|
+
}));
|
|
11676
|
+
}
|
|
11677
|
+
if (!data || !Array.isArray(data.bindings))
|
|
11668
11678
|
throw new ProfileNotFoundError(idOrSlug);
|
|
11669
11679
|
return data.bindings;
|
|
11670
11680
|
}
|
|
11681
|
+
async requestProfileRoute(idOrSlug, pathForId, isUsable) {
|
|
11682
|
+
const attempted = new Set;
|
|
11683
|
+
const request = async (profileId) => {
|
|
11684
|
+
attempted.add(profileId);
|
|
11685
|
+
return this.request("GET", pathForId(profileId), undefined, { allow404: true });
|
|
11686
|
+
};
|
|
11687
|
+
const first = await request(idOrSlug);
|
|
11688
|
+
if (first.status !== 404) {
|
|
11689
|
+
if (isUsable(first.data))
|
|
11690
|
+
return first;
|
|
11691
|
+
throw new CloudHttpError(502, "profile follow-up returned an invalid response", first.data);
|
|
11692
|
+
}
|
|
11693
|
+
const profiles = await this.listProfiles();
|
|
11694
|
+
const profile = profiles.find((candidate) => candidate.id === idOrSlug || candidate.slug === idOrSlug);
|
|
11695
|
+
if (!profile)
|
|
11696
|
+
throw new ProfileNotFoundError(idOrSlug);
|
|
11697
|
+
for (const candidate of [profile.id, profile.slug]) {
|
|
11698
|
+
if (attempted.has(candidate))
|
|
11699
|
+
continue;
|
|
11700
|
+
const response = await request(candidate);
|
|
11701
|
+
if (response.status !== 404) {
|
|
11702
|
+
if (isUsable(response.data))
|
|
11703
|
+
return response;
|
|
11704
|
+
throw new CloudHttpError(502, "profile follow-up returned an invalid response", response.data);
|
|
11705
|
+
}
|
|
11706
|
+
}
|
|
11707
|
+
return { status: 404, data: null };
|
|
11708
|
+
}
|
|
11671
11709
|
async createProfile(input) {
|
|
11672
11710
|
const { data } = await this.request("POST", "/profiles", input, {
|
|
11673
11711
|
idempotent: true
|
|
@@ -11696,8 +11734,12 @@ class CloudConfigStore {
|
|
|
11696
11734
|
await this.request("DELETE", `/profiles/${encodeURIComponent(profileIdOrSlug)}/configs/${encodeURIComponent(configId)}`, undefined, { allow404: true });
|
|
11697
11735
|
}
|
|
11698
11736
|
async getProfileAssetBindings(profileIdOrSlug) {
|
|
11699
|
-
const { status, data } = await this.
|
|
11700
|
-
if (status === 404
|
|
11737
|
+
const { status, data } = await this.requestProfileRoute(profileIdOrSlug, (profileId) => `/profiles/${encodeURIComponent(profileId)}/assets`, (value) => Array.isArray(value?.assets));
|
|
11738
|
+
if (status === 404) {
|
|
11739
|
+
await this.getProfile(profileIdOrSlug);
|
|
11740
|
+
return [];
|
|
11741
|
+
}
|
|
11742
|
+
if (!data || !Array.isArray(data.assets))
|
|
11701
11743
|
throw new ProfileNotFoundError(profileIdOrSlug);
|
|
11702
11744
|
return data.assets;
|
|
11703
11745
|
}
|
package/dist/mcp/index.js
CHANGED
|
@@ -6602,17 +6602,55 @@ class CloudConfigStore {
|
|
|
6602
6602
|
params.set("limit", String(normalized.limit));
|
|
6603
6603
|
params.set("cursor", String(normalized.cursor));
|
|
6604
6604
|
const qs = params.toString();
|
|
6605
|
-
const {
|
|
6606
|
-
if (
|
|
6605
|
+
const { data } = await this.requestProfileRoute(idOrSlug, (profileId) => `/profiles/${encodeURIComponent(profileId)}${qs ? `?${qs}` : ""}`, (value) => Boolean(value?.profile));
|
|
6606
|
+
if (!data?.profile)
|
|
6607
6607
|
throw new ProfileNotFoundError(idOrSlug);
|
|
6608
6608
|
return parseBoundedOrLegacyPage(data.configs, data.profile.configs, normalized, "profile membership");
|
|
6609
6609
|
}
|
|
6610
6610
|
async getProfileConfigBindings(idOrSlug) {
|
|
6611
|
-
const { status, data } = await this.
|
|
6612
|
-
if (status === 404
|
|
6611
|
+
const { status, data } = await this.requestProfileRoute(idOrSlug, (profileId) => `/profiles/${encodeURIComponent(profileId)}/bindings`, (value) => Array.isArray(value?.bindings));
|
|
6612
|
+
if (status === 404) {
|
|
6613
|
+
const profile = await this.getProfile(idOrSlug);
|
|
6614
|
+
const configs = await this.getProfileConfigs(idOrSlug);
|
|
6615
|
+
return configs.map((config, sort_order) => ({
|
|
6616
|
+
profile_id: profile.id,
|
|
6617
|
+
config_id: config.id,
|
|
6618
|
+
sort_order,
|
|
6619
|
+
binding: legacyProfileConfigBinding()
|
|
6620
|
+
}));
|
|
6621
|
+
}
|
|
6622
|
+
if (!data || !Array.isArray(data.bindings))
|
|
6613
6623
|
throw new ProfileNotFoundError(idOrSlug);
|
|
6614
6624
|
return data.bindings;
|
|
6615
6625
|
}
|
|
6626
|
+
async requestProfileRoute(idOrSlug, pathForId, isUsable) {
|
|
6627
|
+
const attempted = new Set;
|
|
6628
|
+
const request = async (profileId) => {
|
|
6629
|
+
attempted.add(profileId);
|
|
6630
|
+
return this.request("GET", pathForId(profileId), undefined, { allow404: true });
|
|
6631
|
+
};
|
|
6632
|
+
const first = await request(idOrSlug);
|
|
6633
|
+
if (first.status !== 404) {
|
|
6634
|
+
if (isUsable(first.data))
|
|
6635
|
+
return first;
|
|
6636
|
+
throw new CloudHttpError(502, "profile follow-up returned an invalid response", first.data);
|
|
6637
|
+
}
|
|
6638
|
+
const profiles = await this.listProfiles();
|
|
6639
|
+
const profile = profiles.find((candidate) => candidate.id === idOrSlug || candidate.slug === idOrSlug);
|
|
6640
|
+
if (!profile)
|
|
6641
|
+
throw new ProfileNotFoundError(idOrSlug);
|
|
6642
|
+
for (const candidate of [profile.id, profile.slug]) {
|
|
6643
|
+
if (attempted.has(candidate))
|
|
6644
|
+
continue;
|
|
6645
|
+
const response = await request(candidate);
|
|
6646
|
+
if (response.status !== 404) {
|
|
6647
|
+
if (isUsable(response.data))
|
|
6648
|
+
return response;
|
|
6649
|
+
throw new CloudHttpError(502, "profile follow-up returned an invalid response", response.data);
|
|
6650
|
+
}
|
|
6651
|
+
}
|
|
6652
|
+
return { status: 404, data: null };
|
|
6653
|
+
}
|
|
6616
6654
|
async createProfile(input) {
|
|
6617
6655
|
const { data } = await this.request("POST", "/profiles", input, {
|
|
6618
6656
|
idempotent: true
|
|
@@ -6641,8 +6679,12 @@ class CloudConfigStore {
|
|
|
6641
6679
|
await this.request("DELETE", `/profiles/${encodeURIComponent(profileIdOrSlug)}/configs/${encodeURIComponent(configId)}`, undefined, { allow404: true });
|
|
6642
6680
|
}
|
|
6643
6681
|
async getProfileAssetBindings(profileIdOrSlug) {
|
|
6644
|
-
const { status, data } = await this.
|
|
6645
|
-
if (status === 404
|
|
6682
|
+
const { status, data } = await this.requestProfileRoute(profileIdOrSlug, (profileId) => `/profiles/${encodeURIComponent(profileId)}/assets`, (value) => Array.isArray(value?.assets));
|
|
6683
|
+
if (status === 404) {
|
|
6684
|
+
await this.getProfile(profileIdOrSlug);
|
|
6685
|
+
return [];
|
|
6686
|
+
}
|
|
6687
|
+
if (!data || !Array.isArray(data.assets))
|
|
6646
6688
|
throw new ProfileNotFoundError(profileIdOrSlug);
|
|
6647
6689
|
return data.assets;
|
|
6648
6690
|
}
|
|
@@ -6742,6 +6784,7 @@ var init_config_store = __esm(() => {
|
|
|
6742
6784
|
init_database();
|
|
6743
6785
|
init_types();
|
|
6744
6786
|
init_bounded_read();
|
|
6787
|
+
init_instruction_graph();
|
|
6745
6788
|
CloudHttpError = class CloudHttpError extends Error {
|
|
6746
6789
|
status;
|
|
6747
6790
|
body;
|
|
@@ -7905,7 +7948,7 @@ var init_sync_dir = __esm(() => {
|
|
|
7905
7948
|
var require_package = __commonJS((exports, module) => {
|
|
7906
7949
|
module.exports = {
|
|
7907
7950
|
name: "@hasna/instructions",
|
|
7908
|
-
version: "0.4.
|
|
7951
|
+
version: "0.4.33",
|
|
7909
7952
|
description: "AI coding agent instruction & configuration manager \u2014 store, version, apply, and share all your AI coding configs. CLI + MCP + HTTP API (instructions-serve) + generated SDK + Dashboard.",
|
|
7910
7953
|
type: "module",
|
|
7911
7954
|
main: "dist/index.js",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hasna/instructions",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.33",
|
|
4
4
|
"description": "AI coding agent instruction & configuration manager \u2014 store, version, apply, and share all your AI coding configs. CLI + MCP + HTTP API (instructions-serve) + generated SDK + Dashboard.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|