@agentic-kit/harness 0.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.
- package/LICENSE +23 -0
- package/README.md +176 -0
- package/blueprint/blueprint-defaults.d.ts +2 -0
- package/blueprint/blueprint-defaults.js +123 -0
- package/blueprint/blueprint-schema.d.ts +138 -0
- package/blueprint/blueprint-schema.js +86 -0
- package/blueprint/field-type.d.ts +25 -0
- package/blueprint/field-type.js +99 -0
- package/blueprint/internal-policies.d.ts +2 -0
- package/blueprint/internal-policies.js +14 -0
- package/blueprint/policy-provisioning.d.ts +79 -0
- package/blueprint/policy-provisioning.js +570 -0
- package/esm/blueprint/blueprint-defaults.d.ts +2 -0
- package/esm/blueprint/blueprint-defaults.js +120 -0
- package/esm/blueprint/blueprint-schema.d.ts +138 -0
- package/esm/blueprint/blueprint-schema.js +83 -0
- package/esm/blueprint/field-type.d.ts +25 -0
- package/esm/blueprint/field-type.js +94 -0
- package/esm/blueprint/internal-policies.d.ts +2 -0
- package/esm/blueprint/internal-policies.js +10 -0
- package/esm/blueprint/policy-provisioning.d.ts +79 -0
- package/esm/blueprint/policy-provisioning.js +553 -0
- package/esm/gating/confirm-gate.d.ts +46 -0
- package/esm/gating/confirm-gate.js +55 -0
- package/esm/gating/decline-guard.d.ts +7 -0
- package/esm/gating/decline-guard.js +48 -0
- package/esm/gating/preview.d.ts +37 -0
- package/esm/gating/preview.js +5 -0
- package/esm/gating/prompts.d.ts +8 -0
- package/esm/gating/prompts.js +175 -0
- package/esm/index.d.ts +20 -0
- package/esm/index.js +20 -0
- package/esm/skills/fetch.d.ts +31 -0
- package/esm/skills/fetch.js +84 -0
- package/esm/skills/frontmatter.d.ts +7 -0
- package/esm/skills/frontmatter.js +28 -0
- package/esm/skills/integrity.d.ts +8 -0
- package/esm/skills/integrity.js +28 -0
- package/esm/skills/manifest.d.ts +39 -0
- package/esm/skills/manifest.js +36 -0
- package/esm/skills/materialize.d.ts +13 -0
- package/esm/skills/materialize.js +26 -0
- package/esm/skills/overlay.d.ts +11 -0
- package/esm/skills/overlay.js +25 -0
- package/esm/skills/registry.d.ts +36 -0
- package/esm/skills/registry.js +30 -0
- package/esm/skills/source.d.ts +21 -0
- package/esm/skills/source.js +51 -0
- package/esm/skills/update-check.d.ts +36 -0
- package/esm/skills/update-check.js +74 -0
- package/esm/stash.d.ts +20 -0
- package/esm/stash.js +19 -0
- package/esm/types.d.ts +60 -0
- package/esm/types.js +8 -0
- package/gating/confirm-gate.d.ts +46 -0
- package/gating/confirm-gate.js +58 -0
- package/gating/decline-guard.d.ts +7 -0
- package/gating/decline-guard.js +52 -0
- package/gating/preview.d.ts +37 -0
- package/gating/preview.js +6 -0
- package/gating/prompts.d.ts +8 -0
- package/gating/prompts.js +179 -0
- package/index.d.ts +20 -0
- package/index.js +36 -0
- package/package.json +42 -0
- package/skills/fetch.d.ts +31 -0
- package/skills/fetch.js +122 -0
- package/skills/frontmatter.d.ts +7 -0
- package/skills/frontmatter.js +31 -0
- package/skills/integrity.d.ts +8 -0
- package/skills/integrity.js +64 -0
- package/skills/manifest.d.ts +39 -0
- package/skills/manifest.js +40 -0
- package/skills/materialize.d.ts +13 -0
- package/skills/materialize.js +62 -0
- package/skills/overlay.d.ts +11 -0
- package/skills/overlay.js +28 -0
- package/skills/registry.d.ts +36 -0
- package/skills/registry.js +34 -0
- package/skills/source.d.ts +21 -0
- package/skills/source.js +88 -0
- package/skills/update-check.d.ts +36 -0
- package/skills/update-check.js +110 -0
- package/stash.d.ts +20 -0
- package/stash.js +55 -0
- package/types.d.ts +60 -0
- package/types.js +9 -0
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MUTATING_DB_TOOLS = void 0;
|
|
4
|
+
exports.buildConfirmPrompt = buildConfirmPrompt;
|
|
5
|
+
exports.MUTATING_DB_TOOLS = new Set([
|
|
6
|
+
'provision_database',
|
|
7
|
+
'provision_blueprint',
|
|
8
|
+
'add_relation',
|
|
9
|
+
'delete_table',
|
|
10
|
+
'create_field',
|
|
11
|
+
'update_field',
|
|
12
|
+
'delete_field',
|
|
13
|
+
'add_policies',
|
|
14
|
+
'apply_template',
|
|
15
|
+
'create_template',
|
|
16
|
+
'update_template',
|
|
17
|
+
'delete_template',
|
|
18
|
+
'add_records',
|
|
19
|
+
'run_codegen',
|
|
20
|
+
]);
|
|
21
|
+
const internal_policies_1 = require("../blueprint/internal-policies");
|
|
22
|
+
function str(input, key) {
|
|
23
|
+
const value = input?.[key];
|
|
24
|
+
return typeof value === 'string' ? value : undefined;
|
|
25
|
+
}
|
|
26
|
+
function recordRows(input) {
|
|
27
|
+
const records = input?.records;
|
|
28
|
+
if (!Array.isArray(records))
|
|
29
|
+
return [];
|
|
30
|
+
return records.filter((r) => typeof r === 'object' && r !== null);
|
|
31
|
+
}
|
|
32
|
+
function obj(value) {
|
|
33
|
+
return typeof value === 'object' && value !== null ? value : undefined;
|
|
34
|
+
}
|
|
35
|
+
function arr(value) {
|
|
36
|
+
return Array.isArray(value) ? value.map(obj).filter((v) => !!v) : [];
|
|
37
|
+
}
|
|
38
|
+
function previewField(raw) {
|
|
39
|
+
return {
|
|
40
|
+
name: typeof raw.name === 'string' ? raw.name : '?',
|
|
41
|
+
type: typeof raw.type === 'string' ? raw.type : '?',
|
|
42
|
+
isRequired: raw.is_required === true,
|
|
43
|
+
defaultValue: typeof raw.default === 'string' ? raw.default : null,
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
function blueprintTables(input) {
|
|
47
|
+
const definition = obj(input?.definition);
|
|
48
|
+
if (!definition)
|
|
49
|
+
return [];
|
|
50
|
+
const relations = arr(definition.relations);
|
|
51
|
+
return arr(definition.tables).map((table) => {
|
|
52
|
+
const tableName = typeof table.table_name === 'string' ? table.table_name : '?';
|
|
53
|
+
return {
|
|
54
|
+
name: tableName,
|
|
55
|
+
fields: arr(table.fields).map(previewField),
|
|
56
|
+
policies: (0, internal_policies_1.filterInternalPolicies)(arr(table.policies)
|
|
57
|
+
.map((policy) => (typeof policy.$type === 'string' ? policy.$type : null))
|
|
58
|
+
.filter((p) => !!p)),
|
|
59
|
+
relationCount: relations.filter((r) => r.source_table === tableName).length,
|
|
60
|
+
};
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
function policyTypes(input) {
|
|
64
|
+
return (0, internal_policies_1.filterInternalPolicies)(arr(input?.policies)
|
|
65
|
+
.map((policy) => (typeof policy.policy_type === 'string' ? policy.policy_type : null))
|
|
66
|
+
.filter((p) => !!p));
|
|
67
|
+
}
|
|
68
|
+
function buildConfirmPrompt(toolName, input) {
|
|
69
|
+
switch (toolName) {
|
|
70
|
+
case 'provision_database': {
|
|
71
|
+
const name = str(input, 'database_name') ?? 'new database';
|
|
72
|
+
return {
|
|
73
|
+
title: 'Provision database?',
|
|
74
|
+
message: `Sign up an owner and provision a new Constructive database "${name}" (standard module set), then write credentials to the project .env.`,
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
case 'provision_blueprint': {
|
|
78
|
+
const name = str(input, 'name') ?? 'new schema';
|
|
79
|
+
const tables = blueprintTables(input);
|
|
80
|
+
const count = tables.length;
|
|
81
|
+
return {
|
|
82
|
+
title: 'Create tables?',
|
|
83
|
+
message: `Provision blueprint "${name}"${count ? ` (${count} table${count === 1 ? '' : 's'})` : ''} in the project database.`,
|
|
84
|
+
preview: count > 0 ? { kind: 'blueprint', tables } : undefined,
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
case 'add_relation': {
|
|
88
|
+
const source = str(input, 'source_table') ?? '?';
|
|
89
|
+
const target = str(input, 'target_table') ?? '?';
|
|
90
|
+
const isManyToMany = str(input, 'relation_type') === 'many_to_many';
|
|
91
|
+
const message = isManyToMany
|
|
92
|
+
? `Create a junction table "${str(input, 'junction_table_name') ?? '?'}" linking existing tables "${source}" ↔ "${target}".`
|
|
93
|
+
: `Add a foreign-key column "${str(input, 'field_name') ?? '?'}" on existing table "${source}" referencing "${target}".`;
|
|
94
|
+
return { title: 'Add relation?', message };
|
|
95
|
+
}
|
|
96
|
+
case 'delete_table':
|
|
97
|
+
return {
|
|
98
|
+
title: 'Delete table?',
|
|
99
|
+
message: `Permanently delete the table "${str(input, 'table_name') ?? '?'}" and its data.`,
|
|
100
|
+
};
|
|
101
|
+
case 'create_field': {
|
|
102
|
+
const tableName = str(input, 'table_name') ?? '?';
|
|
103
|
+
const fieldName = str(input, 'field_name') ?? '?';
|
|
104
|
+
return {
|
|
105
|
+
title: 'Add field?',
|
|
106
|
+
message: `Add field "${fieldName}" to table "${tableName}".`,
|
|
107
|
+
preview: {
|
|
108
|
+
kind: 'field',
|
|
109
|
+
tableName,
|
|
110
|
+
field: {
|
|
111
|
+
name: fieldName,
|
|
112
|
+
type: str(input, 'type') ?? '?',
|
|
113
|
+
isRequired: input?.is_required === true,
|
|
114
|
+
defaultValue: str(input, 'default_value') ?? null,
|
|
115
|
+
},
|
|
116
|
+
},
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
case 'update_field':
|
|
120
|
+
return {
|
|
121
|
+
title: 'Update field?',
|
|
122
|
+
message: `Modify field "${str(input, 'field_name') ?? '?'}" on table "${str(input, 'table_name') ?? '?'}".`,
|
|
123
|
+
};
|
|
124
|
+
case 'delete_field':
|
|
125
|
+
return {
|
|
126
|
+
title: 'Delete field?',
|
|
127
|
+
message: `Permanently delete field "${str(input, 'field_name') ?? '?'}" from table "${str(input, 'table_name') ?? '?'}".`,
|
|
128
|
+
};
|
|
129
|
+
case 'add_policies': {
|
|
130
|
+
const tableName = str(input, 'table_name') ?? '?';
|
|
131
|
+
const policies = policyTypes(input);
|
|
132
|
+
const count = policies.length;
|
|
133
|
+
return {
|
|
134
|
+
title: 'Add policies?',
|
|
135
|
+
message: `Add ${count || ''} RLS ${count === 1 ? 'policy' : 'policies'} to table "${tableName}".`,
|
|
136
|
+
preview: count > 0 ? { kind: 'policies', tableName, policies } : undefined,
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
case 'apply_template':
|
|
140
|
+
return {
|
|
141
|
+
title: 'Apply template?',
|
|
142
|
+
message: `Apply blueprint template "${str(input, 'templateName') ?? '?'}" to the project database.`,
|
|
143
|
+
};
|
|
144
|
+
case 'create_template': {
|
|
145
|
+
const source = str(input, 'blueprintName');
|
|
146
|
+
return {
|
|
147
|
+
title: 'Create template?',
|
|
148
|
+
message: `Create reusable template "${str(input, 'displayName') ?? '?'}" in the catalog from ${source ? `blueprint "${source}"` : 'the latest blueprint'}.`,
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
case 'update_template':
|
|
152
|
+
return {
|
|
153
|
+
title: 'Update template?',
|
|
154
|
+
message: `Update blueprint template "${str(input, 'templateName') ?? '?'}".`,
|
|
155
|
+
};
|
|
156
|
+
case 'delete_template':
|
|
157
|
+
return {
|
|
158
|
+
title: 'Delete template?',
|
|
159
|
+
message: `Permanently delete blueprint template "${str(input, 'templateName') ?? '?'}".`,
|
|
160
|
+
};
|
|
161
|
+
case 'add_records': {
|
|
162
|
+
const rows = recordRows(input);
|
|
163
|
+
const count = rows.length;
|
|
164
|
+
const tableName = str(input, 'table_name') ?? '?';
|
|
165
|
+
return {
|
|
166
|
+
title: 'Add records?',
|
|
167
|
+
message: `Insert ${count || ''} row${count === 1 ? '' : 's'} into table "${tableName}".`,
|
|
168
|
+
preview: count > 0 ? { kind: 'records', tableName, rows } : undefined,
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
case 'run_codegen':
|
|
172
|
+
return {
|
|
173
|
+
title: 'Run codegen?',
|
|
174
|
+
message: 'Generate the typed GraphQL SDK in packages/app (upgrade codegen, run it, normalize barrels).',
|
|
175
|
+
};
|
|
176
|
+
default:
|
|
177
|
+
return { title: 'Run tool?', message: `Allow "${toolName}" to run?` };
|
|
178
|
+
}
|
|
179
|
+
}
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export * from './types';
|
|
2
|
+
export * from './stash';
|
|
3
|
+
export * from './skills/frontmatter';
|
|
4
|
+
export * from './skills/manifest';
|
|
5
|
+
export * from './skills/source';
|
|
6
|
+
export * from './skills/overlay';
|
|
7
|
+
export * from './skills/materialize';
|
|
8
|
+
export * from './skills/registry';
|
|
9
|
+
export * from './skills/integrity';
|
|
10
|
+
export * from './skills/fetch';
|
|
11
|
+
export * from './skills/update-check';
|
|
12
|
+
export * from './gating/preview';
|
|
13
|
+
export * from './gating/decline-guard';
|
|
14
|
+
export * from './gating/prompts';
|
|
15
|
+
export * from './gating/confirm-gate';
|
|
16
|
+
export * from './blueprint/field-type';
|
|
17
|
+
export * from './blueprint/internal-policies';
|
|
18
|
+
export * from './blueprint/policy-provisioning';
|
|
19
|
+
export * from './blueprint/blueprint-schema';
|
|
20
|
+
export * from './blueprint/blueprint-defaults';
|
package/index.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./types"), exports);
|
|
18
|
+
__exportStar(require("./stash"), exports);
|
|
19
|
+
__exportStar(require("./skills/frontmatter"), exports);
|
|
20
|
+
__exportStar(require("./skills/manifest"), exports);
|
|
21
|
+
__exportStar(require("./skills/source"), exports);
|
|
22
|
+
__exportStar(require("./skills/overlay"), exports);
|
|
23
|
+
__exportStar(require("./skills/materialize"), exports);
|
|
24
|
+
__exportStar(require("./skills/registry"), exports);
|
|
25
|
+
__exportStar(require("./skills/integrity"), exports);
|
|
26
|
+
__exportStar(require("./skills/fetch"), exports);
|
|
27
|
+
__exportStar(require("./skills/update-check"), exports);
|
|
28
|
+
__exportStar(require("./gating/preview"), exports);
|
|
29
|
+
__exportStar(require("./gating/decline-guard"), exports);
|
|
30
|
+
__exportStar(require("./gating/prompts"), exports);
|
|
31
|
+
__exportStar(require("./gating/confirm-gate"), exports);
|
|
32
|
+
__exportStar(require("./blueprint/field-type"), exports);
|
|
33
|
+
__exportStar(require("./blueprint/internal-policies"), exports);
|
|
34
|
+
__exportStar(require("./blueprint/policy-provisioning"), exports);
|
|
35
|
+
__exportStar(require("./blueprint/blueprint-schema"), exports);
|
|
36
|
+
__exportStar(require("./blueprint/blueprint-defaults"), exports);
|
package/package.json
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@agentic-kit/harness",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"author": "Dan Lynch <pyramation@gmail.com>",
|
|
5
|
+
"description": "Host-agnostic Constructive harness core — skill overlay resolution, materialization, and on-disk layout for harness hosts (desktop, CLI, MCP)",
|
|
6
|
+
"main": "index.js",
|
|
7
|
+
"module": "esm/index.js",
|
|
8
|
+
"types": "index.d.ts",
|
|
9
|
+
"homepage": "https://github.com/constructive-io/constructive",
|
|
10
|
+
"license": "SEE LICENSE IN LICENSE",
|
|
11
|
+
"publishConfig": {
|
|
12
|
+
"access": "public",
|
|
13
|
+
"directory": "dist"
|
|
14
|
+
},
|
|
15
|
+
"repository": {
|
|
16
|
+
"type": "git",
|
|
17
|
+
"url": "https://github.com/constructive-io/constructive"
|
|
18
|
+
},
|
|
19
|
+
"bugs": {
|
|
20
|
+
"url": "https://github.com/constructive-io/constructive/issues"
|
|
21
|
+
},
|
|
22
|
+
"scripts": {
|
|
23
|
+
"clean": "makage clean",
|
|
24
|
+
"prepack": "npm run build",
|
|
25
|
+
"build": "makage build",
|
|
26
|
+
"build:dev": "makage build --dev",
|
|
27
|
+
"lint": "eslint . --fix",
|
|
28
|
+
"test": "jest",
|
|
29
|
+
"test:watch": "jest --watch"
|
|
30
|
+
},
|
|
31
|
+
"dependencies": {
|
|
32
|
+
"appstash": "^0.7.0",
|
|
33
|
+
"semver": "^7.7.2",
|
|
34
|
+
"tar": "^7.4.3",
|
|
35
|
+
"typebox": "~1.1.38"
|
|
36
|
+
},
|
|
37
|
+
"devDependencies": {
|
|
38
|
+
"@types/semver": "^7.7.0"
|
|
39
|
+
},
|
|
40
|
+
"keywords": [],
|
|
41
|
+
"gitHead": "3ba915d42b63720086eb4d092403328a320b0074"
|
|
42
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Packument, RegistryOptions } from './registry';
|
|
2
|
+
export interface FetchReleaseOptions extends RegistryOptions {
|
|
3
|
+
/** npm package that ships the skills, e.g. `@constructive-io/skills`. */
|
|
4
|
+
pkg: string;
|
|
5
|
+
/**
|
|
6
|
+
* Version pin: exact version, semver range, or dist-tag. Ranges resolve to
|
|
7
|
+
* the highest satisfying published version.
|
|
8
|
+
*/
|
|
9
|
+
pin: string;
|
|
10
|
+
/** Root directory releases unpack into: `<skillsRoot>/<version>/`. */
|
|
11
|
+
skillsRoot: string;
|
|
12
|
+
/** Path of the skills tree inside the package (default `.agents/skills`). */
|
|
13
|
+
packageSubdir?: string;
|
|
14
|
+
}
|
|
15
|
+
export interface FetchedRelease {
|
|
16
|
+
version: string;
|
|
17
|
+
/** Directory containing `<skill>/SKILL.md` folders, ready for DirectorySkillSource. */
|
|
18
|
+
skillsDir: string;
|
|
19
|
+
/** True when the release was already on disk and no download happened. */
|
|
20
|
+
fromCache: boolean;
|
|
21
|
+
}
|
|
22
|
+
export declare function resolvePin(packument: Packument, pin: string): string;
|
|
23
|
+
/**
|
|
24
|
+
* Ensure a skills release is unpacked under `<skillsRoot>/<version>/` and
|
|
25
|
+
* return its skills directory. Downloads at most once per version: an already
|
|
26
|
+
* unpacked release is reused without touching the network, so a previously
|
|
27
|
+
* fetched version keeps working offline.
|
|
28
|
+
*/
|
|
29
|
+
export declare function fetchSkillsRelease(options: FetchReleaseOptions): Promise<FetchedRelease>;
|
|
30
|
+
/** Newest already-downloaded version under `skillsRoot`, or null. */
|
|
31
|
+
export declare function latestLocalRelease(skillsRoot: string, subdir?: string): FetchedRelease | null;
|
package/skills/fetch.js
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.resolvePin = resolvePin;
|
|
37
|
+
exports.fetchSkillsRelease = fetchSkillsRelease;
|
|
38
|
+
exports.latestLocalRelease = latestLocalRelease;
|
|
39
|
+
const fs = __importStar(require("fs"));
|
|
40
|
+
const os = __importStar(require("os"));
|
|
41
|
+
const path = __importStar(require("path"));
|
|
42
|
+
const semver = __importStar(require("semver"));
|
|
43
|
+
const tar = __importStar(require("tar"));
|
|
44
|
+
const integrity_1 = require("./integrity");
|
|
45
|
+
const registry_1 = require("./registry");
|
|
46
|
+
function resolvePin(packument, pin) {
|
|
47
|
+
const distTag = packument['dist-tags'][pin];
|
|
48
|
+
if (distTag)
|
|
49
|
+
return distTag;
|
|
50
|
+
if (packument.versions[pin])
|
|
51
|
+
return pin;
|
|
52
|
+
const versions = Object.keys(packument.versions);
|
|
53
|
+
const resolved = semver.maxSatisfying(versions, pin);
|
|
54
|
+
if (!resolved) {
|
|
55
|
+
throw new Error(`No published version of ${packument.name} satisfies pin "${pin}"`);
|
|
56
|
+
}
|
|
57
|
+
return resolved;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Ensure a skills release is unpacked under `<skillsRoot>/<version>/` and
|
|
61
|
+
* return its skills directory. Downloads at most once per version: an already
|
|
62
|
+
* unpacked release is reused without touching the network, so a previously
|
|
63
|
+
* fetched version keeps working offline.
|
|
64
|
+
*/
|
|
65
|
+
async function fetchSkillsRelease(options) {
|
|
66
|
+
const subdir = options.packageSubdir ?? '.agents/skills';
|
|
67
|
+
const client = new registry_1.RegistryClient(options);
|
|
68
|
+
const exactPin = semver.valid(options.pin);
|
|
69
|
+
if (exactPin) {
|
|
70
|
+
const cached = cachedRelease(options.skillsRoot, exactPin, subdir);
|
|
71
|
+
if (cached)
|
|
72
|
+
return cached;
|
|
73
|
+
}
|
|
74
|
+
const packument = await client.packument(options.pkg);
|
|
75
|
+
const version = resolvePin(packument, options.pin);
|
|
76
|
+
const cached = cachedRelease(options.skillsRoot, version, subdir);
|
|
77
|
+
if (cached)
|
|
78
|
+
return cached;
|
|
79
|
+
const release = packument.versions[version];
|
|
80
|
+
const data = await client.tarball(release.dist.tarball);
|
|
81
|
+
(0, integrity_1.verifyIntegrity)(data, release.dist);
|
|
82
|
+
const versionDir = path.join(options.skillsRoot, version);
|
|
83
|
+
const staging = fs.mkdtempSync(path.join(os.tmpdir(), 'harness-skills-'));
|
|
84
|
+
try {
|
|
85
|
+
const tarballPath = path.join(staging, 'release.tgz');
|
|
86
|
+
fs.writeFileSync(tarballPath, data);
|
|
87
|
+
const unpackDir = path.join(staging, 'package');
|
|
88
|
+
fs.mkdirSync(unpackDir);
|
|
89
|
+
await tar.extract({ file: tarballPath, cwd: unpackDir, strip: 1 });
|
|
90
|
+
fs.mkdirSync(path.dirname(versionDir), { recursive: true });
|
|
91
|
+
fs.rmSync(versionDir, { recursive: true, force: true });
|
|
92
|
+
fs.renameSync(unpackDir, versionDir);
|
|
93
|
+
}
|
|
94
|
+
finally {
|
|
95
|
+
fs.rmSync(staging, { recursive: true, force: true });
|
|
96
|
+
}
|
|
97
|
+
const skillsDir = path.join(versionDir, subdir);
|
|
98
|
+
if (!fs.existsSync(skillsDir)) {
|
|
99
|
+
throw new Error(`Release ${options.pkg}@${version} has no ${subdir} directory`);
|
|
100
|
+
}
|
|
101
|
+
return { version, skillsDir, fromCache: false };
|
|
102
|
+
}
|
|
103
|
+
/** Newest already-downloaded version under `skillsRoot`, or null. */
|
|
104
|
+
function latestLocalRelease(skillsRoot, subdir = '.agents/skills') {
|
|
105
|
+
if (!fs.existsSync(skillsRoot))
|
|
106
|
+
return null;
|
|
107
|
+
const versions = fs
|
|
108
|
+
.readdirSync(skillsRoot)
|
|
109
|
+
.filter((name) => semver.valid(name) && fs.existsSync(path.join(skillsRoot, name, subdir)))
|
|
110
|
+
.sort(semver.rcompare);
|
|
111
|
+
if (versions.length === 0)
|
|
112
|
+
return null;
|
|
113
|
+
return {
|
|
114
|
+
version: versions[0],
|
|
115
|
+
skillsDir: path.join(skillsRoot, versions[0], subdir),
|
|
116
|
+
fromCache: true,
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
function cachedRelease(skillsRoot, version, subdir) {
|
|
120
|
+
const skillsDir = path.join(skillsRoot, version, subdir);
|
|
121
|
+
return fs.existsSync(skillsDir) ? { version, skillsDir, fromCache: true } : null;
|
|
122
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseFrontmatter = parseFrontmatter;
|
|
4
|
+
function unquoteScalar(value) {
|
|
5
|
+
if (value && value.length >= 2 && value.startsWith('"') && value.endsWith('"')) {
|
|
6
|
+
try {
|
|
7
|
+
return JSON.parse(value);
|
|
8
|
+
}
|
|
9
|
+
catch {
|
|
10
|
+
return value;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
return value;
|
|
14
|
+
}
|
|
15
|
+
/** Parse the minimal YAML frontmatter (`name`, `description`) of a SKILL.md. */
|
|
16
|
+
function parseFrontmatter(raw) {
|
|
17
|
+
const match = raw.match(/^---\r?\n([\s\S]*?)\r?\n---\r?\n([\s\S]*)$/);
|
|
18
|
+
if (!match) {
|
|
19
|
+
throw new Error('Skill is missing YAML frontmatter (expected leading `---` block)');
|
|
20
|
+
}
|
|
21
|
+
const [, fm, body] = match;
|
|
22
|
+
const nameMatch = fm.match(/(?:^|\n)name:\s*(.+?)\s*(?:\n|$)/);
|
|
23
|
+
const descMatch = fm.match(/(?:^|\n)description:\s*(.+?)\s*(?:\n|$)/);
|
|
24
|
+
const name = unquoteScalar(nameMatch?.[1]?.trim());
|
|
25
|
+
const description = unquoteScalar(descMatch?.[1]?.trim());
|
|
26
|
+
if (!name)
|
|
27
|
+
throw new Error('Skill frontmatter missing `name`');
|
|
28
|
+
if (!description)
|
|
29
|
+
throw new Error('Skill frontmatter missing `description`');
|
|
30
|
+
return { name, description, body };
|
|
31
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Verify an npm SRI `integrity` string (`sha512-<base64>`, `sha256-…`) or a
|
|
3
|
+
* legacy hex `shasum` (sha1) against tarball bytes. Throws on mismatch.
|
|
4
|
+
*/
|
|
5
|
+
export declare function verifyIntegrity(data: Buffer, { integrity, shasum }: {
|
|
6
|
+
integrity?: string;
|
|
7
|
+
shasum?: string;
|
|
8
|
+
}): void;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.verifyIntegrity = verifyIntegrity;
|
|
37
|
+
const crypto = __importStar(require("crypto"));
|
|
38
|
+
/**
|
|
39
|
+
* Verify an npm SRI `integrity` string (`sha512-<base64>`, `sha256-…`) or a
|
|
40
|
+
* legacy hex `shasum` (sha1) against tarball bytes. Throws on mismatch.
|
|
41
|
+
*/
|
|
42
|
+
function verifyIntegrity(data, { integrity, shasum }) {
|
|
43
|
+
if (integrity) {
|
|
44
|
+
const dash = integrity.indexOf('-');
|
|
45
|
+
if (dash === -1) {
|
|
46
|
+
throw new Error(`Malformed integrity string: ${integrity}`);
|
|
47
|
+
}
|
|
48
|
+
const algorithm = integrity.slice(0, dash);
|
|
49
|
+
const expected = integrity.slice(dash + 1);
|
|
50
|
+
const actual = crypto.createHash(algorithm).update(data).digest('base64');
|
|
51
|
+
if (actual !== expected) {
|
|
52
|
+
throw new Error(`Integrity check failed (${algorithm}): expected ${expected}, got ${actual}`);
|
|
53
|
+
}
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
if (shasum) {
|
|
57
|
+
const actual = crypto.createHash('sha1').update(data).digest('hex');
|
|
58
|
+
if (actual !== shasum) {
|
|
59
|
+
throw new Error(`Integrity check failed (sha1): expected ${shasum}, got ${actual}`);
|
|
60
|
+
}
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
throw new Error('Release has no integrity metadata to verify');
|
|
64
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ordered-overlay skill source manifest.
|
|
3
|
+
*
|
|
4
|
+
* Skills are resolved from an ordered list of sources; later sources override
|
|
5
|
+
* or add skills by name (last-write-wins). Typical order:
|
|
6
|
+
*
|
|
7
|
+
* 1. `constructive-skills` at a pinned release (hardened public base)
|
|
8
|
+
* 2. team overlay repo(s) (skills being iterated on)
|
|
9
|
+
* 3. private known-gaps overlay (internal deployments only)
|
|
10
|
+
*
|
|
11
|
+
* Each layer keeps its own pin so the base can harden slowly while overlays
|
|
12
|
+
* stay fresh; promoting an overlay skill upstream = moving the file down a
|
|
13
|
+
* layer.
|
|
14
|
+
*/
|
|
15
|
+
export interface SkillSourceRef {
|
|
16
|
+
/** Unique layer name, e.g. `constructive-skills`, `team-overlay`. */
|
|
17
|
+
name: string;
|
|
18
|
+
/**
|
|
19
|
+
* Version/SHA pin for the layer. For npm sources a semver or dist-tag; for
|
|
20
|
+
* git sources a commit SHA; for local directories informational only.
|
|
21
|
+
*/
|
|
22
|
+
pin?: string;
|
|
23
|
+
/** Restrict this layer to an explicit set of skill names (default: all). */
|
|
24
|
+
include?: string[];
|
|
25
|
+
/** Skill names to skip from this layer. */
|
|
26
|
+
exclude?: string[];
|
|
27
|
+
}
|
|
28
|
+
export interface SkillsManifest {
|
|
29
|
+
/** Ordered layers, lowest precedence first. */
|
|
30
|
+
sources: SkillSourceRef[];
|
|
31
|
+
/**
|
|
32
|
+
* Semver range of the skills release the installed harness tool code
|
|
33
|
+
* supports. Updaters must not adopt releases outside this range, so skill
|
|
34
|
+
* docs can never drift ahead of installed tool signatures.
|
|
35
|
+
*/
|
|
36
|
+
compatibleSkillsRange?: string;
|
|
37
|
+
}
|
|
38
|
+
export declare function validateManifest(manifest: SkillsManifest): void;
|
|
39
|
+
export declare function layerAllowsSkill(source: SkillSourceRef, skillName: string): boolean;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Ordered-overlay skill source manifest.
|
|
4
|
+
*
|
|
5
|
+
* Skills are resolved from an ordered list of sources; later sources override
|
|
6
|
+
* or add skills by name (last-write-wins). Typical order:
|
|
7
|
+
*
|
|
8
|
+
* 1. `constructive-skills` at a pinned release (hardened public base)
|
|
9
|
+
* 2. team overlay repo(s) (skills being iterated on)
|
|
10
|
+
* 3. private known-gaps overlay (internal deployments only)
|
|
11
|
+
*
|
|
12
|
+
* Each layer keeps its own pin so the base can harden slowly while overlays
|
|
13
|
+
* stay fresh; promoting an overlay skill upstream = moving the file down a
|
|
14
|
+
* layer.
|
|
15
|
+
*/
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.validateManifest = validateManifest;
|
|
18
|
+
exports.layerAllowsSkill = layerAllowsSkill;
|
|
19
|
+
function validateManifest(manifest) {
|
|
20
|
+
if (!Array.isArray(manifest.sources) || manifest.sources.length === 0) {
|
|
21
|
+
throw new Error('Skills manifest must declare at least one source layer');
|
|
22
|
+
}
|
|
23
|
+
const seen = new Set();
|
|
24
|
+
for (const source of manifest.sources) {
|
|
25
|
+
if (!source.name) {
|
|
26
|
+
throw new Error('Every manifest source needs a unique `name`');
|
|
27
|
+
}
|
|
28
|
+
if (seen.has(source.name)) {
|
|
29
|
+
throw new Error(`Duplicate manifest source name: ${source.name}`);
|
|
30
|
+
}
|
|
31
|
+
seen.add(source.name);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
function layerAllowsSkill(source, skillName) {
|
|
35
|
+
if (source.exclude?.includes(skillName))
|
|
36
|
+
return false;
|
|
37
|
+
if (source.include && !source.include.includes(skillName))
|
|
38
|
+
return false;
|
|
39
|
+
return true;
|
|
40
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { HarnessSkill } from '../types';
|
|
2
|
+
export interface MaterializeOptions {
|
|
3
|
+
/**
|
|
4
|
+
* `{{VAR}}` substitutions applied to every skill file, e.g.
|
|
5
|
+
* `{ HARNESS_TEMPLATES_DIR: '/abs/path' }`. Host adapters supply real paths.
|
|
6
|
+
*/
|
|
7
|
+
templateVars?: Record<string, string>;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Write a resolved skill set to `<targetDir>/<skill-name>/…`, replacing any
|
|
11
|
+
* previous contents so removed skills do not linger.
|
|
12
|
+
*/
|
|
13
|
+
export declare function materializeSkills(targetDir: string, skills: HarnessSkill[], options?: MaterializeOptions): string[];
|