@dot-agent/compiler 0.12.0-alpha.0 → 0.12.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/dist/core.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_namespace = require("./namespace-BbxHHnOo.cjs");
2
+ const require_namespace = require("./namespace-BzCp94X1.cjs");
3
3
  exports.CONTENT_NAMESPACES = require_namespace.CONTENT_NAMESPACES;
4
4
  exports.aboutmeToJson = require_namespace.aboutmeToJson;
5
5
  exports.buildAboutme = require_namespace.buildAboutme;
package/dist/core.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import { a as extractFiles, c as buildId, f as parseId, g as parseAboutme, h as buildAboutme, i as createZip, l as extractDigest, m as aboutmeToJson, n as classifyContentPath, o as validateMagicBytes, r as isInContentNamespace, s as validateZipBomb, t as CONTENT_NAMESPACES, u as extractName } from "./namespace-B8prujsD.mjs";
1
+ import { a as extractFiles, c as buildId, f as parseId, g as parseAboutme, h as buildAboutme, i as createZip, l as extractDigest, m as aboutmeToJson, n as classifyContentPath, o as validateMagicBytes, r as isInContentNamespace, s as validateZipBomb, t as CONTENT_NAMESPACES, u as extractName } from "./namespace-C2uz0fGN.mjs";
2
2
  export { CONTENT_NAMESPACES, aboutmeToJson, buildAboutme, buildId, classifyContentPath, createZip, extractDigest, extractFiles, extractName, isInContentNamespace, parseAboutme, parseId, validateMagicBytes, validateZipBomb };
package/dist/index.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_namespace = require("./namespace-BbxHHnOo.cjs");
2
+ const require_namespace = require("./namespace-BzCp94X1.cjs");
3
3
  let module$1 = require("module");
4
4
  let web_tree_sitter = require("web-tree-sitter");
5
5
  let _dot_agent_parser_dsl = require("@dot-agent/parser-dsl");
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { _ as COMPILER_VERSION, a as extractFiles, c as buildId, d as isValidVersion, f as parseId, g as parseAboutme, h as buildAboutme, i as createZip, l as extractDigest, m as aboutmeToJson, n as classifyContentPath, o as validateMagicBytes$1, p as slugify, r as isInContentNamespace, s as validateZipBomb$1, t as CONTENT_NAMESPACES, u as extractName } from "./namespace-B8prujsD.mjs";
1
+ import { _ as COMPILER_VERSION, a as extractFiles, c as buildId, d as isValidVersion, f as parseId, g as parseAboutme, h as buildAboutme, i as createZip, l as extractDigest, m as aboutmeToJson, n as classifyContentPath, o as validateMagicBytes$1, p as slugify, r as isInContentNamespace, s as validateZipBomb$1, t as CONTENT_NAMESPACES, u as extractName } from "./namespace-C2uz0fGN.mjs";
2
2
  import { createRequire } from "module";
3
3
  import { Language, Parser } from "web-tree-sitter";
4
4
  import { get_graph, init, parse_behavior, parse_description } from "@dot-agent/parser-dsl";
@@ -23,7 +23,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
23
23
  let jszip = require("jszip");
24
24
  jszip = __toESM(jszip, 1);
25
25
  //#region src/generated-version.ts
26
- const COMPILER_VERSION = "0.12.0-alpha.0";
26
+ const COMPILER_VERSION = "0.12.0";
27
27
  //#endregion
28
28
  //#region src/manifest.ts
29
29
  function parseAboutme(json) {
@@ -316,4 +316,4 @@ Object.defineProperty(exports, "validateZipBomb", {
316
316
  }
317
317
  });
318
318
 
319
- //# sourceMappingURL=namespace-BbxHHnOo.cjs.map
319
+ //# sourceMappingURL=namespace-BzCp94X1.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"namespace-BzCp94X1.cjs","names":["JSZip"],"sources":["../src/generated-version.ts","../src/manifest.ts","../src/id.ts","../src/zip-core.ts","../src/namespace.ts"],"sourcesContent":["// Generated by scripts/embed-version.mjs from dsl/VERSION and package.json — do not edit by hand.\nexport const DSL_VERSION = '0.1'\nexport const COMPILER_VERSION = '0.12.0'\n","// SPDX-License-Identifier: Apache-2.0\n\nimport type { AboutMe, BuildAboutmeOptions } from './types.js'\nimport { DSL_VERSION } from './generated-version.js'\n\nexport function parseAboutme(json: any): AboutMe {\n if (!json.dslVersion) throw new Error('Missing dslVersion in aboutme.json')\n if (!json.id) throw new Error('Missing id in aboutme.json')\n if (!json.name) throw new Error('Missing name in aboutme.json')\n if (!json.description) throw new Error('Missing description in aboutme.json')\n if (!json.domain) throw new Error('Missing domain in aboutme.json')\n if (!json.compiler) throw new Error('Missing compiler in aboutme.json')\n if (!Array.isArray(json.capabilities)) throw new Error('Missing capabilities array in aboutme.json')\n if (!Array.isArray(json.requires)) throw new Error('Missing requires array in aboutme.json')\n if (!json.integrity) throw new Error('Missing integrity in aboutme.json')\n\n return {\n dslVersion: json.dslVersion,\n id: json.id,\n name: json.name,\n description: json.description,\n version: json.version ?? '',\n domain: json.domain,\n license: json.license ?? '',\n persona: json.persona,\n purpose: json.purpose ?? 'unknown',\n compiler: json.compiler,\n commit: json.commit,\n capabilities: json.capabilities,\n requires: json.requires,\n integrity: json.integrity,\n }\n}\n\nexport function buildAboutme(opts: BuildAboutmeOptions): AboutMe {\n return {\n dslVersion: `dot-agent/${DSL_VERSION}`,\n id: opts.id,\n name: opts.name,\n description: opts.description,\n version: opts.version,\n domain: opts.domain,\n license: opts.license ?? '',\n persona: opts.persona,\n purpose: opts.purpose ?? 'unknown',\n compiler: opts.compiler,\n commit: opts.commit,\n capabilities: opts.capabilities ?? [],\n requires: opts.requires ?? [],\n integrity: opts.integrity,\n }\n}\n\nexport function aboutmeToJson(aboutme: AboutMe): string {\n return JSON.stringify(aboutme, null, 2)\n}\n","// SPDX-License-Identifier: Apache-2.0\n\nimport type { IdParts } from './types.js'\n\n// Code hosting platforms whose namespace format is platform/user rather than plain domain.\n// The list is maintained by the compiler and updated via CLI releases.\nexport const KNOWN_PLATFORMS = ['github.com', 'gitlab.com', 'codeberg.org', 'sr.ht'] as const\n\nfunction parseNamespaceName(identifier: string): { namespace: string; name: string } {\n // Email namespace: @ appears before any /\n const atIdx = identifier.indexOf('@')\n if (atIdx !== -1 && (identifier.indexOf('/') === -1 || atIdx < identifier.indexOf('/'))) {\n const slashIdx = identifier.indexOf('/')\n if (slashIdx === -1) {\n throw new Error(`Invalid agent ID: email namespace requires a name after '/' (got '${identifier}')`)\n }\n return {\n namespace: identifier.slice(0, slashIdx),\n name: identifier.slice(slashIdx + 1),\n }\n }\n\n // Known code-hosting platforms: namespace is platform/user, name is the next segment.\n for (const platform of KNOWN_PLATFORMS) {\n if (identifier.startsWith(platform + '/')) {\n const afterPlatform = identifier.slice(platform.length + 1)\n const slashIdx = afterPlatform.indexOf('/')\n if (slashIdx === -1) {\n throw new Error(\n `Invalid agent ID: '${platform}' namespace requires a user segment and a name (got '${identifier}')`,\n )\n }\n return {\n namespace: platform + '/' + afterPlatform.slice(0, slashIdx),\n name: afterPlatform.slice(slashIdx + 1),\n }\n }\n }\n\n // Domain or reserved keyword (e.g. 'unknown'): last '/' separates namespace from name.\n const lastSlash = identifier.lastIndexOf('/')\n if (lastSlash === -1) {\n throw new Error(`Invalid agent ID: missing '/' separator in '${identifier}'`)\n }\n return {\n namespace: identifier.slice(0, lastSlash),\n name: identifier.slice(lastSlash + 1),\n }\n}\n\nexport function parseId(id: string): IdParts {\n if (!id) throw new Error('Invalid agent ID: empty string')\n\n // Phase 1: split on the first ':' to isolate the identifier from version~digest.\n const colonIdx = id.indexOf(':')\n\n let identifier: string\n let version: string | undefined\n let digest: string | undefined\n\n if (colonIdx === -1) {\n // Form A: namespace/name\n identifier = id\n } else {\n identifier = id.slice(0, colonIdx)\n const rest = id.slice(colonIdx + 1)\n if (!rest) throw new Error(`Invalid agent ID: empty version after ':' in '${id}'`)\n\n // Phase 2: split version~digest\n const tildeIdx = rest.indexOf('~')\n if (tildeIdx === -1) {\n // Form B: namespace/name:version\n version = rest\n } else {\n // Form D: namespace/name:version~digest\n version = rest.slice(0, tildeIdx)\n digest = rest.slice(tildeIdx + 1)\n if (!version) throw new Error(`Invalid agent ID: empty version before '~' in '${id}'`)\n if (!digest) throw new Error(`Invalid agent ID: empty digest after '~' in '${id}'`)\n }\n }\n\n // Phase 3: extract namespace and name from the identifier\n const { namespace, name } = parseNamespaceName(identifier)\n\n if (!namespace) throw new Error(`Invalid agent ID: empty namespace in '${id}'`)\n if (!name) throw new Error(`Invalid agent ID: empty name in '${id}'`)\n\n return { namespace, name, version, digest }\n}\n\nexport function buildId(parts: IdParts): string {\n const { namespace, name, version, digest } = parts\n if (!namespace || !name) {\n throw new Error('Missing required ID parts: namespace and name')\n }\n if (digest && !version) {\n throw new Error('Invalid ID parts: digest requires version')\n }\n let result = `${namespace}/${name}`\n if (version) {\n result += `:${version}`\n if (digest) result += `~${digest}`\n }\n // Ids are always lowercase — domains, platform usernames (GitHub/GitLab/\n // Codeberg/Sourcehut) and email local-parts are all case-insensitive in\n // practice, so normalizing here is safe and gives every id a single shape.\n return result.toLowerCase()\n}\n\n// Turns a human display name (e.g. \"Fridge Assistant\", from `agent Fridge\n// Assistant` in the DSL — spaces/capitalization are deliberate there) into\n// the kebab-case slug used for an id's name segment.\nexport function slugify(name: string): string {\n return name\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, '-')\n .replace(/^-+|-+$/g, '')\n}\n\n// Accepts optional leading 'v' (id spec examples use it; monorepo tags after\n// their '@' split don't), 1-3 dot-separated numeric groups, and optional\n// -prerelease / +build suffixes — e.g. v1.0, 2.3.1, v1.0.0-alpha.1, 1.0+build.\nconst VERSION_RE = /^v?\\d+(\\.\\d+){0,2}(-[0-9A-Za-z.]+)?(\\+[0-9A-Za-z.]+)?$/i\n\nexport function isValidVersion(version: string): boolean {\n return VERSION_RE.test(version)\n}\n\nexport function extractDigest(id: string): string {\n try {\n return parseId(id).digest ?? ''\n } catch {\n return ''\n }\n}\n\nexport function extractName(id: string): string {\n try {\n return parseId(id).name\n } catch {\n return ''\n }\n}\n","// SPDX-License-Identifier: Apache-2.0\n\nimport JSZip from 'jszip'\n\nexport const MAX_ZIP_SIZE = 500 * 1024 * 1024\nexport const MAX_COMPRESSION_RATIO = 100\n\nexport function validateMagicBytes(bytes: Uint8Array): void {\n if (!(bytes[0] === 0x50 && bytes[1] === 0x4b && bytes[2] === 0x03 && bytes[3] === 0x04)) {\n throw new Error('Not a valid .agent file (invalid magic bytes)')\n }\n}\n\nexport function validateZipBomb(zip: JSZip, compressedSize: number): void {\n let totalUncompressed = 0\n zip.forEach((_path, file) => {\n if (!file.dir) totalUncompressed += (file as any)._data?.uncompressedSize || 0\n })\n if (totalUncompressed > MAX_ZIP_SIZE) {\n throw new Error(`Bundle exceeds 500MB uncompressed: ${totalUncompressed}`)\n }\n if (totalUncompressed / compressedSize > MAX_COMPRESSION_RATIO) {\n throw new Error(`Compression ratio exceeds 100x: ${(totalUncompressed / compressedSize).toFixed(1)}x`)\n }\n}\n\nexport function createZip(): JSZip {\n return new JSZip()\n}\n\nexport async function extractFiles(zip: JSZip, filter?: string[]): Promise<Map<string, string>> {\n const files = new Map<string, string>()\n const promises: Promise<void>[] = []\n\n zip.forEach((relativePath, file) => {\n if (file.dir) return\n if (filter && !filter.some(f => relativePath.startsWith(f))) return\n promises.push(\n file.async('text').then(content => {\n files.set(relativePath, content)\n })\n )\n })\n\n await Promise.all(promises)\n return files\n}\n","// SPDX-License-Identifier: Apache-2.0\n\n// The two directories the runtime can actually serve content from: pack.ts's\n// collectFiles() bundles a guide/teach reference at its literal path, but\n// bundle.ts, sdk/load.ts, and the CLI's MCP resource handlers each classify a\n// bundled file into guides/knowledge purely by this prefix — a reference\n// resolving outside them is refused at pack time (see pack.ts's E022) rather\n// than bundled unreachable.\n// Single source of truth so the three sites can't drift on the prefix list.\nexport const CONTENT_NAMESPACES = ['guides', 'knowledge'] as const\nexport type ContentNamespace = (typeof CONTENT_NAMESPACES)[number]\n\nexport function isInContentNamespace(bundlePath: string): boolean {\n return classifyContentPath(bundlePath) !== null\n}\n\nexport function classifyContentPath(bundlePath: string): ContentNamespace | null {\n return CONTENT_NAMESPACES.find(ns => bundlePath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,oBAAoB,UAAU,MAAM;AAC7C;AAEA,SAAgB,oBAAoB,YAA6C;CAC/E,OAAO,mBAAmB,MAAK,OAAM,WAAW,WAAW,GAAG,GAAG,EAAE,CAAC,KAAK;AAC3E"}
@@ -1,6 +1,6 @@
1
1
  import JSZip from "jszip";
2
2
  //#region src/generated-version.ts
3
- const COMPILER_VERSION = "0.12.0-alpha.0";
3
+ const COMPILER_VERSION = "0.12.0";
4
4
  //#endregion
5
5
  //#region src/manifest.ts
6
6
  function parseAboutme(json) {
@@ -186,4 +186,4 @@ function classifyContentPath(bundlePath) {
186
186
  //#endregion
187
187
  export { COMPILER_VERSION as _, extractFiles as a, buildId as c, isValidVersion as d, parseId as f, parseAboutme as g, buildAboutme as h, createZip as i, extractDigest as l, aboutmeToJson as m, classifyContentPath as n, validateMagicBytes as o, slugify as p, isInContentNamespace as r, validateZipBomb as s, CONTENT_NAMESPACES as t, extractName as u };
188
188
 
189
- //# sourceMappingURL=namespace-B8prujsD.mjs.map
189
+ //# sourceMappingURL=namespace-C2uz0fGN.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"namespace-C2uz0fGN.mjs","names":[],"sources":["../src/generated-version.ts","../src/manifest.ts","../src/id.ts","../src/zip-core.ts","../src/namespace.ts"],"sourcesContent":["// Generated by scripts/embed-version.mjs from dsl/VERSION and package.json — do not edit by hand.\nexport const DSL_VERSION = '0.1'\nexport const COMPILER_VERSION = '0.12.0'\n","// SPDX-License-Identifier: Apache-2.0\n\nimport type { AboutMe, BuildAboutmeOptions } from './types.js'\nimport { DSL_VERSION } from './generated-version.js'\n\nexport function parseAboutme(json: any): AboutMe {\n if (!json.dslVersion) throw new Error('Missing dslVersion in aboutme.json')\n if (!json.id) throw new Error('Missing id in aboutme.json')\n if (!json.name) throw new Error('Missing name in aboutme.json')\n if (!json.description) throw new Error('Missing description in aboutme.json')\n if (!json.domain) throw new Error('Missing domain in aboutme.json')\n if (!json.compiler) throw new Error('Missing compiler in aboutme.json')\n if (!Array.isArray(json.capabilities)) throw new Error('Missing capabilities array in aboutme.json')\n if (!Array.isArray(json.requires)) throw new Error('Missing requires array in aboutme.json')\n if (!json.integrity) throw new Error('Missing integrity in aboutme.json')\n\n return {\n dslVersion: json.dslVersion,\n id: json.id,\n name: json.name,\n description: json.description,\n version: json.version ?? '',\n domain: json.domain,\n license: json.license ?? '',\n persona: json.persona,\n purpose: json.purpose ?? 'unknown',\n compiler: json.compiler,\n commit: json.commit,\n capabilities: json.capabilities,\n requires: json.requires,\n integrity: json.integrity,\n }\n}\n\nexport function buildAboutme(opts: BuildAboutmeOptions): AboutMe {\n return {\n dslVersion: `dot-agent/${DSL_VERSION}`,\n id: opts.id,\n name: opts.name,\n description: opts.description,\n version: opts.version,\n domain: opts.domain,\n license: opts.license ?? '',\n persona: opts.persona,\n purpose: opts.purpose ?? 'unknown',\n compiler: opts.compiler,\n commit: opts.commit,\n capabilities: opts.capabilities ?? [],\n requires: opts.requires ?? [],\n integrity: opts.integrity,\n }\n}\n\nexport function aboutmeToJson(aboutme: AboutMe): string {\n return JSON.stringify(aboutme, null, 2)\n}\n","// SPDX-License-Identifier: Apache-2.0\n\nimport type { IdParts } from './types.js'\n\n// Code hosting platforms whose namespace format is platform/user rather than plain domain.\n// The list is maintained by the compiler and updated via CLI releases.\nexport const KNOWN_PLATFORMS = ['github.com', 'gitlab.com', 'codeberg.org', 'sr.ht'] as const\n\nfunction parseNamespaceName(identifier: string): { namespace: string; name: string } {\n // Email namespace: @ appears before any /\n const atIdx = identifier.indexOf('@')\n if (atIdx !== -1 && (identifier.indexOf('/') === -1 || atIdx < identifier.indexOf('/'))) {\n const slashIdx = identifier.indexOf('/')\n if (slashIdx === -1) {\n throw new Error(`Invalid agent ID: email namespace requires a name after '/' (got '${identifier}')`)\n }\n return {\n namespace: identifier.slice(0, slashIdx),\n name: identifier.slice(slashIdx + 1),\n }\n }\n\n // Known code-hosting platforms: namespace is platform/user, name is the next segment.\n for (const platform of KNOWN_PLATFORMS) {\n if (identifier.startsWith(platform + '/')) {\n const afterPlatform = identifier.slice(platform.length + 1)\n const slashIdx = afterPlatform.indexOf('/')\n if (slashIdx === -1) {\n throw new Error(\n `Invalid agent ID: '${platform}' namespace requires a user segment and a name (got '${identifier}')`,\n )\n }\n return {\n namespace: platform + '/' + afterPlatform.slice(0, slashIdx),\n name: afterPlatform.slice(slashIdx + 1),\n }\n }\n }\n\n // Domain or reserved keyword (e.g. 'unknown'): last '/' separates namespace from name.\n const lastSlash = identifier.lastIndexOf('/')\n if (lastSlash === -1) {\n throw new Error(`Invalid agent ID: missing '/' separator in '${identifier}'`)\n }\n return {\n namespace: identifier.slice(0, lastSlash),\n name: identifier.slice(lastSlash + 1),\n }\n}\n\nexport function parseId(id: string): IdParts {\n if (!id) throw new Error('Invalid agent ID: empty string')\n\n // Phase 1: split on the first ':' to isolate the identifier from version~digest.\n const colonIdx = id.indexOf(':')\n\n let identifier: string\n let version: string | undefined\n let digest: string | undefined\n\n if (colonIdx === -1) {\n // Form A: namespace/name\n identifier = id\n } else {\n identifier = id.slice(0, colonIdx)\n const rest = id.slice(colonIdx + 1)\n if (!rest) throw new Error(`Invalid agent ID: empty version after ':' in '${id}'`)\n\n // Phase 2: split version~digest\n const tildeIdx = rest.indexOf('~')\n if (tildeIdx === -1) {\n // Form B: namespace/name:version\n version = rest\n } else {\n // Form D: namespace/name:version~digest\n version = rest.slice(0, tildeIdx)\n digest = rest.slice(tildeIdx + 1)\n if (!version) throw new Error(`Invalid agent ID: empty version before '~' in '${id}'`)\n if (!digest) throw new Error(`Invalid agent ID: empty digest after '~' in '${id}'`)\n }\n }\n\n // Phase 3: extract namespace and name from the identifier\n const { namespace, name } = parseNamespaceName(identifier)\n\n if (!namespace) throw new Error(`Invalid agent ID: empty namespace in '${id}'`)\n if (!name) throw new Error(`Invalid agent ID: empty name in '${id}'`)\n\n return { namespace, name, version, digest }\n}\n\nexport function buildId(parts: IdParts): string {\n const { namespace, name, version, digest } = parts\n if (!namespace || !name) {\n throw new Error('Missing required ID parts: namespace and name')\n }\n if (digest && !version) {\n throw new Error('Invalid ID parts: digest requires version')\n }\n let result = `${namespace}/${name}`\n if (version) {\n result += `:${version}`\n if (digest) result += `~${digest}`\n }\n // Ids are always lowercase — domains, platform usernames (GitHub/GitLab/\n // Codeberg/Sourcehut) and email local-parts are all case-insensitive in\n // practice, so normalizing here is safe and gives every id a single shape.\n return result.toLowerCase()\n}\n\n// Turns a human display name (e.g. \"Fridge Assistant\", from `agent Fridge\n// Assistant` in the DSL — spaces/capitalization are deliberate there) into\n// the kebab-case slug used for an id's name segment.\nexport function slugify(name: string): string {\n return name\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, '-')\n .replace(/^-+|-+$/g, '')\n}\n\n// Accepts optional leading 'v' (id spec examples use it; monorepo tags after\n// their '@' split don't), 1-3 dot-separated numeric groups, and optional\n// -prerelease / +build suffixes — e.g. v1.0, 2.3.1, v1.0.0-alpha.1, 1.0+build.\nconst VERSION_RE = /^v?\\d+(\\.\\d+){0,2}(-[0-9A-Za-z.]+)?(\\+[0-9A-Za-z.]+)?$/i\n\nexport function isValidVersion(version: string): boolean {\n return VERSION_RE.test(version)\n}\n\nexport function extractDigest(id: string): string {\n try {\n return parseId(id).digest ?? ''\n } catch {\n return ''\n }\n}\n\nexport function extractName(id: string): string {\n try {\n return parseId(id).name\n } catch {\n return ''\n }\n}\n","// SPDX-License-Identifier: Apache-2.0\n\nimport JSZip from 'jszip'\n\nexport const MAX_ZIP_SIZE = 500 * 1024 * 1024\nexport const MAX_COMPRESSION_RATIO = 100\n\nexport function validateMagicBytes(bytes: Uint8Array): void {\n if (!(bytes[0] === 0x50 && bytes[1] === 0x4b && bytes[2] === 0x03 && bytes[3] === 0x04)) {\n throw new Error('Not a valid .agent file (invalid magic bytes)')\n }\n}\n\nexport function validateZipBomb(zip: JSZip, compressedSize: number): void {\n let totalUncompressed = 0\n zip.forEach((_path, file) => {\n if (!file.dir) totalUncompressed += (file as any)._data?.uncompressedSize || 0\n })\n if (totalUncompressed > MAX_ZIP_SIZE) {\n throw new Error(`Bundle exceeds 500MB uncompressed: ${totalUncompressed}`)\n }\n if (totalUncompressed / compressedSize > MAX_COMPRESSION_RATIO) {\n throw new Error(`Compression ratio exceeds 100x: ${(totalUncompressed / compressedSize).toFixed(1)}x`)\n }\n}\n\nexport function createZip(): JSZip {\n return new JSZip()\n}\n\nexport async function extractFiles(zip: JSZip, filter?: string[]): Promise<Map<string, string>> {\n const files = new Map<string, string>()\n const promises: Promise<void>[] = []\n\n zip.forEach((relativePath, file) => {\n if (file.dir) return\n if (filter && !filter.some(f => relativePath.startsWith(f))) return\n promises.push(\n file.async('text').then(content => {\n files.set(relativePath, content)\n })\n )\n })\n\n await Promise.all(promises)\n return files\n}\n","// SPDX-License-Identifier: Apache-2.0\n\n// The two directories the runtime can actually serve content from: pack.ts's\n// collectFiles() bundles a guide/teach reference at its literal path, but\n// bundle.ts, sdk/load.ts, and the CLI's MCP resource handlers each classify a\n// bundled file into guides/knowledge purely by this prefix — a reference\n// resolving outside them is refused at pack time (see pack.ts's E022) rather\n// than bundled unreachable.\n// Single source of truth so the three sites can't drift on the prefix list.\nexport const CONTENT_NAMESPACES = ['guides', 'knowledge'] as const\nexport type ContentNamespace = (typeof CONTENT_NAMESPACES)[number]\n\nexport function isInContentNamespace(bundlePath: string): boolean {\n return classifyContentPath(bundlePath) !== null\n}\n\nexport function classifyContentPath(bundlePath: string): ContentNamespace | null {\n return CONTENT_NAMESPACES.find(ns => bundlePath.startsWith(`${ns}/`)) ?? null\n}\n"],"mappings":";;AAEA,MAAa,mBAAmB;;;ACGhC,SAAgB,aAAa,MAAoB;CAC/C,IAAI,CAAC,KAAK,YAAY,MAAM,IAAI,MAAM,oCAAoC;CAC1E,IAAI,CAAC,KAAK,IAAI,MAAM,IAAI,MAAM,4BAA4B;CAC1D,IAAI,CAAC,KAAK,MAAM,MAAM,IAAI,MAAM,8BAA8B;CAC9D,IAAI,CAAC,KAAK,aAAa,M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,OAAO,IAChF,MAAM,IAAI,MAAM,+CAA+C;AAEnE;AAEA,SAAgB,gBAAgB,KAAY,gBAA8B;CACxE,IAAI,oBAAoB;CACxB,IAAI,SAAS,OAAO,SAAS;EAC3B,IAAI,CAAC,KAAK,KAAK,qBAAsB,KAAa,OAAO,oBAAoB;CAC/E,CAAC;CACD,IAAI,oBAAA,UACF,MAAM,IAAI,MAAM,sCAAsC,mBAAmB;CAE3E,IAAI,oBAAoB,iBAAA,KACtB,MAAM,IAAI,MAAM,oCAAoC,oBAAoB,eAAA,CAAgB,QAAQ,CAAC,EAAE,EAAE;AAEzG;AAEA,SAAgB,YAAmB;CACjC,OAAO,IAAI,MAAM;AACnB;AAEA,eAAsB,aAAa,KAAY,QAAiD;CAC9F,MAAM,wBAAQ,IAAI,IAAoB;CACtC,MAAM,WAA4B,CAAC;CAEnC,IAAI,SAAS,cAAc,SAAS;EAClC,IAAI,KAAK,KAAK;EACd,IAAI,UAAU,CAAC,OAAO,MAAK,MAAK,aAAa,WAAW,CAAC,CAAC,GAAG;EAC7D,SAAS,KACP,KAAK,MAAM,MAAM,CAAC,CAAC,MAAK,YAAW;GACjC,MAAM,IAAI,cAAc,OAAO;EACjC,CAAC,CACH;CACF,CAAC;CAED,MAAM,QAAQ,IAAI,QAAQ;CAC1B,OAAO;AACT;;;ACrCA,MAAa,qBAAqB,CAAC,UAAU,WAAW;AAGxD,SAAgB,qBAAqB,YAA6B;CAChE,OAAO,oBAAoB,UAAU,MAAM;AAC7C;AAEA,SAAgB,oBAAoB,YAA6C;CAC/E,OAAO,mBAAmB,MAAK,OAAM,WAAW,WAAW,GAAG,GAAG,EAAE,CAAC,KAAK;AAC3E"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dot-agent/compiler",
3
- "version": "0.12.0-alpha.0",
3
+ "version": "0.12.0",
4
4
  "license": "Apache-2.0",
5
5
  "description": "Compiler for the dot-agent DSL: AST parsing, linting, graph extraction and .agent packaging",
6
6
  "author": {
@@ -79,8 +79,8 @@
79
79
  },
80
80
  "dependencies": {
81
81
  "@clack/prompts": "^1.7.0",
82
- "@dot-agent/parser-dsl": "0.12.0-alpha.0",
83
- "@dot-agent/tree-sitter": "0.12.0-alpha.0",
82
+ "@dot-agent/parser-dsl": "0.12.0",
83
+ "@dot-agent/tree-sitter": "0.12.0",
84
84
  "jszip": "^3.10.2",
85
85
  "web-tree-sitter": "^0.27.0"
86
86
  },
@@ -1 +0,0 @@
1
- {"version":3,"file":"namespace-B8prujsD.mjs","names":[],"sources":["../src/generated-version.ts","../src/manifest.ts","../src/id.ts","../src/zip-core.ts","../src/namespace.ts"],"sourcesContent":["// Generated by scripts/embed-version.mjs from dsl/VERSION and package.json — do not edit by hand.\nexport const DSL_VERSION = '0.1'\nexport const COMPILER_VERSION = '0.12.0-alpha.0'\n","// SPDX-License-Identifier: Apache-2.0\n\nimport type { AboutMe, BuildAboutmeOptions } from './types.js'\nimport { DSL_VERSION } from './generated-version.js'\n\nexport function parseAboutme(json: any): AboutMe {\n if (!json.dslVersion) throw new Error('Missing dslVersion in aboutme.json')\n if (!json.id) throw new Error('Missing id in aboutme.json')\n if (!json.name) throw new Error('Missing name in aboutme.json')\n if (!json.description) throw new Error('Missing description in aboutme.json')\n if (!json.domain) throw new Error('Missing domain in aboutme.json')\n if (!json.compiler) throw new Error('Missing compiler in aboutme.json')\n if (!Array.isArray(json.capabilities)) throw new Error('Missing capabilities array in aboutme.json')\n if (!Array.isArray(json.requires)) throw new Error('Missing requires array in aboutme.json')\n if (!json.integrity) throw new Error('Missing integrity in aboutme.json')\n\n return {\n dslVersion: json.dslVersion,\n id: json.id,\n name: json.name,\n description: json.description,\n version: json.version ?? '',\n domain: json.domain,\n license: json.license ?? '',\n persona: json.persona,\n purpose: json.purpose ?? 'unknown',\n compiler: json.compiler,\n commit: json.commit,\n capabilities: json.capabilities,\n requires: json.requires,\n integrity: json.integrity,\n }\n}\n\nexport function buildAboutme(opts: BuildAboutmeOptions): AboutMe {\n return {\n dslVersion: `dot-agent/${DSL_VERSION}`,\n id: opts.id,\n name: opts.name,\n description: opts.description,\n version: opts.version,\n domain: opts.domain,\n license: opts.license ?? '',\n persona: opts.persona,\n purpose: opts.purpose ?? 'unknown',\n compiler: opts.compiler,\n commit: opts.commit,\n capabilities: opts.capabilities ?? [],\n requires: opts.requires ?? [],\n integrity: opts.integrity,\n }\n}\n\nexport function aboutmeToJson(aboutme: AboutMe): string {\n return JSON.stringify(aboutme, null, 2)\n}\n","// SPDX-License-Identifier: Apache-2.0\n\nimport type { IdParts } from './types.js'\n\n// Code hosting platforms whose namespace format is platform/user rather than plain domain.\n// The list is maintained by the compiler and updated via CLI releases.\nexport const KNOWN_PLATFORMS = ['github.com', 'gitlab.com', 'codeberg.org', 'sr.ht'] as const\n\nfunction parseNamespaceName(identifier: string): { namespace: string; name: string } {\n // Email namespace: @ appears before any /\n const atIdx = identifier.indexOf('@')\n if (atIdx !== -1 && (identifier.indexOf('/') === -1 || atIdx < identifier.indexOf('/'))) {\n const slashIdx = identifier.indexOf('/')\n if (slashIdx === -1) {\n throw new Error(`Invalid agent ID: email namespace requires a name after '/' (got '${identifier}')`)\n }\n return {\n namespace: identifier.slice(0, slashIdx),\n name: identifier.slice(slashIdx + 1),\n }\n }\n\n // Known code-hosting platforms: namespace is platform/user, name is the next segment.\n for (const platform of KNOWN_PLATFORMS) {\n if (identifier.startsWith(platform + '/')) {\n const afterPlatform = identifier.slice(platform.length + 1)\n const slashIdx = afterPlatform.indexOf('/')\n if (slashIdx === -1) {\n throw new Error(\n `Invalid agent ID: '${platform}' namespace requires a user segment and a name (got '${identifier}')`,\n )\n }\n return {\n namespace: platform + '/' + afterPlatform.slice(0, slashIdx),\n name: afterPlatform.slice(slashIdx + 1),\n }\n }\n }\n\n // Domain or reserved keyword (e.g. 'unknown'): last '/' separates namespace from name.\n const lastSlash = identifier.lastIndexOf('/')\n if (lastSlash === -1) {\n throw new Error(`Invalid agent ID: missing '/' separator in '${identifier}'`)\n }\n return {\n namespace: identifier.slice(0, lastSlash),\n name: identifier.slice(lastSlash + 1),\n }\n}\n\nexport function parseId(id: string): IdParts {\n if (!id) throw new Error('Invalid agent ID: empty string')\n\n // Phase 1: split on the first ':' to isolate the identifier from version~digest.\n const colonIdx = id.indexOf(':')\n\n let identifier: string\n let version: string | undefined\n let digest: string | undefined\n\n if (colonIdx === -1) {\n // Form A: namespace/name\n identifier = id\n } else {\n identifier = id.slice(0, colonIdx)\n const rest = id.slice(colonIdx + 1)\n if (!rest) throw new Error(`Invalid agent ID: empty version after ':' in '${id}'`)\n\n // Phase 2: split version~digest\n const tildeIdx = rest.indexOf('~')\n if (tildeIdx === -1) {\n // Form B: namespace/name:version\n version = rest\n } else {\n // Form D: namespace/name:version~digest\n version = rest.slice(0, tildeIdx)\n digest = rest.slice(tildeIdx + 1)\n if (!version) throw new Error(`Invalid agent ID: empty version before '~' in '${id}'`)\n if (!digest) throw new Error(`Invalid agent ID: empty digest after '~' in '${id}'`)\n }\n }\n\n // Phase 3: extract namespace and name from the identifier\n const { namespace, name } = parseNamespaceName(identifier)\n\n if (!namespace) throw new Error(`Invalid agent ID: empty namespace in '${id}'`)\n if (!name) throw new Error(`Invalid agent ID: empty name in '${id}'`)\n\n return { namespace, name, version, digest }\n}\n\nexport function buildId(parts: IdParts): string {\n const { namespace, name, version, digest } = parts\n if (!namespace || !name) {\n throw new Error('Missing required ID parts: namespace and name')\n }\n if (digest && !version) {\n throw new Error('Invalid ID parts: digest requires version')\n }\n let result = `${namespace}/${name}`\n if (version) {\n result += `:${version}`\n if (digest) result += `~${digest}`\n }\n // Ids are always lowercase — domains, platform usernames (GitHub/GitLab/\n // Codeberg/Sourcehut) and email local-parts are all case-insensitive in\n // practice, so normalizing here is safe and gives every id a single shape.\n return result.toLowerCase()\n}\n\n// Turns a human display name (e.g. \"Fridge Assistant\", from `agent Fridge\n// Assistant` in the DSL — spaces/capitalization are deliberate there) into\n// the kebab-case slug used for an id's name segment.\nexport function slugify(name: string): string {\n return name\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, '-')\n .replace(/^-+|-+$/g, '')\n}\n\n// Accepts optional leading 'v' (id spec examples use it; monorepo tags after\n// their '@' split don't), 1-3 dot-separated numeric groups, and optional\n// -prerelease / +build suffixes — e.g. v1.0, 2.3.1, v1.0.0-alpha.1, 1.0+build.\nconst VERSION_RE = /^v?\\d+(\\.\\d+){0,2}(-[0-9A-Za-z.]+)?(\\+[0-9A-Za-z.]+)?$/i\n\nexport function isValidVersion(version: string): boolean {\n return VERSION_RE.test(version)\n}\n\nexport function extractDigest(id: string): string {\n try {\n return parseId(id).digest ?? ''\n } catch {\n return ''\n }\n}\n\nexport function extractName(id: string): string {\n try {\n return parseId(id).name\n } catch {\n return ''\n }\n}\n","// SPDX-License-Identifier: Apache-2.0\n\nimport JSZip from 'jszip'\n\nexport const MAX_ZIP_SIZE = 500 * 1024 * 1024\nexport const MAX_COMPRESSION_RATIO = 100\n\nexport function validateMagicBytes(bytes: Uint8Array): void {\n if (!(bytes[0] === 0x50 && bytes[1] === 0x4b && bytes[2] === 0x03 && bytes[3] === 0x04)) {\n throw new Error('Not a valid .agent file (invalid magic bytes)')\n }\n}\n\nexport function validateZipBomb(zip: JSZip, compressedSize: number): void {\n let totalUncompressed = 0\n zip.forEach((_path, file) => {\n if (!file.dir) totalUncompressed += (file as any)._data?.uncompressedSize || 0\n })\n if (totalUncompressed > MAX_ZIP_SIZE) {\n throw new Error(`Bundle exceeds 500MB uncompressed: ${totalUncompressed}`)\n }\n if (totalUncompressed / compressedSize > MAX_COMPRESSION_RATIO) {\n throw new Error(`Compression ratio exceeds 100x: ${(totalUncompressed / compressedSize).toFixed(1)}x`)\n }\n}\n\nexport function createZip(): JSZip {\n return new JSZip()\n}\n\nexport async function extractFiles(zip: JSZip, filter?: string[]): Promise<Map<string, string>> {\n const files = new Map<string, string>()\n const promises: Promise<void>[] = []\n\n zip.forEach((relativePath, file) => {\n if (file.dir) return\n if (filter && !filter.some(f => relativePath.startsWith(f))) return\n promises.push(\n file.async('text').then(content => {\n files.set(relativePath, content)\n })\n )\n })\n\n await Promise.all(promises)\n return files\n}\n","// SPDX-License-Identifier: Apache-2.0\n\n// The two directories the runtime can actually serve content from: pack.ts's\n// collectFiles() bundles a guide/teach reference at its literal path, but\n// bundle.ts, sdk/load.ts, and the CLI's MCP resource handlers each classify a\n// bundled file into guides/knowledge purely by this prefix — a reference\n// resolving outside them is refused at pack time (see pack.ts's E022) rather\n// than bundled unreachable.\n// Single source of truth so the three sites can't drift on the prefix list.\nexport const CONTENT_NAMESPACES = ['guides', 'knowledge'] as const\nexport type ContentNamespace = (typeof CONTENT_NAMESPACES)[number]\n\nexport function isInContentNamespace(bundlePath: string): boolean {\n return classifyContentPath(bundlePath) !== null\n}\n\nexport function classifyContentPath(bundlePath: string): ContentNamespace | null {\n return CONTENT_NAMESPACES.find(ns => bundlePath.startsWith(`${ns}/`)) ?? null\n}\n"],"mappings":";;AAEA,MAAa,mBAAmB;;;ACGhC,SAAgB,aAAa,MAAoB;CAC/C,IAAI,CAAC,KAAK,YAAY,MAAM,IAAI,MAAM,oCAAoC;CAC1E,IAAI,CAAC,KAAK,IAAI,MAAM,IAAI,MAAM,4BAA4B;CAC1D,IAAI,CAAC,KAAK,MAAM,MAAM,IAAI,MAAM,8BAA8B;CAC9D,IAAI,CAAC,KAAK,aAAa,MAAM,IAAI,MAAM,qCAAqC;CAC5E,IAAI,CAAC,KAAK,QAAQ,MAAM,IAAI,MAAM,gCAAgC;CAClE,IAAI,CAAC,KAAK,UAAU,MAAM,IAAI,MAAM,kCAAkC;CACtE,IAAI,CAAC,MAAM,QAAQ,KAAK,YAAY,GAAG,MAAM,IAAI,MAAM,4CAA4C;CACnG,IAAI,CAAC,MAAM,QAAQ,KAAK,QAAQ,GAAG,MAAM,IAAI,MAAM,wCAAwC;CAC3F,IAAI,CAAC,KAAK,WAAW,MAAM,IAAI,MAAM,mCAAmC;CAExE,OAAO;EACL,YA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E;AAEzG;AAEA,SAAgB,YAAmB;CACjC,OAAO,IAAI,MAAM;AACnB;AAEA,eAAsB,aAAa,KAAY,QAAiD;CAC9F,MAAM,wBAAQ,IAAI,IAAoB;CACtC,MAAM,WAA4B,CAAC;CAEnC,IAAI,SAAS,cAAc,SAAS;EAClC,IAAI,KAAK,KAAK;EACd,IAAI,UAAU,CAAC,OAAO,MAAK,MAAK,aAAa,WAAW,CAAC,CAAC,GAAG;EAC7D,SAAS,KACP,KAAK,MAAM,MAAM,CAAC,CAAC,MAAK,YAAW;GACjC,MAAM,IAAI,cAAc,OAAO;EACjC,CAAC,CACH;CACF,CAAC;CAED,MAAM,QAAQ,IAAI,QAAQ;CAC1B,OAAO;AACT;;;ACrCA,MAAa,qBAAqB,CAAC,UAAU,WAAW;AAGxD,SAAgB,qBAAqB,YAA6B;CAChE,OAAO,oBAAoB,UAAU,MAAM;AAC7C;AAEA,SAAgB,oBAAoB,YAA6C;CAC/E,OAAO,mBAAmB,MAAK,OAAM,WAAW,WAAW,GAAG,GAAG,EAAE,CAAC,KAAK;AAC3E"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"namespace-BbxHHnOo.cjs","names":["JSZip"],"sources":["../src/generated-version.ts","../src/manifest.ts","../src/id.ts","../src/zip-core.ts","../src/namespace.ts"],"sourcesContent":["// Generated by scripts/embed-version.mjs from dsl/VERSION and package.json — do not edit by hand.\nexport const DSL_VERSION = '0.1'\nexport const COMPILER_VERSION = '0.12.0-alpha.0'\n","// SPDX-License-Identifier: Apache-2.0\n\nimport type { AboutMe, BuildAboutmeOptions } from './types.js'\nimport { DSL_VERSION } from './generated-version.js'\n\nexport function parseAboutme(json: any): AboutMe {\n if (!json.dslVersion) throw new Error('Missing dslVersion in aboutme.json')\n if (!json.id) throw new Error('Missing id in aboutme.json')\n if (!json.name) throw new Error('Missing name in aboutme.json')\n if (!json.description) throw new Error('Missing description in aboutme.json')\n if (!json.domain) throw new Error('Missing domain in aboutme.json')\n if (!json.compiler) throw new Error('Missing compiler in aboutme.json')\n if (!Array.isArray(json.capabilities)) throw new Error('Missing capabilities array in aboutme.json')\n if (!Array.isArray(json.requires)) throw new Error('Missing requires array in aboutme.json')\n if (!json.integrity) throw new Error('Missing integrity in aboutme.json')\n\n return {\n dslVersion: json.dslVersion,\n id: json.id,\n name: json.name,\n description: json.description,\n version: json.version ?? '',\n domain: json.domain,\n license: json.license ?? '',\n persona: json.persona,\n purpose: json.purpose ?? 'unknown',\n compiler: json.compiler,\n commit: json.commit,\n capabilities: json.capabilities,\n requires: json.requires,\n integrity: json.integrity,\n }\n}\n\nexport function buildAboutme(opts: BuildAboutmeOptions): AboutMe {\n return {\n dslVersion: `dot-agent/${DSL_VERSION}`,\n id: opts.id,\n name: opts.name,\n description: opts.description,\n version: opts.version,\n domain: opts.domain,\n license: opts.license ?? '',\n persona: opts.persona,\n purpose: opts.purpose ?? 'unknown',\n compiler: opts.compiler,\n commit: opts.commit,\n capabilities: opts.capabilities ?? [],\n requires: opts.requires ?? [],\n integrity: opts.integrity,\n }\n}\n\nexport function aboutmeToJson(aboutme: AboutMe): string {\n return JSON.stringify(aboutme, null, 2)\n}\n","// SPDX-License-Identifier: Apache-2.0\n\nimport type { IdParts } from './types.js'\n\n// Code hosting platforms whose namespace format is platform/user rather than plain domain.\n// The list is maintained by the compiler and updated via CLI releases.\nexport const KNOWN_PLATFORMS = ['github.com', 'gitlab.com', 'codeberg.org', 'sr.ht'] as const\n\nfunction parseNamespaceName(identifier: string): { namespace: string; name: string } {\n // Email namespace: @ appears before any /\n const atIdx = identifier.indexOf('@')\n if (atIdx !== -1 && (identifier.indexOf('/') === -1 || atIdx < identifier.indexOf('/'))) {\n const slashIdx = identifier.indexOf('/')\n if (slashIdx === -1) {\n throw new Error(`Invalid agent ID: email namespace requires a name after '/' (got '${identifier}')`)\n }\n return {\n namespace: identifier.slice(0, slashIdx),\n name: identifier.slice(slashIdx + 1),\n }\n }\n\n // Known code-hosting platforms: namespace is platform/user, name is the next segment.\n for (const platform of KNOWN_PLATFORMS) {\n if (identifier.startsWith(platform + '/')) {\n const afterPlatform = identifier.slice(platform.length + 1)\n const slashIdx = afterPlatform.indexOf('/')\n if (slashIdx === -1) {\n throw new Error(\n `Invalid agent ID: '${platform}' namespace requires a user segment and a name (got '${identifier}')`,\n )\n }\n return {\n namespace: platform + '/' + afterPlatform.slice(0, slashIdx),\n name: afterPlatform.slice(slashIdx + 1),\n }\n }\n }\n\n // Domain or reserved keyword (e.g. 'unknown'): last '/' separates namespace from name.\n const lastSlash = identifier.lastIndexOf('/')\n if (lastSlash === -1) {\n throw new Error(`Invalid agent ID: missing '/' separator in '${identifier}'`)\n }\n return {\n namespace: identifier.slice(0, lastSlash),\n name: identifier.slice(lastSlash + 1),\n }\n}\n\nexport function parseId(id: string): IdParts {\n if (!id) throw new Error('Invalid agent ID: empty string')\n\n // Phase 1: split on the first ':' to isolate the identifier from version~digest.\n const colonIdx = id.indexOf(':')\n\n let identifier: string\n let version: string | undefined\n let digest: string | undefined\n\n if (colonIdx === -1) {\n // Form A: namespace/name\n identifier = id\n } else {\n identifier = id.slice(0, colonIdx)\n const rest = id.slice(colonIdx + 1)\n if (!rest) throw new Error(`Invalid agent ID: empty version after ':' in '${id}'`)\n\n // Phase 2: split version~digest\n const tildeIdx = rest.indexOf('~')\n if (tildeIdx === -1) {\n // Form B: namespace/name:version\n version = rest\n } else {\n // Form D: namespace/name:version~digest\n version = rest.slice(0, tildeIdx)\n digest = rest.slice(tildeIdx + 1)\n if (!version) throw new Error(`Invalid agent ID: empty version before '~' in '${id}'`)\n if (!digest) throw new Error(`Invalid agent ID: empty digest after '~' in '${id}'`)\n }\n }\n\n // Phase 3: extract namespace and name from the identifier\n const { namespace, name } = parseNamespaceName(identifier)\n\n if (!namespace) throw new Error(`Invalid agent ID: empty namespace in '${id}'`)\n if (!name) throw new Error(`Invalid agent ID: empty name in '${id}'`)\n\n return { namespace, name, version, digest }\n}\n\nexport function buildId(parts: IdParts): string {\n const { namespace, name, version, digest } = parts\n if (!namespace || !name) {\n throw new Error('Missing required ID parts: namespace and name')\n }\n if (digest && !version) {\n throw new Error('Invalid ID parts: digest requires version')\n }\n let result = `${namespace}/${name}`\n if (version) {\n result += `:${version}`\n if (digest) result += `~${digest}`\n }\n // Ids are always lowercase — domains, platform usernames (GitHub/GitLab/\n // Codeberg/Sourcehut) and email local-parts are all case-insensitive in\n // practice, so normalizing here is safe and gives every id a single shape.\n return result.toLowerCase()\n}\n\n// Turns a human display name (e.g. \"Fridge Assistant\", from `agent Fridge\n// Assistant` in the DSL — spaces/capitalization are deliberate there) into\n// the kebab-case slug used for an id's name segment.\nexport function slugify(name: string): string {\n return name\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, '-')\n .replace(/^-+|-+$/g, '')\n}\n\n// Accepts optional leading 'v' (id spec examples use it; monorepo tags after\n// their '@' split don't), 1-3 dot-separated numeric groups, and optional\n// -prerelease / +build suffixes — e.g. v1.0, 2.3.1, v1.0.0-alpha.1, 1.0+build.\nconst VERSION_RE = /^v?\\d+(\\.\\d+){0,2}(-[0-9A-Za-z.]+)?(\\+[0-9A-Za-z.]+)?$/i\n\nexport function isValidVersion(version: string): boolean {\n return VERSION_RE.test(version)\n}\n\nexport function extractDigest(id: string): string {\n try {\n return parseId(id).digest ?? ''\n } catch {\n return ''\n }\n}\n\nexport function extractName(id: string): string {\n try {\n return parseId(id).name\n } catch {\n return ''\n }\n}\n","// SPDX-License-Identifier: Apache-2.0\n\nimport JSZip from 'jszip'\n\nexport const MAX_ZIP_SIZE = 500 * 1024 * 1024\nexport const MAX_COMPRESSION_RATIO = 100\n\nexport function validateMagicBytes(bytes: Uint8Array): void {\n if (!(bytes[0] === 0x50 && bytes[1] === 0x4b && bytes[2] === 0x03 && bytes[3] === 0x04)) {\n throw new Error('Not a valid .agent file (invalid magic bytes)')\n }\n}\n\nexport function validateZipBomb(zip: JSZip, compressedSize: number): void {\n let totalUncompressed = 0\n zip.forEach((_path, file) => {\n if (!file.dir) totalUncompressed += (file as any)._data?.uncompressedSize || 0\n })\n if (totalUncompressed > MAX_ZIP_SIZE) {\n throw new Error(`Bundle exceeds 500MB uncompressed: ${totalUncompressed}`)\n }\n if (totalUncompressed / compressedSize > MAX_COMPRESSION_RATIO) {\n throw new Error(`Compression ratio exceeds 100x: ${(totalUncompressed / compressedSize).toFixed(1)}x`)\n }\n}\n\nexport function createZip(): JSZip {\n return new JSZip()\n}\n\nexport async function extractFiles(zip: JSZip, filter?: string[]): Promise<Map<string, string>> {\n const files = new Map<string, string>()\n const promises: Promise<void>[] = []\n\n zip.forEach((relativePath, file) => {\n if (file.dir) return\n if (filter && !filter.some(f => relativePath.startsWith(f))) return\n promises.push(\n file.async('text').then(content => {\n files.set(relativePath, content)\n })\n )\n })\n\n await Promise.all(promises)\n return files\n}\n","// SPDX-License-Identifier: Apache-2.0\n\n// The two directories the runtime can actually serve content from: pack.ts's\n// collectFiles() bundles a guide/teach reference at its literal path, but\n// bundle.ts, sdk/load.ts, and the CLI's MCP resource handlers each classify a\n// bundled file into guides/knowledge purely by this prefix — a reference\n// resolving outside them is refused at pack time (see pack.ts's E022) rather\n// than bundled unreachable.\n// Single source of truth so the three sites can't drift on the prefix list.\nexport const CONTENT_NAMESPACES = ['guides', 'knowledge'] as const\nexport type ContentNamespace = (typeof CONTENT_NAMESPACES)[number]\n\nexport function isInContentNamespace(bundlePath: string): boolean {\n return classifyContentPath(bundlePath) !== null\n}\n\nexport function classifyContentPath(bundlePath: string): ContentNamespace | null {\n return CONTENT_NAMESPACES.find(ns => bundlePath.startsWith(`${ns}/`)) ?? null\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAEA,MAAa,mBAAmB;;;ACGhC,SAAgB,aAAa,MAAoB;CAC/C,IAAI,CAAC,KAAK,YAAY,MAAM,IAAI,MAAM,oCAAoC;CAC1E,IAAI,CAAC,KAAK,IAAI,MAAM,IAAI,MAAM,4BAA4B;CAC1D,IAAI,CAAC,KAAK,MAAM,MAA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