Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 21 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,43 @@
![OpenAI Compatible](https://img.shields.io/badge/API-OpenAI--compatible-111827.svg)
![Tests](https://github.com/makeitdouble/jin_core/actions/workflows/tests.yml/badge.svg)

**JIN Core** is a local-first AI orchestration runtime. Instead of treating models as simple stateless chat boxes, it splits them into dedicated runtime roles (reasoning, service, translation) inside a single, seamless browser interface — with no frontend build step required.
**JIN Core Engine** is a local AI runtime for OpenAI-compatible models with visible memory, visible reasoning traces, and inspectable session state.

### 3-Layer Memory
JIN doesn't just store logs. It uses short-term continuity to dynamically guide conversation strategy:
JIN uses short-term continuity to dynamically guide conversation strategy:

* **L1 (Live Facts):** Actionable session state kept in active process memory.
* **L2 (Patterns):** Tracks interaction loops and repetition counters to adapt prompts on the fly.
* **L3 (Digest):** Compressed session snapshots serialized to browser `localStorage` and replayed on reconnect.

*Every memory update is captured as a versioned snapshot with diff highlights, fully inspectable in the right-side timeline panel.*

## UI Preview

### Runtime Workspace

![JIN Core Engine runtime UI](ui/static/images/jin-core-redesign.jpg)

![highlight](ui/static/images/highlight.png)
Main runtime view: chat, live reasoning, telemetry, and inspectable memory panels in one browser workspace.

### Think Citations

![Think citation highlighting](ui/static/images/think-highlight.jpg)

Think citation highlighting shows where reasoning quotes rules, runtime memory, or restored session context.

### Memory Timeline

![Runtime memory snapshot timeline](ui/static/images/runtime-highlight.png)

Runtime memory snapshots can be stepped through visually, with new or changed facts highlighted in the sidebar.

## Capabilities

- A chat room that feels alive: answers stream in as they are written, thinking stays visually separate from the final reply, and you can stop a generation the moment it drifts.
- A visible short-term memory: JIN keeps a compact sense of what this session is about, what changed, and what still feels unresolved.
- A memory timeline you can inspect: step through snapshots and see which facts or patterns were added instead of guessing what the assistant remembered.
- Citation highlighting inside think blocks: rule fragments, runtime memory, and restored session context are softly highlighted after a thinking block completes, then reappear on hover.
- A calmer loop breaker: when the conversation starts repeating itself, JIN can notice the pattern and change strategy instead of giving the same polite answer again.
- A built-in search move: the model can ask the runtime to search, then answer from trusted results without dumping raw tool syntax into the chat.
- A session save and restore path: saying something like "save the session" or "that's all for today" triggers a compact L3 memory digest. The browser stores it locally and replays it on reconnect so the next session starts from context rather than blank slate.
Expand Down Expand Up @@ -59,6 +75,8 @@ The memory layer can also surface compact pattern signals. When the session star

Each memory update is also stored as a per-session snapshot. The UI can step backward and forward through those snapshots, replaying lightweight diff highlights so the user can see which memory keys or values were added or changed during the conversation.

Completed thinking blocks are also scanned for direct citations from trusted prompt context. Rule matches, indexed runtime-memory matches, and restored session-memory matches are highlighted with separate colors so the user can see which injected source shaped the reasoning without interrupting streaming.

If generation is aborted, the runtime captures the partial answer and schedules an interrupted memory update. The memory summarizer is instructed to mark the turn as incomplete and not treat it as resolved.

When the user signals the end of a session — explicitly or through natural closing phrases — the brain emits a `REMEMBER_SESSION` action. The runtime builds a compact L3 digest from the current snapshot history and sends it to the browser for local storage. On the next connection, the browser sends the digest back as part of the bootstrap payload and the runtime injects it as trusted session context before the first turn.
Expand Down Expand Up @@ -531,8 +549,6 @@ The frontend uses vanilla JavaScript and Tailwind from CDN. The current input be

The following capabilities are planned but not yet implemented.

**Think-block rule citation highlighting.** After a thinking block completes, the UI scans the text for phrases matching known injected prompt sections (core identity, mode rules, runtime memory, session memory). Matched fragments are highlighted with a soft color; hovering shows a tooltip with the source name, type, layer, and full rule text. This makes prompt influence visible during debugging without affecting the streaming display.

**Long-term facts layer (L4).** A cross-session key-fact store extracted from completed turns by the service model, stored as JSON, and retrieved via keyword scoring before each brain call. Facts carry category, relevance, confidence, and mention count. A deduplication pass prevents drift from accumulating near-duplicate entries. The top-N retrieved facts are injected into the brain prompt as low-priority background context. No vector search or embedding index; heuristic scoring only for MVP.

**User and JIN (LX layer) profiles.** A periodic distillation of session snapshots into two versioned JSON files: `user_profile.json` (stable preferences, recurring themes, friction points, open projects) and `jin_profile.json` (emergent behavioral biases, voice tendencies, avoidances). Profiles are built from snapshot archives in batches, not in real time. They are injected as soft background context, not as hard identity constraints. Old profile versions are kept for rollback.
Expand Down
30 changes: 30 additions & 0 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@
from runtime.behavior_contract import (
get_behavior_contract,
)
from utils.rule_citations import (
get_rule_citation_registry,
)

STATUS_CHECK_TIMEOUT = getattr(
config,
Expand Down Expand Up @@ -297,6 +300,33 @@ async def api_behavior_contract():
return get_behavior_contract()


@app.get("/api/debug/rule-citations")
async def api_debug_rule_citations():

enabled = bool(
getattr(
config,
"DEBUG_RULE_CITATIONS",
True,
)
)

if not enabled:
return {
"enabled": False,
"version": "disabled",
"fragmentCount": 0,
"fragments": [],
}

registry = get_rule_citation_registry()

return {
"enabled": True,
**registry,
}


# ---------------------------------------------------------
# DEV ENTRYPOINT
# ---------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion config.example.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
USE_SERVICE_AS_BRAIN = True
TRANSLATION_ENABLED = False
TRANSLATE_RESPONSE = False
DEBUG_RULE_CITATIONS = True

CHAT_ENDPOINT = "/v1/chat/completions"
MODELS_ENDPOINT = "/v1/models"
Expand Down Expand Up @@ -78,7 +79,6 @@

SEARCH_TIMEOUT = 100.0


# ---------------------------------------------------------
# TRANSLATOR MODEL
# ---------------------------------------------------------
Expand Down
Binary file added ui/static/images/think-highlight.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading