@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.
Files changed (87) hide show
  1. package/LICENSE +23 -0
  2. package/README.md +176 -0
  3. package/blueprint/blueprint-defaults.d.ts +2 -0
  4. package/blueprint/blueprint-defaults.js +123 -0
  5. package/blueprint/blueprint-schema.d.ts +138 -0
  6. package/blueprint/blueprint-schema.js +86 -0
  7. package/blueprint/field-type.d.ts +25 -0
  8. package/blueprint/field-type.js +99 -0
  9. package/blueprint/internal-policies.d.ts +2 -0
  10. package/blueprint/internal-policies.js +14 -0
  11. package/blueprint/policy-provisioning.d.ts +79 -0
  12. package/blueprint/policy-provisioning.js +570 -0
  13. package/esm/blueprint/blueprint-defaults.d.ts +2 -0
  14. package/esm/blueprint/blueprint-defaults.js +120 -0
  15. package/esm/blueprint/blueprint-schema.d.ts +138 -0
  16. package/esm/blueprint/blueprint-schema.js +83 -0
  17. package/esm/blueprint/field-type.d.ts +25 -0
  18. package/esm/blueprint/field-type.js +94 -0
  19. package/esm/blueprint/internal-policies.d.ts +2 -0
  20. package/esm/blueprint/internal-policies.js +10 -0
  21. package/esm/blueprint/policy-provisioning.d.ts +79 -0
  22. package/esm/blueprint/policy-provisioning.js +553 -0
  23. package/esm/gating/confirm-gate.d.ts +46 -0
  24. package/esm/gating/confirm-gate.js +55 -0
  25. package/esm/gating/decline-guard.d.ts +7 -0
  26. package/esm/gating/decline-guard.js +48 -0
  27. package/esm/gating/preview.d.ts +37 -0
  28. package/esm/gating/preview.js +5 -0
  29. package/esm/gating/prompts.d.ts +8 -0
  30. package/esm/gating/prompts.js +175 -0
  31. package/esm/index.d.ts +20 -0
  32. package/esm/index.js +20 -0
  33. package/esm/skills/fetch.d.ts +31 -0
  34. package/esm/skills/fetch.js +84 -0
  35. package/esm/skills/frontmatter.d.ts +7 -0
  36. package/esm/skills/frontmatter.js +28 -0
  37. package/esm/skills/integrity.d.ts +8 -0
  38. package/esm/skills/integrity.js +28 -0
  39. package/esm/skills/manifest.d.ts +39 -0
  40. package/esm/skills/manifest.js +36 -0
  41. package/esm/skills/materialize.d.ts +13 -0
  42. package/esm/skills/materialize.js +26 -0
  43. package/esm/skills/overlay.d.ts +11 -0
  44. package/esm/skills/overlay.js +25 -0
  45. package/esm/skills/registry.d.ts +36 -0
  46. package/esm/skills/registry.js +30 -0
  47. package/esm/skills/source.d.ts +21 -0
  48. package/esm/skills/source.js +51 -0
  49. package/esm/skills/update-check.d.ts +36 -0
  50. package/esm/skills/update-check.js +74 -0
  51. package/esm/stash.d.ts +20 -0
  52. package/esm/stash.js +19 -0
  53. package/esm/types.d.ts +60 -0
  54. package/esm/types.js +8 -0
  55. package/gating/confirm-gate.d.ts +46 -0
  56. package/gating/confirm-gate.js +58 -0
  57. package/gating/decline-guard.d.ts +7 -0
  58. package/gating/decline-guard.js +52 -0
  59. package/gating/preview.d.ts +37 -0
  60. package/gating/preview.js +6 -0
  61. package/gating/prompts.d.ts +8 -0
  62. package/gating/prompts.js +179 -0
  63. package/index.d.ts +20 -0
  64. package/index.js +36 -0
  65. package/package.json +42 -0
  66. package/skills/fetch.d.ts +31 -0
  67. package/skills/fetch.js +122 -0
  68. package/skills/frontmatter.d.ts +7 -0
  69. package/skills/frontmatter.js +31 -0
  70. package/skills/integrity.d.ts +8 -0
  71. package/skills/integrity.js +64 -0
  72. package/skills/manifest.d.ts +39 -0
  73. package/skills/manifest.js +40 -0
  74. package/skills/materialize.d.ts +13 -0
  75. package/skills/materialize.js +62 -0
  76. package/skills/overlay.d.ts +11 -0
  77. package/skills/overlay.js +28 -0
  78. package/skills/registry.d.ts +36 -0
  79. package/skills/registry.js +34 -0
  80. package/skills/source.d.ts +21 -0
  81. package/skills/source.js +88 -0
  82. package/skills/update-check.d.ts +36 -0
  83. package/skills/update-check.js +110 -0
  84. package/stash.d.ts +20 -0
  85. package/stash.js +55 -0
  86. package/types.d.ts +60 -0
  87. package/types.js +9 -0
@@ -0,0 +1,62 @@
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.materializeSkills = materializeSkills;
37
+ const fs = __importStar(require("fs"));
38
+ const path = __importStar(require("path"));
39
+ /**
40
+ * Write a resolved skill set to `<targetDir>/<skill-name>/…`, replacing any
41
+ * previous contents so removed skills do not linger.
42
+ */
43
+ function materializeSkills(targetDir, skills, options = {}) {
44
+ fs.rmSync(targetDir, { recursive: true, force: true });
45
+ fs.mkdirSync(targetDir, { recursive: true });
46
+ const written = [];
47
+ for (const skill of skills) {
48
+ const skillDir = path.join(targetDir, skill.name);
49
+ for (const file of skill.files) {
50
+ const dest = path.join(skillDir, file.relPath);
51
+ fs.mkdirSync(path.dirname(dest), { recursive: true });
52
+ fs.writeFileSync(dest, substitute(file.contents, options.templateVars));
53
+ }
54
+ written.push(skillDir);
55
+ }
56
+ return written;
57
+ }
58
+ function substitute(contents, vars) {
59
+ if (!vars)
60
+ return contents;
61
+ return contents.replace(/\{\{([A-Z0-9_]+)\}\}/g, (whole, key) => key in vars ? vars[key] : whole);
62
+ }
@@ -0,0 +1,11 @@
1
+ import { HarnessSkill } from '../types';
2
+ import { SkillsManifest } from './manifest';
3
+ import { SkillSource } from './source';
4
+ /**
5
+ * Resolve the effective skill set from ordered source layers.
6
+ *
7
+ * Sources are applied in manifest order; a later layer replaces an
8
+ * earlier layer's skill of the same name wholesale (all files), and may add
9
+ * new skills. Include/exclude filters apply per layer.
10
+ */
11
+ export declare function resolveSkills(manifest: SkillsManifest, sources: SkillSource[]): Promise<HarnessSkill[]>;
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.resolveSkills = resolveSkills;
4
+ const manifest_1 = require("./manifest");
5
+ /**
6
+ * Resolve the effective skill set from ordered source layers.
7
+ *
8
+ * Sources are applied in manifest order; a later layer replaces an
9
+ * earlier layer's skill of the same name wholesale (all files), and may add
10
+ * new skills. Include/exclude filters apply per layer.
11
+ */
12
+ async function resolveSkills(manifest, sources) {
13
+ (0, manifest_1.validateManifest)(manifest);
14
+ const byName = new Map(sources.map((s) => [s.name, s]));
15
+ const resolved = new Map();
16
+ for (const ref of manifest.sources) {
17
+ const source = byName.get(ref.name);
18
+ if (!source) {
19
+ throw new Error(`Manifest source ${ref.name} has no registered SkillSource`);
20
+ }
21
+ for (const skill of await source.load()) {
22
+ if (!(0, manifest_1.layerAllowsSkill)(ref, skill.name))
23
+ continue;
24
+ resolved.set(skill.name, skill);
25
+ }
26
+ }
27
+ return [...resolved.values()];
28
+ }
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Minimal npm registry client for skill releases. HTTP is injectable so
3
+ * hosts can add proxies/auth and tests can run offline.
4
+ */
5
+ export type FetchLike = (url: string, init?: {
6
+ headers?: Record<string, string>;
7
+ }) => Promise<{
8
+ ok: boolean;
9
+ status: number;
10
+ json(): Promise<unknown>;
11
+ arrayBuffer(): Promise<ArrayBuffer>;
12
+ }>;
13
+ export interface RegistryOptions {
14
+ registryUrl?: string;
15
+ fetchImpl?: FetchLike;
16
+ }
17
+ export interface PackumentVersion {
18
+ version: string;
19
+ dist: {
20
+ tarball: string;
21
+ integrity?: string;
22
+ shasum?: string;
23
+ };
24
+ }
25
+ export interface Packument {
26
+ name: string;
27
+ 'dist-tags': Record<string, string>;
28
+ versions: Record<string, PackumentVersion>;
29
+ }
30
+ export declare class RegistryClient {
31
+ private readonly registryUrl;
32
+ private readonly fetchImpl;
33
+ constructor(options?: RegistryOptions);
34
+ packument(pkg: string): Promise<Packument>;
35
+ tarball(url: string): Promise<Buffer>;
36
+ }
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ /**
3
+ * Minimal npm registry client for skill releases. HTTP is injectable so
4
+ * hosts can add proxies/auth and tests can run offline.
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.RegistryClient = void 0;
8
+ const DEFAULT_REGISTRY = 'https://registry.npmjs.org';
9
+ class RegistryClient {
10
+ registryUrl;
11
+ fetchImpl;
12
+ constructor(options = {}) {
13
+ this.registryUrl = (options.registryUrl ?? DEFAULT_REGISTRY).replace(/\/$/, '');
14
+ this.fetchImpl = options.fetchImpl ?? fetch;
15
+ }
16
+ async packument(pkg) {
17
+ const url = `${this.registryUrl}/${pkg.replace('/', '%2f')}`;
18
+ const res = await this.fetchImpl(url, {
19
+ headers: { accept: 'application/vnd.npm.install-v1+json' },
20
+ });
21
+ if (!res.ok) {
22
+ throw new Error(`Registry request failed for ${pkg}: HTTP ${res.status}`);
23
+ }
24
+ return (await res.json());
25
+ }
26
+ async tarball(url) {
27
+ const res = await this.fetchImpl(url);
28
+ if (!res.ok) {
29
+ throw new Error(`Tarball download failed: HTTP ${res.status} (${url})`);
30
+ }
31
+ return Buffer.from(await res.arrayBuffer());
32
+ }
33
+ }
34
+ exports.RegistryClient = RegistryClient;
@@ -0,0 +1,21 @@
1
+ import { HarnessSkill } from '../types';
2
+ /**
3
+ * A resolvable layer of skills. Implementations: local directory (vendored
4
+ * snapshot, git checkout, unpacked npm release). Network fetchers resolve a
5
+ * release into a local directory and hand it to `DirectorySkillSource`.
6
+ */
7
+ export interface SkillSource {
8
+ name: string;
9
+ load(): Promise<HarnessSkill[]>;
10
+ }
11
+ /**
12
+ * Loads skills from a directory of `<skill-name>/SKILL.md` folders — the
13
+ * agentskills.io layout used by `constructive-skills` (`.agents/skills/`) and
14
+ * by unpacked release tarballs.
15
+ */
16
+ export declare class DirectorySkillSource implements SkillSource {
17
+ readonly name: string;
18
+ private readonly dir;
19
+ constructor(name: string, dir: string);
20
+ load(): Promise<HarnessSkill[]>;
21
+ }
@@ -0,0 +1,88 @@
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.DirectorySkillSource = void 0;
37
+ const fs = __importStar(require("fs"));
38
+ const path = __importStar(require("path"));
39
+ const frontmatter_1 = require("./frontmatter");
40
+ /**
41
+ * Loads skills from a directory of `<skill-name>/SKILL.md` folders — the
42
+ * agentskills.io layout used by `constructive-skills` (`.agents/skills/`) and
43
+ * by unpacked release tarballs.
44
+ */
45
+ class DirectorySkillSource {
46
+ name;
47
+ dir;
48
+ constructor(name, dir) {
49
+ this.name = name;
50
+ this.dir = dir;
51
+ }
52
+ async load() {
53
+ if (!fs.existsSync(this.dir)) {
54
+ throw new Error(`Skill source directory not found: ${this.dir}`);
55
+ }
56
+ const skills = [];
57
+ for (const entry of fs.readdirSync(this.dir, { withFileTypes: true })) {
58
+ if (!entry.isDirectory())
59
+ continue;
60
+ const skillDir = path.join(this.dir, entry.name);
61
+ const skillMd = path.join(skillDir, 'SKILL.md');
62
+ if (!fs.existsSync(skillMd))
63
+ continue;
64
+ const raw = fs.readFileSync(skillMd, 'utf8');
65
+ const { name, description } = (0, frontmatter_1.parseFrontmatter)(raw);
66
+ const files = [{ relPath: 'SKILL.md', contents: raw }];
67
+ collectExtraFiles(skillDir, '', files);
68
+ skills.push({ name, description, files, sourceName: this.name });
69
+ }
70
+ return skills;
71
+ }
72
+ }
73
+ exports.DirectorySkillSource = DirectorySkillSource;
74
+ function collectExtraFiles(root, rel, out) {
75
+ const dir = path.join(root, rel);
76
+ for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
77
+ const entryRel = rel ? path.join(rel, entry.name) : entry.name;
78
+ if (entry.isDirectory()) {
79
+ collectExtraFiles(root, entryRel, out);
80
+ }
81
+ else if (entry.isFile() && entryRel !== 'SKILL.md') {
82
+ out.push({
83
+ relPath: entryRel,
84
+ contents: fs.readFileSync(path.join(root, entryRel), 'utf8'),
85
+ });
86
+ }
87
+ }
88
+ }
@@ -0,0 +1,36 @@
1
+ import { RegistryOptions } from './registry';
2
+ export interface UpdateCheckOptions extends RegistryOptions {
3
+ pkg: string;
4
+ /** Version currently in use. */
5
+ currentVersion: string;
6
+ /**
7
+ * Semver range the installed harness supports (`compatibleSkillsRange`).
8
+ * Newer releases outside this range are reported but never recommended.
9
+ */
10
+ compatibleRange?: string;
11
+ /** Cache file (e.g. `harnessDirs().updateCheckFile`). */
12
+ cacheFile: string;
13
+ /** Re-query the registry only after this long (default 24h). */
14
+ ttlMs?: number;
15
+ now?: () => number;
16
+ }
17
+ export interface UpdateCheckResult {
18
+ checkedAt: number;
19
+ /** True when this result came from the cache file, not the registry. */
20
+ fromCache: boolean;
21
+ currentVersion: string;
22
+ /** Newest published version overall. */
23
+ latestVersion: string;
24
+ /** Newest version inside compatibleRange — the one an updater may adopt. */
25
+ latestCompatible: string | null;
26
+ /** True when latestCompatible is newer than currentVersion. */
27
+ updateAvailable: boolean;
28
+ /** True when a newer release exists but only outside compatibleRange. */
29
+ harnessUpgradeRequired: boolean;
30
+ }
31
+ /**
32
+ * Check the registry for newer skill releases, caching results on disk so
33
+ * repeated sessions don't hit the network. Registry failures fall back to the
34
+ * cached result (stale ok) or report "no update" — never throw.
35
+ */
36
+ export declare function checkForSkillsUpdate(options: UpdateCheckOptions): Promise<UpdateCheckResult>;
@@ -0,0 +1,110 @@
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.checkForSkillsUpdate = checkForSkillsUpdate;
37
+ const fs = __importStar(require("fs"));
38
+ const path = __importStar(require("path"));
39
+ const semver = __importStar(require("semver"));
40
+ const registry_1 = require("./registry");
41
+ const DEFAULT_TTL_MS = 24 * 60 * 60 * 1000;
42
+ /**
43
+ * Check the registry for newer skill releases, caching results on disk so
44
+ * repeated sessions don't hit the network. Registry failures fall back to the
45
+ * cached result (stale ok) or report "no update" — never throw.
46
+ */
47
+ async function checkForSkillsUpdate(options) {
48
+ const now = options.now ?? Date.now;
49
+ const ttl = options.ttlMs ?? DEFAULT_TTL_MS;
50
+ const cached = readCache(options.cacheFile);
51
+ if (cached && cached.currentVersion === options.currentVersion && now() - cached.checkedAt < ttl) {
52
+ return { ...cached, fromCache: true };
53
+ }
54
+ let versions;
55
+ try {
56
+ const packument = await new registry_1.RegistryClient(options).packument(options.pkg);
57
+ versions = Object.keys(packument.versions).filter((v) => semver.valid(v));
58
+ }
59
+ catch {
60
+ if (cached)
61
+ return { ...cached, fromCache: true };
62
+ return noUpdate(options.currentVersion, now());
63
+ }
64
+ if (versions.length === 0)
65
+ return noUpdate(options.currentVersion, now());
66
+ const latestVersion = versions.sort(semver.rcompare)[0];
67
+ const latestCompatible = options.compatibleRange
68
+ ? semver.maxSatisfying(versions, options.compatibleRange)
69
+ : latestVersion;
70
+ const result = {
71
+ checkedAt: now(),
72
+ fromCache: false,
73
+ currentVersion: options.currentVersion,
74
+ latestVersion,
75
+ latestCompatible,
76
+ updateAvailable: latestCompatible !== null && semver.gt(latestCompatible, options.currentVersion),
77
+ harnessUpgradeRequired: semver.gt(latestVersion, options.currentVersion) &&
78
+ (latestCompatible === null || semver.gt(latestVersion, latestCompatible)),
79
+ };
80
+ writeCache(options.cacheFile, result);
81
+ return result;
82
+ }
83
+ function noUpdate(currentVersion, checkedAt) {
84
+ return {
85
+ checkedAt,
86
+ fromCache: false,
87
+ currentVersion,
88
+ latestVersion: currentVersion,
89
+ latestCompatible: currentVersion,
90
+ updateAvailable: false,
91
+ harnessUpgradeRequired: false,
92
+ };
93
+ }
94
+ function readCache(cacheFile) {
95
+ try {
96
+ return JSON.parse(fs.readFileSync(cacheFile, 'utf8'));
97
+ }
98
+ catch {
99
+ return null;
100
+ }
101
+ }
102
+ function writeCache(cacheFile, result) {
103
+ try {
104
+ fs.mkdirSync(path.dirname(cacheFile), { recursive: true });
105
+ fs.writeFileSync(cacheFile, JSON.stringify(result, null, 2));
106
+ }
107
+ catch {
108
+ // Cache write failures are non-fatal.
109
+ }
110
+ }
package/stash.d.ts ADDED
@@ -0,0 +1,20 @@
1
+ import { AppStashResult } from 'appstash';
2
+ export interface HarnessDirs {
3
+ /** appstash root layout for the tool (config/cache/data/logs/tmp). */
4
+ stash: AppStashResult;
5
+ /** Root for downloaded skill releases: `<data>/skills`. */
6
+ skillsRoot: string;
7
+ /** Directory for one resolved skills release: `<data>/skills/<version>`. */
8
+ skillsVersionDir(version: string): string;
9
+ /** Materialized (merged) skill tree consumed by the agent session. */
10
+ materializedDir: string;
11
+ /** Cached update-check metadata: `<cache>/skills-update-check.json`. */
12
+ updateCheckFile: string;
13
+ }
14
+ /**
15
+ * Resolve the harness's on-disk layout via appstash.
16
+ *
17
+ * Defaults to `~/.constructive/…` with XDG/tmp fallbacks; hosts that need an
18
+ * app-specific root (e.g. Electron userData) can pass `baseDir`.
19
+ */
20
+ export declare function harnessDirs(tool?: string, baseDir?: string): HarnessDirs;
package/stash.js ADDED
@@ -0,0 +1,55 @@
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.harnessDirs = harnessDirs;
37
+ const path = __importStar(require("path"));
38
+ const appstash_1 = require("appstash");
39
+ /**
40
+ * Resolve the harness's on-disk layout via appstash.
41
+ *
42
+ * Defaults to `~/.constructive/…` with XDG/tmp fallbacks; hosts that need an
43
+ * app-specific root (e.g. Electron userData) can pass `baseDir`.
44
+ */
45
+ function harnessDirs(tool = 'constructive', baseDir) {
46
+ const stash = (0, appstash_1.appstash)(tool, { ensure: true, baseDir });
47
+ const skillsRoot = path.join(stash.data, 'skills');
48
+ return {
49
+ stash,
50
+ skillsRoot,
51
+ skillsVersionDir: (version) => path.join(skillsRoot, version),
52
+ materializedDir: path.join(stash.cache, 'skills-materialized'),
53
+ updateCheckFile: path.join(stash.cache, 'skills-update-check.json'),
54
+ };
55
+ }
package/types.d.ts ADDED
@@ -0,0 +1,60 @@
1
+ /**
2
+ * Host-neutral contracts for the Constructive harness.
3
+ *
4
+ * A harness host (Electron desktop, terminal CLI, MCP server) supplies a
5
+ * `HarnessContext`; the harness core supplies skills, tools, and policies
6
+ * built against these interfaces without knowing anything about the host.
7
+ */
8
+ /** A single file belonging to a skill (SKILL.md plus optional references/scripts). */
9
+ export interface SkillFile {
10
+ /** Path relative to the skill directory, e.g. `SKILL.md` or `references/topic.md`. */
11
+ relPath: string;
12
+ contents: string;
13
+ }
14
+ /** A resolved skill: parsed identity plus every file it ships. */
15
+ export interface HarnessSkill {
16
+ name: string;
17
+ description: string;
18
+ files: SkillFile[];
19
+ /** Name of the manifest source layer this skill was resolved from. */
20
+ sourceName: string;
21
+ }
22
+ /** Result of a data-plane token request for a provisioned database. */
23
+ export interface DataTokenResult {
24
+ token: string | null;
25
+ /** Where the token came from (host-specific, e.g. `env`, `broker`, `preview`). */
26
+ origin?: string;
27
+ }
28
+ /** Credential access the host must provide; the core never reads secrets itself. */
29
+ export interface HarnessCredentials {
30
+ /** Control-plane (account) bearer token, or null when signed out. */
31
+ accountBearer(): Promise<string | null>;
32
+ /** Data-plane token for a specific provisioned database. */
33
+ dataToken(databaseId: string): Promise<DataTokenResult>;
34
+ }
35
+ /** Backend endpoint configuration pinned by the host / project binding. */
36
+ export interface HarnessEndpoints {
37
+ /** Platform GraphQL endpoint, e.g. `http://api.localhost:3000/graphql`. */
38
+ apiEndpoint: string;
39
+ /** Modules control-plane endpoint used by provisioning. */
40
+ modulesEndpoint: string;
41
+ }
42
+ /** A confirmation request for a mutating/gated tool call. */
43
+ export interface GateRequest {
44
+ toolName: string;
45
+ title: string;
46
+ detail?: string;
47
+ args?: Record<string, unknown>;
48
+ }
49
+ /**
50
+ * Everything a harness host injects. Mirrors the injection points identified
51
+ * in the desktop extraction (credentials, endpoints, confirm gate, project cwd).
52
+ */
53
+ export interface HarnessContext {
54
+ /** Project working directory (where `.constructive/` and `.env` live). */
55
+ cwd: string;
56
+ endpoints: HarnessEndpoints;
57
+ credentials: HarnessCredentials;
58
+ /** Ask the user to confirm a gated tool call. Resolve false to decline. */
59
+ confirm(request: GateRequest): Promise<boolean>;
60
+ }
package/types.js ADDED
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ /**
3
+ * Host-neutral contracts for the Constructive harness.
4
+ *
5
+ * A harness host (Electron desktop, terminal CLI, MCP server) supplies a
6
+ * `HarnessContext`; the harness core supplies skills, tools, and policies
7
+ * built against these interfaces without knowing anything about the host.
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });