MVP 0.93 - stabile, aber Writing Profile ohne erkennbaren Nutzen
This commit is contained in:
1 parent
53b1eff833
commit
f17b3083e8
56 files changed
+5366
-784
No files matched your search
+30
-4
@@ -27,6 +27,7 @@ _PROMPT_COLUMNS = {
|
||||
"output_schema_json": "TEXT",
|
||||
"required_feature": "TEXT NOT NULL DEFAULT 'ai_calls'",
|
||||
"default_template": "TEXT NOT NULL DEFAULT ''",
|
||||
"seed_revision": "TEXT NOT NULL DEFAULT ''",
|
||||
"sort_order": "INTEGER NOT NULL DEFAULT 0",
|
||||
"updated": "TEXT NOT NULL DEFAULT (datetime('now'))",
|
||||
}
|
||||
@@ -62,6 +63,16 @@ _WRITING_VERSION_COLUMNS = {
|
||||
_JOURNAL_DAY_COLUMNS = {
|
||||
"scratch_json": "TEXT NOT NULL DEFAULT '[]'",
|
||||
}
|
||||
_IDENTITY_MAPPING_COLUMNS = {
|
||||
"canonical_label": "TEXT NOT NULL DEFAULT ''",
|
||||
"entity_type": "TEXT NOT NULL DEFAULT 'PERSON'",
|
||||
"status": "TEXT NOT NULL DEFAULT 'legacy_review_required'",
|
||||
"origin": "TEXT NOT NULL DEFAULT 'legacy_auto'",
|
||||
"aliases_json": "TEXT NOT NULL DEFAULT '[]'",
|
||||
# SQLite ALTER TABLE cannot use datetime('now'); backfill in migrate_legacy_identity_rows.
|
||||
"updated": "TEXT NOT NULL DEFAULT ''",
|
||||
"confirmed_at": "TEXT",
|
||||
}
|
||||
|
||||
|
||||
def _connect() -> sqlite3.Connection:
|
||||
@@ -148,10 +159,16 @@ def _seed_platform(conn: sqlite3.Connection) -> None:
|
||||
|
||||
|
||||
def _seed_prompts(conn: sqlite3.Connection) -> None:
|
||||
"""Prompts come from JSON/DB, never from Python string literals."""
|
||||
"""Prompts come from JSON/DB, never from Python string literals.
|
||||
|
||||
Untouched system prompts (template == default_template) receive the seed.
|
||||
Independently edited prompts keep their template; only default_template and
|
||||
seed_revision are refreshed so Reset-to-default stays possible.
|
||||
"""
|
||||
items = json.loads(PROMPTS_SEED_PATH.read_text(encoding="utf-8"))
|
||||
for item in items:
|
||||
template = item.get("template") or ""
|
||||
revision = item.get("seed_revision") or ""
|
||||
existing = row_to_dict(
|
||||
conn.execute("SELECT * FROM ai_prompts WHERE slug = ?", (item["slug"],)).fetchone()
|
||||
)
|
||||
@@ -160,8 +177,8 @@ def _seed_prompts(conn: sqlite3.Connection) -> None:
|
||||
"""
|
||||
INSERT INTO ai_prompts
|
||||
(id, slug, name, description, category, prompt_type, template,
|
||||
required_feature, is_system_default, default_template)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, 1, ?)
|
||||
required_feature, is_system_default, default_template, seed_revision)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, 1, ?, ?)
|
||||
""",
|
||||
(
|
||||
item["id"],
|
||||
@@ -173,6 +190,7 @@ def _seed_prompts(conn: sqlite3.Connection) -> None:
|
||||
template,
|
||||
item.get("required_feature") or "ai_calls",
|
||||
template,
|
||||
revision,
|
||||
),
|
||||
)
|
||||
continue
|
||||
@@ -182,6 +200,7 @@ def _seed_prompts(conn: sqlite3.Connection) -> None:
|
||||
UPDATE ai_prompts
|
||||
SET name = ?, description = ?, category = ?, prompt_type = ?,
|
||||
required_feature = ?, is_system_default = 1, default_template = ?,
|
||||
seed_revision = ?,
|
||||
template = CASE WHEN ? THEN ? ELSE template END,
|
||||
updated = datetime('now')
|
||||
WHERE slug = ?
|
||||
@@ -193,6 +212,7 @@ def _seed_prompts(conn: sqlite3.Connection) -> None:
|
||||
item.get("prompt_type") or "base",
|
||||
item.get("required_feature") or "ai_calls",
|
||||
template,
|
||||
revision,
|
||||
1 if untouched else 0,
|
||||
template,
|
||||
item["slug"],
|
||||
@@ -421,12 +441,12 @@ def init_db() -> None:
|
||||
with get_db() as conn:
|
||||
conn.executescript(schema)
|
||||
_seed_platform(conn)
|
||||
_ensure_columns(conn, "ai_prompts", _PROMPT_COLUMNS)
|
||||
_seed_prompts(conn)
|
||||
from provider_settings import seed_provider_settings
|
||||
|
||||
seed_provider_settings(conn)
|
||||
_ensure_columns(conn, "profiles", _PROFILE_COLUMNS)
|
||||
_ensure_columns(conn, "ai_prompts", _PROMPT_COLUMNS)
|
||||
_ensure_columns(conn, "conversations", _CONVERSATION_COLUMNS)
|
||||
_ensure_columns(conn, "journal_days", _JOURNAL_DAY_COLUMNS)
|
||||
_ensure_columns(conn, "writing_profiles", _WRITING_PROFILE_COLUMNS)
|
||||
@@ -436,6 +456,10 @@ def init_db() -> None:
|
||||
_ensure_columns(conn, "writing_profile_versions", _WRITING_VERSION_COLUMNS)
|
||||
migrate_journal_source_refs(conn)
|
||||
_migrate_writing_profile_shell(conn)
|
||||
_ensure_columns(conn, "identity_mappings", _IDENTITY_MAPPING_COLUMNS)
|
||||
from identity_store import migrate_legacy_identity_rows
|
||||
|
||||
migrate_legacy_identity_rows(conn)
|
||||
_mark(conn, "001_frame")
|
||||
_mark(conn, "002_platform")
|
||||
_mark(conn, "003_dialogue_memory")
|
||||
@@ -448,6 +472,8 @@ def init_db() -> None:
|
||||
_mark(conn, "010_profile_governance")
|
||||
_mark(conn, "011_profile_review")
|
||||
_mark(conn, "012_profile_shell")
|
||||
_mark(conn, "013_journal_generate_narration")
|
||||
_mark(conn, "014_identity_registry")
|
||||
from writing_profile_store import bootstrap_from_existing
|
||||
|
||||
bootstrap_from_existing()
|
||||
Reference in new issue
Block a user