@cairn-tool/cairn 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.markdownlintrc +7 -0
- package/LICENSE +21 -0
- package/README.md +1431 -0
- package/dist/agent/audit/baseline.d.ts +69 -0
- package/dist/agent/audit/baseline.js +128 -0
- package/dist/agent/audit/baseline.js.map +1 -0
- package/dist/agent/audit/index.d.ts +126 -0
- package/dist/agent/audit/index.js +625 -0
- package/dist/agent/audit/index.js.map +1 -0
- package/dist/agent/import/detect.d.ts +49 -0
- package/dist/agent/import/detect.js +159 -0
- package/dist/agent/import/detect.js.map +1 -0
- package/dist/agent/import/normalize.d.ts +72 -0
- package/dist/agent/import/normalize.js +475 -0
- package/dist/agent/import/normalize.js.map +1 -0
- package/dist/agent/install/index.d.ts +211 -0
- package/dist/agent/install/index.js +907 -0
- package/dist/agent/install/index.js.map +1 -0
- package/dist/agent/manifest.d.ts +75 -0
- package/dist/agent/manifest.js +210 -0
- package/dist/agent/manifest.js.map +1 -0
- package/dist/agent/marketplace/index.d.ts +69 -0
- package/dist/agent/marketplace/index.js +212 -0
- package/dist/agent/marketplace/index.js.map +1 -0
- package/dist/agent/marketplace/spec.d.ts +48 -0
- package/dist/agent/marketplace/spec.js +237 -0
- package/dist/agent/marketplace/spec.js.map +1 -0
- package/dist/agent/output.d.ts +36 -0
- package/dist/agent/output.js +56 -0
- package/dist/agent/output.js.map +1 -0
- package/dist/agent/overlays.d.ts +38 -0
- package/dist/agent/overlays.js +223 -0
- package/dist/agent/overlays.js.map +1 -0
- package/dist/agent/package/index.d.ts +105 -0
- package/dist/agent/package/index.js +339 -0
- package/dist/agent/package/index.js.map +1 -0
- package/dist/agent/package/tar.d.ts +36 -0
- package/dist/agent/package/tar.js +137 -0
- package/dist/agent/package/tar.js.map +1 -0
- package/dist/agent/parser.d.ts +13 -0
- package/dist/agent/parser.js +559 -0
- package/dist/agent/parser.js.map +1 -0
- package/dist/agent/render.d.ts +16 -0
- package/dist/agent/render.js +721 -0
- package/dist/agent/render.js.map +1 -0
- package/dist/agent/sarif.d.ts +18 -0
- package/dist/agent/sarif.js +56 -0
- package/dist/agent/sarif.js.map +1 -0
- package/dist/agent/scaffold.d.ts +86 -0
- package/dist/agent/scaffold.js +250 -0
- package/dist/agent/scaffold.js.map +1 -0
- package/dist/agent/targets/antigravity.d.ts +17 -0
- package/dist/agent/targets/antigravity.js +218 -0
- package/dist/agent/targets/antigravity.js.map +1 -0
- package/dist/agent/targets/claude-code.d.ts +2 -0
- package/dist/agent/targets/claude-code.js +220 -0
- package/dist/agent/targets/claude-code.js.map +1 -0
- package/dist/agent/targets/codex.d.ts +2 -0
- package/dist/agent/targets/codex.js +212 -0
- package/dist/agent/targets/codex.js.map +1 -0
- package/dist/agent/targets/cursor.d.ts +2 -0
- package/dist/agent/targets/cursor.js +210 -0
- package/dist/agent/targets/cursor.js.map +1 -0
- package/dist/agent/targets/index.d.ts +31 -0
- package/dist/agent/targets/index.js +64 -0
- package/dist/agent/targets/index.js.map +1 -0
- package/dist/agent/targets/opencode.d.ts +15 -0
- package/dist/agent/targets/opencode.js +215 -0
- package/dist/agent/targets/opencode.js.map +1 -0
- package/dist/agent/targets/schema.d.ts +315 -0
- package/dist/agent/targets/schema.js +179 -0
- package/dist/agent/targets/schema.js.map +1 -0
- package/dist/agent/test/assert.d.ts +46 -0
- package/dist/agent/test/assert.js +288 -0
- package/dist/agent/test/assert.js.map +1 -0
- package/dist/agent/test/index.d.ts +73 -0
- package/dist/agent/test/index.js +181 -0
- package/dist/agent/test/index.js.map +1 -0
- package/dist/agent/test/schema.d.ts +81 -0
- package/dist/agent/test/schema.js +235 -0
- package/dist/agent/test/schema.js.map +1 -0
- package/dist/agent/types.d.ts +204 -0
- package/dist/agent/types.js +11 -0
- package/dist/agent/types.js.map +1 -0
- package/dist/agent/upgrade.d.ts +29 -0
- package/dist/agent/upgrade.js +72 -0
- package/dist/agent/upgrade.js.map +1 -0
- package/dist/agent/writer.d.ts +30 -0
- package/dist/agent/writer.js +73 -0
- package/dist/agent/writer.js.map +1 -0
- package/dist/archive/db.d.ts +20 -0
- package/dist/archive/db.js +98 -0
- package/dist/archive/db.js.map +1 -0
- package/dist/archive/progress.d.ts +62 -0
- package/dist/archive/progress.js +151 -0
- package/dist/archive/progress.js.map +1 -0
- package/dist/archive/query.d.ts +86 -0
- package/dist/archive/query.js +241 -0
- package/dist/archive/query.js.map +1 -0
- package/dist/archive/run.d.ts +91 -0
- package/dist/archive/run.js +331 -0
- package/dist/archive/run.js.map +1 -0
- package/dist/archive/segments.d.ts +89 -0
- package/dist/archive/segments.js +144 -0
- package/dist/archive/segments.js.map +1 -0
- package/dist/archive/sets.d.ts +58 -0
- package/dist/archive/sets.js +344 -0
- package/dist/archive/sets.js.map +1 -0
- package/dist/archive/tar-read.d.ts +35 -0
- package/dist/archive/tar-read.js +90 -0
- package/dist/archive/tar-read.js.map +1 -0
- package/dist/audit-baseline.d.ts +66 -0
- package/dist/audit-baseline.js +124 -0
- package/dist/audit-baseline.js.map +1 -0
- package/dist/automation.d.ts +16 -0
- package/dist/automation.js +38 -0
- package/dist/automation.js.map +1 -0
- package/dist/backlinks.d.ts +15 -0
- package/dist/backlinks.js +30 -0
- package/dist/backlinks.js.map +1 -0
- package/dist/checkers/katex.d.ts +3 -0
- package/dist/checkers/katex.js +71 -0
- package/dist/checkers/katex.js.map +1 -0
- package/dist/checkers/markdown-lint.d.ts +28 -0
- package/dist/checkers/markdown-lint.js +53 -0
- package/dist/checkers/markdown-lint.js.map +1 -0
- package/dist/checkers/mermaid.d.ts +6 -0
- package/dist/checkers/mermaid.js +53 -0
- package/dist/checkers/mermaid.js.map +1 -0
- package/dist/checkers/references.d.ts +3 -0
- package/dist/checkers/references.js +55 -0
- package/dist/checkers/references.js.map +1 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +1117 -0
- package/dist/cli.js.map +1 -0
- package/dist/command-result.d.ts +6 -0
- package/dist/command-result.js +13 -0
- package/dist/command-result.js.map +1 -0
- package/dist/commands/agent-audit.d.ts +21 -0
- package/dist/commands/agent-audit.js +119 -0
- package/dist/commands/agent-audit.js.map +1 -0
- package/dist/commands/agent-doctor.d.ts +25 -0
- package/dist/commands/agent-doctor.js +217 -0
- package/dist/commands/agent-doctor.js.map +1 -0
- package/dist/commands/agent-import.d.ts +21 -0
- package/dist/commands/agent-import.js +212 -0
- package/dist/commands/agent-import.js.map +1 -0
- package/dist/commands/agent-install.d.ts +18 -0
- package/dist/commands/agent-install.js +59 -0
- package/dist/commands/agent-install.js.map +1 -0
- package/dist/commands/agent-installed.d.ts +6 -0
- package/dist/commands/agent-installed.js +17 -0
- package/dist/commands/agent-installed.js.map +1 -0
- package/dist/commands/agent-marketplace.d.ts +11 -0
- package/dist/commands/agent-marketplace.js +178 -0
- package/dist/commands/agent-marketplace.js.map +1 -0
- package/dist/commands/agent-package.d.ts +16 -0
- package/dist/commands/agent-package.js +159 -0
- package/dist/commands/agent-package.js.map +1 -0
- package/dist/commands/agent-scaffold.d.ts +17 -0
- package/dist/commands/agent-scaffold.js +181 -0
- package/dist/commands/agent-scaffold.js.map +1 -0
- package/dist/commands/agent-specs.d.ts +7 -0
- package/dist/commands/agent-specs.js +20 -0
- package/dist/commands/agent-specs.js.map +1 -0
- package/dist/commands/agent-test.d.ts +21 -0
- package/dist/commands/agent-test.js +50 -0
- package/dist/commands/agent-test.js.map +1 -0
- package/dist/commands/agent-uninstall.d.ts +6 -0
- package/dist/commands/agent-uninstall.js +45 -0
- package/dist/commands/agent-uninstall.js.map +1 -0
- package/dist/commands/agent-upgrade.d.ts +5 -0
- package/dist/commands/agent-upgrade.js +105 -0
- package/dist/commands/agent-upgrade.js.map +1 -0
- package/dist/commands/agent.d.ts +27 -0
- package/dist/commands/agent.js +549 -0
- package/dist/commands/agent.js.map +1 -0
- package/dist/commands/archive.d.ts +47 -0
- package/dist/commands/archive.js +311 -0
- package/dist/commands/archive.js.map +1 -0
- package/dist/commands/audit.d.ts +25 -0
- package/dist/commands/audit.js +325 -0
- package/dist/commands/audit.js.map +1 -0
- package/dist/commands/check-snippets.d.ts +58 -0
- package/dist/commands/check-snippets.js +247 -0
- package/dist/commands/check-snippets.js.map +1 -0
- package/dist/commands/check-urls.d.ts +52 -0
- package/dist/commands/check-urls.js +205 -0
- package/dist/commands/check-urls.js.map +1 -0
- package/dist/commands/code-blocks.d.ts +8 -0
- package/dist/commands/code-blocks.js +66 -0
- package/dist/commands/code-blocks.js.map +1 -0
- package/dist/commands/completion.d.ts +15 -0
- package/dist/commands/completion.js +20 -0
- package/dist/commands/completion.js.map +1 -0
- package/dist/commands/context.d.ts +16 -0
- package/dist/commands/context.js +131 -0
- package/dist/commands/context.js.map +1 -0
- package/dist/commands/describe.d.ts +12 -0
- package/dist/commands/describe.js +62 -0
- package/dist/commands/describe.js.map +1 -0
- package/dist/commands/diff.d.ts +11 -0
- package/dist/commands/diff.js +185 -0
- package/dist/commands/diff.js.map +1 -0
- package/dist/commands/fix.d.ts +59 -0
- package/dist/commands/fix.js +173 -0
- package/dist/commands/fix.js.map +1 -0
- package/dist/commands/frontmatter.d.ts +7 -0
- package/dist/commands/frontmatter.js +84 -0
- package/dist/commands/frontmatter.js.map +1 -0
- package/dist/commands/graph.d.ts +12 -0
- package/dist/commands/graph.js +122 -0
- package/dist/commands/graph.js.map +1 -0
- package/dist/commands/headers.d.ts +7 -0
- package/dist/commands/headers.js +48 -0
- package/dist/commands/headers.js.map +1 -0
- package/dist/commands/index.d.ts +8 -0
- package/dist/commands/index.js +32 -0
- package/dist/commands/index.js.map +1 -0
- package/dist/commands/links.d.ts +9 -0
- package/dist/commands/links.js +123 -0
- package/dist/commands/links.js.map +1 -0
- package/dist/commands/lint-dir.d.ts +15 -0
- package/dist/commands/lint-dir.js +156 -0
- package/dist/commands/lint-dir.js.map +1 -0
- package/dist/commands/lint.d.ts +14 -0
- package/dist/commands/lint.js +45 -0
- package/dist/commands/lint.js.map +1 -0
- package/dist/commands/orphans.d.ts +10 -0
- package/dist/commands/orphans.js +74 -0
- package/dist/commands/orphans.js.map +1 -0
- package/dist/commands/outline.d.ts +7 -0
- package/dist/commands/outline.js +54 -0
- package/dist/commands/outline.js.map +1 -0
- package/dist/commands/query.d.ts +18 -0
- package/dist/commands/query.js +341 -0
- package/dist/commands/query.js.map +1 -0
- package/dist/commands/refs-to.d.ts +8 -0
- package/dist/commands/refs-to.js +65 -0
- package/dist/commands/refs-to.js.map +1 -0
- package/dist/commands/refs.d.ts +10 -0
- package/dist/commands/refs.js +103 -0
- package/dist/commands/refs.js.map +1 -0
- package/dist/commands/rename-file.d.ts +16 -0
- package/dist/commands/rename-file.js +215 -0
- package/dist/commands/rename-file.js.map +1 -0
- package/dist/commands/rename-heading.d.ts +10 -0
- package/dist/commands/rename-heading.js +182 -0
- package/dist/commands/rename-heading.js.map +1 -0
- package/dist/commands/schema.d.ts +10 -0
- package/dist/commands/schema.js +34 -0
- package/dist/commands/schema.js.map +1 -0
- package/dist/commands/scripts.d.ts +59 -0
- package/dist/commands/scripts.js +222 -0
- package/dist/commands/scripts.js.map +1 -0
- package/dist/commands/section.d.ts +9 -0
- package/dist/commands/section.js +49 -0
- package/dist/commands/section.js.map +1 -0
- package/dist/commands/serve.d.ts +6 -0
- package/dist/commands/serve.js +48 -0
- package/dist/commands/serve.js.map +1 -0
- package/dist/commands/stats.d.ts +6 -0
- package/dist/commands/stats.js +109 -0
- package/dist/commands/stats.js.map +1 -0
- package/dist/commands/structure.d.ts +6 -0
- package/dist/commands/structure.js +130 -0
- package/dist/commands/structure.js.map +1 -0
- package/dist/commands/tables.d.ts +8 -0
- package/dist/commands/tables.js +77 -0
- package/dist/commands/tables.js.map +1 -0
- package/dist/commands/tasks.d.ts +8 -0
- package/dist/commands/tasks.js +59 -0
- package/dist/commands/tasks.js.map +1 -0
- package/dist/commands/toc.d.ts +18 -0
- package/dist/commands/toc.js +105 -0
- package/dist/commands/toc.js.map +1 -0
- package/dist/commands/update-check.d.ts +36 -0
- package/dist/commands/update-check.js +119 -0
- package/dist/commands/update-check.js.map +1 -0
- package/dist/commands/usage.d.ts +56 -0
- package/dist/commands/usage.js +883 -0
- package/dist/commands/usage.js.map +1 -0
- package/dist/commands/validate-frontmatter.d.ts +13 -0
- package/dist/commands/validate-frontmatter.js +34 -0
- package/dist/commands/validate-frontmatter.js.map +1 -0
- package/dist/completion/model.d.ts +49 -0
- package/dist/completion/model.js +194 -0
- package/dist/completion/model.js.map +1 -0
- package/dist/completion/shells.d.ts +2 -0
- package/dist/completion/shells.js +280 -0
- package/dist/completion/shells.js.map +1 -0
- package/dist/config-schema.d.ts +15 -0
- package/dist/config-schema.js +44 -0
- package/dist/config-schema.js.map +1 -0
- package/dist/config.d.ts +102 -0
- package/dist/config.js +614 -0
- package/dist/config.js.map +1 -0
- package/dist/context.d.ts +106 -0
- package/dist/context.js +202 -0
- package/dist/context.js.map +1 -0
- package/dist/contract/describe.d.ts +84 -0
- package/dist/contract/describe.js +104 -0
- package/dist/contract/describe.js.map +1 -0
- package/dist/contract/registry.d.ts +2 -0
- package/dist/contract/registry.js +622 -0
- package/dist/contract/registry.js.map +1 -0
- package/dist/contract/schemas/agent.d.ts +2 -0
- package/dist/contract/schemas/agent.js +572 -0
- package/dist/contract/schemas/agent.js.map +1 -0
- package/dist/contract/schemas/archive.d.ts +3 -0
- package/dist/contract/schemas/archive.js +227 -0
- package/dist/contract/schemas/archive.js.map +1 -0
- package/dist/contract/schemas/index.d.ts +11 -0
- package/dist/contract/schemas/index.js +49 -0
- package/dist/contract/schemas/index.js.map +1 -0
- package/dist/contract/schemas/markdown.d.ts +15 -0
- package/dist/contract/schemas/markdown.js +1035 -0
- package/dist/contract/schemas/markdown.js.map +1 -0
- package/dist/contract/schemas/meta.d.ts +5 -0
- package/dist/contract/schemas/meta.js +233 -0
- package/dist/contract/schemas/meta.js.map +1 -0
- package/dist/contract/schemas/scripts.d.ts +4 -0
- package/dist/contract/schemas/scripts.js +183 -0
- package/dist/contract/schemas/scripts.js.map +1 -0
- package/dist/contract/schemas/shared.d.ts +11 -0
- package/dist/contract/schemas/shared.js +26 -0
- package/dist/contract/schemas/shared.js.map +1 -0
- package/dist/contract/schemas/usage.d.ts +6 -0
- package/dist/contract/schemas/usage.js +489 -0
- package/dist/contract/schemas/usage.js.map +1 -0
- package/dist/contract/types.d.ts +63 -0
- package/dist/contract/types.js +2 -0
- package/dist/contract/types.js.map +1 -0
- package/dist/contract/version.d.ts +20 -0
- package/dist/contract/version.js +21 -0
- package/dist/contract/version.js.map +1 -0
- package/dist/diff.d.ts +156 -0
- package/dist/diff.js +500 -0
- package/dist/diff.js.map +1 -0
- package/dist/edit-plan.d.ts +133 -0
- package/dist/edit-plan.js +245 -0
- package/dist/edit-plan.js.map +1 -0
- package/dist/fix/markdownlint-fixer.d.ts +34 -0
- package/dist/fix/markdownlint-fixer.js +125 -0
- package/dist/fix/markdownlint-fixer.js.map +1 -0
- package/dist/fix/registry.d.ts +48 -0
- package/dist/fix/registry.js +28 -0
- package/dist/fix/registry.js.map +1 -0
- package/dist/fix/relative-links-fixer.d.ts +21 -0
- package/dist/fix/relative-links-fixer.js +96 -0
- package/dist/fix/relative-links-fixer.js.map +1 -0
- package/dist/fix/snippets-fixer.d.ts +2 -0
- package/dist/fix/snippets-fixer.js +64 -0
- package/dist/fix/snippets-fixer.js.map +1 -0
- package/dist/fix/toc-fixer.d.ts +2 -0
- package/dist/fix/toc-fixer.js +94 -0
- package/dist/fix/toc-fixer.js.map +1 -0
- package/dist/formats.d.ts +22 -0
- package/dist/formats.js +34 -0
- package/dist/formats.js.map +1 -0
- package/dist/formatters.d.ts +11 -0
- package/dist/formatters.js +48 -0
- package/dist/formatters.js.map +1 -0
- package/dist/frontmatter-validation.d.ts +11 -0
- package/dist/frontmatter-validation.js +188 -0
- package/dist/frontmatter-validation.js.map +1 -0
- package/dist/git.d.ts +40 -0
- package/dist/git.js +124 -0
- package/dist/git.js.map +1 -0
- package/dist/graph.d.ts +50 -0
- package/dist/graph.js +200 -0
- package/dist/graph.js.map +1 -0
- package/dist/input-selection.d.ts +9 -0
- package/dist/input-selection.js +122 -0
- package/dist/input-selection.js.map +1 -0
- package/dist/input.d.ts +2 -0
- package/dist/input.js +32 -0
- package/dist/input.js.map +1 -0
- package/dist/link-target.d.ts +39 -0
- package/dist/link-target.js +68 -0
- package/dist/link-target.js.map +1 -0
- package/dist/lint.d.ts +13 -0
- package/dist/lint.js +27 -0
- package/dist/lint.js.map +1 -0
- package/dist/markdown-ast.d.ts +73 -0
- package/dist/markdown-ast.js +187 -0
- package/dist/markdown-ast.js.map +1 -0
- package/dist/object-path.d.ts +14 -0
- package/dist/object-path.js +14 -0
- package/dist/object-path.js.map +1 -0
- package/dist/option-utils.d.ts +13 -0
- package/dist/option-utils.js +25 -0
- package/dist/option-utils.js.map +1 -0
- package/dist/outline.d.ts +16 -0
- package/dist/outline.js +32 -0
- package/dist/outline.js.map +1 -0
- package/dist/query/entities.d.ts +60 -0
- package/dist/query/entities.js +219 -0
- package/dist/query/entities.js.map +1 -0
- package/dist/query/execute.d.ts +22 -0
- package/dist/query/execute.js +0 -0
- package/dist/query/execute.js.map +1 -0
- package/dist/query/plan.d.ts +76 -0
- package/dist/query/plan.js +183 -0
- package/dist/query/plan.js.map +1 -0
- package/dist/query/render.d.ts +3 -0
- package/dist/query/render.js +39 -0
- package/dist/query/render.js.map +1 -0
- package/dist/refs.d.ts +19 -0
- package/dist/refs.js +10 -0
- package/dist/refs.js.map +1 -0
- package/dist/result.d.ts +49 -0
- package/dist/result.js +47 -0
- package/dist/result.js.map +1 -0
- package/dist/runtime.d.ts +35 -0
- package/dist/runtime.js +77 -0
- package/dist/runtime.js.map +1 -0
- package/dist/sarif.d.ts +36 -0
- package/dist/sarif.js +30 -0
- package/dist/sarif.js.map +1 -0
- package/dist/scripts/execute.d.ts +65 -0
- package/dist/scripts/execute.js +235 -0
- package/dist/scripts/execute.js.map +1 -0
- package/dist/scripts/registry.d.ts +55 -0
- package/dist/scripts/registry.js +103 -0
- package/dist/scripts/registry.js.map +1 -0
- package/dist/scripts/resolve.d.ts +90 -0
- package/dist/scripts/resolve.js +288 -0
- package/dist/scripts/resolve.js.map +1 -0
- package/dist/sections.d.ts +53 -0
- package/dist/sections.js +100 -0
- package/dist/sections.js.map +1 -0
- package/dist/serve/errors.d.ts +25 -0
- package/dist/serve/errors.js +45 -0
- package/dist/serve/errors.js.map +1 -0
- package/dist/serve/paths.d.ts +32 -0
- package/dist/serve/paths.js +71 -0
- package/dist/serve/paths.js.map +1 -0
- package/dist/serve/server.d.ts +31 -0
- package/dist/serve/server.js +123 -0
- package/dist/serve/server.js.map +1 -0
- package/dist/serve/tools.d.ts +19 -0
- package/dist/serve/tools.js +597 -0
- package/dist/serve/tools.js.map +1 -0
- package/dist/snippets.d.ts +184 -0
- package/dist/snippets.js +454 -0
- package/dist/snippets.js.map +1 -0
- package/dist/sqlite-store.d.ts +62 -0
- package/dist/sqlite-store.js +104 -0
- package/dist/sqlite-store.js.map +1 -0
- package/dist/sqlite.d.ts +59 -0
- package/dist/sqlite.js +51 -0
- package/dist/sqlite.js.map +1 -0
- package/dist/toc.d.ts +58 -0
- package/dist/toc.js +83 -0
- package/dist/toc.js.map +1 -0
- package/dist/types.d.ts +7 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/update-notifier.d.ts +95 -0
- package/dist/update-notifier.js +301 -0
- package/dist/update-notifier.js.map +1 -0
- package/dist/url-cache.d.ts +14 -0
- package/dist/url-cache.js +70 -0
- package/dist/url-cache.js.map +1 -0
- package/dist/usage/aggregate.d.ts +107 -0
- package/dist/usage/aggregate.js +435 -0
- package/dist/usage/aggregate.js.map +1 -0
- package/dist/usage/db/index.d.ts +49 -0
- package/dist/usage/db/index.js +118 -0
- package/dist/usage/db/index.js.map +1 -0
- package/dist/usage/db/migrations.d.ts +29 -0
- package/dist/usage/db/migrations.js +38 -0
- package/dist/usage/db/migrations.js.map +1 -0
- package/dist/usage/db/open.d.ts +33 -0
- package/dist/usage/db/open.js +37 -0
- package/dist/usage/db/open.js.map +1 -0
- package/dist/usage/db/schema.d.ts +18 -0
- package/dist/usage/db/schema.js +147 -0
- package/dist/usage/db/schema.js.map +1 -0
- package/dist/usage/db/store.d.ts +74 -0
- package/dist/usage/db/store.js +280 -0
- package/dist/usage/db/store.js.map +1 -0
- package/dist/usage/events.d.ts +202 -0
- package/dist/usage/events.js +243 -0
- package/dist/usage/events.js.map +1 -0
- package/dist/usage/filter.d.ts +43 -0
- package/dist/usage/filter.js +97 -0
- package/dist/usage/filter.js.map +1 -0
- package/dist/usage/providers/antigravity.d.ts +2 -0
- package/dist/usage/providers/antigravity.js +431 -0
- package/dist/usage/providers/antigravity.js.map +1 -0
- package/dist/usage/providers/claude-code.d.ts +2 -0
- package/dist/usage/providers/claude-code.js +400 -0
- package/dist/usage/providers/claude-code.js.map +1 -0
- package/dist/usage/providers/codex.d.ts +2 -0
- package/dist/usage/providers/codex.js +387 -0
- package/dist/usage/providers/codex.js.map +1 -0
- package/dist/usage/providers/gemini-cli.d.ts +2 -0
- package/dist/usage/providers/gemini-cli.js +466 -0
- package/dist/usage/providers/gemini-cli.js.map +1 -0
- package/dist/usage/providers/index.d.ts +23 -0
- package/dist/usage/providers/index.js +46 -0
- package/dist/usage/providers/index.js.map +1 -0
- package/dist/usage/providers/opencode.d.ts +2 -0
- package/dist/usage/providers/opencode.js +422 -0
- package/dist/usage/providers/opencode.js.map +1 -0
- package/dist/usage/providers/protobuf.d.ts +35 -0
- package/dist/usage/providers/protobuf.js +125 -0
- package/dist/usage/providers/protobuf.js.map +1 -0
- package/dist/usage/providers/types.d.ts +74 -0
- package/dist/usage/providers/types.js +2 -0
- package/dist/usage/providers/types.js.map +1 -0
- package/dist/usage/scan.d.ts +54 -0
- package/dist/usage/scan.js +216 -0
- package/dist/usage/scan.js.map +1 -0
- package/dist/version.d.ts +2 -0
- package/dist/version.js +8 -0
- package/dist/version.js.map +1 -0
- package/dist/workspace-index.d.ts +39 -0
- package/dist/workspace-index.js +265 -0
- package/dist/workspace-index.js.map +1 -0
- package/dist/workspace.d.ts +89 -0
- package/dist/workspace.js +219 -0
- package/dist/workspace.js.map +1 -0
- package/package.json +92 -0
|
@@ -0,0 +1,721 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { stringify as stringifyYaml } from "yaml";
|
|
3
|
+
import { diagnostic } from "./types.js";
|
|
4
|
+
import { HOOK_EVENT_ALIASES, nativeHookEvent, profileFor } from "./targets/index.js";
|
|
5
|
+
import { applyOverlayManifest, mergeOverlay, overlayArtifacts } from "./overlays.js";
|
|
6
|
+
function json(value) {
|
|
7
|
+
return Buffer.from(JSON.stringify(value, null, 2) + "\n");
|
|
8
|
+
}
|
|
9
|
+
function yamlFrontmatter(metadata, body) {
|
|
10
|
+
const keys = Object.keys(metadata).filter((key) => metadata[key] !== undefined);
|
|
11
|
+
return keys.length
|
|
12
|
+
? `---\n${stringifyYaml(Object.fromEntries(keys.map((key) => [key, metadata[key]])), { lineWidth: 0, indentSeq: false }).trim()}\n---\n${body}`
|
|
13
|
+
: body;
|
|
14
|
+
}
|
|
15
|
+
export function processTargetBlocks(content, target) {
|
|
16
|
+
const pattern = /<!--\s*(target|platform):([^\s]+)\s*-->\r?\n?([\s\S]*?)<!--\s*\/\1:\2\s*-->\r?\n?/g;
|
|
17
|
+
let previous;
|
|
18
|
+
do {
|
|
19
|
+
previous = content;
|
|
20
|
+
content = content.replace(pattern, (_all, _syntax, blockTarget, body) => blockTarget === target ? body : "");
|
|
21
|
+
} while (content !== previous);
|
|
22
|
+
return content;
|
|
23
|
+
}
|
|
24
|
+
function targetOverride(component, target) {
|
|
25
|
+
const targets = component.metadata.targets;
|
|
26
|
+
if (!targets || typeof targets !== "object" || Array.isArray(targets))
|
|
27
|
+
return {};
|
|
28
|
+
const override = targets[target];
|
|
29
|
+
return override && typeof override === "object" && !Array.isArray(override)
|
|
30
|
+
? override
|
|
31
|
+
: {};
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Whether a component reaches a target at all.
|
|
35
|
+
*
|
|
36
|
+
* Exported so `agent inspect --target` filters on exactly the predicate the
|
|
37
|
+
* renderer uses; a reimplementation would eventually disagree with `convert`
|
|
38
|
+
* about which components exist.
|
|
39
|
+
*/
|
|
40
|
+
export function selected(component, target) {
|
|
41
|
+
const override = targetOverride(component, target);
|
|
42
|
+
const include = component.metadata.include;
|
|
43
|
+
const exclude = component.metadata.exclude;
|
|
44
|
+
if (override.enabled === false || override.exclude === true)
|
|
45
|
+
return false;
|
|
46
|
+
if (Array.isArray(include) && !include.map(String).includes(target))
|
|
47
|
+
return false;
|
|
48
|
+
return !(Array.isArray(exclude) && exclude.map(String).includes(target));
|
|
49
|
+
}
|
|
50
|
+
function rewritePlaceholders(content, target, kind, diagnostics, component, profile = "plugin") {
|
|
51
|
+
const targetProfile = profileFor(target);
|
|
52
|
+
const hadArguments = /\$ARGUMENTS|\$\{ARGUMENTS\}|\{\{arguments\}\}/.test(content);
|
|
53
|
+
content = content.replace(/\$\{ARGUMENTS\}|\{\{arguments\}\}/g, "$ARGUMENTS");
|
|
54
|
+
const nativeRoot = targetProfile.placeholders.bundleRoot[profile];
|
|
55
|
+
content = content.replace(/\$\{BUNDLE_ROOT\}|\{\{bundleRoot\}\}/g, nativeRoot);
|
|
56
|
+
content = content.replace(/\$\{SKILL_DIR\}|\{\{skillDir\}\}/g, "${CLAUDE_SKILL_DIR}");
|
|
57
|
+
if (target === "claude-code")
|
|
58
|
+
return profile === "project"
|
|
59
|
+
? content.replace(/\$\{CLAUDE_PLUGIN_ROOT\}/g, "${CLAUDE_PROJECT_DIR}")
|
|
60
|
+
: content;
|
|
61
|
+
if (target === "codex")
|
|
62
|
+
content = content.replace(/\$\{CLAUDE_PLUGIN_ROOT\}/g, profile === "plugin" ? "${PLUGIN_ROOT}" : ".");
|
|
63
|
+
content = content
|
|
64
|
+
.replace(/\$\{CLAUDE_PLUGIN_ROOT\}\//g, "./")
|
|
65
|
+
.replace(/\$\{CLAUDE_PLUGIN_ROOT\}/g, ".");
|
|
66
|
+
content = content
|
|
67
|
+
.replace(/\$\{CLAUDE_SKILL_DIR\}\//g, "")
|
|
68
|
+
.replace(/\$\{CLAUDE_SKILL_DIR\}/g, ".");
|
|
69
|
+
if (hadArguments &&
|
|
70
|
+
kind === "skill" &&
|
|
71
|
+
targetProfile.placeholders.arguments === "advisory" &&
|
|
72
|
+
!content.includes("If the above shows literal `$ARGUMENTS`")) {
|
|
73
|
+
const lines = content.split("\n");
|
|
74
|
+
const index = lines.findIndex((line) => line.includes("$ARGUMENTS") && !line.includes("`$ARGUMENTS`"));
|
|
75
|
+
if (index >= 0)
|
|
76
|
+
lines.splice(index + 1, 0, "", "> If the above shows literal `$ARGUMENTS`, extract the argument from the user's message.");
|
|
77
|
+
content = lines.join("\n");
|
|
78
|
+
}
|
|
79
|
+
if (hadArguments && targetProfile.placeholders.arguments === "prose") {
|
|
80
|
+
content = content.replace(/\$ARGUMENTS/g, "the invocation arguments from the user's message");
|
|
81
|
+
diagnostics.push(diagnostic("AB302", `${target} has no portable $ARGUMENTS substitution; emitted explanatory text`, "approximate", {
|
|
82
|
+
component: component?.name,
|
|
83
|
+
path: component?.path,
|
|
84
|
+
target,
|
|
85
|
+
remediation: `Provide targets.${target} instructions when exact argument handling matters.`,
|
|
86
|
+
}));
|
|
87
|
+
}
|
|
88
|
+
return content;
|
|
89
|
+
}
|
|
90
|
+
function metadataFor(component, target) {
|
|
91
|
+
const result = { ...component.metadata, ...targetOverride(component, target) };
|
|
92
|
+
for (const key of [
|
|
93
|
+
"targets",
|
|
94
|
+
"include",
|
|
95
|
+
"exclude",
|
|
96
|
+
"enabled",
|
|
97
|
+
"activation",
|
|
98
|
+
"globs",
|
|
99
|
+
"invocationPolicy",
|
|
100
|
+
"invocation",
|
|
101
|
+
"arguments",
|
|
102
|
+
"argumentHint",
|
|
103
|
+
"modelClass",
|
|
104
|
+
])
|
|
105
|
+
delete result[key];
|
|
106
|
+
return result;
|
|
107
|
+
}
|
|
108
|
+
function transformMarkdown(component, target, diagnostics, kind = "other", profile = "plugin") {
|
|
109
|
+
const override = targetOverride(component, target);
|
|
110
|
+
const body = typeof override.instructions === "string" ? override.instructions : component.body;
|
|
111
|
+
return yamlFrontmatter(metadataFor(component, target), rewritePlaceholders(processTargetBlocks(body, target), target, kind, diagnostics, component, profile));
|
|
112
|
+
}
|
|
113
|
+
function copyComponentFiles(component, base, target, diagnostics, artifacts, profile) {
|
|
114
|
+
for (const file of component.files) {
|
|
115
|
+
if (file.path === "SKILL.md")
|
|
116
|
+
continue;
|
|
117
|
+
const markdown = file.path.endsWith(".md");
|
|
118
|
+
const content = markdown
|
|
119
|
+
? Buffer.from(rewritePlaceholders(processTargetBlocks(file.content.toString("utf8"), target), target, "other", diagnostics, component, profile))
|
|
120
|
+
: file.content;
|
|
121
|
+
artifacts.push({
|
|
122
|
+
path: path.posix.join(base, file.path.split(path.sep).join("/")),
|
|
123
|
+
content,
|
|
124
|
+
mode: file.mode,
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
function transformedHooks(bundle, target, profile, diagnostics) {
|
|
129
|
+
if (!bundle.hooks)
|
|
130
|
+
return undefined;
|
|
131
|
+
const root = bundle.hooks.value;
|
|
132
|
+
const overrides = root.targets && typeof root.targets === "object" && !Array.isArray(root.targets)
|
|
133
|
+
? root.targets[target]
|
|
134
|
+
: undefined;
|
|
135
|
+
const override = overrides && typeof overrides === "object" && !Array.isArray(overrides)
|
|
136
|
+
? overrides
|
|
137
|
+
: {};
|
|
138
|
+
const base = root.hooks && typeof root.hooks === "object"
|
|
139
|
+
? root.hooks
|
|
140
|
+
: root.events && typeof root.events === "object"
|
|
141
|
+
? root.events
|
|
142
|
+
: Object.fromEntries(Object.entries(root).filter(([key]) => key !== "targets"));
|
|
143
|
+
const overrideEvents = override.hooks && typeof override.hooks === "object"
|
|
144
|
+
? override.hooks
|
|
145
|
+
: override.events && typeof override.events === "object"
|
|
146
|
+
? override.events
|
|
147
|
+
: override;
|
|
148
|
+
const source = { ...base, ...overrideEvents };
|
|
149
|
+
const hooks = {};
|
|
150
|
+
for (const [rawEvent, handlers] of Object.entries(source)) {
|
|
151
|
+
const neutral = HOOK_EVENT_ALIASES[rawEvent] ?? rawEvent;
|
|
152
|
+
const targetName = nativeHookEvent(target, neutral);
|
|
153
|
+
if (!targetName) {
|
|
154
|
+
const manifestOverrides = bundle.manifest.targets;
|
|
155
|
+
const hasOverride = Boolean(manifestOverrides?.[target]) || Object.keys(override).length > 0;
|
|
156
|
+
if (!hasOverride)
|
|
157
|
+
diagnostics.push(diagnostic("AB320", `Hook event '${rawEvent}' is not portable to ${target}`, "unsupported", {
|
|
158
|
+
path: bundle.hooks.path,
|
|
159
|
+
target,
|
|
160
|
+
profile,
|
|
161
|
+
remediation: `Add a targets.${target} hook override.`,
|
|
162
|
+
}));
|
|
163
|
+
continue;
|
|
164
|
+
}
|
|
165
|
+
const rewrite = (value) => {
|
|
166
|
+
if (typeof value === "string")
|
|
167
|
+
return rewritePlaceholders(value, target, "other", diagnostics, undefined, profile);
|
|
168
|
+
if (Array.isArray(value))
|
|
169
|
+
return value.map(rewrite);
|
|
170
|
+
if (value && typeof value === "object")
|
|
171
|
+
return Object.fromEntries(Object.entries(value).map(([key, child]) => [
|
|
172
|
+
key,
|
|
173
|
+
rewrite(child),
|
|
174
|
+
]));
|
|
175
|
+
return value;
|
|
176
|
+
};
|
|
177
|
+
const normalizeHandlers = (value) => {
|
|
178
|
+
if (bundle.legacy || !Array.isArray(value))
|
|
179
|
+
return value;
|
|
180
|
+
return value.map((item) => {
|
|
181
|
+
if (!item || typeof item !== "object" || Array.isArray(item))
|
|
182
|
+
return item;
|
|
183
|
+
const handler = item;
|
|
184
|
+
if (Array.isArray(handler.hooks))
|
|
185
|
+
return handler;
|
|
186
|
+
if (handler.windowsCommand && !Object.keys(override).length)
|
|
187
|
+
diagnostics.push(diagnostic("AB321", "Windows-specific hook command requires a target override", "approximate", {
|
|
188
|
+
path: bundle.hooks?.path,
|
|
189
|
+
target,
|
|
190
|
+
profile,
|
|
191
|
+
remediation: `Add targets.${target} with the desired native command selection.`,
|
|
192
|
+
}));
|
|
193
|
+
const protocol = handler.protocol ?? handler.inputProtocol ?? handler.outputProtocol;
|
|
194
|
+
if (protocol && !profileFor(target).hooks.supportedProtocols.includes(String(protocol)))
|
|
195
|
+
diagnostics.push(diagnostic("AB322", `Hook protocol '${String(protocol)}' is not portable`, "unsupported", {
|
|
196
|
+
path: bundle.hooks?.path,
|
|
197
|
+
target,
|
|
198
|
+
profile,
|
|
199
|
+
remediation: `Add a targets.${target} handler override.`,
|
|
200
|
+
}));
|
|
201
|
+
// A host may nest only some of its events: Antigravity accepts a
|
|
202
|
+
// tool-name `matcher` on its two tool events and a bare handler list on
|
|
203
|
+
// the rest, so the shape is decided per portable event rather than once
|
|
204
|
+
// for the whole document.
|
|
205
|
+
const hookProfile = profileFor(target).hooks;
|
|
206
|
+
const nested = hookProfile.handlerShape === "claude-nested" ||
|
|
207
|
+
(hookProfile.handlerShape === "nested-for-matcher-events" &&
|
|
208
|
+
hookProfile.matcherEvents.includes(neutral));
|
|
209
|
+
if (!nested)
|
|
210
|
+
return Object.fromEntries(Object.entries(handler).filter(([key]) => !["type", "windowsCommand", "protocol", "inputProtocol", "outputProtocol"].includes(key)));
|
|
211
|
+
const inner = Object.fromEntries(Object.entries(handler).filter(([key]) => ![
|
|
212
|
+
"matcher",
|
|
213
|
+
"windowsCommand",
|
|
214
|
+
"protocol",
|
|
215
|
+
"inputProtocol",
|
|
216
|
+
"outputProtocol",
|
|
217
|
+
].includes(key)));
|
|
218
|
+
return {
|
|
219
|
+
...(handler.matcher !== undefined ? { matcher: handler.matcher } : {}),
|
|
220
|
+
hooks: [{ type: "command", ...inner }],
|
|
221
|
+
};
|
|
222
|
+
});
|
|
223
|
+
};
|
|
224
|
+
hooks[targetName] = rewrite(normalizeHandlers(handlers));
|
|
225
|
+
}
|
|
226
|
+
const envelope = profileFor(target).hooks.envelope;
|
|
227
|
+
if (envelope === "versioned" && !bundle.legacy)
|
|
228
|
+
return { version: 1, hooks };
|
|
229
|
+
// `named` keys the whole document by the bundle, which is how a host that
|
|
230
|
+
// merges several hook sets tells them apart and can disable one wholesale.
|
|
231
|
+
if (envelope === "named" && !bundle.legacy)
|
|
232
|
+
return { [bundle.name]: hooks };
|
|
233
|
+
return { hooks };
|
|
234
|
+
}
|
|
235
|
+
function manifest(bundle, target) {
|
|
236
|
+
const profile = profileFor(target);
|
|
237
|
+
const pluginAgentRoot = profile.paths.plugin.agents;
|
|
238
|
+
if (bundle.legacy && pluginAgentRoot !== null)
|
|
239
|
+
return { ...bundle.manifest };
|
|
240
|
+
const implied = new Set(profile.manifest.impliedFields ?? []);
|
|
241
|
+
const result = {
|
|
242
|
+
name: bundle.name,
|
|
243
|
+
version: bundle.version,
|
|
244
|
+
description: bundle.description,
|
|
245
|
+
};
|
|
246
|
+
if (!implied.has("skills"))
|
|
247
|
+
result.skills = "./skills/";
|
|
248
|
+
if (bundle.hooks && !implied.has("hooks"))
|
|
249
|
+
result.hooks = "./hooks/hooks.json";
|
|
250
|
+
if (bundle.mcp && !implied.has("mcpServers"))
|
|
251
|
+
result.mcpServers = "./.mcp.json";
|
|
252
|
+
if (pluginAgentRoot !== null && bundle.agents.length && !implied.has("agents"))
|
|
253
|
+
result.agents = `./${pluginAgentRoot}/`;
|
|
254
|
+
return result;
|
|
255
|
+
}
|
|
256
|
+
function mapModel(value, target, component, diagnostics) {
|
|
257
|
+
if (value === undefined)
|
|
258
|
+
return undefined;
|
|
259
|
+
const model = String(value);
|
|
260
|
+
const semantic = {
|
|
261
|
+
fast: "fast",
|
|
262
|
+
balanced: "balanced",
|
|
263
|
+
capable: "capable",
|
|
264
|
+
inherit: "inherit",
|
|
265
|
+
haiku: "fast",
|
|
266
|
+
sonnet: "balanced",
|
|
267
|
+
opus: "capable",
|
|
268
|
+
};
|
|
269
|
+
const level = semantic[model];
|
|
270
|
+
if (!level) {
|
|
271
|
+
diagnostics.push(diagnostic("AB330", `Model '${model}' is not a stable semantic class; target will inherit`, "approximate", {
|
|
272
|
+
component: component.name,
|
|
273
|
+
path: component.path,
|
|
274
|
+
target,
|
|
275
|
+
remediation: `Use fast, balanced, capable, inherit, or targets.${target}.model.`,
|
|
276
|
+
}));
|
|
277
|
+
return "inherit";
|
|
278
|
+
}
|
|
279
|
+
return profileFor(target).models.classes[level] ?? undefined;
|
|
280
|
+
}
|
|
281
|
+
function mapTools(metadata, target, component, diagnostics, legacy) {
|
|
282
|
+
if (!Array.isArray(metadata.tools))
|
|
283
|
+
return;
|
|
284
|
+
const targetProfile = profileFor(target);
|
|
285
|
+
if (legacy && targetProfile.paths.plugin.agents !== null)
|
|
286
|
+
return;
|
|
287
|
+
const explicit = Object.prototype.hasOwnProperty.call(targetOverride(component, target), "tools");
|
|
288
|
+
if (explicit)
|
|
289
|
+
return;
|
|
290
|
+
const capabilities = metadata.tools.map(String);
|
|
291
|
+
const mapping = targetProfile.tools.capabilities;
|
|
292
|
+
if (mapping) {
|
|
293
|
+
const unsupported = capabilities.filter((value) => !mapping[value]);
|
|
294
|
+
metadata.tools = [...new Set(capabilities.flatMap((value) => mapping[value] ?? []))];
|
|
295
|
+
if (unsupported.length)
|
|
296
|
+
diagnostics.push(diagnostic("AB331", `Tool capabilities cannot be restricted exactly: ${unsupported.join(", ")}`, "unsupported", {
|
|
297
|
+
component: component.name,
|
|
298
|
+
path: component.path,
|
|
299
|
+
target,
|
|
300
|
+
remediation: `Provide targets.${target}.tools with native tool names.`,
|
|
301
|
+
}));
|
|
302
|
+
return;
|
|
303
|
+
}
|
|
304
|
+
delete metadata.tools;
|
|
305
|
+
diagnostics.push(diagnostic("AB332", `Capability-based tool restrictions require a ${target} override`, "approximate", {
|
|
306
|
+
component: component.name,
|
|
307
|
+
path: component.path,
|
|
308
|
+
target,
|
|
309
|
+
remediation: `Provide targets.${target}.tools; restrictions were not broadened silently.`,
|
|
310
|
+
}));
|
|
311
|
+
}
|
|
312
|
+
function renderSkill(bundle, component, target, profile, diagnostics, artifacts) {
|
|
313
|
+
if (!selected(component, target))
|
|
314
|
+
return;
|
|
315
|
+
const targetProfile = profileFor(target);
|
|
316
|
+
const directory = targetProfile.paths.namespacePluginSkills && profile === "plugin"
|
|
317
|
+
? `${bundle.name}-${component.name}`
|
|
318
|
+
: component.name;
|
|
319
|
+
const skillRoot = profile === "project" ? targetProfile.paths.project.skills : targetProfile.paths.plugin.skills;
|
|
320
|
+
const base = `${skillRoot}/${directory}`;
|
|
321
|
+
const invocation = String(component.metadata.invocationPolicy ?? component.metadata.invocation ?? "auto");
|
|
322
|
+
let renderedComponent = component;
|
|
323
|
+
if (["explicit", "manual"].includes(invocation)) {
|
|
324
|
+
const form = profileFor(target).skills.invocationPolicy;
|
|
325
|
+
if (form === "frontmatter-flag")
|
|
326
|
+
renderedComponent = {
|
|
327
|
+
...component,
|
|
328
|
+
metadata: { ...component.metadata, "disable-model-invocation": true },
|
|
329
|
+
};
|
|
330
|
+
else if (form === "openai-yaml" &&
|
|
331
|
+
!component.files.some((file) => file.path.split(path.sep).join("/") === "agents/openai.yaml")) {
|
|
332
|
+
artifacts.push({
|
|
333
|
+
path: `${base}/agents/openai.yaml`,
|
|
334
|
+
content: Buffer.from("policy:\n allow_implicit_invocation: false\n"),
|
|
335
|
+
mode: 0o644,
|
|
336
|
+
});
|
|
337
|
+
}
|
|
338
|
+
else if (form === "advisory" || form === null)
|
|
339
|
+
diagnostics.push(diagnostic("AB310", `${target} skill invocation policy is advisory`, "approximate", {
|
|
340
|
+
component: component.name,
|
|
341
|
+
path: component.path,
|
|
342
|
+
target,
|
|
343
|
+
profile,
|
|
344
|
+
remediation: `Provide targets.${target} invocation instructions if implicit activation must be prevented.`,
|
|
345
|
+
}));
|
|
346
|
+
}
|
|
347
|
+
const argumentHint = component.metadata.argumentHint ?? component.metadata.arguments;
|
|
348
|
+
if (argumentHint !== undefined && targetProfile.placeholders.arguments !== "prose")
|
|
349
|
+
renderedComponent = {
|
|
350
|
+
...renderedComponent,
|
|
351
|
+
metadata: {
|
|
352
|
+
...renderedComponent.metadata,
|
|
353
|
+
"argument-hint": Array.isArray(argumentHint)
|
|
354
|
+
? argumentHint.map(String).join(" ")
|
|
355
|
+
: String(argumentHint),
|
|
356
|
+
},
|
|
357
|
+
};
|
|
358
|
+
artifacts.push({
|
|
359
|
+
path: `${base}/SKILL.md`,
|
|
360
|
+
content: Buffer.from(transformMarkdown(renderedComponent, target, diagnostics, "skill", profile)),
|
|
361
|
+
mode: 0o644,
|
|
362
|
+
});
|
|
363
|
+
copyComponentFiles(component, base, target, diagnostics, artifacts, profile);
|
|
364
|
+
}
|
|
365
|
+
function renderAgent(component, target, profile, bundle, diagnostics, artifacts) {
|
|
366
|
+
if (!selected(component, target))
|
|
367
|
+
return;
|
|
368
|
+
const metadata = metadataFor(component, target);
|
|
369
|
+
mapTools(metadata, target, component, diagnostics, bundle.legacy);
|
|
370
|
+
const model = mapModel(metadata.model ?? targetOverride(component, target).modelClass ?? component.metadata.modelClass, target, component, diagnostics);
|
|
371
|
+
const targetProfile = profileFor(target);
|
|
372
|
+
if (!targetProfile.features.agents.profiles.includes(profile)) {
|
|
373
|
+
diagnostics.push(diagnostic("AB340", `${target} custom agents are not emitted for the ${profile} profile`, "unsupported", {
|
|
374
|
+
component: component.name,
|
|
375
|
+
path: component.path,
|
|
376
|
+
target,
|
|
377
|
+
profile,
|
|
378
|
+
remediation: targetProfile.features.agents.profiles.length
|
|
379
|
+
? `Generate the ${targetProfile.features.agents.profiles.join(" or ")} profile as well.`
|
|
380
|
+
: `${target} has no custom-agent surface; express the behavior as a skill.`,
|
|
381
|
+
}));
|
|
382
|
+
return;
|
|
383
|
+
}
|
|
384
|
+
if (target === "codex") {
|
|
385
|
+
const lines = [
|
|
386
|
+
`name = ${JSON.stringify(component.name)}`,
|
|
387
|
+
`description = ${JSON.stringify(component.description)}`,
|
|
388
|
+
];
|
|
389
|
+
if (metadata.reasoning)
|
|
390
|
+
lines.push(`model_reasoning_effort = ${JSON.stringify(String(metadata.reasoning))}`);
|
|
391
|
+
lines.push(`developer_instructions = ${JSON.stringify(rewritePlaceholders(processTargetBlocks(component.body, target), target, "other", diagnostics, component, profile))}`);
|
|
392
|
+
artifacts.push({
|
|
393
|
+
path: `.codex/agents/${component.name}.toml`,
|
|
394
|
+
content: Buffer.from(lines.join("\n") + "\n"),
|
|
395
|
+
mode: 0o644,
|
|
396
|
+
});
|
|
397
|
+
return;
|
|
398
|
+
}
|
|
399
|
+
const outMetadata = { ...metadata };
|
|
400
|
+
// A target that cannot express a model must not be handed the *portable*
|
|
401
|
+
// class name instead: `model: capable` is not a model id on any host, and
|
|
402
|
+
// leaving it there emits a key the host will reject or misread.
|
|
403
|
+
if (model)
|
|
404
|
+
outMetadata.model = model;
|
|
405
|
+
else
|
|
406
|
+
delete outMetadata.model;
|
|
407
|
+
if (target === "cursor" && Array.isArray(outMetadata.skills)) {
|
|
408
|
+
const sections = outMetadata.skills
|
|
409
|
+
.map(String)
|
|
410
|
+
.map((name) => bundle.skills.find((skill) => skill.name === name))
|
|
411
|
+
.filter(Boolean)
|
|
412
|
+
.map((skill) => rewritePlaceholders(processTargetBlocks(skill.body, target), target, "skill", diagnostics, skill, profile).trim());
|
|
413
|
+
delete outMetadata.skills;
|
|
414
|
+
component = {
|
|
415
|
+
...component,
|
|
416
|
+
body: `${component.body.trimEnd()}${sections.length ? `\n\n${sections.join("\n\n")}\n` : ""}`,
|
|
417
|
+
};
|
|
418
|
+
}
|
|
419
|
+
const agentRoot = profile === "project" ? targetProfile.paths.project.agents : targetProfile.paths.plugin.agents;
|
|
420
|
+
artifacts.push({
|
|
421
|
+
path: `${agentRoot}/${component.name}.md`,
|
|
422
|
+
content: Buffer.from(yamlFrontmatter(outMetadata, rewritePlaceholders(processTargetBlocks(component.body, target), target, "other", diagnostics, component, profile))),
|
|
423
|
+
mode: 0o644,
|
|
424
|
+
});
|
|
425
|
+
}
|
|
426
|
+
function renderRules(bundle, target, profile, diagnostics, artifacts) {
|
|
427
|
+
const targetProfile = profileFor(target);
|
|
428
|
+
for (const rule of bundle.rules) {
|
|
429
|
+
if (!selected(rule, target))
|
|
430
|
+
continue;
|
|
431
|
+
if (!targetProfile.features.rules.profiles.includes(profile)) {
|
|
432
|
+
diagnostics.push(diagnostic("AB350", `${target} instruction rules are project-only`, "unsupported", {
|
|
433
|
+
component: rule.name,
|
|
434
|
+
path: rule.path,
|
|
435
|
+
target,
|
|
436
|
+
profile,
|
|
437
|
+
remediation: "Generate the project profile.",
|
|
438
|
+
}));
|
|
439
|
+
continue;
|
|
440
|
+
}
|
|
441
|
+
const body = rewritePlaceholders(processTargetBlocks(rule.body, target), target, "other", diagnostics, rule, profile);
|
|
442
|
+
if (!targetProfile.rules.exactActivation.includes(rule.activation))
|
|
443
|
+
diagnostics.push(diagnostic("AB351", `Rule activation '${rule.activation}' is not exact on ${target}`, targetProfile.rules.approximateActivation.includes(rule.activation)
|
|
444
|
+
? "approximate"
|
|
445
|
+
: "unsupported", {
|
|
446
|
+
component: rule.name,
|
|
447
|
+
path: rule.path,
|
|
448
|
+
target,
|
|
449
|
+
profile,
|
|
450
|
+
remediation: `Provide targets.${target} instructions or split the rule into a native activation surface.`,
|
|
451
|
+
}));
|
|
452
|
+
const ruleRoot = targetProfile.paths.project.rules;
|
|
453
|
+
if (targetProfile.rules.form === "mdc") {
|
|
454
|
+
const metadata = {
|
|
455
|
+
description: rule.description,
|
|
456
|
+
alwaysApply: rule.activation === "always",
|
|
457
|
+
};
|
|
458
|
+
if (rule.globs.length)
|
|
459
|
+
metadata.globs = rule.globs.join(",");
|
|
460
|
+
artifacts.push({
|
|
461
|
+
path: `${ruleRoot}/${rule.name}.mdc`,
|
|
462
|
+
content: Buffer.from(yamlFrontmatter(metadata, body)),
|
|
463
|
+
mode: 0o644,
|
|
464
|
+
});
|
|
465
|
+
}
|
|
466
|
+
else if (targetProfile.rules.form === "markdown") {
|
|
467
|
+
const metadata = rule.globs.length ? { paths: rule.globs } : {};
|
|
468
|
+
artifacts.push({
|
|
469
|
+
path: `${ruleRoot}/${rule.name}.md`,
|
|
470
|
+
content: Buffer.from(yamlFrontmatter(metadata, body)),
|
|
471
|
+
mode: 0o644,
|
|
472
|
+
});
|
|
473
|
+
}
|
|
474
|
+
else if (targetProfile.rules.form === "trigger-frontmatter") {
|
|
475
|
+
// Antigravity loads `always_on` rules unconditionally and defers the rest
|
|
476
|
+
// to the model, which is the distinction its `trigger` key expresses.
|
|
477
|
+
const metadata = {
|
|
478
|
+
description: rule.description,
|
|
479
|
+
trigger: rule.activation === "always" ? "always_on" : "model_decision",
|
|
480
|
+
};
|
|
481
|
+
if (rule.globs.length)
|
|
482
|
+
metadata.globs = rule.globs;
|
|
483
|
+
artifacts.push({
|
|
484
|
+
path: `${ruleRoot}/${rule.name}.md`,
|
|
485
|
+
content: Buffer.from(yamlFrontmatter(metadata, body)),
|
|
486
|
+
mode: 0o644,
|
|
487
|
+
});
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
if (targetProfile.rules.form === "aggregated-agents-md" &&
|
|
491
|
+
profile === "project" &&
|
|
492
|
+
bundle.rules.length) {
|
|
493
|
+
const content = bundle.rules
|
|
494
|
+
.filter((rule) => selected(rule, target))
|
|
495
|
+
.map((rule) => `## ${rule.name}\n\n${rewritePlaceholders(processTargetBlocks(rule.body, target), target, "other", diagnostics, rule, profile).trim()}`)
|
|
496
|
+
.join("\n\n");
|
|
497
|
+
artifacts.push({
|
|
498
|
+
path: String(targetProfile.paths.project.rules),
|
|
499
|
+
content: Buffer.from(content + "\n"),
|
|
500
|
+
mode: 0o644,
|
|
501
|
+
});
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
/** The bundle's policy rules, flattened. One definition of "what a rule is". */
|
|
505
|
+
export function policyEntries(bundle) {
|
|
506
|
+
return bundle.policies.flatMap((policy) => {
|
|
507
|
+
const value = policy.value.rules ?? policy.value.policies;
|
|
508
|
+
return Array.isArray(value)
|
|
509
|
+
? value.filter((item) => Boolean(item && typeof item === "object" && !Array.isArray(item)))
|
|
510
|
+
: [policy.value];
|
|
511
|
+
});
|
|
512
|
+
}
|
|
513
|
+
function structuredTargetValue(value, target) {
|
|
514
|
+
const base = Object.fromEntries(Object.entries(value).filter(([key]) => key !== "targets"));
|
|
515
|
+
const targets = value.targets;
|
|
516
|
+
if (!targets || typeof targets !== "object" || Array.isArray(targets))
|
|
517
|
+
return base;
|
|
518
|
+
const override = targets[target];
|
|
519
|
+
return override && typeof override === "object" && !Array.isArray(override)
|
|
520
|
+
? { ...base, ...override }
|
|
521
|
+
: base;
|
|
522
|
+
}
|
|
523
|
+
function renderPolicies(bundle, target, profile, diagnostics, artifacts) {
|
|
524
|
+
const entries = policyEntries(bundle);
|
|
525
|
+
if (!entries.length)
|
|
526
|
+
return;
|
|
527
|
+
if (profile === "plugin") {
|
|
528
|
+
diagnostics.push(diagnostic("AB360", "Command policies are emitted only in project profiles", "unsupported", {
|
|
529
|
+
target,
|
|
530
|
+
profile,
|
|
531
|
+
remediation: "Generate the project profile.",
|
|
532
|
+
}));
|
|
533
|
+
return;
|
|
534
|
+
}
|
|
535
|
+
const form = profileFor(target).policies.form;
|
|
536
|
+
if (form === "cursor-hooks") {
|
|
537
|
+
const hookOverrides = entries.flatMap((entry) => {
|
|
538
|
+
const targets = entry.targets;
|
|
539
|
+
if (!targets || typeof targets !== "object" || Array.isArray(targets))
|
|
540
|
+
return [];
|
|
541
|
+
const cursor = targets.cursor;
|
|
542
|
+
return cursor && typeof cursor === "object" && !Array.isArray(cursor)
|
|
543
|
+
? [cursor]
|
|
544
|
+
: [];
|
|
545
|
+
});
|
|
546
|
+
if (hookOverrides.length) {
|
|
547
|
+
const hooks = Object.assign({}, ...hookOverrides.map((override) => override.hooks ?? override));
|
|
548
|
+
artifacts.push({
|
|
549
|
+
path: ".cursor/hooks.json",
|
|
550
|
+
content: json({ version: 1, hooks }),
|
|
551
|
+
mode: 0o644,
|
|
552
|
+
});
|
|
553
|
+
return;
|
|
554
|
+
}
|
|
555
|
+
diagnostics.push(diagnostic("AB361", `${target} has no native command-policy format`, "unsupported", {
|
|
556
|
+
target,
|
|
557
|
+
profile,
|
|
558
|
+
remediation: `Provide an explicit ${target} hook override; prompt rules are not security policy.`,
|
|
559
|
+
}));
|
|
560
|
+
return;
|
|
561
|
+
}
|
|
562
|
+
// A host with no policy surface says so and emits nothing. This used to be an
|
|
563
|
+
// unguarded `else`, which handed every target that was neither Claude Code
|
|
564
|
+
// nor Cursor a `.codex/rules/bundle.rules` it does not read — a path its own
|
|
565
|
+
// profile does not declare, and output that looks right and does nothing.
|
|
566
|
+
if (form === null) {
|
|
567
|
+
diagnostics.push(diagnostic("AB361", `${target} has no native command-policy format`, "unsupported", {
|
|
568
|
+
target,
|
|
569
|
+
profile,
|
|
570
|
+
remediation: `Express the policy natively for ${target}; prompt rules are not security policy.`,
|
|
571
|
+
}));
|
|
572
|
+
return;
|
|
573
|
+
}
|
|
574
|
+
// `paths.project.policies` is the surface each form writes into, and the
|
|
575
|
+
// forms disagree about what that means: Claude Code and Cursor name a file,
|
|
576
|
+
// Codex names the directory its rules file lives in. Each form reads it the
|
|
577
|
+
// way its own host does rather than the field being normalized to one shape.
|
|
578
|
+
const policyPath = profileFor(target).paths.project.policies;
|
|
579
|
+
if (form === "claude-permissions") {
|
|
580
|
+
const permissions = { allow: [], ask: [], deny: [] };
|
|
581
|
+
for (const entry of entries) {
|
|
582
|
+
const action = String(entry.action ?? entry.decision ?? "prompt");
|
|
583
|
+
const rawPattern = entry.pattern ?? entry.prefix ?? entry.command ?? "";
|
|
584
|
+
const pattern = Array.isArray(rawPattern)
|
|
585
|
+
? rawPattern.flat().map(String).join(" ")
|
|
586
|
+
: String(rawPattern);
|
|
587
|
+
permissions[action === "prompt" ? "ask" : action]?.push(`Bash(${pattern} *)`);
|
|
588
|
+
}
|
|
589
|
+
artifacts.push({
|
|
590
|
+
path: policyPath ?? ".claude/settings.json",
|
|
591
|
+
content: json({ permissions }),
|
|
592
|
+
mode: 0o644,
|
|
593
|
+
});
|
|
594
|
+
}
|
|
595
|
+
else if (form === "codex-prefix-rules") {
|
|
596
|
+
const lines = entries.map((entry) => {
|
|
597
|
+
const rawPattern = entry.pattern ?? entry.prefix ?? entry.command ?? [];
|
|
598
|
+
const pattern = Array.isArray(rawPattern)
|
|
599
|
+
? rawPattern
|
|
600
|
+
: String(rawPattern).trim().split(/\s+/).filter(Boolean);
|
|
601
|
+
const action = String(entry.action ?? entry.decision ?? "prompt");
|
|
602
|
+
const decision = action === "deny" ? "forbidden" : action;
|
|
603
|
+
const fields = [
|
|
604
|
+
` pattern = ${JSON.stringify(pattern)},`,
|
|
605
|
+
` decision = ${JSON.stringify(decision)},`,
|
|
606
|
+
];
|
|
607
|
+
if (entry.justification)
|
|
608
|
+
fields.push(` justification = ${JSON.stringify(String(entry.justification))},`);
|
|
609
|
+
const positive = entry.positiveExamples ?? entry.matches;
|
|
610
|
+
const negative = entry.negativeExamples ?? entry.nonMatches;
|
|
611
|
+
if (Array.isArray(positive))
|
|
612
|
+
fields.push(` match = ${JSON.stringify(positive.map(String))},`);
|
|
613
|
+
if (Array.isArray(negative))
|
|
614
|
+
fields.push(` not_match = ${JSON.stringify(negative.map(String))},`);
|
|
615
|
+
return `prefix_rule(\n${fields.join("\n")}\n)`;
|
|
616
|
+
});
|
|
617
|
+
artifacts.push({
|
|
618
|
+
path: `${policyPath ?? ".codex/rules"}/bundle.rules`,
|
|
619
|
+
content: Buffer.from(lines.join("\n") + "\n"),
|
|
620
|
+
mode: 0o644,
|
|
621
|
+
});
|
|
622
|
+
}
|
|
623
|
+
}
|
|
624
|
+
export function renderBundle(bundle, targets, profiles) {
|
|
625
|
+
const diagnostics = [...bundle.diagnostics];
|
|
626
|
+
const artifacts = [];
|
|
627
|
+
for (const target of targets)
|
|
628
|
+
for (const profile of profiles) {
|
|
629
|
+
const prefix = `${target}/${profile}`;
|
|
630
|
+
const local = [];
|
|
631
|
+
const overlay = bundle.overlays.find((item) => item.target === target);
|
|
632
|
+
if (profile === "plugin") {
|
|
633
|
+
const { directory: manifestDir, file: manifestFile } = profileFor(target).manifest;
|
|
634
|
+
// `directory` is declared nullable for a host whose manifest sits at
|
|
635
|
+
// the plugin root; `import/detect.ts` already honours that.
|
|
636
|
+
local.push({
|
|
637
|
+
path: manifestDir ? `${manifestDir}/${manifestFile}` : manifestFile,
|
|
638
|
+
content: json(applyOverlayManifest(manifest(bundle, target), overlay?.manifest, target, diagnostics)),
|
|
639
|
+
mode: 0o644,
|
|
640
|
+
});
|
|
641
|
+
}
|
|
642
|
+
for (const skill of bundle.skills)
|
|
643
|
+
renderSkill(bundle, skill, target, profile, diagnostics, local);
|
|
644
|
+
for (const agent of bundle.agents)
|
|
645
|
+
renderAgent(agent, target, profile, bundle, diagnostics, local);
|
|
646
|
+
renderRules(bundle, target, profile, diagnostics, local);
|
|
647
|
+
renderPolicies(bundle, target, profile, diagnostics, local);
|
|
648
|
+
if (bundle.hooks && profileFor(target).features.hooks.profiles.includes(profile)) {
|
|
649
|
+
const hookRoots = profileFor(target).paths.plugin;
|
|
650
|
+
const hooks = transformedHooks(bundle, target, profile, diagnostics);
|
|
651
|
+
if (hooks)
|
|
652
|
+
local.push({ path: hookRoots.hooksFile, content: json(hooks), mode: 0o644 });
|
|
653
|
+
for (const file of bundle.hookFiles)
|
|
654
|
+
local.push({
|
|
655
|
+
...file,
|
|
656
|
+
path: `${hookRoots.hooks}/${file.path.split(path.sep).join("/")}`,
|
|
657
|
+
});
|
|
658
|
+
}
|
|
659
|
+
if (bundle.mcp && profile === "plugin") {
|
|
660
|
+
const targetMcp = structuredTargetValue(bundle.mcp.value, target);
|
|
661
|
+
const rewritten = rewritePlaceholders(JSON.stringify(targetMcp), target, "other", diagnostics, undefined, profile);
|
|
662
|
+
const pluginMcp = profileFor(target).paths.plugin.mcp ?? ".mcp.json";
|
|
663
|
+
local.push({ path: pluginMcp, content: json(JSON.parse(rewritten)), mode: 0o644 });
|
|
664
|
+
}
|
|
665
|
+
else if (bundle.mcp && profile === "project") {
|
|
666
|
+
const targetMcp = structuredTargetValue(bundle.mcp.value, target);
|
|
667
|
+
const rewritten = rewritePlaceholders(JSON.stringify(targetMcp), target, "other", diagnostics, undefined, profile);
|
|
668
|
+
const mcpPath = profileFor(target).paths.project.mcp ?? ".mcp.json";
|
|
669
|
+
if (target === "codex" && typeof targetMcp.configToml === "string")
|
|
670
|
+
local.push({
|
|
671
|
+
path: ".codex/config.toml",
|
|
672
|
+
content: Buffer.from(String(targetMcp.configToml).trimEnd() + "\n"),
|
|
673
|
+
mode: 0o644,
|
|
674
|
+
});
|
|
675
|
+
else if (target === "codex")
|
|
676
|
+
diagnostics.push(diagnostic("AB370", "Codex project MCP configuration requires TOML and cannot be translated losslessly from arbitrary structured input", "unsupported", {
|
|
677
|
+
path: bundle.mcp.path,
|
|
678
|
+
target,
|
|
679
|
+
profile,
|
|
680
|
+
remediation: "Provide targets.codex.configToml or use the plugin profile.",
|
|
681
|
+
}));
|
|
682
|
+
else
|
|
683
|
+
local.push({ path: mcpPath, content: json(JSON.parse(rewritten)), mode: 0o644 });
|
|
684
|
+
}
|
|
685
|
+
for (const asset of bundle.assets) {
|
|
686
|
+
const textual = /\.(?:md|txt|json|ya?ml|toml|sh|js|mjs|cjs|ts|py)$/i.test(asset.path) &&
|
|
687
|
+
!asset.content.includes(0);
|
|
688
|
+
local.push({
|
|
689
|
+
...asset,
|
|
690
|
+
content: textual
|
|
691
|
+
? Buffer.from(rewritePlaceholders(processTargetBlocks(asset.content.toString("utf8"), target), target, "other", diagnostics, undefined, profile))
|
|
692
|
+
: asset.content,
|
|
693
|
+
path: bundle.legacy
|
|
694
|
+
? asset.path.split(path.sep).join("/")
|
|
695
|
+
: `assets/${asset.path.split(path.sep).join("/")}`,
|
|
696
|
+
});
|
|
697
|
+
}
|
|
698
|
+
// Overlays merge after every portable component so a collision is decided
|
|
699
|
+
// against the complete portable set, never against a partial one.
|
|
700
|
+
const merged = mergeOverlay(local, overlayArtifacts(overlay, profile), overlay?.onCollision ?? "overlay-wins", target, profile, diagnostics);
|
|
701
|
+
const seen = new Set();
|
|
702
|
+
for (const artifact of merged.sort((a, b) => a.path.localeCompare(b.path))) {
|
|
703
|
+
if (seen.has(artifact.path))
|
|
704
|
+
diagnostics.push({
|
|
705
|
+
...diagnostic("AB170", `Duplicate output path '${artifact.path}'`, "unsupported", {
|
|
706
|
+
target,
|
|
707
|
+
profile,
|
|
708
|
+
remediation: "Rename one of the colliding components.",
|
|
709
|
+
}),
|
|
710
|
+
severity: "error",
|
|
711
|
+
});
|
|
712
|
+
seen.add(artifact.path);
|
|
713
|
+
artifacts.push({ ...artifact, path: `${prefix}/${artifact.path}` });
|
|
714
|
+
}
|
|
715
|
+
}
|
|
716
|
+
const unique = new Map();
|
|
717
|
+
for (const item of diagnostics)
|
|
718
|
+
unique.set(JSON.stringify(item), item);
|
|
719
|
+
return { artifacts, diagnostics: [...unique.values()] };
|
|
720
|
+
}
|
|
721
|
+
//# sourceMappingURL=render.js.map
|