@agentic-kit/harness 0.1.0 → 0.3.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.
@@ -1,83 +1,98 @@
1
- import { Type } from 'typebox';
2
- const FieldBlueprint = Type.Object({
3
- name: Type.String({ description: 'Field name in snake_case' }),
4
- type: Type.String({
5
- description: 'PostgreSQL type: uuid, text, integer, smallint, numeric, boolean, date, timestamp, timestamptz, time, json, jsonb, inet, citext, email, url, image, upload',
6
- }),
7
- is_required: Type.Optional(Type.Boolean({ description: 'Whether the field is NOT NULL' })),
8
- default: Type.Optional(Type.Union([Type.String(), Type.Null()], {
9
- description: 'SQL default expression, e.g. "uuidv7()", "now()", "\'draft\'"',
10
- })),
1
+ import { z } from 'zod';
2
+ const FieldBlueprintSchema = z.object({
3
+ name: z.string().describe('Field name in snake_case'),
4
+ type: z
5
+ .string()
6
+ .describe('PostgreSQL type: uuid, text, integer, smallint, numeric, boolean, date, timestamp, timestamptz, time, json, jsonb, inet, citext, email, url, image, upload'),
7
+ is_required: z.boolean().optional().describe('Whether the field is NOT NULL'),
8
+ default: z
9
+ .union([z.string(), z.null()])
10
+ .optional()
11
+ .describe('SQL default expression, e.g. "uuidv7()", "now()", "\'draft\'"'),
11
12
  });
12
- const PolicyBlueprint = Type.Object({
13
- $type: Type.String({
14
- description: 'Policy type: AuthzDirectOwner, AuthzEntityMembership, AuthzAllowAll, AuthzPublishable, AuthzAppMembership',
15
- }),
16
- data: Type.Optional(Type.Record(Type.String(), Type.Unknown(), { description: 'Policy config overrides' })),
17
- privileges: Type.Optional(Type.Array(Type.String(), {
18
- description: 'SQL privileges this policy applies to, lowercase, e.g. ["select","insert","update","delete"]. Defaults to all.',
19
- })),
20
- policy_role: Type.Optional(Type.String({ description: 'Role name. Defaults to "authenticated".' })),
21
- permissive: Type.Optional(Type.Boolean({
22
- description: 'Whether permissive (true) or restrictive (false). Defaults to true.',
23
- })),
13
+ const PolicyBlueprintSchema = z.object({
14
+ $type: z
15
+ .string()
16
+ .describe('Policy type: AuthzDirectOwner, AuthzEntityMembership, AuthzAllowAll, AuthzPublishable, AuthzAppMembership'),
17
+ data: z.record(z.string(), z.unknown()).optional().describe('Policy config overrides'),
18
+ privileges: z
19
+ .array(z.string())
20
+ .optional()
21
+ .describe('SQL privileges this policy applies to, lowercase, e.g. ["select","insert","update","delete"]. Defaults to all.'),
22
+ policy_role: z.string().optional().describe('Role name. Defaults to "authenticated".'),
23
+ permissive: z
24
+ .boolean()
25
+ .optional()
26
+ .describe('Whether permissive (true) or restrictive (false). Defaults to true.'),
24
27
  });
25
- const NodeBlueprint = Type.Union([
26
- Type.String({ description: 'Node type shorthand, e.g. "DataTimestamps"' }),
27
- Type.Object({
28
- $type: Type.String({ description: 'Node type, e.g. "DataDirectOwner"' }),
29
- data: Type.Optional(Type.Record(Type.String(), Type.Unknown(), { description: 'Node configuration data' })),
28
+ const NodeBlueprintSchema = z.union([
29
+ z.string().describe('Node type shorthand, e.g. "DataTimestamps"'),
30
+ z.object({
31
+ $type: z.string().describe('Node type, e.g. "DataDirectOwner"'),
32
+ data: z.record(z.string(), z.unknown()).optional().describe('Node configuration data'),
30
33
  }),
31
34
  ]);
32
- const DeleteAction = Type.Union([
33
- Type.Literal('c'),
34
- Type.Literal('r'),
35
- Type.Literal('n'),
36
- Type.Literal('a'),
37
- Type.Literal('d'),
38
- ], {
39
- description: 'FK delete action: c=CASCADE, r=RESTRICT, n=SET NULL, a=NO ACTION (default), d=SET DEFAULT',
35
+ const DeleteActionSchema = z
36
+ .enum(['c', 'r', 'n', 'a', 'd'])
37
+ .describe('FK delete action: c=CASCADE, r=RESTRICT, n=SET NULL, a=NO ACTION (default), d=SET DEFAULT');
38
+ const BelongsToRelationSchema = z.object({
39
+ $type: z.literal('RelationBelongsTo'),
40
+ source_table: z.string().describe('Source table name'),
41
+ target_table: z.string().describe('Target table name'),
42
+ field_name: z.string().describe('FK column name on the source table, e.g. "author_id"'),
43
+ delete_action: DeleteActionSchema.optional(),
44
+ is_required: z.boolean().optional().describe('Whether the FK is NOT NULL (default: true)'),
40
45
  });
41
- const BelongsToRelation = Type.Object({
42
- $type: Type.Literal('RelationBelongsTo'),
43
- source_table: Type.String({ description: 'Source table name' }),
44
- target_table: Type.String({ description: 'Target table name' }),
45
- field_name: Type.String({ description: 'FK column name on the source table, e.g. "author_id"' }),
46
- delete_action: Type.Optional(DeleteAction),
47
- is_required: Type.Optional(Type.Boolean({ description: 'Whether the FK is NOT NULL (default: true)' })),
46
+ const ManyToManyRelationSchema = z.object({
47
+ $type: z.literal('RelationManyToMany'),
48
+ source_table: z.string().describe('Source table name'),
49
+ target_table: z.string().describe('Target table name'),
50
+ junction_table_name: z.string().describe('Junction table name, e.g. "post_tags"'),
51
+ delete_action: DeleteActionSchema.optional(),
48
52
  });
49
- const ManyToManyRelation = Type.Object({
50
- $type: Type.Literal('RelationManyToMany'),
51
- source_table: Type.String({ description: 'Source table name' }),
52
- target_table: Type.String({ description: 'Target table name' }),
53
- junction_table_name: Type.String({ description: 'Junction table name, e.g. "post_tags"' }),
54
- delete_action: Type.Optional(DeleteAction),
55
- });
56
- const RelationBlueprint = Type.Union([BelongsToRelation, ManyToManyRelation]);
57
- const TableBlueprint = Type.Object({
58
- table_name: Type.String({ description: 'PostgreSQL table name in snake_case, plural' }),
59
- nodes: Type.Optional(Type.Array(NodeBlueprint, {
60
- description: 'Data behavior nodes (e.g. DataTimestamps, DataSoftDelete). DataId and DataTimestamps are auto-included.',
61
- })),
62
- fields: Type.Optional(Type.Array(FieldBlueprint, {
63
- description: 'Custom fields only — do NOT include id, timestamps, or node-generated fields (owner_id, entity_id, is_published, published_at)',
64
- })),
65
- policies: Type.Array(PolicyBlueprint, {
66
- description: 'RLS policies for this table. At least one required.',
67
- }),
53
+ const RelationBlueprintSchema = z.union([BelongsToRelationSchema, ManyToManyRelationSchema]);
54
+ const TableBlueprintSchema = z.object({
55
+ table_name: z.string().describe('PostgreSQL table name in snake_case, plural'),
56
+ nodes: z
57
+ .array(NodeBlueprintSchema)
58
+ .optional()
59
+ .describe('Data behavior nodes (e.g. DataTimestamps, DataSoftDelete). DataId and DataTimestamps are auto-included.'),
60
+ fields: z
61
+ .array(FieldBlueprintSchema)
62
+ .optional()
63
+ .describe('Custom fields only — do NOT include id, timestamps, or node-generated fields (owner_id, entity_id, is_published, published_at)'),
64
+ policies: z
65
+ .array(PolicyBlueprintSchema)
66
+ .describe('RLS policies for this table. At least one required.'),
68
67
  });
69
- export const BlueprintDefinitionSchema = Type.Object({
70
- tables: Type.Array(TableBlueprint, { description: 'Tables to create' }),
71
- relations: Type.Optional(Type.Array(RelationBlueprint, { description: 'Relations between tables' })),
68
+ export const BlueprintDefinitionZod = z.object({
69
+ tables: z.array(TableBlueprintSchema).describe('Tables to create'),
70
+ relations: z
71
+ .array(RelationBlueprintSchema)
72
+ .optional()
73
+ .describe('Relations between tables'),
72
74
  });
73
- export const BlueprintSchema = Type.Object({
74
- name: Type.String({ description: 'Blueprint name in snake_case' }),
75
- description: Type.String({ description: 'Brief description of what this schema is for' }),
76
- definition: BlueprintDefinitionSchema,
77
- categories: Type.Optional(Type.Array(Type.String(), {
78
- description: 'Template categories if saved as template, e.g. ["e-commerce", "healthcare"]',
79
- })),
80
- tags: Type.Optional(Type.Array(Type.String(), {
81
- description: 'Freeform search tags if saved as template, e.g. ["products", "orders"]',
82
- })),
75
+ export const BlueprintZod = z.object({
76
+ name: z.string().describe('Blueprint name in snake_case'),
77
+ description: z.string().describe('Brief description of what this schema is for'),
78
+ definition: BlueprintDefinitionZod,
79
+ categories: z
80
+ .array(z.string())
81
+ .optional()
82
+ .describe('Template categories if saved as template, e.g. ["e-commerce", "healthcare"]'),
83
+ tags: z
84
+ .array(z.string())
85
+ .optional()
86
+ .describe('Freeform search tags if saved as template, e.g. ["products", "orders"]'),
83
87
  });
88
+ /**
89
+ * JSON Schema objects for hosts that hand tool parameter schemas to an agent
90
+ * runtime (e.g. pi's `ToolDefinition.parameters`). Same shapes the previous
91
+ * typebox exports produced.
92
+ */
93
+ export const BlueprintDefinitionSchema = toJsonSchema(BlueprintDefinitionZod);
94
+ export const BlueprintSchema = toJsonSchema(BlueprintZod);
95
+ function toJsonSchema(schema) {
96
+ const { $schema: _$schema, ...rest } = z.toJSONSchema(schema, { target: 'draft-7' });
97
+ return rest;
98
+ }
package/esm/index.d.ts CHANGED
@@ -8,6 +8,7 @@ export * from './skills/materialize';
8
8
  export * from './skills/registry';
9
9
  export * from './skills/integrity';
10
10
  export * from './skills/fetch';
11
+ export * from './skills/git-fetch';
11
12
  export * from './skills/update-check';
12
13
  export * from './gating/preview';
13
14
  export * from './gating/decline-guard';
package/esm/index.js CHANGED
@@ -8,6 +8,7 @@ export * from './skills/materialize';
8
8
  export * from './skills/registry';
9
9
  export * from './skills/integrity';
10
10
  export * from './skills/fetch';
11
+ export * from './skills/git-fetch';
11
12
  export * from './skills/update-check';
12
13
  export * from './gating/preview';
13
14
  export * from './gating/decline-guard';
@@ -1,7 +1,9 @@
1
1
  export interface ParsedSkillFrontmatter {
2
2
  name: string;
3
3
  description: string;
4
+ /** Skill names this skill depends on (frontmatter `requires:`). */
5
+ requires: string[];
4
6
  body: string;
5
7
  }
6
- /** Parse the minimal YAML frontmatter (`name`, `description`) of a SKILL.md. */
8
+ /** Parse the minimal YAML frontmatter (`name`, `description`, optional `requires`) of a SKILL.md. */
7
9
  export declare function parseFrontmatter(raw: string): ParsedSkillFrontmatter;
@@ -1,3 +1,21 @@
1
+ function parseRequires(fm) {
2
+ const inline = fm.match(/(?:^|\n)requires:\s*\[([^\]]*)\]/);
3
+ if (inline) {
4
+ return inline[1]
5
+ .split(',')
6
+ .map((s) => unquoteScalar(s.trim()) ?? '')
7
+ .filter(Boolean);
8
+ }
9
+ const block = fm.match(/(?:^|\n)requires:\s*\n((?:[ \t]+-[^\n]*\n?)+)/);
10
+ if (block) {
11
+ return block[1]
12
+ .split('\n')
13
+ .map((line) => line.replace(/^[ \t]+-\s*/, '').trim())
14
+ .map((s) => unquoteScalar(s) ?? '')
15
+ .filter(Boolean);
16
+ }
17
+ return [];
18
+ }
1
19
  function unquoteScalar(value) {
2
20
  if (value && value.length >= 2 && value.startsWith('"') && value.endsWith('"')) {
3
21
  try {
@@ -9,7 +27,7 @@ function unquoteScalar(value) {
9
27
  }
10
28
  return value;
11
29
  }
12
- /** Parse the minimal YAML frontmatter (`name`, `description`) of a SKILL.md. */
30
+ /** Parse the minimal YAML frontmatter (`name`, `description`, optional `requires`) of a SKILL.md. */
13
31
  export function parseFrontmatter(raw) {
14
32
  const match = raw.match(/^---\r?\n([\s\S]*?)\r?\n---\r?\n([\s\S]*)$/);
15
33
  if (!match) {
@@ -24,5 +42,5 @@ export function parseFrontmatter(raw) {
24
42
  throw new Error('Skill frontmatter missing `name`');
25
43
  if (!description)
26
44
  throw new Error('Skill frontmatter missing `description`');
27
- return { name, description, body };
45
+ return { name, description, requires: parseRequires(fm), body };
28
46
  }
@@ -0,0 +1,32 @@
1
+ import { FetchedRelease } from './fetch';
2
+ import { FetchLike } from './registry';
3
+ /**
4
+ * GitHub-repo skill source: the skills repo is just a git repository
5
+ * (e.g. `constructive-io/constructive-skills`), released by tagging. Releases
6
+ * are downloaded as codeload tarballs and unpacked into the same
7
+ * `<skillsRoot>/<version>/` layout the npm fetcher uses, so
8
+ * `latestLocalRelease()` and `DirectorySkillSource` work identically for both.
9
+ */
10
+ export interface GitFetchOptions {
11
+ /** `owner/repo`, e.g. `constructive-io/constructive-skills`. */
12
+ repo: string;
13
+ /**
14
+ * Ref pin: a tag (`v1.2.0`), a semver range resolved against tags
15
+ * (`^1.2.0`), a full commit SHA, or a branch name. Tags and SHAs are
16
+ * reproducible pins; a branch is a moving pointer resolved at fetch time.
17
+ */
18
+ pin: string;
19
+ /** Root directory releases unpack into: `<skillsRoot>/<version>/`. */
20
+ skillsRoot: string;
21
+ /** Path of the skills tree inside the repo (default `.agents/skills`). */
22
+ repoSubdir?: string;
23
+ /** GitHub API/codeload base overrides (GHES) and injectable HTTP. */
24
+ apiUrl?: string;
25
+ codeloadUrl?: string;
26
+ fetchImpl?: FetchLike;
27
+ /** Token for private repos; sent as `authorization: Bearer <token>`. */
28
+ token?: string;
29
+ }
30
+ export declare function fetchSkillsFromGit(options: GitFetchOptions): Promise<FetchedRelease>;
31
+ /** Semver versions published as tags on the repo (e.g. `v1.2.0` → `1.2.0`). */
32
+ export declare function listGitTagVersions(options: Pick<GitFetchOptions, 'repo' | 'apiUrl' | 'fetchImpl' | 'token'>): Promise<string[]>;
@@ -0,0 +1,120 @@
1
+ import * as fs from 'fs';
2
+ import * as os from 'os';
3
+ import * as path from 'path';
4
+ import * as semver from 'semver';
5
+ import * as tar from 'tar';
6
+ const DEFAULT_API = 'https://api.github.com';
7
+ const DEFAULT_CODELOAD = 'https://codeload.github.com';
8
+ const FULL_SHA = /^[0-9a-f]{40}$/;
9
+ export async function fetchSkillsFromGit(options) {
10
+ const subdir = options.repoSubdir ?? '.agents/skills';
11
+ const fetchImpl = options.fetchImpl ?? fetch;
12
+ // Reproducible pins already on disk never touch the network.
13
+ const exact = semver.valid(cleanTag(options.pin)) ?? (FULL_SHA.test(options.pin) ? options.pin : null);
14
+ if (exact) {
15
+ const cached = cachedGitRelease(options.skillsRoot, exact, subdir);
16
+ if (cached)
17
+ return cached;
18
+ }
19
+ const resolved = await resolveGitPin(options, fetchImpl);
20
+ const cached = cachedGitRelease(options.skillsRoot, resolved.version, subdir);
21
+ if (cached)
22
+ return cached;
23
+ const codeload = (options.codeloadUrl ?? DEFAULT_CODELOAD).replace(/\/$/, '');
24
+ const url = `${codeload}/${options.repo}/tar.gz/${resolved.ref}`;
25
+ const res = await fetchImpl(url, { headers: authHeaders(options.token) });
26
+ if (!res.ok) {
27
+ throw new Error(`Git tarball download failed: HTTP ${res.status} (${url})`);
28
+ }
29
+ const data = Buffer.from(await res.arrayBuffer());
30
+ const versionDir = path.join(options.skillsRoot, resolved.version);
31
+ const staging = fs.mkdtempSync(path.join(os.tmpdir(), 'harness-skills-git-'));
32
+ try {
33
+ const tarballPath = path.join(staging, 'release.tgz');
34
+ fs.writeFileSync(tarballPath, data);
35
+ const unpackDir = path.join(staging, 'repo');
36
+ fs.mkdirSync(unpackDir);
37
+ await tar.extract({ file: tarballPath, cwd: unpackDir, strip: 1 });
38
+ if (!fs.existsSync(path.join(unpackDir, subdir))) {
39
+ throw new Error(`${options.repo}@${resolved.ref} has no ${subdir} directory`);
40
+ }
41
+ fs.mkdirSync(path.dirname(versionDir), { recursive: true });
42
+ fs.rmSync(versionDir, { recursive: true, force: true });
43
+ fs.renameSync(unpackDir, versionDir);
44
+ }
45
+ finally {
46
+ fs.rmSync(staging, { recursive: true, force: true });
47
+ }
48
+ return {
49
+ version: resolved.version,
50
+ skillsDir: path.join(versionDir, subdir),
51
+ fromCache: false,
52
+ };
53
+ }
54
+ /**
55
+ * Resolve a pin to a downloadable ref:
56
+ * 1. full commit SHA → itself;
57
+ * 2. exact tag (with or without `v`) → that tag;
58
+ * 3. semver range → highest satisfying tag;
59
+ * 4. anything else → treated as a branch, resolved to its head SHA.
60
+ */
61
+ async function resolveGitPin(options, fetchImpl) {
62
+ const { pin } = options;
63
+ if (FULL_SHA.test(pin)) {
64
+ return { version: pin, ref: pin, sha: pin };
65
+ }
66
+ const tags = await listTags(options, fetchImpl);
67
+ const byVersion = new Map();
68
+ for (const tag of tags) {
69
+ const version = semver.valid(cleanTag(tag.name));
70
+ if (version)
71
+ byVersion.set(version, tag);
72
+ }
73
+ const exact = semver.valid(cleanTag(pin));
74
+ if (exact && byVersion.has(exact)) {
75
+ const tag = byVersion.get(exact);
76
+ return { version: exact, ref: tag.name, sha: tag.sha };
77
+ }
78
+ const resolved = semver.maxSatisfying([...byVersion.keys()], pin);
79
+ if (resolved) {
80
+ const tag = byVersion.get(resolved);
81
+ return { version: resolved, ref: tag.name, sha: tag.sha };
82
+ }
83
+ // Branch pin: resolve the head SHA so the unpacked dir is content-addressed.
84
+ const api = (options.apiUrl ?? DEFAULT_API).replace(/\/$/, '');
85
+ const res = await fetchImpl(`${api}/repos/${options.repo}/commits/${encodeURIComponent(pin)}`, {
86
+ headers: { accept: 'application/vnd.github+json', ...authHeaders(options.token) },
87
+ });
88
+ if (!res.ok) {
89
+ throw new Error(`No tag satisfies "${pin}" and ref lookup failed: HTTP ${res.status}`);
90
+ }
91
+ const commit = (await res.json());
92
+ return { version: commit.sha, ref: commit.sha, sha: commit.sha };
93
+ }
94
+ /** Semver versions published as tags on the repo (e.g. `v1.2.0` → `1.2.0`). */
95
+ export async function listGitTagVersions(options) {
96
+ const fetchImpl = options.fetchImpl ?? fetch;
97
+ const tags = await listTags(options, fetchImpl);
98
+ return tags.map((t) => semver.valid(cleanTag(t.name))).filter((v) => v !== null);
99
+ }
100
+ async function listTags(options, fetchImpl) {
101
+ const api = (options.apiUrl ?? DEFAULT_API).replace(/\/$/, '');
102
+ const res = await fetchImpl(`${api}/repos/${options.repo}/tags?per_page=100`, {
103
+ headers: { accept: 'application/vnd.github+json', ...authHeaders(options.token) },
104
+ });
105
+ if (!res.ok) {
106
+ throw new Error(`Tag listing failed for ${options.repo}: HTTP ${res.status}`);
107
+ }
108
+ const tags = (await res.json());
109
+ return tags.map((t) => ({ name: t.name, sha: t.commit.sha }));
110
+ }
111
+ function cachedGitRelease(skillsRoot, version, subdir) {
112
+ const skillsDir = path.join(skillsRoot, version, subdir);
113
+ return fs.existsSync(skillsDir) ? { version, skillsDir, fromCache: true } : null;
114
+ }
115
+ function cleanTag(tag) {
116
+ return tag.replace(/^v/, '');
117
+ }
118
+ function authHeaders(token) {
119
+ return token ? { authorization: `Bearer ${token}` } : {};
120
+ }
@@ -1,11 +1,24 @@
1
1
  import { HarnessSkill } from '../types';
2
2
  import { SkillsManifest } from './manifest';
3
3
  import { SkillSource } from './source';
4
+ export interface ResolveSkillsOptions {
5
+ /**
6
+ * Called for every `requires:` entry that names a skill not present in any
7
+ * layer (or explicitly excluded everywhere). Missing requirements never
8
+ * throw — a skill may legitimately depend on one the host bundles itself.
9
+ */
10
+ onMissingRequire?: (skillName: string, requiredName: string) => void;
11
+ }
4
12
  /**
5
13
  * Resolve the effective skill set from ordered source layers.
6
14
  *
7
15
  * Sources are applied in manifest order; a later layer replaces an
8
16
  * earlier layer's skill of the same name wholesale (all files), and may add
9
17
  * new skills. Include/exclude filters apply per layer.
18
+ *
19
+ * After merging, frontmatter `requires:` dependencies are followed
20
+ * transitively: a required skill is pulled in even when a layer's `include`
21
+ * list omits it. Explicit `exclude` entries still win — an excluded skill is
22
+ * never pulled back in by a dependency.
10
23
  */
11
- export declare function resolveSkills(manifest: SkillsManifest, sources: SkillSource[]): Promise<HarnessSkill[]>;
24
+ export declare function resolveSkills(manifest: SkillsManifest, sources: SkillSource[], options?: ResolveSkillsOptions): Promise<HarnessSkill[]>;
@@ -5,21 +5,47 @@ import { layerAllowsSkill, validateManifest } from './manifest';
5
5
  * Sources are applied in manifest order; a later layer replaces an
6
6
  * earlier layer's skill of the same name wholesale (all files), and may add
7
7
  * new skills. Include/exclude filters apply per layer.
8
+ *
9
+ * After merging, frontmatter `requires:` dependencies are followed
10
+ * transitively: a required skill is pulled in even when a layer's `include`
11
+ * list omits it. Explicit `exclude` entries still win — an excluded skill is
12
+ * never pulled back in by a dependency.
8
13
  */
9
- export async function resolveSkills(manifest, sources) {
14
+ export async function resolveSkills(manifest, sources, options = {}) {
10
15
  validateManifest(manifest);
11
16
  const byName = new Map(sources.map((s) => [s.name, s]));
12
17
  const resolved = new Map();
18
+ /** Merged pool ignoring `include` filters (but honoring `exclude`) — the
19
+ * candidates a `requires:` may pull in. */
20
+ const requirePool = new Map();
13
21
  for (const ref of manifest.sources) {
14
22
  const source = byName.get(ref.name);
15
23
  if (!source) {
16
24
  throw new Error(`Manifest source ${ref.name} has no registered SkillSource`);
17
25
  }
18
26
  for (const skill of await source.load()) {
27
+ if (ref.exclude?.includes(skill.name))
28
+ continue;
29
+ requirePool.set(skill.name, skill);
19
30
  if (!layerAllowsSkill(ref, skill.name))
20
31
  continue;
21
32
  resolved.set(skill.name, skill);
22
33
  }
23
34
  }
35
+ const queue = [...resolved.values()];
36
+ while (queue.length > 0) {
37
+ const skill = queue.pop();
38
+ for (const requiredName of skill.requires) {
39
+ if (resolved.has(requiredName))
40
+ continue;
41
+ const required = requirePool.get(requiredName);
42
+ if (!required) {
43
+ options.onMissingRequire?.(skill.name, requiredName);
44
+ continue;
45
+ }
46
+ resolved.set(requiredName, required);
47
+ queue.push(required);
48
+ }
49
+ }
24
50
  return [...resolved.values()];
25
51
  }
@@ -26,10 +26,10 @@ export class DirectorySkillSource {
26
26
  if (!fs.existsSync(skillMd))
27
27
  continue;
28
28
  const raw = fs.readFileSync(skillMd, 'utf8');
29
- const { name, description } = parseFrontmatter(raw);
29
+ const { name, description, requires } = parseFrontmatter(raw);
30
30
  const files = [{ relPath: 'SKILL.md', contents: raw }];
31
31
  collectExtraFiles(skillDir, '', files);
32
- skills.push({ name, description, files, sourceName: this.name });
32
+ skills.push({ name, description, requires, files, sourceName: this.name });
33
33
  }
34
34
  return skills;
35
35
  }
@@ -1,6 +1,6 @@
1
+ import { GitFetchOptions } from './git-fetch';
1
2
  import { RegistryOptions } from './registry';
2
- export interface UpdateCheckOptions extends RegistryOptions {
3
- pkg: string;
3
+ interface UpdateCheckCommonOptions {
4
4
  /** Version currently in use. */
5
5
  currentVersion: string;
6
6
  /**
@@ -14,6 +14,11 @@ export interface UpdateCheckOptions extends RegistryOptions {
14
14
  ttlMs?: number;
15
15
  now?: () => number;
16
16
  }
17
+ export interface UpdateCheckOptions extends RegistryOptions, UpdateCheckCommonOptions {
18
+ pkg: string;
19
+ }
20
+ export interface GitUpdateCheckOptions extends Pick<GitFetchOptions, 'repo' | 'apiUrl' | 'fetchImpl' | 'token'>, UpdateCheckCommonOptions {
21
+ }
17
22
  export interface UpdateCheckResult {
18
23
  checkedAt: number;
19
24
  /** True when this result came from the cache file, not the registry. */
@@ -34,3 +39,9 @@ export interface UpdateCheckResult {
34
39
  * cached result (stale ok) or report "no update" — never throw.
35
40
  */
36
41
  export declare function checkForSkillsUpdate(options: UpdateCheckOptions): Promise<UpdateCheckResult>;
42
+ /**
43
+ * Same update check against a GitHub repo's semver tags instead of an npm
44
+ * registry (the skills repo is just a git repository, released by tagging).
45
+ */
46
+ export declare function checkForSkillsUpdateFromGit(options: GitUpdateCheckOptions): Promise<UpdateCheckResult>;
47
+ export {};
@@ -1,6 +1,7 @@
1
1
  import * as fs from 'fs';
2
2
  import * as path from 'path';
3
3
  import * as semver from 'semver';
4
+ import { listGitTagVersions } from './git-fetch';
4
5
  import { RegistryClient } from './registry';
5
6
  const DEFAULT_TTL_MS = 24 * 60 * 60 * 1000;
6
7
  /**
@@ -9,6 +10,19 @@ const DEFAULT_TTL_MS = 24 * 60 * 60 * 1000;
9
10
  * cached result (stale ok) or report "no update" — never throw.
10
11
  */
11
12
  export async function checkForSkillsUpdate(options) {
13
+ return checkWithLister(options, async () => {
14
+ const packument = await new RegistryClient(options).packument(options.pkg);
15
+ return Object.keys(packument.versions);
16
+ });
17
+ }
18
+ /**
19
+ * Same update check against a GitHub repo's semver tags instead of an npm
20
+ * registry (the skills repo is just a git repository, released by tagging).
21
+ */
22
+ export async function checkForSkillsUpdateFromGit(options) {
23
+ return checkWithLister(options, () => listGitTagVersions(options));
24
+ }
25
+ async function checkWithLister(options, listVersions) {
12
26
  const now = options.now ?? Date.now;
13
27
  const ttl = options.ttlMs ?? DEFAULT_TTL_MS;
14
28
  const cached = readCache(options.cacheFile);
@@ -17,8 +31,7 @@ export async function checkForSkillsUpdate(options) {
17
31
  }
18
32
  let versions;
19
33
  try {
20
- const packument = await new RegistryClient(options).packument(options.pkg);
21
- versions = Object.keys(packument.versions).filter((v) => semver.valid(v));
34
+ versions = (await listVersions()).filter((v) => semver.valid(v));
22
35
  }
23
36
  catch {
24
37
  if (cached)
package/esm/types.d.ts CHANGED
@@ -15,6 +15,8 @@ export interface SkillFile {
15
15
  export interface HarnessSkill {
16
16
  name: string;
17
17
  description: string;
18
+ /** Skill names this skill depends on (frontmatter `requires:`). */
19
+ requires: string[];
18
20
  files: SkillFile[];
19
21
  /** Name of the manifest source layer this skill was resolved from. */
20
22
  sourceName: string;
package/index.d.ts CHANGED
@@ -8,6 +8,7 @@ export * from './skills/materialize';
8
8
  export * from './skills/registry';
9
9
  export * from './skills/integrity';
10
10
  export * from './skills/fetch';
11
+ export * from './skills/git-fetch';
11
12
  export * from './skills/update-check';
12
13
  export * from './gating/preview';
13
14
  export * from './gating/decline-guard';
package/index.js CHANGED
@@ -24,6 +24,7 @@ __exportStar(require("./skills/materialize"), exports);
24
24
  __exportStar(require("./skills/registry"), exports);
25
25
  __exportStar(require("./skills/integrity"), exports);
26
26
  __exportStar(require("./skills/fetch"), exports);
27
+ __exportStar(require("./skills/git-fetch"), exports);
27
28
  __exportStar(require("./skills/update-check"), exports);
28
29
  __exportStar(require("./gating/preview"), exports);
29
30
  __exportStar(require("./gating/decline-guard"), exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentic-kit/harness",
3
- "version": "0.1.0",
3
+ "version": "0.3.0",
4
4
  "author": "Dan Lynch <pyramation@gmail.com>",
5
5
  "description": "Host-agnostic Constructive harness core — skill overlay resolution, materialization, and on-disk layout for harness hosts (desktop, CLI, MCP)",
6
6
  "main": "index.js",
@@ -32,11 +32,11 @@
32
32
  "appstash": "^0.7.0",
33
33
  "semver": "^7.7.2",
34
34
  "tar": "^7.4.3",
35
- "typebox": "~1.1.38"
35
+ "zod": "^4.4.3"
36
36
  },
37
37
  "devDependencies": {
38
38
  "@types/semver": "^7.7.0"
39
39
  },
40
40
  "keywords": [],
41
- "gitHead": "3ba915d42b63720086eb4d092403328a320b0074"
41
+ "gitHead": "31f7cd3d3cc28cf069056eae5b2a0d4198d154a1"
42
42
  }
@@ -1,7 +1,9 @@
1
1
  export interface ParsedSkillFrontmatter {
2
2
  name: string;
3
3
  description: string;
4
+ /** Skill names this skill depends on (frontmatter `requires:`). */
5
+ requires: string[];
4
6
  body: string;
5
7
  }
6
- /** Parse the minimal YAML frontmatter (`name`, `description`) of a SKILL.md. */
8
+ /** Parse the minimal YAML frontmatter (`name`, `description`, optional `requires`) of a SKILL.md. */
7
9
  export declare function parseFrontmatter(raw: string): ParsedSkillFrontmatter;