@smeltjs/core 0.2.0 → 0.4.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/README.md +3 -3
- package/dist/agents/guide.d.ts +68 -0
- package/dist/agents/guide.d.ts.map +1 -0
- package/dist/agents/guide.js +72 -0
- package/dist/agents/guide.js.map +1 -0
- package/dist/agents/instructions.d.ts +133 -0
- package/dist/agents/instructions.d.ts.map +1 -0
- package/dist/agents/instructions.js +212 -0
- package/dist/agents/instructions.js.map +1 -0
- package/dist/agents/lint.d.ts +154 -0
- package/dist/agents/lint.d.ts.map +1 -0
- package/dist/agents/lint.js +761 -0
- package/dist/agents/lint.js.map +1 -0
- package/dist/agents/split.d.ts +113 -0
- package/dist/agents/split.d.ts.map +1 -0
- package/dist/agents/split.js +234 -0
- package/dist/agents/split.js.map +1 -0
- package/dist/apply.d.ts.map +1 -1
- package/dist/apply.js.map +1 -1
- package/dist/cache/prefix.d.ts.map +1 -1
- package/dist/cache/prefix.js.map +1 -1
- package/dist/cli/agents.d.ts +39 -0
- package/dist/cli/agents.d.ts.map +1 -0
- package/dist/cli/agents.js +121 -0
- package/dist/cli/agents.js.map +1 -0
- package/dist/cli/args.d.ts +17 -70
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +18 -338
- package/dist/cli/args.js.map +1 -1
- package/dist/cli/bin.d.ts.map +1 -1
- package/dist/cli/bin.js.map +1 -1
- package/dist/cli/config.d.ts +60 -0
- package/dist/cli/config.d.ts.map +1 -1
- package/dist/cli/config.js +89 -2
- package/dist/cli/config.js.map +1 -1
- package/dist/cli/hooks.d.ts +55 -51
- package/dist/cli/hooks.d.ts.map +1 -1
- package/dist/cli/hooks.js +206 -658
- package/dist/cli/hooks.js.map +1 -1
- package/dist/cli/init.d.ts +30 -15
- package/dist/cli/init.d.ts.map +1 -1
- package/dist/cli/init.js +167 -38
- package/dist/cli/init.js.map +1 -1
- package/dist/cli/report.d.ts +23 -0
- package/dist/cli/report.d.ts.map +1 -1
- package/dist/cli/report.js +142 -4
- package/dist/cli/report.js.map +1 -1
- package/dist/cli/run.d.ts +29 -90
- package/dist/cli/run.d.ts.map +1 -1
- package/dist/cli/run.js +34 -342
- package/dist/cli/run.js.map +1 -1
- package/dist/cli/shell.d.ts +106 -0
- package/dist/cli/shell.d.ts.map +1 -0
- package/dist/cli/shell.js +100 -0
- package/dist/cli/shell.js.map +1 -0
- package/dist/cli/subcommands/agents.d.ts +72 -0
- package/dist/cli/subcommands/agents.d.ts.map +1 -0
- package/dist/cli/subcommands/agents.js +162 -0
- package/dist/cli/subcommands/agents.js.map +1 -0
- package/dist/cli/subcommands/flags.d.ts +144 -0
- package/dist/cli/subcommands/flags.d.ts.map +1 -0
- package/dist/cli/subcommands/flags.js +220 -0
- package/dist/cli/subcommands/flags.js.map +1 -0
- package/dist/cli/subcommands/hooks.d.ts +18 -0
- package/dist/cli/subcommands/hooks.d.ts.map +1 -0
- package/dist/cli/subcommands/hooks.js +80 -0
- package/dist/cli/subcommands/hooks.js.map +1 -0
- package/dist/cli/subcommands/init.d.ts +19 -0
- package/dist/cli/subcommands/init.d.ts.map +1 -0
- package/dist/cli/subcommands/init.js +44 -0
- package/dist/cli/subcommands/init.js.map +1 -0
- package/dist/cli/subcommands/map.d.ts +75 -0
- package/dist/cli/subcommands/map.d.ts.map +1 -0
- package/dist/cli/subcommands/map.js +132 -0
- package/dist/cli/subcommands/map.js.map +1 -0
- package/dist/cli/subcommands/registry.d.ts +81 -0
- package/dist/cli/subcommands/registry.d.ts.map +1 -0
- package/dist/cli/subcommands/registry.js +141 -0
- package/dist/cli/subcommands/registry.js.map +1 -0
- package/dist/cli/subcommands/retrieve.d.ts +74 -0
- package/dist/cli/subcommands/retrieve.d.ts.map +1 -0
- package/dist/cli/subcommands/retrieve.js +84 -0
- package/dist/cli/subcommands/retrieve.js.map +1 -0
- package/dist/cli/subcommands/smelt.d.ts +107 -0
- package/dist/cli/subcommands/smelt.d.ts.map +1 -0
- package/dist/cli/subcommands/smelt.js +304 -0
- package/dist/cli/subcommands/smelt.js.map +1 -0
- package/dist/cli/subcommands/stats.d.ts +43 -0
- package/dist/cli/subcommands/stats.d.ts.map +1 -0
- package/dist/cli/subcommands/stats.js +62 -0
- package/dist/cli/subcommands/stats.js.map +1 -0
- package/dist/cli/subcommands/subcommand.d.ts +113 -0
- package/dist/cli/subcommands/subcommand.d.ts.map +1 -0
- package/dist/cli/subcommands/subcommand.js +3 -0
- package/dist/cli/subcommands/subcommand.js.map +1 -0
- package/dist/cli/usage.d.ts +3 -0
- package/dist/cli/usage.d.ts.map +1 -0
- package/dist/cli/usage.js +95 -0
- package/dist/cli/usage.js.map +1 -0
- package/dist/detect.d.ts.map +1 -1
- package/dist/detect.js.map +1 -1
- package/dist/errors.d.ts +21 -1
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +33 -1
- package/dist/errors.js.map +1 -1
- package/dist/harness/aider.d.ts +10 -0
- package/dist/harness/aider.d.ts.map +1 -0
- package/dist/harness/aider.js +21 -0
- package/dist/harness/aider.js.map +1 -0
- package/dist/harness/claude-code.d.ts +3 -0
- package/dist/harness/claude-code.d.ts.map +1 -0
- package/dist/harness/claude-code.js +68 -0
- package/dist/harness/claude-code.js.map +1 -0
- package/dist/harness/cline.d.ts +3 -0
- package/dist/harness/cline.d.ts.map +1 -0
- package/dist/harness/cline.js +54 -0
- package/dist/harness/cline.js.map +1 -0
- package/dist/harness/codex.d.ts +3 -0
- package/dist/harness/codex.d.ts.map +1 -0
- package/dist/harness/codex.js +92 -0
- package/dist/harness/codex.js.map +1 -0
- package/dist/harness/cursor.d.ts +3 -0
- package/dist/harness/cursor.d.ts.map +1 -0
- package/dist/harness/cursor.js +54 -0
- package/dist/harness/cursor.js.map +1 -0
- package/dist/harness/gemini.d.ts +3 -0
- package/dist/harness/gemini.d.ts.map +1 -0
- package/dist/harness/gemini.js +60 -0
- package/dist/harness/gemini.js.map +1 -0
- package/dist/harness/grok.d.ts +3 -0
- package/dist/harness/grok.d.ts.map +1 -0
- package/dist/harness/grok.js +47 -0
- package/dist/harness/grok.js.map +1 -0
- package/dist/harness/hermes.d.ts +3 -0
- package/dist/harness/hermes.d.ts.map +1 -0
- package/dist/harness/hermes.js +72 -0
- package/dist/harness/hermes.js.map +1 -0
- package/dist/harness/kilocode.d.ts +3 -0
- package/dist/harness/kilocode.d.ts.map +1 -0
- package/dist/harness/kilocode.js +35 -0
- package/dist/harness/kilocode.js.map +1 -0
- package/dist/harness/opencode.d.ts +3 -0
- package/dist/harness/opencode.d.ts.map +1 -0
- package/dist/harness/opencode.js +97 -0
- package/dist/harness/opencode.js.map +1 -0
- package/dist/harness/paths.d.ts +17 -0
- package/dist/harness/paths.d.ts.map +1 -0
- package/dist/harness/paths.js +45 -0
- package/dist/harness/paths.js.map +1 -0
- package/dist/harness/profile.d.ts +209 -0
- package/dist/harness/profile.d.ts.map +1 -0
- package/dist/harness/profile.js +41 -0
- package/dist/harness/profile.js.map +1 -0
- package/dist/harness/registry.d.ts +100 -0
- package/dist/harness/registry.d.ts.map +1 -0
- package/dist/harness/registry.js +144 -0
- package/dist/harness/registry.js.map +1 -0
- package/dist/harness/snippet.d.ts +19 -0
- package/dist/harness/snippet.d.ts.map +1 -0
- package/dist/harness/snippet.js +41 -0
- package/dist/harness/snippet.js.map +1 -0
- package/dist/hash.d.ts.map +1 -1
- package/dist/hash.js.map +1 -1
- package/dist/hooks/guard-core.d.ts +14 -14
- package/dist/hooks/guard-core.d.ts.map +1 -1
- package/dist/hooks/guard-core.js +15 -37
- package/dist/hooks/guard-core.js.map +1 -1
- package/dist/hooks/shim.d.ts +95 -4
- package/dist/hooks/shim.d.ts.map +1 -1
- package/dist/hooks/shim.js +87 -2
- package/dist/hooks/shim.js.map +1 -1
- package/dist/hooks/shims/claude-code.d.ts +5 -18
- package/dist/hooks/shims/claude-code.d.ts.map +1 -1
- package/dist/hooks/shims/claude-code.js +9 -56
- package/dist/hooks/shims/claude-code.js.map +1 -1
- package/dist/hooks/shims/cline.d.ts +5 -12
- package/dist/hooks/shims/cline.d.ts.map +1 -1
- package/dist/hooks/shims/cline.js +9 -34
- package/dist/hooks/shims/cline.js.map +1 -1
- package/dist/hooks/shims/codex.d.ts +5 -18
- package/dist/hooks/shims/codex.d.ts.map +1 -1
- package/dist/hooks/shims/codex.js +9 -51
- package/dist/hooks/shims/codex.js.map +1 -1
- package/dist/hooks/shims/cursor.d.ts +5 -14
- package/dist/hooks/shims/cursor.d.ts.map +1 -1
- package/dist/hooks/shims/cursor.js +9 -42
- package/dist/hooks/shims/cursor.js.map +1 -1
- package/dist/hooks/shims/gemini.d.ts +5 -18
- package/dist/hooks/shims/gemini.d.ts.map +1 -1
- package/dist/hooks/shims/gemini.js +9 -48
- package/dist/hooks/shims/gemini.js.map +1 -1
- package/dist/hooks/shims/grok.d.ts +5 -13
- package/dist/hooks/shims/grok.d.ts.map +1 -1
- package/dist/hooks/shims/grok.js +9 -32
- package/dist/hooks/shims/grok.js.map +1 -1
- package/dist/hooks/shims/hermes.d.ts +5 -17
- package/dist/hooks/shims/hermes.d.ts.map +1 -1
- package/dist/hooks/shims/hermes.js +9 -45
- package/dist/hooks/shims/hermes.js.map +1 -1
- package/dist/index.d.ts +43 -76
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +21 -67
- package/dist/index.js.map +1 -1
- package/dist/lang/bash.d.ts.map +1 -1
- package/dist/lang/bash.js.map +1 -1
- package/dist/lang/c.d.ts.map +1 -1
- package/dist/lang/c.js.map +1 -1
- package/dist/lang/c_sharp.d.ts.map +1 -1
- package/dist/lang/c_sharp.js.map +1 -1
- package/dist/lang/cpp.d.ts.map +1 -1
- package/dist/lang/cpp.js.map +1 -1
- package/dist/lang/go.d.ts.map +1 -1
- package/dist/lang/go.js.map +1 -1
- package/dist/lang/java.d.ts.map +1 -1
- package/dist/lang/java.js.map +1 -1
- package/dist/lang/javascript.d.ts.map +1 -1
- package/dist/lang/javascript.js.map +1 -1
- package/dist/lang/kotlin.d.ts.map +1 -1
- package/dist/lang/kotlin.js.map +1 -1
- package/dist/lang/php.d.ts.map +1 -1
- package/dist/lang/php.js.map +1 -1
- package/dist/lang/profile.d.ts.map +1 -1
- package/dist/lang/profile.js.map +1 -1
- package/dist/lang/python.d.ts.map +1 -1
- package/dist/lang/python.js.map +1 -1
- package/dist/lang/registry.d.ts.map +1 -1
- package/dist/lang/registry.js.map +1 -1
- package/dist/lang/ruby.d.ts.map +1 -1
- package/dist/lang/ruby.js.map +1 -1
- package/dist/lang/rust.d.ts.map +1 -1
- package/dist/lang/rust.js.map +1 -1
- package/dist/lang/swift.d.ts.map +1 -1
- package/dist/lang/swift.js.map +1 -1
- package/dist/lang/tsx.d.ts.map +1 -1
- package/dist/lang/tsx.js.map +1 -1
- package/dist/lang/typescript.d.ts.map +1 -1
- package/dist/lang/typescript.js.map +1 -1
- package/dist/net/policy.d.ts +18 -1
- package/dist/net/policy.d.ts.map +1 -1
- package/dist/net/policy.js +6 -4
- package/dist/net/policy.js.map +1 -1
- package/dist/ops/index.d.ts +39 -0
- package/dist/ops/index.d.ts.map +1 -0
- package/dist/ops/index.js +37 -0
- package/dist/ops/index.js.map +1 -0
- package/dist/ops/inputs.d.ts +170 -0
- package/dist/ops/inputs.d.ts.map +1 -0
- package/dist/ops/inputs.js +142 -0
- package/dist/ops/inputs.js.map +1 -0
- package/dist/ops/verbs.d.ts +136 -0
- package/dist/ops/verbs.d.ts.map +1 -0
- package/dist/ops/verbs.js +76 -0
- package/dist/ops/verbs.js.map +1 -0
- package/dist/plan/auto.d.ts +69 -0
- package/dist/plan/auto.d.ts.map +1 -0
- package/dist/plan/auto.js +70 -0
- package/dist/plan/auto.js.map +1 -0
- package/dist/plan/budget.d.ts +21 -0
- package/dist/plan/budget.d.ts.map +1 -0
- package/dist/plan/budget.js +26 -0
- package/dist/plan/budget.js.map +1 -0
- package/dist/plan/grammar.d.ts +14 -0
- package/dist/plan/grammar.d.ts.map +1 -1
- package/dist/plan/grammar.js +47 -6
- package/dist/plan/grammar.js.map +1 -1
- package/dist/plan/lexical.d.ts.map +1 -1
- package/dist/plan/lexical.js +1 -7
- package/dist/plan/lexical.js.map +1 -1
- package/dist/plan/planners.d.ts +35 -2
- package/dist/plan/planners.d.ts.map +1 -1
- package/dist/plan/planners.js +35 -2
- package/dist/plan/planners.js.map +1 -1
- package/dist/plan/structural.d.ts +19 -5
- package/dist/plan/structural.d.ts.map +1 -1
- package/dist/plan/structural.js +180 -33
- package/dist/plan/structural.js.map +1 -1
- package/dist/repomap/cache.d.ts +48 -0
- package/dist/repomap/cache.d.ts.map +1 -1
- package/dist/repomap/cache.js +112 -13
- package/dist/repomap/cache.js.map +1 -1
- package/dist/repomap/io.d.ts +24 -0
- package/dist/repomap/io.d.ts.map +1 -0
- package/dist/repomap/io.js +34 -0
- package/dist/repomap/io.js.map +1 -0
- package/dist/repomap/map.d.ts +69 -6
- package/dist/repomap/map.d.ts.map +1 -1
- package/dist/repomap/map.js +104 -22
- package/dist/repomap/map.js.map +1 -1
- package/dist/repomap/rank.d.ts +26 -2
- package/dist/repomap/rank.d.ts.map +1 -1
- package/dist/repomap/rank.js +20 -0
- package/dist/repomap/rank.js.map +1 -1
- package/dist/repomap/reader.d.ts +73 -0
- package/dist/repomap/reader.d.ts.map +1 -0
- package/dist/repomap/reader.js +30 -0
- package/dist/repomap/reader.js.map +1 -0
- package/dist/repomap/tags.d.ts.map +1 -1
- package/dist/repomap/tags.js.map +1 -1
- package/dist/retrieve.d.ts +8 -0
- package/dist/retrieve.d.ts.map +1 -1
- package/dist/retrieve.js +12 -1
- package/dist/retrieve.js.map +1 -1
- package/dist/smelter.d.ts +79 -0
- package/dist/smelter.d.ts.map +1 -0
- package/dist/smelter.js +65 -0
- package/dist/smelter.js.map +1 -0
- package/dist/stages.d.ts.map +1 -1
- package/dist/stages.js +2 -2
- package/dist/stages.js.map +1 -1
- package/dist/stats.d.ts +2 -1
- package/dist/stats.d.ts.map +1 -1
- package/dist/stats.js +2 -1
- package/dist/stats.js.map +1 -1
- package/dist/store-dir.d.ts +43 -4
- package/dist/store-dir.d.ts.map +1 -1
- package/dist/store-dir.js +48 -5
- package/dist/store-dir.js.map +1 -1
- package/dist/store.d.ts +6 -0
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +6 -0
- package/dist/store.js.map +1 -1
- package/dist/text/json-edit.d.ts +71 -0
- package/dist/text/json-edit.d.ts.map +1 -0
- package/dist/text/json-edit.js +219 -0
- package/dist/text/json-edit.js.map +1 -0
- package/dist/types.d.ts +35 -14
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/grammars/tree-sitter-bash.wasm +0 -0
- package/grammars/tree-sitter-c.wasm +0 -0
- package/grammars/tree-sitter-c_sharp.wasm +0 -0
- package/grammars/tree-sitter-cpp.wasm +0 -0
- package/grammars/tree-sitter-go.wasm +0 -0
- package/grammars/tree-sitter-java.wasm +0 -0
- package/grammars/tree-sitter-javascript.wasm +0 -0
- package/grammars/tree-sitter-kotlin.wasm +0 -0
- package/grammars/tree-sitter-php.wasm +0 -0
- package/grammars/tree-sitter-python.wasm +0 -0
- package/grammars/tree-sitter-ruby.wasm +0 -0
- package/grammars/tree-sitter-rust.wasm +0 -0
- package/grammars/tree-sitter-swift.wasm +0 -0
- package/grammars/tree-sitter-tsx.wasm +0 -0
- package/grammars/tree-sitter-typescript.wasm +0 -0
- package/package.json +11 -11
- package/dist/cli/resolve.d.ts +0 -103
- package/dist/cli/resolve.d.ts.map +0 -1
- package/dist/cli/resolve.js +0 -106
- package/dist/cli/resolve.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"python.d.ts","sourceRoot":"","sources":["../../src/lang/python.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAEpD,eAAO,MAAM,MAAM,EAAE,eA+BpB,CAAC"}
|
|
1
|
+
{"version":3,"file":"python.d.ts","sourceRoot":"","sources":["../../src/lang/python.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAEpD,eAAO,MAAM,MAAM,EAAE,eA+BpB,CAAC","sourcesContent":["import type { LanguageProfile } from './profile.ts';\n\nexport const python: LanguageProfile = {\n id: 'python',\n extensions: ['py', 'pyi'],\n wasm: 'tree-sitter-python.wasm',\n markerLeader: '# ',\n structure: {\n // Docstrings are not comments — they live inside the definition's body, so a kept\n // definition keeps its docstring because units are kept whole. `#` comments above\n // a definition attach the same way `/** … */` does in TypeScript.\n commentTypes: new Set(['comment']),\n attributeTypes: new Set(),\n // `#!/usr/bin/env python3` parses as a plain comment node, but it decides which\n // interpreter runs the file — pinned the way the bash and ruby shebangs are.\n pinnedCommentPattern: /^#!/,\n wrapperTypes: { decorated_definition: 'declaration' },\n kindLabels: {\n function_definition: 'function',\n class_definition: 'class',\n import_statement: 'import statement',\n import_from_statement: 'import statement',\n future_import_statement: 'import statement',\n expression_statement: 'statement',\n },\n },\n repomap: {\n defKinds: {\n function_definition: 'function',\n class_definition: 'class',\n },\n refTypes: ['identifier'],\n },\n};\n"]}
|
package/dist/lang/python.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"python.js","sourceRoot":"","sources":["../../src/lang/python.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,MAAM,GAAoB;IACrC,EAAE,EAAE,QAAQ;IACZ,UAAU,EAAE,CAAC,IAAI,EAAE,KAAK,CAAC;IACzB,IAAI,EAAE,yBAAyB;IAC/B,YAAY,EAAE,IAAI;IAClB,SAAS,EAAE;QACT,kFAAkF;QAClF,kFAAkF;QAClF,kEAAkE;QAClE,YAAY,EAAE,IAAI,GAAG,CAAC,CAAC,SAAS,CAAC,CAAC;QAClC,cAAc,EAAE,IAAI,GAAG,EAAE;QACzB,gFAAgF;QAChF,6EAA6E;QAC7E,oBAAoB,EAAE,KAAK;QAC3B,YAAY,EAAE,EAAE,oBAAoB,EAAE,aAAa,EAAE;QACrD,UAAU,EAAE;YACV,mBAAmB,EAAE,UAAU;YAC/B,gBAAgB,EAAE,OAAO;YACzB,gBAAgB,EAAE,kBAAkB;YACpC,qBAAqB,EAAE,kBAAkB;YACzC,uBAAuB,EAAE,kBAAkB;YAC3C,oBAAoB,EAAE,WAAW;SAClC;KACF;IACD,OAAO,EAAE;QACP,QAAQ,EAAE;YACR,mBAAmB,EAAE,UAAU;YAC/B,gBAAgB,EAAE,OAAO;SAC1B;QACD,QAAQ,EAAE,CAAC,YAAY,CAAC;KACzB;CACF,CAAC"}
|
|
1
|
+
{"version":3,"file":"python.js","sourceRoot":"","sources":["../../src/lang/python.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,MAAM,GAAoB;IACrC,EAAE,EAAE,QAAQ;IACZ,UAAU,EAAE,CAAC,IAAI,EAAE,KAAK,CAAC;IACzB,IAAI,EAAE,yBAAyB;IAC/B,YAAY,EAAE,IAAI;IAClB,SAAS,EAAE;QACT,kFAAkF;QAClF,kFAAkF;QAClF,kEAAkE;QAClE,YAAY,EAAE,IAAI,GAAG,CAAC,CAAC,SAAS,CAAC,CAAC;QAClC,cAAc,EAAE,IAAI,GAAG,EAAE;QACzB,gFAAgF;QAChF,6EAA6E;QAC7E,oBAAoB,EAAE,KAAK;QAC3B,YAAY,EAAE,EAAE,oBAAoB,EAAE,aAAa,EAAE;QACrD,UAAU,EAAE;YACV,mBAAmB,EAAE,UAAU;YAC/B,gBAAgB,EAAE,OAAO;YACzB,gBAAgB,EAAE,kBAAkB;YACpC,qBAAqB,EAAE,kBAAkB;YACzC,uBAAuB,EAAE,kBAAkB;YAC3C,oBAAoB,EAAE,WAAW;SAClC;KACF;IACD,OAAO,EAAE;QACP,QAAQ,EAAE;YACR,mBAAmB,EAAE,UAAU;YAC/B,gBAAgB,EAAE,OAAO;SAC1B;QACD,QAAQ,EAAE,CAAC,YAAY,CAAC;KACzB;CACF,CAAC","sourcesContent":["import type { LanguageProfile } from './profile.ts';\n\nexport const python: LanguageProfile = {\n id: 'python',\n extensions: ['py', 'pyi'],\n wasm: 'tree-sitter-python.wasm',\n markerLeader: '# ',\n structure: {\n // Docstrings are not comments — they live inside the definition's body, so a kept\n // definition keeps its docstring because units are kept whole. `#` comments above\n // a definition attach the same way `/** … */` does in TypeScript.\n commentTypes: new Set(['comment']),\n attributeTypes: new Set(),\n // `#!/usr/bin/env python3` parses as a plain comment node, but it decides which\n // interpreter runs the file — pinned the way the bash and ruby shebangs are.\n pinnedCommentPattern: /^#!/,\n wrapperTypes: { decorated_definition: 'declaration' },\n kindLabels: {\n function_definition: 'function',\n class_definition: 'class',\n import_statement: 'import statement',\n import_from_statement: 'import statement',\n future_import_statement: 'import statement',\n expression_statement: 'statement',\n },\n },\n repomap: {\n defKinds: {\n function_definition: 'function',\n class_definition: 'class',\n },\n refTypes: ['identifier'],\n },\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/lang/registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAiBpD;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,iBAAiB,EAAE,QAAQ,CAAC,MAAM,CAAC,UAAU,EAAE,eAAe,CAAC,CAgB3E,CAAC;AAEF,oFAAoF;AACpF,wBAAgB,UAAU,CAAC,EAAE,EAAE,UAAU,GAAG,eAAe,CAE1D;AAoBD;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,eAAe,GAAG,SAAS,CAMpF;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,IAAI,SAAS,UAAU,EAAE,CAI3D"}
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/lang/registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAiBpD;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,iBAAiB,EAAE,QAAQ,CAAC,MAAM,CAAC,UAAU,EAAE,eAAe,CAAC,CAgB3E,CAAC;AAEF,oFAAoF;AACpF,wBAAgB,UAAU,CAAC,EAAE,EAAE,UAAU,GAAG,eAAe,CAE1D;AAoBD;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,eAAe,GAAG,SAAS,CAMpF;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,IAAI,SAAS,UAAU,EAAE,CAI3D","sourcesContent":["import type { LanguageId } from '../types.ts';\n\nimport type { LanguageProfile } from './profile.ts';\nimport { bash } from './bash.ts';\nimport { c } from './c.ts';\nimport { c_sharp } from './c_sharp.ts';\nimport { cpp } from './cpp.ts';\nimport { go } from './go.ts';\nimport { java } from './java.ts';\nimport { javascript } from './javascript.ts';\nimport { kotlin } from './kotlin.ts';\nimport { php } from './php.ts';\nimport { python } from './python.ts';\nimport { ruby } from './ruby.ts';\nimport { rust } from './rust.ts';\nimport { swift } from './swift.ts';\nimport { tsx } from './tsx.ts';\nimport { typescript } from './typescript.ts';\n\n/**\n * The registry — every language smelt knows, one {@link LanguageProfile} each.\n *\n * `Record<LanguageId, LanguageProfile>` on purpose: adding a `LanguageId` in\n * `types.ts` without writing its profile is a compile error, so the id list and the\n * facts cannot drift. Every derived view — `SUPPORTED_LANGUAGES`,\n * `WASM_BY_LANGUAGE`, `STRUCTURAL_LANGUAGES`, the extension map, the marker leaders,\n * the repo-map tag tables — is computed from this object, never written twice.\n *\n * Key order is meaningful: it is the order every rendered language list uses (the\n * `--language`/`--strategy` help, the init wizard, error messages), so keep it stable\n * and append new languages at the end.\n */\nexport const LANGUAGE_PROFILES: Readonly<Record<LanguageId, LanguageProfile>> = {\n typescript,\n tsx,\n javascript,\n rust,\n python,\n go,\n java,\n c,\n cpp,\n c_sharp,\n ruby,\n php,\n kotlin,\n swift,\n bash,\n};\n\n/** The profile for a language id. Total by construction — see the registry type. */\nexport function profileFor(id: LanguageId): LanguageProfile {\n return LANGUAGE_PROFILES[id];\n}\n\n/** Extension → profile, derived once. A duplicate claim would be a registry bug. */\nconst BY_EXTENSION: ReadonlyMap<string, LanguageProfile> = (() => {\n const index = new Map<string, LanguageProfile>();\n for (const profile of Object.values(LANGUAGE_PROFILES)) {\n for (const extension of profile.extensions) {\n const holder = index.get(extension);\n if (holder !== undefined) {\n throw new Error(\n `smelt: extension \".${extension}\" is claimed by both \"${holder.id}\" and ` +\n `\"${profile.id}\" — a path would detect as whichever loaded last.`,\n );\n }\n index.set(extension, profile);\n }\n }\n return index;\n})();\n\n/**\n * The profile a path's extension selects, or `undefined` for anything unmapped.\n * Deliberately not a content sniffer: guessing from bytes gets things wrong silently,\n * and `undefined` costs nothing here — `detectLanguage` turns it into `'unknown'`,\n * which selects the lexical planner, and that works on anything.\n */\nexport function profileForPath(path: string | undefined): LanguageProfile | undefined {\n if (path === undefined) return undefined;\n const base = path.replace(/\\\\/g, '/').split('/').pop() ?? '';\n const dot = base.lastIndexOf('.');\n if (dot <= 0) return undefined;\n return BY_EXTENSION.get(base.slice(dot + 1).toLowerCase());\n}\n\n/**\n * The languages the structural planner claims: exactly the profiles that carry a\n * `structure` section. In registry order, so every rendered list agrees.\n */\nexport function structuralLanguages(): readonly LanguageId[] {\n return Object.values(LANGUAGE_PROFILES)\n .filter((profile) => profile.structure !== undefined)\n .map((profile) => profile.id);\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../src/lang/registry.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAC;AAC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C,CAAC","sourcesContent":["import type { LanguageId } from '../types.ts';\n\nimport type { LanguageProfile } from './profile.ts';\nimport { bash } from './bash.ts';\nimport { c } from './c.ts';\nimport { c_sharp } from './c_sharp.ts';\nimport { cpp } from './cpp.ts';\nimport { go } from './go.ts';\nimport { java } from './java.ts';\nimport { javascript } from './javascript.ts';\nimport { kotlin } from './kotlin.ts';\nimport { php } from './php.ts';\nimport { python } from './python.ts';\nimport { ruby } from './ruby.ts';\nimport { rust } from './rust.ts';\nimport { swift } from './swift.ts';\nimport { tsx } from './tsx.ts';\nimport { typescript } from './typescript.ts';\n\n/**\n * The registry — every language smelt knows, one {@link LanguageProfile} each.\n *\n * `Record<LanguageId, LanguageProfile>` on purpose: adding a `LanguageId` in\n * `types.ts` without writing its profile is a compile error, so the id list and the\n * facts cannot drift. Every derived view — `SUPPORTED_LANGUAGES`,\n * `WASM_BY_LANGUAGE`, `STRUCTURAL_LANGUAGES`, the extension map, the marker leaders,\n * the repo-map tag tables — is computed from this object, never written twice.\n *\n * Key order is meaningful: it is the order every rendered language list uses (the\n * `--language`/`--strategy` help, the init wizard, error messages), so keep it stable\n * and append new languages at the end.\n */\nexport const LANGUAGE_PROFILES: Readonly<Record<LanguageId, LanguageProfile>> = {\n typescript,\n tsx,\n javascript,\n rust,\n python,\n go,\n java,\n c,\n cpp,\n c_sharp,\n ruby,\n php,\n kotlin,\n swift,\n bash,\n};\n\n/** The profile for a language id. Total by construction — see the registry type. */\nexport function profileFor(id: LanguageId): LanguageProfile {\n return LANGUAGE_PROFILES[id];\n}\n\n/** Extension → profile, derived once. A duplicate claim would be a registry bug. */\nconst BY_EXTENSION: ReadonlyMap<string, LanguageProfile> = (() => {\n const index = new Map<string, LanguageProfile>();\n for (const profile of Object.values(LANGUAGE_PROFILES)) {\n for (const extension of profile.extensions) {\n const holder = index.get(extension);\n if (holder !== undefined) {\n throw new Error(\n `smelt: extension \".${extension}\" is claimed by both \"${holder.id}\" and ` +\n `\"${profile.id}\" — a path would detect as whichever loaded last.`,\n );\n }\n index.set(extension, profile);\n }\n }\n return index;\n})();\n\n/**\n * The profile a path's extension selects, or `undefined` for anything unmapped.\n * Deliberately not a content sniffer: guessing from bytes gets things wrong silently,\n * and `undefined` costs nothing here — `detectLanguage` turns it into `'unknown'`,\n * which selects the lexical planner, and that works on anything.\n */\nexport function profileForPath(path: string | undefined): LanguageProfile | undefined {\n if (path === undefined) return undefined;\n const base = path.replace(/\\\\/g, '/').split('/').pop() ?? '';\n const dot = base.lastIndexOf('.');\n if (dot <= 0) return undefined;\n return BY_EXTENSION.get(base.slice(dot + 1).toLowerCase());\n}\n\n/**\n * The languages the structural planner claims: exactly the profiles that carry a\n * `structure` section. In registry order, so every rendered list agrees.\n */\nexport function structuralLanguages(): readonly LanguageId[] {\n return Object.values(LANGUAGE_PROFILES)\n .filter((profile) => profile.structure !== undefined)\n .map((profile) => profile.id);\n}\n"]}
|
package/dist/lang/ruby.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ruby.d.ts","sourceRoot":"","sources":["../../src/lang/ruby.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAEpD,eAAO,MAAM,IAAI,EAAE,eA6ClB,CAAC"}
|
|
1
|
+
{"version":3,"file":"ruby.d.ts","sourceRoot":"","sources":["../../src/lang/ruby.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAEpD,eAAO,MAAM,IAAI,EAAE,eA6ClB,CAAC","sourcesContent":["import type { LanguageProfile } from './profile.ts';\n\nexport const ruby: LanguageProfile = {\n id: 'ruby',\n extensions: ['rb'],\n wasm: 'tree-sitter-ruby.wasm',\n markerLeader: '# ',\n structure: {\n commentTypes: new Set(['comment']),\n attributeTypes: new Set(),\n // The shebang and the `# frozen_string_literal:` magic comment both govern how\n // the whole file executes; neither may collapse into a run.\n pinnedCommentPattern: /^#(?:!|\\s*frozen_string_literal:)/,\n // A heredoc's body is a top-level sibling of the statement holding its opener —\n // it extends that statement's unit, or a collapse could keep the opener and cut\n // the body, leaving an unterminated heredoc that swallows every declaration\n // after it (and tree-sitter-ruby reports no ERROR for it at EOF).\n ridesBackwardTypes: new Set(['heredoc_body']),\n wrapperTypes: {},\n kindLabels: {\n method: 'method',\n singleton_method: 'method',\n class: 'class',\n module: 'module',\n // Top-level `require \"json\"` and `CONSTANT = 1` are expression nodes in\n // tree-sitter-ruby; \"statement\" is the honest generic word for both — and for\n // top-level control-flow blocks, which are expressions here too.\n call: 'statement',\n assignment: 'statement',\n if: 'statement',\n unless: 'statement',\n case: 'statement',\n while: 'statement',\n until: 'statement',\n for: 'statement',\n begin: 'statement',\n heredoc_body: 'heredoc body',\n comment: 'comment',\n },\n },\n repomap: {\n defKinds: {\n method: 'method',\n singleton_method: 'method',\n },\n refTypes: ['identifier', 'constant'],\n },\n};\n"]}
|
package/dist/lang/ruby.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ruby.js","sourceRoot":"","sources":["../../src/lang/ruby.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,IAAI,GAAoB;IACnC,EAAE,EAAE,MAAM;IACV,UAAU,EAAE,CAAC,IAAI,CAAC;IAClB,IAAI,EAAE,uBAAuB;IAC7B,YAAY,EAAE,IAAI;IAClB,SAAS,EAAE;QACT,YAAY,EAAE,IAAI,GAAG,CAAC,CAAC,SAAS,CAAC,CAAC;QAClC,cAAc,EAAE,IAAI,GAAG,EAAE;QACzB,+EAA+E;QAC/E,4DAA4D;QAC5D,oBAAoB,EAAE,mCAAmC;QACzD,gFAAgF;QAChF,gFAAgF;QAChF,4EAA4E;QAC5E,kEAAkE;QAClE,kBAAkB,EAAE,IAAI,GAAG,CAAC,CAAC,cAAc,CAAC,CAAC;QAC7C,YAAY,EAAE,EAAE;QAChB,UAAU,EAAE;YACV,MAAM,EAAE,QAAQ;YAChB,gBA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E,8EAA8E;YAC9E,iEAAiE;YACjE,IAAI,EAAE,WAAW;YACjB,UAAU,EAAE,WAAW;YACvB,EAAE,EAAE,WAAW;YACf,MAAM,EAAE,WAAW;YACnB,IAAI,EAAE,WAAW;YACjB,KAAK,EAAE,WAAW;YAClB,KAAK,EAAE,WAAW;YAClB,GAAG,EAAE,WAAW;YAChB,KAAK,EAAE,WAAW;YAClB,YAAY,EAAE,cAAc;YAC5B,OAAO,EAAE,SAAS;SACnB;KACF;IACD,OAAO,EAAE;QACP,QAAQ,EAAE;YACR,MAAM,EAAE,QAAQ;YAChB,gBAAgB,EAAE,QAAQ;SAC3B;QACD,QAAQ,EAAE,CAAC,YAAY,EAAE,UAAU,CAAC;KACrC;CACF,CAAC","sourcesContent":["import type { LanguageProfile } from './profile.ts';\n\nexport const ruby: LanguageProfile = {\n id: 'ruby',\n extensions: ['rb'],\n wasm: 'tree-sitter-ruby.wasm',\n markerLeader: '# ',\n structure: {\n commentTypes: new Set(['comment']),\n attributeTypes: new Set(),\n // The shebang and the `# frozen_string_literal:` magic comment both govern how\n // the whole file executes; neither may collapse into a run.\n pinnedCommentPattern: /^#(?:!|\\s*frozen_string_literal:)/,\n // A heredoc's body is a top-level sibling of the statement holding its opener —\n // it extends that statement's unit, or a collapse could keep the opener and cut\n // the body, leaving an unterminated heredoc that swallows every declaration\n // after it (and tree-sitter-ruby reports no ERROR for it at EOF).\n ridesBackwardTypes: new Set(['heredoc_body']),\n wrapperTypes: {},\n kindLabels: {\n method: 'method',\n singleton_method: 'method',\n class: 'class',\n module: 'module',\n // Top-level `require \"json\"` and `CONSTANT = 1` are expression nodes in\n // tree-sitter-ruby; \"statement\" is the honest generic word for both — and for\n // top-level control-flow blocks, which are expressions here too.\n call: 'statement',\n assignment: 'statement',\n if: 'statement',\n unless: 'statement',\n case: 'statement',\n while: 'statement',\n until: 'statement',\n for: 'statement',\n begin: 'statement',\n heredoc_body: 'heredoc body',\n comment: 'comment',\n },\n },\n repomap: {\n defKinds: {\n method: 'method',\n singleton_method: 'method',\n },\n refTypes: ['identifier', 'constant'],\n },\n};\n"]}
|
package/dist/lang/rust.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rust.d.ts","sourceRoot":"","sources":["../../src/lang/rust.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAEpD,eAAO,MAAM,IAAI,EAAE,eA2ClB,CAAC"}
|
|
1
|
+
{"version":3,"file":"rust.d.ts","sourceRoot":"","sources":["../../src/lang/rust.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAEpD,eAAO,MAAM,IAAI,EAAE,eA2ClB,CAAC","sourcesContent":["import type { LanguageProfile } from './profile.ts';\n\nexport const rust: LanguageProfile = {\n id: 'rust',\n extensions: ['rs'],\n wasm: 'tree-sitter-rust.wasm',\n markerLeader: '// ',\n structure: {\n // `///` and `//!` doc comments are line_comment nodes; `/** … */` is block_comment.\n commentTypes: new Set(['line_comment', 'block_comment']),\n // `#[…]` is a top-level sibling in tree-sitter-rust; it rides forward to its item.\n attributeTypes: new Set(['attribute_item']),\n wrapperTypes: {},\n kindLabels: {\n function_item: 'function',\n struct_item: 'struct',\n enum_item: 'enum',\n union_item: 'union',\n trait_item: 'trait',\n impl_item: 'impl block',\n mod_item: 'module',\n macro_definition: 'macro',\n type_item: 'type alias',\n const_item: 'constant',\n static_item: 'static item',\n use_declaration: 'use declaration',\n extern_crate_declaration: 'extern crate declaration',\n attribute_item: 'attribute',\n foreign_mod_item: 'extern block',\n },\n },\n repomap: {\n defKinds: {\n function_item: 'function',\n struct_item: 'struct',\n enum_item: 'enum',\n trait_item: 'trait',\n mod_item: 'module',\n const_item: 'constant',\n static_item: 'static',\n type_item: 'type alias',\n union_item: 'union',\n },\n refTypes: ['identifier', 'type_identifier'],\n },\n};\n"]}
|
package/dist/lang/rust.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rust.js","sourceRoot":"","sources":["../../src/lang/rust.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,IAAI,GAAoB;IACnC,EAAE,EAAE,MAAM;IACV,UAAU,EAAE,CAAC,IAAI,CAAC;IAClB,IAAI,EAAE,uBAAuB;IAC7B,YAAY,EAAE,KAAK;IACnB,SAAS,EAAE;QACT,oFAAoF;QACpF,YAAY,EAAE,IAAI,GAAG,CAAC,CAAC,cAAc,EAAE,eAAe,CAAC,CAAC;QACxD,mFAAmF;QACnF,cAAc,EAAE,IAAI,GAAG,CAAC,CAAC,gBAAgB,CAAC,CAAC;QAC3C,YAAY,EAAE,EAAE;QAChB,UAAU,EAAE;YACV,aAAa,EAAE,UAAU;YACzB,WAAW,EAAE,QAAQ;YACrB,SAAS,EAAE,MAAM;YACjB,UAAU,EAAE,OAAO;YACnB,UAAU,EAAE,OAAO;YACnB,SAAS,EAAE,YAAY;YACvB,QAAQ,EAAE,QAAQ;YAClB,gBAAgB,EAAE,OAAO;YACzB,SAAS,EAAE,YAAY;YACvB,UAAU,EAAE,UAAU;YACtB,WAAW,EAAE,aAAa;YAC1B,eAAe,EAAE,iBAAiB;YAClC,wBAAwB,EAAE,0BAA0B;YACpD,cAAc,EAAE,WAAW;YAC3B,gBAAgB,EAAE,cAAc;SACjC;KACF;IACD,OAAO,EAAE;QACP,QAAQ,EAAE;YACR,aAAa,EAAE,UAAU;YACzB,WAAW,EAAE,QAAQ;YACrB,SAAS,EAAE,MAAM;YACjB,UAAU,EAAE,OAAO;YACnB,QAAQ,EAAE,QAAQ;YAClB,UAAU,EAAE,UAAU;YACtB,WAAW,EAAE,QAAQ;YACrB,SAAS,EAAE,YAAY;YACvB,UAAU,EAAE,OAAO;SACpB;QACD,QAAQ,EAAE,CAAC,YAAY,EAAE,iBAAiB,CAAC;KAC5C;CACF,CAAC"}
|
|
1
|
+
{"version":3,"file":"rust.js","sourceRoot":"","sources":["../../src/lang/rust.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,IAAI,GAAoB;IACnC,EAAE,EAAE,MAAM;IACV,UAAU,EAAE,CAAC,IAAI,CAAC;IAClB,IAAI,EAAE,uBAAuB;IAC7B,YAAY,EAAE,KAAK;IACnB,SAAS,EAAE;QACT,oFAAoF;QACpF,YAAY,EAAE,IAAI,GAAG,CAAC,CAAC,cAAc,EAAE,eAAe,CAAC,CAAC;QACxD,mFAAmF;QACnF,cAAc,EAAE,IAAI,GAAG,CAAC,CAAC,gBAAgB,CAAC,CAAC;QAC3C,YAAY,EAAE,EAAE;QAChB,UAAU,EAAE;YACV,aAAa,EAAE,UAAU;YACzB,WAAW,EAAE,QAAQ;YACrB,SAAS,EAAE,MAAM;YACjB,UAAU,EAAE,OAAO;YACnB,UAAU,EAAE,OAAO;YACnB,SAAS,EAAE,YAAY;YACvB,QAAQ,EAAE,QAAQ;YAClB,gBAAgB,EAAE,OAAO;YACzB,SAAS,EAAE,YAAY;YACvB,UAAU,EAAE,UAAU;YACtB,WAAW,EAAE,aAAa;YAC1B,eAAe,EAAE,iBAAiB;YAClC,wBAAwB,EAAE,0BAA0B;YACpD,cAAc,EAAE,WAAW;YAC3B,gBAAgB,EAAE,cAAc;SACjC;KACF;IACD,OAAO,EAAE;QACP,QAAQ,EAAE;YACR,aAAa,EAAE,UAAU;YACzB,WAAW,EAAE,QAAQ;YACrB,SAAS,EAAE,MAAM;YACjB,UAAU,EAAE,OAAO;YACnB,QAAQ,EAAE,QAAQ;YAClB,UAAU,EAAE,UAAU;YACtB,WAAW,EAAE,QAAQ;YACrB,SAAS,EAAE,YAAY;YACvB,UAAU,EAAE,OAAO;SACpB;QACD,QAAQ,EAAE,CAAC,YAAY,EAAE,iBAAiB,CAAC;KAC5C;CACF,CAAC","sourcesContent":["import type { LanguageProfile } from './profile.ts';\n\nexport const rust: LanguageProfile = {\n id: 'rust',\n extensions: ['rs'],\n wasm: 'tree-sitter-rust.wasm',\n markerLeader: '// ',\n structure: {\n // `///` and `//!` doc comments are line_comment nodes; `/** … */` is block_comment.\n commentTypes: new Set(['line_comment', 'block_comment']),\n // `#[…]` is a top-level sibling in tree-sitter-rust; it rides forward to its item.\n attributeTypes: new Set(['attribute_item']),\n wrapperTypes: {},\n kindLabels: {\n function_item: 'function',\n struct_item: 'struct',\n enum_item: 'enum',\n union_item: 'union',\n trait_item: 'trait',\n impl_item: 'impl block',\n mod_item: 'module',\n macro_definition: 'macro',\n type_item: 'type alias',\n const_item: 'constant',\n static_item: 'static item',\n use_declaration: 'use declaration',\n extern_crate_declaration: 'extern crate declaration',\n attribute_item: 'attribute',\n foreign_mod_item: 'extern block',\n },\n },\n repomap: {\n defKinds: {\n function_item: 'function',\n struct_item: 'struct',\n enum_item: 'enum',\n trait_item: 'trait',\n mod_item: 'module',\n const_item: 'constant',\n static_item: 'static',\n type_item: 'type alias',\n union_item: 'union',\n },\n refTypes: ['identifier', 'type_identifier'],\n },\n};\n"]}
|
package/dist/lang/swift.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"swift.d.ts","sourceRoot":"","sources":["../../src/lang/swift.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAEpD,eAAO,MAAM,KAAK,EAAE,eAgCnB,CAAC"}
|
|
1
|
+
{"version":3,"file":"swift.d.ts","sourceRoot":"","sources":["../../src/lang/swift.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAEpD,eAAO,MAAM,KAAK,EAAE,eAgCnB,CAAC","sourcesContent":["import type { LanguageProfile } from './profile.ts';\n\nexport const swift: LanguageProfile = {\n id: 'swift',\n extensions: ['swift'],\n wasm: 'tree-sitter-swift.wasm',\n markerLeader: '// ',\n structure: {\n // `//` and `///` are comment nodes; `/* … */` is multiline_comment.\n commentTypes: new Set(['comment', 'multiline_comment']),\n attributeTypes: new Set(),\n // `#!/usr/bin/env swift` parses as a shebang_line node; same law as the rest.\n pinnedTypes: new Set(['shebang_line']),\n wrapperTypes: {},\n kindLabels: {\n function_declaration: 'function',\n // tree-sitter-swift parses struct, class, enum and extension declarations all\n // as class_declaration — \"type declaration\" is the honest word for the union.\n class_declaration: 'type declaration',\n protocol_declaration: 'protocol',\n property_declaration: 'property',\n typealias_declaration: 'type alias',\n import_declaration: 'import declaration',\n shebang_line: 'shebang',\n },\n },\n repomap: {\n defKinds: {\n class_declaration: 'type',\n protocol_declaration: 'protocol',\n function_declaration: 'function',\n },\n refTypes: ['simple_identifier', 'type_identifier'],\n },\n};\n"]}
|
package/dist/lang/swift.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"swift.js","sourceRoot":"","sources":["../../src/lang/swift.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,KAAK,GAAoB;IACpC,EAAE,EAAE,OAAO;IACX,UAAU,EAAE,CAAC,OAAO,CAAC;IACrB,IAAI,EAAE,wBAAwB;IAC9B,YAAY,EAAE,KAAK;IACnB,SAAS,EAAE;QACT,oEAAoE;QACpE,YAAY,EAAE,IAAI,GAAG,CAAC,CAAC,SAAS,EAAE,mBAAmB,CAAC,CAAC;QACvD,cAAc,EAAE,IAAI,GAAG,EAAE;QACzB,8EAA8E;QAC9E,WAAW,EAAE,IAAI,GAAG,CAAC,CAAC,cAAc,CAAC,CAAC;QACtC,YAAY,EAAE,EAAE;QAChB,UAAU,EAAE;YACV,oBAAoB,EAAE,UAAU;YAChC,8EAA8E;YAC9E,8EAA8E;YAC9E,iBAAiB,EAAE,kBAAkB;YACrC,oBAAoB,EAAE,UAAU;YAChC,oBAAoB,EAAE,UAAU;YAChC,qBAAqB,EAAE,YAAY;YACnC,kBAAkB,EAAE,oBAAoB;YACxC,YAAY,EAAE,SAAS;SACxB;KACF;IACD,OAAO,EAAE;QACP,QAAQ,EAAE;YACR,iBAAiB,EAAE,MAAM;YACzB,oBAAoB,EAAE,UAAU;YAChC,oBAAoB,EAAE,UAAU;SACjC;QACD,QAAQ,EAAE,CAAC,mBAAmB,EAAE,iBAAiB,CAAC;KACnD;CACF,CAAC"}
|
|
1
|
+
{"version":3,"file":"swift.js","sourceRoot":"","sources":["../../src/lang/swift.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,KAAK,GAAoB;IACpC,EAAE,EAAE,OAAO;IACX,UAAU,EAAE,CAAC,OAAO,CAAC;IACrB,IAAI,EAAE,wBAAwB;IAC9B,YAAY,EAAE,KAAK;IACnB,SAAS,EAAE;QACT,oEAAoE;QACpE,YAAY,EAAE,IAAI,GAAG,CAAC,CAAC,SAAS,EAAE,mBAAmB,CAAC,CAAC;QACvD,cAAc,EAAE,IAAI,GAAG,EAAE;QACzB,8EAA8E;QAC9E,WAAW,EAAE,IAAI,GAAG,CAAC,CAAC,cAAc,CAAC,CAAC;QACtC,YAAY,EAAE,EAAE;QAChB,UAAU,EAAE;YACV,oBAAoB,EAAE,UAAU;YAChC,8EAA8E;YAC9E,8EAA8E;YAC9E,iBAAiB,EAAE,kBAAkB;YACrC,oBAAoB,EAAE,UAAU;YAChC,oBAAoB,EAAE,UAAU;YAChC,qBAAqB,EAAE,YAAY;YACnC,kBAAkB,EAAE,oBAAoB;YACxC,YAAY,EAAE,SAAS;SACxB;KACF;IACD,OAAO,EAAE;QACP,QAAQ,EAAE;YACR,iBAAiB,EAAE,MAAM;YACzB,oBAAoB,EAAE,UAAU;YAChC,oBAAoB,EAAE,UAAU;SACjC;QACD,QAAQ,EAAE,CAAC,mBAAmB,EAAE,iBAAiB,CAAC;KACnD;CACF,CAAC","sourcesContent":["import type { LanguageProfile } from './profile.ts';\n\nexport const swift: LanguageProfile = {\n id: 'swift',\n extensions: ['swift'],\n wasm: 'tree-sitter-swift.wasm',\n markerLeader: '// ',\n structure: {\n // `//` and `///` are comment nodes; `/* … */` is multiline_comment.\n commentTypes: new Set(['comment', 'multiline_comment']),\n attributeTypes: new Set(),\n // `#!/usr/bin/env swift` parses as a shebang_line node; same law as the rest.\n pinnedTypes: new Set(['shebang_line']),\n wrapperTypes: {},\n kindLabels: {\n function_declaration: 'function',\n // tree-sitter-swift parses struct, class, enum and extension declarations all\n // as class_declaration — \"type declaration\" is the honest word for the union.\n class_declaration: 'type declaration',\n protocol_declaration: 'protocol',\n property_declaration: 'property',\n typealias_declaration: 'type alias',\n import_declaration: 'import declaration',\n shebang_line: 'shebang',\n },\n },\n repomap: {\n defKinds: {\n class_declaration: 'type',\n protocol_declaration: 'protocol',\n function_declaration: 'function',\n },\n refTypes: ['simple_identifier', 'type_identifier'],\n },\n};\n"]}
|
package/dist/lang/tsx.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tsx.d.ts","sourceRoot":"","sources":["../../src/lang/tsx.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAGpD,qFAAqF;AACrF,eAAO,MAAM,GAAG,EAAE,eAOjB,CAAC"}
|
|
1
|
+
{"version":3,"file":"tsx.d.ts","sourceRoot":"","sources":["../../src/lang/tsx.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAGpD,qFAAqF;AACrF,eAAO,MAAM,GAAG,EAAE,eAOjB,CAAC","sourcesContent":["import type { LanguageProfile } from './profile.ts';\nimport { TS_DEF_KINDS, TS_REF_TYPES, TS_STRUCTURE } from './typescript.ts';\n\n/** TSX is the typescript grammar family's second id — same structure, same facts. */\nexport const tsx: LanguageProfile = {\n id: 'tsx',\n extensions: ['tsx'],\n wasm: 'tree-sitter-tsx.wasm',\n markerLeader: '// ',\n structure: TS_STRUCTURE,\n repomap: { defKinds: TS_DEF_KINDS, refTypes: TS_REF_TYPES },\n};\n"]}
|
package/dist/lang/tsx.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tsx.js","sourceRoot":"","sources":["../../src/lang/tsx.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE3E,qFAAqF;AACrF,MAAM,CAAC,MAAM,GAAG,GAAoB;IAClC,EAAE,EAAE,KAAK;IACT,UAAU,EAAE,CAAC,KAAK,CAAC;IACnB,IAAI,EAAE,sBAAsB;IAC5B,YAAY,EAAE,KAAK;IACnB,SAAS,EAAE,YAAY;IACvB,OAAO,EAAE,EAAE,QAAQ,EAAE,YAAY,EAAE,QAAQ,EAAE,YAAY,EAAE;CAC5D,CAAC"}
|
|
1
|
+
{"version":3,"file":"tsx.js","sourceRoot":"","sources":["../../src/lang/tsx.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE3E,qFAAqF;AACrF,MAAM,CAAC,MAAM,GAAG,GAAoB;IAClC,EAAE,EAAE,KAAK;IACT,UAAU,EAAE,CAAC,KAAK,CAAC;IACnB,IAAI,EAAE,sBAAsB;IAC5B,YAAY,EAAE,KAAK;IACnB,SAAS,EAAE,YAAY;IACvB,OAAO,EAAE,EAAE,QAAQ,EAAE,YAAY,EAAE,QAAQ,EAAE,YAAY,EAAE;CAC5D,CAAC","sourcesContent":["import type { LanguageProfile } from './profile.ts';\nimport { TS_DEF_KINDS, TS_REF_TYPES, TS_STRUCTURE } from './typescript.ts';\n\n/** TSX is the typescript grammar family's second id — same structure, same facts. */\nexport const tsx: LanguageProfile = {\n id: 'tsx',\n extensions: ['tsx'],\n wasm: 'tree-sitter-tsx.wasm',\n markerLeader: '// ',\n structure: TS_STRUCTURE,\n repomap: { defKinds: TS_DEF_KINDS, refTypes: TS_REF_TYPES },\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typescript.d.ts","sourceRoot":"","sources":["../../src/lang/typescript.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEvE;;;;GAIG;AACH,eAAO,MAAM,cAAc,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAkB3D,CAAC;AAEF,mFAAmF;AACnF,eAAO,MAAM,YAAY,EAAE,iBAQ1B,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,YAAY,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAWzD,CAAC;AAEF,uEAAuE;AACvE,eAAO,MAAM,YAAY,EAAE,SAAS,MAAM,EAAsC,CAAC;AAEjF,eAAO,MAAM,UAAU,EAAE,eAOxB,CAAC"}
|
|
1
|
+
{"version":3,"file":"typescript.d.ts","sourceRoot":"","sources":["../../src/lang/typescript.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEvE;;;;GAIG;AACH,eAAO,MAAM,cAAc,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAkB3D,CAAC;AAEF,mFAAmF;AACnF,eAAO,MAAM,YAAY,EAAE,iBAQ1B,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,YAAY,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAWzD,CAAC;AAEF,uEAAuE;AACvE,eAAO,MAAM,YAAY,EAAE,SAAS,MAAM,EAAsC,CAAC;AAEjF,eAAO,MAAM,UAAU,EAAE,eAOxB,CAAC","sourcesContent":["import type { LanguageProfile, LanguageStructure } from './profile.ts';\n\n/**\n * Human words for the tree-sitter node types the structural planner expects at the\n * top level of a TypeScript or TSX file. What the map does not name, the planner\n * still labels honestly — see {@link LanguageStructure.kindLabels}.\n */\nexport const TS_KIND_LABELS: Readonly<Record<string, string>> = {\n function_declaration: 'function',\n generator_function_declaration: 'function',\n function_signature: 'function',\n class_declaration: 'class',\n abstract_class_declaration: 'class',\n interface_declaration: 'interface',\n type_alias_declaration: 'type alias',\n enum_declaration: 'enum',\n lexical_declaration: 'variable',\n variable_declaration: 'variable',\n import_statement: 'import statement',\n internal_module: 'namespace',\n module: 'namespace',\n ambient_declaration: 'ambient declaration',\n expression_statement: 'statement',\n hash_bang_line: 'shebang',\n comment: 'comment',\n};\n\n/** One grammar family, two ids: the tsx profile shares this structure verbatim. */\nexport const TS_STRUCTURE: LanguageStructure = {\n commentTypes: new Set(['comment']),\n attributeTypes: new Set(),\n // `#!/usr/bin/env -S npx tsx` parses as a hash_bang_line here too — same node, same\n // law as javascript's: collapsing it changes which interpreter runs the file.\n pinnedTypes: new Set(['hash_bang_line']),\n wrapperTypes: { export_statement: 'export' },\n kindLabels: TS_KIND_LABELS,\n};\n\n/**\n * Repo-map definition kinds for the typescript grammar family — shared by the\n * typescript, tsx and javascript profiles, exactly as the extraction treats them.\n */\nexport const TS_DEF_KINDS: Readonly<Record<string, string>> = {\n function_declaration: 'function',\n generator_function_declaration: 'function',\n function_signature: 'function',\n class_declaration: 'class',\n abstract_class_declaration: 'class',\n interface_declaration: 'interface',\n type_alias_declaration: 'type alias',\n enum_declaration: 'enum',\n method_definition: 'method',\n variable_declarator: 'variable',\n};\n\n/** Repo-map reference node types for the typescript grammar family. */\nexport const TS_REF_TYPES: readonly string[] = ['identifier', 'type_identifier'];\n\nexport const typescript: LanguageProfile = {\n id: 'typescript',\n extensions: ['ts', 'mts', 'cts'],\n wasm: 'tree-sitter-typescript.wasm',\n markerLeader: '// ',\n structure: TS_STRUCTURE,\n repomap: { defKinds: TS_DEF_KINDS, refTypes: TS_REF_TYPES },\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typescript.js","sourceRoot":"","sources":["../../src/lang/typescript.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,MAAM,CAAC,MAAM,cAAc,GAAqC;IAC9D,oBAAoB,EAAE,UAAU;IA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,oBAAoB,EAAE,UAAU;IAChC,8BAA8B,EAAE,UAAU;IAC1C,kBAAkB,EAAE,UAAU;IAC9B,iBAAiB,EAAE,OAAO;IAC1B,0BAA0B,EAAE,OAAO;IACnC,qBAAqB,EAAE,WAAW;IAClC,sBAAsB,EAAE,YAAY;IACpC,gBAAgB,EAAE,MAAM;IACxB,iBAAiB,EAAE,QAAQ;IAC3B,mBAAmB,EAAE,UAAU;CAChC,CAAC;AAEF,uEAAuE;AACvE,MAAM,CAAC,MAAM,YAAY,GAAsB,CAAC,YAAY,EAAE,iBAAiB,CAAC,CAAC;AAEjF,MAAM,CAAC,MAAM,UAAU,GAAoB;IACzC,EAAE,EAAE,YAAY;IAChB,UAAU,EAAE,CAAC,IAAI,EAAE,KAAK,EAAE,KAAK,CAAC;IAChC,IAAI,EAAE,6BAA6B;IACnC,YAAY,EAAE,KAAK;IACnB,SAAS,EAAE,YAAY;IACvB,OAAO,EAAE,EAAE,QAAQ,EAAE,YAAY,EAAE,QAAQ,EAAE,YAAY,EAAE;CAC5D,CAAC","sourcesContent":["import type { LanguageProfile, LanguageStructure } from './profile.ts';\n\n/**\n * Human words for the tree-sitter node types the structural planner expects at the\n * top level of a TypeScript or TSX file. What the map does not name, the planner\n * still labels honestly — see {@link LanguageStructure.kindLabels}.\n */\nexport const TS_KIND_LABELS: Readonly<Record<string, string>> = {\n function_declaration: 'function',\n generator_function_declaration: 'function',\n function_signature: 'function',\n class_declaration: 'class',\n abstract_class_declaration: 'class',\n interface_declaration: 'interface',\n type_alias_declaration: 'type alias',\n enum_declaration: 'enum',\n lexical_declaration: 'variable',\n variable_declaration: 'variable',\n import_statement: 'import statement',\n internal_module: 'namespace',\n module: 'namespace',\n ambient_declaration: 'ambient declaration',\n expression_statement: 'statement',\n hash_bang_line: 'shebang',\n comment: 'comment',\n};\n\n/** One grammar family, two ids: the tsx profile shares this structure verbatim. */\nexport const TS_STRUCTURE: LanguageStructure = {\n commentTypes: new Set(['comment']),\n attributeTypes: new Set(),\n // `#!/usr/bin/env -S npx tsx` parses as a hash_bang_line here too — same node, same\n // law as javascript's: collapsing it changes which interpreter runs the file.\n pinnedTypes: new Set(['hash_bang_line']),\n wrapperTypes: { export_statement: 'export' },\n kindLabels: TS_KIND_LABELS,\n};\n\n/**\n * Repo-map definition kinds for the typescript grammar family — shared by the\n * typescript, tsx and javascript profiles, exactly as the extraction treats them.\n */\nexport const TS_DEF_KINDS: Readonly<Record<string, string>> = {\n function_declaration: 'function',\n generator_function_declaration: 'function',\n function_signature: 'function',\n class_declaration: 'class',\n abstract_class_declaration: 'class',\n interface_declaration: 'interface',\n type_alias_declaration: 'type alias',\n enum_declaration: 'enum',\n method_definition: 'method',\n variable_declarator: 'variable',\n};\n\n/** Repo-map reference node types for the typescript grammar family. */\nexport const TS_REF_TYPES: readonly string[] = ['identifier', 'type_identifier'];\n\nexport const typescript: LanguageProfile = {\n id: 'typescript',\n extensions: ['ts', 'mts', 'cts'],\n wasm: 'tree-sitter-typescript.wasm',\n markerLeader: '// ',\n structure: TS_STRUCTURE,\n repomap: { defKinds: TS_DEF_KINDS, refTypes: TS_REF_TYPES },\n};\n"]}
|
package/dist/net/policy.d.ts
CHANGED
|
@@ -40,10 +40,27 @@ export declare const ALLOWED_PACKAGES: readonly string[];
|
|
|
40
40
|
* Every resource smelt hands to a loader goes through {@link assertLocalResource} first.
|
|
41
41
|
*/
|
|
42
42
|
export declare const ALLOWED_URL_SCHEMES: readonly string[];
|
|
43
|
+
/**
|
|
44
|
+
* The parsed resource {@link assertLocalResource} takes and hands back.
|
|
45
|
+
*
|
|
46
|
+
* A WHATWG `URL` satisfies it, and one is what comes back at runtime — but `URL` is
|
|
47
|
+
* *stated* structurally here, for the reason `AnswerStream` is not
|
|
48
|
+
* `NodeJS.ReadableStream` and `RepoReader.read` returns `Uint8Array`: `URL` is a
|
|
49
|
+
* global that only a compilation which pulled in `@types/node` (or the DOM lib) has,
|
|
50
|
+
* so naming it in an exported signature put two errors into the shipped `.d.ts` for
|
|
51
|
+
* every consumer building with `skipLibCheck: false` and no such types of their own.
|
|
52
|
+
* These are the two members the policy reads and the two its callers use.
|
|
53
|
+
*/
|
|
54
|
+
export interface LocalResource {
|
|
55
|
+
/** The scheme, with its colon — `'file:'`. */
|
|
56
|
+
readonly protocol: string;
|
|
57
|
+
/** The whole URL, as a string. `fileURLToPath` takes it directly. */
|
|
58
|
+
readonly href: string;
|
|
59
|
+
}
|
|
43
60
|
/**
|
|
44
61
|
* Reject anything that is not a local file, and return the resolved `file:` URL.
|
|
45
62
|
*
|
|
46
63
|
* @throws {NetworkPolicyError} if the input names a remote scheme.
|
|
47
64
|
*/
|
|
48
|
-
export declare function assertLocalResource(input: string |
|
|
65
|
+
export declare function assertLocalResource(input: string | LocalResource): LocalResource;
|
|
49
66
|
//# sourceMappingURL=policy.d.ts.map
|
package/dist/net/policy.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"policy.d.ts","sourceRoot":"","sources":["../../src/net/policy.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;GAUG;AACH,eAAO,MAAM,sBAAsB,EAAE,SAAS,MAAM,EAenD,CAAC;AAEF,uFAAuF;AACvF,eAAO,MAAM,kBAAkB,EAAE,SAAS,MAAM,EAU/C,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,EAAE,SAAS,MAAM,EAQ9C,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,qBAAqB,EAAE,SAAS,MAAM,
|
|
1
|
+
{"version":3,"file":"policy.d.ts","sourceRoot":"","sources":["../../src/net/policy.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;GAUG;AACH,eAAO,MAAM,sBAAsB,EAAE,SAAS,MAAM,EAenD,CAAC;AAEF,uFAAuF;AACvF,eAAO,MAAM,kBAAkB,EAAE,SAAS,MAAM,EAU/C,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,EAAE,SAAS,MAAM,EAQ9C,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,qBAAqB,EAAE,SAAS,MAAM,EAYlD,CAAC;AAEF,yFAAyF;AACzF,eAAO,MAAM,gBAAgB,EAAE,SAAS,MAAM,EAG7C,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,mBAAmB,EAAE,SAAS,MAAM,EAAc,CAAC;AAEhE;;;;;;;;;;GAUG;AACH,MAAM,WAAW,aAAa;IAC5B,8CAA8C;IAC9C,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,qEAAqE;IACrE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,aAAa,GAAG,aAAa,CAShF","sourcesContent":["import { NetworkPolicyError } from '../errors.ts';\n\n/**\n * Law 1 — zero network in v1 — written down once, in one place, so that the guard\n * test and the runtime check cannot drift apart. `test/guards/no-network.test.ts`\n * imports these lists and fails if any module reachable from the public entrypoint\n * imports one of them.\n *\n * This is a *partition of a discovered set*, not an allowlist over an assumed one:\n * the guard walks the real import graph and classifies every edge it finds. A new\n * transport nobody thought of still gets classified — as an unknown bare import,\n * which the guard reports rather than ignores.\n */\nexport const FORBIDDEN_NODE_MODULES: readonly string[] = [\n 'http',\n 'https',\n 'http2',\n 'net',\n 'tls',\n 'dgram',\n 'dns',\n 'node:http',\n 'node:https',\n 'node:http2',\n 'node:net',\n 'node:tls',\n 'node:dgram',\n 'node:dns',\n];\n\n/** Third-party transports. A dependency that pulls one in is a Law 1 violation too. */\nexport const FORBIDDEN_PACKAGES: readonly string[] = [\n 'undici',\n 'axios',\n 'node-fetch',\n 'got',\n 'ky',\n 'superagent',\n 'ws',\n 'socket.io-client',\n 'eventsource',\n];\n\n/**\n * Globals that reach the network without an import. Grepped for by the guard — both\n * bare (`fetch(…)`) and qualified through a global object (`globalThis.fetch(…)`),\n * which is why `globalThis` and `global` are themselves on the list: an access\n * routed through the global object is the escape hatch around a bare-name grep.\n */\nexport const FORBIDDEN_GLOBALS: readonly string[] = [\n 'fetch',\n 'XMLHttpRequest',\n 'WebSocket',\n 'EventSource',\n 'navigator',\n 'globalThis',\n 'global',\n];\n\n/**\n * The other half of the partition.\n *\n * A forbidden-list alone is an allowlist over an assumed set: it can only catch\n * transports somebody already thought of. So the guard classifies *every* import edge\n * it discovers, and an edge that matches neither the forbidden lists nor these\n * permitted ones **fails the build**. Adding a dependency therefore requires adding it\n * here, in a diff, next to the reason — which is the point.\n */\nexport const ALLOWED_NODE_BUILTINS: readonly string[] = [\n 'node:crypto', // content hashing for the elision store\n 'node:fs', // reading grammar .wasm files off disk\n 'node:fs/promises',\n 'node:path',\n 'node:url',\n 'node:buffer',\n 'node:module', // web-tree-sitter's own loader shim needs createRequire\n 'node:util', // parseArgs, for the CLI. Argument parsing with zero dependencies.\n 'node:process', // argv, stdin/stdout/stderr and the exit code, for the CLI\n 'node:os', // homedir(), for `smelt hooks install` harness detection — reads a path, opens nothing\n 'node:tty', // isatty(0) for the CLI's TTY check — a plain syscall, no stream, no socket\n];\n\n/** Third-party packages any smelt module may import. Keep this list boring and short. */\nexport const ALLOWED_PACKAGES: readonly string[] = [\n 'web-tree-sitter', // WASM parsers. No native build step, no download at runtime.\n 'tree-sitter-wasms', // prebuilt grammar .wasm blobs, resolved to local file paths\n];\n\n/**\n * The only URL schemes any smelt code path may resolve.\n *\n * This is not paranoia about our own code. `web-tree-sitter`'s `Language.load()`\n * accepts a `string | URL`, and an `https:` URL there would fetch a grammar over the\n * wire — a real network call inside the elision path, from a dependency's happy path.\n * Every resource smelt hands to a loader goes through {@link assertLocalResource} first.\n */\nexport const ALLOWED_URL_SCHEMES: readonly string[] = ['file:'];\n\n/**\n * The parsed resource {@link assertLocalResource} takes and hands back.\n *\n * A WHATWG `URL` satisfies it, and one is what comes back at runtime — but `URL` is\n * *stated* structurally here, for the reason `AnswerStream` is not\n * `NodeJS.ReadableStream` and `RepoReader.read` returns `Uint8Array`: `URL` is a\n * global that only a compilation which pulled in `@types/node` (or the DOM lib) has,\n * so naming it in an exported signature put two errors into the shipped `.d.ts` for\n * every consumer building with `skipLibCheck: false` and no such types of their own.\n * These are the two members the policy reads and the two its callers use.\n */\nexport interface LocalResource {\n /** The scheme, with its colon — `'file:'`. */\n readonly protocol: string;\n /** The whole URL, as a string. `fileURLToPath` takes it directly. */\n readonly href: string;\n}\n\n/**\n * Reject anything that is not a local file, and return the resolved `file:` URL.\n *\n * @throws {NetworkPolicyError} if the input names a remote scheme.\n */\nexport function assertLocalResource(input: string | LocalResource): LocalResource {\n const url = toUrl(input);\n if (!ALLOWED_URL_SCHEMES.includes(url.protocol)) {\n throw new NetworkPolicyError(\n `refusing to load \"${resourceLabel(input)}\": scheme \"${url.protocol}\" is not local. ` +\n `v1 makes zero network calls; only ${ALLOWED_URL_SCHEMES.join(', ')} is allowed.`,\n );\n }\n return url;\n}\n\nconst resourceLabel = (input: string | LocalResource): string =>\n typeof input === 'string' ? input : input.href;\n\nfunction toUrl(input: string | LocalResource): URL {\n // Structural in, structural out: anything carrying an `href` is re-parsed from it,\n // which covers a real `URL` and a `URL` from another realm identically.\n if (typeof input !== 'string') return new URL(input.href);\n // A bare path is a local path. Anything with a scheme is parsed as-is so that\n // \"https://evil/grammar.wasm\" is caught rather than treated as a relative path.\n if (/^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(input)) {\n try {\n return new URL(input);\n } catch {\n throw new NetworkPolicyError(`refusing to load \"${input}\": not a parseable URL or path.`);\n }\n }\n return new URL(`file://${input.startsWith('/') ? '' : '/'}${input}`);\n}\n"]}
|
package/dist/net/policy.js
CHANGED
|
@@ -73,7 +73,6 @@ export const ALLOWED_NODE_BUILTINS = [
|
|
|
73
73
|
'node:util', // parseArgs, for the CLI. Argument parsing with zero dependencies.
|
|
74
74
|
'node:process', // argv, stdin/stdout/stderr and the exit code, for the CLI
|
|
75
75
|
'node:os', // homedir(), for `smelt hooks install` harness detection — reads a path, opens nothing
|
|
76
|
-
'node:readline/promises', // line-by-line answers for `smelt init` — reads streams it is handed, opens nothing
|
|
77
76
|
'node:tty', // isatty(0) for the CLI's TTY check — a plain syscall, no stream, no socket
|
|
78
77
|
];
|
|
79
78
|
/** Third-party packages any smelt module may import. Keep this list boring and short. */
|
|
@@ -98,14 +97,17 @@ export const ALLOWED_URL_SCHEMES = ['file:'];
|
|
|
98
97
|
export function assertLocalResource(input) {
|
|
99
98
|
const url = toUrl(input);
|
|
100
99
|
if (!ALLOWED_URL_SCHEMES.includes(url.protocol)) {
|
|
101
|
-
throw new NetworkPolicyError(`refusing to load "${
|
|
100
|
+
throw new NetworkPolicyError(`refusing to load "${resourceLabel(input)}": scheme "${url.protocol}" is not local. ` +
|
|
102
101
|
`v1 makes zero network calls; only ${ALLOWED_URL_SCHEMES.join(', ')} is allowed.`);
|
|
103
102
|
}
|
|
104
103
|
return url;
|
|
105
104
|
}
|
|
105
|
+
const resourceLabel = (input) => typeof input === 'string' ? input : input.href;
|
|
106
106
|
function toUrl(input) {
|
|
107
|
-
|
|
108
|
-
|
|
107
|
+
// Structural in, structural out: anything carrying an `href` is re-parsed from it,
|
|
108
|
+
// which covers a real `URL` and a `URL` from another realm identically.
|
|
109
|
+
if (typeof input !== 'string')
|
|
110
|
+
return new URL(input.href);
|
|
109
111
|
// A bare path is a local path. Anything with a scheme is parsed as-is so that
|
|
110
112
|
// "https://evil/grammar.wasm" is caught rather than treated as a relative path.
|
|
111
113
|
if (/^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(input)) {
|
package/dist/net/policy.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"policy.js","sourceRoot":"","sources":["../../src/net/policy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAElD;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAsB;IACvD,MAAM;IACN,OAAO;IACP,OAAO;IACP,KAAK;IACL,KAAK;IACL,OAAO;IACP,KAAK;IACL,WAAW;IACX,YAAY;IACZ,YAAY;IACZ,UAAU;IACV,UAAU;IACV,YAAY;IACZ,UAAU;CACX,CAAC;AAEF,uFAAuF;AACvF,MAAM,CAAC,MAAM,kBAAkB,GAAsB;IACnD,QAAQ;IACR,OAAO;IACP,YAAY;IACZ,KAAK;IACL,IAAI;IACJ,YAAY;IACZ,IAAI;IACJ,kBAAkB;IAClB,aAAa;CACd,CAAC;AAEF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAsB;IAClD,OAAO;IACP,gBAAgB;IAChB,WAAW;IACX,aAAa;IACb,WAAW;IACX,YAAY;IACZ,QAAQ;CACT,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAsB;IACtD,aAAa,EAAE,wCAAwC;IACvD,SAAS,EAAE,uCAAuC;IAClD,kBAAkB;IAClB,WAAW;IACX,UAAU;IACV,aAAa;IACb,aAAa,EAAE,wDAAwD;IACvE,WAAW,EAAE,mEAAmE;IAChF,cAAc,EAAE,2DAA2D;IAC3E,SAAS,EAAE,uFAAuF;IAClG,
|
|
1
|
+
{"version":3,"file":"policy.js","sourceRoot":"","sources":["../../src/net/policy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAElD;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAsB;IACvD,MAAM;IACN,OAAO;IACP,OAAO;IACP,KAAK;IACL,KAAK;IACL,OAAO;IACP,KAAK;IACL,WAAW;IACX,YAAY;IACZ,YAAY;IACZ,UAAU;IACV,UAAU;IACV,YAAY;IACZ,UAAU;CACX,CAAC;AAEF,uFAAuF;AACvF,MAAM,CAAC,MAAM,kBAAkB,GAAsB;IACnD,QAAQ;IACR,OAAO;IACP,YAAY;IACZ,KAAK;IACL,IAAI;IACJ,YAAY;IACZ,IAAI;IACJ,kBA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,IAAI,CAAC;AAEjD,SAAS,KAAK,CAAC,KAA6B;IAC1C,mFAAmF;IACnF,wEAAwE;IACxE,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,IAAI,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC1D,8EAA8E;IAC9E,gFAAgF;IAChF,IAAI,2BAA2B,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;QAC5C,IAAI,CAAC;YACH,OAAO,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC;QACxB,CAAC;QAAC,MAAM,CAAC;YACP,MAAM,IAAI,kBAAkB,CAAC,qBAAqB,KAAK,iCAAiC,CAAC,CAAC;QAC5F,CAAC;IACH,CAAC;IACD,OAAO,IAAI,GAAG,CAAC,UAAU,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,GAAG,KAAK,EAAE,CAAC,CAAC;AACvE,CAAC","sourcesContent":["import { NetworkPolicyError } from '../errors.ts';\n\n/**\n * Law 1 — zero network in v1 — written down once, in one place, so that the guard\n * test and the runtime check cannot drift apart. `test/guards/no-network.test.ts`\n * imports these lists and fails if any module reachable from the public entrypoint\n * imports one of them.\n *\n * This is a *partition of a discovered set*, not an allowlist over an assumed one:\n * the guard walks the real import graph and classifies every edge it finds. A new\n * transport nobody thought of still gets classified — as an unknown bare import,\n * which the guard reports rather than ignores.\n */\nexport const FORBIDDEN_NODE_MODULES: readonly string[] = [\n 'http',\n 'https',\n 'http2',\n 'net',\n 'tls',\n 'dgram',\n 'dns',\n 'node:http',\n 'node:https',\n 'node:http2',\n 'node:net',\n 'node:tls',\n 'node:dgram',\n 'node:dns',\n];\n\n/** Third-party transports. A dependency that pulls one in is a Law 1 violation too. */\nexport const FORBIDDEN_PACKAGES: readonly string[] = [\n 'undici',\n 'axios',\n 'node-fetch',\n 'got',\n 'ky',\n 'superagent',\n 'ws',\n 'socket.io-client',\n 'eventsource',\n];\n\n/**\n * Globals that reach the network without an import. Grepped for by the guard — both\n * bare (`fetch(…)`) and qualified through a global object (`globalThis.fetch(…)`),\n * which is why `globalThis` and `global` are themselves on the list: an access\n * routed through the global object is the escape hatch around a bare-name grep.\n */\nexport const FORBIDDEN_GLOBALS: readonly string[] = [\n 'fetch',\n 'XMLHttpRequest',\n 'WebSocket',\n 'EventSource',\n 'navigator',\n 'globalThis',\n 'global',\n];\n\n/**\n * The other half of the partition.\n *\n * A forbidden-list alone is an allowlist over an assumed set: it can only catch\n * transports somebody already thought of. So the guard classifies *every* import edge\n * it discovers, and an edge that matches neither the forbidden lists nor these\n * permitted ones **fails the build**. Adding a dependency therefore requires adding it\n * here, in a diff, next to the reason — which is the point.\n */\nexport const ALLOWED_NODE_BUILTINS: readonly string[] = [\n 'node:crypto', // content hashing for the elision store\n 'node:fs', // reading grammar .wasm files off disk\n 'node:fs/promises',\n 'node:path',\n 'node:url',\n 'node:buffer',\n 'node:module', // web-tree-sitter's own loader shim needs createRequire\n 'node:util', // parseArgs, for the CLI. Argument parsing with zero dependencies.\n 'node:process', // argv, stdin/stdout/stderr and the exit code, for the CLI\n 'node:os', // homedir(), for `smelt hooks install` harness detection — reads a path, opens nothing\n 'node:tty', // isatty(0) for the CLI's TTY check — a plain syscall, no stream, no socket\n];\n\n/** Third-party packages any smelt module may import. Keep this list boring and short. */\nexport const ALLOWED_PACKAGES: readonly string[] = [\n 'web-tree-sitter', // WASM parsers. No native build step, no download at runtime.\n 'tree-sitter-wasms', // prebuilt grammar .wasm blobs, resolved to local file paths\n];\n\n/**\n * The only URL schemes any smelt code path may resolve.\n *\n * This is not paranoia about our own code. `web-tree-sitter`'s `Language.load()`\n * accepts a `string | URL`, and an `https:` URL there would fetch a grammar over the\n * wire — a real network call inside the elision path, from a dependency's happy path.\n * Every resource smelt hands to a loader goes through {@link assertLocalResource} first.\n */\nexport const ALLOWED_URL_SCHEMES: readonly string[] = ['file:'];\n\n/**\n * The parsed resource {@link assertLocalResource} takes and hands back.\n *\n * A WHATWG `URL` satisfies it, and one is what comes back at runtime — but `URL` is\n * *stated* structurally here, for the reason `AnswerStream` is not\n * `NodeJS.ReadableStream` and `RepoReader.read` returns `Uint8Array`: `URL` is a\n * global that only a compilation which pulled in `@types/node` (or the DOM lib) has,\n * so naming it in an exported signature put two errors into the shipped `.d.ts` for\n * every consumer building with `skipLibCheck: false` and no such types of their own.\n * These are the two members the policy reads and the two its callers use.\n */\nexport interface LocalResource {\n /** The scheme, with its colon — `'file:'`. */\n readonly protocol: string;\n /** The whole URL, as a string. `fileURLToPath` takes it directly. */\n readonly href: string;\n}\n\n/**\n * Reject anything that is not a local file, and return the resolved `file:` URL.\n *\n * @throws {NetworkPolicyError} if the input names a remote scheme.\n */\nexport function assertLocalResource(input: string | LocalResource): LocalResource {\n const url = toUrl(input);\n if (!ALLOWED_URL_SCHEMES.includes(url.protocol)) {\n throw new NetworkPolicyError(\n `refusing to load \"${resourceLabel(input)}\": scheme \"${url.protocol}\" is not local. ` +\n `v1 makes zero network calls; only ${ALLOWED_URL_SCHEMES.join(', ')} is allowed.`,\n );\n }\n return url;\n}\n\nconst resourceLabel = (input: string | LocalResource): string =>\n typeof input === 'string' ? input : input.href;\n\nfunction toUrl(input: string | LocalResource): URL {\n // Structural in, structural out: anything carrying an `href` is re-parsed from it,\n // which covers a real `URL` and a `URL` from another realm identically.\n if (typeof input !== 'string') return new URL(input.href);\n // A bare path is a local path. Anything with a scheme is parsed as-is so that\n // \"https://evil/grammar.wasm\" is caught rather than treated as a relative path.\n if (/^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(input)) {\n try {\n return new URL(input);\n } catch {\n throw new NetworkPolicyError(`refusing to load \"${input}\": not a parseable URL or path.`);\n }\n }\n return new URL(`file://${input.startsWith('/') ? '' : '/'}${input}`);\n}\n"]}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The operations seam: what `smelt` *does*, under every door that asks it to.
|
|
3
|
+
*
|
|
4
|
+
* smelt has two front doors — the `smelt` binary in this package and the
|
|
5
|
+
* `@smeltjs/mcp` server next to it — and they are not two products. They are two
|
|
6
|
+
* conventions for saying the same four things: cut this blob, map this tree, give
|
|
7
|
+
* those bytes back, read the counters. The difference between them is entirely at the
|
|
8
|
+
* edges: one reads argv and writes to two streams and returns an exit code, the other
|
|
9
|
+
* validates a JSON Schema and returns a `CallToolResult`.
|
|
10
|
+
*
|
|
11
|
+
* The middle was duplicated anyway. Both packages had their own copy of *the budget is
|
|
12
|
+
* a positive integer with no default*, *an explicit strategy beats a configured one
|
|
13
|
+
* and `lexical` fills last*, *a tree reader refuses a file*, *read a path or fail
|
|
14
|
+
* naming it*, and *a config decides a store*. Five laws, ten implementations — and the
|
|
15
|
+
* mechanical cause is visible in one line of history: `resolveStoreRun` was never
|
|
16
|
+
* exported, so the package that needed the store law could not import it and wrote its
|
|
17
|
+
* own. A restatement leaked across a package boundary because the seam it needed sat
|
|
18
|
+
* on the wrong side of a barrel.
|
|
19
|
+
*
|
|
20
|
+
* So this module is the seam, below both doors:
|
|
21
|
+
*
|
|
22
|
+
* - **`ops/verbs.ts`** — {@link smeltBlob}, {@link mapTree}, {@link retrieveBytes},
|
|
23
|
+
* {@link readCounters}. The verbs over already-resolved inputs, returning data.
|
|
24
|
+
* - **`ops/inputs.ts`** — the laws an input must satisfy to *be* resolved, each
|
|
25
|
+
* stating its rule once and taking the caller's naming as an argument.
|
|
26
|
+
*
|
|
27
|
+
* A front door is now an adapter: **parse and resolve, call an op, render.** The CLI
|
|
28
|
+
* subcommand bodies do that with flags, a config file and an exit code; the MCP tools
|
|
29
|
+
* do it with a JSON Schema and a result envelope. What each may still keep is what is
|
|
30
|
+
* genuinely its own — its error type, its exit code, its wording, and any policy it
|
|
31
|
+
* deliberately does not share. (`smelt retrieve` refuses a memory store; the MCP
|
|
32
|
+
* server accepts one and says so when it bites. That divergence is intentional, it is
|
|
33
|
+
* documented on both sides, and it lives in the adapters — never here.)
|
|
34
|
+
*/
|
|
35
|
+
export { budgetFault, budgetMalformed, budgetRequired, openStore, readBlob, readTree, resolveStrategy, } from './inputs.ts';
|
|
36
|
+
export type { BudgetFault, BudgetNaming, ResolvedStrategy, Ruling, StrategySource, TreeNaming, } from './inputs.ts';
|
|
37
|
+
export { mapTree, readCounters, retrieveBytes, smeltBlob } from './verbs.ts';
|
|
38
|
+
export type { MapTreeOp, ReadCountersOp, RetrieveBytesOp, SmeltBlobOp, SmeltBlobOutcome, } from './verbs.ts';
|
|
39
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ops/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAEH,OAAO,EACL,WAAW,EACX,eAAe,EACf,cAAc,EACd,SAAS,EACT,QAAQ,EACR,QAAQ,EACR,eAAe,GAChB,MAAM,aAAa,CAAC;AACrB,YAAY,EACV,WAAW,EACX,YAAY,EACZ,gBAAgB,EAChB,MAAM,EACN,cAAc,EACd,UAAU,GACX,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAC7E,YAAY,EACV,SAAS,EACT,cAAc,EACd,eAAe,EACf,WAAW,EACX,gBAAgB,GACjB,MAAM,YAAY,CAAC","sourcesContent":["/**\n * The operations seam: what `smelt` *does*, under every door that asks it to.\n *\n * smelt has two front doors — the `smelt` binary in this package and the\n * `@smeltjs/mcp` server next to it — and they are not two products. They are two\n * conventions for saying the same four things: cut this blob, map this tree, give\n * those bytes back, read the counters. The difference between them is entirely at the\n * edges: one reads argv and writes to two streams and returns an exit code, the other\n * validates a JSON Schema and returns a `CallToolResult`.\n *\n * The middle was duplicated anyway. Both packages had their own copy of *the budget is\n * a positive integer with no default*, *an explicit strategy beats a configured one\n * and `lexical` fills last*, *a tree reader refuses a file*, *read a path or fail\n * naming it*, and *a config decides a store*. Five laws, ten implementations — and the\n * mechanical cause is visible in one line of history: `resolveStoreRun` was never\n * exported, so the package that needed the store law could not import it and wrote its\n * own. A restatement leaked across a package boundary because the seam it needed sat\n * on the wrong side of a barrel.\n *\n * So this module is the seam, below both doors:\n *\n * - **`ops/verbs.ts`** — {@link smeltBlob}, {@link mapTree}, {@link retrieveBytes},\n * {@link readCounters}. The verbs over already-resolved inputs, returning data.\n * - **`ops/inputs.ts`** — the laws an input must satisfy to *be* resolved, each\n * stating its rule once and taking the caller's naming as an argument.\n *\n * A front door is now an adapter: **parse and resolve, call an op, render.** The CLI\n * subcommand bodies do that with flags, a config file and an exit code; the MCP tools\n * do it with a JSON Schema and a result envelope. What each may still keep is what is\n * genuinely its own — its error type, its exit code, its wording, and any policy it\n * deliberately does not share. (`smelt retrieve` refuses a memory store; the MCP\n * server accepts one and says so when it bites. That divergence is intentional, it is\n * documented on both sides, and it lives in the adapters — never here.)\n */\n\nexport {\n budgetFault,\n budgetMalformed,\n budgetRequired,\n openStore,\n readBlob,\n readTree,\n resolveStrategy,\n} from './inputs.ts';\nexport type {\n BudgetFault,\n BudgetNaming,\n ResolvedStrategy,\n Ruling,\n StrategySource,\n TreeNaming,\n} from './inputs.ts';\nexport { mapTree, readCounters, retrieveBytes, smeltBlob } from './verbs.ts';\nexport type {\n MapTreeOp,\n ReadCountersOp,\n RetrieveBytesOp,\n SmeltBlobOp,\n SmeltBlobOutcome,\n} from './verbs.ts';\n"]}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The operations seam: what `smelt` *does*, under every door that asks it to.
|
|
3
|
+
*
|
|
4
|
+
* smelt has two front doors — the `smelt` binary in this package and the
|
|
5
|
+
* `@smeltjs/mcp` server next to it — and they are not two products. They are two
|
|
6
|
+
* conventions for saying the same four things: cut this blob, map this tree, give
|
|
7
|
+
* those bytes back, read the counters. The difference between them is entirely at the
|
|
8
|
+
* edges: one reads argv and writes to two streams and returns an exit code, the other
|
|
9
|
+
* validates a JSON Schema and returns a `CallToolResult`.
|
|
10
|
+
*
|
|
11
|
+
* The middle was duplicated anyway. Both packages had their own copy of *the budget is
|
|
12
|
+
* a positive integer with no default*, *an explicit strategy beats a configured one
|
|
13
|
+
* and `lexical` fills last*, *a tree reader refuses a file*, *read a path or fail
|
|
14
|
+
* naming it*, and *a config decides a store*. Five laws, ten implementations — and the
|
|
15
|
+
* mechanical cause is visible in one line of history: `resolveStoreRun` was never
|
|
16
|
+
* exported, so the package that needed the store law could not import it and wrote its
|
|
17
|
+
* own. A restatement leaked across a package boundary because the seam it needed sat
|
|
18
|
+
* on the wrong side of a barrel.
|
|
19
|
+
*
|
|
20
|
+
* So this module is the seam, below both doors:
|
|
21
|
+
*
|
|
22
|
+
* - **`ops/verbs.ts`** — {@link smeltBlob}, {@link mapTree}, {@link retrieveBytes},
|
|
23
|
+
* {@link readCounters}. The verbs over already-resolved inputs, returning data.
|
|
24
|
+
* - **`ops/inputs.ts`** — the laws an input must satisfy to *be* resolved, each
|
|
25
|
+
* stating its rule once and taking the caller's naming as an argument.
|
|
26
|
+
*
|
|
27
|
+
* A front door is now an adapter: **parse and resolve, call an op, render.** The CLI
|
|
28
|
+
* subcommand bodies do that with flags, a config file and an exit code; the MCP tools
|
|
29
|
+
* do it with a JSON Schema and a result envelope. What each may still keep is what is
|
|
30
|
+
* genuinely its own — its error type, its exit code, its wording, and any policy it
|
|
31
|
+
* deliberately does not share. (`smelt retrieve` refuses a memory store; the MCP
|
|
32
|
+
* server accepts one and says so when it bites. That divergence is intentional, it is
|
|
33
|
+
* documented on both sides, and it lives in the adapters — never here.)
|
|
34
|
+
*/
|
|
35
|
+
export { budgetFault, budgetMalformed, budgetRequired, openStore, readBlob, readTree, resolveStrategy, } from './inputs.js';
|
|
36
|
+
export { mapTree, readCounters, retrieveBytes, smeltBlob } from './verbs.js';
|
|
37
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/ops/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAEH,OAAO,EACL,WAAW,EACX,eAAe,EACf,cAAc,EACd,SAAS,EACT,QAAQ,EACR,QAAQ,EACR,eAAe,GAChB,MAAM,aAAa,CAAC;AASrB,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC","sourcesContent":["/**\n * The operations seam: what `smelt` *does*, under every door that asks it to.\n *\n * smelt has two front doors — the `smelt` binary in this package and the\n * `@smeltjs/mcp` server next to it — and they are not two products. They are two\n * conventions for saying the same four things: cut this blob, map this tree, give\n * those bytes back, read the counters. The difference between them is entirely at the\n * edges: one reads argv and writes to two streams and returns an exit code, the other\n * validates a JSON Schema and returns a `CallToolResult`.\n *\n * The middle was duplicated anyway. Both packages had their own copy of *the budget is\n * a positive integer with no default*, *an explicit strategy beats a configured one\n * and `lexical` fills last*, *a tree reader refuses a file*, *read a path or fail\n * naming it*, and *a config decides a store*. Five laws, ten implementations — and the\n * mechanical cause is visible in one line of history: `resolveStoreRun` was never\n * exported, so the package that needed the store law could not import it and wrote its\n * own. A restatement leaked across a package boundary because the seam it needed sat\n * on the wrong side of a barrel.\n *\n * So this module is the seam, below both doors:\n *\n * - **`ops/verbs.ts`** — {@link smeltBlob}, {@link mapTree}, {@link retrieveBytes},\n * {@link readCounters}. The verbs over already-resolved inputs, returning data.\n * - **`ops/inputs.ts`** — the laws an input must satisfy to *be* resolved, each\n * stating its rule once and taking the caller's naming as an argument.\n *\n * A front door is now an adapter: **parse and resolve, call an op, render.** The CLI\n * subcommand bodies do that with flags, a config file and an exit code; the MCP tools\n * do it with a JSON Schema and a result envelope. What each may still keep is what is\n * genuinely its own — its error type, its exit code, its wording, and any policy it\n * deliberately does not share. (`smelt retrieve` refuses a memory store; the MCP\n * server accepts one and says so when it bites. That divergence is intentional, it is\n * documented on both sides, and it lives in the adapters — never here.)\n */\n\nexport {\n budgetFault,\n budgetMalformed,\n budgetRequired,\n openStore,\n readBlob,\n readTree,\n resolveStrategy,\n} from './inputs.ts';\nexport type {\n BudgetFault,\n BudgetNaming,\n ResolvedStrategy,\n Ruling,\n StrategySource,\n TreeNaming,\n} from './inputs.ts';\nexport { mapTree, readCounters, retrieveBytes, smeltBlob } from './verbs.ts';\nexport type {\n MapTreeOp,\n ReadCountersOp,\n RetrieveBytesOp,\n SmeltBlobOp,\n SmeltBlobOutcome,\n} from './verbs.ts';\n"]}
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import type { ConfiguredStore } from '../cli/config.ts';
|
|
2
|
+
import type { Strategy } from '../plan/planners.ts';
|
|
3
|
+
import type { ElisionStore } from '../types.ts';
|
|
4
|
+
/**
|
|
5
|
+
* The laws an operation's input must satisfy — stated once, for every front door.
|
|
6
|
+
*
|
|
7
|
+
* Each rule here was, until this seam existed, written twice: once in a
|
|
8
|
+
* `cli/subcommands/*` verb and once in the MCP server's tool handlers. Two copies of a
|
|
9
|
+
* law is two laws, and the copies had already begun to differ — the `smelt` CLI and
|
|
10
|
+
* the `smelt_file` tool refuse a missing budget with the same reasoning in two
|
|
11
|
+
* separately-maintained sentences, and only one of them was ever edited at a time.
|
|
12
|
+
*
|
|
13
|
+
* **What is shared and what is not.** A law has two halves, and only one of them can
|
|
14
|
+
* be shared honestly:
|
|
15
|
+
*
|
|
16
|
+
* - the **rule and its reasoning** — that a budget is a whole number of bytes
|
|
17
|
+
* greater than zero, that there is no default and why, that a tree-reader refuses
|
|
18
|
+
* a file, that a strategy falls back to `lexical` last. That half lives here.
|
|
19
|
+
* - the **naming** — a CLI spells its budget `--budget` and points at
|
|
20
|
+
* `smelt.config.json`; a tool spells it `"budgetBytes"` and points at nothing.
|
|
21
|
+
* That half is the front door's own, and every function here takes it as an
|
|
22
|
+
* argument rather than guessing.
|
|
23
|
+
*
|
|
24
|
+
* Nothing here throws. The two front doors refuse in different currencies — the CLI
|
|
25
|
+
* with a {@link CliUsageError} that exits 2, the MCP server with a tool-level error
|
|
26
|
+
* carrying `isError: true` — and a shared law that threw would force one of them to
|
|
27
|
+
* catch and re-wrap the other's error type, which is how an exit code changes by
|
|
28
|
+
* accident. So a law that can refuse returns a {@link Ruling}: the value, or the one
|
|
29
|
+
* sentence that refuses it, for the caller to throw in its own currency.
|
|
30
|
+
*
|
|
31
|
+
* Nothing here *finds* a `smelt.config.json` either. Config discovery is a CLI
|
|
32
|
+
* concern by design (see `cli/config.ts`); {@link openStore} takes a decision that
|
|
33
|
+
* has already been made and opens it, so no library call's behaviour depends on the
|
|
34
|
+
* directory it was invoked from.
|
|
35
|
+
*/
|
|
36
|
+
/**
|
|
37
|
+
* The answer to a law that can refuse: the value, or the one sentence refusing it.
|
|
38
|
+
*
|
|
39
|
+
* Deliberately not an exception — see the module comment. The refusal is the
|
|
40
|
+
* complete sentence *minus* whatever prefix the front door puts on its own errors
|
|
41
|
+
* (`smelt: ` for the CLI, the tool name for MCP), because that prefix is naming, and
|
|
42
|
+
* naming belongs to the caller.
|
|
43
|
+
*/
|
|
44
|
+
export type Ruling<T> = {
|
|
45
|
+
readonly ok: true;
|
|
46
|
+
readonly value: T;
|
|
47
|
+
} | {
|
|
48
|
+
readonly ok: false;
|
|
49
|
+
readonly refusal: string;
|
|
50
|
+
};
|
|
51
|
+
/** How one front door spells the budget it is refusing, and what it points at next. */
|
|
52
|
+
export interface BudgetNaming {
|
|
53
|
+
/** The knob, as this surface spells it: `--budget`, `"budgetBytes"`. */
|
|
54
|
+
readonly knob: string;
|
|
55
|
+
/**
|
|
56
|
+
* What a budget smelt invented would silently decide — the back half of the
|
|
57
|
+
* no-default sentence. `'your context to throw away'` for a blob run, `'the map to
|
|
58
|
+
* leave out'` for a tree.
|
|
59
|
+
*/
|
|
60
|
+
readonly stake: string;
|
|
61
|
+
/**
|
|
62
|
+
* Anything this surface adds after the law: where else the value can come from, and
|
|
63
|
+
* an example. Appended after a single space. The CLI names `defaultBudgetBytes` and
|
|
64
|
+
* `smelt init` here; a tool whose schema already says `required` adds nothing.
|
|
65
|
+
*/
|
|
66
|
+
readonly advice?: string;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Law: **a budget is required, and there is no default.**
|
|
70
|
+
*
|
|
71
|
+
* The reasoning is the whole point of the sentence, so it is stated once here rather
|
|
72
|
+
* than paraphrased per surface: a budget smelt invented would silently decide how much
|
|
73
|
+
* of the caller's context to throw away, which is a number nobody measured making a
|
|
74
|
+
* decision nobody made.
|
|
75
|
+
*/
|
|
76
|
+
export declare function budgetRequired(naming: BudgetNaming): string;
|
|
77
|
+
/** The two ways a budget that *was* given can still be wrong. See {@link budgetFault}. */
|
|
78
|
+
export type BudgetFault = 'not-an-integer' | 'not-positive';
|
|
79
|
+
/**
|
|
80
|
+
* Law: **a budget is a whole number of UTF-8 bytes greater than zero.**
|
|
81
|
+
*
|
|
82
|
+
* The numeric half only. Getting a candidate *number* out of a surface is that
|
|
83
|
+
* surface's own lexing and stays there: argv carries strings (`--budget 4kb` is a
|
|
84
|
+
* malformed number, and `-1` never reaches here because a leading `-` is not a
|
|
85
|
+
* budget at all), while a JSON tool argument carries whatever type the model sent.
|
|
86
|
+
* Both then ask this function the same question about the same rule.
|
|
87
|
+
*/
|
|
88
|
+
export declare function budgetFault(value: number): BudgetFault | undefined;
|
|
89
|
+
/**
|
|
90
|
+
* The sentence for a {@link BudgetFault}, naming the value it rejected.
|
|
91
|
+
*
|
|
92
|
+
* `got` is rendered with `JSON.stringify`, which is what both front doors already
|
|
93
|
+
* printed: a CLI passes the raw argv word and gets it back quoted (`"4kb"`), a tool
|
|
94
|
+
* passes the raw JSON value and gets numbers bare (`0`) and strings quoted. One
|
|
95
|
+
* renderer, because a value echoed back in a different shape than it was written is a
|
|
96
|
+
* value the author has to translate before they can see their own typo.
|
|
97
|
+
*/
|
|
98
|
+
export declare function budgetMalformed(fault: BudgetFault, knob: string, got: unknown): string;
|
|
99
|
+
/**
|
|
100
|
+
* The strategy a run falls back to when neither the caller nor a config names one.
|
|
101
|
+
*
|
|
102
|
+
* Re-exported rather than restated: {@link DEFAULT_STRATEGY} is the planner registry's
|
|
103
|
+
* own fact, and a second spelling here would be the fork this seam exists to close.
|
|
104
|
+
*/
|
|
105
|
+
export { DEFAULT_STRATEGY } from '../plan/planners.ts';
|
|
106
|
+
/** Where a resolved strategy came from — the receipt {@link resolveStrategy} returns. */
|
|
107
|
+
export type StrategySource = 'flag' | 'config' | 'builtin';
|
|
108
|
+
/** A strategy, with the provenance that explains it. */
|
|
109
|
+
export interface ResolvedStrategy {
|
|
110
|
+
readonly strategy: Strategy;
|
|
111
|
+
readonly source: StrategySource;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Law: **an explicit strategy wins over a configured one, and `lexical` fills last.**
|
|
115
|
+
*
|
|
116
|
+
* Both front doors had this precedence written out, and both spelled the built-in
|
|
117
|
+
* `'lexical'` inline — so a sixth planner promoted to the default would have been a
|
|
118
|
+
* two-package edit with no compiler and no test to notice half of it. `chosen` is
|
|
119
|
+
* whatever the caller said explicitly (a `--strategy` flag, a `"strategy"` argument);
|
|
120
|
+
* `configured` is what the nearest `smelt.config.json` says. Validating the name is
|
|
121
|
+
* *not* part of this law — membership in the `PLANNERS` registry (`isStrategy`) is
|
|
122
|
+
* that, already shared, and the sentence each surface refuses an unknown name with is
|
|
123
|
+
* its own register: a flag and a JSON argument do not read alike.
|
|
124
|
+
*/
|
|
125
|
+
export declare function resolveStrategy(chosen: Strategy | undefined, configured: Strategy | undefined): ResolvedStrategy;
|
|
126
|
+
/**
|
|
127
|
+
* Law: **read a path, or fail naming it.**
|
|
128
|
+
*
|
|
129
|
+
* `shownAs` is the path as its author wrote it, which is not always the path opened:
|
|
130
|
+
* a tool resolves a relative argument against the server's working directory, and
|
|
131
|
+
* echoing back the absolute result would answer a question nobody asked. The cause is
|
|
132
|
+
* carried through verbatim — an `EACCES` and an `ENOENT` call for different
|
|
133
|
+
* responses, and flattening them to "could not read" throws that away.
|
|
134
|
+
*/
|
|
135
|
+
export declare function readBlob(fullPath: string, shownAs: string): Ruling<string>;
|
|
136
|
+
/** How one front door names the tree verb and its single-file sibling. */
|
|
137
|
+
export interface TreeNaming {
|
|
138
|
+
/** The whole-tree reader, as this surface spells it: `map`, `repo_map`. */
|
|
139
|
+
readonly tree: string;
|
|
140
|
+
/** Where to go for one file instead: `` `smelt <file>` ``, `smelt_file`. */
|
|
141
|
+
readonly file: string;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Law: **a tree reader reads a directory, and says so when handed a file.**
|
|
145
|
+
*
|
|
146
|
+
* Two distinct refusals, kept distinct: a path that cannot be statted at all
|
|
147
|
+
* (misspelled, unreadable) and a path that is a perfectly good *file*. The second is
|
|
148
|
+
* the interesting one — it is a caller who wanted the other verb, so the refusal
|
|
149
|
+
* names the other verb instead of leaving them to guess which of their two options
|
|
150
|
+
* was wrong.
|
|
151
|
+
*/
|
|
152
|
+
export declare function readTree(fullPath: string, shownAs: string, naming: TreeNaming): Ruling<string>;
|
|
153
|
+
/**
|
|
154
|
+
* Law: **a store decision, opened.**
|
|
155
|
+
*
|
|
156
|
+
* The *decision* — which kind, and where — is `configuredStore()` in `cli/config.ts`,
|
|
157
|
+
* one reading of one config key. This is the other half: turning that decision into a
|
|
158
|
+
* live {@link ElisionStore}. It was the missing half. The MCP package needed exactly
|
|
159
|
+
* this and could not import it, so it re-derived the decision *and* the construction
|
|
160
|
+
* from the config keys directly, and a second reading of `store.kind` came into
|
|
161
|
+
* existence in another package.
|
|
162
|
+
*
|
|
163
|
+
* What each front door does with a memory store stays the front door's: `smelt
|
|
164
|
+
* retrieve` and `smelt stats` refuse one (a marker's hash from an earlier run names
|
|
165
|
+
* bytes no memory store ever held), while the MCP server accepts one and says so at
|
|
166
|
+
* the moment it bites. That divergence is deliberate and documented; it is a policy
|
|
167
|
+
* about a store, not a fact about opening one.
|
|
168
|
+
*/
|
|
169
|
+
export declare function openStore(decision: ConfiguredStore): ElisionStore;
|
|
170
|
+
//# sourceMappingURL=inputs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inputs.d.ts","sourceRoot":"","sources":["../../src/ops/inputs.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAExD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAGpD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH;;;;;;;GAOG;AACH,MAAM,MAAM,MAAM,CAAC,CAAC,IAClB;IAAE,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAA;CAAE,GAAG;IAAE,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC;AAE9F,uFAAuF;AACvF,MAAM,WAAW,YAAY;IAC3B,wEAAwE;IACxE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB;;;;OAIG;IACH,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB;;;;OAIG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,YAAY,GAAG,MAAM,CAM3D;AAED,0FAA0F;AAC1F,MAAM,MAAM,WAAW,GAAG,gBAAgB,GAAG,cAAc,CAAC;AAE5D;;;;;;;;GAQG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,WAAW,GAAG,SAAS,CAIlE;AAED;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,GAAG,MAAM,CAItF;AAED;;;;;GAKG;AACH,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAEvD,yFAAyF;AACzF,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,QAAQ,GAAG,SAAS,CAAC;AAE3D,wDAAwD;AACxD,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAC5B,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAC;CACjC;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,eAAe,CAC7B,MAAM,EAAE,QAAQ,GAAG,SAAS,EAC5B,UAAU,EAAE,QAAQ,GAAG,SAAS,GAC/B,gBAAgB,CAIlB;AAED;;;;;;;;GAQG;AACH,wBAAgB,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,CAM1E;AAED,0EAA0E;AAC1E,MAAM,WAAW,UAAU;IACzB,2EAA2E;IAC3E,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,4EAA4E;IAC5E,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAED;;;;;;;;GAQG;AACH,wBAAgB,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,GAAG,MAAM,CAAC,MAAM,CAAC,CAgB9F;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,SAAS,CAAC,QAAQ,EAAE,eAAe,GAAG,YAAY,CAIjE","sourcesContent":["import { readFileSync, statSync } from 'node:fs';\n\nimport type { ConfiguredStore } from '../cli/config.ts';\nimport { DEFAULT_STRATEGY } from '../plan/planners.ts';\nimport type { Strategy } from '../plan/planners.ts';\nimport { MemoryElisionStore } from '../store.ts';\nimport { DirectoryElisionStore } from '../store-dir.ts';\nimport type { ElisionStore } from '../types.ts';\n\n/**\n * The laws an operation's input must satisfy — stated once, for every front door.\n *\n * Each rule here was, until this seam existed, written twice: once in a\n * `cli/subcommands/*` verb and once in the MCP server's tool handlers. Two copies of a\n * law is two laws, and the copies had already begun to differ — the `smelt` CLI and\n * the `smelt_file` tool refuse a missing budget with the same reasoning in two\n * separately-maintained sentences, and only one of them was ever edited at a time.\n *\n * **What is shared and what is not.** A law has two halves, and only one of them can\n * be shared honestly:\n *\n * - the **rule and its reasoning** — that a budget is a whole number of bytes\n * greater than zero, that there is no default and why, that a tree-reader refuses\n * a file, that a strategy falls back to `lexical` last. That half lives here.\n * - the **naming** — a CLI spells its budget `--budget` and points at\n * `smelt.config.json`; a tool spells it `\"budgetBytes\"` and points at nothing.\n * That half is the front door's own, and every function here takes it as an\n * argument rather than guessing.\n *\n * Nothing here throws. The two front doors refuse in different currencies — the CLI\n * with a {@link CliUsageError} that exits 2, the MCP server with a tool-level error\n * carrying `isError: true` — and a shared law that threw would force one of them to\n * catch and re-wrap the other's error type, which is how an exit code changes by\n * accident. So a law that can refuse returns a {@link Ruling}: the value, or the one\n * sentence that refuses it, for the caller to throw in its own currency.\n *\n * Nothing here *finds* a `smelt.config.json` either. Config discovery is a CLI\n * concern by design (see `cli/config.ts`); {@link openStore} takes a decision that\n * has already been made and opens it, so no library call's behaviour depends on the\n * directory it was invoked from.\n */\n\n/**\n * The answer to a law that can refuse: the value, or the one sentence refusing it.\n *\n * Deliberately not an exception — see the module comment. The refusal is the\n * complete sentence *minus* whatever prefix the front door puts on its own errors\n * (`smelt: ` for the CLI, the tool name for MCP), because that prefix is naming, and\n * naming belongs to the caller.\n */\nexport type Ruling<T> =\n { readonly ok: true; readonly value: T } | { readonly ok: false; readonly refusal: string };\n\n/** How one front door spells the budget it is refusing, and what it points at next. */\nexport interface BudgetNaming {\n /** The knob, as this surface spells it: `--budget`, `\"budgetBytes\"`. */\n readonly knob: string;\n /**\n * What a budget smelt invented would silently decide — the back half of the\n * no-default sentence. `'your context to throw away'` for a blob run, `'the map to\n * leave out'` for a tree.\n */\n readonly stake: string;\n /**\n * Anything this surface adds after the law: where else the value can come from, and\n * an example. Appended after a single space. The CLI names `defaultBudgetBytes` and\n * `smelt init` here; a tool whose schema already says `required` adds nothing.\n */\n readonly advice?: string;\n}\n\n/**\n * Law: **a budget is required, and there is no default.**\n *\n * The reasoning is the whole point of the sentence, so it is stated once here rather\n * than paraphrased per surface: a budget smelt invented would silently decide how much\n * of the caller's context to throw away, which is a number nobody measured making a\n * decision nobody made.\n */\nexport function budgetRequired(naming: BudgetNaming): string {\n return (\n `${naming.knob} is required, in UTF-8 bytes. There is no default, because a budget ` +\n `smelt invented would silently decide how much of ${naming.stake}.` +\n (naming.advice === undefined ? '' : ` ${naming.advice}`)\n );\n}\n\n/** The two ways a budget that *was* given can still be wrong. See {@link budgetFault}. */\nexport type BudgetFault = 'not-an-integer' | 'not-positive';\n\n/**\n * Law: **a budget is a whole number of UTF-8 bytes greater than zero.**\n *\n * The numeric half only. Getting a candidate *number* out of a surface is that\n * surface's own lexing and stays there: argv carries strings (`--budget 4kb` is a\n * malformed number, and `-1` never reaches here because a leading `-` is not a\n * budget at all), while a JSON tool argument carries whatever type the model sent.\n * Both then ask this function the same question about the same rule.\n */\nexport function budgetFault(value: number): BudgetFault | undefined {\n if (!Number.isInteger(value)) return 'not-an-integer';\n if (value <= 0) return 'not-positive';\n return undefined;\n}\n\n/**\n * The sentence for a {@link BudgetFault}, naming the value it rejected.\n *\n * `got` is rendered with `JSON.stringify`, which is what both front doors already\n * printed: a CLI passes the raw argv word and gets it back quoted (`\"4kb\"`), a tool\n * passes the raw JSON value and gets numbers bare (`0`) and strings quoted. One\n * renderer, because a value echoed back in a different shape than it was written is a\n * value the author has to translate before they can see their own typo.\n */\nexport function budgetMalformed(fault: BudgetFault, knob: string, got: unknown): string {\n return fault === 'not-an-integer'\n ? `${knob} must be a whole number of bytes, got ${JSON.stringify(got)}.`\n : `${knob} must be greater than zero, got ${JSON.stringify(got)}.`;\n}\n\n/**\n * The strategy a run falls back to when neither the caller nor a config names one.\n *\n * Re-exported rather than restated: {@link DEFAULT_STRATEGY} is the planner registry's\n * own fact, and a second spelling here would be the fork this seam exists to close.\n */\nexport { DEFAULT_STRATEGY } from '../plan/planners.ts';\n\n/** Where a resolved strategy came from — the receipt {@link resolveStrategy} returns. */\nexport type StrategySource = 'flag' | 'config' | 'builtin';\n\n/** A strategy, with the provenance that explains it. */\nexport interface ResolvedStrategy {\n readonly strategy: Strategy;\n readonly source: StrategySource;\n}\n\n/**\n * Law: **an explicit strategy wins over a configured one, and `lexical` fills last.**\n *\n * Both front doors had this precedence written out, and both spelled the built-in\n * `'lexical'` inline — so a sixth planner promoted to the default would have been a\n * two-package edit with no compiler and no test to notice half of it. `chosen` is\n * whatever the caller said explicitly (a `--strategy` flag, a `\"strategy\"` argument);\n * `configured` is what the nearest `smelt.config.json` says. Validating the name is\n * *not* part of this law — membership in the `PLANNERS` registry (`isStrategy`) is\n * that, already shared, and the sentence each surface refuses an unknown name with is\n * its own register: a flag and a JSON argument do not read alike.\n */\nexport function resolveStrategy(\n chosen: Strategy | undefined,\n configured: Strategy | undefined,\n): ResolvedStrategy {\n if (chosen !== undefined) return { strategy: chosen, source: 'flag' };\n if (configured !== undefined) return { strategy: configured, source: 'config' };\n return { strategy: DEFAULT_STRATEGY, source: 'builtin' };\n}\n\n/**\n * Law: **read a path, or fail naming it.**\n *\n * `shownAs` is the path as its author wrote it, which is not always the path opened:\n * a tool resolves a relative argument against the server's working directory, and\n * echoing back the absolute result would answer a question nobody asked. The cause is\n * carried through verbatim — an `EACCES` and an `ENOENT` call for different\n * responses, and flattening them to \"could not read\" throws that away.\n */\nexport function readBlob(fullPath: string, shownAs: string): Ruling<string> {\n try {\n return { ok: true, value: readFileSync(fullPath, 'utf8') };\n } catch (cause) {\n return { ok: false, refusal: `cannot read \"${shownAs}\": ${describe(cause)}` };\n }\n}\n\n/** How one front door names the tree verb and its single-file sibling. */\nexport interface TreeNaming {\n /** The whole-tree reader, as this surface spells it: `map`, `repo_map`. */\n readonly tree: string;\n /** Where to go for one file instead: `` `smelt <file>` ``, `smelt_file`. */\n readonly file: string;\n}\n\n/**\n * Law: **a tree reader reads a directory, and says so when handed a file.**\n *\n * Two distinct refusals, kept distinct: a path that cannot be statted at all\n * (misspelled, unreadable) and a path that is a perfectly good *file*. The second is\n * the interesting one — it is a caller who wanted the other verb, so the refusal\n * names the other verb instead of leaving them to guess which of their two options\n * was wrong.\n */\nexport function readTree(fullPath: string, shownAs: string, naming: TreeNaming): Ruling<string> {\n let isDirectory: boolean;\n try {\n isDirectory = statSync(fullPath).isDirectory();\n } catch (cause) {\n return { ok: false, refusal: `cannot read directory \"${shownAs}\": ${describe(cause)}` };\n }\n if (!isDirectory) {\n return {\n ok: false,\n refusal:\n `\"${shownAs}\" is not a directory. ${naming.tree} reads a whole tree; for one ` +\n `file, use ${naming.file}.`,\n };\n }\n return { ok: true, value: fullPath };\n}\n\n/**\n * Law: **a store decision, opened.**\n *\n * The *decision* — which kind, and where — is `configuredStore()` in `cli/config.ts`,\n * one reading of one config key. This is the other half: turning that decision into a\n * live {@link ElisionStore}. It was the missing half. The MCP package needed exactly\n * this and could not import it, so it re-derived the decision *and* the construction\n * from the config keys directly, and a second reading of `store.kind` came into\n * existence in another package.\n *\n * What each front door does with a memory store stays the front door's: `smelt\n * retrieve` and `smelt stats` refuse one (a marker's hash from an earlier run names\n * bytes no memory store ever held), while the MCP server accepts one and says so at\n * the moment it bites. That divergence is deliberate and documented; it is a policy\n * about a store, not a fact about opening one.\n */\nexport function openStore(decision: ConfiguredStore): ElisionStore {\n return decision.kind === 'memory'\n ? new MemoryElisionStore()\n : new DirectoryElisionStore(decision.path);\n}\n\n/** A thrown cause as one line, without pretending an unknown throw was an Error. */\nfunction describe(cause: unknown): string {\n return cause instanceof Error ? cause.message : String(cause);\n}\n"]}
|