seif-cli 0.4.2__tar.gz → 0.5.0__tar.gz

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 (108) hide show
  1. {seif_cli-0.4.2/src/seif_cli.egg-info → seif_cli-0.5.0}/PKG-INFO +24 -15
  2. {seif_cli-0.4.2 → seif_cli-0.5.0}/README.md +23 -14
  3. {seif_cli-0.4.2 → seif_cli-0.5.0}/pyproject.toml +5 -1
  4. {seif_cli-0.4.2 → seif_cli-0.5.0}/src/seif/analysis/stance_detector.py +4 -1
  5. {seif_cli-0.4.2 → seif_cli-0.5.0}/src/seif/cli/cli.py +158 -0
  6. seif_cli-0.5.0/src/seif/cli/setup.py +443 -0
  7. {seif_cli-0.4.2 → seif_cli-0.5.0}/src/seif/cli/wrapper.py +179 -41
  8. seif_cli-0.5.0/src/seif/plugins/__init__.py +0 -0
  9. seif_cli-0.5.0/src/seif/plugins/claude-code/hooks/hooks.json +50 -0
  10. seif_cli-0.5.0/src/seif/plugins/claude-code/scripts/circuit-check.sh +34 -0
  11. seif_cli-0.5.0/src/seif/plugins/claude-code/scripts/circuit-monitor.py +223 -0
  12. seif_cli-0.5.0/src/seif/plugins/claude-code/scripts/classification-gate.sh +141 -0
  13. seif_cli-0.5.0/src/seif/plugins/claude-code/scripts/kernel-seed.py +95 -0
  14. seif_cli-0.5.0/src/seif/plugins/claude-code/scripts/orchestra-probe.py +291 -0
  15. seif_cli-0.5.0/src/seif/plugins/claude-code/scripts/quality-gate.sh +35 -0
  16. seif_cli-0.5.0/src/seif/plugins/claude-code/scripts/session-end.sh +182 -0
  17. seif_cli-0.5.0/src/seif/plugins/claude-code/scripts/session-start.sh +262 -0
  18. seif_cli-0.5.0/src/seif/plugins/claude-code/skills/gate/SKILL.md +18 -0
  19. seif_cli-0.5.0/src/seif/plugins/claude-code/skills/status/SKILL.md +54 -0
  20. seif_cli-0.5.0/src/seif/plugins/claude-code/skills/sync/SKILL.md +17 -0
  21. {seif_cli-0.4.2 → seif_cli-0.5.0/src/seif_cli.egg-info}/PKG-INFO +24 -15
  22. {seif_cli-0.4.2 → seif_cli-0.5.0}/src/seif_cli.egg-info/SOURCES.txt +14 -0
  23. {seif_cli-0.4.2 → seif_cli-0.5.0}/LICENSE +0 -0
  24. {seif_cli-0.4.2 → seif_cli-0.5.0}/MANIFEST.in +0 -0
  25. {seif_cli-0.4.2 → seif_cli-0.5.0}/setup.cfg +0 -0
  26. {seif_cli-0.4.2 → seif_cli-0.5.0}/src/seif/__init__.py +0 -0
  27. {seif_cli-0.4.2 → seif_cli-0.5.0}/src/seif/__main__.py +0 -0
  28. {seif_cli-0.4.2 → seif_cli-0.5.0}/src/seif/analysis/__init__.py +0 -0
  29. {seif_cli-0.4.2 → seif_cli-0.5.0}/src/seif/analysis/physical_constants.py +0 -0
  30. {seif_cli-0.4.2 → seif_cli-0.5.0}/src/seif/analysis/quality_gate.py +0 -0
  31. {seif_cli-0.4.2 → seif_cli-0.5.0}/src/seif/analysis/transcompiler.py +0 -0
  32. {seif_cli-0.4.2 → seif_cli-0.5.0}/src/seif/bridge/__init__.py +0 -0
  33. {seif_cli-0.4.2 → seif_cli-0.5.0}/src/seif/bridge/native_client.py +0 -0
  34. {seif_cli-0.4.2 → seif_cli-0.5.0}/src/seif/bridge/telegram_bot.py +0 -0
  35. {seif_cli-0.4.2 → seif_cli-0.5.0}/src/seif/cli/__init__.py +0 -0
  36. {seif_cli-0.4.2 → seif_cli-0.5.0}/src/seif/cli/__main__.py +0 -0
  37. {seif_cli-0.4.2 → seif_cli-0.5.0}/src/seif/cli/chat.py +0 -0
  38. {seif_cli-0.4.2 → seif_cli-0.5.0}/src/seif/cli/identity.py +0 -0
  39. {seif_cli-0.4.2 → seif_cli-0.5.0}/src/seif/cli/main.py +0 -0
  40. {seif_cli-0.4.2 → seif_cli-0.5.0}/src/seif/cli/resonance_display.py +0 -0
  41. {seif_cli-0.4.2 → seif_cli-0.5.0}/src/seif/cli/serve.py +0 -0
  42. {seif_cli-0.4.2 → seif_cli-0.5.0}/src/seif/cli/serve_v2.py +0 -0
  43. {seif_cli-0.4.2 → seif_cli-0.5.0}/src/seif/constants.py +0 -0
  44. {seif_cli-0.4.2 → seif_cli-0.5.0}/src/seif/context/__init__.py +0 -0
  45. {seif_cli-0.4.2 → seif_cli-0.5.0}/src/seif/context/advisor.py +0 -0
  46. {seif_cli-0.4.2 → seif_cli-0.5.0}/src/seif/context/code_compressor.py +0 -0
  47. {seif_cli-0.4.2 → seif_cli-0.5.0}/src/seif/context/context_bridge.py +0 -0
  48. {seif_cli-0.4.2 → seif_cli-0.5.0}/src/seif/context/context_importer.py +0 -0
  49. {seif_cli-0.4.2 → seif_cli-0.5.0}/src/seif/context/context_manager.py +0 -0
  50. {seif_cli-0.4.2 → seif_cli-0.5.0}/src/seif/context/context_qr.py +0 -0
  51. {seif_cli-0.4.2 → seif_cli-0.5.0}/src/seif/context/cycle.py +0 -0
  52. {seif_cli-0.4.2 → seif_cli-0.5.0}/src/seif/context/file_extractor.py +0 -0
  53. {seif_cli-0.4.2 → seif_cli-0.5.0}/src/seif/context/git_context.py +0 -0
  54. {seif_cli-0.4.2 → seif_cli-0.5.0}/src/seif/context/git_hooks.py +0 -0
  55. {seif_cli-0.4.2 → seif_cli-0.5.0}/src/seif/context/ingest.py +0 -0
  56. {seif_cli-0.4.2 → seif_cli-0.5.0}/src/seif/context/nucleus.py +0 -0
  57. {seif_cli-0.4.2 → seif_cli-0.5.0}/src/seif/context/ref.py +0 -0
  58. {seif_cli-0.4.2 → seif_cli-0.5.0}/src/seif/context/registry.py +0 -0
  59. {seif_cli-0.4.2 → seif_cli-0.5.0}/src/seif/context/seif_io.py +0 -0
  60. {seif_cli-0.4.2 → seif_cli-0.5.0}/src/seif/context/sessions.py +0 -0
  61. {seif_cli-0.4.2 → seif_cli-0.5.0}/src/seif/context/workspace.py +0 -0
  62. {seif_cli-0.4.2 → seif_cli-0.5.0}/src/seif/core/__init__.py +0 -0
  63. {seif_cli-0.4.2 → seif_cli-0.5.0}/src/seif/core/fingerprint.py +0 -0
  64. {seif_cli-0.4.2 → seif_cli-0.5.0}/src/seif/core/resonance_encoding.py +0 -0
  65. {seif_cli-0.4.2 → seif_cli-0.5.0}/src/seif/core/resonance_gate.py +0 -0
  66. {seif_cli-0.4.2 → seif_cli-0.5.0}/src/seif/core/resonance_signal.py +0 -0
  67. {seif_cli-0.4.2 → seif_cli-0.5.0}/src/seif/core/signing.py +0 -0
  68. {seif_cli-0.4.2 → seif_cli-0.5.0}/src/seif/core/timestamping.py +0 -0
  69. {seif_cli-0.4.2 → seif_cli-0.5.0}/src/seif/core/transfer_function.py +0 -0
  70. {seif_cli-0.4.2 → seif_cli-0.5.0}/src/seif/core/triple_gate.py +0 -0
  71. {seif_cli-0.4.2 → seif_cli-0.5.0}/src/seif/data/RESONANCE.json +0 -0
  72. {seif_cli-0.4.2 → seif_cli-0.5.0}/src/seif/data/__init__.py +0 -0
  73. {seif_cli-0.4.2 → seif_cli-0.5.0}/src/seif/data/defaults/__init__.py +0 -0
  74. {seif_cli-0.4.2 → seif_cli-0.5.0}/src/seif/data/defaults/circuit-recovery-v1.seif +0 -0
  75. {seif_cli-0.4.2 → seif_cli-0.5.0}/src/seif/data/defaults/definitions-v1.seif +0 -0
  76. {seif_cli-0.4.2 → seif_cli-0.5.0}/src/seif/data/defaults/ise-dissonance-v1.seif +0 -0
  77. {seif_cli-0.4.2 → seif_cli-0.5.0}/src/seif/data/defaults/multi-agent-sync-v1.seif +0 -0
  78. {seif_cli-0.4.2 → seif_cli-0.5.0}/src/seif/data/defaults/onboarding.seif +0 -0
  79. {seif_cli-0.4.2 → seif_cli-0.5.0}/src/seif/data/defaults/partial-attention-axiom-v1.seif +0 -0
  80. {seif_cli-0.4.2 → seif_cli-0.5.0}/src/seif/data/defaults/seif-cycle-v1.seif +0 -0
  81. {seif_cli-0.4.2 → seif_cli-0.5.0}/src/seif/data/defaults/seif-os-architecture-v1.seif +0 -0
  82. {seif_cli-0.4.2 → seif_cli-0.5.0}/src/seif/data/defaults/triad-convergence-v1.seif +0 -0
  83. {seif_cli-0.4.2 → seif_cli-0.5.0}/src/seif/data/paths.py +0 -0
  84. {seif_cli-0.4.2 → seif_cli-0.5.0}/src/seif/security/__init__.py +0 -0
  85. {seif_cli-0.4.2 → seif_cli-0.5.0}/src/seif/security/mode.py +0 -0
  86. {seif_cli-0.4.2 → seif_cli-0.5.0}/src/seif_cli.egg-info/dependency_links.txt +0 -0
  87. {seif_cli-0.4.2 → seif_cli-0.5.0}/src/seif_cli.egg-info/entry_points.txt +0 -0
  88. {seif_cli-0.4.2 → seif_cli-0.5.0}/src/seif_cli.egg-info/requires.txt +0 -0
  89. {seif_cli-0.4.2 → seif_cli-0.5.0}/src/seif_cli.egg-info/top_level.txt +0 -0
  90. {seif_cli-0.4.2 → seif_cli-0.5.0}/tests/test_advisor.py +0 -0
  91. {seif_cli-0.4.2 → seif_cli-0.5.0}/tests/test_canonical_inputs.py +0 -0
  92. {seif_cli-0.4.2 → seif_cli-0.5.0}/tests/test_code_compressor.py +0 -0
  93. {seif_cli-0.4.2 → seif_cli-0.5.0}/tests/test_collaborative_seif.py +0 -0
  94. {seif_cli-0.4.2 → seif_cli-0.5.0}/tests/test_context_qr.py +0 -0
  95. {seif_cli-0.4.2 → seif_cli-0.5.0}/tests/test_context_repo.py +0 -0
  96. {seif_cli-0.4.2 → seif_cli-0.5.0}/tests/test_git_context.py +0 -0
  97. {seif_cli-0.4.2 → seif_cli-0.5.0}/tests/test_git_hooks.py +0 -0
  98. {seif_cli-0.4.2 → seif_cli-0.5.0}/tests/test_init.py +0 -0
  99. {seif_cli-0.4.2 → seif_cli-0.5.0}/tests/test_quality_gate.py +0 -0
  100. {seif_cli-0.4.2 → seif_cli-0.5.0}/tests/test_ref.py +0 -0
  101. {seif_cli-0.4.2 → seif_cli-0.5.0}/tests/test_registry.py +0 -0
  102. {seif_cli-0.4.2 → seif_cli-0.5.0}/tests/test_resonance_gate.py +0 -0
  103. {seif_cli-0.4.2 → seif_cli-0.5.0}/tests/test_seif_io.py +0 -0
  104. {seif_cli-0.4.2 → seif_cli-0.5.0}/tests/test_stance_detector.py +0 -0
  105. {seif_cli-0.4.2 → seif_cli-0.5.0}/tests/test_transcompiler.py +0 -0
  106. {seif_cli-0.4.2 → seif_cli-0.5.0}/tests/test_transfer_function.py +0 -0
  107. {seif_cli-0.4.2 → seif_cli-0.5.0}/tests/test_triple_gate.py +0 -0
  108. {seif_cli-0.4.2 → seif_cli-0.5.0}/tests/test_workspace.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: seif-cli
3
- Version: 0.4.2
3
+ Version: 0.5.0
4
4
  Summary: Measure AI output quality, protect sensitive data, watch your AI environment resonate. Quality Gate, Classification, Sentinel & Auto-Healing, SEIF OS.
5
5
  Author: André Cunha Antero de Carvalho
6
6
  License: CC-BY-NC-SA-4.0
@@ -184,29 +184,38 @@ open https://seifprotocol.com/auth
184
184
 
185
185
  ```bash
186
186
  pip install seif-cli
187
+ cd your-project
188
+ seif
189
+ ```
187
190
 
188
- # Works immediately (no backend)
189
- seif --quality-gate "Python 3.11 added tomllib" --role ai
190
- seif --gate "SELECT * FROM users WHERE api_key = 'sk-...'"
191
- seif --encode "any text"
191
+ That's it. One command. SEIF detects that your project is new, initializes `.seif/` context, installs Claude Code hooks, and launches Claude — all automatically.
192
192
 
193
- # With SEIF OS running
194
- seif serve --v2
195
- seif --init # scan project, generate .seif/
196
- seif --sync # re-sync git context
197
- ```
193
+ On subsequent runs, `seif` sees everything is configured and launches Claude directly.
194
+
195
+ ### What happens
196
+
197
+ | Event | What SEIF does |
198
+ |-------|---------------|
199
+ | Session starts | Loads `.seif/` context — your AI remembers |
200
+ | AI writes code | Classification gate blocks credential leaks |
201
+ | AI finishes writing | Quality gate measures stance (GROUNDED vs DRIFT) |
202
+ | You type `/gate` | Measures any text (Grade A-F) |
203
+ | You type `/sync` | Re-syncs project context |
204
+ | You type `/status` | Shows loaded modules and integration health |
198
205
 
199
206
  ---
200
207
 
201
- ## Claude Code Plugin
208
+ ## Claude Code Integration
202
209
 
203
210
  ```bash
204
- cp -r plugins/claude-code/skills/* .claude/skills/
211
+ seif setup claude-code # one command — installs everything
212
+ seif setup --status # verify integration
213
+ seif setup --uninstall # clean removal
205
214
  ```
206
215
 
207
- - **Session start**: loads `.seif/` context automatically
208
- - **Pre-write**: blocks classified data from being written outside `.seif/`
209
- - **Slash commands**: `/gate`, `/sync`, `/status`
216
+ Installs **hooks** (session lifecycle, classification gate, quality gate) and **skills** (`/gate`, `/sync`, `/status`) into Claude Code. Works globally or per-project (`--project`).
217
+
218
+ > **Full guide**: [docs/QUICKSTART.md](docs/QUICKSTART.md) everything a developer needs to get started.
210
219
 
211
220
  ---
212
221
 
@@ -140,29 +140,38 @@ open https://seifprotocol.com/auth
140
140
 
141
141
  ```bash
142
142
  pip install seif-cli
143
+ cd your-project
144
+ seif
145
+ ```
143
146
 
144
- # Works immediately (no backend)
145
- seif --quality-gate "Python 3.11 added tomllib" --role ai
146
- seif --gate "SELECT * FROM users WHERE api_key = 'sk-...'"
147
- seif --encode "any text"
147
+ That's it. One command. SEIF detects that your project is new, initializes `.seif/` context, installs Claude Code hooks, and launches Claude — all automatically.
148
148
 
149
- # With SEIF OS running
150
- seif serve --v2
151
- seif --init # scan project, generate .seif/
152
- seif --sync # re-sync git context
153
- ```
149
+ On subsequent runs, `seif` sees everything is configured and launches Claude directly.
150
+
151
+ ### What happens
152
+
153
+ | Event | What SEIF does |
154
+ |-------|---------------|
155
+ | Session starts | Loads `.seif/` context — your AI remembers |
156
+ | AI writes code | Classification gate blocks credential leaks |
157
+ | AI finishes writing | Quality gate measures stance (GROUNDED vs DRIFT) |
158
+ | You type `/gate` | Measures any text (Grade A-F) |
159
+ | You type `/sync` | Re-syncs project context |
160
+ | You type `/status` | Shows loaded modules and integration health |
154
161
 
155
162
  ---
156
163
 
157
- ## Claude Code Plugin
164
+ ## Claude Code Integration
158
165
 
159
166
  ```bash
160
- cp -r plugins/claude-code/skills/* .claude/skills/
167
+ seif setup claude-code # one command — installs everything
168
+ seif setup --status # verify integration
169
+ seif setup --uninstall # clean removal
161
170
  ```
162
171
 
163
- - **Session start**: loads `.seif/` context automatically
164
- - **Pre-write**: blocks classified data from being written outside `.seif/`
165
- - **Slash commands**: `/gate`, `/sync`, `/status`
172
+ Installs **hooks** (session lifecycle, classification gate, quality gate) and **skills** (`/gate`, `/sync`, `/status`) into Claude Code. Works globally or per-project (`--project`).
173
+
174
+ > **Full guide**: [docs/QUICKSTART.md](docs/QUICKSTART.md) everything a developer needs to get started.
166
175
 
167
176
  ---
168
177
 
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "seif-cli"
7
- version = "0.4.2"
7
+ version = "0.5.0"
8
8
  description = "Measure AI output quality, protect sensitive data, watch your AI environment resonate. Quality Gate, Classification, Sentinel & Auto-Healing, SEIF OS."
9
9
  readme = "README.md"
10
10
  license = {text = "CC-BY-NC-SA-4.0"}
@@ -85,6 +85,10 @@ seif = [
85
85
  "py.typed",
86
86
  "data/RESONANCE.json",
87
87
  "data/defaults/*.seif",
88
+ "plugins/claude-code/hooks/*.json",
89
+ "plugins/claude-code/scripts/*.sh",
90
+ "plugins/claude-code/scripts/*.py",
91
+ "plugins/claude-code/skills/*/SKILL.md",
88
92
  ]
89
93
 
90
94
  [tool.pytest.ini_options]
@@ -69,6 +69,9 @@ VERIFIABLE_PATTERNS = [
69
69
  r'\b(?:theorem|proof|exhaustive|brute.?force)\b',
70
70
  r'(?:ISE|IAE|ITAE|RLC|PCB|BOM|DRC)',
71
71
  r'formal.?symbolic',
72
+ r'\b\w+[_]\w+\s*=', # variable_name = (e.g. f_peak = f_n/2)
73
+ r'\b[A-Z]\([a-z]\)', # H(s), F(x), G(s)
74
+ r'property|unique|halving', # mathematical property language
72
75
  ]
73
76
 
74
77
  # Patterns that indicate metaphorical/interpretive drift
@@ -95,7 +98,7 @@ def analyze(text: str) -> StanceAnalysis:
95
98
  This does NOT judge the truth of claims. It measures the RATIO of
96
99
  verifiable to interpretive content, enabling informed reading.
97
100
  """
98
- sentences = [s.strip() for s in re.split(r'[.!?\n]', text) if len(s.strip()) > 10]
101
+ sentences = [s.strip() for s in re.split(r'(?<![0-9])[.!?]|\n', text) if len(s.strip()) > 10]
99
102
 
100
103
  if len(sentences) < 2:
101
104
  return StanceAnalysis(
@@ -1056,8 +1056,14 @@ def cmd_init(root_path: str, author: str, context_repo: str = None,
1056
1056
  except Exception as e:
1057
1057
  print(f"\n (owner modules: {e})")
1058
1058
 
1059
+ # Generate CLAUDE.md for Claude Code integration
1060
+ _generate_claude_md(root, project_name=author)
1061
+ if (root / "CLAUDE.md").exists():
1062
+ print(f"\nCLAUDE.md: generated (Claude Code loads this automatically)")
1063
+
1059
1064
  print()
1060
1065
  print("Done. Next steps:")
1066
+ print(" seif setup claude-code — install hooks + skills")
1061
1067
  print(" seif --quality-gate \"text\" — measure any text")
1062
1068
  if context_repo:
1063
1069
  print(f" seif --sync --context-repo {context_repo} — re-sync")
@@ -1069,6 +1075,158 @@ def cmd_init(root_path: str, author: str, context_repo: str = None,
1069
1075
  print(" seif --workspace --ingest daily.txt — route to all projects")
1070
1076
 
1071
1077
 
1078
+
1079
+ def _generate_claude_md(root: Path, project_name: str = ""):
1080
+ """Generate CLAUDE.md with operational SEIF instructions for Claude Code.
1081
+
1082
+ This is the score that the maestro reads. Without it, the orchestra
1083
+ plays random notes. With it, every instrument knows its part.
1084
+ """
1085
+ claude_md = root / "CLAUDE.md"
1086
+
1087
+ # Don't overwrite if it already has SEIF section
1088
+ if claude_md.exists():
1089
+ existing = claude_md.read_text(encoding="utf-8")
1090
+ if "S.E.I.F." in existing or "seif" in existing.lower()[:200]:
1091
+ return False
1092
+
1093
+ name = project_name or root.name
1094
+ has_seif = (root / ".seif").is_dir()
1095
+
1096
+ lines = []
1097
+ lines.append(f"# {name}")
1098
+ lines.append("")
1099
+
1100
+ lines.append("## S.E.I.F. Protocol — Operational Instructions")
1101
+ lines.append("")
1102
+ lines.append("This project uses S.E.I.F. for persistent context, quality measurement,")
1103
+ lines.append("and data classification. These are not descriptions — they are instructions")
1104
+ lines.append("you MUST follow during this session.")
1105
+ lines.append("")
1106
+
1107
+ # -- Session lifecycle --
1108
+ lines.append("### Session Lifecycle")
1109
+ lines.append("")
1110
+ lines.append("You are the **writer** in this session. Follow this lifecycle:")
1111
+ lines.append("")
1112
+ lines.append("#### 1. SESSION START (do this NOW)")
1113
+ if has_seif:
1114
+ lines.append("- Read `.seif/mapper.json` — load top 5 modules by relevance")
1115
+ lines.append("- Read `.seif/config.json` — check autonomous_context and session_lifecycle")
1116
+ lines.append("- Check `.seif/sessions/` for open sessions — resume if one exists")
1117
+ lines.append("- If no open session, create one:")
1118
+ lines.append(" ```bash")
1119
+ lines.append(' seif --session create --session-name $(date +%Y-%m-%d)-<topic> --author claude --session-message "<purpose>"')
1120
+ lines.append(" ```")
1121
+ else:
1122
+ lines.append("- No `.seif/` found. Suggest running `seif --init` to the user.")
1123
+ lines.append("")
1124
+
1125
+ lines.append("#### 2. DURING SESSION — Contribute at milestones")
1126
+ lines.append("- After significant decisions, deliverables, or discoveries:")
1127
+ lines.append(" ```bash")
1128
+ lines.append(' seif --session contribute --session-name <name> --author claude --session-message "<what happened>"')
1129
+ lines.append(" ```")
1130
+ lines.append("- Contribute at natural milestones, not after every tool call")
1131
+ lines.append("- If you create persistent knowledge (a pattern, a decision, feedback),")
1132
+ lines.append(" persist it to `.seif/` — not just in conversation memory")
1133
+ lines.append("")
1134
+
1135
+ lines.append("#### 3. SESSION END — Full Circle ritual")
1136
+ lines.append("Before the conversation ends, you MUST complete the closure ritual:")
1137
+ lines.append("")
1138
+ lines.append("1. **CHECKPOINT** — Summarize what was done")
1139
+ lines.append("2. **AUDIT** — Verify `.seif/` integrity: no orphans, no ghosts, hashes valid")
1140
+ lines.append(" ```bash")
1141
+ lines.append(" seif --autonomous status")
1142
+ lines.append(" ```")
1143
+ lines.append("3. **MEDITATE** — Run quality gate on your key contributions:")
1144
+ lines.append(" ```bash")
1145
+ lines.append(' seif --quality-gate "<your most important output this session>" --role ai')
1146
+ lines.append(" ```")
1147
+ lines.append("4. **ABSORB** — Persist any observations for the next session")
1148
+ lines.append("5. **CIRCLE** — Close the session:")
1149
+ lines.append(" ```bash")
1150
+ lines.append(" seif --session close --session-name <name> --author claude")
1151
+ lines.append(" ```")
1152
+ lines.append("")
1153
+
1154
+ # -- Quality Gate --
1155
+ lines.append("### Quality Gate — How to use it")
1156
+ lines.append("")
1157
+ lines.append("The quality gate measures your output on two axes:")
1158
+ lines.append("- **Stance**: GROUNDED (verifiable) vs DRIFT (speculative)")
1159
+ lines.append("- **Grade**: A (excellent) to F (ungrounded)")
1160
+ lines.append("")
1161
+ lines.append("Rules:")
1162
+ lines.append("- When you make a factual claim, it must be verifiable")
1163
+ lines.append("- Distinguish clearly between verified facts and interpretive claims")
1164
+ lines.append("- If you don't know something, say so — DRIFT is detectable")
1165
+ lines.append("- After significant writes, the PostToolUse hook measures automatically")
1166
+ lines.append('- You can self-check: `seif --quality-gate "<text>" --role ai`')
1167
+ lines.append("")
1168
+
1169
+ # -- Classification --
1170
+ lines.append("### Classification Gate — Data protection")
1171
+ lines.append("")
1172
+ lines.append("Content is classified as PUBLIC, INTERNAL, or CONFIDENTIAL.")
1173
+ lines.append("")
1174
+ lines.append("Rules:")
1175
+ lines.append("- NEVER write CONFIDENTIAL content to files outside `.seif/`")
1176
+ lines.append("- Keywords that auto-escalate to CONFIDENTIAL: password, token, credential,")
1177
+ lines.append(" api_key, secret, CVE, private key, Bearer")
1178
+ lines.append("- Classification only escalates, never downgrades")
1179
+ lines.append("- The PreToolUse hook blocks violations automatically, but you should")
1180
+ lines.append(" self-monitor and avoid even attempting to write sensitive data")
1181
+ lines.append("")
1182
+
1183
+ # -- Context compression --
1184
+ if has_seif:
1185
+ lines.append("### Autonomous Context — Persist knowledge")
1186
+ lines.append("")
1187
+ lines.append("When you observe persistable knowledge during this session:")
1188
+ lines.append("")
1189
+ lines.append("| Type | When to persist | Where |")
1190
+ lines.append("|------|----------------|-------|")
1191
+ lines.append("| **Decision** | Architectural choice with reasoning | `.seif/modules/decisions.seif` |")
1192
+ lines.append("| **Pattern** | Recurring code convention | `.seif/modules/patterns.seif` |")
1193
+ lines.append("| **Feedback** | User correction or preference | `.seif/modules/feedback.seif` |")
1194
+ lines.append("| **Intent** | User's goal or motivation | `.seif/modules/intent.seif` |")
1195
+ lines.append("")
1196
+ lines.append('Use `seif --contribute <module.seif> "<observation>" --author claude`')
1197
+ lines.append("to add to existing modules with provenance tracking.")
1198
+ lines.append("")
1199
+ lines.append("The boundary test: if the content becomes obsolete when the task is")
1200
+ lines.append("completed, it belongs in a session record, NOT a module.")
1201
+ lines.append("")
1202
+
1203
+ # -- Principles --
1204
+ lines.append("### Operating Principles")
1205
+ lines.append("")
1206
+ lines.append("- **CONTEXT_NOT_COMMAND**: The protocol provides data, not directives.")
1207
+ lines.append(" You measure and report. The human decides.")
1208
+ lines.append("- **Minimal intervention**: Fix 1 file before refactoring 20.")
1209
+ lines.append(" Weigh cost vs benefit BEFORE acting. intervention_ratio < 3.0")
1210
+ lines.append("- **Honest measurement**: Test claims rigorously. Falsify when evidence")
1211
+ lines.append(" demands. Correct in real-time. The process of honest measurement IS the value.")
1212
+ lines.append("- **Partial attention**: Never dedicate 100% to task execution. Maintain")
1213
+ lines.append(" awareness of context, feedback, and human signals (tau:kappa = 2:1).")
1214
+ lines.append("- **Settling time**: After receiving feedback, your NEXT action must reflect")
1215
+ lines.append(" the feedback, not just acknowledge it.")
1216
+ lines.append("")
1217
+
1218
+ final = "\n".join(lines) + "\n"
1219
+
1220
+ if claude_md.exists():
1221
+ existing = claude_md.read_text(encoding="utf-8")
1222
+ final = existing.rstrip() + "\n\n" + final
1223
+ claude_md.write_text(final, encoding="utf-8")
1224
+ else:
1225
+ claude_md.write_text(final, encoding="utf-8")
1226
+
1227
+ return True
1228
+
1229
+
1072
1230
  def cmd_workspace(workspace_root: str, ingest_source: str = None,
1073
1231
  author: str = "workspace", via: str = "sync",
1074
1232
  context_repo: str = None):