@isaacriehm/cairn-core 0.1.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/LICENSE +21 -0
- package/dist/.tsbuildinfo +1 -0
- package/dist/claude/error.d.ts +33 -0
- package/dist/claude/error.js +58 -0
- package/dist/claude/error.js.map +1 -0
- package/dist/claude/index.d.ts +3 -0
- package/dist/claude/index.js +3 -0
- package/dist/claude/index.js.map +1 -0
- package/dist/claude/runner.d.ts +11 -0
- package/dist/claude/runner.js +132 -0
- package/dist/claude/runner.js.map +1 -0
- package/dist/claude/types.d.ts +52 -0
- package/dist/claude/types.js +14 -0
- package/dist/claude/types.js.map +1 -0
- package/dist/context/checkpoint.d.ts +10 -0
- package/dist/context/checkpoint.js +29 -0
- package/dist/context/checkpoint.js.map +1 -0
- package/dist/context/handoff-builder.d.ts +11 -0
- package/dist/context/handoff-builder.js +268 -0
- package/dist/context/handoff-builder.js.map +1 -0
- package/dist/context/index.d.ts +11 -0
- package/dist/context/index.js +11 -0
- package/dist/context/index.js.map +1 -0
- package/dist/context/spec-delta.d.ts +47 -0
- package/dist/context/spec-delta.js +237 -0
- package/dist/context/spec-delta.js.map +1 -0
- package/dist/decision-capture/capture.d.ts +57 -0
- package/dist/decision-capture/capture.js +186 -0
- package/dist/decision-capture/capture.js.map +1 -0
- package/dist/decision-capture/extractor.d.ts +20 -0
- package/dist/decision-capture/extractor.js +103 -0
- package/dist/decision-capture/extractor.js.map +1 -0
- package/dist/decision-capture/id.d.ts +21 -0
- package/dist/decision-capture/id.js +60 -0
- package/dist/decision-capture/id.js.map +1 -0
- package/dist/decision-capture/index.d.ts +25 -0
- package/dist/decision-capture/index.js +21 -0
- package/dist/decision-capture/index.js.map +1 -0
- package/dist/decision-capture/prompt.d.ts +15 -0
- package/dist/decision-capture/prompt.js +68 -0
- package/dist/decision-capture/prompt.js.map +1 -0
- package/dist/decision-capture/refinement-prompt.d.ts +25 -0
- package/dist/decision-capture/refinement-prompt.js +146 -0
- package/dist/decision-capture/refinement-prompt.js.map +1 -0
- package/dist/decision-capture/refinement-schema.d.ts +52 -0
- package/dist/decision-capture/refinement-schema.js +61 -0
- package/dist/decision-capture/refinement-schema.js.map +1 -0
- package/dist/decision-capture/refinement.d.ts +60 -0
- package/dist/decision-capture/refinement.js +439 -0
- package/dist/decision-capture/refinement.js.map +1 -0
- package/dist/decision-capture/schema.d.ts +70 -0
- package/dist/decision-capture/schema.js +71 -0
- package/dist/decision-capture/schema.js.map +1 -0
- package/dist/decision-capture/types.d.ts +201 -0
- package/dist/decision-capture/types.js +20 -0
- package/dist/decision-capture/types.js.map +1 -0
- package/dist/decision-capture/writer.d.ts +90 -0
- package/dist/decision-capture/writer.js +267 -0
- package/dist/decision-capture/writer.js.map +1 -0
- package/dist/doctor/index.d.ts +48 -0
- package/dist/doctor/index.js +460 -0
- package/dist/doctor/index.js.map +1 -0
- package/dist/events/index.d.ts +15 -0
- package/dist/events/index.js +14 -0
- package/dist/events/index.js.map +1 -0
- package/dist/events/paths.d.ts +2 -0
- package/dist/events/paths.js +6 -0
- package/dist/events/paths.js.map +1 -0
- package/dist/events/reader.d.ts +40 -0
- package/dist/events/reader.js +139 -0
- package/dist/events/reader.js.map +1 -0
- package/dist/events/writer.d.ts +61 -0
- package/dist/events/writer.js +68 -0
- package/dist/events/writer.js.map +1 -0
- package/dist/frontend-types.d.ts +243 -0
- package/dist/frontend-types.js +15 -0
- package/dist/frontend-types.js.map +1 -0
- package/dist/gc/apply.d.ts +26 -0
- package/dist/gc/apply.js +48 -0
- package/dist/gc/apply.js.map +1 -0
- package/dist/gc/canary.d.ts +42 -0
- package/dist/gc/canary.js +134 -0
- package/dist/gc/canary.js.map +1 -0
- package/dist/gc/citation-integrity.d.ts +24 -0
- package/dist/gc/citation-integrity.js +151 -0
- package/dist/gc/citation-integrity.js.map +1 -0
- package/dist/gc/classify.d.ts +25 -0
- package/dist/gc/classify.js +89 -0
- package/dist/gc/classify.js.map +1 -0
- package/dist/gc/completion-integrity.d.ts +22 -0
- package/dist/gc/completion-integrity.js +165 -0
- package/dist/gc/completion-integrity.js.map +1 -0
- package/dist/gc/doc-gardening.d.ts +29 -0
- package/dist/gc/doc-gardening.js +146 -0
- package/dist/gc/doc-gardening.js.map +1 -0
- package/dist/gc/frontmatter.d.ts +35 -0
- package/dist/gc/frontmatter.js +105 -0
- package/dist/gc/frontmatter.js.map +1 -0
- package/dist/gc/generator-drift.d.ts +28 -0
- package/dist/gc/generator-drift.js +53 -0
- package/dist/gc/generator-drift.js.map +1 -0
- package/dist/gc/index.d.ts +42 -0
- package/dist/gc/index.js +30 -0
- package/dist/gc/index.js.map +1 -0
- package/dist/gc/quality-update.d.ts +23 -0
- package/dist/gc/quality-update.js +69 -0
- package/dist/gc/quality-update.js.map +1 -0
- package/dist/gc/scope-coverage.d.ts +20 -0
- package/dist/gc/scope-coverage.js +70 -0
- package/dist/gc/scope-coverage.js.map +1 -0
- package/dist/gc/stub-hits.d.ts +31 -0
- package/dist/gc/stub-hits.js +78 -0
- package/dist/gc/stub-hits.js.map +1 -0
- package/dist/gc/sweep.d.ts +56 -0
- package/dist/gc/sweep.js +205 -0
- package/dist/gc/sweep.js.map +1 -0
- package/dist/gc/types.d.ts +129 -0
- package/dist/gc/types.js +26 -0
- package/dist/gc/types.js.map +1 -0
- package/dist/gc/walk-source.d.ts +14 -0
- package/dist/gc/walk-source.js +59 -0
- package/dist/gc/walk-source.js.map +1 -0
- package/dist/ground/drift.d.ts +8 -0
- package/dist/ground/drift.js +23 -0
- package/dist/ground/drift.js.map +1 -0
- package/dist/ground/frontmatter.d.ts +20 -0
- package/dist/ground/frontmatter.js +49 -0
- package/dist/ground/frontmatter.js.map +1 -0
- package/dist/ground/glob.d.ts +10 -0
- package/dist/ground/glob.js +46 -0
- package/dist/ground/glob.js.map +1 -0
- package/dist/ground/index.d.ts +16 -0
- package/dist/ground/index.js +11 -0
- package/dist/ground/index.js.map +1 -0
- package/dist/ground/ledgers.d.ts +18 -0
- package/dist/ground/ledgers.js +103 -0
- package/dist/ground/ledgers.js.map +1 -0
- package/dist/ground/manifest.d.ts +10 -0
- package/dist/ground/manifest.js +88 -0
- package/dist/ground/manifest.js.map +1 -0
- package/dist/ground/paths.d.ts +20 -0
- package/dist/ground/paths.js +61 -0
- package/dist/ground/paths.js.map +1 -0
- package/dist/ground/quality-grades.d.ts +11 -0
- package/dist/ground/quality-grades.js +98 -0
- package/dist/ground/quality-grades.js.map +1 -0
- package/dist/ground/schemas.d.ts +306 -0
- package/dist/ground/schemas.js +188 -0
- package/dist/ground/schemas.js.map +1 -0
- package/dist/ground/scope-index.d.ts +48 -0
- package/dist/ground/scope-index.js +120 -0
- package/dist/ground/scope-index.js.map +1 -0
- package/dist/ground/walk.d.ts +7 -0
- package/dist/ground/walk.js +53 -0
- package/dist/ground/walk.js.map +1 -0
- package/dist/hooks/bypass-detection.d.ts +28 -0
- package/dist/hooks/bypass-detection.js +106 -0
- package/dist/hooks/bypass-detection.js.map +1 -0
- package/dist/hooks/index.d.ts +12 -0
- package/dist/hooks/index.js +13 -0
- package/dist/hooks/index.js.map +1 -0
- package/dist/hooks/post-tool-use/allowlist-reader.d.ts +14 -0
- package/dist/hooks/post-tool-use/allowlist-reader.js +69 -0
- package/dist/hooks/post-tool-use/allowlist-reader.js.map +1 -0
- package/dist/hooks/post-tool-use/citation-scanner.d.ts +23 -0
- package/dist/hooks/post-tool-use/citation-scanner.js +59 -0
- package/dist/hooks/post-tool-use/citation-scanner.js.map +1 -0
- package/dist/hooks/post-tool-use/copy-scanner.d.ts +25 -0
- package/dist/hooks/post-tool-use/copy-scanner.js +192 -0
- package/dist/hooks/post-tool-use/copy-scanner.js.map +1 -0
- package/dist/hooks/post-tool-use/index.d.ts +19 -0
- package/dist/hooks/post-tool-use/index.js +15 -0
- package/dist/hooks/post-tool-use/index.js.map +1 -0
- package/dist/hooks/post-tool-use/ledger-cache.d.ts +32 -0
- package/dist/hooks/post-tool-use/ledger-cache.js +236 -0
- package/dist/hooks/post-tool-use/ledger-cache.js.map +1 -0
- package/dist/hooks/post-tool-use/legend-builder.d.ts +15 -0
- package/dist/hooks/post-tool-use/legend-builder.js +84 -0
- package/dist/hooks/post-tool-use/legend-builder.js.map +1 -0
- package/dist/hooks/post-tool-use/read-enricher.d.ts +13 -0
- package/dist/hooks/post-tool-use/read-enricher.js +157 -0
- package/dist/hooks/post-tool-use/read-enricher.js.map +1 -0
- package/dist/hooks/post-tool-use/write-guardian.d.ts +17 -0
- package/dist/hooks/post-tool-use/write-guardian.js +176 -0
- package/dist/hooks/post-tool-use/write-guardian.js.map +1 -0
- package/dist/hooks/read-enrich.d.ts +6 -0
- package/dist/hooks/read-enrich.js +11 -0
- package/dist/hooks/read-enrich.js.map +1 -0
- package/dist/hooks/runners/index.d.ts +12 -0
- package/dist/hooks/runners/index.js +11 -0
- package/dist/hooks/runners/index.js.map +1 -0
- package/dist/hooks/runners/payload.d.ts +32 -0
- package/dist/hooks/runners/payload.js +70 -0
- package/dist/hooks/runners/payload.js.map +1 -0
- package/dist/hooks/runners/session-end.d.ts +7 -0
- package/dist/hooks/runners/session-end.js +42 -0
- package/dist/hooks/runners/session-end.js.map +1 -0
- package/dist/hooks/runners/session-start.d.ts +10 -0
- package/dist/hooks/runners/session-start.js +167 -0
- package/dist/hooks/runners/session-start.js.map +1 -0
- package/dist/hooks/runners/stop.d.ts +18 -0
- package/dist/hooks/runners/stop.js +165 -0
- package/dist/hooks/runners/stop.js.map +1 -0
- package/dist/hooks/session-end.d.ts +5 -0
- package/dist/hooks/session-end.js +10 -0
- package/dist/hooks/session-end.js.map +1 -0
- package/dist/hooks/session-start.d.ts +7 -0
- package/dist/hooks/session-start.js +12 -0
- package/dist/hooks/session-start.js.map +1 -0
- package/dist/hooks/stop.d.ts +5 -0
- package/dist/hooks/stop.js +10 -0
- package/dist/hooks/stop.js.map +1 -0
- package/dist/hooks/write-guard.d.ts +6 -0
- package/dist/hooks/write-guard.js +11 -0
- package/dist/hooks/write-guard.js.map +1 -0
- package/dist/inbox.d.ts +17 -0
- package/dist/inbox.js +30 -0
- package/dist/inbox.js.map +1 -0
- package/dist/index.d.ts +33 -0
- package/dist/index.js +32 -0
- package/dist/index.js.map +1 -0
- package/dist/init/baseline-audit.d.ts +71 -0
- package/dist/init/baseline-audit.js +377 -0
- package/dist/init/baseline-audit.js.map +1 -0
- package/dist/init/brand-setup.d.ts +44 -0
- package/dist/init/brand-setup.js +201 -0
- package/dist/init/brand-setup.js.map +1 -0
- package/dist/init/daemon-autostart.d.ts +16 -0
- package/dist/init/daemon-autostart.js +95 -0
- package/dist/init/daemon-autostart.js.map +1 -0
- package/dist/init/detect.d.ts +25 -0
- package/dist/init/detect.js +319 -0
- package/dist/init/detect.js.map +1 -0
- package/dist/init/index.d.ts +32 -0
- package/dist/init/index.js +18 -0
- package/dist/init/index.js.map +1 -0
- package/dist/init/ingest-docs.d.ts +74 -0
- package/dist/init/ingest-docs.js +499 -0
- package/dist/init/ingest-docs.js.map +1 -0
- package/dist/init/init.d.ts +165 -0
- package/dist/init/init.js +1166 -0
- package/dist/init/init.js.map +1 -0
- package/dist/init/mapper-legacy.d.ts +148 -0
- package/dist/init/mapper-legacy.js +238 -0
- package/dist/init/mapper-legacy.js.map +1 -0
- package/dist/init/mapper-merge.d.ts +38 -0
- package/dist/init/mapper-merge.js +238 -0
- package/dist/init/mapper-merge.js.map +1 -0
- package/dist/init/mapper-parallel.d.ts +48 -0
- package/dist/init/mapper-parallel.js +409 -0
- package/dist/init/mapper-parallel.js.map +1 -0
- package/dist/init/mapper-prompts.d.ts +135 -0
- package/dist/init/mapper-prompts.js +189 -0
- package/dist/init/mapper-prompts.js.map +1 -0
- package/dist/init/mapper.d.ts +211 -0
- package/dist/init/mapper.js +151 -0
- package/dist/init/mapper.js.map +1 -0
- package/dist/init/module-slicer.d.ts +39 -0
- package/dist/init/module-slicer.js +809 -0
- package/dist/init/module-slicer.js.map +1 -0
- package/dist/init/multi-dev/index.d.ts +2 -0
- package/dist/init/multi-dev/index.js +2 -0
- package/dist/init/multi-dev/index.js.map +1 -0
- package/dist/init/multi-dev/install.d.ts +40 -0
- package/dist/init/multi-dev/install.js +139 -0
- package/dist/init/multi-dev/install.js.map +1 -0
- package/dist/init/preflight-guards.d.ts +42 -0
- package/dist/init/preflight-guards.js +108 -0
- package/dist/init/preflight-guards.js.map +1 -0
- package/dist/init/prompts.d.ts +61 -0
- package/dist/init/prompts.js +66 -0
- package/dist/init/prompts.js.map +1 -0
- package/dist/init/rules-merge/discover.d.ts +21 -0
- package/dist/init/rules-merge/discover.js +78 -0
- package/dist/init/rules-merge/discover.js.map +1 -0
- package/dist/init/rules-merge/index.d.ts +10 -0
- package/dist/init/rules-merge/index.js +6 -0
- package/dist/init/rules-merge/index.js.map +1 -0
- package/dist/init/rules-merge/ingest.d.ts +56 -0
- package/dist/init/rules-merge/ingest.js +336 -0
- package/dist/init/rules-merge/ingest.js.map +1 -0
- package/dist/init/rules-merge/keep-markers.d.ts +39 -0
- package/dist/init/rules-merge/keep-markers.js +97 -0
- package/dist/init/rules-merge/keep-markers.js.map +1 -0
- package/dist/init/rules-merge/parse-sections.d.ts +24 -0
- package/dist/init/rules-merge/parse-sections.js +71 -0
- package/dist/init/rules-merge/parse-sections.js.map +1 -0
- package/dist/init/rules-merge/regenerate.d.ts +33 -0
- package/dist/init/rules-merge/regenerate.js +163 -0
- package/dist/init/rules-merge/regenerate.js.map +1 -0
- package/dist/init/secrets.d.ts +18 -0
- package/dist/init/secrets.js +76 -0
- package/dist/init/secrets.js.map +1 -0
- package/dist/init/seed.d.ts +21 -0
- package/dist/init/seed.js +96 -0
- package/dist/init/seed.js.map +1 -0
- package/dist/init/setup-runners.d.ts +15 -0
- package/dist/init/setup-runners.js +143 -0
- package/dist/init/setup-runners.js.map +1 -0
- package/dist/init/source-comments/classify.d.ts +98 -0
- package/dist/init/source-comments/classify.js +244 -0
- package/dist/init/source-comments/classify.js.map +1 -0
- package/dist/init/source-comments/index.d.ts +8 -0
- package/dist/init/source-comments/index.js +5 -0
- package/dist/init/source-comments/index.js.map +1 -0
- package/dist/init/source-comments/ingest.d.ts +51 -0
- package/dist/init/source-comments/ingest.js +236 -0
- package/dist/init/source-comments/ingest.js.map +1 -0
- package/dist/init/source-comments/strip-replace.d.ts +106 -0
- package/dist/init/source-comments/strip-replace.js +284 -0
- package/dist/init/source-comments/strip-replace.js.map +1 -0
- package/dist/init/source-comments/walker.d.ts +65 -0
- package/dist/init/source-comments/walker.js +777 -0
- package/dist/init/source-comments/walker.js.map +1 -0
- package/dist/init/submodules.d.ts +48 -0
- package/dist/init/submodules.js +149 -0
- package/dist/init/submodules.js.map +1 -0
- package/dist/init/types.d.ts +55 -0
- package/dist/init/types.js +10 -0
- package/dist/init/types.js.map +1 -0
- package/dist/init/visual.d.ts +69 -0
- package/dist/init/visual.js +265 -0
- package/dist/init/visual.js.map +1 -0
- package/dist/init/walker.d.ts +82 -0
- package/dist/init/walker.js +585 -0
- package/dist/init/walker.js.map +1 -0
- package/dist/init/workflow-block.d.ts +34 -0
- package/dist/init/workflow-block.js +110 -0
- package/dist/init/workflow-block.js.map +1 -0
- package/dist/join/index.d.ts +67 -0
- package/dist/join/index.js +256 -0
- package/dist/join/index.js.map +1 -0
- package/dist/lock.d.ts +39 -0
- package/dist/lock.js +129 -0
- package/dist/lock.js.map +1 -0
- package/dist/logger.d.ts +13 -0
- package/dist/logger.js +78 -0
- package/dist/logger.js.map +1 -0
- package/dist/mcp/bootstrap-guard.d.ts +29 -0
- package/dist/mcp/bootstrap-guard.js +47 -0
- package/dist/mcp/bootstrap-guard.js.map +1 -0
- package/dist/mcp/context.d.ts +23 -0
- package/dist/mcp/context.js +9 -0
- package/dist/mcp/context.js.map +1 -0
- package/dist/mcp/errors.d.ts +17 -0
- package/dist/mcp/errors.js +23 -0
- package/dist/mcp/errors.js.map +1 -0
- package/dist/mcp/history/index.d.ts +6 -0
- package/dist/mcp/history/index.js +5 -0
- package/dist/mcp/history/index.js.map +1 -0
- package/dist/mcp/history/prompt.d.ts +32 -0
- package/dist/mcp/history/prompt.js +99 -0
- package/dist/mcp/history/prompt.js.map +1 -0
- package/dist/mcp/history/schema.d.ts +58 -0
- package/dist/mcp/history/schema.js +41 -0
- package/dist/mcp/history/schema.js.map +1 -0
- package/dist/mcp/history/summarizer.d.ts +81 -0
- package/dist/mcp/history/summarizer.js +196 -0
- package/dist/mcp/history/summarizer.js.map +1 -0
- package/dist/mcp/history/walker.d.ts +57 -0
- package/dist/mcp/history/walker.js +156 -0
- package/dist/mcp/history/walker.js.map +1 -0
- package/dist/mcp/index.d.ts +13 -0
- package/dist/mcp/index.js +9 -0
- package/dist/mcp/index.js.map +1 -0
- package/dist/mcp/path-allowlist.d.ts +29 -0
- package/dist/mcp/path-allowlist.js +71 -0
- package/dist/mcp/path-allowlist.js.map +1 -0
- package/dist/mcp/result.d.ts +8 -0
- package/dist/mcp/result.js +18 -0
- package/dist/mcp/result.js.map +1 -0
- package/dist/mcp/schemas.d.ts +192 -0
- package/dist/mcp/schemas.js +174 -0
- package/dist/mcp/schemas.js.map +1 -0
- package/dist/mcp/serve.d.ts +15 -0
- package/dist/mcp/serve.js +71 -0
- package/dist/mcp/serve.js.map +1 -0
- package/dist/mcp/server.d.ts +11 -0
- package/dist/mcp/server.js +58 -0
- package/dist/mcp/server.js.map +1 -0
- package/dist/mcp/telemetry.d.ts +15 -0
- package/dist/mcp/telemetry.js +13 -0
- package/dist/mcp/telemetry.js.map +1 -0
- package/dist/mcp/tools/append-run-note.d.ts +18 -0
- package/dist/mcp/tools/append-run-note.js +47 -0
- package/dist/mcp/tools/append-run-note.js.map +1 -0
- package/dist/mcp/tools/append.d.ts +8 -0
- package/dist/mcp/tools/append.js +37 -0
- package/dist/mcp/tools/append.js.map +1 -0
- package/dist/mcp/tools/archive.d.ts +8 -0
- package/dist/mcp/tools/archive.js +72 -0
- package/dist/mcp/tools/archive.js.map +1 -0
- package/dist/mcp/tools/ask-operator.d.ts +34 -0
- package/dist/mcp/tools/ask-operator.js +97 -0
- package/dist/mcp/tools/ask-operator.js.map +1 -0
- package/dist/mcp/tools/canonical-for-topic.d.ts +6 -0
- package/dist/mcp/tools/canonical-for-topic.js +40 -0
- package/dist/mcp/tools/canonical-for-topic.js.map +1 -0
- package/dist/mcp/tools/decision-get.d.ts +6 -0
- package/dist/mcp/tools/decision-get.js +49 -0
- package/dist/mcp/tools/decision-get.js.map +1 -0
- package/dist/mcp/tools/decisions-for-symbol.d.ts +7 -0
- package/dist/mcp/tools/decisions-for-symbol.js +42 -0
- package/dist/mcp/tools/decisions-for-symbol.js.map +1 -0
- package/dist/mcp/tools/decisions-in-scope.d.ts +7 -0
- package/dist/mcp/tools/decisions-in-scope.js +47 -0
- package/dist/mcp/tools/decisions-in-scope.js.map +1 -0
- package/dist/mcp/tools/drop-task.d.ts +12 -0
- package/dist/mcp/tools/drop-task.js +68 -0
- package/dist/mcp/tools/drop-task.js.map +1 -0
- package/dist/mcp/tools/get-full.d.ts +7 -0
- package/dist/mcp/tools/get-full.js +46 -0
- package/dist/mcp/tools/get-full.js.map +1 -0
- package/dist/mcp/tools/ground-get.d.ts +7 -0
- package/dist/mcp/tools/ground-get.js +77 -0
- package/dist/mcp/tools/ground-get.js.map +1 -0
- package/dist/mcp/tools/index.d.ts +3 -0
- package/dist/mcp/tools/index.js +40 -0
- package/dist/mcp/tools/index.js.map +1 -0
- package/dist/mcp/tools/invariant-get.d.ts +6 -0
- package/dist/mcp/tools/invariant-get.js +49 -0
- package/dist/mcp/tools/invariant-get.js.map +1 -0
- package/dist/mcp/tools/invariants-in-scope.d.ts +7 -0
- package/dist/mcp/tools/invariants-in-scope.js +62 -0
- package/dist/mcp/tools/invariants-in-scope.js.map +1 -0
- package/dist/mcp/tools/query-history.d.ts +20 -0
- package/dist/mcp/tools/query-history.js +51 -0
- package/dist/mcp/tools/query-history.js.map +1 -0
- package/dist/mcp/tools/record-decision.d.ts +14 -0
- package/dist/mcp/tools/record-decision.js +98 -0
- package/dist/mcp/tools/record-decision.js.map +1 -0
- package/dist/mcp/tools/record-run-event.d.ts +10 -0
- package/dist/mcp/tools/record-run-event.js +32 -0
- package/dist/mcp/tools/record-run-event.js.map +1 -0
- package/dist/mcp/tools/resolve-attention.d.ts +31 -0
- package/dist/mcp/tools/resolve-attention.js +191 -0
- package/dist/mcp/tools/resolve-attention.js.map +1 -0
- package/dist/mcp/tools/search.d.ts +9 -0
- package/dist/mcp/tools/search.js +164 -0
- package/dist/mcp/tools/search.js.map +1 -0
- package/dist/mcp/tools/supersedes-chain.d.ts +6 -0
- package/dist/mcp/tools/supersedes-chain.js +66 -0
- package/dist/mcp/tools/supersedes-chain.js.map +1 -0
- package/dist/mcp/tools/timeline.d.ts +9 -0
- package/dist/mcp/tools/timeline.js +65 -0
- package/dist/mcp/tools/timeline.js.map +1 -0
- package/dist/mcp/tools/types.d.ts +9 -0
- package/dist/mcp/tools/types.js +2 -0
- package/dist/mcp/tools/types.js.map +1 -0
- package/dist/mirror/clone.d.ts +6 -0
- package/dist/mirror/clone.js +48 -0
- package/dist/mirror/clone.js.map +1 -0
- package/dist/mirror/dirty-overlap.d.ts +13 -0
- package/dist/mirror/dirty-overlap.js +42 -0
- package/dist/mirror/dirty-overlap.js.map +1 -0
- package/dist/mirror/index.d.ts +7 -0
- package/dist/mirror/index.js +7 -0
- package/dist/mirror/index.js.map +1 -0
- package/dist/mirror/paths.d.ts +18 -0
- package/dist/mirror/paths.js +45 -0
- package/dist/mirror/paths.js.map +1 -0
- package/dist/mirror/push.d.ts +9 -0
- package/dist/mirror/push.js +27 -0
- package/dist/mirror/push.js.map +1 -0
- package/dist/mirror/state.d.ts +4 -0
- package/dist/mirror/state.js +36 -0
- package/dist/mirror/state.js.map +1 -0
- package/dist/mirror/sync.d.ts +9 -0
- package/dist/mirror/sync.js +33 -0
- package/dist/mirror/sync.js.map +1 -0
- package/dist/mirror/types.d.ts +77 -0
- package/dist/mirror/types.js +2 -0
- package/dist/mirror/types.js.map +1 -0
- package/dist/paths/index.d.ts +23 -0
- package/dist/paths/index.js +50 -0
- package/dist/paths/index.js.map +1 -0
- package/dist/profiles/index.d.ts +3 -0
- package/dist/profiles/index.js +3 -0
- package/dist/profiles/index.js.map +1 -0
- package/dist/profiles/registry.d.ts +5 -0
- package/dist/profiles/registry.js +31 -0
- package/dist/profiles/registry.js.map +1 -0
- package/dist/profiles/types.d.ts +48 -0
- package/dist/profiles/types.js +11 -0
- package/dist/profiles/types.js.map +1 -0
- package/dist/profiles/unknown.d.ts +9 -0
- package/dist/profiles/unknown.js +17 -0
- package/dist/profiles/unknown.js.map +1 -0
- package/dist/prompt.d.ts +19 -0
- package/dist/prompt.js +50 -0
- package/dist/prompt.js.map +1 -0
- package/dist/sensors/attestation.d.ts +44 -0
- package/dist/sensors/attestation.js +262 -0
- package/dist/sensors/attestation.js.map +1 -0
- package/dist/sensors/catalog.d.ts +41 -0
- package/dist/sensors/catalog.js +123 -0
- package/dist/sensors/catalog.js.map +1 -0
- package/dist/sensors/decisions.d.ts +30 -0
- package/dist/sensors/decisions.js +393 -0
- package/dist/sensors/decisions.js.map +1 -0
- package/dist/sensors/diff.d.ts +27 -0
- package/dist/sensors/diff.js +148 -0
- package/dist/sensors/diff.js.map +1 -0
- package/dist/sensors/index.d.ts +13 -0
- package/dist/sensors/index.js +9 -0
- package/dist/sensors/index.js.map +1 -0
- package/dist/sensors/remediation.d.ts +20 -0
- package/dist/sensors/remediation.js +65 -0
- package/dist/sensors/remediation.js.map +1 -0
- package/dist/sensors/runner.d.ts +44 -0
- package/dist/sensors/runner.js +95 -0
- package/dist/sensors/runner.js.map +1 -0
- package/dist/sensors/structural.d.ts +30 -0
- package/dist/sensors/structural.js +204 -0
- package/dist/sensors/structural.js.map +1 -0
- package/dist/sensors/stub-catalog.d.ts +39 -0
- package/dist/sensors/stub-catalog.js +115 -0
- package/dist/sensors/stub-catalog.js.map +1 -0
- package/dist/sensors/types.d.ts +135 -0
- package/dist/sensors/types.js +14 -0
- package/dist/sensors/types.js.map +1 -0
- package/dist/session/events-marker.d.ts +39 -0
- package/dist/session/events-marker.js +74 -0
- package/dist/session/events-marker.js.map +1 -0
- package/dist/session/id.d.ts +83 -0
- package/dist/session/id.js +166 -0
- package/dist/session/id.js.map +1 -0
- package/dist/session/index.d.ts +14 -0
- package/dist/session/index.js +13 -0
- package/dist/session/index.js.map +1 -0
- package/dist/session-start/build.d.ts +53 -0
- package/dist/session-start/build.js +645 -0
- package/dist/session-start/build.js.map +1 -0
- package/dist/session-start/index.d.ts +18 -0
- package/dist/session-start/index.js +18 -0
- package/dist/session-start/index.js.map +1 -0
- package/dist/session-start/templates.d.ts +6 -0
- package/dist/session-start/templates.js +38 -0
- package/dist/session-start/templates.js.map +1 -0
- package/dist/status-line/format.d.ts +14 -0
- package/dist/status-line/format.js +40 -0
- package/dist/status-line/format.js.map +1 -0
- package/dist/status-line/index.d.ts +29 -0
- package/dist/status-line/index.js +14 -0
- package/dist/status-line/index.js.map +1 -0
- package/dist/status-line/reader.d.ts +13 -0
- package/dist/status-line/reader.js +76 -0
- package/dist/status-line/reader.js.map +1 -0
- package/dist/status-line/writer.d.ts +33 -0
- package/dist/status-line/writer.js +72 -0
- package/dist/status-line/writer.js.map +1 -0
- package/dist/tier0/classify.d.ts +10 -0
- package/dist/tier0/classify.js +110 -0
- package/dist/tier0/classify.js.map +1 -0
- package/dist/tier0/index.d.ts +2 -0
- package/dist/tier0/index.js +2 -0
- package/dist/tier0/index.js.map +1 -0
- package/dist/tier0/ollama.d.ts +22 -0
- package/dist/tier0/ollama.js +63 -0
- package/dist/tier0/ollama.js.map +1 -0
- package/dist/tier0/types.d.ts +24 -0
- package/dist/tier0/types.js +9 -0
- package/dist/tier0/types.js.map +1 -0
- package/dist/tightener/index.d.ts +4 -0
- package/dist/tightener/index.js +4 -0
- package/dist/tightener/index.js.map +1 -0
- package/dist/tightener/prompt.d.ts +3 -0
- package/dist/tightener/prompt.js +67 -0
- package/dist/tightener/prompt.js.map +1 -0
- package/dist/tightener/schema.d.ts +68 -0
- package/dist/tightener/schema.js +44 -0
- package/dist/tightener/schema.js.map +1 -0
- package/dist/tightener/tighten.d.ts +2 -0
- package/dist/tightener/tighten.js +66 -0
- package/dist/tightener/tighten.js.map +1 -0
- package/dist/tightener/types.d.ts +74 -0
- package/dist/tightener/types.js +6 -0
- package/dist/tightener/types.js.map +1 -0
- package/dist/voice/index.d.ts +4 -0
- package/dist/voice/index.js +4 -0
- package/dist/voice/index.js.map +1 -0
- package/dist/voice/model.d.ts +23 -0
- package/dist/voice/model.js +46 -0
- package/dist/voice/model.js.map +1 -0
- package/dist/voice/pipe.d.ts +9 -0
- package/dist/voice/pipe.js +47 -0
- package/dist/voice/pipe.js.map +1 -0
- package/dist/voice/transcribe.d.ts +3 -0
- package/dist/voice/transcribe.js +43 -0
- package/dist/voice/transcribe.js.map +1 -0
- package/dist/voice/types.d.ts +26 -0
- package/dist/voice/types.js +9 -0
- package/dist/voice/types.js.map +1 -0
- package/package.json +54 -0
- package/templates/.archive/README.md +67 -0
- package/templates/.cairn/JOIN.md +87 -0
- package/templates/.cairn/config/sensors.yaml +185 -0
- package/templates/.cairn/config/stub-patterns.yaml +231 -0
- package/templates/.cairn/config/trust-policy.yaml +95 -0
- package/templates/.cairn/config/workflow.md +230 -0
- package/templates/.cairn/git-hooks/commit-msg +17 -0
- package/templates/.cairn/git-hooks/post-commit +28 -0
- package/templates/.cairn/git-hooks/pre-commit +24 -0
- package/templates/.cairn/ground/brand/overview.md +24 -0
- package/templates/.cairn/ground/brand/voice.md +20 -0
- package/templates/.cairn/ground/canonical-map/topics.yaml +54 -0
- package/templates/.cairn/ground/capabilities/mcp-tools.yaml +4 -0
- package/templates/.cairn/ground/capabilities/skills.yaml +3 -0
- package/templates/.cairn/ground/capabilities/snippets.yaml +3 -0
- package/templates/.cairn/ground/manifest.yaml +16 -0
- package/templates/.cairn/ground/product/personas.yaml +4 -0
- package/templates/.cairn/ground/product/positioning.md +21 -0
- package/templates/.claude/settings.json +57 -0
- package/templates/.github/workflows/cairn-check.yml +31 -0
- package/templates/.mcp.json +8 -0
- package/templates/README.md +24 -0
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Phase 5b — interactive brand setup.
|
|
3
|
+
*
|
|
4
|
+
* After seedCairnLayout writes the templates with `status: draft`, ask the
|
|
5
|
+
* operator 4 quick questions and flip the answered files to `status: current`.
|
|
6
|
+
*
|
|
7
|
+
* Skipped questions stay draft. Ctrl+C / EOF anywhere mid-flow exits gracefully
|
|
8
|
+
* (whatever was answered before the abort sticks; the rest stay draft).
|
|
9
|
+
*
|
|
10
|
+
* Uses node:readline/promises — no new deps.
|
|
11
|
+
*/
|
|
12
|
+
import { existsSync, readFileSync, writeFileSync } from "node:fs";
|
|
13
|
+
import { join } from "node:path";
|
|
14
|
+
import { createInterface } from "node:readline/promises";
|
|
15
|
+
import { stdin, stdout } from "node:process";
|
|
16
|
+
const EMPTY = {
|
|
17
|
+
whatItDoes: "",
|
|
18
|
+
mainUsers: "",
|
|
19
|
+
voice: "",
|
|
20
|
+
avoid: "",
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Run the 4-question wizard. Returns whatever answers the operator provided
|
|
24
|
+
* (empty string for skipped questions). Always resolves; never throws on
|
|
25
|
+
* Ctrl+C / EOF — the partial answers up to the abort are returned.
|
|
26
|
+
*/
|
|
27
|
+
export async function runBrandSetup(opts) {
|
|
28
|
+
if (opts.skip === true) {
|
|
29
|
+
return { ...EMPTY, ...(opts.scriptedAnswers ?? {}) };
|
|
30
|
+
}
|
|
31
|
+
if (opts.scriptedAnswers !== undefined) {
|
|
32
|
+
return { ...EMPTY, ...opts.scriptedAnswers };
|
|
33
|
+
}
|
|
34
|
+
stdout.write("\n ✓ Files written.\n\n");
|
|
35
|
+
stdout.write(" Fill in your project brain — 4 quick questions.\n");
|
|
36
|
+
stdout.write(" Press Enter to skip any. Fill the rest later with: cairn configure\n\n");
|
|
37
|
+
const rl = createInterface({
|
|
38
|
+
input: stdin,
|
|
39
|
+
output: stdout,
|
|
40
|
+
terminal: stdin.isTTY === true,
|
|
41
|
+
});
|
|
42
|
+
// Ctrl+C inside readline emits SIGINT but rl.question() doesn't reject by
|
|
43
|
+
// default — install our own handler so the operator can abort cleanly.
|
|
44
|
+
rl.on("SIGINT", () => {
|
|
45
|
+
rl.close();
|
|
46
|
+
stdout.write(`\n ⚠ cancelled\n`);
|
|
47
|
+
process.exit(130);
|
|
48
|
+
});
|
|
49
|
+
const answers = { ...EMPTY };
|
|
50
|
+
try {
|
|
51
|
+
answers.whatItDoes = await ask(rl, ` What does ${opts.projectName} do? (one sentence)\n › `);
|
|
52
|
+
answers.mainUsers = await ask(rl, `\n Who are the main users?\n › `);
|
|
53
|
+
answers.voice = await ask(rl, `\n How should Claude communicate in this project? (tone, style)\n › `);
|
|
54
|
+
answers.avoid = await ask(rl, `\n Anything Claude should never do here?\n › `);
|
|
55
|
+
}
|
|
56
|
+
catch {
|
|
57
|
+
// EOF / Ctrl+C / readline closed — keep whatever we got, return.
|
|
58
|
+
}
|
|
59
|
+
finally {
|
|
60
|
+
rl.close();
|
|
61
|
+
}
|
|
62
|
+
return answers;
|
|
63
|
+
}
|
|
64
|
+
async function ask(rl, prompt) {
|
|
65
|
+
const reply = await rl.question(prompt);
|
|
66
|
+
return reply.trim();
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Apply answers to the seeded templates. Empty answers are no-ops; only
|
|
70
|
+
* answered files flip from `status: draft` to `status: current`.
|
|
71
|
+
*
|
|
72
|
+
* Returns the list of files that were actually rewritten.
|
|
73
|
+
*/
|
|
74
|
+
export function applyBrandAnswers(repoRoot, answers) {
|
|
75
|
+
const updated = [];
|
|
76
|
+
const warnings = [];
|
|
77
|
+
if (answers.whatItDoes.length > 0) {
|
|
78
|
+
const rel = ".cairn/ground/product/positioning.md";
|
|
79
|
+
const ok = rewriteWithBody(join(repoRoot, rel), answers.whatItDoes, warnings, rel);
|
|
80
|
+
if (ok)
|
|
81
|
+
updated.push(rel);
|
|
82
|
+
}
|
|
83
|
+
if (answers.mainUsers.length > 0) {
|
|
84
|
+
const rel = ".cairn/ground/product/personas.yaml";
|
|
85
|
+
const ok = rewritePersonas(join(repoRoot, rel), answers.mainUsers, warnings, rel);
|
|
86
|
+
if (ok)
|
|
87
|
+
updated.push(rel);
|
|
88
|
+
}
|
|
89
|
+
if (answers.voice.length > 0 || answers.avoid.length > 0) {
|
|
90
|
+
const rel = ".cairn/ground/brand/voice.md";
|
|
91
|
+
const ok = rewriteVoice(join(repoRoot, rel), answers.voice, answers.avoid, warnings, rel);
|
|
92
|
+
if (ok)
|
|
93
|
+
updated.push(rel);
|
|
94
|
+
}
|
|
95
|
+
return { updated, warnings };
|
|
96
|
+
}
|
|
97
|
+
function rewriteWithBody(abs, body, warnings, rel) {
|
|
98
|
+
if (!existsSync(abs)) {
|
|
99
|
+
warnings.push(`brand-setup: ${rel} missing — skipping`);
|
|
100
|
+
return false;
|
|
101
|
+
}
|
|
102
|
+
let text;
|
|
103
|
+
try {
|
|
104
|
+
text = readFileSync(abs, "utf8");
|
|
105
|
+
}
|
|
106
|
+
catch (err) {
|
|
107
|
+
warnings.push(`brand-setup: ${rel} unreadable: ${stringifyErr(err)}`);
|
|
108
|
+
return false;
|
|
109
|
+
}
|
|
110
|
+
const flipped = flipStatus(text);
|
|
111
|
+
const out = replaceBodyAfterFrontmatter(flipped, body);
|
|
112
|
+
try {
|
|
113
|
+
writeFileSync(abs, out, "utf8");
|
|
114
|
+
}
|
|
115
|
+
catch (err) {
|
|
116
|
+
warnings.push(`brand-setup: ${rel} write failed: ${stringifyErr(err)}`);
|
|
117
|
+
return false;
|
|
118
|
+
}
|
|
119
|
+
return true;
|
|
120
|
+
}
|
|
121
|
+
function rewritePersonas(abs, description, warnings, rel) {
|
|
122
|
+
if (!existsSync(abs)) {
|
|
123
|
+
warnings.push(`brand-setup: ${rel} missing — skipping`);
|
|
124
|
+
return false;
|
|
125
|
+
}
|
|
126
|
+
const next = `# Product personas — who this is for. Read at every SessionStart.\n` +
|
|
127
|
+
`# See DOCS_SPEC.md §3.4 for shape.\n` +
|
|
128
|
+
`status: current\n` +
|
|
129
|
+
`personas:\n` +
|
|
130
|
+
` - name: primary\n` +
|
|
131
|
+
` description: ${yamlSingleLine(description)}\n`;
|
|
132
|
+
try {
|
|
133
|
+
writeFileSync(abs, next, "utf8");
|
|
134
|
+
}
|
|
135
|
+
catch (err) {
|
|
136
|
+
warnings.push(`brand-setup: ${rel} write failed: ${stringifyErr(err)}`);
|
|
137
|
+
return false;
|
|
138
|
+
}
|
|
139
|
+
return true;
|
|
140
|
+
}
|
|
141
|
+
function rewriteVoice(abs, body, avoid, warnings, rel) {
|
|
142
|
+
if (!existsSync(abs)) {
|
|
143
|
+
warnings.push(`brand-setup: ${rel} missing — skipping`);
|
|
144
|
+
return false;
|
|
145
|
+
}
|
|
146
|
+
let text;
|
|
147
|
+
try {
|
|
148
|
+
text = readFileSync(abs, "utf8");
|
|
149
|
+
}
|
|
150
|
+
catch (err) {
|
|
151
|
+
warnings.push(`brand-setup: ${rel} unreadable: ${stringifyErr(err)}`);
|
|
152
|
+
return false;
|
|
153
|
+
}
|
|
154
|
+
const flipped = flipStatus(text);
|
|
155
|
+
const main = body.length > 0 ? body : "(operator did not specify a voice — fill in later)";
|
|
156
|
+
const avoidBlock = avoid.length > 0 ? `\n\n## Avoid\n\n${avoid}\n` : "";
|
|
157
|
+
const out = replaceBodyAfterFrontmatter(flipped, `${main}${avoidBlock}`);
|
|
158
|
+
try {
|
|
159
|
+
writeFileSync(abs, out, "utf8");
|
|
160
|
+
}
|
|
161
|
+
catch (err) {
|
|
162
|
+
warnings.push(`brand-setup: ${rel} write failed: ${stringifyErr(err)}`);
|
|
163
|
+
return false;
|
|
164
|
+
}
|
|
165
|
+
return true;
|
|
166
|
+
}
|
|
167
|
+
const FRONTMATTER_RE = /^---\n([\s\S]*?\n)---\n?/;
|
|
168
|
+
function flipStatus(text) {
|
|
169
|
+
const m = text.match(FRONTMATTER_RE);
|
|
170
|
+
if (!m)
|
|
171
|
+
return text;
|
|
172
|
+
const fm = m[1] ?? "";
|
|
173
|
+
const flipped = /^status:\s*draft\s*$/m.test(fm)
|
|
174
|
+
? fm.replace(/^status:\s*draft\s*$/m, "status: current")
|
|
175
|
+
: /^status:\s*/m.test(fm)
|
|
176
|
+
? fm
|
|
177
|
+
: `${fm}status: current\n`;
|
|
178
|
+
return text.replace(FRONTMATTER_RE, `---\n${flipped}---\n`);
|
|
179
|
+
}
|
|
180
|
+
function replaceBodyAfterFrontmatter(text, body) {
|
|
181
|
+
const m = text.match(FRONTMATTER_RE);
|
|
182
|
+
if (!m)
|
|
183
|
+
return `${text.trimEnd()}\n\n${body}\n`;
|
|
184
|
+
const fmBlock = m[0];
|
|
185
|
+
const rest = text.slice(fmBlock.length);
|
|
186
|
+
// Preserve the H1 line from the existing template, replace the rest.
|
|
187
|
+
const h1Match = rest.match(/^\n*(#\s+[^\n]+\n)/);
|
|
188
|
+
const headerLine = h1Match?.[1] ?? "# (untitled)\n";
|
|
189
|
+
return `${fmBlock}\n${headerLine}\n${body.trimEnd()}\n`;
|
|
190
|
+
}
|
|
191
|
+
function yamlSingleLine(s) {
|
|
192
|
+
// Quote when the value contains characters yaml would parse oddly.
|
|
193
|
+
if (/[:#&*!|>'"%@`?\-]/.test(s) || s.includes("\n")) {
|
|
194
|
+
return `"${s.replace(/"/g, '\\"')}"`;
|
|
195
|
+
}
|
|
196
|
+
return s;
|
|
197
|
+
}
|
|
198
|
+
function stringifyErr(err) {
|
|
199
|
+
return err instanceof Error ? err.message : String(err);
|
|
200
|
+
}
|
|
201
|
+
//# sourceMappingURL=brand-setup.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"brand-setup.js","sourceRoot":"","sources":["../../src/init/brand-setup.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,E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AAS,YAAY,CAAC,GAAY;IAChC,OAAO,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;AAC1D,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Phase 5c — daemon autostart attempt.
|
|
3
|
+
*
|
|
4
|
+
* Spawns `harness daemon start --detach` (best-effort) and waits up to 1.5s
|
|
5
|
+
* for the project's `status.json` to appear. Returns a summary the init
|
|
6
|
+
* Phase-6 output can render. Never throws — autostart is opportunistic.
|
|
7
|
+
*/
|
|
8
|
+
export interface DaemonAutostartResult {
|
|
9
|
+
/** True when status.json materialised within the wait window. */
|
|
10
|
+
started: boolean;
|
|
11
|
+
/** PID parsed out of status.json when present. */
|
|
12
|
+
pid: number | null;
|
|
13
|
+
/** Reason the autostart was abandoned. Null on success. */
|
|
14
|
+
reason: string | null;
|
|
15
|
+
}
|
|
16
|
+
export declare function tryStartDaemon(repoRoot: string): Promise<DaemonAutostartResult>;
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Phase 5c — daemon autostart attempt.
|
|
3
|
+
*
|
|
4
|
+
* Spawns `harness daemon start --detach` (best-effort) and waits up to 1.5s
|
|
5
|
+
* for the project's `status.json` to appear. Returns a summary the init
|
|
6
|
+
* Phase-6 output can render. Never throws — autostart is opportunistic.
|
|
7
|
+
*/
|
|
8
|
+
import { spawn } from "node:child_process";
|
|
9
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
10
|
+
import { basename, join } from "node:path";
|
|
11
|
+
import { normalizeProjectName, projectStatePath } from "../mirror/index.js";
|
|
12
|
+
const WAIT_MS = 1_500;
|
|
13
|
+
const POLL_INTERVAL_MS = 100;
|
|
14
|
+
export async function tryStartDaemon(repoRoot) {
|
|
15
|
+
const slug = normalizeProjectName(basename(repoRoot));
|
|
16
|
+
const stateDir = projectStatePath(slug);
|
|
17
|
+
const statusFile = join(stateDir, "status.json");
|
|
18
|
+
// Pre-existing status.json + a recent updated_at means the daemon is already
|
|
19
|
+
// running. No need to spawn a duplicate.
|
|
20
|
+
if (existsSync(statusFile)) {
|
|
21
|
+
const pid = readPidFromState(stateDir, statusFile);
|
|
22
|
+
return { started: true, pid, reason: null };
|
|
23
|
+
}
|
|
24
|
+
let spawnFailed = null;
|
|
25
|
+
try {
|
|
26
|
+
const child = spawn("harness", ["daemon", "start", "--detach"], {
|
|
27
|
+
detached: true,
|
|
28
|
+
stdio: "ignore",
|
|
29
|
+
cwd: repoRoot,
|
|
30
|
+
});
|
|
31
|
+
child.on("error", (err) => {
|
|
32
|
+
spawnFailed = err instanceof Error ? err.message : String(err);
|
|
33
|
+
});
|
|
34
|
+
child.unref();
|
|
35
|
+
}
|
|
36
|
+
catch (err) {
|
|
37
|
+
spawnFailed = err instanceof Error ? err.message : String(err);
|
|
38
|
+
}
|
|
39
|
+
if (spawnFailed !== null) {
|
|
40
|
+
return {
|
|
41
|
+
started: false,
|
|
42
|
+
pid: null,
|
|
43
|
+
reason: `harness binary not on PATH (${spawnFailed})`,
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
const deadline = Date.now() + WAIT_MS;
|
|
47
|
+
while (Date.now() < deadline) {
|
|
48
|
+
if (spawnFailed !== null) {
|
|
49
|
+
return { started: false, pid: null, reason: spawnFailed };
|
|
50
|
+
}
|
|
51
|
+
if (existsSync(statusFile)) {
|
|
52
|
+
const pid = readPidFromState(stateDir, statusFile);
|
|
53
|
+
return { started: true, pid, reason: null };
|
|
54
|
+
}
|
|
55
|
+
await sleep(POLL_INTERVAL_MS);
|
|
56
|
+
}
|
|
57
|
+
if (spawnFailed !== null) {
|
|
58
|
+
return { started: false, pid: null, reason: spawnFailed };
|
|
59
|
+
}
|
|
60
|
+
return {
|
|
61
|
+
started: false,
|
|
62
|
+
pid: null,
|
|
63
|
+
reason: "status.json did not appear within 1.5s",
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
function readPidFromState(stateDir, statusFile) {
|
|
67
|
+
// Per STATUS_LINE_SPEC §3 the daemon's PID file is `daemon.pid` next to status.json.
|
|
68
|
+
const pidFile = join(stateDir, "daemon.pid");
|
|
69
|
+
if (existsSync(pidFile)) {
|
|
70
|
+
try {
|
|
71
|
+
const txt = readFileSync(pidFile, "utf8").trim();
|
|
72
|
+
const n = Number.parseInt(txt, 10);
|
|
73
|
+
if (Number.isFinite(n) && n > 0)
|
|
74
|
+
return n;
|
|
75
|
+
}
|
|
76
|
+
catch {
|
|
77
|
+
// fall through
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
// Some implementations carry pid directly in status.json under "pid".
|
|
81
|
+
try {
|
|
82
|
+
const parsed = JSON.parse(readFileSync(statusFile, "utf8"));
|
|
83
|
+
const pid = parsed["pid"];
|
|
84
|
+
if (typeof pid === "number" && Number.isFinite(pid) && pid > 0)
|
|
85
|
+
return pid;
|
|
86
|
+
}
|
|
87
|
+
catch {
|
|
88
|
+
// ignore
|
|
89
|
+
}
|
|
90
|
+
return null;
|
|
91
|
+
}
|
|
92
|
+
function sleep(ms) {
|
|
93
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
94
|
+
}
|
|
95
|
+
//# sourceMappingURL=daemon-autostart.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"daemon-autostart.js","sourceRoot":"","sources":["../../src/init/daemon-autostart.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAW5E,MAAM,OAAO,GAAG,KAAK,CAAC;AACtB,MAAM,g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AAC,QAAQ,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;YACnC,IAAI,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC;gBAAE,OAAO,CAAC,CAAC;QAC5C,CAAC;QAAC,MAAM,CAAC;YACP,eAAe;QACjB,CAAC;IACH,CAAC;IACD,sEAAsE;IACtE,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,UAAU,EAAE,MAAM,CAAC,CAGzD,CAAC;QACF,MAAM,GAAG,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;QAC1B,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,GAAG,GAAG,CAAC;YAAE,OAAO,GAAG,CAAC;IAC7E,CAAC;IAAC,MAAM,CAAC;QACP,SAAS;IACX,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,SAAS,KAAK,CAAC,EAAU;IACvB,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;AAC3D,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Profile-free stack detection for `cairn init`.
|
|
3
|
+
*
|
|
4
|
+
* Each detection function returns plain data; the wizard composes them.
|
|
5
|
+
* No prompts, no side effects, no stdout writes. Detection is mechanical:
|
|
6
|
+
* read filesystem signatures, return arrays of findings.
|
|
7
|
+
*/
|
|
8
|
+
import type { DetectionResult, HookCapability, SensorProposal, StackSignature, StartCommand } from "./types.js";
|
|
9
|
+
export declare function detectProjectSlug(args: {
|
|
10
|
+
repoRoot: string;
|
|
11
|
+
originUrl: string | null;
|
|
12
|
+
}): string;
|
|
13
|
+
export declare function detectOriginUrl(repoRoot: string): Promise<string | null>;
|
|
14
|
+
export declare function detectStackSignatures(repoRoot: string): StackSignature[];
|
|
15
|
+
export declare function detectAvailableSensors(args: {
|
|
16
|
+
repoRoot: string;
|
|
17
|
+
signatures: StackSignature[];
|
|
18
|
+
}): SensorProposal[];
|
|
19
|
+
export declare function detectStartCommand(args: {
|
|
20
|
+
repoRoot: string;
|
|
21
|
+
signatures: StackSignature[];
|
|
22
|
+
}): StartCommand | null;
|
|
23
|
+
export declare function detectHookCapability(repoRoot: string): HookCapability;
|
|
24
|
+
export declare function detectEnvironment(): Promise<DetectionResult["environment"]>;
|
|
25
|
+
export declare function detectAll(repoRoot: string): Promise<DetectionResult>;
|
|
@@ -0,0 +1,319 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Profile-free stack detection for `cairn init`.
|
|
3
|
+
*
|
|
4
|
+
* Each detection function returns plain data; the wizard composes them.
|
|
5
|
+
* No prompts, no side effects, no stdout writes. Detection is mechanical:
|
|
6
|
+
* read filesystem signatures, return arrays of findings.
|
|
7
|
+
*/
|
|
8
|
+
import { existsSync, readFileSync, statSync } from "node:fs";
|
|
9
|
+
import { basename, join } from "node:path";
|
|
10
|
+
import { simpleGit } from "simple-git";
|
|
11
|
+
import { claudeIsAvailable } from "../claude/index.js";
|
|
12
|
+
import { normalizeProjectName } from "../paths/index.js";
|
|
13
|
+
export function detectProjectSlug(args) {
|
|
14
|
+
const pkgPath = join(args.repoRoot, "package.json");
|
|
15
|
+
if (existsSync(pkgPath)) {
|
|
16
|
+
try {
|
|
17
|
+
const pkg = JSON.parse(readFileSync(pkgPath, "utf8"));
|
|
18
|
+
if (typeof pkg.name === "string" && pkg.name.length > 0) {
|
|
19
|
+
return normalizeProjectName(pkg.name);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
catch {
|
|
23
|
+
// fall through
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
if (args.originUrl !== null) {
|
|
27
|
+
const match = args.originUrl.match(/[/:]([^/]+?)(?:\.git)?$/);
|
|
28
|
+
if (match?.[1])
|
|
29
|
+
return normalizeProjectName(match[1]);
|
|
30
|
+
}
|
|
31
|
+
return normalizeProjectName(basename(args.repoRoot));
|
|
32
|
+
}
|
|
33
|
+
export async function detectOriginUrl(repoRoot) {
|
|
34
|
+
if (!existsSync(join(repoRoot, ".git")))
|
|
35
|
+
return null;
|
|
36
|
+
try {
|
|
37
|
+
const remotes = await simpleGit(repoRoot).getRemotes(true);
|
|
38
|
+
const origin = remotes.find((r) => r.name === "origin");
|
|
39
|
+
return origin?.refs?.fetch ?? null;
|
|
40
|
+
}
|
|
41
|
+
catch {
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
export function detectStackSignatures(repoRoot) {
|
|
46
|
+
const signatures = [];
|
|
47
|
+
const flag = (kind, marker) => {
|
|
48
|
+
if (existsSync(join(repoRoot, marker))) {
|
|
49
|
+
signatures.push({ kind, marker });
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
flag("typescript", "package.json");
|
|
53
|
+
flag("python", "pyproject.toml");
|
|
54
|
+
if (signatures.find((s) => s.kind === "python") === undefined) {
|
|
55
|
+
flag("python", "requirements.txt");
|
|
56
|
+
}
|
|
57
|
+
flag("ruby", "Gemfile");
|
|
58
|
+
flag("go", "go.mod");
|
|
59
|
+
flag("rust", "Cargo.toml");
|
|
60
|
+
flag("elixir", "mix.exs");
|
|
61
|
+
if (signatures.length === 0) {
|
|
62
|
+
signatures.push({ kind: "unknown", marker: repoRoot });
|
|
63
|
+
}
|
|
64
|
+
return signatures;
|
|
65
|
+
}
|
|
66
|
+
export function detectAvailableSensors(args) {
|
|
67
|
+
const sensors = [];
|
|
68
|
+
const has = (path) => existsSync(join(args.repoRoot, path));
|
|
69
|
+
const hasAny = (paths) => paths.some(has);
|
|
70
|
+
// ── typescript ───────────────────────────────────────────
|
|
71
|
+
if (args.signatures.some((s) => s.kind === "typescript")) {
|
|
72
|
+
if (has("tsconfig.json") || has("tsconfig.base.json")) {
|
|
73
|
+
sensors.push({
|
|
74
|
+
id: "tsc",
|
|
75
|
+
command: "pnpm",
|
|
76
|
+
args: ["-w", "exec", "tsc", "-b", "--noEmit"],
|
|
77
|
+
applies_to: ["typescript"],
|
|
78
|
+
reason: "tsconfig.json present",
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
if (hasAny([
|
|
82
|
+
".eslintrc",
|
|
83
|
+
".eslintrc.js",
|
|
84
|
+
".eslintrc.json",
|
|
85
|
+
".eslintrc.cjs",
|
|
86
|
+
"eslint.config.js",
|
|
87
|
+
"eslint.config.mjs",
|
|
88
|
+
])) {
|
|
89
|
+
sensors.push({
|
|
90
|
+
id: "eslint",
|
|
91
|
+
command: "pnpm",
|
|
92
|
+
args: ["-w", "exec", "eslint", "."],
|
|
93
|
+
applies_to: ["typescript"],
|
|
94
|
+
reason: "eslint config present",
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
// ── python ───────────────────────────────────────────────
|
|
99
|
+
if (args.signatures.some((s) => s.kind === "python")) {
|
|
100
|
+
const pyToml = readFileIfExists(join(args.repoRoot, "pyproject.toml"));
|
|
101
|
+
if (has("ruff.toml") || (pyToml && /\[tool\.ruff\]/.test(pyToml))) {
|
|
102
|
+
sensors.push({
|
|
103
|
+
id: "ruff",
|
|
104
|
+
command: "ruff",
|
|
105
|
+
args: ["check", "."],
|
|
106
|
+
applies_to: ["python"],
|
|
107
|
+
reason: "ruff config present",
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
if (has("mypy.ini") || (pyToml && /\[tool\.mypy\]/.test(pyToml))) {
|
|
111
|
+
sensors.push({
|
|
112
|
+
id: "mypy",
|
|
113
|
+
command: "mypy",
|
|
114
|
+
args: ["."],
|
|
115
|
+
applies_to: ["python"],
|
|
116
|
+
reason: "mypy config present",
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
// ── ruby ─────────────────────────────────────────────────
|
|
121
|
+
if (args.signatures.some((s) => s.kind === "ruby")) {
|
|
122
|
+
const gemfile = readFileIfExists(join(args.repoRoot, "Gemfile"));
|
|
123
|
+
if (has(".rubocop.yml") || (gemfile && /\brubocop\b/.test(gemfile))) {
|
|
124
|
+
sensors.push({
|
|
125
|
+
id: "rubocop",
|
|
126
|
+
command: "bundle",
|
|
127
|
+
args: ["exec", "rubocop"],
|
|
128
|
+
applies_to: ["ruby"],
|
|
129
|
+
reason: "rubocop config / dep present",
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
if (gemfile && /\brails\b/.test(gemfile)) {
|
|
133
|
+
sensors.push({
|
|
134
|
+
id: "brakeman",
|
|
135
|
+
command: "bundle",
|
|
136
|
+
args: ["exec", "brakeman", "--no-pager"],
|
|
137
|
+
applies_to: ["ruby"],
|
|
138
|
+
reason: "rails app detected",
|
|
139
|
+
needs_install: true,
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
// ── go ───────────────────────────────────────────────────
|
|
144
|
+
if (args.signatures.some((s) => s.kind === "go")) {
|
|
145
|
+
sensors.push({
|
|
146
|
+
id: "go-vet",
|
|
147
|
+
command: "go",
|
|
148
|
+
args: ["vet", "./..."],
|
|
149
|
+
applies_to: ["go"],
|
|
150
|
+
reason: "go.mod present",
|
|
151
|
+
});
|
|
152
|
+
sensors.push({
|
|
153
|
+
id: "gofmt",
|
|
154
|
+
command: "gofmt",
|
|
155
|
+
args: ["-l", "."],
|
|
156
|
+
applies_to: ["go"],
|
|
157
|
+
reason: "go.mod present",
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
// ── rust ─────────────────────────────────────────────────
|
|
161
|
+
if (args.signatures.some((s) => s.kind === "rust")) {
|
|
162
|
+
sensors.push({
|
|
163
|
+
id: "cargo-check",
|
|
164
|
+
command: "cargo",
|
|
165
|
+
args: ["check"],
|
|
166
|
+
applies_to: ["rust"],
|
|
167
|
+
reason: "Cargo.toml present",
|
|
168
|
+
});
|
|
169
|
+
sensors.push({
|
|
170
|
+
id: "cargo-clippy",
|
|
171
|
+
command: "cargo",
|
|
172
|
+
args: ["clippy", "--", "-D", "warnings"],
|
|
173
|
+
applies_to: ["rust"],
|
|
174
|
+
reason: "Cargo.toml present",
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
// ── elixir ───────────────────────────────────────────────
|
|
178
|
+
if (args.signatures.some((s) => s.kind === "elixir")) {
|
|
179
|
+
sensors.push({
|
|
180
|
+
id: "mix-compile-warnings",
|
|
181
|
+
command: "mix",
|
|
182
|
+
args: ["compile", "--warnings-as-errors"],
|
|
183
|
+
applies_to: ["elixir"],
|
|
184
|
+
reason: "mix.exs present",
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
return sensors;
|
|
188
|
+
}
|
|
189
|
+
export function detectStartCommand(args) {
|
|
190
|
+
// typescript: prefer package.json scripts.dev > scripts.start
|
|
191
|
+
if (args.signatures.some((s) => s.kind === "typescript")) {
|
|
192
|
+
const pkgPath = join(args.repoRoot, "package.json");
|
|
193
|
+
if (existsSync(pkgPath)) {
|
|
194
|
+
try {
|
|
195
|
+
const pkg = JSON.parse(readFileSync(pkgPath, "utf8"));
|
|
196
|
+
const script = pkg.scripts?.["dev"] ?? pkg.scripts?.["start"];
|
|
197
|
+
const scriptName = pkg.scripts?.["dev"] !== undefined ? "dev" : "start";
|
|
198
|
+
if (script !== undefined) {
|
|
199
|
+
return {
|
|
200
|
+
command: "pnpm",
|
|
201
|
+
args: ["run", scriptName],
|
|
202
|
+
reason: `package.json scripts.${scriptName}: \`${script}\``,
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
catch {
|
|
207
|
+
// fall through
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
// python: manage.py runserver; FastAPI uvicorn from Procfile/dev.sh
|
|
212
|
+
if (args.signatures.some((s) => s.kind === "python")) {
|
|
213
|
+
if (existsSync(join(args.repoRoot, "manage.py"))) {
|
|
214
|
+
return {
|
|
215
|
+
command: "python",
|
|
216
|
+
args: ["manage.py", "runserver"],
|
|
217
|
+
reason: "Django manage.py detected",
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
const procfile = readFileIfExists(join(args.repoRoot, "Procfile"));
|
|
221
|
+
if (procfile) {
|
|
222
|
+
const webLine = procfile.split(/\r?\n/).find((l) => /^web:/i.test(l));
|
|
223
|
+
if (webLine) {
|
|
224
|
+
const cmdRaw = webLine.replace(/^web:\s*/i, "").trim();
|
|
225
|
+
const parts = cmdRaw.split(/\s+/);
|
|
226
|
+
if (parts.length > 0 && parts[0] !== undefined) {
|
|
227
|
+
return {
|
|
228
|
+
command: parts[0],
|
|
229
|
+
args: parts.slice(1),
|
|
230
|
+
reason: `Procfile web: ${cmdRaw}`,
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
// ruby: bin/rails server
|
|
237
|
+
if (args.signatures.some((s) => s.kind === "ruby")) {
|
|
238
|
+
if (existsSync(join(args.repoRoot, "bin", "rails"))) {
|
|
239
|
+
return {
|
|
240
|
+
command: "bin/rails",
|
|
241
|
+
args: ["server"],
|
|
242
|
+
reason: "bin/rails detected",
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
// go: best-guess `go run ./...`
|
|
247
|
+
if (args.signatures.some((s) => s.kind === "go")) {
|
|
248
|
+
return {
|
|
249
|
+
command: "go",
|
|
250
|
+
args: ["run", "./..."],
|
|
251
|
+
reason: "go.mod present",
|
|
252
|
+
};
|
|
253
|
+
}
|
|
254
|
+
// rust: cargo run
|
|
255
|
+
if (args.signatures.some((s) => s.kind === "rust")) {
|
|
256
|
+
return {
|
|
257
|
+
command: "cargo",
|
|
258
|
+
args: ["run"],
|
|
259
|
+
reason: "Cargo.toml present",
|
|
260
|
+
};
|
|
261
|
+
}
|
|
262
|
+
return null;
|
|
263
|
+
}
|
|
264
|
+
export function detectHookCapability(repoRoot) {
|
|
265
|
+
const claudeDir = join(repoRoot, ".claude");
|
|
266
|
+
if (existsSync(claudeDir) && isDirectory(claudeDir))
|
|
267
|
+
return "claude-code";
|
|
268
|
+
if (existsSync(join(repoRoot, ".git")))
|
|
269
|
+
return "git-hooks";
|
|
270
|
+
return "cli-only";
|
|
271
|
+
}
|
|
272
|
+
export async function detectEnvironment() {
|
|
273
|
+
return {
|
|
274
|
+
claude_auth: claudeIsAvailable(),
|
|
275
|
+
};
|
|
276
|
+
}
|
|
277
|
+
export async function detectAll(repoRoot) {
|
|
278
|
+
const originUrl = await detectOriginUrl(repoRoot);
|
|
279
|
+
const project_slug = detectProjectSlug({ repoRoot, originUrl });
|
|
280
|
+
const stack_signatures = detectStackSignatures(repoRoot);
|
|
281
|
+
const proposed_sensors = detectAvailableSensors({
|
|
282
|
+
repoRoot,
|
|
283
|
+
signatures: stack_signatures,
|
|
284
|
+
});
|
|
285
|
+
const start_command = detectStartCommand({
|
|
286
|
+
repoRoot,
|
|
287
|
+
signatures: stack_signatures,
|
|
288
|
+
});
|
|
289
|
+
const hook_capability = detectHookCapability(repoRoot);
|
|
290
|
+
const environment = await detectEnvironment();
|
|
291
|
+
return {
|
|
292
|
+
repo_root: repoRoot,
|
|
293
|
+
project_slug,
|
|
294
|
+
origin_url: originUrl,
|
|
295
|
+
stack_signatures,
|
|
296
|
+
proposed_sensors,
|
|
297
|
+
start_command,
|
|
298
|
+
hook_capability,
|
|
299
|
+
environment,
|
|
300
|
+
};
|
|
301
|
+
}
|
|
302
|
+
/* ───────────────────────── helpers ───────────────────────── */
|
|
303
|
+
function readFileIfExists(path) {
|
|
304
|
+
try {
|
|
305
|
+
return readFileSync(path, "utf8");
|
|
306
|
+
}
|
|
307
|
+
catch {
|
|
308
|
+
return null;
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
function isDirectory(path) {
|
|
312
|
+
try {
|
|
313
|
+
return statSync(path).isDirectory();
|
|
314
|
+
}
|
|
315
|
+
catch {
|
|
316
|
+
return false;
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
//# sourceMappingURL=detect.js.map
|