@dot-agent/compiler 0.10.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.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","names":["bpInit","bpParseBehavior","bpParseDescription"],"sources":["../src/parser.ts","../src/linter.ts","../src/zip.ts","../src/schema.ts","../src/pack.ts","../src/bundle.ts"],"sourcesContent":["// Copyright 2026 Danilo Borges\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n\nimport { createRequire } from 'module'\nimport { Parser, Language } from 'web-tree-sitter'\nimport type { Node, Tree } from 'web-tree-sitter'\nimport type { LangId, BehaviorFile, DescriptionFile, ParseDiagnostic } from './types.js'\nimport { init as bpInit, parse_behavior as bpParseBehavior, parse_description as bpParseDescription, get_graph } from '@dot-agent/parser-dsl'\n\nconst require = createRequire(import.meta.url)\nconst { descriptionWasmPath, behaviorWasmPath } = require('@dot-agent/tree-sitter') as {\n descriptionWasmPath: string\n behaviorWasmPath: string\n}\n\nlet _initialized = false\nlet _descriptionParser: Parser\nlet _behaviorParser: Parser\nlet _bpInitialized = false\n\nexport async function initBehaviorParser(): Promise<void> {\n if (_bpInitialized) return\n await bpInit()\n _bpInitialized = true\n}\n\nexport interface ParseResult<T> {\n ok: T | null\n diagnostics: ParseDiagnostic[]\n}\n\nexport function parseBehaviorFile(text: string): ParseResult<BehaviorFile> {\n return JSON.parse(bpParseBehavior(text)) as ParseResult<BehaviorFile>\n}\n\nexport function parseDescriptionFile(text: string): ParseResult<DescriptionFile> {\n return JSON.parse(bpParseDescription(text)) as ParseResult<DescriptionFile>\n}\n\nexport function getBehaviorScxml(text: string): string {\n return get_graph(text)\n}\n\nexport async function initParsers(): Promise<void> {\n if (_initialized) return\n await Parser.init()\n const descriptionLang = await Language.load(descriptionWasmPath)\n const behaviorLang = await Language.load(behaviorWasmPath)\n _descriptionParser = new Parser()\n _descriptionParser.setLanguage(descriptionLang)\n _behaviorParser = new Parser()\n _behaviorParser.setLanguage(behaviorLang)\n _initialized = true\n}\n\n/**\n * Parse source text and return a tree-sitter Tree.\n *\n * @param langId - 'description' or 'behavior'\n * @param text - source text to parse\n * @param previousTree - optional previous tree for incremental parsing (LSP use)\n */\nexport async function parse(\n langId: LangId,\n text: string,\n previousTree?: Tree\n): Promise<Tree> {\n await initParsers()\n const parser = langId === 'behavior' ? _behaviorParser : _descriptionParser\n return parser.parse(text, previousTree)!\n}\n\n/** Parse without initializing if parsers are already ready. Returns null if not initialized. */\nexport function parseSync(langId: LangId, text: string, previousTree?: Tree): Tree | null {\n if (!_initialized) return null\n const parser = langId === 'behavior' ? _behaviorParser : _descriptionParser\n return parser.parse(text, previousTree)\n}\n\n// ── AST helpers ──────────────────────────────────────────────────────────────\n\nexport function nodesOfType(tree: Tree, type: string): Node[] {\n if (!tree) return []\n return tree.rootNode.descendantsOfType(type).filter((n): n is Node => n !== null)\n}\n\nexport function nodeAtOffset(tree: Tree, offset: number): Node | null {\n if (!tree) return null\n return tree.rootNode.descendantForIndex(offset)\n}\n\nexport function nodeToRange(node: Node): {\n start: { line: number; character: number }\n end: { line: number; character: number }\n} {\n return {\n start: { line: node.startPosition.row, character: node.startPosition.column },\n end: { line: node.endPosition.row, character: node.endPosition.column },\n }\n}\n\nexport function positionToOffset(text: string, line: number, character: number): number {\n let offset = 0\n for (let i = 0; i < line; i++) {\n const nl = text.indexOf('\\n', offset)\n offset = nl === -1 ? text.length : nl + 1\n }\n return offset + character\n}\n\nexport function getContextNode(tree: Tree, offset: number): Node {\n let node = nodeAtOffset(tree, offset)\n while (node && (node.isError || node.isMissing)) {\n node = node.parent\n }\n if (!node || node.type === 'ERROR') {\n const raw = nodeAtOffset(tree, offset)\n const parent = raw?.parent\n if (parent) {\n const siblings = parent.children\n const idx = siblings.findIndex((c: Node | null) => c !== null && c.startIndex > offset)\n const prev = idx > 0 ? siblings[idx - 1] : siblings[siblings.length - 1]\n if (prev && !prev.isError) node = prev\n }\n }\n return node ?? tree.rootNode\n}\n","// Copyright 2026 Danilo Borges\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { readFileSync } from 'fs'\nimport { resolve, dirname } from 'path'\nimport { parse, nodesOfType, parseSync, initBehaviorParser, parseBehaviorFile } from './parser.js'\nimport type { LintMessage } from './types.js'\nimport type { Node, Tree } from 'web-tree-sitter'\n\nfunction nodePosition(node: Node): { line: number; col: number } {\n return { line: node.startPosition.row + 1, col: node.startPosition.column + 1 }\n}\n\n// ── Syntax error collection (reports deepest ERROR node per branch) ──────────\n\nconst MISSING_HINTS: Record<string, string> = {\n interact_stmt: \"Missing 'interact' — oriented states require 'goal … interact … on intent … on offtopic'.\",\n offtopic_handler: \"Missing 'on offtopic' handler — every state with 'interact' must handle the offtopic case.\",\n intent_handler: \"Missing at least one 'on intent' handler after 'interact'.\",\n goal_stmt: \"Missing 'goal' — every state with 'interact' must declare a goal.\",\n state_name: \"Missing state name after 'state' keyword.\",\n quoted_string: \"Missing quoted string — expected a value in double quotes.\",\n}\n\nfunction collectSyntaxErrors(root: Node, messages: LintMessage[], file: string): void {\n const seen = new Set<string>()\n\n function push(node: Node, message: string, code: string, severity: 'error' | 'warning' = 'error') {\n const key = `${node.startIndex}:${node.endIndex}:${message}`\n if (seen.has(key)) return\n seen.add(key)\n const { line, col } = nodePosition(node)\n messages.push({ file, line, col, severity, code, message })\n }\n\n function walk(node: Node) {\n if (node.isMissing) {\n const hint = MISSING_HINTS[node.type]\n push(node, hint ?? `Syntax error: missing '${node.type}'.`, 'E004')\n return\n }\n if (node.type === 'ERROR') {\n const hasNestedError = node.descendantsOfType('ERROR').some((e: Node | null) => e !== null && e.id !== node.id)\n if (!hasNestedError) {\n const snippet = node.text.replace(/\\s+/g, ' ').trim().slice(0, 40)\n push(node, snippet ? `Syntax error near '${snippet}'.` : 'Syntax error.', 'E004')\n return\n }\n }\n for (const child of node.children) {\n if (child) walk(child)\n }\n }\n\n walk(root)\n}\n\n// ── Description linting ──────────────────────────────────────────────────────\n\nconst STRICT_BLOCK_TYPES: Record<string, string> = {\n input_block: 'input',\n output_block: 'output',\n requires_block: 'requires',\n capabilities_block: 'capabilities',\n}\n\nexport async function lintDescription(text: string, file = 'agent.description'): Promise<LintMessage[]> {\n const tree = await parse('description', text)\n const messages: LintMessage[] = []\n\n collectSyntaxErrors(tree.rootNode, messages, file)\n\n // W003: default domain value\n // The grammar uses `agent_meta` nodes with key/value fields (not `domain_declaration`)\n for (const metaNode of nodesOfType(tree, 'agent_meta')) {\n const keyNode = metaNode.childForFieldName('key')\n if (keyNode?.text !== 'domain') continue\n const valueNode = metaNode.childForFieldName('value')\n if (valueNode?.text === 'example.com') {\n const { line, col } = nodePosition(valueNode)\n messages.push({\n file,\n line,\n col,\n severity: 'warning',\n code: 'W003',\n message: 'domain still has default value \"example.com\"',\n })\n }\n }\n\n // W007: no domain declared → agent will be packaged as unknown/name\n const hasDomain = nodesOfType(tree, 'agent_meta').some(\n n => n.childForFieldName('key')?.text === 'domain' && n.childForFieldName('value')?.text?.trim(),\n )\n if (!hasDomain) {\n messages.push({\n file,\n line: 1,\n col: 1,\n severity: 'warning',\n code: 'W007',\n message:\n 'No domain declared — agent will be packaged as unknown/name. Interoperability between runtimes is not guaranteed.',\n })\n }\n\n // E017: multiple behavior declarations\n const behaviorBlocks = nodesOfType(tree, 'behavior_block')\n if (behaviorBlocks.length > 1) {\n const { line, col } = nodePosition(behaviorBlocks[1])\n messages.push({\n file, line, col, severity: 'error', code: 'E017',\n message: \"Multiple 'behavior' declarations — only one is allowed. To combine multiple files, use 'merge' in your .behavior file.\",\n })\n }\n\n // W004: undeclared type references in input/output/requires/capabilities blocks\n const declaredTypes = new Set(\n nodesOfType(tree, 'type_decl')\n .map(n => n.childForFieldName('name')?.text)\n .filter(Boolean) as string[]\n )\n\n if (declaredTypes.size > 0) {\n for (const blockType of Object.keys(STRICT_BLOCK_TYPES)) {\n for (const blockNode of nodesOfType(tree, blockType)) {\n for (const typeRefNode of blockNode.descendantsOfType('type_reference').filter((n): n is Node => n !== null)) {\n const idNode = typeRefNode.firstNamedChild\n if (!idNode) continue\n const typeName = idNode.text\n if (!declaredTypes.has(typeName)) {\n const { line, col } = nodePosition(idNode)\n messages.push({\n file,\n line,\n col,\n severity: 'warning',\n code: 'W004',\n message: `Type '${typeName}' is not declared in this file (assuming native or external).`,\n })\n }\n }\n }\n }\n }\n\n return messages\n}\n\n// ── Behavior linting ─────────────────────────────────────────────────────────\n\nfunction levenshtein(a: string, b: string): number {\n const la = a.length, lb = b.length\n const dp: number[][] = Array.from({ length: la + 1 }, (_, i) =>\n Array.from({ length: lb + 1 }, (_, j) => (i === 0 ? j : j === 0 ? i : 0))\n )\n for (let i = 1; i <= la; i++) {\n for (let j = 1; j <= lb; j++) {\n dp[i][j] = a[i - 1] === b[j - 1]\n ? dp[i - 1][j - 1]\n : 1 + Math.min(dp[i - 1][j], dp[i][j - 1], dp[i - 1][j - 1])\n }\n }\n return dp[la][lb]\n}\n\nfunction closestName(token: string, candidates: string[]): string | undefined {\n let best: string | undefined\n let bestDist = Infinity\n for (const name of candidates) {\n const d = levenshtein(token.toLowerCase(), name.toLowerCase())\n if (d > 0 && d <= 2 && d < bestDist) { bestDist = d; best = name }\n }\n return best\n}\n\nconst KERNEL_LIFECYCLE_NAMES = ['init', 'welcome', 'end', 'online', 'offline']\n\nfunction collectTransitionTargets(stmts: Array<{ type: string; [k: string]: unknown }>): string[] {\n const targets: string[] = []\n for (const stmt of stmts) {\n if (!stmt || typeof stmt !== 'object') continue\n if (stmt.type === 'transition_stmt' && typeof stmt['state'] === 'string') {\n targets.push(stmt['state'])\n }\n if (stmt.type === 'intent_handler' && typeof stmt['body'] === 'string') {\n targets.push(stmt['body'])\n }\n const recurse = (v: unknown) => {\n if (Array.isArray(v)) targets.push(...collectTransitionTargets(v as Array<{ type: string }>))\n }\n if (stmt.type !== 'intent_handler') recurse(stmt['body'])\n recurse(stmt['handlers'])\n recurse(stmt['then'])\n recurse(stmt['else'])\n recurse(stmt['on_complete'])\n recurse(stmt['on_failure'])\n }\n return targets\n}\n\nfunction collectMergedStates(\n tree: Tree,\n docDir: string,\n states: Set<string>,\n visited = new Set<string>()\n): void {\n for (const mergeNode of nodesOfType(tree, 'merge_decl')) {\n const pathNode = mergeNode.childForFieldName('path')\n if (!pathNode) continue\n const filename = pathNode.text.replace(/^\"|\"$/g, '')\n const absPath = resolve(docDir, filename)\n if (visited.has(absPath)) continue\n visited.add(absPath)\n let mergedText: string\n try {\n mergedText = readFileSync(absPath, 'utf-8')\n } catch {\n continue\n }\n const mergedTree = parseSync('behavior', mergedText)\n if (!mergedTree) continue\n nodesOfType(mergedTree, 'state_decl').forEach(n => {\n const name = n.childForFieldName('name')?.text\n if (name) states.add(name)\n })\n collectMergedStates(mergedTree, dirname(absPath), states, visited)\n }\n}\n\nexport async function lintBehavior(\n text: string,\n file = 'agent.behavior',\n docPath?: string,\n consolidated = false,\n externalStates?: Set<string>,\n mergedText?: string,\n): Promise<LintMessage[]> {\n await initBehaviorParser()\n if (!text.endsWith('\\n')) text = text + '\\n'\n const tree = await parse('behavior', text)\n const messages: LintMessage[] = []\n\n // Rule 0: syntax errors\n collectSyntaxErrors(tree.rootNode, messages, file)\n\n for (const stateNode of nodesOfType(tree, 'state_decl')) {\n if (stateNode.hasError) continue\n const nameNode = stateNode.childForFieldName('name')\n const stateName = nameNode?.text ?? '?'\n const hasInteract = stateNode.descendantsOfType('interact_stmt').length > 0\n const hasGoal = stateNode.descendantsOfType('goal_stmt').length > 0\n const intentHandlers = stateNode.descendantsOfType('intent_handler')\n\n // W013: interact without goal (supersedes E008 — downgraded to warning)\n if (hasInteract && !hasGoal) {\n const { line, col } = nodePosition(nameNode ?? stateNode)\n messages.push({\n file, line, col, severity: 'warning', code: 'W013',\n message: `'interact' without 'goal'. Add 'goal \"...\"' before 'interact'.`,\n })\n }\n\n // W012: goal without interact\n if (hasGoal && !hasInteract) {\n const { line, col } = nodePosition(nameNode ?? stateNode)\n messages.push({\n file, line, col, severity: 'warning', code: 'W012',\n message: `'goal' is only valid in an oriented state. Add 'interact' or remove 'goal'.`,\n })\n }\n\n // E009: oriented state with no on intent handlers\n if (hasInteract && intentHandlers.length === 0) {\n const { line, col } = nodePosition(nameNode ?? stateNode)\n messages.push({\n file, line, col, severity: 'error', code: 'E009',\n message: `Oriented state '${stateName}' has no 'on intent' handlers. At least one is required.`,\n })\n }\n\n // W008: duplicate on intent label in same state (Error-level per spec)\n const seenIntents = new Map<string, true>()\n for (const handler of intentHandlers) {\n const intentNode = handler.childForFieldName('intent')\n if (!intentNode) continue\n const label = intentNode.text.replace(/^\"|\"$/g, '')\n if (seenIntents.has(label)) {\n const { line, col } = nodePosition(handler)\n messages.push({\n file, line, col, severity: 'error', code: 'W008',\n message: `Duplicate 'on intent \"${label}\"' in state '${stateName}'. The FSM cannot route ambiguous intents — use a unique label for each handler.`,\n })\n } else {\n seenIntents.set(label, true)\n }\n }\n\n // W011: on intent handler transitions to its own enclosing state\n for (const handler of intentHandlers) {\n for (const t of handler.descendantsOfType('transition_stmt')) {\n const targetNode = t.childForFieldName('state')\n if (targetNode?.text === stateName) {\n const { line, col } = nodePosition(handler)\n messages.push({\n file, line, col, severity: 'warning', code: 'W011',\n message: `'on intent' handler in state '${stateName}' transitions back to itself. The user expressed an intent but receives no progress — did you mean a different target state?`,\n })\n }\n }\n }\n\n // I001/I002: state overrides kernel lifecycle\n if (stateName === 'init' || stateName === 'end') {\n const { line, col } = nodePosition(nameNode ?? stateNode)\n if (stateName === 'init') {\n messages.push({\n file, line, col, severity: 'info', code: 'I001',\n message: `State 'init' overrides the kernel's default entry lifecycle. The kernel will use this definition instead of its built-in init sequence.`,\n })\n } else {\n messages.push({\n file, line, col, severity: 'info', code: 'I002',\n message: `State 'end' overrides the kernel's default terminal lifecycle. The kernel will treat this state as the canonical exit point.`,\n })\n }\n }\n\n // H001: state name close to (but not exact match of) kernel lifecycle names\n if (!KERNEL_LIFECYCLE_NAMES.includes(stateName)) {\n const closest = closestName(stateName, KERNEL_LIFECYCLE_NAMES)\n if (closest) {\n const { line, col } = nodePosition(nameNode ?? stateNode)\n messages.push({\n file, line, col, severity: 'hint', code: 'H001',\n message: `State name '${stateName}' resembles the kernel lifecycle name '${closest}'. If this is intentional, ignore this hint.`,\n })\n }\n }\n }\n\n // E010: parallel block with no run statements\n for (const parallelNode of nodesOfType(tree, 'parallel_stmt')) {\n if (parallelNode.hasError) continue\n if (parallelNode.descendantsOfType('run_stmt').length === 0) {\n const { line, col } = nodePosition(parallelNode)\n let stateName = '?'\n let ancestor = parallelNode.parent\n while (ancestor && ancestor.type !== 'state_decl') ancestor = ancestor.parent\n if (ancestor) stateName = ancestor.childForFieldName('name')?.text ?? '?'\n messages.push({\n file, line, col, severity: 'warning', code: 'E010',\n message: `'parallel' block in state '${stateName}' has no 'run' statements and does nothing.`,\n })\n }\n }\n\n // E011: after statement with prompts: 0\n for (const afterNode of nodesOfType(tree, 'after_stmt')) {\n if (afterNode.hasError) continue\n const countNode = afterNode.childForFieldName('count')\n if (countNode?.text === '0') {\n const { line, col } = nodePosition(countNode)\n messages.push({\n file, line, col, severity: 'error', code: 'E011',\n message: `'after 0' is invalid — prompts must be ≥ 1. Use 'after 1' for the next prompt.`,\n })\n }\n }\n\n // W002: goal_stmt text > 280 chars\n for (const stmtNode of nodesOfType(tree, 'goal_stmt')) {\n const strNode = stmtNode.descendantsOfType('quoted_string').find((n): n is Node => n !== null)\n if (!strNode) continue\n const content = strNode.text.replace(/^\"|\"$/g, '')\n if (content.length > 280) {\n const { line, col } = nodePosition(strNode)\n messages.push({\n file, line, col, severity: 'warning', code: 'W002',\n message: `Text block exceeds 280 characters (${content.length}). Consider using 'guide' to load long orientation text from an external text file.`,\n })\n }\n }\n\n // W010: guide_stmt text > 280 chars\n for (const stmtNode of nodesOfType(tree, 'guide_stmt')) {\n const strNode = stmtNode.descendantsOfType('quoted_string').find((n): n is Node => n !== null)\n if (!strNode) continue\n const content = strNode.text.replace(/^\"|\"$/g, '')\n if (content.length > 280) {\n const { line, col } = nodePosition(strNode)\n let p = stmtNode.parent\n while (p && p.type !== 'state_decl') p = p.parent\n const stateName = p?.childForFieldName('name')?.text ?? '?'\n messages.push({\n file, line, col, severity: 'warning', code: 'W010',\n message: `'guide' text in state '${stateName}' is ${content.length} characters. Consider using an external file.`,\n })\n }\n }\n\n // E005/W005: dangling transitions — state not defined (H002: hint with closest name)\n const definedStates = new Set(\n nodesOfType(tree, 'state_decl')\n .map(n => n.childForFieldName('name')?.text)\n .filter(Boolean) as string[]\n )\n\n if (docPath) {\n try {\n collectMergedStates(tree, dirname(docPath), definedStates)\n } catch {\n // path resolution failed — continue with local states only\n }\n }\n\n // Fragment files (merged INTO another file, with no merge of their own)\n // don't see the parent's states via collectMergedStates, which only walks\n // forward. Callers that resolve the merge root can pass its consolidated\n // state set here so dangling-transition checks see the whole tree.\n if (externalStates) {\n for (const name of externalStates) definedStates.add(name)\n }\n\n const stateNameList = Array.from(definedStates)\n for (const transitionNode of nodesOfType(tree, 'transition_stmt')) {\n const stateNode = transitionNode.childForFieldName('state')\n if (!stateNode) continue\n const target = stateNode.text\n if (!definedStates.has(target)) {\n const { line, col } = nodePosition(stateNode)\n const isExternal = target.includes('.')\n // H002: enrich E005 with closest state name suggestion\n const hint = !isExternal ? closestName(target, stateNameList) : undefined\n messages.push({\n file, line, col,\n severity: isExternal ? 'warning' : 'error',\n code: isExternal ? 'W005' : 'E005',\n message: isExternal\n ? `State '${target}' is not defined locally (assuming external flow reference).`\n : `State '${target}' is not defined in this file.`,\n ...(hint ? { hint: `did you mean '${hint}'?` } : {}),\n })\n }\n }\n\n // W006: dead-end interact (no handlers at all)\n for (const interactNode of nodesOfType(tree, 'interact_stmt')) {\n let ancestor = interactNode.parent\n while (ancestor && ancestor.type !== 'state_decl') ancestor = ancestor.parent\n if (!ancestor) continue\n const hasHandlers =\n ancestor.descendantsOfType('intent_handler').length +\n ancestor.descendantsOfType('offtopic_handler').length > 0\n if (!hasHandlers) {\n const { line, col } = nodePosition(interactNode)\n messages.push({\n file, line, col, severity: 'warning', code: 'W006',\n message: 'This state calls interact but has no handlers (on intent/offtopic). This will trap the agent.',\n })\n }\n }\n\n // Semantic FSM validation via behavior-parser WASM. This always parses the\n // file's own `text` — never `mergedText` — so E006 and node positions below\n // (W009) stay anchored to real locations in the file the editor has open.\n const fsmResult = parseBehaviorFile(text)\n if (fsmResult.ok === null) {\n const firstMsg = fsmResult.diagnostics[0]?.message ?? 'Parse error'\n messages.push({\n file, line: 1, col: 1, severity: 'error', code: 'E006',\n message: `Parse error: ${firstMsg}`,\n })\n return messages\n }\n\n const fsm = fsmResult.ok\n\n // Reachability (used by W001/W009) should see the whole merge component\n // when it's known, so a state only ever reached from a merged sibling file\n // isn't wrongly flagged — but we still only *report* on states declared in\n // this file, at positions from this file's own tree.\n const wholeFsm = mergedText !== undefined ? parseBehaviorFile(mergedText).ok : null\n const reachabilityStates = wholeFsm?.states ?? fsm.states\n const allTargets = new Set(collectTransitionTargets(reachabilityStates.flatMap(s => s.body)))\n\n // W001: isolated state (no incoming and no outgoing transitions)\n for (const state of fsm.states) {\n const hasOutgoing = collectTransitionTargets(state.body).length > 0\n const hasIncoming = allTargets.has(state.name)\n if (!hasIncoming && !hasOutgoing) {\n messages.push({\n file, line: 1, col: 1, severity: 'warning', code: 'W001',\n message: `State \"${state.name}\" has no transitions`,\n })\n }\n }\n\n // W009: unreachable state (no incoming transitions, not the first state)\n for (let i = 1; i < fsm.states.length; i++) {\n const state = fsm.states[i]\n if (!allTargets.has(state.name)) {\n const stateNode = nodesOfType(tree, 'state_decl')\n .find(n => n.childForFieldName('name')?.text === state.name)\n const pos = stateNode ? nodePosition(stateNode) : { line: 1, col: 1 }\n messages.push({\n file, line: pos.line, col: pos.col, severity: 'warning', code: 'W009',\n message: `State '${state.name}' is unreachable — no other state transitions to it.`,\n })\n }\n }\n\n if (consolidated) {\n // E015/E016/W014 are whole-tree facts. When `mergedText` is given, derive\n // them from it instead of the local `fsm` — this is the only place a\n // merged-text FSM should be consulted, and it never affects positions\n // (all three report at a synthetic line 1 col 1, never a node position).\n const wholeTreeFsm = wholeFsm ?? fsm\n\n // E015: duplicate state name across merged files\n const seenStates = new Set<string>()\n for (const state of wholeTreeFsm.states) {\n if (seenStates.has(state.name)) {\n messages.push({\n file, line: 1, col: 1, severity: 'error', code: 'E015',\n message: `Duplicate state '${state.name}' across merged files — each state name must be unique in the consolidated FSM.`,\n })\n } else {\n seenStates.add(state.name)\n }\n }\n\n // E016: init state missing\n if (!wholeTreeFsm.states.some(s => s.name === 'init')) {\n messages.push({\n file, line: 1, col: 1, severity: 'error', code: 'E016',\n message: `Required 'init' state is missing. Add a state named 'init' as the entry point of your behavior.`,\n })\n }\n\n // W014: duplicate global trigger event across merged files\n const seenTriggers = new Set<string>()\n for (const trigger of wholeTreeFsm.global_triggers) {\n if (seenTriggers.has(trigger.event)) {\n messages.push({\n file, line: 1, col: 1, severity: 'warning', code: 'W014',\n message: `Duplicate global trigger '${trigger.event}' across merged files — only the last definition takes effect.`,\n })\n } else {\n seenTriggers.add(trigger.event)\n }\n }\n }\n\n return messages\n}\n\nexport async function createLinter() {\n return { lintDescription, lintBehavior }\n}\n","// Copyright 2026 Danilo Borges\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport JSZip from 'jszip'\nimport { readFile, writeFile } from 'fs/promises'\nexport { createZip, extractFiles } from './zip-core.js'\nimport {\n validateMagicBytes as validateMagicBytesCore,\n validateZipBomb as validateZipBombCore,\n} from './zip-core.js'\n\nexport async function readZip(filePath: string): Promise<JSZip> {\n const data = await readFile(filePath)\n return JSZip.loadAsync(data)\n}\n\nexport async function validateZipBomb(filePath: string): Promise<boolean> {\n const data = await readFile(filePath)\n const zip = await JSZip.loadAsync(data)\n validateZipBombCore(zip, data.length)\n return true\n}\n\nexport async function validateMagicBytes(filePath: string): Promise<boolean> {\n const data = await readFile(filePath)\n validateMagicBytesCore(data)\n return true\n}\n\nexport async function writeZip(zip: JSZip, outPath: string): Promise<void> {\n const data = await zip.generateAsync({ type: 'arraybuffer' })\n await writeFile(outPath, Buffer.from(data))\n}\n","// Copyright 2026 Danilo Borges\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n\nimport type { DescriptionFile, TypeDefinition, PropertyType, AnnotatedRef } from './types.js'\n\nconst STD_BASE = 'https://dot-agent.dev/schema/std/v1/'\n\nfunction propertyTypeToSchema(pt: PropertyType): object {\n switch (pt.kind) {\n case 'primitive':\n return { type: pt.value }\n case 'reference':\n return pt.value.startsWith('std.')\n ? { $ref: `${STD_BASE}${pt.value.slice(4)}.json` }\n : { $ref: `#/$defs/${pt.value}` }\n case 'array':\n return { type: 'array', items: propertyTypeToSchema(pt.value) }\n case 'enum':\n return { type: 'string', enum: pt.value }\n }\n}\n\nfunction typeDefinitionToSchema(td: TypeDefinition): object {\n const required = td.properties.filter(p => !p.is_optional).map(p => p.name)\n const properties: Record<string, object> = {}\n for (const p of td.properties) {\n properties[p.name] = {\n ...propertyTypeToSchema(p.type),\n ...(p.description ? { description: p.description } : {}),\n }\n }\n return {\n $schema: 'https://json-schema.org/draft/2020-12/schema',\n 'x-category': td.category.uri,\n ...(td.category.label ? { 'x-category-label': td.category.label } : {}),\n ...(td.concept ? { 'x-concept': td.concept.uri } : {}),\n ...(td.concept?.label ? { 'x-concept-label': td.concept.label } : {}),\n type: 'object',\n properties,\n ...(required.length ? { required } : {}),\n }\n}\n\nfunction refFromAnnotatedRef(ref: AnnotatedRef): object {\n return ref.name.startsWith('std.')\n ? { $ref: `${STD_BASE}${ref.name.slice(4)}.json` }\n : { $ref: `#/$defs/${ref.name}` }\n}\n\n/** Returns JSON Schema 2020-12 string for types.json, or null if nothing to write. */\nexport function buildTypesJson(df: DescriptionFile): string | null {\n if (df.types.length === 0 && df.input.length === 0 && df.output.length === 0) return null\n\n const defs: Record<string, object> = {}\n for (const td of df.types) {\n defs[td.name] = typeDefinitionToSchema(td)\n }\n\n return JSON.stringify(\n {\n ...(df.input.length ? { input: df.input.map(refFromAnnotatedRef) } : {}),\n ...(df.output.length ? { output: df.output.map(refFromAnnotatedRef) } : {}),\n ...(Object.keys(defs).length ? { $defs: defs } : {}),\n },\n null,\n 2\n )\n}\n","// Copyright 2026 Danilo Borges\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n\nimport { readFile, stat, readdir } from 'fs/promises'\nimport { join, basename, resolve, relative, isAbsolute, normalize, dirname } from 'path'\nimport { execSync } from 'child_process'\nimport { createHash } from 'crypto'\nimport JSZip from 'jszip'\nimport type { LintMessage, PackOptions, PackResult, Statement } from './types.js'\nimport { lintDescription, lintBehavior } from './linter.js'\nimport { buildId, slugify, isValidVersion } from './id.js'\nimport { buildAboutme, aboutmeToJson } from './manifest.js'\nimport { initBehaviorParser, parseDescriptionFile, parseBehaviorFile } from './parser.js'\nimport { buildTypesJson } from './schema.js'\nimport { writeZip } from './zip.js'\nimport { COMPILER_VERSION } from './generated-version.js'\n\nfunction gitRevParseShort(): string | null {\n try {\n return execSync('git rev-parse --short HEAD', { stdio: 'pipe', encoding: 'utf-8' }).trim()\n } catch {\n return null\n }\n}\n\nasync function resolveCommit(explicit?: string): Promise<string | undefined> {\n if (explicit) return explicit\n return gitRevParseShort() ?? undefined\n}\n\n// ── Version resolution ────────────────────────────────────────────────────────\n\ninterface VersionCandidate {\n version: string\n label: string\n}\n\n// The repo's tags are all monorepo-style `<pkg>@<version>` (there is no plain\n// vX.Y.Z release tag convention here). Rather than guess which tag belongs to\n// the directory being packed, list the most recent tags with their package\n// context and let a human pick — precision comes from judgment, not a\n// heuristic that can silently attribute the wrong package's version.\nfunction recentTagCandidates(limit = 5): VersionCandidate[] {\n let tags: string[]\n try {\n tags = execSync('git tag --sort=-creatordate', { stdio: 'pipe', encoding: 'utf-8' })\n .trim()\n .split('\\n')\n .filter(Boolean)\n } catch {\n return []\n }\n return tags\n .slice(0, limit)\n .map((tag): VersionCandidate => {\n const atIdx = tag.lastIndexOf('@')\n const version = atIdx === -1 ? tag : tag.slice(atIdx + 1)\n const label = atIdx === -1 ? tag : `${version} (tag: ${tag})`\n return { version, label }\n })\n .filter(c => isValidVersion(c.version))\n}\n\n// String sentinels (not symbols) — @clack/prompts' select() types `value` as\n// `string`, and these are extremely unlikely to collide with a real tag-derived version.\nconst CUSTOM_VERSION = '__dot-agent-custom-version__'\nconst BARE_VERSION = '__dot-agent-bare-version__'\n\n// No hardcoded version default — an unresolved version produces a form A\n// (bare) id per docs/reference/agent-id.md, rather than fabricating one.\nasync function resolveVersionInteractive(explicit?: string): Promise<string | undefined> {\n if (explicit) {\n if (!isValidVersion(explicit)) {\n throw new Error(`E019: Invalid version format '${explicit}' — expected vX.Y[.Z][-prerelease] or X.Y[.Z][-prerelease]`)\n }\n return explicit\n }\n\n if (!process.stdin.isTTY || !process.stdout.isTTY) {\n process.stderr.write('[dot-agent] no TTY and no --version — packing without a version\\n')\n return undefined\n }\n\n const candidates = recentTagCandidates()\n\n // @clack/prompts is ESM-only — dynamic import() resolves it correctly\n // regardless of whether this package itself is consumed as ESM or CJS\n // (a static import would break `require()` callers), and it also means the\n // non-interactive paths above never pay to load it at all.\n const clack = await import('@clack/prompts')\n\n const choice = await clack.select({\n message: 'Choose a version for this package',\n options: [\n ...candidates.map(c => ({ value: c.version, label: c.label })),\n { value: CUSTOM_VERSION, label: 'Type a custom version…' },\n { value: BARE_VERSION, label: 'None (bare — no version)' },\n ],\n })\n\n if (clack.isCancel(choice)) {\n clack.cancel('Pack cancelled.')\n process.exit(1)\n }\n\n if (choice === BARE_VERSION) return undefined\n\n if (choice === CUSTOM_VERSION) {\n const typed = await clack.text({\n message: 'Version',\n validate: v => (v && isValidVersion(v) ? undefined : 'Invalid version format — expected vX.Y[.Z][-prerelease] or X.Y[.Z][-prerelease]'),\n })\n if (clack.isCancel(typed)) {\n clack.cancel('Pack cancelled.')\n process.exit(1)\n }\n return typed\n }\n\n return choice as string\n}\n\n// ── Path safety ──────────────────────────────────────────────────────────────\n\nfunction isExternalPath(agentRoot: string, declaredPath: string): boolean {\n if (isAbsolute(declaredPath)) return true\n const normRoot = normalize(resolve(agentRoot))\n const resolved = resolve(normRoot, declaredPath)\n return relative(normRoot, resolved).startsWith('..')\n}\n\n// ── Description file discovery ────────────────────────────────────────────────\n\nexport async function discoverDescriptionFile(dir: string, explicit?: string): Promise<string> {\n if (explicit) {\n try {\n await stat(join(dir, explicit))\n return explicit\n } catch {\n throw new Error(`E003: Description file '${explicit}' not found in ${dir}`)\n }\n }\n const entries = await readdir(dir)\n const descFiles = entries.filter(f => f.endsWith('.description'))\n if (descFiles.length === 0) {\n throw new Error(`E003: No .description file found in ${dir}`)\n }\n if (descFiles.length > 1) {\n throw new Error(`E003: Multiple .description files found: ${descFiles.join(', ')} — use PackOptions.description to specify one`)\n }\n const name = descFiles[0]\n if (name !== 'agent.description') {\n console.info(`[dot-agent] using description file: ${name}`)\n }\n return name\n}\n\n// ── Merge graph consolidation ─────────────────────────────────────────────────\n\ninterface ConsolidateResult {\n mergedText: string\n mergeSources: string[] // relative paths within agent root, e.g. [\"main.behavior\"]\n}\n\nexport async function consolidate(agentRoot: string, entryFile: string): Promise<ConsolidateResult> {\n await initBehaviorParser()\n const normRoot = normalize(resolve(agentRoot))\n const visiting = new Set<string>()\n const visited = new Set<string>()\n const order: string[] = []\n const textCache = new Map<string, string>()\n\n async function dfs(relPath: string): Promise<void> {\n const absPath = resolve(normRoot, relPath)\n\n if (visiting.has(absPath)) {\n throw new Error(`E013: Circular merge dependency involving '${relPath}'`)\n }\n if (visited.has(absPath)) return\n\n visiting.add(absPath)\n\n let fileText: string\n try {\n fileText = await readFile(absPath, 'utf-8')\n } catch {\n throw new Error(`E012: Merge target not found: '${relPath}'`)\n }\n textCache.set(absPath, fileText)\n\n const result = parseBehaviorFile(fileText)\n const merges = result.ok?.merges ?? []\n\n for (const mergePath of merges) {\n if (isAbsolute(mergePath)) {\n throw new Error(`E014: Merge path '${mergePath}' in '${relPath}' is absolute — only paths within the agent root are allowed`)\n }\n const mergeAbs = resolve(dirname(absPath), mergePath)\n const mergeRel = relative(normRoot, mergeAbs)\n if (mergeRel.startsWith('..')) {\n throw new Error(`E014: Merge path '${mergePath}' in '${relPath}' escapes the agent root`)\n }\n await dfs(mergeRel)\n }\n\n visiting.delete(absPath)\n visited.add(absPath)\n order.push(relPath)\n }\n\n await dfs(entryFile)\n\n const texts = order.map(relPath => textCache.get(resolve(normRoot, relPath))!)\n return {\n mergedText: texts.join('\\n'),\n mergeSources: order,\n }\n}\n\n// ── guide/teach file references ───────────────────────────────────────────────\n\n// `guide \"...\"` / `teach \"...\"` text is either inline orientation prose or a\n// filename to bundle alongside the agent (e.g. `teach \"recipes.txt\"`). A\n// trailing .txt/.md is the only signal we have to tell them apart — anything\n// else stays literal, embedded verbatim in the flattened agent.behavior.\nconst FILE_REF_RE = /\\.(txt|md)$/i\n\ninterface FileRef {\n kind: 'guide' | 'teach'\n text: string\n}\n\nfunction collectFileRefs(stmts: Statement[], out: Map<string, FileRef>): void {\n for (const s of stmts) {\n switch (s.type) {\n case 'guide_stmt':\n if (FILE_REF_RE.test(s.text)) out.set(`guide:${s.text}`, { kind: 'guide', text: s.text })\n break\n case 'teach_stmt':\n if (FILE_REF_RE.test(s.text)) out.set(`teach:${s.text}`, { kind: 'teach', text: s.text })\n break\n case 'interact_stmt':\n collectFileRefs(s.handlers, out)\n break\n case 'intent_handler':\n if (Array.isArray(s.body)) collectFileRefs(s.body, out)\n break\n case 'offtopic_handler':\n case 'after_stmt':\n case 'parallel_stmt':\n collectFileRefs(s.body, out)\n break\n case 'conditional_stmt':\n collectFileRefs(s.then, out)\n if (s.else) collectFileRefs(s.else, out)\n break\n }\n }\n}\n\n// ── File collection ───────────────────────────────────────────────────────────\n\nfunction namespaceOf(kind: FileRef['kind']): 'guides' | 'knowledge' {\n return kind === 'guide' ? 'guides' : 'knowledge'\n}\n\nasync function collectBehaviorFileRefs(mergedBehaviorText: string): Promise<Map<string, FileRef>> {\n await initBehaviorParser()\n const refs = new Map<string, FileRef>()\n const behaviorAst = parseBehaviorFile(mergedBehaviorText).ok\n if (!behaviorAst) return refs\n for (const state of behaviorAst.states) collectFileRefs(state.body, refs)\n for (const trigger of behaviorAst.global_triggers) collectFileRefs(trigger.body, refs)\n return refs\n}\n\n// Every file under guides/ or knowledge/, keyed by the bundle path it *would*\n// occupy. Nothing here reaches the bundle on its own — only a guide/teach\n// reference pulls a file in (see collectFiles) — so this exists solely to let\n// findOrphanContentFiles report the files that never make it.\nasync function listContentFiles(dir: string, ns: 'guides' | 'knowledge'): Promise<string[]> {\n const found: string[] = []\n\n async function walk(subdir: string, prefix: string) {\n let entries: string[]\n try {\n entries = await readdir(subdir)\n } catch {\n return // directory doesn't exist or can't be read\n }\n for (const entry of entries) {\n if (entry.startsWith('.')) continue\n const fullPath = join(subdir, entry)\n const relativePath = `${prefix}/${entry}`\n if ((await stat(fullPath)).isDirectory()) {\n await walk(fullPath, relativePath)\n } else {\n found.push(relativePath)\n }\n }\n }\n\n await walk(join(dir, ns), ns)\n return found\n}\n\n// A file in guides/ or knowledge/ that no guide/teach statement names is absent\n// from the bundle under the linked-only rule — and would be unreachable at runtime\n// even if it were bundled, since the kernel hands the LLM a bare filename via the\n// teach effect and the MCP server exposes no listing endpoint. W015 is what keeps\n// that from being a silent drop, including for something like knowledge/data.csv\n// that FILE_REF_RE never recognises as a file reference to begin with.\nexport async function findOrphanContentFiles(\n dir: string,\n mergedBehaviorText: string,\n): Promise<LintMessage[]> {\n const refs = await collectBehaviorFileRefs(mergedBehaviorText)\n const referenced = new Set<string>()\n for (const { kind, text } of refs.values()) referenced.add(`${namespaceOf(kind)}/${text}`)\n\n const onDisk = [\n ...(await listContentFiles(dir, 'guides')),\n ...(await listContentFiles(dir, 'knowledge')),\n ]\n\n return onDisk\n .filter(path => !referenced.has(path))\n .map((path): LintMessage => ({\n file: path,\n line: 1,\n col: 1,\n severity: 'warning',\n code: 'W015',\n message: `'${path}' is not referenced by any guide or teach statement — it will not be included in the bundle`,\n }))\n}\n\nexport async function collectFiles(\n dir: string,\n descriptionFile: string,\n mergedBehaviorText: string,\n mergeSources: string[],\n personaFile?: string,\n): Promise<Map<string, string>> {\n const files = new Map<string, string>()\n\n files.set(descriptionFile, await readFile(join(dir, descriptionFile), 'utf-8'))\n // mergedBehaviorText is a literal concatenation of every merged file's raw\n // source (see consolidate() above), so a `merge \"...\"` line from the entry\n // file survives verbatim even though every state it would pull in is\n // already inlined by the concatenation. Left in, a runtime that re-parses\n // this flat file (e.g. AgentSession.start() in @dot-agent/sdk) treats it as\n // a live merge directive and tries to re-resolve it against a differently\n // keyed bundle, failing with \"files not found\". It's dead once flattened —\n // strip it. Safe to do after linting (above), which already ran on the\n // unstripped text.\n const flatBehaviorText = mergedBehaviorText.replace(/^\\s*merge\\s+\"[^\"]*\"\\s*$/gm, '')\n files.set('agent.behavior', flatBehaviorText)\n\n for (const relPath of mergeSources) {\n files.set(`behaviors/${relPath}`, await readFile(join(dir, relPath), 'utf-8'))\n }\n\n if (personaFile) {\n if (isExternalPath(dir, personaFile)) {\n throw new Error(`E014: persona path '${personaFile}' in '${descriptionFile}' is absolute or escapes the agent root`)\n }\n let personaText: string\n try {\n personaText = await readFile(join(dir, personaFile), 'utf-8')\n } catch {\n throw new Error(`E_DESC: persona file '${personaFile}' declared in '${descriptionFile}' not found`)\n }\n files.set(personaFile, personaText)\n }\n\n // A `guide \"intro.md\"` / `teach \"recipes.txt\"` reference is the only thing that\n // pulls a content file into the bundle — guides/ and knowledge/ are not swept\n // wholesale, so the bundle is a function of the behavior graph rather than of\n // whatever happens to sit in the directory. Resolve against the recommended\n // layout (guides/<text>, knowledge/<text>) first, then fall back to a file\n // sitting loose next to agent.behavior; either way it lands under <ns>/ in the\n // bundle. findOrphanContentFiles() reports what this loop leaves behind.\n const refs = await collectBehaviorFileRefs(mergedBehaviorText)\n for (const { kind, text } of refs.values()) {\n if (isExternalPath(dir, text)) {\n throw new Error(`E014: '${kind}' path '${text}' is absolute or escapes the agent root`)\n }\n const ns = namespaceOf(kind)\n const nsPath = `${ns}/${text}`\n\n let content: string | undefined\n for (const candidate of [join(dir, ns, text), join(dir, text)]) {\n try {\n content = await readFile(candidate, 'utf-8')\n break\n } catch {\n // fall through to the next candidate\n }\n }\n if (content === undefined) {\n throw new Error(\n `E018: '${kind}' file '${text}' referenced in agent.behavior not found in ${dir} — looked for '${nsPath}' and '${text}'`\n )\n }\n\n files.set(nsPath, content)\n }\n\n return files\n}\n\n// The bundle extension is always .agent — append it when the caller left it off\n// rather than requiring `--out foo.agent` to be typed out every time.\nfunction withAgentExtension(path: string): string {\n return path.endsWith('.agent') ? path : `${path}.agent`\n}\n\nexport async function pack(options: PackOptions = {}): Promise<PackResult> {\n const dir = options.dir ?? process.cwd()\n const outPath = withAgentExtension(options.out ?? join(dir, basename(dir)))\n\n // 1. Discover and read description file\n const descriptionFileName = await discoverDescriptionFile(dir, options.description)\n const descriptionText = await readFile(join(dir, descriptionFileName), 'utf-8')\n\n // 2. Lint description — fail fast on errors (E017, E004, etc.)\n const descriptionMessages = await lintDescription(descriptionText, descriptionFileName)\n const descErrors = descriptionMessages.filter(m => m.severity === 'error')\n if (descErrors.length > 0) {\n throw new Error(\n `Lint failed:\\n${descErrors.map(e => ` ${e.file}:${e.line}:${e.col} ${e.code} ${e.message}`).join('\\n')}`\n )\n }\n\n // 3. Init WASM parser (needed for parseDescriptionFile and consolidate)\n await initBehaviorParser()\n\n // 4. Parse description to get df.behavior\n const descResult = parseDescriptionFile(descriptionText)\n if (descResult.ok === null) {\n const firstError = descResult.diagnostics.find(d => d.severity === 'error')\n throw new Error(`E_DESC: ${firstError?.message ?? 'parse failed'}`)\n }\n const df = descResult.ok\n\n // 5. Validate df.behavior\n if (!df.behavior) {\n throw new Error(`E_DESC: '${descriptionFileName}' must declare a behavior file — add 'behavior \"agent.behavior\"' (or the name of your entry .behavior file)`)\n }\n if (isExternalPath(dir, df.behavior)) {\n throw new Error(`E014: behavior path '${df.behavior}' in '${descriptionFileName}' is absolute or escapes the agent root`)\n }\n\n // 6. Consolidate merge graph → single merged text\n const { mergedText, mergeSources } = await consolidate(dir, df.behavior)\n\n // 7. Lint consolidated behavior (E015, E016, W014 only fire when consolidated=true)\n const behaviorMessages = await lintBehavior(mergedText, 'agent.behavior', undefined, true)\n const allMessages = [...descriptionMessages, ...behaviorMessages]\n const errors = allMessages.filter(m => m.severity === 'error')\n const lintWarnings = allMessages.filter(m => m.severity === 'warning')\n\n if (errors.length > 0) {\n throw new Error(\n `Lint failed:\\n${errors.map(e => ` ${e.file}:${e.line}:${e.col} ${e.code} ${e.message}`).join('\\n')}`\n )\n }\n\n // 8. Collect all files for the bundle\n const version = await resolveVersionInteractive(options.version)\n const commit = await resolveCommit(options.commit)\n const allFiles = await collectFiles(dir, descriptionFileName, mergedText, mergeSources, df.persona ?? undefined)\n const warnings = [...lintWarnings, ...(await findOrphanContentFiles(dir, mergedText))]\n\n const contentForHash = Array.from(allFiles.values()).join('')\n const sha256 = createHash('sha256').update(contentForHash).digest('hex')\n\n const namespace = df.agent.domain ?? 'unknown'\n // digest requires version (buildId's own invariant) — a bare (versionless)\n // id never carries a digest either, even if a commit sha is available.\n const id = buildId({ namespace, name: slugify(df.agent.name), version, digest: version ? commit : undefined })\n\n const typesJson = buildTypesJson(df)\n const integrity = {\n sha256,\n ...(typesJson ? { types: '.agent/types.json' } : {}),\n files: '.agent/files.json',\n }\n\n const aboutme = buildAboutme({\n id,\n name: df.agent.name,\n description: df.description ?? '',\n version: version ?? '',\n domain: df.agent.domain ?? '',\n license: df.agent.license ?? '',\n persona: df.persona ?? undefined,\n purpose: 'unknown',\n compiler: `dot-agent/${COMPILER_VERSION}`,\n commit,\n capabilities: df.capabilities.map(c => ({ id: c.name, description: c.description ?? '' })),\n requires: df.requires,\n integrity,\n })\n\n const zip = new JSZip()\n const agentFolder = zip.folder('.agent')!\n agentFolder.file('aboutme.json', aboutmeToJson(aboutme))\n\n if (typesJson) {\n agentFolder.file('types.json', typesJson)\n }\n\n const filesJson = {\n description: descriptionFileName,\n behavior: 'agent.behavior',\n ...(df.persona ? { persona: df.persona } : {}),\n behaviors: Array.from(allFiles.keys()).filter(f => f.startsWith('behaviors/')),\n guides: Array.from(allFiles.keys()).filter(f => f.startsWith('guides/')),\n knowledge: Array.from(allFiles.keys()).filter(f => f.startsWith('knowledge/')),\n }\n agentFolder.file('files.json', JSON.stringify(filesJson, null, 2))\n\n for (const [path, content] of allFiles) {\n zip.file(path, content)\n }\n\n await writeZip(zip, outPath)\n\n return { path: outPath, id, warnings }\n}\n","// Copyright 2026 Danilo Borges\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n\nimport { readFile } from 'fs/promises'\nimport { join } from 'path'\nimport { createHash } from 'crypto'\nimport type { AgentBundle, AgentFiles } from './types.js'\nimport { discoverDescriptionFile, consolidate, collectFiles, findOrphanContentFiles } from './pack.js'\nimport { lintDescription, lintBehavior } from './linter.js'\nimport { buildId, slugify } from './id.js'\nimport { buildAboutme } from './manifest.js'\nimport { initBehaviorParser, parseDescriptionFile } from './parser.js'\nimport { COMPILER_VERSION } from './generated-version.js'\n\nexport async function bundleFromDir(dir: string): Promise<AgentBundle> {\n const descriptionFileName = await discoverDescriptionFile(dir)\n const descriptionText = await readFile(join(dir, descriptionFileName), 'utf-8')\n\n const descMessages = await lintDescription(descriptionText, descriptionFileName)\n const descErrors = descMessages.filter(m => m.severity === 'error')\n if (descErrors.length > 0) {\n throw new Error(\n `Lint failed:\\n${descErrors.map(e => ` ${e.file}:${e.line}:${e.col} ${e.code} ${e.message}`).join('\\n')}`\n )\n }\n\n await initBehaviorParser()\n const descResult = parseDescriptionFile(descriptionText)\n if (descResult.ok === null) {\n const firstError = descResult.diagnostics.find(d => d.severity === 'error')\n throw new Error(`E_DESC: ${firstError?.message ?? 'parse failed'}`)\n }\n const df = descResult.ok\n\n if (!df.behavior) {\n throw new Error(`E_DESC: '${descriptionFileName}' must declare a behavior file`)\n }\n\n const { mergedText, mergeSources } = await consolidate(dir, df.behavior)\n\n const behaviorMessages = await lintBehavior(mergedText, 'agent.behavior', undefined, true)\n const orphanMessages = await findOrphanContentFiles(dir, mergedText)\n const allMessages = [...descMessages, ...behaviorMessages, ...orphanMessages]\n const errors = allMessages.filter(m => m.severity === 'error')\n const warnings = allMessages.filter(m => m.severity === 'warning')\n\n if (errors.length > 0) {\n throw new Error(\n `Lint failed:\\n${errors.map(e => ` ${e.file}:${e.line}:${e.col} ${e.code} ${e.message}`).join('\\n')}`\n )\n }\n\n for (const w of warnings) {\n process.stderr.write(`\\x1b[33m⚠\\x1b[0m ${w.file}:${w.line}:${w.col} ${w.code} ${w.message}\\n`)\n }\n\n const allFiles = await collectFiles(dir, descriptionFileName, mergedText, mergeSources, df.persona ?? undefined)\n\n const sha256 = createHash('sha256')\n .update(Array.from(allFiles.values()).join(''))\n .digest('hex')\n\n const id = buildId({ namespace: df.agent.domain ?? 'unknown', name: slugify(df.agent.name), version: 'dev' })\n\n const aboutme = buildAboutme({\n id,\n name: df.agent.name,\n description: df.description ?? '',\n version: 'dev',\n domain: df.agent.domain ?? '',\n license: df.agent.license ?? '',\n persona: df.persona ?? undefined,\n purpose: 'development',\n compiler: `dot-agent/${COMPILER_VERSION}`,\n capabilities: df.capabilities.map(c => ({ id: c.name, description: c.description ?? '' })),\n requires: df.requires,\n integrity: { sha256, files: '.agent/files.json' },\n })\n\n const files: AgentFiles = {\n description: descriptionText,\n // Reuse collectFiles()'s 'agent.behavior' entry rather than the raw\n // mergedText — it has redundant `merge \"...\"` lines stripped (see\n // collectFiles() for why they're dead weight once flattened).\n behavior: allFiles.get('agent.behavior') ?? mergedText,\n persona: df.persona ? allFiles.get(df.persona) : undefined,\n guides: Array.from(allFiles.entries())\n .filter(([p]) => p.startsWith('guides/'))\n .map(([path, content]) => ({ path, content })),\n knowledge: Array.from(allFiles.entries())\n .filter(([p]) => p.startsWith('knowledge/'))\n .map(([path, content]) => ({ path, content })),\n behaviors: Array.from(allFiles.entries())\n .filter(([p]) => p.startsWith('behaviors/'))\n .map(([path, content]) => ({ path, content })),\n }\n\n return { id, aboutme, files }\n}\n"],"mappings":";;;;;;;;;;;AAeA,MAAM,EAAE,qBAAqB,qBADb,cAAc,OAAO,KAAK,GACc,CAAC,CAAC,wBAAwB;AAKlF,IAAI,eAAe;AACnB,IAAI;AACJ,IAAI;AACJ,IAAI,iBAAiB;AAErB,eAAsB,qBAAoC;CACxD,IAAI,gBAAgB;CACpB,MAAMA,KAAO;CACb,iBAAiB;AACnB;AAOA,SAAgB,kBAAkB,MAAyC;CACzE,OAAO,KAAK,MAAMC,eAAgB,IAAI,CAAC;AACzC;AAEA,SAAgB,qBAAqB,MAA4C;CAC/E,OAAO,KAAK,MAAMC,kBAAmB,IAAI,CAAC;AAC5C;AAEA,S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T,UAAU,aAAa;GACvB,cAAc,GAAG,aAAa,KAAI,OAAM;IAAE,IAAI,EAAE;IAAM,aAAa,EAAE,eAAe;GAAG,EAAE;GACzF,UAAU,GAAG;GACb,WAAW;IAAE;IAAQ,OAAO;GAAoB;EAClD,CAoBmB;EAAG,OAAA;GAjBpB,aAAa;GAIb,UAAU,SAAS,IAAI,gBAAgB,KAAK;GAC5C,SAAS,GAAG,UAAU,SAAS,IAAI,GAAG,OAAO,IAAI,KAAA;GACjD,QAAQ,MAAM,KAAK,SAAS,QAAQ,CAAC,CAAC,CACnC,QAAQ,CAAC,OAAO,EAAE,WAAW,SAAS,CAAC,CAAC,CACxC,KAAK,CAAC,MAAM,cAAc;IAAE;IAAM;GAAQ,EAAE;GAC/C,WAAW,MAAM,KAAK,SAAS,QAAQ,CAAC,CAAC,CACtC,QAAQ,CAAC,OAAO,EAAE,WAAW,YAAY,CAAC,CAAC,CAC3C,KAAK,CAAC,MAAM,cAAc;IAAE;IAAM;GAAQ,EAAE;GAC/C,WAAW,MAAM,KAAK,SAAS,QAAQ,CAAC,CAAC,CACtC,QAAQ,CAAC,OAAO,EAAE,WAAW,YAAY,CAAC,CAAC,CAC3C,KAAK,CAAC,MAAM,cAAc;IAAE;IAAM;GAAQ,EAAE;EAGvB;CAAE;AAC9B"}
@@ -0,0 +1,123 @@
1
+ import { AgentDecl, AnnotatedRef, BehaviorFile, DescriptionFile, OntologyRef, PropertyDecl, PropertyType, StateDef, Statement, TriggerDecl, TypeDefinition } from "@dot-agent/parser-dsl";
2
+ import JSZip from "jszip";
3
+ //#region src/types.d.ts
4
+ type LangId = 'description' | 'behavior';
5
+ /** Structured diagnostic from the Rust WASM parser. */
6
+ interface ParseDiagnostic {
7
+ severity: 'error' | 'warning' | 'info' | 'hint';
8
+ code: string;
9
+ message: string;
10
+ hint?: string;
11
+ /** [line, col] 1-based, absent when position is unavailable (e.g. serde errors). */
12
+ start?: [number, number];
13
+ end?: [number, number];
14
+ }
15
+ interface LintMessage {
16
+ file: string;
17
+ line: number;
18
+ col: number;
19
+ severity: 'error' | 'warning' | 'info' | 'hint';
20
+ code: string;
21
+ message: string;
22
+ hint?: string;
23
+ }
24
+ interface IdParts {
25
+ namespace: string;
26
+ name: string;
27
+ version?: string;
28
+ digest?: string;
29
+ }
30
+ interface Capability {
31
+ id: string;
32
+ description: string;
33
+ }
34
+ interface Integrity {
35
+ sha256: string;
36
+ types?: string;
37
+ files?: string;
38
+ }
39
+ interface AboutMe {
40
+ dslVersion: string;
41
+ id: string;
42
+ name: string;
43
+ description: string;
44
+ version: string;
45
+ domain: string;
46
+ license: string;
47
+ persona?: string;
48
+ purpose: string;
49
+ compiler: string;
50
+ commit?: string;
51
+ capabilities: Capability[];
52
+ requires: AnnotatedRef[];
53
+ integrity: Integrity;
54
+ }
55
+ interface AgentFiles {
56
+ description: string;
57
+ behavior: string;
58
+ persona?: string;
59
+ guides: Array<{
60
+ path: string;
61
+ content: string;
62
+ }>;
63
+ knowledge: Array<{
64
+ path: string;
65
+ content: string;
66
+ }>;
67
+ behaviors: Array<{
68
+ path: string;
69
+ content: string;
70
+ }>;
71
+ }
72
+ interface AgentBundle {
73
+ id: string;
74
+ aboutme: AboutMe;
75
+ files: AgentFiles;
76
+ }
77
+ interface PackOptions {
78
+ dir?: string;
79
+ out?: string;
80
+ commit?: string;
81
+ version?: string;
82
+ description?: string;
83
+ }
84
+ interface PackResult {
85
+ path: string;
86
+ id: string;
87
+ warnings: LintMessage[];
88
+ }
89
+ interface BuildAboutmeOptions {
90
+ id: string;
91
+ name: string;
92
+ description: string;
93
+ version: string;
94
+ domain: string;
95
+ license?: string;
96
+ persona?: string;
97
+ purpose?: string;
98
+ compiler: string;
99
+ commit?: string;
100
+ capabilities?: Capability[];
101
+ requires?: AnnotatedRef[];
102
+ integrity: Integrity;
103
+ }
104
+ //#endregion
105
+ //#region src/manifest.d.ts
106
+ declare function parseAboutme(json: any): AboutMe;
107
+ declare function buildAboutme(opts: BuildAboutmeOptions): AboutMe;
108
+ declare function aboutmeToJson(aboutme: AboutMe): string;
109
+ //#endregion
110
+ //#region src/id.d.ts
111
+ declare function parseId(id: string): IdParts;
112
+ declare function buildId(parts: IdParts): string;
113
+ declare function extractDigest(id: string): string;
114
+ declare function extractName(id: string): string;
115
+ //#endregion
116
+ //#region src/zip-core.d.ts
117
+ declare function validateMagicBytes(bytes: Uint8Array): void;
118
+ declare function validateZipBomb(zip: JSZip, compressedSize: number): void;
119
+ declare function createZip(): JSZip;
120
+ declare function extractFiles(zip: JSZip, filter?: string[]): Promise<Map<string, string>>;
121
+ //#endregion
122
+ export { PropertyType as A, LangId as C, PackResult as D, PackOptions as E, Statement as M, TriggerDecl as N, ParseDiagnostic as O, TypeDefinition as P, Integrity as S, OntologyRef as T, BehaviorFile as _, buildId as a, DescriptionFile as b, parseId as c, parseAboutme as d, AboutMe as f, AnnotatedRef as g, AgentFiles as h, validateZipBomb as i, StateDef as j, PropertyDecl as k, aboutmeToJson as l, AgentDecl as m, extractFiles as n, extractDigest as o, AgentBundle as p, validateMagicBytes as r, extractName as s, createZip as t, buildAboutme as u, BuildAboutmeOptions as v, LintMessage as w, IdParts as x, Capability as y };
123
+ //# sourceMappingURL=zip-core-BCiH0sUt.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"zip-core-BCiH0sUt.d.cts","names":[],"sources":["../src/types.ts","../src/manifest.ts","../src/id.ts","../src/zip-core.ts"],"mappings":";;;KAQY;;UAiCK;EACf;EACA;EACA;EACA;;EAEA;EACA;;UAGe;EACf;EACA;EACA;EACA;EACA;EACA;EACA;;UAGe;EACf;EACA;EACA;EACA;;UAGe;EACf;EACA;;UAGe;EACf;EACA;EACA;;UAGe;EACf;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,cAAc;EACd,UAAU;EACV,WAAW;;UAGI;EACf;EACA;EACA;EACA,QAAQ;IAAQ;IAAc;;EAC9B,WAAW;IAAQ;IAAc;;EACjC,WAAW;IAAQ;IAAc;;;UAGlB;EACf;EACA,SAAS;EACT,OAAO;;UAGQ;EACf;EACA;EACA;EACA;EACA;;UAGe;EACf;EACA;EACA,UAAU;;UAGK;EACf;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,eAAe;EACf,WAAW;EACX,WAAW;;;;iBC/HG,aAAa,YAAY;iBA6BzB,aAAa,MAAM,sBAAsB;iBAmBzC,cAAc,SAAS;;;iBCGvB,QAAQ,aAAa;iBAyCrB,QAAQ,OAAO;iBAsCf,cAAc;iBAQd,YAAY;;;iBClIZ,mBAAmB,OAAO;iBAM1B,gBAAgB,KAAK,OAAO;iBAa5B,aAAa;iBAIP,aAAa,KAAK,OAAO,oBAAoB,QAAQ"}
@@ -0,0 +1,123 @@
1
+ import { AgentDecl, AnnotatedRef, BehaviorFile, DescriptionFile, OntologyRef, PropertyDecl, PropertyType, StateDef, Statement, TriggerDecl, TypeDefinition } from "@dot-agent/parser-dsl";
2
+ import JSZip from "jszip";
3
+ //#region src/types.d.ts
4
+ type LangId = 'description' | 'behavior';
5
+ /** Structured diagnostic from the Rust WASM parser. */
6
+ interface ParseDiagnostic {
7
+ severity: 'error' | 'warning' | 'info' | 'hint';
8
+ code: string;
9
+ message: string;
10
+ hint?: string;
11
+ /** [line, col] 1-based, absent when position is unavailable (e.g. serde errors). */
12
+ start?: [number, number];
13
+ end?: [number, number];
14
+ }
15
+ interface LintMessage {
16
+ file: string;
17
+ line: number;
18
+ col: number;
19
+ severity: 'error' | 'warning' | 'info' | 'hint';
20
+ code: string;
21
+ message: string;
22
+ hint?: string;
23
+ }
24
+ interface IdParts {
25
+ namespace: string;
26
+ name: string;
27
+ version?: string;
28
+ digest?: string;
29
+ }
30
+ interface Capability {
31
+ id: string;
32
+ description: string;
33
+ }
34
+ interface Integrity {
35
+ sha256: string;
36
+ types?: string;
37
+ files?: string;
38
+ }
39
+ interface AboutMe {
40
+ dslVersion: string;
41
+ id: string;
42
+ name: string;
43
+ description: string;
44
+ version: string;
45
+ domain: string;
46
+ license: string;
47
+ persona?: string;
48
+ purpose: string;
49
+ compiler: string;
50
+ commit?: string;
51
+ capabilities: Capability[];
52
+ requires: AnnotatedRef[];
53
+ integrity: Integrity;
54
+ }
55
+ interface AgentFiles {
56
+ description: string;
57
+ behavior: string;
58
+ persona?: string;
59
+ guides: Array<{
60
+ path: string;
61
+ content: string;
62
+ }>;
63
+ knowledge: Array<{
64
+ path: string;
65
+ content: string;
66
+ }>;
67
+ behaviors: Array<{
68
+ path: string;
69
+ content: string;
70
+ }>;
71
+ }
72
+ interface AgentBundle {
73
+ id: string;
74
+ aboutme: AboutMe;
75
+ files: AgentFiles;
76
+ }
77
+ interface PackOptions {
78
+ dir?: string;
79
+ out?: string;
80
+ commit?: string;
81
+ version?: string;
82
+ description?: string;
83
+ }
84
+ interface PackResult {
85
+ path: string;
86
+ id: string;
87
+ warnings: LintMessage[];
88
+ }
89
+ interface BuildAboutmeOptions {
90
+ id: string;
91
+ name: string;
92
+ description: string;
93
+ version: string;
94
+ domain: string;
95
+ license?: string;
96
+ persona?: string;
97
+ purpose?: string;
98
+ compiler: string;
99
+ commit?: string;
100
+ capabilities?: Capability[];
101
+ requires?: AnnotatedRef[];
102
+ integrity: Integrity;
103
+ }
104
+ //#endregion
105
+ //#region src/manifest.d.ts
106
+ declare function parseAboutme(json: any): AboutMe;
107
+ declare function buildAboutme(opts: BuildAboutmeOptions): AboutMe;
108
+ declare function aboutmeToJson(aboutme: AboutMe): string;
109
+ //#endregion
110
+ //#region src/id.d.ts
111
+ declare function parseId(id: string): IdParts;
112
+ declare function buildId(parts: IdParts): string;
113
+ declare function extractDigest(id: string): string;
114
+ declare function extractName(id: string): string;
115
+ //#endregion
116
+ //#region src/zip-core.d.ts
117
+ declare function validateMagicBytes(bytes: Uint8Array): void;
118
+ declare function validateZipBomb(zip: JSZip, compressedSize: number): void;
119
+ declare function createZip(): JSZip;
120
+ declare function extractFiles(zip: JSZip, filter?: string[]): Promise<Map<string, string>>;
121
+ //#endregion
122
+ export { PropertyType as A, LangId as C, PackResult as D, PackOptions as E, Statement as M, TriggerDecl as N, ParseDiagnostic as O, TypeDefinition as P, Integrity as S, OntologyRef as T, BehaviorFile as _, buildId as a, DescriptionFile as b, parseId as c, parseAboutme as d, AboutMe as f, AnnotatedRef as g, AgentFiles as h, validateZipBomb as i, StateDef as j, PropertyDecl as k, aboutmeToJson as l, AgentDecl as m, extractFiles as n, extractDigest as o, AgentBundle as p, validateMagicBytes as r, extractName as s, createZip as t, buildAboutme as u, BuildAboutmeOptions as v, LintMessage as w, IdParts as x, Capability as y };
123
+ //# sourceMappingURL=zip-core-BCiH0sUt.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"zip-core-BCiH0sUt.d.mts","names":[],"sources":["../src/types.ts","../src/manifest.ts","../src/id.ts","../src/zip-core.ts"],"mappings":";;;KAQY;;UAiCK;EACf;EACA;EACA;EACA;;EAEA;EACA;;UAGe;EACf;EACA;EACA;EACA;EACA;EACA;EACA;;UAGe;EACf;EACA;EACA;EACA;;UAGe;EACf;EACA;;UAGe;EACf;EACA;EACA;;UAGe;EACf;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,cAAc;EACd,UAAU;EACV,WAAW;;UAGI;EACf;EACA;EACA;EACA,QAAQ;IAAQ;IAAc;;EAC9B,WAAW;IAAQ;IAAc;;EACjC,WAAW;IAAQ;IAAc;;;UAGlB;EACf;EACA,SAAS;EACT,OAAO;;UAGQ;EACf;EACA;EACA;EACA;EACA;;UAGe;EACf;EACA;EACA,UAAU;;UAGK;EACf;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,eAAe;EACf,WAAW;EACX,WAAW;;;;iBC/HG,aAAa,YAAY;iBA6BzB,aAAa,MAAM,sBAAsB;iBAmBzC,cAAc,SAAS;;;iBCGvB,QAAQ,aAAa;iBAyCrB,QAAQ,OAAO;iBAsCf,cAAc;iBAQd,YAAY;;;iBClIZ,mBAAmB,OAAO;iBAM1B,gBAAgB,KAAK,OAAO;iBAa5B,aAAa;iBAIP,aAAa,KAAK,OAAO,oBAAoB,QAAQ"}