{"_id":"@0x800a6/author-txt","name":"@0x800a6/author-txt","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"@0x800a6/author-txt","version":"1.0.0","description":"Author DSL Parser – A robust parser for author configuration files with support for blocks, types, and multiline values.","main":"dist/index.js","module":"dist/index.mjs","types":"dist/index.d.ts","repository":{"type":"git","url":"git+https://github.com/0x800a6/author.txt.git"},"homepage":"https://github.com/0x800a6/author.txt#readme","bugs":{"url":"https://github.com/0x800a6/author.txt/issues"},"keywords":["dsl","parser","author.txt","config","typescript","library"],"author":{"name":"Lexi","email":"oss@0x800a6.dev","url":"0x800a6"},"license":"MIT","publishConfig":{"access":"public"},"devDependencies":{"docdash":"^2.0.0","jsdoc":"^4.0.2","jsdoc-to-markdown":"^8.0.0","prettier":"^3.3.3","ts-node":"^10.9.2","typescript":"^5.6.3"},"scripts":{"format":"prettier --cache --write . --ignore-path .prettierignore","build":"tsc","dev":"ts-node src/index.ts","start":"node dist/index.js","docs":"jsdoc -c jsdoc.conf.json","docs:md":"jsdoc2md dist/**/*.js > docs/api.md","docs:all":"node scripts/generate-docs.js"},"_id":"@0x800a6/author-txt@1.0.0","_integrity":"sha512-roIJuKGcHADyh6sTOBUb71ekLQyGr5J77WigXNIgZA8I5HBu6xH5pJCzk7fw6WM0XOk6ARbQLz/RZ1tTT9z6BQ==","_resolved":"/tmp/496e1ee41f8ef496d778dac0d6043190/0x800a6-author-txt-1.0.0.tgz","_from":"file:0x800a6-author-txt-1.0.0.tgz","_nodeVersion":"18.20.8","_npmVersion":"10.8.2","dist":{"integrity":"sha512-roIJuKGcHADyh6sTOBUb71ekLQyGr5J77WigXNIgZA8I5HBu6xH5pJCzk7fw6WM0XOk6ARbQLz/RZ1tTT9z6BQ==","shasum":"2352907b27e2f540bff48cc446104e5d024d9dae","tarball":"https://registry.npmjs.org/@0x800a6/author-txt/-/author-txt-1.0.0.tgz","fileCount":13,"unpackedSize":90247,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQDWwZ6w85VfDCe/+IOKRF+gISerMNv7RRhn2am5DwdFCQIhAPV5I7AiuMrfQD5CUaqelMB4juiPxmb9guzFb1m3H5ZU"}]},"_npmUser":{"name":"0x800a6","email":"oss@0x800a6.dev"},"directories":{},"maintainers":[{"name":"0x800a6","email":"oss@0x800a6.dev"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/author-txt_1.0.0_1758903788080_0.8594071683066371"},"_hasShrinkwrap":false}},"time":{"created":"2025-09-26T16:23:08.005Z","1.0.0":"2025-09-26T16:23:08.275Z","modified":"2025-09-26T16:23:08.584Z"},"maintainers":[{"name":"0x800a6","email":"oss@0x800a6.dev"}],"description":"Author DSL Parser – A robust parser for author configuration files with support for blocks, types, and multiline values.","homepage":"https://github.com/0x800a6/author.txt#readme","keywords":["dsl","parser","author.txt","config","typescript","library"],"repository":{"type":"git","url":"git+https://github.com/0x800a6/author.txt.git"},"author":{"name":"Lexi","email":"oss@0x800a6.dev","url":"0x800a6"},"bugs":{"url":"https://github.com/0x800a6/author.txt/issues"},"license":"MIT","readme":"# Author DSL Parser\n\nThe Author DSL parser reads and validates `author.txt` files. It turns them into a clean abstract syntax tree (AST) for use in scripts, websites, or applications. The format is designed for author profiles and metadata. It supports blocks, typed keys, lists, and multiline values.\n\nFull specification: [Author DSL Specification](https://0x800a6.dev/specs/author_txt)\n\n## Specification\n\n- File name: `author.txt`\n- Location: `/author.txt` or `/.well-known/author.txt`\n- Purpose: Provide machine-readable metadata about authors or maintainers.\n\nThe DSL is line-oriented. Each line is a statement, block, or comment.\n\n### Syntax Rules\n\n- **Comments**: Lines starting with `#` are ignored.  \n- **Statements**: `Key: Value` pairs.  \n- **Typed keys**: `Key@type: Value`. Common types include `url`, `email`, `date`, and `multiline`.  \n- **Blocks**: Begin with `Begin Name` and end with `End Name`.  \n- **Lists**: Repeated keys or comma-separated values.  \n- **Multiline values**: Use triple quotes `\"\"\"` to span multiple lines.  \n- **Includes**: `Include: <path>` to reference another file.  \n\n### Reserved Keys\n\n- `Author-DSL` – DSL version  \n- `Include` – references another file  \n- `Expires` – expiration date  \n- `PublicKey` / `Fingerprint` – optional identity proof  \n\n## Example\n\n```\n# Author file example\nAuthor-DSL: 1.0\nAuthor: Lexi\nHandle: 0x800a6\nAlias: lexi, author, sysprog\nWebsite@url: https://0x800a6.dev\nContact@email: mailto:lexi@example.com\n\nBio@multiline: \"\"\"\nSystems programmer.\nPrivacy advocate.\nInspired by Serial Experiments Lain.\n\"\"\"\n\nBegin Profile\n    Skills: Assembly, Rust, C, TypeScript\n    Motto: \"Building the future, one line at a time\"\nEnd Profile\n\nInclude: https://0x800a6.dev/more-links.txt\n```\n\n## AST Example\n\n```\n{\n  \"Author\": \"Lexi\",\n  \"Handle\": \"0x800a6\",\n  \"Alias\": [\"lexi\", \"author\", \"sysprog\"],\n  \"Website\": { \"type\": \"url\", \"value\": \"https://0x800a6.dev\" },\n  \"Bio\": \"Systems programmer.\\nPrivacy advocate.\\nInspired by Serial Experiments Lain.\",\n  \"Profile\": [\n    { \"Skills\": [\"Assembly\", \"Rust\", \"C\", \"TypeScript\"], \"Motto\": \"Building the future, one line at a time\" }\n  ]\n}\n```\n\n## Installation\n\n```bash\nnpm install @0x800a6/author-txt\n```\n\nor clone directly:\n\n```bash\ngit clone https://github.com/0x800a6/author.txt.git\ncd author.txt\n```\n\n## Usage\n\n### Basic Usage\n\n```typescript\nimport { readFileSync } from \"fs\";\nimport {\n  parseAuthorDSL,\n  formatParsedData,\n  validateParsedData,\n} from \"@0x800a6/author-txt\";\n\nfunction main(): void {\n  const inputPath = \"author.txt\";\n  let input: string;\n\n  try {\n    input = readFileSync(inputPath, \"utf-8\");\n  } catch (err) {\n    console.error(`Failed to read file: ${inputPath}`);\n    if (err instanceof Error) {\n      console.error(err.message);\n    }\n    process.exit(1);\n    return;\n  }\n\n  try {\n    const data = parseAuthorDSL(input);\n    console.log(\"Parsed JSON:\", JSON.stringify(data, null, 2));\n    console.log(\"Formatted:\\n\", formatParsedData(data));\n\n    const warnings: string[] = validateParsedData(data);\n    if (warnings.length > 0) {\n      console.warn(\"Validation warnings:\");\n      for (const warning of warnings) {\n        console.warn(`- ${warning}`);\n      }\n    }\n  } catch (err) {\n    console.error(\"Parsing failed.\");\n    if (err instanceof Error) {\n      console.error(err.message);\n    } else {\n      console.error(\"Unknown error:\", err);\n    }\n    process.exit(1);\n  }\n}\n\nmain();\n```\n\n### Using the Plugin System\n\n```typescript\nimport { \n  parseAuthorDSLWithPlugins, \n  validateParsedDataWithPlugins,\n  PluginManager,\n  JsonFormatterPlugin,\n  YamlFormatterPlugin \n} from \"@0x800a6/author-txt\";\n\n// Use with default plugins\nconst data = parseAuthorDSLWithPlugins(input);\nconst warnings = validateParsedDataWithPlugins(data);\n\n// Or create custom plugin manager\nconst pluginManager = new PluginManager();\npluginManager.register(new JsonFormatterPlugin());\npluginManager.register(new YamlFormatterPlugin());\n\n// Get available output formats\nconst formats = pluginManager.getAvailableFormats();\nconsole.log('Available formats:', formats); // ['json', 'yaml', 'yml']\n\n// Format data\nconst jsonOutput = pluginManager.formatData(data, 'json', { indent: 2 });\nconst yamlOutput = pluginManager.formatData(data, 'yaml');\n```\n\n## Errors\n\nThe parser reports descriptive errors with line numbers. It will throw when:\n\n- Blocks are unclosed or mismatched\n- Multiline values are not closed\n- Keys or types are invalid\n- Keys or values are empty\n\n\n## Plugin System\n\nThe Author DSL Parser includes a comprehensive plugin system for extensibility:\n\n### Plugin Types\n\n- **Type Plugins**: Handle custom value types (`@phone`, `@github`, `@color`)\n- **Validation Plugins**: Add custom validation rules\n- **Formatter Plugins**: Create custom output formats (JSON, YAML, Markdown)\n- **Parser Plugins**: Hook into the parsing process\n\n### Built-in Plugins\n\n- **Type Plugins**: `@url`, `@email`, `@date`, `@phone`, `@github`\n- **Validation Plugins**: Enhanced validation, security checks\n- **Formatter Plugins**: JSON, YAML, Markdown output\n\n### Creating Custom Plugins\n\n```typescript\nimport { TypePlugin, PluginContext, PluginMetadata } from '@0x800a6/author-txt';\n\nclass CustomTypePlugin implements TypePlugin {\n  metadata: PluginMetadata = {\n    name: 'custom-type',\n    version: '1.0.0',\n    description: 'Custom type plugin'\n  };\n\n  supportedTypes = ['custom'];\n\n  processValue(value: string, type: string, context: PluginContext): any {\n    return { type, value: value.toUpperCase() };\n  }\n}\n\n// Register and use\nconst pluginManager = new PluginManager();\npluginManager.register(new CustomTypePlugin());\nconst data = parseAuthorDSL(input, pluginManager);\n```\n\nSee [Plugin System Documentation](docs/plugin-system.md) for complete details.\n\n## Extensibility\n\nThe DSL can grow without breaking existing files. You can:\n\n- Add new types (`@phone`, `@github`, `@color`)\n- Add new blocks for projects, skills, or social profiles\n- Add attributes to keys (`Social::Handle{preferred=main}`)\n- Create custom plugins for any aspect of parsing, validation, or formatting\n\nParsers should ignore unknown keys to stay forward-compatible.\n\n## License\n\nMIT License. See [LICENSE](LICENSE).","readmeFilename":"README.md","_rev":"1-5ea1edfb37874efb9de8468b613a1a1e"}