@dot-agent/cli 1.0.0 → 1.0.2

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/AGENTS.md CHANGED
@@ -75,6 +75,15 @@ When adding a new agent, use this format:
75
75
 
76
76
  ---
77
77
 
78
+ ## Absolute Rules
79
+
80
+ **License headers are mandatory on every source file.** Before committing any `.ts`, `.tsx`, `.js`, or `.jsx` file you must ensure the correct header is present at the very top of the file:
81
+ - **New file** (all files in this project): full Apache 2.0 header, sole copyright Danilo Borges 2026.
82
+
83
+ The pre-commit hook (`scripts/ensure-license-headers.sh`, registered in `.githooks/pre-commit` via `git config core.hooksPath`) applies the headers automatically and re-stages patched files. After cloning the repository, run `npm install` to activate the hook. If you add a file programmatically and bypass the hook, inject the header manually before staging. Never remove or alter existing copyright notices.
84
+
85
+ ---
86
+
78
87
  ## Orchestration Rules
79
88
 
80
89
  When composing agents that have dependencies:
package/LICENSE ADDED
@@ -0,0 +1,185 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship made available under
36
+ the License, as indicated by a copyright notice that is included in
37
+ or attached to the work (an example is provided in the Appendix below).
38
+
39
+ "Derivative Works" shall mean any work, whether in Source or Object
40
+ form, that is based on (or derived from) the Work and for which the
41
+ editorial revisions, annotations, elaborations, or other modifications
42
+ represent, as a whole, an original work of authorship. For the purposes
43
+ of this License, Derivative Works shall not include works that remain
44
+ separable from, or merely link (or bind by name) to the interfaces of,
45
+ the Work and Derivative Works thereof.
46
+
47
+ "Contribution" shall mean, as submitted to the Licensor for inclusion
48
+ in the Work by the copyright owner or by an individual or Legal Entity
49
+ authorized to submit on behalf of the copyright owner. For the purposes
50
+ of this definition, "submitted" means any form of electronic, verbal,
51
+ or written communication sent to the Licensor or its representatives,
52
+ including but not limited to communication on electronic mailing lists,
53
+ source code control systems, and issue tracking systems that are managed
54
+ by, or on behalf of, the Licensor for the purpose of discussing and
55
+ improving the Work, but excluding communication that is conspicuously
56
+ marked or designated in writing by the copyright owner as "Not a
57
+ Contribution."
58
+
59
+ "Contributor" shall mean Licensor and any Legal Entity on behalf of
60
+ whom a Contribution has been received by the Licensor and included
61
+ within the Work.
62
+
63
+ 2. Grant of Copyright License. Subject to the terms and conditions of
64
+ this License, each Contributor hereby grants to You a perpetual,
65
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
66
+ copyright license to reproduce, prepare Derivative Works of,
67
+ publicly display, publicly perform, sublicense, and distribute the
68
+ Work and such Derivative Works in Source or Object form.
69
+
70
+ 3. Grant of Patent License. Subject to the terms and conditions of
71
+ this License, each Contributor hereby grants to You a perpetual,
72
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
73
+ (except as stated in this section) patent license to make, have made,
74
+ use, offer to sell, sell, import, and otherwise transfer the Work,
75
+ where such license applies only to those patent claims licensable
76
+ by such Contributor that are necessarily infringed by their
77
+ Contribution(s) alone or by the combination of their Contributions
78
+ with the Work to which such Contributions were submitted. If You
79
+ institute patent litigation against any entity (including a cross-claim
80
+ or counterclaim in a lawsuit) alleging that the Work or any
81
+ Contribution embodied within the Work constitutes direct or
82
+ contributory patent infringement, then any patent licenses granted to
83
+ You under this License for that Work shall terminate as of the date
84
+ such litigation is filed.
85
+
86
+ 4. Redistribution. You may reproduce and distribute copies of the
87
+ Work or Derivative Works thereof in any medium, with or without
88
+ modifications, and in Source or Object form, provided that You
89
+ meet the following conditions:
90
+
91
+ (a) You must give any other recipients of the Work or Derivative
92
+ Works a copy of this License; and
93
+
94
+ (b) You must cause any modified files to carry prominent notices
95
+ stating that You changed the files; and
96
+
97
+ (c) You must retain, in the Source form of any Derivative Works
98
+ that You distribute, all copyright, patent, trademark, and
99
+ attribution notices from the Source form of the Work,
100
+ excluding those notices that do not pertain to any part of
101
+ the Derivative Works; and
102
+
103
+ (d) If the Work includes a "NOTICE" text file as part of its
104
+ distribution, You must include a readable copy of the
105
+ attribution notices contained within such NOTICE file, in
106
+ at least one of the following places: within a NOTICE text
107
+ file distributed as part of the Derivative Works; within
108
+ the Source form or documentation, if provided along with the
109
+ Derivative Works; or, within a display generated by the
110
+ Derivative Works, if and wherever such third-party notices
111
+ normally appear. The contents of the NOTICE file are for
112
+ informational purposes only and do not modify the License.
113
+ You may add Your own attribution notices within Derivative
114
+ Works that You distribute, alongside or as an addendum to
115
+ the NOTICE text from the Work, provided that such additional
116
+ attribution notices cannot be construed as modifying the License.
117
+
118
+ You may add Your own license statement for Your modifications and
119
+ may provide additional grant of rights to use, copy, modify, merge,
120
+ publish, distribute, sublicense, and/or sell copies of the
121
+ Contribution, either in combined form with the Work or separate from
122
+ the Work. If You choose to provide additional grant of rights, You
123
+ must do so in a manner consistent with the terms of this License.
124
+
125
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
126
+ any Contribution intentionally submitted for inclusion in the Work
127
+ by You to the Licensor shall be under the terms and conditions of
128
+ this License, without any additional terms or conditions.
129
+ Notwithstanding the above, nothing herein shall supersede or modify
130
+ the terms of any separate license agreement you may have executed
131
+ with Licensor regarding such Contributions.
132
+
133
+ 6. Trademarks. This License does not grant permission to use the trade
134
+ names, trademarks, service marks, or product names of the Licensor,
135
+ except as required for reasonable and customary use in describing the
136
+ origin of the Work and reproducing the content of the NOTICE file.
137
+
138
+ 7. Disclaimer of Warranty. Unless required by applicable law or
139
+ agreed to in writing, Licensor provides the Work (and each
140
+ Contributor provides its Contributions) on an "AS IS" BASIS,
141
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
142
+ implied, including, without limitation, any warranties or conditions
143
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
144
+ PARTICULAR PURPOSE. You are solely responsible for determining the
145
+ appropriateness of using or reproducing the Work and assume any
146
+ risks associated with Your exercise of permissions under this License.
147
+
148
+ 8. Limitation of Liability. In no event and under no legal theory,
149
+ whether in tort (including negligence), contract, or otherwise,
150
+ unless required by applicable law (such as deliberate and grossly
151
+ negligent acts) or agreed to in writing, shall any Contributor be
152
+ liable to You for damages, including any direct, indirect, special,
153
+ incidental, or exemplary damages of any character arising as a
154
+ result of this License or out of the use or inability to use the
155
+ Work (including but not limited to damages for loss of goodwill,
156
+ work stoppage, computer failure or malfunction, or all other
157
+ commercial damages or losses), even if such Contributor has been
158
+ advised of the possibility of such damages.
159
+
160
+ 9. Accepting Warranty or Additional Liability. While redistributing
161
+ the Work or Derivative Works thereof, You may choose to offer,
162
+ and charge a fee for, acceptance of support, warranty, indemnity,
163
+ or other liability obligations and/or rights consistent with this
164
+ License. However, in accepting such obligations, You may act only
165
+ on Your own behalf and on Your sole responsibility, not on behalf
166
+ of any other Contributor, and only if You agree to indemnify,
167
+ defend, and hold each Contributor harmless for any liability
168
+ incurred by, or claims asserted against, such Contributor by reason
169
+ of your accepting any such warranty or additional liability.
170
+
171
+ END OF TERMS AND CONDITIONS
172
+
173
+ Copyright (c) 2026 Danilo Borges (https://github.com/daniloborges)
174
+
175
+ Licensed under the Apache License, Version 2.0 (the "License");
176
+ you may not use this file except in compliance with the License.
177
+ You may obtain a copy of the License at
178
+
179
+ http://www.apache.org/licenses/LICENSE-2.0
180
+
181
+ Unless required by applicable law or agreed to in writing, software
182
+ distributed under the License is distributed on an "AS IS" BASIS,
183
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
184
+ See the License for the specific language governing permissions and
185
+ limitations under the License.
@@ -753,4 +753,4 @@ export {
753
753
  unpack,
754
754
  run
755
755
  };
756
- //# sourceMappingURL=chunk-PSDRJRNL.js.map
756
+ //# sourceMappingURL=chunk-BTLKCX2G.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/commands/init.ts","../src/commands/pack.ts","../src/core/lint.ts","../src/core/id.ts","../src/core/envelope.ts","../src/core/zip.ts","../src/commands/unpack.ts","../src/commands/run.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//\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 { mkdir, writeFile, stat } from 'fs/promises'\nimport { join, basename } from 'path'\nimport { InitOptions, InitResult } from '../types.js'\n\nconst AGENT_DESCRIPTION_TEMPLATE = (name: string, domain: string) => `agent ${name}\n domain ${domain}\n license Apache-2.0\n\ndescription\n Describe what this agent does.\n\nbehavior agent.behavior\n\ncapabilities\n ActionName \"Describe this capability\"\n`\n\nconst AGENT_BEHAVIOR_TEMPLATE = `state init\n transition to responsive\n\nstate responsive\n goal \"Help the user with their task.\"\n interact\n on intent \"start\" transition to responsive\n`\n\nconst SOUL_TEMPLATE = (name: string) => `# ${name} — Persona\n\n## Voice and Tone\n\nDescribe the agent's voice, personality, and communication style.\n`\n\nconst README_TEMPLATE = (name: string) => `# ${name}\n\nBrief description of what this agent does.\n\n## Usage\n\nExample of how to use this agent.\n`\n\nconst LICENSE = `Apache License\nVersion 2.0, January 2004\n\nhttp://www.apache.org/licenses/\n\nTERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION\n`\n\nexport async function init(options: InitOptions = {}): Promise<InitResult> {\n const dir = options.dir || process.cwd()\n const name = options.name || basename(dir)\n const domain = options.domain || 'example.com'\n\n try {\n await stat(dir)\n } catch {\n await mkdir(dir, { recursive: true })\n }\n\n const agentDescriptionPath = join(dir, 'agent.description')\n try {\n await stat(agentDescriptionPath)\n throw new Error(`agent.description already exists at ${agentDescriptionPath}`)\n } catch (err: any) {\n if (err.code !== 'ENOENT') throw err\n }\n\n const files: string[] = []\n\n await writeFile(agentDescriptionPath, AGENT_DESCRIPTION_TEMPLATE(name, domain))\n files.push('agent.description')\n\n await writeFile(join(dir, 'agent.behavior'), AGENT_BEHAVIOR_TEMPLATE)\n files.push('agent.behavior')\n\n await writeFile(join(dir, 'SOUL.md'), SOUL_TEMPLATE(name))\n files.push('SOUL.md')\n\n await writeFile(join(dir, 'README.md'), README_TEMPLATE(name))\n files.push('README.md')\n\n await writeFile(join(dir, 'LICENSE'), LICENSE)\n files.push('LICENSE')\n\n await mkdir(join(dir, 'behaviors'), { recursive: true })\n await writeFile(join(dir, 'behaviors', '.gitkeep'), '')\n files.push('behaviors/.gitkeep')\n\n await mkdir(join(dir, 'guides'), { recursive: true })\n await writeFile(join(dir, 'guides', '.gitkeep'), '')\n files.push('guides/.gitkeep')\n\n await mkdir(join(dir, 'knowledge'), { recursive: true })\n await writeFile(join(dir, 'knowledge', '.gitkeep'), '')\n files.push('knowledge/.gitkeep')\n\n await writeFile(join(dir, 'AGENTS.md'), '')\n files.push('AGENTS.md')\n\n return { dir, files }\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 { readFile, stat, readdir } from 'fs/promises'\nimport { join, basename, dirname } from 'path'\nimport { execSync } from 'child_process'\nimport { createHash } from 'crypto'\nimport JSZip from 'jszip'\nimport { PackOptions, PackResult, LintMessage } from '../types.js'\nimport { createLinter } from '../core/lint.js'\nimport { buildId } from '../core/id.js'\nimport { buildAboutme, aboutmeToJson } from '../core/envelope.js'\nimport { buildTypesJson } from '../core/types.js'\nimport { writeZip } from '../core/zip.js'\n\nfunction gitDescribeTags(): string | null {\n try {\n return execSync('git describe --tags --abbrev=0', {\n stdio: 'pipe',\n encoding: 'utf-8',\n }).trim()\n } catch {\n return null\n }\n}\n\nfunction gitRevParseShort(): string | null {\n try {\n return execSync('git rev-parse --short HEAD', {\n stdio: 'pipe',\n encoding: 'utf-8',\n }).trim()\n } catch {\n return null\n }\n}\n\nasync function resolveVersion(explicit?: string): Promise<string> {\n if (explicit) return explicit\n\n const gitTag = gitDescribeTags()\n if (gitTag) return gitTag\n\n return 'v1.0.0'\n}\n\nasync function resolveCommit(explicit?: string): Promise<string | undefined> {\n if (explicit) return explicit\n return gitRevParseShort() || undefined\n}\n\nasync function collectFiles(dir: string): Promise<Map<string, string>> {\n const files = new Map<string, string>()\n\n async function walk(subdir: string, prefix: string = '') {\n try {\n const entries = await readdir(subdir)\n for (const entry of entries) {\n if (entry === '.gitkeep' || entry.startsWith('.')) continue\n\n const fullPath = join(subdir, entry)\n const stats = await stat(fullPath)\n const relativePath = prefix ? `${prefix}/${entry}` : entry\n\n if (stats.isDirectory()) {\n await walk(fullPath, relativePath)\n } else {\n const content = await readFile(fullPath, 'utf-8')\n files.set(relativePath, content)\n }\n }\n } catch {\n // directory doesn't exist or can't be read\n }\n }\n\n const description = await readFile(join(dir, 'agent.description'), 'utf-8')\n files.set('agent.description', description)\n\n const behavior = await readFile(join(dir, 'agent.behavior'), 'utf-8')\n files.set('agent.behavior', behavior)\n\n try {\n const soul = await readFile(join(dir, 'SOUL.md'), 'utf-8')\n files.set('SOUL.md', soul)\n } catch {\n // optional\n }\n\n await walk(join(dir, 'behaviors'), 'behaviors')\n await walk(join(dir, 'guides'), 'guides')\n await walk(join(dir, 'knowledge'), 'knowledge')\n\n return files\n}\n\nfunction parseDescription(text: string): any {\n const domain = text.match(/domain\\s+([^\\n]+)/)?.[1] || ''\n const name = text.match(/agent\\s+([^\\n]+)/)?.[1] || ''\n const description = text.match(/description\\s+(.+?)(?=\\n\\n|\\n[a-z])/s)?.[1] || ''\n\n return {\n domain: domain.trim(),\n name: name.trim(),\n description: description.trim(),\n capabilities: [],\n }\n}\n\nexport async function pack(options: PackOptions = {}): Promise<PackResult> {\n const dir = options.dir || process.cwd()\n const outPath = options.out || join(dir, `${basename(dir)}.agent`)\n\n // Read files\n let descriptionText: string\n let behaviorText: string\n\n try {\n descriptionText = await readFile(join(dir, 'agent.description'), 'utf-8')\n } catch {\n throw new Error('E003: File agent.description not found')\n }\n\n try {\n behaviorText = await readFile(join(dir, 'agent.behavior'), 'utf-8')\n } catch {\n throw new Error('E007: File agent.behavior not found')\n }\n\n // Lint\n const linter = await createLinter()\n const descriptionMessages = await linter.lintDescription(descriptionText)\n const behaviorMessages = await linter.lintBehavior(behaviorText)\n\n const allMessages = [...descriptionMessages, ...behaviorMessages]\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(`Lint failed: ${errors.map(e => `${e.file}:${e.line}:${e.col} ${e.code} ${e.message}`).join('\\n')}`)\n }\n\n // Parse description\n const description = parseDescription(descriptionText)\n\n // Resolve version & commit\n const version = await resolveVersion(options.version)\n const commit = await resolveCommit(options.commit)\n\n // Collect all files\n const allFiles = await collectFiles(dir)\n\n // Build ID\n const contentForHash = Array.from(allFiles.values()).join('')\n const digest = createHash('sha256').update(contentForHash).digest('hex').substring(0, 8)\n const id = buildId({\n namespace: description.domain,\n name: description.name,\n version,\n digest,\n })\n\n // Build aboutme\n const aboutme = buildAboutme({\n id,\n name: description.name,\n description: description.description,\n version,\n domain: description.domain,\n license: 'Apache-2.0',\n persona: 'SOUL.md',\n compiler: 'dot-agent/1.0.0',\n commit,\n skills: [],\n requires: [],\n integrity: {\n sha256: createHash('sha256').update(contentForHash).digest('hex'),\n files: '.agent/files.json',\n },\n })\n\n // Build ZIP\n const zip = new JSZip()\n\n zip.folder('.agent')!.file('aboutme.json', aboutmeToJson(aboutme))\n\n // Build files.json\n const filesJson = {\n description: 'agent.description',\n behavior: 'agent.behavior',\n behaviors: Array.from(allFiles.keys())\n .filter(f => f.startsWith('behaviors/') && f !== 'behaviors/.gitkeep')\n .map(f => f),\n guides: Array.from(allFiles.keys())\n .filter(f => f.startsWith('guides/') && f !== 'guides/.gitkeep')\n .map(f => f),\n knowledge: Array.from(allFiles.keys())\n .filter(f => f.startsWith('knowledge/') && f !== 'knowledge/.gitkeep')\n .map(f => f),\n }\n\n zip.folder('.agent')!.file('files.json', JSON.stringify(filesJson, null, 2))\n\n // Add all files to ZIP root\n for (const [path, content] of allFiles) {\n if (path !== 'behaviors/.gitkeep' && path !== 'guides/.gitkeep' && path !== 'knowledge/.gitkeep') {\n zip.file(path, content)\n }\n }\n\n // Write ZIP\n await writeZip(zip, outPath)\n\n return {\n path: outPath,\n id,\n warnings,\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//\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 { createRequire } from 'module'\nimport { Parser, Language } from 'web-tree-sitter'\nimport { AgentDSLKernel, init as initKernel } from '@dot-agent/kernel-dsl'\nimport { LintMessage } from '../types.js'\n\nconst require = createRequire(import.meta.url)\nconst { agentWasmPath, behaviorWasmPath } = require('@dot-agent/tree-sitter')\n\ndeclare module '@dot-agent/tree-sitter' {\n export const agentWasmPath: string\n export const behaviorWasmPath: string\n}\n\nlet _initialized = false\nlet _agentParser: Parser\nlet _behaviorParser: Parser\nlet _agentLang: any\nlet _behaviorLang: any\n\nasync function ensureWasmInit() {\n if (_initialized) return\n\n try {\n await Parser.init()\n } catch (err) {\n throw err\n }\n\n _agentParser = new Parser()\n _behaviorParser = new Parser()\n\n try {\n _agentLang = await Language.load(agentWasmPath)\n _behaviorLang = await Language.load(behaviorWasmPath)\n } catch (err) {\n throw err\n }\n\n try {\n await initKernel()\n } catch (err) {\n // Silently fail - kernel might not be available in all environments\n // We can continue with tree-sitter only for syntax checking\n }\n\n _initialized = true\n}\n\nfunction collectSyntaxErrors(node: Parser.SyntaxNode): Parser.SyntaxNode[] {\n const errors: Parser.SyntaxNode[] = []\n if (node.isError || node.isMissing) errors.push(node)\n for (const child of node.children) {\n errors.push(...collectSyntaxErrors(child))\n }\n return errors\n}\n\nfunction getLineCol(node: Parser.SyntaxNode): { line: number; col: number } {\n return { line: node.startPosition.row + 1, col: node.startPosition.column + 1 }\n}\n\nexport async function lintDescription(text: string): Promise<LintMessage[]> {\n await ensureWasmInit()\n\n _agentParser.setLanguage(_agentLang)\n const tree = _agentParser.parse(text)\n const messages: LintMessage[] = []\n\n const syntaxErrors = collectSyntaxErrors(tree.rootNode)\n if (syntaxErrors.length > 0) {\n for (const error of syntaxErrors) {\n const { line, col } = getLineCol(error)\n messages.push({\n file: 'agent.description',\n line,\n col,\n severity: 'error',\n code: 'E004',\n message: 'Syntax error in description',\n })\n }\n }\n\n const walk = (node: Parser.SyntaxNode) => {\n if (node.type === 'domain_declaration' && node.childCount > 0) {\n const valueNode = node.child(node.childCount - 1)\n if (valueNode && valueNode.text === 'example.com') {\n const { line, col } = getLineCol(valueNode)\n messages.push({\n file: 'agent.description',\n line,\n col,\n severity: 'warning',\n code: 'W003',\n message: 'domain still has default value \"example.com\"',\n })\n }\n }\n for (const child of node.children) walk(child)\n }\n walk(tree.rootNode)\n\n return messages\n}\n\nexport async function lintBehavior(text: string): Promise<LintMessage[]> {\n await ensureWasmInit()\n\n _behaviorParser.setLanguage(_behaviorLang)\n const tree = _behaviorParser.parse(text)\n const messages: LintMessage[] = []\n\n const syntaxErrors = collectSyntaxErrors(tree.rootNode)\n if (syntaxErrors.length > 0) {\n for (const error of syntaxErrors) {\n const { line, col } = getLineCol(error)\n messages.push({\n file: 'agent.behavior',\n line,\n col,\n severity: 'error',\n code: 'E004',\n message: 'Syntax error in behavior DSL',\n })\n }\n }\n\n const walk = (node: Parser.SyntaxNode) => {\n if (node.type === 'text_block') {\n if (node.text.length > 280) {\n const { line, col } = getLineCol(node)\n messages.push({\n file: 'agent.behavior',\n line,\n col,\n severity: 'warning',\n code: 'W002',\n message: `Text block exceeds 280 characters (${node.text.length})`,\n })\n }\n }\n for (const child of node.children) walk(child)\n }\n walk(tree.rootNode)\n\n try {\n const kernel = new AgentDSLKernel()\n try {\n const effects = kernel.load_behavior(text)\n\n if (Array.isArray(effects)) {\n for (const effect of effects) {\n if (effect.type === 'parse_error') {\n messages.push({\n file: 'agent.behavior',\n line: 1,\n col: 1,\n severity: 'error',\n code: 'E006',\n message: `Parse error: ${effect.message}`,\n })\n }\n }\n }\n\n const graph = kernel.get_graph()\n if (graph?.states) {\n for (const stateName of Object.keys(graph.states)) {\n const state = graph.states[stateName]\n const hasIncoming = graph.transitions?.some((t: any) => t.to === stateName)\n const hasOutgoing = graph.transitions?.some((t: any) => t.from === stateName)\n\n if (!hasIncoming && !hasOutgoing && stateName !== graph.current) {\n messages.push({\n file: 'agent.behavior',\n line: 1,\n col: 1,\n severity: 'warning',\n code: 'W001',\n message: `state \"${stateName}\" has no transitions`,\n })\n }\n }\n }\n } catch (kernelErr: any) {\n // Kernel load failed - skip semantic checks, syntax errors already caught by tree-sitter\n }\n } catch (err: any) {\n // Could not initialize kernel - skip semantic checks\n }\n\n return messages\n}\n\nexport async function createLinter() {\n await ensureWasmInit()\n\n return {\n lintDescription,\n lintBehavior,\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//\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\nexport interface IdParts {\n namespace: string\n name: string\n version: string\n digest: string\n}\n\nexport function parseId(id: string): IdParts {\n const match = id.match(/^(.+)\\/(.+):(.+)~(.+)$/)\n if (!match) {\n throw new Error(`Invalid agent ID format: ${id}. Expected: namespace/name:version~digest`)\n }\n const [, namespace, name, version, digest] = match\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 || !version || !digest) {\n throw new Error('Missing required ID parts: namespace, name, version, digest')\n }\n return `${namespace}/${name}:${version}~${digest}`\n}\n\nexport function extractDigest(id: string): string {\n try {\n const parts = parseId(id)\n return parts.digest\n } catch {\n return ''\n }\n}\n\nexport function extractName(id: string): string {\n try {\n const parts = parseId(id)\n return parts.name\n } catch {\n return ''\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//\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 { AboutMe, Integrity, Skill } from '../types.js'\n\nexport function parseAboutme(json: any): AboutMe {\n if (!json.schemaVersion) throw new Error('Missing schemaVersion 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.version) throw new Error('Missing version in aboutme.json')\n if (!json.domain) throw new Error('Missing domain in aboutme.json')\n if (!json.license) throw new Error('Missing license in aboutme.json')\n if (!json.persona) throw new Error('Missing persona in aboutme.json')\n if (!json.compiler) throw new Error('Missing compiler in aboutme.json')\n if (!Array.isArray(json.skills)) throw new Error('Missing skills 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 schemaVersion: json.schemaVersion,\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 compiler: json.compiler,\n commit: json.commit,\n skills: json.skills,\n requires: json.requires,\n integrity: json.integrity,\n }\n}\n\nexport interface BuildAboutmeOptions {\n id: string\n name: string\n description: string\n version: string\n domain: string\n license?: string\n persona: string\n compiler: string\n commit?: string\n skills?: Skill[]\n requires?: string[]\n integrity: Integrity\n}\n\nexport function buildAboutme(opts: BuildAboutmeOptions): AboutMe {\n return {\n schemaVersion: 'dot-agent/1.0',\n id: opts.id,\n name: opts.name,\n description: opts.description,\n version: opts.version,\n domain: opts.domain,\n license: opts.license || 'Apache-2.0',\n persona: opts.persona,\n compiler: opts.compiler,\n commit: opts.commit,\n skills: opts.skills || [],\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","// 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'\n\nconst MAX_ZIP_SIZE = 500 * 1024 * 1024\nconst MAX_COMPRESSION_RATIO = 100\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\n let totalUncompressed = 0\n zip.forEach((relativePath, file) => {\n if (!file.dir) {\n totalUncompressed += file._data?.uncompressedSize || 0\n }\n })\n\n const compressedSize = data.length\n const ratio = totalUncompressed / compressedSize\n\n if (totalUncompressed > MAX_ZIP_SIZE) {\n throw new Error(`ZIP uncompressed size exceeds 500MB limit: ${totalUncompressed}`)\n }\n\n if (ratio > MAX_COMPRESSION_RATIO) {\n throw new Error(`ZIP compression ratio exceeds 100x limit: ${ratio.toFixed(1)}x`)\n }\n\n return true\n}\n\nexport async function extractFiles(\n zip: JSZip,\n filter?: string[]\n): Promise<Map<string, string>> {\n const files = new Map<string, string>()\n\n const promises: Promise<void>[] = []\n zip.forEach((relativePath, file) => {\n if (file.dir) return\n if (filter && !filter.some(f => relativePath.startsWith(f))) return\n\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\nexport function createZip(): JSZip {\n return new JSZip()\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\nexport async function validateMagicBytes(filePath: string): Promise<boolean> {\n const data = await readFile(filePath)\n const magicBytes = data.subarray(0, 4)\n const isZip = magicBytes[0] === 0x50 && magicBytes[1] === 0x4b && magicBytes[2] === 0x03 && magicBytes[3] === 0x04\n if (!isZip) {\n throw new Error('File is not a valid ZIP (invalid magic bytes)')\n }\n return true\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 { mkdir, writeFile, stat } from 'fs/promises'\nimport { join } from 'path'\nimport { createHash } from 'crypto'\nimport { UnpackOptions, UnpackResult } from '../types.js'\nimport { readZip, validateZipBomb, validateMagicBytes, extractFiles } from '../core/zip.js'\nimport { parseAboutme } from '../core/envelope.js'\n\nexport async function unpack(options: UnpackOptions): Promise<UnpackResult> {\n const { file, out, force = false } = options\n\n // Validate magic bytes\n await validateMagicBytes(file)\n\n // Validate ZIP bomb\n await validateZipBomb(file)\n\n // Load ZIP\n const zip = await readZip(file)\n\n // Read aboutme.json\n const aboutmeFile = zip.file('.agent/aboutme.json')\n if (!aboutmeFile) {\n throw new Error('Missing .agent/aboutme.json in ZIP')\n }\n\n const aboutmeText = await aboutmeFile.async('text')\n const aboutme = parseAboutme(JSON.parse(aboutmeText))\n\n // Extract output directory\n const outDir = out || `./${aboutme.name}`\n\n // Check if directory exists\n try {\n await stat(outDir)\n if (!force) {\n throw new Error(`Output directory already exists: ${outDir}. Use --force to overwrite.`)\n }\n } catch (err: any) {\n if (err.code !== 'ENOENT') throw err\n }\n\n // Extract all files from root\n const files = await extractFiles(zip)\n await mkdir(outDir, { recursive: true })\n\n const extractedFiles: string[] = []\n\n for (const [path, content] of files) {\n if (path.startsWith('.agent/')) continue\n\n const fullPath = join(outDir, path)\n const dir = fullPath.substring(0, fullPath.lastIndexOf('/'))\n\n await mkdir(dir, { recursive: true })\n await writeFile(fullPath, content)\n extractedFiles.push(path)\n }\n\n return {\n dir: outDir,\n id: aboutme.id,\n files: extractedFiles,\n aboutme,\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//\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 { EventEmitter } from 'events'\nimport { readFile, stat } from 'fs/promises'\nimport { AgentDSLKernel, init as initKernel } from '@dot-agent/kernel-dsl'\nimport { RunOptions, AgentContext, FileEntry } from '../types.js'\nimport { readZip, validateZipBomb, validateMagicBytes, extractFiles } from '../core/zip.js'\nimport { parseAboutme } from '../core/envelope.js'\n\nfunction isZipFile(source: string): boolean {\n return source.endsWith('.agent')\n}\n\nexport async function run(options: RunOptions): Promise<AgentContext> {\n const { source } = options\n const context = new EventEmitter() as any as AgentContext\n\n try {\n context.emit('progress', { step: 'opening', pct: 0 })\n\n let descriptionText: string\n let behaviorText: string\n let aboutme: any = null\n let id: string\n\n if (isZipFile(source)) {\n // Load from .agent ZIP\n await validateMagicBytes(source)\n await validateZipBomb(source)\n\n const zip = await readZip(source)\n\n const aboutmeFile = zip.file('.agent/aboutme.json')\n if (!aboutmeFile) {\n throw new Error('Missing .agent/aboutme.json')\n }\n\n const aboutmeText = await aboutmeFile.async('text')\n aboutme = parseAboutme(JSON.parse(aboutmeText))\n id = aboutme.id\n\n const descFile = zip.file('agent.description')\n if (!descFile) throw new Error('Missing agent.description')\n descriptionText = await descFile.async('text')\n\n const behavFile = zip.file('agent.behavior')\n if (!behavFile) throw new Error('Missing agent.behavior')\n behaviorText = await behavFile.async('text')\n\n context.emit('progress', { step: 'parsing', pct: 30 })\n\n // Load kernel-dsl\n let kernel: any\n try {\n await initKernel()\n kernel = new AgentDSLKernel()\n kernel.load_behavior(behaviorText)\n } catch (err: any) {\n // Kernel failed - create a stub\n kernel = {\n get_current_state: () => 'init',\n get_graph: () => ({}),\n get_memory: () => [],\n get_valid_intents: () => [],\n load_behavior: () => {},\n observe: () => {},\n send_complete: () => {},\n send_event: () => {},\n send_failed: () => {},\n send_fallback: () => {},\n send_intent: () => {},\n send_offtopic: () => {},\n tick_prompt: () => {},\n free: () => {},\n }\n }\n\n context.emit('progress', { step: 'loading-files', pct: 60 })\n\n // Load files\n const soulFile = zip.file('SOUL.md')\n const soul = soulFile ? await soulFile.async('text') : undefined\n\n const allFiles = await extractFiles(zip)\n const guides: FileEntry[] = []\n const knowledge: FileEntry[] = []\n const behaviors: FileEntry[] = []\n\n for (const [path, content] of allFiles) {\n if (path.startsWith('guides/') && path !== 'guides/.gitkeep') {\n guides.push({ path, content })\n } else if (path.startsWith('knowledge/') && path !== 'knowledge/.gitkeep') {\n knowledge.push({ path, content })\n } else if (path.startsWith('behaviors/') && path !== 'behaviors/.gitkeep') {\n behaviors.push({ path, content })\n }\n }\n\n context.id = id\n context.description = { domain: 'example.com', name: 'Agent' }\n context.behavior = {}\n context.kernel = kernel\n context.files = { soul, guides, knowledge, behaviors }\n context.aboutme = aboutme\n } else {\n // Load from directory\n const descPath = `${source}/agent.description`\n const behavPath = `${source}/agent.behavior`\n\n try {\n descriptionText = await readFile(descPath, 'utf-8')\n } catch {\n throw new Error(`Missing agent.description at ${descPath}`)\n }\n\n try {\n behaviorText = await readFile(behavPath, 'utf-8')\n } catch {\n throw new Error(`Missing agent.behavior at ${behavPath}`)\n }\n\n context.emit('progress', { step: 'parsing', pct: 30 })\n\n // Load kernel-dsl\n let kernel: any\n try {\n await initKernel()\n kernel = new AgentDSLKernel()\n kernel.load_behavior(behaviorText)\n } catch (err: any) {\n // Kernel failed - create a stub\n kernel = {\n get_current_state: () => 'init',\n get_graph: () => ({}),\n get_memory: () => [],\n get_valid_intents: () => [],\n load_behavior: () => {},\n observe: () => {},\n send_complete: () => {},\n send_event: () => {},\n send_failed: () => {},\n send_fallback: () => {},\n send_intent: () => {},\n send_offtopic: () => {},\n tick_prompt: () => {},\n free: () => {},\n }\n }\n\n context.emit('progress', { step: 'loading-files', pct: 60 })\n\n id = 'local/agent:v1.0~unknown'\n\n try {\n const soul = await readFile(`${source}/SOUL.md`, 'utf-8')\n context.files = {\n soul,\n guides: [],\n knowledge: [],\n behaviors: [],\n }\n } catch {\n context.files = { guides: [], knowledge: [], behaviors: [] }\n }\n\n const defaultAboutme: any = {\n schemaVersion: 'dot-agent/1.0',\n id,\n name: 'Agent',\n description: '',\n version: 'v1.0',\n domain: 'local',\n license: 'Apache-2.0',\n persona: 'SOUL.md',\n compiler: 'dot-agent/1.0.0',\n skills: [],\n requires: [],\n integrity: { sha256: '', files: '' },\n }\n\n context.id = id\n context.description = { domain: 'example.com', name: 'Agent' }\n context.behavior = {}\n context.kernel = kernel\n context.aboutme = defaultAboutme\n }\n\n context.emit('progress', { step: 'ready', pct: 100 })\n context.emit('ready', context)\n\n return context\n } catch (err) {\n context.emit('error', err)\n throw err\n }\n}\n"],"mappings":";AAcA,SAAS,OAAO,WAAW,YAAY;AACvC,SAAS,MAAM,gBAAgB;AAG/B,IAAM,6BAA6B,CAAC,MAAc,WAAmB,SAAS,IAAI;AAAA,WACvE,MAAM;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAYjB,IAAM,0BAA0B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAShC,IAAM,gBAAgB,CAAC,SAAiB,KAAK,IAAI;AAAA;AAAA;AAAA;AAAA;AAAA;AAOjD,IAAM,kBA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AA,MACF,QAAQ;AACN,gBAAQ,QAAQ,EAAE,QAAQ,CAAC,GAAG,WAAW,CAAC,GAAG,WAAW,CAAC,EAAE;AAAA,MAC7D;AAEA,YAAM,iBAAsB;AAAA,QAC1B,eAAe;AAAA,QACf;AAAA,QACA,MAAM;AAAA,QACN,aAAa;AAAA,QACb,SAAS;AAAA,QACT,QAAQ;AAAA,QACR,SAAS;AAAA,QACT,SAAS;AAAA,QACT,UAAU;AAAA,QACV,QAAQ,CAAC;AAAA,QACT,UAAU,CAAC;AAAA,QACX,WAAW,EAAE,QAAQ,IAAI,OAAO,GAAG;AAAA,MACrC;AAEA,cAAQ,KAAK;AACb,cAAQ,cAAc,EAAE,QAAQ,eAAe,MAAM,QAAQ;AAC7D,cAAQ,WAAW,CAAC;AACpB,cAAQ,SAAS;AACjB,cAAQ,UAAU;AAAA,IACpB;AAEA,YAAQ,KAAK,YAAY,EAAE,MAAM,SAAS,KAAK,IAAI,CAAC;AACpD,YAAQ,KAAK,SAAS,OAAO;AAE7B,WAAO;AAAA,EACT,SAAS,KAAK;AACZ,YAAQ,KAAK,SAAS,GAAG;AACzB,UAAM;AAAA,EACR;AACF;","names":["readFile","stat","join","basename","JSZip","require","writeFile","writeFile","join","stat","readFile","basename","JSZip","mkdir","writeFile","stat","join","stat","mkdir","join","writeFile","readFile","AgentDSLKernel","initKernel","initKernel","AgentDSLKernel","readFile"]}
package/dist/cli.cjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../node_modules/tsup/assets/cjs_shims.js","../src/commands/init.ts","../src/commands/pack.ts","../src/core/lint.ts","../src/core/id.ts","../src/core/envelope.ts","../src/core/zip.ts","../src/commands/unpack.ts","../src/commands/run.ts","../src/cli.ts"],"sourcesContent":["// Shim globals in cjs bundle\n// There's a weird bug that esbuild will always inject importMetaUrl\n// if we export it as `const importMetaUrl = ... __filename ...`\n// But using a function will not cause this issue\n\nconst getImportMetaUrl = () => \n typeof document === \"undefined\" \n ? new URL(`file:${__filename}`).href \n : (document.currentScript && document.currentScript.tagName.toUpperCase() === 'SCRIPT') \n ? document.currentScript.src \n : new URL(\"main.js\", document.baseURI).href;\n\nexport const importMetaUrl = /* @__PURE__ */ getImportMetaUrl()\n","import { mkdir, writeFile, stat } from 'fs/promises'\nimport { join, basename } from 'path'\nimport { InitOptions, InitResult } from '../types.js'\n\nconst AGENT_DESCRIPTION_TEMPLATE = (name: string, domain: string) => `agent ${name}\n domain ${domain}\n license Apache-2.0\n\ndescription\n Describe what this agent does.\n\nbehavior agent.behavior\n\ncapabilities\n ActionName \"Describe this capability\"\n`\n\nconst AGENT_BEHAVIOR_TEMPLATE = `state init\n transition to responsive\n\nstate responsive\n goal \"Help the user with their task.\"\n interact\n on intent \"start\" transition to responsive\n`\n\nconst SOUL_TEMPLATE = (name: string) => `# ${name} — Persona\n\n## Voice and Tone\n\nDescribe the agent's voice, personality, and communication style.\n`\n\nconst README_TEMPLATE = (name: string) => `# ${name}\n\nBrief description of what this agent does.\n\n## Usage\n\nExample of how to use this agent.\n`\n\nconst LICENSE = `Apache License\nVersion 2.0, January 2004\n\nhttp://www.apache.org/licenses/\n\nTERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION\n`\n\nexport async function init(options: InitOptions = {}): Promise<InitResult> {\n const dir = options.dir || process.cwd()\n const name = options.name || basename(dir)\n const domain = options.domain || 'example.com'\n\n try {\n await stat(dir)\n } catch {\n await mkdir(dir, { recursive: true })\n }\n\n const agentDescriptionPath = join(dir, 'agent.description')\n try {\n await stat(agentDescriptionPath)\n throw new Error(`agent.description already exists at ${agentDescriptionPath}`)\n } catch (err: any) {\n if (err.code !== 'ENOENT') throw err\n }\n\n const files: string[] = []\n\n await writeFile(agentDescriptionPath, AGENT_DESCRIPTION_TEMPLATE(name, domain))\n files.push('agent.description')\n\n await writeFile(join(dir, 'agent.behavior'), AGENT_BEHAVIOR_TEMPLATE)\n files.push('agent.behavior')\n\n await writeFile(join(dir, 'SOUL.md'), SOUL_TEMPLATE(name))\n files.push('SOUL.md')\n\n await writeFile(join(dir, 'README.md'), README_TEMPLATE(name))\n files.push('README.md')\n\n await writeFile(join(dir, 'LICENSE'), LICENSE)\n files.push('LICENSE')\n\n await mkdir(join(dir, 'behaviors'), { recursive: true })\n await writeFile(join(dir, 'behaviors', '.gitkeep'), '')\n files.push('behaviors/.gitkeep')\n\n await mkdir(join(dir, 'guides'), { recursive: true })\n await writeFile(join(dir, 'guides', '.gitkeep'), '')\n files.push('guides/.gitkeep')\n\n await mkdir(join(dir, 'knowledge'), { recursive: true })\n await writeFile(join(dir, 'knowledge', '.gitkeep'), '')\n files.push('knowledge/.gitkeep')\n\n await writeFile(join(dir, 'AGENTS.md'), '')\n files.push('AGENTS.md')\n\n return { dir, files }\n}\n","import { readFile, stat, readdir } from 'fs/promises'\nimport { join, basename, dirname } from 'path'\nimport { execSync } from 'child_process'\nimport { createHash } from 'crypto'\nimport JSZip from 'jszip'\nimport { PackOptions, PackResult, LintMessage } from '../types.js'\nimport { createLinter } from '../core/lint.js'\nimport { buildId } from '../core/id.js'\nimport { buildAboutme, aboutmeToJson } from '../core/envelope.js'\nimport { buildTypesJson } from '../core/types.js'\nimport { writeZip } from '../core/zip.js'\n\nfunction gitDescribeTags(): string | null {\n try {\n return execSync('git describe --tags --abbrev=0', {\n stdio: 'pipe',\n encoding: 'utf-8',\n }).trim()\n } catch {\n return null\n }\n}\n\nfunction gitRevParseShort(): string | null {\n try {\n return execSync('git rev-parse --short HEAD', {\n stdio: 'pipe',\n encoding: 'utf-8',\n }).trim()\n } catch {\n return null\n }\n}\n\nasync function resolveVersion(explicit?: string): Promise<string> {\n if (explicit) return explicit\n\n const gitTag = gitDescribeTags()\n if (gitTag) return gitTag\n\n return 'v1.0.0'\n}\n\nasync function resolveCommit(explicit?: string): Promise<string | undefined> {\n if (explicit) return explicit\n return gitRevParseShort() || undefined\n}\n\nasync function collectFiles(dir: string): Promise<Map<string, string>> {\n const files = new Map<string, string>()\n\n async function walk(subdir: string, prefix: string = '') {\n try {\n const entries = await readdir(subdir)\n for (const entry of entries) {\n if (entry === '.gitkeep' || entry.startsWith('.')) continue\n\n const fullPath = join(subdir, entry)\n const stats = await stat(fullPath)\n const relativePath = prefix ? `${prefix}/${entry}` : entry\n\n if (stats.isDirectory()) {\n await walk(fullPath, relativePath)\n } else {\n const content = await readFile(fullPath, 'utf-8')\n files.set(relativePath, content)\n }\n }\n } catch {\n // directory doesn't exist or can't be read\n }\n }\n\n const description = await readFile(join(dir, 'agent.description'), 'utf-8')\n files.set('agent.description', description)\n\n const behavior = await readFile(join(dir, 'agent.behavior'), 'utf-8')\n files.set('agent.behavior', behavior)\n\n try {\n const soul = await readFile(join(dir, 'SOUL.md'), 'utf-8')\n files.set('SOUL.md', soul)\n } catch {\n // optional\n }\n\n await walk(join(dir, 'behaviors'), 'behaviors')\n await walk(join(dir, 'guides'), 'guides')\n await walk(join(dir, 'knowledge'), 'knowledge')\n\n return files\n}\n\nfunction parseDescription(text: string): any {\n const domain = text.match(/domain\\s+([^\\n]+)/)?.[1] || ''\n const name = text.match(/agent\\s+([^\\n]+)/)?.[1] || ''\n const description = text.match(/description\\s+(.+?)(?=\\n\\n|\\n[a-z])/s)?.[1] || ''\n\n return {\n domain: domain.trim(),\n name: name.trim(),\n description: description.trim(),\n capabilities: [],\n }\n}\n\nexport async function pack(options: PackOptions = {}): Promise<PackResult> {\n const dir = options.dir || process.cwd()\n const outPath = options.out || join(dir, `${basename(dir)}.agent`)\n\n // Read files\n let descriptionText: string\n let behaviorText: string\n\n try {\n descriptionText = await readFile(join(dir, 'agent.description'), 'utf-8')\n } catch {\n throw new Error('E003: File agent.description not found')\n }\n\n try {\n behaviorText = await readFile(join(dir, 'agent.behavior'), 'utf-8')\n } catch {\n throw new Error('E007: File agent.behavior not found')\n }\n\n // Lint\n const linter = await createLinter()\n const descriptionMessages = await linter.lintDescription(descriptionText)\n const behaviorMessages = await linter.lintBehavior(behaviorText)\n\n const allMessages = [...descriptionMessages, ...behaviorMessages]\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(`Lint failed: ${errors.map(e => `${e.file}:${e.line}:${e.col} ${e.code} ${e.message}`).join('\\n')}`)\n }\n\n // Parse description\n const description = parseDescription(descriptionText)\n\n // Resolve version & commit\n const version = await resolveVersion(options.version)\n const commit = await resolveCommit(options.commit)\n\n // Collect all files\n const allFiles = await collectFiles(dir)\n\n // Build ID\n const contentForHash = Array.from(allFiles.values()).join('')\n const digest = createHash('sha256').update(contentForHash).digest('hex').substring(0, 8)\n const id = buildId({\n namespace: description.domain,\n name: description.name,\n version,\n digest,\n })\n\n // Build aboutme\n const aboutme = buildAboutme({\n id,\n name: description.name,\n description: description.description,\n version,\n domain: description.domain,\n license: 'Apache-2.0',\n persona: 'SOUL.md',\n compiler: 'dot-agent/1.0.0',\n commit,\n skills: [],\n requires: [],\n integrity: {\n sha256: createHash('sha256').update(contentForHash).digest('hex'),\n files: '.agent/files.json',\n },\n })\n\n // Build ZIP\n const zip = new JSZip()\n\n zip.folder('.agent')!.file('aboutme.json', aboutmeToJson(aboutme))\n\n // Build files.json\n const filesJson = {\n description: 'agent.description',\n behavior: 'agent.behavior',\n behaviors: Array.from(allFiles.keys())\n .filter(f => f.startsWith('behaviors/') && f !== 'behaviors/.gitkeep')\n .map(f => f),\n guides: Array.from(allFiles.keys())\n .filter(f => f.startsWith('guides/') && f !== 'guides/.gitkeep')\n .map(f => f),\n knowledge: Array.from(allFiles.keys())\n .filter(f => f.startsWith('knowledge/') && f !== 'knowledge/.gitkeep')\n .map(f => f),\n }\n\n zip.folder('.agent')!.file('files.json', JSON.stringify(filesJson, null, 2))\n\n // Add all files to ZIP root\n for (const [path, content] of allFiles) {\n if (path !== 'behaviors/.gitkeep' && path !== 'guides/.gitkeep' && path !== 'knowledge/.gitkeep') {\n zip.file(path, content)\n }\n }\n\n // Write ZIP\n await writeZip(zip, outPath)\n\n return {\n path: outPath,\n id,\n warnings,\n }\n}\n","import { createRequire } from 'module'\nimport { Parser, Language } from 'web-tree-sitter'\nimport { AgentDSLKernel, init as initKernel } from '@dot-agent/kernel-dsl'\nimport { LintMessage } from '../types.js'\n\nconst require = createRequire(import.meta.url)\nconst { agentWasmPath, behaviorWasmPath } = require('@dot-agent/tree-sitter')\n\ndeclare module '@dot-agent/tree-sitter' {\n export const agentWasmPath: string\n export const behaviorWasmPath: string\n}\n\nlet _initialized = false\nlet _agentParser: Parser\nlet _behaviorParser: Parser\nlet _agentLang: any\nlet _behaviorLang: any\n\nasync function ensureWasmInit() {\n if (_initialized) return\n\n try {\n await Parser.init()\n } catch (err) {\n throw err\n }\n\n _agentParser = new Parser()\n _behaviorParser = new Parser()\n\n try {\n _agentLang = await Language.load(agentWasmPath)\n _behaviorLang = await Language.load(behaviorWasmPath)\n } catch (err) {\n throw err\n }\n\n try {\n await initKernel()\n } catch (err) {\n // Silently fail - kernel might not be available in all environments\n // We can continue with tree-sitter only for syntax checking\n }\n\n _initialized = true\n}\n\nfunction collectSyntaxErrors(node: Parser.SyntaxNode): Parser.SyntaxNode[] {\n const errors: Parser.SyntaxNode[] = []\n if (node.isError || node.isMissing) errors.push(node)\n for (const child of node.children) {\n errors.push(...collectSyntaxErrors(child))\n }\n return errors\n}\n\nfunction getLineCol(node: Parser.SyntaxNode): { line: number; col: number } {\n return { line: node.startPosition.row + 1, col: node.startPosition.column + 1 }\n}\n\nexport async function lintDescription(text: string): Promise<LintMessage[]> {\n await ensureWasmInit()\n\n _agentParser.setLanguage(_agentLang)\n const tree = _agentParser.parse(text)\n const messages: LintMessage[] = []\n\n const syntaxErrors = collectSyntaxErrors(tree.rootNode)\n if (syntaxErrors.length > 0) {\n for (const error of syntaxErrors) {\n const { line, col } = getLineCol(error)\n messages.push({\n file: 'agent.description',\n line,\n col,\n severity: 'error',\n code: 'E004',\n message: 'Syntax error in description',\n })\n }\n }\n\n const walk = (node: Parser.SyntaxNode) => {\n if (node.type === 'domain_declaration' && node.childCount > 0) {\n const valueNode = node.child(node.childCount - 1)\n if (valueNode && valueNode.text === 'example.com') {\n const { line, col } = getLineCol(valueNode)\n messages.push({\n file: 'agent.description',\n line,\n col,\n severity: 'warning',\n code: 'W003',\n message: 'domain still has default value \"example.com\"',\n })\n }\n }\n for (const child of node.children) walk(child)\n }\n walk(tree.rootNode)\n\n return messages\n}\n\nexport async function lintBehavior(text: string): Promise<LintMessage[]> {\n await ensureWasmInit()\n\n _behaviorParser.setLanguage(_behaviorLang)\n const tree = _behaviorParser.parse(text)\n const messages: LintMessage[] = []\n\n const syntaxErrors = collectSyntaxErrors(tree.rootNode)\n if (syntaxErrors.length > 0) {\n for (const error of syntaxErrors) {\n const { line, col } = getLineCol(error)\n messages.push({\n file: 'agent.behavior',\n line,\n col,\n severity: 'error',\n code: 'E004',\n message: 'Syntax error in behavior DSL',\n })\n }\n }\n\n const walk = (node: Parser.SyntaxNode) => {\n if (node.type === 'text_block') {\n if (node.text.length > 280) {\n const { line, col } = getLineCol(node)\n messages.push({\n file: 'agent.behavior',\n line,\n col,\n severity: 'warning',\n code: 'W002',\n message: `Text block exceeds 280 characters (${node.text.length})`,\n })\n }\n }\n for (const child of node.children) walk(child)\n }\n walk(tree.rootNode)\n\n try {\n const kernel = new AgentDSLKernel()\n try {\n const effects = kernel.load_behavior(text)\n\n if (Array.isArray(effects)) {\n for (const effect of effects) {\n if (effect.type === 'parse_error') {\n messages.push({\n file: 'agent.behavior',\n line: 1,\n col: 1,\n severity: 'error',\n code: 'E006',\n message: `Parse error: ${effect.message}`,\n })\n }\n }\n }\n\n const graph = kernel.get_graph()\n if (graph?.states) {\n for (const stateName of Object.keys(graph.states)) {\n const state = graph.states[stateName]\n const hasIncoming = graph.transitions?.some((t: any) => t.to === stateName)\n const hasOutgoing = graph.transitions?.some((t: any) => t.from === stateName)\n\n if (!hasIncoming && !hasOutgoing && stateName !== graph.current) {\n messages.push({\n file: 'agent.behavior',\n line: 1,\n col: 1,\n severity: 'warning',\n code: 'W001',\n message: `state \"${stateName}\" has no transitions`,\n })\n }\n }\n }\n } catch (kernelErr: any) {\n // Kernel load failed - skip semantic checks, syntax errors already caught by tree-sitter\n }\n } catch (err: any) {\n // Could not initialize kernel - skip semantic checks\n }\n\n return messages\n}\n\nexport async function createLinter() {\n await ensureWasmInit()\n\n return {\n lintDescription,\n lintBehavior,\n }\n}\n","export interface IdParts {\n namespace: string\n name: string\n version: string\n digest: string\n}\n\nexport function parseId(id: string): IdParts {\n const match = id.match(/^(.+)\\/(.+):(.+)~(.+)$/)\n if (!match) {\n throw new Error(`Invalid agent ID format: ${id}. Expected: namespace/name:version~digest`)\n }\n const [, namespace, name, version, digest] = match\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 || !version || !digest) {\n throw new Error('Missing required ID parts: namespace, name, version, digest')\n }\n return `${namespace}/${name}:${version}~${digest}`\n}\n\nexport function extractDigest(id: string): string {\n try {\n const parts = parseId(id)\n return parts.digest\n } catch {\n return ''\n }\n}\n\nexport function extractName(id: string): string {\n try {\n const parts = parseId(id)\n return parts.name\n } catch {\n return ''\n }\n}\n","import { AboutMe, Integrity, Skill } from '../types.js'\n\nexport function parseAboutme(json: any): AboutMe {\n if (!json.schemaVersion) throw new Error('Missing schemaVersion 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.version) throw new Error('Missing version in aboutme.json')\n if (!json.domain) throw new Error('Missing domain in aboutme.json')\n if (!json.license) throw new Error('Missing license in aboutme.json')\n if (!json.persona) throw new Error('Missing persona in aboutme.json')\n if (!json.compiler) throw new Error('Missing compiler in aboutme.json')\n if (!Array.isArray(json.skills)) throw new Error('Missing skills 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 schemaVersion: json.schemaVersion,\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 compiler: json.compiler,\n commit: json.commit,\n skills: json.skills,\n requires: json.requires,\n integrity: json.integrity,\n }\n}\n\nexport interface BuildAboutmeOptions {\n id: string\n name: string\n description: string\n version: string\n domain: string\n license?: string\n persona: string\n compiler: string\n commit?: string\n skills?: Skill[]\n requires?: string[]\n integrity: Integrity\n}\n\nexport function buildAboutme(opts: BuildAboutmeOptions): AboutMe {\n return {\n schemaVersion: 'dot-agent/1.0',\n id: opts.id,\n name: opts.name,\n description: opts.description,\n version: opts.version,\n domain: opts.domain,\n license: opts.license || 'Apache-2.0',\n persona: opts.persona,\n compiler: opts.compiler,\n commit: opts.commit,\n skills: opts.skills || [],\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","import JSZip from 'jszip'\nimport { readFile, writeFile } from 'fs/promises'\n\nconst MAX_ZIP_SIZE = 500 * 1024 * 1024\nconst MAX_COMPRESSION_RATIO = 100\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\n let totalUncompressed = 0\n zip.forEach((relativePath, file) => {\n if (!file.dir) {\n totalUncompressed += file._data?.uncompressedSize || 0\n }\n })\n\n const compressedSize = data.length\n const ratio = totalUncompressed / compressedSize\n\n if (totalUncompressed > MAX_ZIP_SIZE) {\n throw new Error(`ZIP uncompressed size exceeds 500MB limit: ${totalUncompressed}`)\n }\n\n if (ratio > MAX_COMPRESSION_RATIO) {\n throw new Error(`ZIP compression ratio exceeds 100x limit: ${ratio.toFixed(1)}x`)\n }\n\n return true\n}\n\nexport async function extractFiles(\n zip: JSZip,\n filter?: string[]\n): Promise<Map<string, string>> {\n const files = new Map<string, string>()\n\n const promises: Promise<void>[] = []\n zip.forEach((relativePath, file) => {\n if (file.dir) return\n if (filter && !filter.some(f => relativePath.startsWith(f))) return\n\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\nexport function createZip(): JSZip {\n return new JSZip()\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\nexport async function validateMagicBytes(filePath: string): Promise<boolean> {\n const data = await readFile(filePath)\n const magicBytes = data.subarray(0, 4)\n const isZip = magicBytes[0] === 0x50 && magicBytes[1] === 0x4b && magicBytes[2] === 0x03 && magicBytes[3] === 0x04\n if (!isZip) {\n throw new Error('File is not a valid ZIP (invalid magic bytes)')\n }\n return true\n}\n","import { mkdir, writeFile, stat } from 'fs/promises'\nimport { join } from 'path'\nimport { createHash } from 'crypto'\nimport { UnpackOptions, UnpackResult } from '../types.js'\nimport { readZip, validateZipBomb, validateMagicBytes, extractFiles } from '../core/zip.js'\nimport { parseAboutme } from '../core/envelope.js'\n\nexport async function unpack(options: UnpackOptions): Promise<UnpackResult> {\n const { file, out, force = false } = options\n\n // Validate magic bytes\n await validateMagicBytes(file)\n\n // Validate ZIP bomb\n await validateZipBomb(file)\n\n // Load ZIP\n const zip = await readZip(file)\n\n // Read aboutme.json\n const aboutmeFile = zip.file('.agent/aboutme.json')\n if (!aboutmeFile) {\n throw new Error('Missing .agent/aboutme.json in ZIP')\n }\n\n const aboutmeText = await aboutmeFile.async('text')\n const aboutme = parseAboutme(JSON.parse(aboutmeText))\n\n // Extract output directory\n const outDir = out || `./${aboutme.name}`\n\n // Check if directory exists\n try {\n await stat(outDir)\n if (!force) {\n throw new Error(`Output directory already exists: ${outDir}. Use --force to overwrite.`)\n }\n } catch (err: any) {\n if (err.code !== 'ENOENT') throw err\n }\n\n // Extract all files from root\n const files = await extractFiles(zip)\n await mkdir(outDir, { recursive: true })\n\n const extractedFiles: string[] = []\n\n for (const [path, content] of files) {\n if (path.startsWith('.agent/')) continue\n\n const fullPath = join(outDir, path)\n const dir = fullPath.substring(0, fullPath.lastIndexOf('/'))\n\n await mkdir(dir, { recursive: true })\n await writeFile(fullPath, content)\n extractedFiles.push(path)\n }\n\n return {\n dir: outDir,\n id: aboutme.id,\n files: extractedFiles,\n aboutme,\n }\n}\n","import { EventEmitter } from 'events'\nimport { readFile, stat } from 'fs/promises'\nimport { AgentDSLKernel, init as initKernel } from '@dot-agent/kernel-dsl'\nimport { RunOptions, AgentContext, FileEntry } from '../types.js'\nimport { readZip, validateZipBomb, validateMagicBytes, extractFiles } from '../core/zip.js'\nimport { parseAboutme } from '../core/envelope.js'\n\nfunction isZipFile(source: string): boolean {\n return source.endsWith('.agent')\n}\n\nexport async function run(options: RunOptions): Promise<AgentContext> {\n const { source } = options\n const context = new EventEmitter() as any as AgentContext\n\n try {\n context.emit('progress', { step: 'opening', pct: 0 })\n\n let descriptionText: string\n let behaviorText: string\n let aboutme: any = null\n let id: string\n\n if (isZipFile(source)) {\n // Load from .agent ZIP\n await validateMagicBytes(source)\n await validateZipBomb(source)\n\n const zip = await readZip(source)\n\n const aboutmeFile = zip.file('.agent/aboutme.json')\n if (!aboutmeFile) {\n throw new Error('Missing .agent/aboutme.json')\n }\n\n const aboutmeText = await aboutmeFile.async('text')\n aboutme = parseAboutme(JSON.parse(aboutmeText))\n id = aboutme.id\n\n const descFile = zip.file('agent.description')\n if (!descFile) throw new Error('Missing agent.description')\n descriptionText = await descFile.async('text')\n\n const behavFile = zip.file('agent.behavior')\n if (!behavFile) throw new Error('Missing agent.behavior')\n behaviorText = await behavFile.async('text')\n\n context.emit('progress', { step: 'parsing', pct: 30 })\n\n // Load kernel-dsl\n let kernel: any\n try {\n await initKernel()\n kernel = new AgentDSLKernel()\n kernel.load_behavior(behaviorText)\n } catch (err: any) {\n // Kernel failed - create a stub\n kernel = {\n get_current_state: () => 'init',\n get_graph: () => ({}),\n get_memory: () => [],\n get_valid_intents: () => [],\n load_behavior: () => {},\n observe: () => {},\n send_complete: () => {},\n send_event: () => {},\n send_failed: () => {},\n send_fallback: () => {},\n send_intent: () => {},\n send_offtopic: () => {},\n tick_prompt: () => {},\n free: () => {},\n }\n }\n\n context.emit('progress', { step: 'loading-files', pct: 60 })\n\n // Load files\n const soulFile = zip.file('SOUL.md')\n const soul = soulFile ? await soulFile.async('text') : undefined\n\n const allFiles = await extractFiles(zip)\n const guides: FileEntry[] = []\n const knowledge: FileEntry[] = []\n const behaviors: FileEntry[] = []\n\n for (const [path, content] of allFiles) {\n if (path.startsWith('guides/') && path !== 'guides/.gitkeep') {\n guides.push({ path, content })\n } else if (path.startsWith('knowledge/') && path !== 'knowledge/.gitkeep') {\n knowledge.push({ path, content })\n } else if (path.startsWith('behaviors/') && path !== 'behaviors/.gitkeep') {\n behaviors.push({ path, content })\n }\n }\n\n context.id = id\n context.description = { domain: 'example.com', name: 'Agent' }\n context.behavior = {}\n context.kernel = kernel\n context.files = { soul, guides, knowledge, behaviors }\n context.aboutme = aboutme\n } else {\n // Load from directory\n const descPath = `${source}/agent.description`\n const behavPath = `${source}/agent.behavior`\n\n try {\n descriptionText = await readFile(descPath, 'utf-8')\n } catch {\n throw new Error(`Missing agent.description at ${descPath}`)\n }\n\n try {\n behaviorText = await readFile(behavPath, 'utf-8')\n } catch {\n throw new Error(`Missing agent.behavior at ${behavPath}`)\n }\n\n context.emit('progress', { step: 'parsing', pct: 30 })\n\n // Load kernel-dsl\n let kernel: any\n try {\n await initKernel()\n kernel = new AgentDSLKernel()\n kernel.load_behavior(behaviorText)\n } catch (err: any) {\n // Kernel failed - create a stub\n kernel = {\n get_current_state: () => 'init',\n get_graph: () => ({}),\n get_memory: () => [],\n get_valid_intents: () => [],\n load_behavior: () => {},\n observe: () => {},\n send_complete: () => {},\n send_event: () => {},\n send_failed: () => {},\n send_fallback: () => {},\n send_intent: () => {},\n send_offtopic: () => {},\n tick_prompt: () => {},\n free: () => {},\n }\n }\n\n context.emit('progress', { step: 'loading-files', pct: 60 })\n\n id = 'local/agent:v1.0~unknown'\n\n try {\n const soul = await readFile(`${source}/SOUL.md`, 'utf-8')\n context.files = {\n soul,\n guides: [],\n knowledge: [],\n behaviors: [],\n }\n } catch {\n context.files = { guides: [], knowledge: [], behaviors: [] }\n }\n\n const defaultAboutme: any = {\n schemaVersion: 'dot-agent/1.0',\n id,\n name: 'Agent',\n description: '',\n version: 'v1.0',\n domain: 'local',\n license: 'Apache-2.0',\n persona: 'SOUL.md',\n compiler: 'dot-agent/1.0.0',\n skills: [],\n requires: [],\n integrity: { sha256: '', files: '' },\n }\n\n context.id = id\n context.description = { domain: 'example.com', name: 'Agent' }\n context.behavior = {}\n context.kernel = kernel\n context.aboutme = defaultAboutme\n }\n\n context.emit('progress', { step: 'ready', pct: 100 })\n context.emit('ready', context)\n\n return context\n } catch (err) {\n context.emit('error', err)\n throw err\n }\n}\n","#!/usr/bin/env node\n\nimport { init, pack, unpack, run } from './index.js'\n\nconst args = process.argv.slice(2)\nconst command = args[0]\n\nfunction formatError(msg: string) {\n const lines = msg.split('\\n')\n console.error(`\\x1b[31m✗\\x1b[0m ${lines[0]}`)\n if (lines.length > 1) {\n lines.slice(1).forEach(line => console.error(` ${line}`))\n }\n}\n\nfunction formatSuccess(msg: string) {\n console.log(`\\x1b[32m✓\\x1b[0m ${msg}`)\n}\n\nfunction formatWarning(msg: string) {\n console.warn(`\\x1b[33m⚠\\x1b[0m ${msg}`)\n}\n\nasync function main() {\n try {\n if (command === 'init') {\n const options: any = {}\n for (let i = 1; i < args.length; i++) {\n if (args[i] === '--name' && i + 1 < args.length) options.name = args[++i]\n if (args[i] === '--domain' && i + 1 < args.length) options.domain = args[++i]\n if (args[i] === '--dir' && i + 1 < args.length) options.dir = args[++i]\n }\n\n const result = await init(options)\n formatSuccess(`Scaffolded agent project in ${result.dir}`)\n console.log(` Files: ${result.files.join(', ')}`)\n } else if (command === 'pack') {\n const options: any = {}\n for (let i = 1; i < args.length; i++) {\n if (args[i] === '--dir' && i + 1 < args.length) options.dir = args[++i]\n if (args[i] === '--out' && i + 1 < args.length) options.out = args[++i]\n if (args[i] === '--commit' && i + 1 < args.length) options.commit = args[++i]\n if (args[i] === '--version' && i + 1 < args.length) options.version = args[++i]\n }\n\n const result = await pack(options)\n formatSuccess(`Packed → ${result.path}`)\n console.log(` ID: ${result.id}`)\n if (result.warnings.length > 0) {\n console.log(` Warnings: ${result.warnings.length}`)\n result.warnings.forEach(w => {\n formatWarning(`${w.file}:${w.line}:${w.col} ${w.code} ${w.message}`)\n })\n }\n } else if (command === 'unpack') {\n const file = args[1]\n if (!file) {\n formatError('Usage: dot-agent unpack <file.agent> [--out <dir>] [--force]')\n process.exit(1)\n }\n\n const options: any = { file }\n for (let i = 2; i < args.length; i++) {\n if (args[i] === '--out' && i + 1 < args.length) options.out = args[++i]\n if (args[i] === '--force') options.force = true\n }\n\n const result = await unpack(options)\n formatSuccess(`Unpacked to ${result.dir}`)\n console.log(` ID: ${result.id}`)\n console.log(` Files: ${result.files.length}`)\n } else if (command === 'run') {\n const source = args[1]\n if (!source) {\n formatError('Usage: dot-agent run <file.agent | dir>')\n process.exit(1)\n }\n\n const context = await run({ source })\n formatSuccess(`Agent loaded: ${context.id}`)\n } else {\n console.log(`dot-agent CLI v1.0.0\n\nUsage:\n dot-agent init [--name <name>] [--domain <domain>] [--dir <dir>]\n dot-agent pack [--dir <dir>] [--out <file>] [--commit <hash>] [--version <tag>]\n dot-agent unpack <file.agent> [--out <dir>] [--force]\n dot-agent run <file.agent | dir>\n`)\n }\n } catch (err: any) {\n formatError(err.message)\n process.exit(1)\n }\n}\n\nmain()\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAKA,IAAM,mBAAmB,MACvB,OAAO,aAAa,cAChB,IAAI,IAAI,QAAQ,UAAU,EAAE,EAAE,O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AAM,UAAU,MAAM,IAAI,EAAE,OAAO,CAAC;AACpC,oBAAc,iBAAiB,QAAQ,EAAE,EAAE;AAAA,IAC7C,OAAO;AACL,cAAQ,IAAI;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAOjB;AAAA,IACG;AAAA,EACF,SAAS,KAAU;AACjB,gBAAY,IAAI,OAAO;AACvB,YAAQ,KAAK,CAAC;AAAA,EAChB;AACF;AAEA,KAAK;","names":["import_promises","import_path","import_jszip","require","initKernel","import_promises","JSZip","JSZip","import_promises","import_path","import_promises","import_kernel_dsl","initKernel"]}
1
+ {"version":3,"sources":["../node_modules/tsup/assets/cjs_shims.js","../src/commands/init.ts","../src/commands/pack.ts","../src/core/lint.ts","../src/core/id.ts","../src/core/envelope.ts","../src/core/zip.ts","../src/commands/unpack.ts","../src/commands/run.ts","../src/cli.ts"],"sourcesContent":["// Shim globals in cjs bundle\n// There's a weird bug that esbuild will always inject importMetaUrl\n// if we export it as `const importMetaUrl = ... __filename ...`\n// But using a function will not cause this issue\n\nconst getImportMetaUrl = () => \n typeof document === \"undefined\" \n ? new URL(`file:${__filename}`).href \n : (document.currentScript && document.currentScript.tagName.toUpperCase() === 'SCRIPT') \n ? document.currentScript.src \n : new URL(\"main.js\", document.baseURI).href;\n\nexport const importMetaUrl = /* @__PURE__ */ getImportMetaUrl()\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 { mkdir, writeFile, stat } from 'fs/promises'\nimport { join, basename } from 'path'\nimport { InitOptions, InitResult } from '../types.js'\n\nconst AGENT_DESCRIPTION_TEMPLATE = (name: string, domain: string) => `agent ${name}\n domain ${domain}\n license Apache-2.0\n\ndescription\n Describe what this agent does.\n\nbehavior agent.behavior\n\ncapabilities\n ActionName \"Describe this capability\"\n`\n\nconst AGENT_BEHAVIOR_TEMPLATE = `state init\n transition to responsive\n\nstate responsive\n goal \"Help the user with their task.\"\n interact\n on intent \"start\" transition to responsive\n`\n\nconst SOUL_TEMPLATE = (name: string) => `# ${name} — Persona\n\n## Voice and Tone\n\nDescribe the agent's voice, personality, and communication style.\n`\n\nconst README_TEMPLATE = (name: string) => `# ${name}\n\nBrief description of what this agent does.\n\n## Usage\n\nExample of how to use this agent.\n`\n\nconst LICENSE = `Apache License\nVersion 2.0, January 2004\n\nhttp://www.apache.org/licenses/\n\nTERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION\n`\n\nexport async function init(options: InitOptions = {}): Promise<InitResult> {\n const dir = options.dir || process.cwd()\n const name = options.name || basename(dir)\n const domain = options.domain || 'example.com'\n\n try {\n await stat(dir)\n } catch {\n await mkdir(dir, { recursive: true })\n }\n\n const agentDescriptionPath = join(dir, 'agent.description')\n try {\n await stat(agentDescriptionPath)\n throw new Error(`agent.description already exists at ${agentDescriptionPath}`)\n } catch (err: any) {\n if (err.code !== 'ENOENT') throw err\n }\n\n const files: string[] = []\n\n await writeFile(agentDescriptionPath, AGENT_DESCRIPTION_TEMPLATE(name, domain))\n files.push('agent.description')\n\n await writeFile(join(dir, 'agent.behavior'), AGENT_BEHAVIOR_TEMPLATE)\n files.push('agent.behavior')\n\n await writeFile(join(dir, 'SOUL.md'), SOUL_TEMPLATE(name))\n files.push('SOUL.md')\n\n await writeFile(join(dir, 'README.md'), README_TEMPLATE(name))\n files.push('README.md')\n\n await writeFile(join(dir, 'LICENSE'), LICENSE)\n files.push('LICENSE')\n\n await mkdir(join(dir, 'behaviors'), { recursive: true })\n await writeFile(join(dir, 'behaviors', '.gitkeep'), '')\n files.push('behaviors/.gitkeep')\n\n await mkdir(join(dir, 'guides'), { recursive: true })\n await writeFile(join(dir, 'guides', '.gitkeep'), '')\n files.push('guides/.gitkeep')\n\n await mkdir(join(dir, 'knowledge'), { recursive: true })\n await writeFile(join(dir, 'knowledge', '.gitkeep'), '')\n files.push('knowledge/.gitkeep')\n\n await writeFile(join(dir, 'AGENTS.md'), '')\n files.push('AGENTS.md')\n\n return { dir, files }\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 { readFile, stat, readdir } from 'fs/promises'\nimport { join, basename, dirname } from 'path'\nimport { execSync } from 'child_process'\nimport { createHash } from 'crypto'\nimport JSZip from 'jszip'\nimport { PackOptions, PackResult, LintMessage } from '../types.js'\nimport { createLinter } from '../core/lint.js'\nimport { buildId } from '../core/id.js'\nimport { buildAboutme, aboutmeToJson } from '../core/envelope.js'\nimport { buildTypesJson } from '../core/types.js'\nimport { writeZip } from '../core/zip.js'\n\nfunction gitDescribeTags(): string | null {\n try {\n return execSync('git describe --tags --abbrev=0', {\n stdio: 'pipe',\n encoding: 'utf-8',\n }).trim()\n } catch {\n return null\n }\n}\n\nfunction gitRevParseShort(): string | null {\n try {\n return execSync('git rev-parse --short HEAD', {\n stdio: 'pipe',\n encoding: 'utf-8',\n }).trim()\n } catch {\n return null\n }\n}\n\nasync function resolveVersion(explicit?: string): Promise<string> {\n if (explicit) return explicit\n\n const gitTag = gitDescribeTags()\n if (gitTag) return gitTag\n\n return 'v1.0.0'\n}\n\nasync function resolveCommit(explicit?: string): Promise<string | undefined> {\n if (explicit) return explicit\n return gitRevParseShort() || undefined\n}\n\nasync function collectFiles(dir: string): Promise<Map<string, string>> {\n const files = new Map<string, string>()\n\n async function walk(subdir: string, prefix: string = '') {\n try {\n const entries = await readdir(subdir)\n for (const entry of entries) {\n if (entry === '.gitkeep' || entry.startsWith('.')) continue\n\n const fullPath = join(subdir, entry)\n const stats = await stat(fullPath)\n const relativePath = prefix ? `${prefix}/${entry}` : entry\n\n if (stats.isDirectory()) {\n await walk(fullPath, relativePath)\n } else {\n const content = await readFile(fullPath, 'utf-8')\n files.set(relativePath, content)\n }\n }\n } catch {\n // directory doesn't exist or can't be read\n }\n }\n\n const description = await readFile(join(dir, 'agent.description'), 'utf-8')\n files.set('agent.description', description)\n\n const behavior = await readFile(join(dir, 'agent.behavior'), 'utf-8')\n files.set('agent.behavior', behavior)\n\n try {\n const soul = await readFile(join(dir, 'SOUL.md'), 'utf-8')\n files.set('SOUL.md', soul)\n } catch {\n // optional\n }\n\n await walk(join(dir, 'behaviors'), 'behaviors')\n await walk(join(dir, 'guides'), 'guides')\n await walk(join(dir, 'knowledge'), 'knowledge')\n\n return files\n}\n\nfunction parseDescription(text: string): any {\n const domain = text.match(/domain\\s+([^\\n]+)/)?.[1] || ''\n const name = text.match(/agent\\s+([^\\n]+)/)?.[1] || ''\n const description = text.match(/description\\s+(.+?)(?=\\n\\n|\\n[a-z])/s)?.[1] || ''\n\n return {\n domain: domain.trim(),\n name: name.trim(),\n description: description.trim(),\n capabilities: [],\n }\n}\n\nexport async function pack(options: PackOptions = {}): Promise<PackResult> {\n const dir = options.dir || process.cwd()\n const outPath = options.out || join(dir, `${basename(dir)}.agent`)\n\n // Read files\n let descriptionText: string\n let behaviorText: string\n\n try {\n descriptionText = await readFile(join(dir, 'agent.description'), 'utf-8')\n } catch {\n throw new Error('E003: File agent.description not found')\n }\n\n try {\n behaviorText = await readFile(join(dir, 'agent.behavior'), 'utf-8')\n } catch {\n throw new Error('E007: File agent.behavior not found')\n }\n\n // Lint\n const linter = await createLinter()\n const descriptionMessages = await linter.lintDescription(descriptionText)\n const behaviorMessages = await linter.lintBehavior(behaviorText)\n\n const allMessages = [...descriptionMessages, ...behaviorMessages]\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(`Lint failed: ${errors.map(e => `${e.file}:${e.line}:${e.col} ${e.code} ${e.message}`).join('\\n')}`)\n }\n\n // Parse description\n const description = parseDescription(descriptionText)\n\n // Resolve version & commit\n const version = await resolveVersion(options.version)\n const commit = await resolveCommit(options.commit)\n\n // Collect all files\n const allFiles = await collectFiles(dir)\n\n // Build ID\n const contentForHash = Array.from(allFiles.values()).join('')\n const digest = createHash('sha256').update(contentForHash).digest('hex').substring(0, 8)\n const id = buildId({\n namespace: description.domain,\n name: description.name,\n version,\n digest,\n })\n\n // Build aboutme\n const aboutme = buildAboutme({\n id,\n name: description.name,\n description: description.description,\n version,\n domain: description.domain,\n license: 'Apache-2.0',\n persona: 'SOUL.md',\n compiler: 'dot-agent/1.0.0',\n commit,\n skills: [],\n requires: [],\n integrity: {\n sha256: createHash('sha256').update(contentForHash).digest('hex'),\n files: '.agent/files.json',\n },\n })\n\n // Build ZIP\n const zip = new JSZip()\n\n zip.folder('.agent')!.file('aboutme.json', aboutmeToJson(aboutme))\n\n // Build files.json\n const filesJson = {\n description: 'agent.description',\n behavior: 'agent.behavior',\n behaviors: Array.from(allFiles.keys())\n .filter(f => f.startsWith('behaviors/') && f !== 'behaviors/.gitkeep')\n .map(f => f),\n guides: Array.from(allFiles.keys())\n .filter(f => f.startsWith('guides/') && f !== 'guides/.gitkeep')\n .map(f => f),\n knowledge: Array.from(allFiles.keys())\n .filter(f => f.startsWith('knowledge/') && f !== 'knowledge/.gitkeep')\n .map(f => f),\n }\n\n zip.folder('.agent')!.file('files.json', JSON.stringify(filesJson, null, 2))\n\n // Add all files to ZIP root\n for (const [path, content] of allFiles) {\n if (path !== 'behaviors/.gitkeep' && path !== 'guides/.gitkeep' && path !== 'knowledge/.gitkeep') {\n zip.file(path, content)\n }\n }\n\n // Write ZIP\n await writeZip(zip, outPath)\n\n return {\n path: outPath,\n id,\n warnings,\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//\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 { createRequire } from 'module'\nimport { Parser, Language } from 'web-tree-sitter'\nimport { AgentDSLKernel, init as initKernel } from '@dot-agent/kernel-dsl'\nimport { LintMessage } from '../types.js'\n\nconst require = createRequire(import.meta.url)\nconst { agentWasmPath, behaviorWasmPath } = require('@dot-agent/tree-sitter')\n\ndeclare module '@dot-agent/tree-sitter' {\n export const agentWasmPath: string\n export const behaviorWasmPath: string\n}\n\nlet _initialized = false\nlet _agentParser: Parser\nlet _behaviorParser: Parser\nlet _agentLang: any\nlet _behaviorLang: any\n\nasync function ensureWasmInit() {\n if (_initialized) return\n\n try {\n await Parser.init()\n } catch (err) {\n throw err\n }\n\n _agentParser = new Parser()\n _behaviorParser = new Parser()\n\n try {\n _agentLang = await Language.load(agentWasmPath)\n _behaviorLang = await Language.load(behaviorWasmPath)\n } catch (err) {\n throw err\n }\n\n try {\n await initKernel()\n } catch (err) {\n // Silently fail - kernel might not be available in all environments\n // We can continue with tree-sitter only for syntax checking\n }\n\n _initialized = true\n}\n\nfunction collectSyntaxErrors(node: Parser.SyntaxNode): Parser.SyntaxNode[] {\n const errors: Parser.SyntaxNode[] = []\n if (node.isError || node.isMissing) errors.push(node)\n for (const child of node.children) {\n errors.push(...collectSyntaxErrors(child))\n }\n return errors\n}\n\nfunction getLineCol(node: Parser.SyntaxNode): { line: number; col: number } {\n return { line: node.startPosition.row + 1, col: node.startPosition.column + 1 }\n}\n\nexport async function lintDescription(text: string): Promise<LintMessage[]> {\n await ensureWasmInit()\n\n _agentParser.setLanguage(_agentLang)\n const tree = _agentParser.parse(text)\n const messages: LintMessage[] = []\n\n const syntaxErrors = collectSyntaxErrors(tree.rootNode)\n if (syntaxErrors.length > 0) {\n for (const error of syntaxErrors) {\n const { line, col } = getLineCol(error)\n messages.push({\n file: 'agent.description',\n line,\n col,\n severity: 'error',\n code: 'E004',\n message: 'Syntax error in description',\n })\n }\n }\n\n const walk = (node: Parser.SyntaxNode) => {\n if (node.type === 'domain_declaration' && node.childCount > 0) {\n const valueNode = node.child(node.childCount - 1)\n if (valueNode && valueNode.text === 'example.com') {\n const { line, col } = getLineCol(valueNode)\n messages.push({\n file: 'agent.description',\n line,\n col,\n severity: 'warning',\n code: 'W003',\n message: 'domain still has default value \"example.com\"',\n })\n }\n }\n for (const child of node.children) walk(child)\n }\n walk(tree.rootNode)\n\n return messages\n}\n\nexport async function lintBehavior(text: string): Promise<LintMessage[]> {\n await ensureWasmInit()\n\n _behaviorParser.setLanguage(_behaviorLang)\n const tree = _behaviorParser.parse(text)\n const messages: LintMessage[] = []\n\n const syntaxErrors = collectSyntaxErrors(tree.rootNode)\n if (syntaxErrors.length > 0) {\n for (const error of syntaxErrors) {\n const { line, col } = getLineCol(error)\n messages.push({\n file: 'agent.behavior',\n line,\n col,\n severity: 'error',\n code: 'E004',\n message: 'Syntax error in behavior DSL',\n })\n }\n }\n\n const walk = (node: Parser.SyntaxNode) => {\n if (node.type === 'text_block') {\n if (node.text.length > 280) {\n const { line, col } = getLineCol(node)\n messages.push({\n file: 'agent.behavior',\n line,\n col,\n severity: 'warning',\n code: 'W002',\n message: `Text block exceeds 280 characters (${node.text.length})`,\n })\n }\n }\n for (const child of node.children) walk(child)\n }\n walk(tree.rootNode)\n\n try {\n const kernel = new AgentDSLKernel()\n try {\n const effects = kernel.load_behavior(text)\n\n if (Array.isArray(effects)) {\n for (const effect of effects) {\n if (effect.type === 'parse_error') {\n messages.push({\n file: 'agent.behavior',\n line: 1,\n col: 1,\n severity: 'error',\n code: 'E006',\n message: `Parse error: ${effect.message}`,\n })\n }\n }\n }\n\n const graph = kernel.get_graph()\n if (graph?.states) {\n for (const stateName of Object.keys(graph.states)) {\n const state = graph.states[stateName]\n const hasIncoming = graph.transitions?.some((t: any) => t.to === stateName)\n const hasOutgoing = graph.transitions?.some((t: any) => t.from === stateName)\n\n if (!hasIncoming && !hasOutgoing && stateName !== graph.current) {\n messages.push({\n file: 'agent.behavior',\n line: 1,\n col: 1,\n severity: 'warning',\n code: 'W001',\n message: `state \"${stateName}\" has no transitions`,\n })\n }\n }\n }\n } catch (kernelErr: any) {\n // Kernel load failed - skip semantic checks, syntax errors already caught by tree-sitter\n }\n } catch (err: any) {\n // Could not initialize kernel - skip semantic checks\n }\n\n return messages\n}\n\nexport async function createLinter() {\n await ensureWasmInit()\n\n return {\n lintDescription,\n lintBehavior,\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//\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\nexport interface IdParts {\n namespace: string\n name: string\n version: string\n digest: string\n}\n\nexport function parseId(id: string): IdParts {\n const match = id.match(/^(.+)\\/(.+):(.+)~(.+)$/)\n if (!match) {\n throw new Error(`Invalid agent ID format: ${id}. Expected: namespace/name:version~digest`)\n }\n const [, namespace, name, version, digest] = match\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 || !version || !digest) {\n throw new Error('Missing required ID parts: namespace, name, version, digest')\n }\n return `${namespace}/${name}:${version}~${digest}`\n}\n\nexport function extractDigest(id: string): string {\n try {\n const parts = parseId(id)\n return parts.digest\n } catch {\n return ''\n }\n}\n\nexport function extractName(id: string): string {\n try {\n const parts = parseId(id)\n return parts.name\n } catch {\n return ''\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//\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 { AboutMe, Integrity, Skill } from '../types.js'\n\nexport function parseAboutme(json: any): AboutMe {\n if (!json.schemaVersion) throw new Error('Missing schemaVersion 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.version) throw new Error('Missing version in aboutme.json')\n if (!json.domain) throw new Error('Missing domain in aboutme.json')\n if (!json.license) throw new Error('Missing license in aboutme.json')\n if (!json.persona) throw new Error('Missing persona in aboutme.json')\n if (!json.compiler) throw new Error('Missing compiler in aboutme.json')\n if (!Array.isArray(json.skills)) throw new Error('Missing skills 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 schemaVersion: json.schemaVersion,\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 compiler: json.compiler,\n commit: json.commit,\n skills: json.skills,\n requires: json.requires,\n integrity: json.integrity,\n }\n}\n\nexport interface BuildAboutmeOptions {\n id: string\n name: string\n description: string\n version: string\n domain: string\n license?: string\n persona: string\n compiler: string\n commit?: string\n skills?: Skill[]\n requires?: string[]\n integrity: Integrity\n}\n\nexport function buildAboutme(opts: BuildAboutmeOptions): AboutMe {\n return {\n schemaVersion: 'dot-agent/1.0',\n id: opts.id,\n name: opts.name,\n description: opts.description,\n version: opts.version,\n domain: opts.domain,\n license: opts.license || 'Apache-2.0',\n persona: opts.persona,\n compiler: opts.compiler,\n commit: opts.commit,\n skills: opts.skills || [],\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","// 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'\n\nconst MAX_ZIP_SIZE = 500 * 1024 * 1024\nconst MAX_COMPRESSION_RATIO = 100\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\n let totalUncompressed = 0\n zip.forEach((relativePath, file) => {\n if (!file.dir) {\n totalUncompressed += file._data?.uncompressedSize || 0\n }\n })\n\n const compressedSize = data.length\n const ratio = totalUncompressed / compressedSize\n\n if (totalUncompressed > MAX_ZIP_SIZE) {\n throw new Error(`ZIP uncompressed size exceeds 500MB limit: ${totalUncompressed}`)\n }\n\n if (ratio > MAX_COMPRESSION_RATIO) {\n throw new Error(`ZIP compression ratio exceeds 100x limit: ${ratio.toFixed(1)}x`)\n }\n\n return true\n}\n\nexport async function extractFiles(\n zip: JSZip,\n filter?: string[]\n): Promise<Map<string, string>> {\n const files = new Map<string, string>()\n\n const promises: Promise<void>[] = []\n zip.forEach((relativePath, file) => {\n if (file.dir) return\n if (filter && !filter.some(f => relativePath.startsWith(f))) return\n\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\nexport function createZip(): JSZip {\n return new JSZip()\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\nexport async function validateMagicBytes(filePath: string): Promise<boolean> {\n const data = await readFile(filePath)\n const magicBytes = data.subarray(0, 4)\n const isZip = magicBytes[0] === 0x50 && magicBytes[1] === 0x4b && magicBytes[2] === 0x03 && magicBytes[3] === 0x04\n if (!isZip) {\n throw new Error('File is not a valid ZIP (invalid magic bytes)')\n }\n return true\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 { mkdir, writeFile, stat } from 'fs/promises'\nimport { join } from 'path'\nimport { createHash } from 'crypto'\nimport { UnpackOptions, UnpackResult } from '../types.js'\nimport { readZip, validateZipBomb, validateMagicBytes, extractFiles } from '../core/zip.js'\nimport { parseAboutme } from '../core/envelope.js'\n\nexport async function unpack(options: UnpackOptions): Promise<UnpackResult> {\n const { file, out, force = false } = options\n\n // Validate magic bytes\n await validateMagicBytes(file)\n\n // Validate ZIP bomb\n await validateZipBomb(file)\n\n // Load ZIP\n const zip = await readZip(file)\n\n // Read aboutme.json\n const aboutmeFile = zip.file('.agent/aboutme.json')\n if (!aboutmeFile) {\n throw new Error('Missing .agent/aboutme.json in ZIP')\n }\n\n const aboutmeText = await aboutmeFile.async('text')\n const aboutme = parseAboutme(JSON.parse(aboutmeText))\n\n // Extract output directory\n const outDir = out || `./${aboutme.name}`\n\n // Check if directory exists\n try {\n await stat(outDir)\n if (!force) {\n throw new Error(`Output directory already exists: ${outDir}. Use --force to overwrite.`)\n }\n } catch (err: any) {\n if (err.code !== 'ENOENT') throw err\n }\n\n // Extract all files from root\n const files = await extractFiles(zip)\n await mkdir(outDir, { recursive: true })\n\n const extractedFiles: string[] = []\n\n for (const [path, content] of files) {\n if (path.startsWith('.agent/')) continue\n\n const fullPath = join(outDir, path)\n const dir = fullPath.substring(0, fullPath.lastIndexOf('/'))\n\n await mkdir(dir, { recursive: true })\n await writeFile(fullPath, content)\n extractedFiles.push(path)\n }\n\n return {\n dir: outDir,\n id: aboutme.id,\n files: extractedFiles,\n aboutme,\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//\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 { EventEmitter } from 'events'\nimport { readFile, stat } from 'fs/promises'\nimport { AgentDSLKernel, init as initKernel } from '@dot-agent/kernel-dsl'\nimport { RunOptions, AgentContext, FileEntry } from '../types.js'\nimport { readZip, validateZipBomb, validateMagicBytes, extractFiles } from '../core/zip.js'\nimport { parseAboutme } from '../core/envelope.js'\n\nfunction isZipFile(source: string): boolean {\n return source.endsWith('.agent')\n}\n\nexport async function run(options: RunOptions): Promise<AgentContext> {\n const { source } = options\n const context = new EventEmitter() as any as AgentContext\n\n try {\n context.emit('progress', { step: 'opening', pct: 0 })\n\n let descriptionText: string\n let behaviorText: string\n let aboutme: any = null\n let id: string\n\n if (isZipFile(source)) {\n // Load from .agent ZIP\n await validateMagicBytes(source)\n await validateZipBomb(source)\n\n const zip = await readZip(source)\n\n const aboutmeFile = zip.file('.agent/aboutme.json')\n if (!aboutmeFile) {\n throw new Error('Missing .agent/aboutme.json')\n }\n\n const aboutmeText = await aboutmeFile.async('text')\n aboutme = parseAboutme(JSON.parse(aboutmeText))\n id = aboutme.id\n\n const descFile = zip.file('agent.description')\n if (!descFile) throw new Error('Missing agent.description')\n descriptionText = await descFile.async('text')\n\n const behavFile = zip.file('agent.behavior')\n if (!behavFile) throw new Error('Missing agent.behavior')\n behaviorText = await behavFile.async('text')\n\n context.emit('progress', { step: 'parsing', pct: 30 })\n\n // Load kernel-dsl\n let kernel: any\n try {\n await initKernel()\n kernel = new AgentDSLKernel()\n kernel.load_behavior(behaviorText)\n } catch (err: any) {\n // Kernel failed - create a stub\n kernel = {\n get_current_state: () => 'init',\n get_graph: () => ({}),\n get_memory: () => [],\n get_valid_intents: () => [],\n load_behavior: () => {},\n observe: () => {},\n send_complete: () => {},\n send_event: () => {},\n send_failed: () => {},\n send_fallback: () => {},\n send_intent: () => {},\n send_offtopic: () => {},\n tick_prompt: () => {},\n free: () => {},\n }\n }\n\n context.emit('progress', { step: 'loading-files', pct: 60 })\n\n // Load files\n const soulFile = zip.file('SOUL.md')\n const soul = soulFile ? await soulFile.async('text') : undefined\n\n const allFiles = await extractFiles(zip)\n const guides: FileEntry[] = []\n const knowledge: FileEntry[] = []\n const behaviors: FileEntry[] = []\n\n for (const [path, content] of allFiles) {\n if (path.startsWith('guides/') && path !== 'guides/.gitkeep') {\n guides.push({ path, content })\n } else if (path.startsWith('knowledge/') && path !== 'knowledge/.gitkeep') {\n knowledge.push({ path, content })\n } else if (path.startsWith('behaviors/') && path !== 'behaviors/.gitkeep') {\n behaviors.push({ path, content })\n }\n }\n\n context.id = id\n context.description = { domain: 'example.com', name: 'Agent' }\n context.behavior = {}\n context.kernel = kernel\n context.files = { soul, guides, knowledge, behaviors }\n context.aboutme = aboutme\n } else {\n // Load from directory\n const descPath = `${source}/agent.description`\n const behavPath = `${source}/agent.behavior`\n\n try {\n descriptionText = await readFile(descPath, 'utf-8')\n } catch {\n throw new Error(`Missing agent.description at ${descPath}`)\n }\n\n try {\n behaviorText = await readFile(behavPath, 'utf-8')\n } catch {\n throw new Error(`Missing agent.behavior at ${behavPath}`)\n }\n\n context.emit('progress', { step: 'parsing', pct: 30 })\n\n // Load kernel-dsl\n let kernel: any\n try {\n await initKernel()\n kernel = new AgentDSLKernel()\n kernel.load_behavior(behaviorText)\n } catch (err: any) {\n // Kernel failed - create a stub\n kernel = {\n get_current_state: () => 'init',\n get_graph: () => ({}),\n get_memory: () => [],\n get_valid_intents: () => [],\n load_behavior: () => {},\n observe: () => {},\n send_complete: () => {},\n send_event: () => {},\n send_failed: () => {},\n send_fallback: () => {},\n send_intent: () => {},\n send_offtopic: () => {},\n tick_prompt: () => {},\n free: () => {},\n }\n }\n\n context.emit('progress', { step: 'loading-files', pct: 60 })\n\n id = 'local/agent:v1.0~unknown'\n\n try {\n const soul = await readFile(`${source}/SOUL.md`, 'utf-8')\n context.files = {\n soul,\n guides: [],\n knowledge: [],\n behaviors: [],\n }\n } catch {\n context.files = { guides: [], knowledge: [], behaviors: [] }\n }\n\n const defaultAboutme: any = {\n schemaVersion: 'dot-agent/1.0',\n id,\n name: 'Agent',\n description: '',\n version: 'v1.0',\n domain: 'local',\n license: 'Apache-2.0',\n persona: 'SOUL.md',\n compiler: 'dot-agent/1.0.0',\n skills: [],\n requires: [],\n integrity: { sha256: '', files: '' },\n }\n\n context.id = id\n context.description = { domain: 'example.com', name: 'Agent' }\n context.behavior = {}\n context.kernel = kernel\n context.aboutme = defaultAboutme\n }\n\n context.emit('progress', { step: 'ready', pct: 100 })\n context.emit('ready', context)\n\n return context\n } catch (err) {\n context.emit('error', err)\n throw err\n }\n}\n","#!/usr/bin/env node\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 { init, pack, unpack, run } from './index.js'\n\nconst args = process.argv.slice(2)\nconst command = args[0]\n\nfunction formatError(msg: string) {\n const lines = msg.split('\\n')\n console.error(`\\x1b[31m✗\\x1b[0m ${lines[0]}`)\n if (lines.length > 1) {\n lines.slice(1).forEach(line => console.error(` ${line}`))\n }\n}\n\nfunction formatSuccess(msg: string) {\n console.log(`\\x1b[32m✓\\x1b[0m ${msg}`)\n}\n\nfunction formatWarning(msg: string) {\n console.warn(`\\x1b[33m⚠\\x1b[0m ${msg}`)\n}\n\nasync function main() {\n try {\n if (command === 'init') {\n const options: any = {}\n for (let i = 1; i < args.length; i++) {\n if (args[i] === '--name' && i + 1 < args.length) options.name = args[++i]\n if (args[i] === '--domain' && i + 1 < args.length) options.domain = args[++i]\n if (args[i] === '--dir' && i + 1 < args.length) options.dir = args[++i]\n }\n\n const result = await init(options)\n formatSuccess(`Scaffolded agent project in ${result.dir}`)\n console.log(` Files: ${result.files.join(', ')}`)\n } else if (command === 'pack') {\n const options: any = {}\n for (let i = 1; i < args.length; i++) {\n if (args[i] === '--dir' && i + 1 < args.length) options.dir = args[++i]\n if (args[i] === '--out' && i + 1 < args.length) options.out = args[++i]\n if (args[i] === '--commit' && i + 1 < args.length) options.commit = args[++i]\n if (args[i] === '--version' && i + 1 < args.length) options.version = args[++i]\n }\n\n const result = await pack(options)\n formatSuccess(`Packed → ${result.path}`)\n console.log(` ID: ${result.id}`)\n if (result.warnings.length > 0) {\n console.log(` Warnings: ${result.warnings.length}`)\n result.warnings.forEach(w => {\n formatWarning(`${w.file}:${w.line}:${w.col} ${w.code} ${w.message}`)\n })\n }\n } else if (command === 'unpack') {\n const file = args[1]\n if (!file) {\n formatError('Usage: dot-agent unpack <file.agent> [--out <dir>] [--force]')\n process.exit(1)\n }\n\n const options: any = { file }\n for (let i = 2; i < args.length; i++) {\n if (args[i] === '--out' && i + 1 < args.length) options.out = args[++i]\n if (args[i] === '--force') options.force = true\n }\n\n const result = await unpack(options)\n formatSuccess(`Unpacked to ${result.dir}`)\n console.log(` ID: ${result.id}`)\n console.log(` Files: ${result.files.length}`)\n } else if (command === 'run') {\n const source = args[1]\n if (!source) {\n formatError('Usage: dot-agent run <file.agent | dir>')\n process.exit(1)\n }\n\n const context = await run({ source })\n formatSuccess(`Agent loaded: ${context.id}`)\n } else {\n console.log(`dot-agent CLI v1.0.0\n\nUsage:\n dot-agent init [--name <name>] [--domain <domain>] [--dir <dir>]\n dot-agent pack [--dir <dir>] [--out <file>] [--commit <hash>] [--version <tag>]\n dot-agent unpack <file.agent> [--out <dir>] [--force]\n dot-agent run <file.agent | dir>\n`)\n }\n } catch (err: any) {\n formatError(err.message)\n process.exit(1)\n }\n}\n\nmain()\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAKA,IAAM,mBAAmB,MACvB,OAAO,aAAa,cAChB,IAAI,IAAI,QAAQ,UAAU,EAAE,EAAE,OAC7B,SAAS,iBAAiB,SAAS,cAAc,QAAQ,YAAY,MAAM,WAC1E,SAAS,cAAc,MACvB,IAAI,IAAI,WAAW,SAAS,OAAO,EAAE;AAEtC,IAAM,gBAAgC,iCAAiB;;;ACE9D,sBAAuC;AACvC,kBAA+B;AAG/B,IAAM,6BAA6B,CAAC,MAAc,WAAmB,SAAS,IAAI;AAAA,WACvE,MAAM;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAYjB,IAAM,0BAA0B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAShC,IAAM,gBAAgB,CAAC,SAAiB,KAAK,IAAI;AAAA;AAAA;AAAA;AAAA;AAAA;AAOjD,IAAM,kBAAkB,CAAC,SA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IAAI,EAAE,OAAO,EAAE;AAAA,QACrE,CAAC;AAAA,MACH;AAAA,IACF,WAAW,YAAY,UAAU;AAC/B,YAAM,OAAO,KAAK,CAAC;AACnB,UAAI,CAAC,MAAM;AACT,oBAAY,8DAA8D;AAC1E,gBAAQ,KAAK,CAAC;AAAA,MAChB;AAEA,YAAM,UAAe,EAAE,KAAK;AAC5B,eAAS,IAAI,GAAG,IAAI,KAAK,QAAQ,KAAK;AACpC,YAAI,KAAK,CAAC,MAAM,WAAW,IAAI,IAAI,KAAK,OAAQ,SAAQ,MAAM,KAAK,EAAE,CAAC;AACtE,YAAI,KAAK,CAAC,MAAM,UAAW,SAAQ,QAAQ;AAAA,MAC7C;AAEA,YAAM,SAAS,MAAM,OAAO,OAAO;AACnC,oBAAc,eAAe,OAAO,GAAG,EAAE;AACzC,cAAQ,IAAI,SAAS,OAAO,EAAE,EAAE;AAChC,cAAQ,IAAI,YAAY,OAAO,MAAM,MAAM,EAAE;AAAA,IAC/C,WAAW,YAAY,OAAO;AAC5B,YAAM,SAAS,KAAK,CAAC;AACrB,UAAI,CAAC,QAAQ;AACX,oBAAY,yCAAyC;AACrD,gBAAQ,KAAK,CAAC;AAAA,MAChB;AAEA,YAAM,UAAU,MAAM,IAAI,EAAE,OAAO,CAAC;AACpC,oBAAc,iBAAiB,QAAQ,EAAE,EAAE;AAAA,IAC7C,OAAO;AACL,cAAQ,IAAI;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAOjB;AAAA,IACG;AAAA,EACF,SAAS,KAAU;AACjB,gBAAY,IAAI,OAAO;AACvB,YAAQ,KAAK,CAAC;AAAA,EAChB;AACF;AAEA,KAAK;","names":["import_promises","import_path","import_jszip","require","initKernel","import_promises","JSZip","JSZip","import_promises","import_path","import_promises","import_kernel_dsl","initKernel"]}