soturail 0.2.1

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.
Files changed (149) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +205 -0
  3. package/dist/cli.d.ts +3 -0
  4. package/dist/cli.js +54 -0
  5. package/dist/cli.js.map +1 -0
  6. package/dist/commands/bench.d.ts +31 -0
  7. package/dist/commands/bench.js +387 -0
  8. package/dist/commands/bench.js.map +1 -0
  9. package/dist/commands/dedupe.d.ts +2 -0
  10. package/dist/commands/dedupe.js +16 -0
  11. package/dist/commands/dedupe.js.map +1 -0
  12. package/dist/commands/doctor.d.ts +14 -0
  13. package/dist/commands/doctor.js +122 -0
  14. package/dist/commands/doctor.js.map +1 -0
  15. package/dist/commands/expand.d.ts +3 -0
  16. package/dist/commands/expand.js +23 -0
  17. package/dist/commands/expand.js.map +1 -0
  18. package/dist/commands/format.d.ts +6 -0
  19. package/dist/commands/format.js +48 -0
  20. package/dist/commands/format.js.map +1 -0
  21. package/dist/commands/hooks.d.ts +11 -0
  22. package/dist/commands/hooks.js +248 -0
  23. package/dist/commands/hooks.js.map +1 -0
  24. package/dist/commands/index.d.ts +3 -0
  25. package/dist/commands/index.js +28 -0
  26. package/dist/commands/index.js.map +1 -0
  27. package/dist/commands/ingest.d.ts +6 -0
  28. package/dist/commands/ingest.js +52 -0
  29. package/dist/commands/ingest.js.map +1 -0
  30. package/dist/commands/init.d.ts +7 -0
  31. package/dist/commands/init.js +179 -0
  32. package/dist/commands/init.js.map +1 -0
  33. package/dist/commands/memory.d.ts +39 -0
  34. package/dist/commands/memory.js +184 -0
  35. package/dist/commands/memory.js.map +1 -0
  36. package/dist/commands/native.d.ts +2 -0
  37. package/dist/commands/native.js +17 -0
  38. package/dist/commands/native.js.map +1 -0
  39. package/dist/commands/read.d.ts +8 -0
  40. package/dist/commands/read.js +87 -0
  41. package/dist/commands/read.js.map +1 -0
  42. package/dist/commands/rules.d.ts +5 -0
  43. package/dist/commands/rules.js +62 -0
  44. package/dist/commands/rules.js.map +1 -0
  45. package/dist/commands/run.d.ts +22 -0
  46. package/dist/commands/run.js +200 -0
  47. package/dist/commands/run.js.map +1 -0
  48. package/dist/commands/spec.d.ts +11 -0
  49. package/dist/commands/spec.js +217 -0
  50. package/dist/commands/spec.js.map +1 -0
  51. package/dist/commands/stats.d.ts +15 -0
  52. package/dist/commands/stats.js +82 -0
  53. package/dist/commands/stats.js.map +1 -0
  54. package/dist/compressors/agent-response-reducer.d.ts +13 -0
  55. package/dist/compressors/agent-response-reducer.js +160 -0
  56. package/dist/compressors/agent-response-reducer.js.map +1 -0
  57. package/dist/compressors/generic-stream.d.ts +6 -0
  58. package/dist/compressors/generic-stream.js +63 -0
  59. package/dist/compressors/generic-stream.js.map +1 -0
  60. package/dist/compressors/git-reducer.d.ts +2 -0
  61. package/dist/compressors/git-reducer.js +78 -0
  62. package/dist/compressors/git-reducer.js.map +1 -0
  63. package/dist/compressors/index.d.ts +10 -0
  64. package/dist/compressors/index.js +84 -0
  65. package/dist/compressors/index.js.map +1 -0
  66. package/dist/compressors/json-toon.d.ts +14 -0
  67. package/dist/compressors/json-toon.js +149 -0
  68. package/dist/compressors/json-toon.js.map +1 -0
  69. package/dist/compressors/test-reducer.d.ts +2 -0
  70. package/dist/compressors/test-reducer.js +50 -0
  71. package/dist/compressors/test-reducer.js.map +1 -0
  72. package/dist/core/cache-normalizer.d.ts +23 -0
  73. package/dist/core/cache-normalizer.js +170 -0
  74. package/dist/core/cache-normalizer.js.map +1 -0
  75. package/dist/core/config.d.ts +104 -0
  76. package/dist/core/config.js +186 -0
  77. package/dist/core/config.js.map +1 -0
  78. package/dist/core/dedupe-store.d.ts +17 -0
  79. package/dist/core/dedupe-store.js +44 -0
  80. package/dist/core/dedupe-store.js.map +1 -0
  81. package/dist/core/document-ingest.d.ts +15 -0
  82. package/dist/core/document-ingest.js +45 -0
  83. package/dist/core/document-ingest.js.map +1 -0
  84. package/dist/core/file-scanner.d.ts +47 -0
  85. package/dist/core/file-scanner.js +248 -0
  86. package/dist/core/file-scanner.js.map +1 -0
  87. package/dist/core/git.d.ts +2 -0
  88. package/dist/core/git.js +29 -0
  89. package/dist/core/git.js.map +1 -0
  90. package/dist/core/metrics-store.d.ts +20 -0
  91. package/dist/core/metrics-store.js +19 -0
  92. package/dist/core/metrics-store.js.map +1 -0
  93. package/dist/core/native-engine.d.ts +25 -0
  94. package/dist/core/native-engine.js +137 -0
  95. package/dist/core/native-engine.js.map +1 -0
  96. package/dist/core/native-runner-adapter.d.ts +18 -0
  97. package/dist/core/native-runner-adapter.js +60 -0
  98. package/dist/core/native-runner-adapter.js.map +1 -0
  99. package/dist/core/raw-store.d.ts +28 -0
  100. package/dist/core/raw-store.js +57 -0
  101. package/dist/core/raw-store.js.map +1 -0
  102. package/dist/core/response-policy.d.ts +11 -0
  103. package/dist/core/response-policy.js +14 -0
  104. package/dist/core/response-policy.js.map +1 -0
  105. package/dist/core/rule-extractor.d.ts +18 -0
  106. package/dist/core/rule-extractor.js +116 -0
  107. package/dist/core/rule-extractor.js.map +1 -0
  108. package/dist/core/rule-validator.d.ts +9 -0
  109. package/dist/core/rule-validator.js +85 -0
  110. package/dist/core/rule-validator.js.map +1 -0
  111. package/dist/core/safety-policy.d.ts +10 -0
  112. package/dist/core/safety-policy.js +69 -0
  113. package/dist/core/safety-policy.js.map +1 -0
  114. package/dist/core/token-estimator.d.ts +2 -0
  115. package/dist/core/token-estimator.js +7 -0
  116. package/dist/core/token-estimator.js.map +1 -0
  117. package/dist/types/index.d.ts +4 -0
  118. package/dist/types/index.js +2 -0
  119. package/dist/types/index.js.map +1 -0
  120. package/docs/architecture.md +47 -0
  121. package/docs/assets/screenshots/README.md +18 -0
  122. package/docs/assets/screenshots/init.svg +13 -0
  123. package/docs/assets/screenshots/run-expand.svg +13 -0
  124. package/docs/assets/screenshots/stats.svg +11 -0
  125. package/docs/assets/soturail-fox.svg +17 -0
  126. package/docs/assets/soturail-icon.svg +10 -0
  127. package/docs/benchmarking.md +34 -0
  128. package/docs/branding.md +14 -0
  129. package/docs/hooks/claude.md +24 -0
  130. package/docs/hooks/codex.md +5 -0
  131. package/docs/hooks/cursor.md +5 -0
  132. package/docs/hooks/gemini.md +5 -0
  133. package/docs/hooks/host-capabilities.json +22 -0
  134. package/docs/hooks.md +15 -0
  135. package/docs/knowledge-to-rules.md +23 -0
  136. package/docs/metrics.md +35 -0
  137. package/docs/mvp.md +21 -0
  138. package/docs/native-runner.md +52 -0
  139. package/docs/prompt-caching.md +27 -0
  140. package/docs/pt-BR/visao-geral.md +26 -0
  141. package/docs/public-roadmap.md +20 -0
  142. package/docs/reducers.md +19 -0
  143. package/docs/release-checklist.md +13 -0
  144. package/docs/response-compression.md +15 -0
  145. package/docs/rules.md +23 -0
  146. package/docs/security-model.md +32 -0
  147. package/docs/spec-driven-workflow.md +22 -0
  148. package/docs/usage.md +64 -0
  149. package/package.json +71 -0
@@ -0,0 +1,13 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 820 360" role="img" aria-labelledby="title desc">
2
+ <title id="title">SotuRail run and expand documentation example</title>
3
+ <desc id="desc">Static terminal-style documentation example showing raw_id recovery.</desc>
4
+ <rect width="820" height="360" rx="14" fill="#111827"/>
5
+ <text x="28" y="58" fill="#e5e7eb" font-family="Consolas, monospace" font-size="18">$ soturail run npm test</text>
6
+ <text x="28" y="98" fill="#fca5a5" font-family="Consolas, monospace" font-size="16">FAIL tests/app.test.ts</text>
7
+ <text x="28" y="128" fill="#fca5a5" font-family="Consolas, monospace" font-size="16">AssertionError: expected 1 to equal 2</text>
8
+ <text x="28" y="180" fill="#fb923c" font-family="Consolas, monospace" font-size="16">SotuRail run complete.</text>
9
+ <text x="28" y="210" fill="#e5e7eb" font-family="Consolas, monospace" font-size="16">Compressor: test-reducer</text>
10
+ <text x="28" y="240" fill="#e5e7eb" font-family="Consolas, monospace" font-size="16">raw_id: example123</text>
11
+ <text x="28" y="270" fill="#86efac" font-family="Consolas, monospace" font-size="16">Recovery: soturail expand example123</text>
12
+ <text x="28" y="320" fill="#94a3b8" font-family="Consolas, monospace" font-size="14">Documentation example; raw_id is illustrative.</text>
13
+ </svg>
@@ -0,0 +1,11 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 760 340" role="img" aria-labelledby="title desc">
2
+ <title id="title">SotuRail stats documentation example</title>
3
+ <desc id="desc">Static terminal-style documentation example for honest local stats.</desc>
4
+ <rect width="760" height="340" rx="14" fill="#0b1220"/>
5
+ <text x="28" y="58" fill="#e2e8f0" font-family="Consolas, monospace" font-size="18">$ soturail stats</text>
6
+ <text x="28" y="102" fill="#fb923c" font-family="Consolas, monospace" font-size="17">SotuRail local stats</text>
7
+ <text x="28" y="138" fill="#e2e8f0" font-family="Consolas, monospace" font-size="16">estimated_raw_tokens: from local manifests</text>
8
+ <text x="28" y="168" fill="#e2e8f0" font-family="Consolas, monospace" font-size="16">estimated_compressed_tokens: from reducers</text>
9
+ <text x="28" y="198" fill="#e2e8f0" font-family="Consolas, monospace" font-size="16">real_provider_cache_hits: not imported</text>
10
+ <text x="28" y="250" fill="#94a3b8" font-family="Consolas, monospace" font-size="14">Documentation example; no fake benchmark numbers shown.</text>
11
+ </svg>
@@ -0,0 +1,17 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 320 220" role="img" aria-labelledby="title desc">
2
+ <title id="title">SotuRail fox logo</title>
3
+ <desc id="desc">A friendly minimal orange fox head with subtle circuit-like context rails underneath.</desc>
4
+ <g fill="none" stroke-linecap="round" stroke-linejoin="round">
5
+ <path d="M88 92 118 28l37 43h10l37-43 30 64-18 65c-9 32-32 49-54 49s-45-17-54-49L88 92Z" fill="#f97316" stroke="#7c2d12" stroke-width="8"/>
6
+ <path d="M118 28 129 89 88 92Z" fill="#fb923c" stroke="#7c2d12" stroke-width="7"/>
7
+ <path d="M202 28 191 89l41 3Z" fill="#fb923c" stroke="#7c2d12" stroke-width="7"/>
8
+ <path d="M117 104c18-16 68-16 86 0l-10 41c-6 23-21 36-33 36s-27-13-33-36l-10-41Z" fill="#fff7ed" stroke="#fed7aa" stroke-width="4"/>
9
+ <path d="M139 117c0 6-5 11-11 11s-11-5-11-11 5-11 11-11 11 5 11 11Zm64 0c0 6-5 11-11 11s-11-5-11-11 5-11 11-11 11 5 11 11Z" fill="#111827" stroke="none"/>
10
+ <path d="M151 138h18l-9 9-9-9Z" fill="#111827" stroke="none"/>
11
+ <path d="M143 160c11 8 23 8 34 0" stroke="#7c2d12" stroke-width="6"/>
12
+ <path d="M76 196h168M103 210h114" stroke="#38bdf8" stroke-width="6"/>
13
+ <path d="M116 186v31M160 184v33M204 186v31" stroke="#0f766e" stroke-width="4"/>
14
+ <circle cx="76" cy="196" r="5" fill="#38bdf8" stroke="none"/>
15
+ <circle cx="244" cy="196" r="5" fill="#38bdf8" stroke="none"/>
16
+ </g>
17
+ </svg>
@@ -0,0 +1,10 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 128 128" role="img" aria-labelledby="title desc">
2
+ <title id="title">SotuRail icon</title>
3
+ <desc id="desc">Compact orange fox icon with a small context rail mark.</desc>
4
+ <path d="M20 50 36 16l20 23h16l20-23 16 34-9 36c-6 22-22 33-35 33S35 108 29 86L20 50Z" fill="#f97316" stroke="#7c2d12" stroke-width="5" stroke-linejoin="round"/>
5
+ <path d="M39 59c11-9 39-9 50 0l-6 22c-4 13-12 20-19 20s-15-7-19-20l-6-22Z" fill="#fff7ed"/>
6
+ <circle cx="48" cy="67" r="5" fill="#111827"/>
7
+ <circle cx="80" cy="67" r="5" fill="#111827"/>
8
+ <path d="M59 79h10l-5 5-5-5Z" fill="#111827"/>
9
+ <path d="M27 116h74M42 124h44" stroke="#38bdf8" stroke-width="4" stroke-linecap="round"/>
10
+ </svg>
@@ -0,0 +1,34 @@
1
+ # Benchmarking
2
+
3
+ SotuRail benchmarks use deterministic local fixtures. They are intended to make reducer and context behavior measurable without claiming external superiority.
4
+
5
+ ```bash
6
+ npm run build
7
+ soturail bench prepare
8
+ soturail bench run --engine ts
9
+ soturail bench report
10
+ ```
11
+
12
+ Outputs:
13
+
14
+ - `benchmarks/results/latest.json`
15
+ - `benchmarks/reports/latest.md`
16
+
17
+ The suite groups results as:
18
+
19
+ - terminal compression;
20
+ - agent response compression;
21
+ - JSON/tool payload compression;
22
+ - knowledge structuring;
23
+ - native performance when available.
24
+
25
+ Knowledge-to-Rules is not judged as pure compression. It creates reusable structured rules, citations and validator metadata.
26
+
27
+ Native comparison:
28
+
29
+ ```bash
30
+ soturail bench run --engine native
31
+ soturail bench compare-engines
32
+ ```
33
+
34
+ Optional RTK or Squeez comparisons are only run when the user already has those tools on PATH.
@@ -0,0 +1,14 @@
1
+ # Branding
2
+
3
+ SotuRail means local context rails for AI coding agents. The name points to the idea of guiding repository, terminal and memory context along safe rails instead of flooding a model with unstable noise.
4
+
5
+ The fox mascot is friendly and alert: a small signal that SotuRail is meant to help developers move quickly while still watching for safety and evidence.
6
+
7
+ The rail/circuit line under the fox represents context flow: source files, command output, specs, memory and rules are routed into stable, recoverable payloads.
8
+
9
+ Logo files:
10
+
11
+ - `docs/assets/soturail-fox.svg` for the README and project pages.
12
+ - `docs/assets/soturail-icon.svg` for compact usage.
13
+
14
+ Both assets are original project identity artwork. They make no trademark or copyright claim beyond SotuRail project branding.
@@ -0,0 +1,24 @@
1
+ # Claude Hooks
2
+
3
+ SotuRail v0.2.1 includes a conservative Claude Code hook template.
4
+
5
+ ```bash
6
+ soturail hooks install claude --dry-run
7
+ soturail hooks install claude
8
+ ```
9
+
10
+ Generated files:
11
+
12
+ - `.claude/settings.json`
13
+ - `.claude/hooks/soturail-pre-tool-use.js`
14
+ - `.claude/hooks/soturail-post-tool-use.js`
15
+
16
+ Existing files are backed up with `.soturail.bak` before being changed.
17
+
18
+ The pre-tool hook inspects incoming tool payload text when Claude Code provides it. It blocks obvious destructive shell commands, including recursive deletion, `sudo`, `git push`, downloaded script piping and raw disk copy patterns. It also suggests `soturail run` for tests, builds and logs.
19
+
20
+ The hook never routes `git push` through `soturail run`.
21
+
22
+ ## Limitation
23
+
24
+ Claude Code hook schemas may vary by installed version. SotuRail writes a conservative documented template; if your Claude Code release expects a different schema, copy the generated command into the supported hook slot manually.
@@ -0,0 +1,5 @@
1
+ # Codex Hooks
2
+
3
+ Codex prompt-only integration uses `AGENTS.md`.
4
+
5
+ SotuRail does not assume private Codex host hook APIs. The fallback rules describe when to index, read progressively, run through SotuRail and avoid `git push`.
@@ -0,0 +1,5 @@
1
+ # Cursor Hooks
2
+
3
+ Cursor prompt-only integration writes `.cursor/rules/soturail.mdc` when installed.
4
+
5
+ Existing files are backed up before SotuRail adds its rules.
@@ -0,0 +1,5 @@
1
+ # Gemini Hooks
2
+
3
+ Gemini prompt-only integration uses `GEMINI.md`.
4
+
5
+ The generated rules keep repository scans, progressive file reads and raw log recovery visible to Gemini CLI sessions.
@@ -0,0 +1,22 @@
1
+ {
2
+ "claude": {
3
+ "mode": "adapter-template",
4
+ "target": "CLAUDE.md",
5
+ "notes": "Pre-tool hooks vary by host version; prompt-only rules are always safe."
6
+ },
7
+ "codex": {
8
+ "mode": "prompt-only",
9
+ "target": "AGENTS.md",
10
+ "notes": "Uses repository guidance rather than unstable host internals."
11
+ },
12
+ "gemini": {
13
+ "mode": "prompt-only",
14
+ "target": "GEMINI.md",
15
+ "notes": "Uses local project guidance."
16
+ },
17
+ "cursor": {
18
+ "mode": "prompt-only",
19
+ "target": ".cursor/rules/soturail.mdc",
20
+ "notes": "Cursor rules file fallback."
21
+ }
22
+ }
package/docs/hooks.md ADDED
@@ -0,0 +1,15 @@
1
+ # Agent Hooks
2
+
3
+ SotuRail hook support is cautious. Claude gets a conservative hook template first; Codex, Gemini and Cursor remain prompt-only fallbacks because host APIs are not all stable.
4
+
5
+ ```bash
6
+ soturail hooks list
7
+ soturail hooks doctor
8
+ soturail hooks install claude --dry-run
9
+ soturail hooks install all --dry-run
10
+ soturail hooks prompt-only codex
11
+ ```
12
+
13
+ Installers create backups before modifying existing files. If a host config location is uncertain, SotuRail generates prompt-only guidance instead of guessing.
14
+
15
+ Claude install writes `.claude/settings.json` and hook scripts under `.claude/hooks/`. Dry-run prints every file that would change.
@@ -0,0 +1,23 @@
1
+ # Knowledge-to-Rules Engine
2
+
3
+ SotuRail can ingest heavy documents into reusable structured rules:
4
+
5
+ ```bash
6
+ soturail ingest docs/requirements.md --type requirements
7
+ soturail rules list
8
+ soturail rules check
9
+ soturail rules export --format yaml
10
+ ```
11
+
12
+ Supported v0.2.0 inputs:
13
+
14
+ - Markdown
15
+ - TXT
16
+ - JSON
17
+ - YAML
18
+
19
+ PDF extraction is documented as experimental and disabled unless a safe text extraction path is added later.
20
+
21
+ Rules are deterministic and cite source file, source section and content hash. SotuRail should not invent rules that do not appear in the source.
22
+
23
+ Benchmarks report this feature as knowledge structuring, not pure compression. A structured rule set may be larger than a short source document because it adds ids, citations, severities and validator metadata that can be reused across agent sessions.
@@ -0,0 +1,35 @@
1
+ # Metrics
2
+
3
+ SotuRail metrics are local, append-only and transparent.
4
+
5
+ ## Sources
6
+
7
+ - `.soturail/raw/index.jsonl`
8
+ - `.soturail/metrics/events.jsonl`
9
+ - `.soturail/cache/blocks.jsonl`
10
+ - `.soturail/dedupe/index.jsonl`
11
+ - benchmark JSON reports under `benchmarks/results/`
12
+
13
+ ## Reported Values
14
+
15
+ - estimated raw tokens;
16
+ - estimated compressed tokens;
17
+ - compression ratio;
18
+ - command count;
19
+ - expansion count;
20
+ - manual omission/failure count when present;
21
+ - estimated cache stability score;
22
+ - real provider cache hits only if imported metadata exists.
23
+ - response compression reduction and preservation counts;
24
+ - rules ingestion and validation counts;
25
+ - benchmark fixture measurements.
26
+
27
+ ## Token Estimation
28
+
29
+ v0.1.0 uses:
30
+
31
+ ```text
32
+ Math.ceil(text.length / 4)
33
+ ```
34
+
35
+ This is deterministic and useful for local comparisons. It is not a provider tokenizer.
package/docs/mvp.md ADDED
@@ -0,0 +1,21 @@
1
+ # MVP Scope
2
+
3
+ SotuRail v0.1.0 validates the core foundation:
4
+
5
+ - local workspace creation;
6
+ - cross-platform file scanning with deny rules;
7
+ - progressive file reading;
8
+ - safe tee-stream command execution;
9
+ - raw log recovery;
10
+ - SDD artifact generation;
11
+ - Git-linked memory;
12
+ - prompt-cache-friendly block ordering;
13
+ - honest local metrics.
14
+
15
+ ## Non-goals
16
+
17
+ - No telemetry.
18
+ - No remote service.
19
+ - No native compiled dependencies.
20
+ - No automatic `git push`.
21
+ - No provider cache-hit claims unless metadata is manually imported.
@@ -0,0 +1,52 @@
1
+ # Native Runner
2
+
3
+ SotuRail v0.2.1 keeps TypeScript as the public CLI, policy orchestration, docs and npm distribution layer. Rust is used only for optional hot paths where streaming, lower overhead and binary execution are useful.
4
+
5
+ ## Responsibility Split
6
+
7
+ - TypeScript: CLI commands, config validation, safety policy, workspace manifests, docs, metrics and npm package distribution.
8
+ - Rust: optional reducers and native tee-stream command execution.
9
+
10
+ ## Native Commands
11
+
12
+ - `soturail-native --version`
13
+ - `soturail-native reduce-generic`
14
+ - `soturail-native reduce-git`
15
+ - `soturail-native reduce-test`
16
+ - `soturail-native reduce-json`
17
+ - `soturail-native run --raw-log <path> --summary-json <path> -- <command...>`
18
+
19
+ The native runner spawns a subprocess, tees stdout/stderr to the terminal, writes the same bytes to a raw log and records a compact JSON summary. TypeScript safety checks remain the primary gate, and the Rust binary also refuses obvious destructive command strings when called directly.
20
+
21
+ ## Detection and Fallback
22
+
23
+ The TypeScript CLI checks:
24
+
25
+ 1. `native/soturail-native/target/release/soturail-native`
26
+ 2. `native/soturail-native/target/debug/soturail-native`
27
+ 3. `dist/native/soturail-native`
28
+ 4. `soturail-native` on PATH
29
+
30
+ `--engine auto` falls back to TypeScript when native is missing. `--engine native` fails clearly when native is unavailable.
31
+
32
+ ## Build
33
+
34
+ ```bash
35
+ npm run build # TypeScript only
36
+ npm run build:native # Rust release binary
37
+ npm run build:all # TypeScript + Rust
38
+ ```
39
+
40
+ ## Native Benchmarks
41
+
42
+ ```bash
43
+ npm run build:native
44
+ soturail bench run --engine native
45
+ soturail bench compare-engines
46
+ ```
47
+
48
+ ## Current Limitations
49
+
50
+ - Native binaries are not prebuilt for npm yet.
51
+ - Interactive TTY behavior is best-effort.
52
+ - TypeScript remains the source of truth for workspace manifests and safety prompts.
@@ -0,0 +1,27 @@
1
+ # Prompt Caching
2
+
3
+ SotuRail formats context so stable blocks appear before dynamic session data:
4
+
5
+ 1. `static_header`
6
+ 2. `governance`
7
+ 3. `config`
8
+ 4. `repo_map`
9
+ 5. `approved_specs`
10
+ 6. `approved_memory`
11
+ 7. `dynamic_footer`
12
+
13
+ The cache normalizer writes `.soturail/cache/blocks.jsonl` with block ids, source paths, hashes, stable order and token estimates.
14
+
15
+ ## Dynamic Data
16
+
17
+ Dynamic data must stay after stable blocks:
18
+
19
+ - timestamps;
20
+ - raw ids;
21
+ - command status;
22
+ - recent logs;
23
+ - ephemeral user questions.
24
+
25
+ ## Honesty
26
+
27
+ `estimated_cache_stability_score` is a local estimate. v0.2.0 never claims real provider cache hits unless imported metadata exists.
@@ -0,0 +1,26 @@
1
+ # Visao geral do SotuRail
2
+
3
+ SotuRail e um Context OS local-first para agentes de IA que trabalham com codigo.
4
+
5
+ Ele ajuda a:
6
+
7
+ - indexar o repositorio sem lotar o contexto do modelo;
8
+ - ler arquivos grandes de forma progressiva;
9
+ - executar comandos com uma politica de seguranca;
10
+ - salvar logs brutos recuperaveis;
11
+ - comprimir saidas longas do terminal;
12
+ - separar blocos estaveis de dados dinamicos para prompt caching;
13
+ - manter memoria local ligada ao commit Git atual;
14
+ - comprimir respostas de agentes em modos profissionais;
15
+ - transformar documentos em regras estruturadas e validadores;
16
+ - instalar regras de hooks ou fallback prompt-only para agentes;
17
+ - gerar benchmarks locais reproduziveis;
18
+ - relatar metricas honestas.
19
+
20
+ O comando principal e:
21
+
22
+ ```bash
23
+ soturail
24
+ ```
25
+
26
+ No v0.2.1, os numeros de tokens, reducao e cache sao estimativas locais quando nao ha metadados reais importados. Knowledge-to-Rules e tratado como estruturacao reutilizavel, nao apenas compressao. SotuRail nao inventa acertos reais de cache de provedores.
@@ -0,0 +1,20 @@
1
+ # Public Roadmap
2
+
3
+ SotuRail is early but functional. The public roadmap prioritizes local-first evidence, safety and reproducible measurement.
4
+
5
+ ## Near Term
6
+
7
+ - Polish v0.2.x native hot paths.
8
+ - Improve reducer quality checks.
9
+ - Harden Claude hook templates.
10
+ - Publish clearer benchmark interpretation docs.
11
+
12
+ ## v0.3.0 Direction
13
+
14
+ - MCP server.
15
+ - Tree-sitter repository map.
16
+ - Hardened PDF extraction.
17
+ - Semantic memory with embeddings.
18
+ - Native runner packaging for npm prebuilds.
19
+ - External benchmark comparison docs.
20
+ - Real provider cache metadata import.
@@ -0,0 +1,19 @@
1
+ # Reducers
2
+
3
+ Reducers compress terminal output while preserving the recovery path to raw logs.
4
+
5
+ ## Generic
6
+
7
+ Keeps first and last lines, error-looking lines, warnings, permission failures, timeouts, file paths and repeated-line summaries.
8
+
9
+ ## Git
10
+
11
+ Handles status, diff, log, show and branch output heuristically. It preserves changed files, rename/delete markers, conflict markers and hunk headers.
12
+
13
+ ## Test
14
+
15
+ Handles Vitest, Jest, Mocha, Pytest, Maven Surefire and Gradle test output at a heuristic level. It preserves failing test names, assertions, expected/received summaries, stack traces and file paths.
16
+
17
+ ## JSON TOON Lite
18
+
19
+ Emits a compressed representation with relevant `path: value` lines. It preserves error messages, statuses, ids, file paths, booleans and nulls that affect debugging, while collapsing repetitive arrays and object structure. The reduced representation is clearly labeled when it is not valid JSON.
@@ -0,0 +1,13 @@
1
+ # Release Checklist
2
+
3
+ Before publishing:
4
+
5
+ - [ ] `npm install`
6
+ - [ ] `npm run build`
7
+ - [ ] `npm test`
8
+ - [ ] Verify `soturail --help`
9
+ - [ ] Verify `soturail init` in a clean temp repo
10
+ - [ ] Confirm docs mention limitations honestly
11
+ - [ ] Confirm no telemetry exists
12
+ - [ ] Confirm no `git push` was run automatically
13
+ - [ ] Tag release manually after review
@@ -0,0 +1,15 @@
1
+ # Agent Response Compression
2
+
3
+ `soturail format` compresses verbose AI or documentation output deterministically. It does not call an external LLM.
4
+
5
+ Modes:
6
+
7
+ - `normal` - light cleanup.
8
+ - `concise` - direct technical instructions.
9
+ - `ultra` - maximum command-focused compression.
10
+ - `review` - code-review style grouped by severity.
11
+ - `commit` - Conventional Commit suggestion.
12
+ - `debug` - symptom, cause, fix, verification and next command.
13
+ - `docs` - README/docs-oriented language.
14
+
15
+ The reducer preserves fenced code blocks, shell commands, file paths, line numbers, warnings, security notes and failure information.
package/docs/rules.md ADDED
@@ -0,0 +1,23 @@
1
+ # Rules
2
+
3
+ Extracted rules are written to:
4
+
5
+ - `.soturail/rules/rules.yml`
6
+ - `.soturail/rules/checklist.md`
7
+ - `.soturail/rules/citations.json`
8
+ - `.soturail/rules/validators/`
9
+
10
+ Each rule includes:
11
+
12
+ - id
13
+ - title
14
+ - description
15
+ - source_file
16
+ - source_section
17
+ - severity
18
+ - validation_type
19
+ - suggested_validator_name
20
+ - created_at
21
+ - content_hash
22
+
23
+ `soturail rules check` runs deterministic validators for package metadata, required files, forbidden files, README sections, CI workflow presence and documentation presence when the rule text supports it.
@@ -0,0 +1,32 @@
1
+ # Security Model
2
+
3
+ SotuRail reduces accidental damage from AI-assisted terminal use. It is not a sandbox and does not make untrusted commands safe.
4
+
5
+ ## Blocked by Default
6
+
7
+ - `rm -rf`
8
+ - `sudo`
9
+ - `format`
10
+ - `dd if=`
11
+ - `curl | sh`
12
+ - `wget | sh`
13
+ - `del /s`
14
+ - `git push`
15
+
16
+ ## Unsafe Confirmation
17
+
18
+ Dangerous commands can only run when the exact phrase is supplied:
19
+
20
+ ```text
21
+ I_UNDERSTAND_THIS_CAN_DESTROY_DATA
22
+ ```
23
+
24
+ This is intentionally verbose so accidental bypasses are unlikely.
25
+
26
+ ## Raw Logs
27
+
28
+ Raw command logs remain on disk so compressed summaries can always be audited.
29
+
30
+ ## Limitations
31
+
32
+ SotuRail does not isolate processes, prevent all shell tricks or replace OS permissions. Treat it as a policy and evidence layer.
@@ -0,0 +1,22 @@
1
+ # Spec-Driven Workflow
2
+
3
+ SotuRail specs live under `.soturail/specs/`.
4
+
5
+ ```bash
6
+ soturail spec new "feature idea"
7
+ soturail spec status
8
+ soturail spec validate
9
+ soturail spec task add .soturail/specs/001-feature "Write tests"
10
+ soturail spec task list .soturail/specs/001-feature
11
+ soturail spec task done .soturail/specs/001-feature 1
12
+ ```
13
+
14
+ v0.2.0 specs include:
15
+
16
+ - `constitution.md`
17
+ - `spec.md`
18
+ - `plan.md`
19
+ - `tasks.md`
20
+ - `verification.md`
21
+ - `context-budget.md`
22
+ - `security-impact.md`
package/docs/usage.md ADDED
@@ -0,0 +1,64 @@
1
+ # Usage
2
+
3
+ ## Initialize
4
+
5
+ ```bash
6
+ soturail init
7
+ ```
8
+
9
+ Creates `.soturail/` and starter docs without overwriting existing files.
10
+
11
+ ## Index
12
+
13
+ ```bash
14
+ soturail index
15
+ ```
16
+
17
+ Writes `.soturail/indexes/repo-map.json` and `.soturail/indexes/tree.txt`.
18
+
19
+ ## Read
20
+
21
+ ```bash
22
+ soturail read src/core/file-scanner.ts --query "ignore rules"
23
+ soturail read src/core/file-scanner.ts --full
24
+ ```
25
+
26
+ Files under 150 lines are printed fully. Larger files include the first 15 lines, query matches with margin, the last 10 lines and reversible collapsed markers.
27
+
28
+ ## Run and Expand
29
+
30
+ ```bash
31
+ soturail run npm test
32
+ soturail expand <raw_id>
33
+ ```
34
+
35
+ The runner streams output live, writes the same output to a raw log and prints a compressed summary.
36
+
37
+ ## Specs and Memory
38
+
39
+ ```bash
40
+ soturail spec new "safe command profiles"
41
+ soturail memory add "We block git push by default"
42
+ soturail memory search "git push"
43
+ ```
44
+
45
+ ## Doctor and Stats
46
+
47
+ ```bash
48
+ soturail doctor
49
+ soturail doctor cache
50
+ soturail stats
51
+ ```
52
+
53
+ ## v0.2.x Workflows
54
+
55
+ ```bash
56
+ soturail bench prepare
57
+ soturail bench run --engine ts
58
+ soturail hooks install codex --dry-run
59
+ soturail format README.md --mode concise
60
+ soturail ingest README.md --type docs
61
+ soturail rules check
62
+ soturail native doctor
63
+ soturail bench compare-engines
64
+ ```