@agentic-kit/harness 0.9.0 → 0.10.1

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.
@@ -21,6 +21,10 @@ export function createConfirmGate(deps) {
21
21
  if (!MUTATING_DB_TOOLS.has(event.toolName))
22
22
  return;
23
23
  const input = event.input;
24
+ // manage_entity_types multiplexes read + write actions behind one tool
25
+ // name; its read action is not a mutation, so it skips the gate.
26
+ if (event.toolName === 'manage_entity_types' && input?.action === 'list')
27
+ return;
24
28
  const retryBlock = declineGuard.checkRetry(event.toolName, input);
25
29
  if (retryBlock) {
26
30
  if (host.hasUI) {
@@ -41,8 +45,13 @@ export function createConfirmGate(deps) {
41
45
  }
42
46
  if (!(await deps.isProjectRunnable(cwd)))
43
47
  return;
44
- if (event.toolName === 'add_records' && !(await deps.hasDataToken(cwd)))
48
+ // Tools that need an app sign-in skip the confirm when no data token
49
+ // exists — the tool returns its sign-in prompt instead of making the
50
+ // user approve something that fails.
51
+ if ((event.toolName === 'add_records' || event.toolName === 'create_api_key') &&
52
+ !(await deps.hasDataToken(cwd))) {
45
53
  return;
54
+ }
46
55
  let resolvedPreview;
47
56
  if (event.toolName === 'create_template') {
48
57
  const blueprintName = typeof input?.blueprintName === 'string' ? input.blueprintName : undefined;
@@ -12,6 +12,8 @@ export const MUTATING_DB_TOOLS = new Set([
12
12
  'update_template',
13
13
  'delete_template',
14
14
  'add_records',
15
+ 'manage_entity_types',
16
+ 'create_api_key',
15
17
  'run_codegen',
16
18
  ]);
17
19
  import { filterInternalPolicies } from '../blueprint/internal-policies';
@@ -164,6 +166,37 @@ export function buildConfirmPrompt(toolName, input) {
164
166
  preview: count > 0 ? { kind: 'records', tableName, rows } : undefined,
165
167
  };
166
168
  }
169
+ case 'manage_entity_types': {
170
+ const action = str(input, 'action');
171
+ const name = str(input, 'name');
172
+ const id = str(input, 'entity_type_id');
173
+ switch (action) {
174
+ case 'create':
175
+ return {
176
+ title: 'Create entity type?',
177
+ message: `Provision entity type "${name ?? '?'}" in the project database (creates its entity table and membership wiring).`,
178
+ };
179
+ case 'delete':
180
+ return {
181
+ title: 'Delete entity type?',
182
+ message: `Delete the registration of entity type ${id ?? '?'}. The provisioned entity table and its data stay in the API schema.`,
183
+ };
184
+ default:
185
+ return { title: 'Manage entity types?', message: 'Change entity types in the project database.' };
186
+ }
187
+ }
188
+ case 'create_api_key': {
189
+ const keyName = str(input, 'key_name') ?? '?';
190
+ const readOnly = input?.read_only === true;
191
+ const entityIds = Array.isArray(input?.entity_ids) ? input.entity_ids.length : 0;
192
+ const scope = entityIds > 0
193
+ ? `scoped to ${entityIds} entit${entityIds === 1 ? 'y' : 'ies'}`
194
+ : 'unscoped — it acts as your signed-in app user';
195
+ return {
196
+ title: 'Create API key?',
197
+ message: `Mint API key "${keyName}" (${scope}${readOnly ? ', read-only' : ''}). You may be asked to verify your password; the key is written to .env and shown to you once — never to the agent.`,
198
+ };
199
+ }
167
200
  case 'run_codegen':
168
201
  return {
169
202
  title: 'Run codegen?',
package/esm/index.d.ts CHANGED
@@ -7,6 +7,7 @@ export * from './gating/confirm-gate';
7
7
  export * from './gating/decline-guard';
8
8
  export * from './gating/preview';
9
9
  export * from './gating/prompts';
10
+ export * from './skills/default-source';
10
11
  export * from './skills/fetch';
11
12
  export * from './skills/frontmatter';
12
13
  export * from './skills/git-fetch';
package/esm/index.js CHANGED
@@ -7,6 +7,7 @@ export * from './gating/confirm-gate';
7
7
  export * from './gating/decline-guard';
8
8
  export * from './gating/preview';
9
9
  export * from './gating/prompts';
10
+ export * from './skills/default-source';
10
11
  export * from './skills/fetch';
11
12
  export * from './skills/frontmatter';
12
13
  export * from './skills/git-fetch';
@@ -0,0 +1,30 @@
1
+ import { FetchedRelease } from './fetch';
2
+ import { GitFetchOptions } from './git-fetch';
3
+ import { SkillSourceRef } from './manifest';
4
+ /**
5
+ * The default skills layer every harness consumer gets without declaring
6
+ * anything: the public `constructive-skills` repo at branch head. The repo has
7
+ * no semver tags yet, so `main` is the only "latest" mechanism; once tagging
8
+ * starts, consumers can harden to a semver pin via their manifest.
9
+ */
10
+ export declare const DEFAULT_SKILLS_REPO = "constructive-io/constructive-skills";
11
+ export declare const DEFAULT_SKILLS_SOURCE_NAME = "constructive-skills";
12
+ export declare const DEFAULT_SKILLS_PIN = "main";
13
+ export type FetchDefaultSkillsOptions = Pick<GitFetchOptions, 'skillsRoot'> & Partial<Omit<GitFetchOptions, 'skillsRoot'>>;
14
+ /**
15
+ * Fetch the default skills layer: `DEFAULT_SKILLS_REPO@main` through the
16
+ * normal git fetcher (per-SHA on-disk cache, no re-download for an unchanged
17
+ * head). When the fetch fails — offline, rate-limited — the newest release
18
+ * already on disk is returned instead; with nothing cached the fetch error
19
+ * propagates so the caller can skip the layer with a warning.
20
+ */
21
+ export declare function fetchDefaultSkills(options: FetchDefaultSkillsOptions): Promise<FetchedRelease>;
22
+ /** Manifest ref for the default layer, lowest precedence by convention. */
23
+ export declare function defaultSkillLayer(): SkillSourceRef;
24
+ /**
25
+ * Newest already-downloaded release under `skillsRoot`, including branch-head
26
+ * fetches. Branch heads unpack under commit-SHA directory names, which the
27
+ * semver filter in `latestLocalRelease` cannot see — those fall back to
28
+ * newest-by-mtime. Tagged (semver) releases win over SHA directories.
29
+ */
30
+ export declare function latestLocalAnyRelease(skillsRoot: string, subdir?: string): FetchedRelease | null;
@@ -0,0 +1,73 @@
1
+ import * as fs from 'fs';
2
+ import * as path from 'path';
3
+ import * as semver from 'semver';
4
+ import { latestLocalRelease } from './fetch';
5
+ import { fetchSkillsFromGit } from './git-fetch';
6
+ /**
7
+ * The default skills layer every harness consumer gets without declaring
8
+ * anything: the public `constructive-skills` repo at branch head. The repo has
9
+ * no semver tags yet, so `main` is the only "latest" mechanism; once tagging
10
+ * starts, consumers can harden to a semver pin via their manifest.
11
+ */
12
+ export const DEFAULT_SKILLS_REPO = 'constructive-io/constructive-skills';
13
+ export const DEFAULT_SKILLS_SOURCE_NAME = 'constructive-skills';
14
+ export const DEFAULT_SKILLS_PIN = 'main';
15
+ const DEFAULT_SUBDIR = '.agents/skills';
16
+ /**
17
+ * Fetch the default skills layer: `DEFAULT_SKILLS_REPO@main` through the
18
+ * normal git fetcher (per-SHA on-disk cache, no re-download for an unchanged
19
+ * head). When the fetch fails — offline, rate-limited — the newest release
20
+ * already on disk is returned instead; with nothing cached the fetch error
21
+ * propagates so the caller can skip the layer with a warning.
22
+ */
23
+ export async function fetchDefaultSkills(options) {
24
+ const subdir = options.repoSubdir ?? DEFAULT_SUBDIR;
25
+ try {
26
+ return await fetchSkillsFromGit({
27
+ repo: DEFAULT_SKILLS_REPO,
28
+ pin: DEFAULT_SKILLS_PIN,
29
+ ...options,
30
+ });
31
+ }
32
+ catch (error) {
33
+ const local = latestLocalAnyRelease(options.skillsRoot, subdir);
34
+ if (local)
35
+ return local;
36
+ throw error;
37
+ }
38
+ }
39
+ /** Manifest ref for the default layer, lowest precedence by convention. */
40
+ export function defaultSkillLayer() {
41
+ return { name: DEFAULT_SKILLS_SOURCE_NAME };
42
+ }
43
+ /**
44
+ * Newest already-downloaded release under `skillsRoot`, including branch-head
45
+ * fetches. Branch heads unpack under commit-SHA directory names, which the
46
+ * semver filter in `latestLocalRelease` cannot see — those fall back to
47
+ * newest-by-mtime. Tagged (semver) releases win over SHA directories.
48
+ */
49
+ export function latestLocalAnyRelease(skillsRoot, subdir = DEFAULT_SUBDIR) {
50
+ const tagged = latestLocalRelease(skillsRoot, subdir);
51
+ if (tagged)
52
+ return tagged;
53
+ if (!fs.existsSync(skillsRoot))
54
+ return null;
55
+ let newest = null;
56
+ for (const name of fs.readdirSync(skillsRoot)) {
57
+ if (semver.valid(name))
58
+ continue;
59
+ const dir = path.join(skillsRoot, name);
60
+ if (!fs.existsSync(path.join(dir, subdir)))
61
+ continue;
62
+ const mtimeMs = fs.statSync(dir).mtimeMs;
63
+ if (!newest || mtimeMs > newest.mtimeMs)
64
+ newest = { version: name, mtimeMs };
65
+ }
66
+ if (!newest)
67
+ return null;
68
+ return {
69
+ version: newest.version,
70
+ skillsDir: path.join(skillsRoot, newest.version, subdir),
71
+ fromCache: true,
72
+ };
73
+ }
@@ -24,6 +24,10 @@ function createConfirmGate(deps) {
24
24
  if (!prompts_1.MUTATING_DB_TOOLS.has(event.toolName))
25
25
  return;
26
26
  const input = event.input;
27
+ // manage_entity_types multiplexes read + write actions behind one tool
28
+ // name; its read action is not a mutation, so it skips the gate.
29
+ if (event.toolName === 'manage_entity_types' && input?.action === 'list')
30
+ return;
27
31
  const retryBlock = declineGuard.checkRetry(event.toolName, input);
28
32
  if (retryBlock) {
29
33
  if (host.hasUI) {
@@ -44,8 +48,13 @@ function createConfirmGate(deps) {
44
48
  }
45
49
  if (!(await deps.isProjectRunnable(cwd)))
46
50
  return;
47
- if (event.toolName === 'add_records' && !(await deps.hasDataToken(cwd)))
51
+ // Tools that need an app sign-in skip the confirm when no data token
52
+ // exists — the tool returns its sign-in prompt instead of making the
53
+ // user approve something that fails.
54
+ if ((event.toolName === 'add_records' || event.toolName === 'create_api_key') &&
55
+ !(await deps.hasDataToken(cwd))) {
48
56
  return;
57
+ }
49
58
  let resolvedPreview;
50
59
  if (event.toolName === 'create_template') {
51
60
  const blueprintName = typeof input?.blueprintName === 'string' ? input.blueprintName : undefined;
package/gating/prompts.js CHANGED
@@ -16,6 +16,8 @@ exports.MUTATING_DB_TOOLS = new Set([
16
16
  'update_template',
17
17
  'delete_template',
18
18
  'add_records',
19
+ 'manage_entity_types',
20
+ 'create_api_key',
19
21
  'run_codegen',
20
22
  ]);
21
23
  const internal_policies_1 = require("../blueprint/internal-policies");
@@ -168,6 +170,37 @@ function buildConfirmPrompt(toolName, input) {
168
170
  preview: count > 0 ? { kind: 'records', tableName, rows } : undefined,
169
171
  };
170
172
  }
173
+ case 'manage_entity_types': {
174
+ const action = str(input, 'action');
175
+ const name = str(input, 'name');
176
+ const id = str(input, 'entity_type_id');
177
+ switch (action) {
178
+ case 'create':
179
+ return {
180
+ title: 'Create entity type?',
181
+ message: `Provision entity type "${name ?? '?'}" in the project database (creates its entity table and membership wiring).`,
182
+ };
183
+ case 'delete':
184
+ return {
185
+ title: 'Delete entity type?',
186
+ message: `Delete the registration of entity type ${id ?? '?'}. The provisioned entity table and its data stay in the API schema.`,
187
+ };
188
+ default:
189
+ return { title: 'Manage entity types?', message: 'Change entity types in the project database.' };
190
+ }
191
+ }
192
+ case 'create_api_key': {
193
+ const keyName = str(input, 'key_name') ?? '?';
194
+ const readOnly = input?.read_only === true;
195
+ const entityIds = Array.isArray(input?.entity_ids) ? input.entity_ids.length : 0;
196
+ const scope = entityIds > 0
197
+ ? `scoped to ${entityIds} entit${entityIds === 1 ? 'y' : 'ies'}`
198
+ : 'unscoped — it acts as your signed-in app user';
199
+ return {
200
+ title: 'Create API key?',
201
+ message: `Mint API key "${keyName}" (${scope}${readOnly ? ', read-only' : ''}). You may be asked to verify your password; the key is written to .env and shown to you once — never to the agent.`,
202
+ };
203
+ }
171
204
  case 'run_codegen':
172
205
  return {
173
206
  title: 'Run codegen?',
package/index.d.ts CHANGED
@@ -7,6 +7,7 @@ export * from './gating/confirm-gate';
7
7
  export * from './gating/decline-guard';
8
8
  export * from './gating/preview';
9
9
  export * from './gating/prompts';
10
+ export * from './skills/default-source';
10
11
  export * from './skills/fetch';
11
12
  export * from './skills/frontmatter';
12
13
  export * from './skills/git-fetch';
package/index.js CHANGED
@@ -23,6 +23,7 @@ __exportStar(require("./gating/confirm-gate"), exports);
23
23
  __exportStar(require("./gating/decline-guard"), exports);
24
24
  __exportStar(require("./gating/preview"), exports);
25
25
  __exportStar(require("./gating/prompts"), exports);
26
+ __exportStar(require("./skills/default-source"), exports);
26
27
  __exportStar(require("./skills/fetch"), exports);
27
28
  __exportStar(require("./skills/frontmatter"), exports);
28
29
  __exportStar(require("./skills/git-fetch"), exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentic-kit/harness",
3
- "version": "0.9.0",
3
+ "version": "0.10.1",
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",
@@ -29,14 +29,14 @@
29
29
  "test:watch": "jest --watch"
30
30
  },
31
31
  "dependencies": {
32
- "appstash": "^0.7.0",
33
- "semver": "^7.7.2",
32
+ "appstash": "^0.8.0",
33
+ "semver": "^7.8.5",
34
34
  "tar": "^7.4.3",
35
35
  "zod": "^4.4.3"
36
36
  },
37
37
  "devDependencies": {
38
- "@types/semver": "^7.7.0"
38
+ "@types/semver": "^7.8.0"
39
39
  },
40
40
  "keywords": [],
41
- "gitHead": "d508453a32a2f1d70ff6916871046615226e6f33"
41
+ "gitHead": "0d9f0718a8c768cc8b7659525953dc762833bd6b"
42
42
  }
@@ -0,0 +1,30 @@
1
+ import { FetchedRelease } from './fetch';
2
+ import { GitFetchOptions } from './git-fetch';
3
+ import { SkillSourceRef } from './manifest';
4
+ /**
5
+ * The default skills layer every harness consumer gets without declaring
6
+ * anything: the public `constructive-skills` repo at branch head. The repo has
7
+ * no semver tags yet, so `main` is the only "latest" mechanism; once tagging
8
+ * starts, consumers can harden to a semver pin via their manifest.
9
+ */
10
+ export declare const DEFAULT_SKILLS_REPO = "constructive-io/constructive-skills";
11
+ export declare const DEFAULT_SKILLS_SOURCE_NAME = "constructive-skills";
12
+ export declare const DEFAULT_SKILLS_PIN = "main";
13
+ export type FetchDefaultSkillsOptions = Pick<GitFetchOptions, 'skillsRoot'> & Partial<Omit<GitFetchOptions, 'skillsRoot'>>;
14
+ /**
15
+ * Fetch the default skills layer: `DEFAULT_SKILLS_REPO@main` through the
16
+ * normal git fetcher (per-SHA on-disk cache, no re-download for an unchanged
17
+ * head). When the fetch fails — offline, rate-limited — the newest release
18
+ * already on disk is returned instead; with nothing cached the fetch error
19
+ * propagates so the caller can skip the layer with a warning.
20
+ */
21
+ export declare function fetchDefaultSkills(options: FetchDefaultSkillsOptions): Promise<FetchedRelease>;
22
+ /** Manifest ref for the default layer, lowest precedence by convention. */
23
+ export declare function defaultSkillLayer(): SkillSourceRef;
24
+ /**
25
+ * Newest already-downloaded release under `skillsRoot`, including branch-head
26
+ * fetches. Branch heads unpack under commit-SHA directory names, which the
27
+ * semver filter in `latestLocalRelease` cannot see — those fall back to
28
+ * newest-by-mtime. Tagged (semver) releases win over SHA directories.
29
+ */
30
+ export declare function latestLocalAnyRelease(skillsRoot: string, subdir?: string): FetchedRelease | null;
@@ -0,0 +1,112 @@
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.DEFAULT_SKILLS_PIN = exports.DEFAULT_SKILLS_SOURCE_NAME = exports.DEFAULT_SKILLS_REPO = void 0;
37
+ exports.fetchDefaultSkills = fetchDefaultSkills;
38
+ exports.defaultSkillLayer = defaultSkillLayer;
39
+ exports.latestLocalAnyRelease = latestLocalAnyRelease;
40
+ const fs = __importStar(require("fs"));
41
+ const path = __importStar(require("path"));
42
+ const semver = __importStar(require("semver"));
43
+ const fetch_1 = require("./fetch");
44
+ const git_fetch_1 = require("./git-fetch");
45
+ /**
46
+ * The default skills layer every harness consumer gets without declaring
47
+ * anything: the public `constructive-skills` repo at branch head. The repo has
48
+ * no semver tags yet, so `main` is the only "latest" mechanism; once tagging
49
+ * starts, consumers can harden to a semver pin via their manifest.
50
+ */
51
+ exports.DEFAULT_SKILLS_REPO = 'constructive-io/constructive-skills';
52
+ exports.DEFAULT_SKILLS_SOURCE_NAME = 'constructive-skills';
53
+ exports.DEFAULT_SKILLS_PIN = 'main';
54
+ const DEFAULT_SUBDIR = '.agents/skills';
55
+ /**
56
+ * Fetch the default skills layer: `DEFAULT_SKILLS_REPO@main` through the
57
+ * normal git fetcher (per-SHA on-disk cache, no re-download for an unchanged
58
+ * head). When the fetch fails — offline, rate-limited — the newest release
59
+ * already on disk is returned instead; with nothing cached the fetch error
60
+ * propagates so the caller can skip the layer with a warning.
61
+ */
62
+ async function fetchDefaultSkills(options) {
63
+ const subdir = options.repoSubdir ?? DEFAULT_SUBDIR;
64
+ try {
65
+ return await (0, git_fetch_1.fetchSkillsFromGit)({
66
+ repo: exports.DEFAULT_SKILLS_REPO,
67
+ pin: exports.DEFAULT_SKILLS_PIN,
68
+ ...options,
69
+ });
70
+ }
71
+ catch (error) {
72
+ const local = latestLocalAnyRelease(options.skillsRoot, subdir);
73
+ if (local)
74
+ return local;
75
+ throw error;
76
+ }
77
+ }
78
+ /** Manifest ref for the default layer, lowest precedence by convention. */
79
+ function defaultSkillLayer() {
80
+ return { name: exports.DEFAULT_SKILLS_SOURCE_NAME };
81
+ }
82
+ /**
83
+ * Newest already-downloaded release under `skillsRoot`, including branch-head
84
+ * fetches. Branch heads unpack under commit-SHA directory names, which the
85
+ * semver filter in `latestLocalRelease` cannot see — those fall back to
86
+ * newest-by-mtime. Tagged (semver) releases win over SHA directories.
87
+ */
88
+ function latestLocalAnyRelease(skillsRoot, subdir = DEFAULT_SUBDIR) {
89
+ const tagged = (0, fetch_1.latestLocalRelease)(skillsRoot, subdir);
90
+ if (tagged)
91
+ return tagged;
92
+ if (!fs.existsSync(skillsRoot))
93
+ return null;
94
+ let newest = null;
95
+ for (const name of fs.readdirSync(skillsRoot)) {
96
+ if (semver.valid(name))
97
+ continue;
98
+ const dir = path.join(skillsRoot, name);
99
+ if (!fs.existsSync(path.join(dir, subdir)))
100
+ continue;
101
+ const mtimeMs = fs.statSync(dir).mtimeMs;
102
+ if (!newest || mtimeMs > newest.mtimeMs)
103
+ newest = { version: name, mtimeMs };
104
+ }
105
+ if (!newest)
106
+ return null;
107
+ return {
108
+ version: newest.version,
109
+ skillsDir: path.join(skillsRoot, newest.version, subdir),
110
+ fromCache: true,
111
+ };
112
+ }