@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,62 @@
|
|
|
1
|
+
import type { SqliteDatabase } from "./sqlite.js";
|
|
2
|
+
/**
|
|
3
|
+
* Opening and migrating a SQLite store this project owns.
|
|
4
|
+
*
|
|
5
|
+
* Two stores use it — the usage store and the artifact archive index — and they
|
|
6
|
+
* share it rather than each carrying a copy, because the parts that are easy to
|
|
7
|
+
* get subtly wrong are the same in both: running migrations inside one
|
|
8
|
+
* transaction, writing `user_version` inside that same transaction, and refusing
|
|
9
|
+
* a file from the future instead of writing to it.
|
|
10
|
+
*
|
|
11
|
+
* These are **migrated** stores, not caches. `src/url-cache.ts` and the
|
|
12
|
+
* workspace index invalidate by discarding, which is safe because their contents
|
|
13
|
+
* are always re-derivable. Neither of these is: an archive holds the only copy
|
|
14
|
+
* of files that may since have been deleted, and the usage store can outlive the
|
|
15
|
+
* transcripts it was built from. So a version bump carries the data forward, and
|
|
16
|
+
* the rules in {@link Migration} are not optional.
|
|
17
|
+
*/
|
|
18
|
+
export interface Migration {
|
|
19
|
+
version: number;
|
|
20
|
+
description: string;
|
|
21
|
+
up(db: SqliteDatabase): void;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Thrown when the file on disk was written by a newer build.
|
|
25
|
+
*
|
|
26
|
+
* Refusing is the point. A newer schema may carry columns this build does not
|
|
27
|
+
* know about, and opening it read-write would drop them on the next write — for
|
|
28
|
+
* a store that may hold the only copy of something, silently.
|
|
29
|
+
*/
|
|
30
|
+
export declare class StoreTooNewError extends Error {
|
|
31
|
+
readonly label: string;
|
|
32
|
+
readonly found: number;
|
|
33
|
+
readonly supported: number;
|
|
34
|
+
constructor(label: string, found: number, supported: number);
|
|
35
|
+
}
|
|
36
|
+
export interface StoreOptions {
|
|
37
|
+
path: string;
|
|
38
|
+
/** Ordered migrations. The highest version is what this build writes. */
|
|
39
|
+
migrations: readonly Migration[];
|
|
40
|
+
/** Names the store in error messages, e.g. "usage database". */
|
|
41
|
+
label: string;
|
|
42
|
+
/** Open without migrating, and refuse to create. */
|
|
43
|
+
readOnly?: boolean;
|
|
44
|
+
/** Apply pending migrations. Default true. */
|
|
45
|
+
migrate?: boolean;
|
|
46
|
+
}
|
|
47
|
+
export interface StoreHandle {
|
|
48
|
+
db: SqliteDatabase;
|
|
49
|
+
/** Version before this call did anything. */
|
|
50
|
+
from: number;
|
|
51
|
+
/** Version now. */
|
|
52
|
+
to: number;
|
|
53
|
+
/** Versions applied by this call, in order. */
|
|
54
|
+
applied: number[];
|
|
55
|
+
}
|
|
56
|
+
export declare function latestVersion(migrations: readonly Migration[]): number;
|
|
57
|
+
export declare function userVersion(db: SqliteDatabase): number;
|
|
58
|
+
export declare function openStore(options: StoreOptions): StoreHandle;
|
|
59
|
+
/** Closing must never fail a caller that already has its answer. */
|
|
60
|
+
export declare function closeQuietly(db: SqliteDatabase | undefined): void;
|
|
61
|
+
/** Runs `work` inside a transaction, rolling back if it throws. */
|
|
62
|
+
export declare function transact<T>(db: SqliteDatabase, work: () => T): T;
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { requireSqlite } from "./sqlite.js";
|
|
4
|
+
/**
|
|
5
|
+
* Thrown when the file on disk was written by a newer build.
|
|
6
|
+
*
|
|
7
|
+
* Refusing is the point. A newer schema may carry columns this build does not
|
|
8
|
+
* know about, and opening it read-write would drop them on the next write — for
|
|
9
|
+
* a store that may hold the only copy of something, silently.
|
|
10
|
+
*/
|
|
11
|
+
export class StoreTooNewError extends Error {
|
|
12
|
+
label;
|
|
13
|
+
found;
|
|
14
|
+
supported;
|
|
15
|
+
constructor(label, found, supported) {
|
|
16
|
+
super(`The ${label} is at schema version ${found}, but this build of cairn ` +
|
|
17
|
+
`understands ${supported}. Upgrade cairn to read it.`);
|
|
18
|
+
this.label = label;
|
|
19
|
+
this.found = found;
|
|
20
|
+
this.supported = supported;
|
|
21
|
+
this.name = "StoreTooNewError";
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
export function latestVersion(migrations) {
|
|
25
|
+
return migrations.reduce((highest, migration) => Math.max(highest, migration.version), 0);
|
|
26
|
+
}
|
|
27
|
+
export function userVersion(db) {
|
|
28
|
+
const value = db.prepare("PRAGMA user_version").get()?.user_version;
|
|
29
|
+
return typeof value === "number" ? value : 0;
|
|
30
|
+
}
|
|
31
|
+
export function openStore(options) {
|
|
32
|
+
const sqlite = requireSqlite();
|
|
33
|
+
const readOnly = options.readOnly === true;
|
|
34
|
+
const latest = latestVersion(options.migrations);
|
|
35
|
+
if (readOnly && !fs.existsSync(options.path)) {
|
|
36
|
+
throw new Error(`No ${options.label} at ${options.path}.`);
|
|
37
|
+
}
|
|
38
|
+
if (!readOnly)
|
|
39
|
+
fs.mkdirSync(path.dirname(options.path), { recursive: true });
|
|
40
|
+
const db = new sqlite.DatabaseSync(options.path, readOnly ? { readOnly: true } : {});
|
|
41
|
+
try {
|
|
42
|
+
if (!readOnly) {
|
|
43
|
+
// WAL so a reader in another process is not blocked by an import, which is
|
|
44
|
+
// the normal shape here: a report runs while another terminal writes.
|
|
45
|
+
db.exec("PRAGMA journal_mode = WAL");
|
|
46
|
+
db.exec("PRAGMA synchronous = NORMAL");
|
|
47
|
+
}
|
|
48
|
+
// Both schemas lean on ON DELETE CASCADE to replace a row's children. With
|
|
49
|
+
// this pragma off SQLite silently orphans them instead.
|
|
50
|
+
db.exec("PRAGMA foreign_keys = ON");
|
|
51
|
+
const from = userVersion(db);
|
|
52
|
+
if (from > latest)
|
|
53
|
+
throw new StoreTooNewError(options.label, from, latest);
|
|
54
|
+
const applied = [];
|
|
55
|
+
if (options.migrate !== false && !readOnly && from < latest) {
|
|
56
|
+
const pending = options.migrations
|
|
57
|
+
.filter((migration) => migration.version > from)
|
|
58
|
+
.sort((a, b) => a.version - b.version);
|
|
59
|
+
db.exec("BEGIN");
|
|
60
|
+
try {
|
|
61
|
+
for (const migration of pending) {
|
|
62
|
+
migration.up(db);
|
|
63
|
+
applied.push(migration.version);
|
|
64
|
+
}
|
|
65
|
+
// A pragma takes no bound parameter, so the value is interpolated. It is
|
|
66
|
+
// a number derived from this build's own migration list, never input.
|
|
67
|
+
db.exec(`PRAGMA user_version = ${latest}`);
|
|
68
|
+
db.exec("COMMIT");
|
|
69
|
+
}
|
|
70
|
+
catch (error) {
|
|
71
|
+
db.exec("ROLLBACK");
|
|
72
|
+
throw error;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return { db, from, to: userVersion(db), applied };
|
|
76
|
+
}
|
|
77
|
+
catch (error) {
|
|
78
|
+
closeQuietly(db);
|
|
79
|
+
throw error;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
/** Closing must never fail a caller that already has its answer. */
|
|
83
|
+
export function closeQuietly(db) {
|
|
84
|
+
try {
|
|
85
|
+
db?.close();
|
|
86
|
+
}
|
|
87
|
+
catch {
|
|
88
|
+
// Best-effort.
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
/** Runs `work` inside a transaction, rolling back if it throws. */
|
|
92
|
+
export function transact(db, work) {
|
|
93
|
+
db.exec("BEGIN");
|
|
94
|
+
try {
|
|
95
|
+
const result = work();
|
|
96
|
+
db.exec("COMMIT");
|
|
97
|
+
return result;
|
|
98
|
+
}
|
|
99
|
+
catch (error) {
|
|
100
|
+
db.exec("ROLLBACK");
|
|
101
|
+
throw error;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
//# sourceMappingURL=sqlite-store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sqlite-store.js","sourceRoot":"","sources":["../src/sqlite-store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,M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QACpB,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC"}
|
package/dist/sqlite.d.ts
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `node:sqlite` boundary.
|
|
3
|
+
*
|
|
4
|
+
* Two very different callers share this module. The antigravity provider opens
|
|
5
|
+
* somebody else's database read-only and treats every failure as a missing
|
|
6
|
+
* token column; the usage store and the artifact archive own their databases and
|
|
7
|
+
* write to them. What they have in common is the loader below, which must not be
|
|
8
|
+
* duplicated: the `process.emitWarning` swap it performs is load-bearing, and a
|
|
9
|
+
* second copy would be a second chance to get it wrong.
|
|
10
|
+
*
|
|
11
|
+
* The interfaces are hand-written rather than imported from `node:sqlite`
|
|
12
|
+
* because the module is only required at runtime — `@types/node` declares it,
|
|
13
|
+
* but importing the type would make `dist` depend on a module the type checker
|
|
14
|
+
* resolves and the emitted code must not.
|
|
15
|
+
*/
|
|
16
|
+
export interface SqliteRow {
|
|
17
|
+
[column: string]: unknown;
|
|
18
|
+
}
|
|
19
|
+
/** The subset of `StatementSync` this project uses. */
|
|
20
|
+
export interface SqliteStatement {
|
|
21
|
+
all(...parameters: unknown[]): SqliteRow[];
|
|
22
|
+
get(...parameters: unknown[]): SqliteRow | undefined;
|
|
23
|
+
run(...parameters: unknown[]): {
|
|
24
|
+
changes: number | bigint;
|
|
25
|
+
lastInsertRowid: number | bigint;
|
|
26
|
+
};
|
|
27
|
+
iterate(...parameters: unknown[]): IterableIterator<SqliteRow>;
|
|
28
|
+
}
|
|
29
|
+
/** The subset of `DatabaseSync` this project uses. */
|
|
30
|
+
export interface SqliteDatabase {
|
|
31
|
+
prepare(sql: string): SqliteStatement;
|
|
32
|
+
exec(sql: string): void;
|
|
33
|
+
close(): void;
|
|
34
|
+
}
|
|
35
|
+
export interface SqliteModule {
|
|
36
|
+
DatabaseSync: new (path: string, options?: object) => SqliteDatabase;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Loads `node:sqlite`, suppressing its experimental warning.
|
|
40
|
+
*
|
|
41
|
+
* The warning goes to stderr, and stderr carries the JSON payload whenever a
|
|
42
|
+
* command reports findings — so letting it through would corrupt a consumer's
|
|
43
|
+
* parse. This is the same rule that keeps the update notifier off machine-
|
|
44
|
+
* readable streams.
|
|
45
|
+
*
|
|
46
|
+
* Returns null when the runtime has no `node:sqlite`. For the antigravity
|
|
47
|
+
* provider that costs the token column and nothing else; for the usage store it
|
|
48
|
+
* is fatal, and `openDatabase` says so rather than degrading silently.
|
|
49
|
+
*
|
|
50
|
+
* The tri-state memo is deliberate: `undefined` means untried, `null` means
|
|
51
|
+
* tried and unavailable, so a missing module is not re-required per call.
|
|
52
|
+
*/
|
|
53
|
+
export declare function loadSqlite(): SqliteModule | null;
|
|
54
|
+
/** Thrown when a caller that requires SQLite cannot have it. */
|
|
55
|
+
export declare class SqliteUnavailableError extends Error {
|
|
56
|
+
constructor();
|
|
57
|
+
}
|
|
58
|
+
/** Loads the module or throws. For callers that cannot degrade. */
|
|
59
|
+
export declare function requireSqlite(): SqliteModule;
|
package/dist/sqlite.js
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
let sqliteModule;
|
|
3
|
+
/**
|
|
4
|
+
* Loads `node:sqlite`, suppressing its experimental warning.
|
|
5
|
+
*
|
|
6
|
+
* The warning goes to stderr, and stderr carries the JSON payload whenever a
|
|
7
|
+
* command reports findings — so letting it through would corrupt a consumer's
|
|
8
|
+
* parse. This is the same rule that keeps the update notifier off machine-
|
|
9
|
+
* readable streams.
|
|
10
|
+
*
|
|
11
|
+
* Returns null when the runtime has no `node:sqlite`. For the antigravity
|
|
12
|
+
* provider that costs the token column and nothing else; for the usage store it
|
|
13
|
+
* is fatal, and `openDatabase` says so rather than degrading silently.
|
|
14
|
+
*
|
|
15
|
+
* The tri-state memo is deliberate: `undefined` means untried, `null` means
|
|
16
|
+
* tried and unavailable, so a missing module is not re-required per call.
|
|
17
|
+
*/
|
|
18
|
+
export function loadSqlite() {
|
|
19
|
+
if (sqliteModule !== undefined)
|
|
20
|
+
return sqliteModule;
|
|
21
|
+
const emit = process.emitWarning;
|
|
22
|
+
try {
|
|
23
|
+
process.emitWarning = () => { };
|
|
24
|
+
// A synchronous require of a builtin, which `import` cannot do from a
|
|
25
|
+
// non-async call site. `createRequire` is how ESM asks for one.
|
|
26
|
+
sqliteModule = createRequire(import.meta.url)("node:sqlite");
|
|
27
|
+
}
|
|
28
|
+
catch {
|
|
29
|
+
sqliteModule = null;
|
|
30
|
+
}
|
|
31
|
+
finally {
|
|
32
|
+
process.emitWarning = emit;
|
|
33
|
+
}
|
|
34
|
+
return sqliteModule;
|
|
35
|
+
}
|
|
36
|
+
/** Thrown when a caller that requires SQLite cannot have it. */
|
|
37
|
+
export class SqliteUnavailableError extends Error {
|
|
38
|
+
constructor() {
|
|
39
|
+
super("This build of Node has no `node:sqlite`. The usage store needs it; " +
|
|
40
|
+
"run with --no-index to report without one.");
|
|
41
|
+
this.name = "SqliteUnavailableError";
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
/** Loads the module or throws. For callers that cannot degrade. */
|
|
45
|
+
export function requireSqlite() {
|
|
46
|
+
const module = loadSqlite();
|
|
47
|
+
if (!module)
|
|
48
|
+
throw new SqliteUnavailableError();
|
|
49
|
+
return module;
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=sqlite.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sqlite.js","sourceRoot":"","sources":["../src/sqlite.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAyC5C,IAAI,YAA6C,CAAC;AAElD;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,UAAU;IACxB,IAAI,YAAY,KAAK,SAAS;QAAE,OAAO,YAAY,CAAC;IACpD,MAAM,IAAI,GAAG,OAAO,CAAC,WAAW,CAAC;IACjC,IAAI,CAAC;QACH,OAAO,CAAC,WAAW,GAAG,GAAG,EAAE,GAAE,CAAC,CAAC;QAC/B,sEAAsE;QACtE,gEAAgE;QAChE,YAAY,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,aAAa,CAAiB,CAAC;IAC/E,CAAC;IAAC,MAAM,CAAC;QACP,YAAY,GAAG,IAAI,CAAC;IACtB,CAAC;YAAS,CAAC;QACT,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC;IAC7B,CAAC;IACD,OAAO,YAAY,CAAC;AACtB,CAAC;AAED,gEAAgE;AAChE,MAAM,OAAO,sBAAuB,SAAQ,KAAK;IAC/C;QACE,KAAK,CACH,qEAAqE;YACnE,4CAA4C,CAC/C,CAAC;QACF,IAAI,CAAC,IAAI,GAAG,wBAAwB,CAAC;IACvC,CAAC;CACF;AAED,mEAAmE;AACnE,MAAM,UAAU,aAAa;IAC3B,MAAM,MAAM,GAAG,UAAU,EAAE,CAAC;IAC5B,IAAI,CAAC,MAAM;QAAE,MAAM,IAAI,sBAAsB,EAAE,CAAC;IAChD,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
package/dist/toc.d.ts
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { type MdCodeBlock, type MdHeading } from "./markdown-ast.js";
|
|
2
|
+
export declare const TOC_START = "<!-- cairn:toc:start -->";
|
|
3
|
+
export declare const TOC_END = "<!-- cairn:toc:end -->";
|
|
4
|
+
/**
|
|
5
|
+
* The pre-rename markers, still recognized so documents already carrying them
|
|
6
|
+
* keep synchronizing.
|
|
7
|
+
*
|
|
8
|
+
* A found pair keeps its own spelling: `synchronizeToc` only ever rewrites the
|
|
9
|
+
* interior between the markers, never the markers themselves. Migrating them on
|
|
10
|
+
* `--write` would report every legacy document as stale for a change that alters
|
|
11
|
+
* no table of contents, so the two spellings are equal forever and only an
|
|
12
|
+
* inserted pair uses the current one.
|
|
13
|
+
*/
|
|
14
|
+
export declare const LEGACY_TOC_START = "<!-- claude-cli:toc:start -->";
|
|
15
|
+
export declare const LEGACY_TOC_END = "<!-- claude-cli:toc:end -->";
|
|
16
|
+
export declare function renderToc(headings: MdHeading[], ordered?: boolean): string;
|
|
17
|
+
/**
|
|
18
|
+
* Offsets of the bytes strictly between the markers.
|
|
19
|
+
*
|
|
20
|
+
* Reported so a caller can express the update as a scoped edit rather than a
|
|
21
|
+
* whole-file replacement; `synchronizeToc` computes it either way.
|
|
22
|
+
*/
|
|
23
|
+
export interface TocRange {
|
|
24
|
+
start: number;
|
|
25
|
+
end: number;
|
|
26
|
+
}
|
|
27
|
+
export type TocSynchronization = {
|
|
28
|
+
status: "missing";
|
|
29
|
+
} | {
|
|
30
|
+
status: "malformed";
|
|
31
|
+
message: string;
|
|
32
|
+
} | {
|
|
33
|
+
status: "current";
|
|
34
|
+
content: string;
|
|
35
|
+
block: string;
|
|
36
|
+
range: TocRange;
|
|
37
|
+
} | {
|
|
38
|
+
status: "stale";
|
|
39
|
+
content: string;
|
|
40
|
+
replacement: string;
|
|
41
|
+
block: string;
|
|
42
|
+
range: TocRange;
|
|
43
|
+
/** The rendered interior that belongs between the markers. */
|
|
44
|
+
interior: string;
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* Locates the marker block, ignoring markers inside fenced code.
|
|
48
|
+
*
|
|
49
|
+
* Markers are found by scanning raw text, so a fenced block *documenting* the
|
|
50
|
+
* syntax — as this project's own README and `md toc` page both do — would
|
|
51
|
+
* otherwise look like a real pair, and writing a table of contents into a code
|
|
52
|
+
* sample would corrupt it.
|
|
53
|
+
*
|
|
54
|
+
* `codeBlocks` is optional only so a caller that already parsed the document
|
|
55
|
+
* can avoid a second parse. Omitting it parses rather than skipping the check,
|
|
56
|
+
* so a caller cannot silently opt out.
|
|
57
|
+
*/
|
|
58
|
+
export declare function synchronizeToc(content: string, toc: string, codeBlocks?: readonly MdCodeBlock[]): TocSynchronization;
|
package/dist/toc.js
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { extractCodeBlocks, isLineInCodeBlock, parseMarkdown, } from "./markdown-ast.js";
|
|
2
|
+
export const TOC_START = "<!-- cairn:toc:start -->";
|
|
3
|
+
export const TOC_END = "<!-- cairn:toc:end -->";
|
|
4
|
+
/**
|
|
5
|
+
* The pre-rename markers, still recognized so documents already carrying them
|
|
6
|
+
* keep synchronizing.
|
|
7
|
+
*
|
|
8
|
+
* A found pair keeps its own spelling: `synchronizeToc` only ever rewrites the
|
|
9
|
+
* interior between the markers, never the markers themselves. Migrating them on
|
|
10
|
+
* `--write` would report every legacy document as stale for a change that alters
|
|
11
|
+
* no table of contents, so the two spellings are equal forever and only an
|
|
12
|
+
* inserted pair uses the current one.
|
|
13
|
+
*/
|
|
14
|
+
export const LEGACY_TOC_START = "<!-- claude-cli:toc:start -->";
|
|
15
|
+
export const LEGACY_TOC_END = "<!-- claude-cli:toc:end -->";
|
|
16
|
+
export function renderToc(headings, ordered = false) {
|
|
17
|
+
if (!headings.length)
|
|
18
|
+
return "";
|
|
19
|
+
const baseDepth = Math.min(...headings.map((heading) => heading.depth));
|
|
20
|
+
return headings
|
|
21
|
+
.map((heading) => `${" ".repeat(heading.depth - baseDepth)}${ordered ? "1." : "-"} [${heading.text}](#${heading.slug})`)
|
|
22
|
+
.join("\n");
|
|
23
|
+
}
|
|
24
|
+
/** 1-based line containing `offset`. */
|
|
25
|
+
function lineOf(content, offset) {
|
|
26
|
+
let line = 1;
|
|
27
|
+
for (let index = 0; index < offset && index < content.length; index++) {
|
|
28
|
+
if (content[index] === "\n")
|
|
29
|
+
line++;
|
|
30
|
+
}
|
|
31
|
+
return line;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Locates the marker block, ignoring markers inside fenced code.
|
|
35
|
+
*
|
|
36
|
+
* Markers are found by scanning raw text, so a fenced block *documenting* the
|
|
37
|
+
* syntax — as this project's own README and `md toc` page both do — would
|
|
38
|
+
* otherwise look like a real pair, and writing a table of contents into a code
|
|
39
|
+
* sample would corrupt it.
|
|
40
|
+
*
|
|
41
|
+
* `codeBlocks` is optional only so a caller that already parsed the document
|
|
42
|
+
* can avoid a second parse. Omitting it parses rather than skipping the check,
|
|
43
|
+
* so a caller cannot silently opt out.
|
|
44
|
+
*/
|
|
45
|
+
export function synchronizeToc(content, toc, codeBlocks) {
|
|
46
|
+
const fenced = codeBlocks ?? extractCodeBlocks(parseMarkdown(content));
|
|
47
|
+
const outsideFence = (match) => !isLineInCodeBlock(lineOf(content, match.index), [...fenced]);
|
|
48
|
+
const matches = (marker) => [...content.matchAll(new RegExp(marker, "g"))].filter(outsideFence);
|
|
49
|
+
const starts = [...matches(TOC_START), ...matches(LEGACY_TOC_START)];
|
|
50
|
+
const ends = [...matches(TOC_END), ...matches(LEGACY_TOC_END)];
|
|
51
|
+
if (!starts.length && !ends.length)
|
|
52
|
+
return { status: "missing" };
|
|
53
|
+
if (starts.length !== 1 || ends.length !== 1)
|
|
54
|
+
return { status: "malformed", message: "Expected exactly one TOC marker pair" };
|
|
55
|
+
// Both spellings are read, but a pair may not mix them: the two halves of one
|
|
56
|
+
// block always came from the same writer, so a mixed pair is a hand edit that
|
|
57
|
+
// silently lost half a rename rather than something to guess at.
|
|
58
|
+
const legacy = starts[0][0] === LEGACY_TOC_START;
|
|
59
|
+
if (legacy !== (ends[0][0] === LEGACY_TOC_END))
|
|
60
|
+
return { status: "malformed", message: "TOC start and end markers use different spellings" };
|
|
61
|
+
const startMarker = legacy ? LEGACY_TOC_START : TOC_START;
|
|
62
|
+
const endMarker = legacy ? LEGACY_TOC_END : TOC_END;
|
|
63
|
+
const startEnd = starts[0].index + startMarker.length;
|
|
64
|
+
const endStart = ends[0].index;
|
|
65
|
+
if (endStart < startEnd)
|
|
66
|
+
return { status: "malformed", message: "TOC end marker appears before start marker" };
|
|
67
|
+
const eol = content.includes("\r\n") ? "\r\n" : "\n";
|
|
68
|
+
const normalizedToc = toc.replace(/\r?\n/g, eol);
|
|
69
|
+
const interior = `${eol}${normalizedToc}${normalizedToc ? eol : ""}`;
|
|
70
|
+
const block = `${startMarker}${interior}${endMarker}`;
|
|
71
|
+
const range = { start: startEnd, end: endStart };
|
|
72
|
+
if (content.slice(startEnd, endStart) === interior)
|
|
73
|
+
return { status: "current", content, block, range };
|
|
74
|
+
return {
|
|
75
|
+
status: "stale",
|
|
76
|
+
content,
|
|
77
|
+
replacement: content.slice(0, startEnd) + interior + content.slice(endStart),
|
|
78
|
+
block,
|
|
79
|
+
range,
|
|
80
|
+
interior,
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
//# sourceMappingURL=toc.js.map
|
package/dist/toc.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toc.js","sourceRoot":"","sources":["../src/toc.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,iBAAiB,EACjB,aAAa,GAGd,MAAM,mBAAmB,CAAC;AAE3B,MAAM,CAAC,MAAM,SAAS,GAAG,0BAA0B,CAAC;AACpD,MAAM,CAAC,MAAM,OAAO,GAAG,wBAAwB,CAAC;AAEhD;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,+BAA+B,CAAC;AAChE,MAAM,CAAC,MAAM,cAAc,GAAG,6BAA6B,CAAC;AAE5D,MAAM,UAAU,SAAS,CAAC,QAAqB,EAAE,OAAO,GAAG,KAAK;IAC9D,IAAI,CAAC,QAAQ,CAAC,MAAM;QAAE,OAAO,EAAE,CAAC;IAChC,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC;IACxE,OAAO,QAAQ;SACZ,GAAG,CACF,CAAC,OAAO,EAAE,EAAE,CACV,GAAG,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,GAAG,SAAS,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,IAA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a,GAAG,aAAa,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;IACrE,MAAM,KAAK,GAAG,GAAG,WAAW,GAAG,QAAQ,GAAG,SAAS,EAAE,CAAC;IACtD,MAAM,KAAK,GAAG,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,EAAE,QAAQ,EAAE,CAAC;IACjD,IAAI,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,QAAQ,CAAC,KAAK,QAAQ;QAChD,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;IACtD,OAAO;QACL,MAAM,EAAE,OAAO;QACf,OAAO;QACP,WAAW,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,QAAQ,CAAC,GAAG,QAAQ,GAAG,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC;QAC5E,KAAK;QACL,KAAK;QACL,QAAQ;KACT,CAAC;AACJ,CAAC"}
|
package/dist/types.d.ts
ADDED
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/** How long a cached result stays fresh. */
|
|
2
|
+
export declare const CHECK_INTERVAL_MS: number;
|
|
3
|
+
/** argv token that runs the detached cache refresh. Hidden from help. */
|
|
4
|
+
export declare const REFRESH_COMMAND = "__refresh-update-cache";
|
|
5
|
+
/** User-facing command that checks explicitly; suppresses the passive notice. */
|
|
6
|
+
export declare const CHECK_COMMAND = "check-update";
|
|
7
|
+
/**
|
|
8
|
+
* Contract-discovery commands. Their stdout is unconditionally a machine
|
|
9
|
+
* document, so a notice is never useful alongside them.
|
|
10
|
+
*/
|
|
11
|
+
export declare const DESCRIBE_COMMAND = "describe";
|
|
12
|
+
export declare const SCHEMA_COMMAND = "schema";
|
|
13
|
+
export declare const COMPLETION_COMMAND = "completion";
|
|
14
|
+
/**
|
|
15
|
+
* `scripts run` hands its stderr to a child process, so a notice appended at exit
|
|
16
|
+
* would land inside whatever the calling hook captured.
|
|
17
|
+
*/
|
|
18
|
+
export declare const SCRIPTS_COMMAND = "scripts";
|
|
19
|
+
export declare const SCRIPTS_RUN_SUBCOMMAND = "run";
|
|
20
|
+
/**
|
|
21
|
+
* The machine-stream guarantees, published through `describe` so consumers can
|
|
22
|
+
* read them rather than infer them. Exported from here, next to the gate that
|
|
23
|
+
* enforces them, so the two cannot drift.
|
|
24
|
+
*/
|
|
25
|
+
export declare const NOTIFIER_CONTRACT: {
|
|
26
|
+
readonly description: "The update notice is advisory only and never appears on a machine-readable stream.";
|
|
27
|
+
readonly stream: "stderr";
|
|
28
|
+
readonly suppressedWhen: readonly ["CAIRN_NO_UPDATE_NOTIFIER=1", "CI is set", "stderr is not a TTY", "--format is json, jsonl, or sarif, including a project-configured format", "the command is check-update, describe, schema, completion, scripts run, or the internal cache refresh"];
|
|
29
|
+
readonly optOutEnv: "CAIRN_NO_UPDATE_NOTIFIER";
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* How long a held refresh lock is trusted. Must exceed the child's own fetch
|
|
33
|
+
* timeout so a working refresh is never treated as abandoned.
|
|
34
|
+
*/
|
|
35
|
+
export declare const LOCK_STALE_MS = 60000;
|
|
36
|
+
export interface UpdateCache {
|
|
37
|
+
/** Epoch ms of the last attempt — set even when the attempt failed, so failures back off too. */
|
|
38
|
+
lastCheckedAt: number;
|
|
39
|
+
/** Last known published version, or null if never resolved. */
|
|
40
|
+
latestVersion: string | null;
|
|
41
|
+
}
|
|
42
|
+
export declare function getCachePath(env?: NodeJS.ProcessEnv, homedir?: string): string;
|
|
43
|
+
export declare function readCache(cachePath: string): UpdateCache | null;
|
|
44
|
+
export declare function writeCache(cachePath: string, cache: UpdateCache): boolean;
|
|
45
|
+
export declare function getLockPath(cachePath: string): string;
|
|
46
|
+
/**
|
|
47
|
+
* Exclusively claims the right to spawn a refresh, so concurrent invocations
|
|
48
|
+
* cannot each start their own child process. Uses an atomic `wx` create rather
|
|
49
|
+
* than an exists-then-write check, which would race.
|
|
50
|
+
*
|
|
51
|
+
* Returns false when another refresh is already in flight.
|
|
52
|
+
*/
|
|
53
|
+
export declare function acquireRefreshLock(lockPath: string, now: number, staleMs?: number): boolean;
|
|
54
|
+
export declare function releaseRefreshLock(lockPath: string): void;
|
|
55
|
+
export declare function isCacheStale(cache: UpdateCache | null, now: number, intervalMs?: number): boolean;
|
|
56
|
+
/**
|
|
57
|
+
* True when `candidate` is a strictly newer release than `current`.
|
|
58
|
+
*
|
|
59
|
+
* Deliberately conservative: unparseable input and prerelease-to-prerelease
|
|
60
|
+
* comparisons return false. A wrong `true` nags the user on every command, so
|
|
61
|
+
* staying quiet is the safer failure mode.
|
|
62
|
+
*/
|
|
63
|
+
export declare function isNewerVersion(candidate: string, current: string): boolean;
|
|
64
|
+
/** Detects JSON output from already-normalised argv (cli.ts expands `-fj` first). */
|
|
65
|
+
export declare function hasJsonOutput(argv: readonly string[]): boolean;
|
|
66
|
+
export interface NotifyDecision {
|
|
67
|
+
currentVersion: string;
|
|
68
|
+
cache: UpdateCache | null;
|
|
69
|
+
argv: readonly string[];
|
|
70
|
+
isTty: boolean;
|
|
71
|
+
env: NodeJS.ProcessEnv;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Whether the notice may be shown at all. Also gates the background refresh, so
|
|
75
|
+
* non-interactive callers never spawn a child process either.
|
|
76
|
+
*/
|
|
77
|
+
export declare function isNotifierAllowed(ctx: Omit<NotifyDecision, "cache" | "currentVersion">): boolean;
|
|
78
|
+
export declare function shouldNotify(ctx: NotifyDecision): boolean;
|
|
79
|
+
export declare function formatNotice(current: string, latest: string, packageName: string): string;
|
|
80
|
+
export interface InstallOptions {
|
|
81
|
+
currentVersion: string;
|
|
82
|
+
packageName: string;
|
|
83
|
+
argv: readonly string[];
|
|
84
|
+
/** Path to the CLI entry point, re-invoked for the detached refresh. */
|
|
85
|
+
entryPoint: string;
|
|
86
|
+
env?: NodeJS.ProcessEnv;
|
|
87
|
+
now?: number;
|
|
88
|
+
isTty?: boolean;
|
|
89
|
+
cachePath?: string;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Prints an update notice from cache at process exit and kicks off a detached refresh when
|
|
93
|
+
* the cache is stale. Never delays or fails a command.
|
|
94
|
+
*/
|
|
95
|
+
export declare function installUpdateNotifier(opts: InstallOptions): void;
|