text
stringlengths
185
73.3k
repo
stringlengths
7
100
path
stringlengths
4
146
language
stringclasses
7 values
hash
stringlengths
16
16
score
float64
7
8.5
stars
int64
0
237k
#!/usr/bin/env python3 """turn_reader.py — read EVERY assistant message shown since the last human turn (row 482). Moved out of hooks/register-judge.py so every Stop-hook scan that owes the whole turn (not just its last message) can share one reader: register-judge.py, scissors-scan.py, hedge-scan.py. A hook that read...
happysasha18/live-spec
hooks/turn_reader.py
.py
ac1e870d7b61c218
7.15
1
"""`Cmd+クリック` で何を起こすか(D-1 / D-2)。 仕様書 §5.2 が約束していた「リンクは `Cmd+クリック` で既定ブラウザを開く」 「タグはクリックで絞り込む」を実現するための判定。 **開く先はここで絞る。** 本文は手で編集できるので、`javascript:` や `file:` を書いておいて踏ませることができてしまう。判定を UI 側に散らすと 抜け道ができるため、1 か所に閉じ込める。 `core/` にあるので PySide6 に依存しない(R3)。 """ from dataclasses import dataclass from enum import Enum, auto f...
Toshiaki0315/hitofude
hitofude/core/activation.py
.py
329bd5c3de4065ce
7.15
1
"""コードフェンスの言語補完(ユーザー要望)。 候補の源は Pygments の別名一覧。色付け(`code_tokens.tokenize`)と同じ `get_lexer_by_name` の名前空間なので、**補完に出た名前は必ず色が付く**。 `core/` にあるので PySide6 に依存しない(R3)。発火位置の判定と絞り込みは 純関数で、エディタはこれを呼ぶだけ。 """ import re from functools import cache from pygments.lexers import get_all_lexers # フェンス開始行の打ちかけ。行頭の ``` 以降に言語トークンが続き、 #...
Toshiaki0315/hitofude
hitofude/core/code_langs.py
.py
097bf78ddd5b5342
7.15
1
"""コードの字句解析(B-6 / 画面用)。 書き出し(`core/html.py`)は Pygments に HTML を組ませればよいが、画面は `QSyntaxHighlighter` が**行単位**で動くので、行ごとの位置と色が要る。 **1 行ずつ解析してはいけない。** 複数行の文字列やコメントは行をまたぐので、 その行だけを見ると中身の `def` が予約語に見えてしまう。コードブロック全体を 1 回解析して、結果を行に割る。 `core/` にあるので PySide6 に依存しない(R3)。 """ import logging from dataclasses import dataclass from...
Toshiaki0315/hitofude
hitofude/core/code_tokens.py
.py
28eb4d079dfadd8c
7.15
1
"""ノート 1 つ分のモデルと、そこから導かれる情報(spec §7.2, §7.3)。 タイトルもタグも**本文から導く**。front matter に書き写して二重管理すると、 本文を編集したときに必ず食い違う。真実は常に本文側(§7.2)。 """ import hashlib import os import secrets import time from dataclasses import dataclass, field from pathlib import Path from typing import Any from hitofude.core import frontmatter, tags fr...
Toshiaki0315/hitofude
hitofude/core/document.py
.py
e06bc60deea1df0e
7.15
1
"""選択範囲を別のノートに切り出す(M-1 / 仮身化)。 BTRON の「選択した部分が新しい実身として切り出され、元の場所には仮身が 残る」を Markdown に写したもの。**ここは Qt もファイルも知らない**(R3)。 **題名は本文から決まる。** ノートの題名は `document.title_of`(最初の H1 → 最初の非空行)が決めるので、こちらで勝手に付けた題名は索引に載らない。 `[[…]]` は題名で解決する(E-6)から、ずれると**リンクの先が行方不明**に なり、しかも押すと「無ければ作る」で 2 つ目ができる。気づきにくい。 だから**題名を作り直したときは見出しを足して、本文から同じ...
Toshiaki0315/hitofude
hitofude/core/extract.py
.py
49fceb2cce184d2c
7.15
1
"""コードフェンスの開閉を行ごとに追う門番(レビュー 2026-08-25)。 同じ状態機械が `tags` と `wikilink`(2 か所)に 3 回書かれていた。 開閉の規則(CommonMark)はここに 1 つだけ置く: - 前置の空白 3 つまでを許した ``` か ~~~ で開く - **同じ文字**の、**同じ長さ以上**の区切りで閉じる - 区切りの行そのものはコードでも本文でもない(どの利用者も飛ばす) `block_parser.classify_line` はこれより多くのこと(言語名・行の種類)を 返す別物で、`highlightBlock` 用。全文を歩くだけの利用者はこちらで足りる。 """ ...
Toshiaki0315/hitofude
hitofude/core/fences.py
.py
62e85c27aeb45769
7.15
1
"""YAML front matter の分離と再結合(spec §7.2)。 front matter は**任意**。Qt は front matter をパースしない(公式明記)ため自前で扱う。 設計上の最重要方針: **メタデータが壊れていても本文は必ず返す**。 front matter は付随情報にすぎず、それを理由にノートが開けなくなるのは ローカルファイルにプレーンテキストで保存する意味(G3)を損なう。 """ import re from collections.abc import Mapping from dataclasses import dataclass, field from typing ...
Toshiaki0315/hitofude
hitofude/core/frontmatter.py
.py
7f8d90a45a81e10d
7.15
1
"""リンクの図(M-2 / 仮身ネットワーク)。 BTRON の「あるファイルを起点としたリンク構造」を写したもの。 **ここは Qt も索引も知らない**(R3)——題名と行き先の対応を渡すだけで、 座標まで出す。Qt 無しで形を検証できる。 **絞らないと開けない。** 素朴な力学モデルは点の数の 2 乗で効き、実測で 200 点 359ms・1,000 点 9.2 秒(TASKS.md の M-2)。5,000 ノートの vault を 丸ごと描く道は無いので、**起点からの深さで絞る**——絞り方は記事のほうが 持っていた(「何段階先まで表示するか指定できる」)。 """ import math from colle...
Toshiaki0315/hitofude
hitofude/core/graph.py
.py
622583516a53dc78
7.15
1
"""取り込んだ文字を Markdown に整える(F-1)。 PowerPoint(F-3)と PDF(F-2)の両方がここを通る。**ざっくり整えて手で 直す**前提で、元の見た目の再現は狙わない。 判断の物差しは「**間違えたときにどちらが困るか**」で揃えてある。 消しすぎると本文が減って気づけないので、迷ったら残す。見出しの推定も 外れることがあるが、`##` が余分に付くのは目で見て直せる。 `core/` にあるので PySide6 に依存しない(R3)。 """ import re import unicodedata # 見出しらしさの上限。これより長い行は、句点が無くても本文として扱う MAX_HEAD...
Toshiaki0315/hitofude
hitofude/core/imported.py
.py
449494bacf259100
7.15
1
"""コア層のデータモデル(spec §6.2)。 オフセットの約束: **すべて `[start, end)` の半開区間**。 `QSyntaxHighlighter.setFormat(start, length)` にそのまま渡せるようにするため。 唯一の例外はリビール判定の `InlineSpan.contains()` で、こちらは閉区間(§6.4)。 """ from dataclasses import dataclass from enum import Enum, auto # 見出しは CommonMark の定義により 1..6 MIN_HEADING_LEVEL = 1 MAX_HEADING_LEV...
Toshiaki0315/hitofude
hitofude/core/models.py
.py
a2f609c54918618e
7.15
1
"""`[[ノート名]]` の打ちかけ判定と候補絞り(ユーザー要望)。 書けるのに候補が出ないと、正確な名前を覚えているか、別のノートを開いて 確かめることになる。タグ(`core/tags.py`)と同じ形で補完する。 **ここは Qt に触れない**(R3)。どこに出すか・何を候補にするかは UI 側。 """ import re from hitofude.core import tags as _tags # 打ちかけの `[[名前`。**閉じていないものだけ**を拾う。 # # - `|` と `]` を含まない … 別名の記法(`[[名前|表示]]`)は未対応で、 # 中途半端に補完すると名前が壊れる(`i...
Toshiaki0315/hitofude
hitofude/core/notelink.py
.py
ef44805677c7e555
7.15
1
"""画像を文字にする([ADR-0027](../../docs/adr/0027-ocr.md))。 読み手は 2 つ。**既定は macOS**(実測 0.85 秒・誤りゼロ)で、ローカルLLM は 大きなモデルを積める人向け(`gemma3:4b` は 17.3 秒かけて読み違えた)。 **ここは Qt を知らない**(R3)。外の道具(同梱の実行ファイル・Ollama)は 差し替えられるので、テストで実物を動かさない。 """ import logging import re import subprocess from collections.abc import Callable from dataclasses...
Toshiaki0315/hitofude
hitofude/core/ocr.py
.py
2c528e12fb161945
7.15
1
"""見出しの一覧(C-2 / アウトライン)。 長いノートで迷子にならないよう、見出しへ飛べるようにする。 **分類はハイライタと同じ経路を使う**(`block_parser.classify_line`)。 自前で `#` を数えると、コードブロックの中の `# コメント` や `#タグ` を 見出しとして拾ってしまう。 """ from dataclasses import dataclass from hitofude.core.block_parser import classify_line from hitofude.core.models import BlockState, BlockType @da...
Toshiaki0315/hitofude
hitofude/core/outline.py
.py
e263694f24ab24c6
7.15
1
"""保管フォルダの外を指す参照を弾く(spec §7.1)。 本文も設定ファイルも**手で編集できる**。`![](../../../etc/passwd)` と 書かれても、保管フォルダの外を読みに行かない。 同じ判定が `config.py` / `editor/exporter.py` / `editor/image_cache.py` に 別々の実装で 3 つあり、`config` だけ `resolve()` を通しておらず **シンボリックリンク経由の脱出を見ていなかった**。安全に関わる規則の実装が 複数あると、1 つ直しても他が残る。ここが唯一の実装。 """ from pathlib import Path...
Toshiaki0315/hitofude
hitofude/core/paths.py
.py
ce351c5fc47c9ee5
7.15
1
"""関連するノートを並べる(L-3)。 **LLM に選ばせない。** 関係の根拠は既に索引の中にある(同じタグ・ `[[…]]` の指し合い・題名の語)。モデルに選ばせると **なぜ関係するのか 確かめられず**、待たされ、Ollama を入れていない人には何も出ない。 索引から引けば即座に出て、**理由も一緒に出せる**。 ここは並べ方だけの純関数(R3)。索引を引くのは呼ぶ側。 """ from dataclasses import dataclass LINK = 3 """`[[…]]` で指している/指されている。**書いた人が手で結んだ**関係なので いちばん強い。""" SHARED_TAG = 2 ""...
Toshiaki0315/hitofude
hitofude/core/related.py
.py
e4b357e85050c8e0
7.15
1
"""開いている 1 つのノートの中を探す(`Cmd+F`)。 `Cmd+O` はノートを探し、`Cmd+Shift+F` は索引を使ってノートを横断する。 ここはそのどちらでもなく、**今見ている本文の中**を前後に辿る層。 R3 に従い GUI に依存しない。R4 により `QTextCursor` の位置と文字オフセットは 常に 1:1 なので、ここが返す位置はそのままカーソルへ渡せる。 **正規表現は使わない。** ユーザーが打った `.` や `*` が予想外の位置に 一致すると、置換で本文を壊す。打った文字をそのまま探す。 """ type Match = tuple[int, int] """一致範囲。半開区間...
Toshiaki0315/hitofude
hitofude/core/search.py
.py
50dcc8a73bedf9ab
7.15
1
"""検索の問い合わせを読み取る(提案 3)。 `Cmd+Shift+F` は全文一致だけで、タグで絞れなかった。索引にはタグが入って いるので、`#仕事 予算` のように**本文と同じ書き方**で絞れるようにする。 **入力欄は増やさない。** 書き方が本文と揃っているほうが覚えることが少ない。 **ここは Qt にも SQL にも触れない**(R3)。読み取るだけで、どう探すかは `storage/index_db.py`、どこに出すかは UI の仕事。 """ import re from dataclasses import dataclass from datetime import date from hito...
Toshiaki0315/hitofude
hitofude/core/searchquery.py
.py
166998619d08ace3
7.15
1
"""文字数と行数(ステータスバーの表示)。 **単語数は出さない。** 日本語には語の区切りが無く、かつて CJK を 1 文字 1 語として数えていたが、`東京都渋谷区` が 6 語になるなど 語数としての意味を成さなかった(ユーザーの指摘で取りやめ)。 本当に数えるには形態素解析が要り、ステータスバーの数字 1 つのために 依存を増やす価値はない。 数える対象はマーカーを外した本文(`plain_text`)。`**` や `#` は 読む文章の一部ではないので、分量に含めない。front matter も同様。 """ from dataclasses import dataclass from hitofude.c...
Toshiaki0315/hitofude
hitofude/core/stats.py
.py
441028716dee10d5
7.15
1
"""`#tag` の抽出・階層分解・正規化(spec §6.5 規則 7, §7.2, §7.3)。 タグは front matter ではなく**本文が真実**(§7.2)。ノートを保存するたびに 本文を全走査して索引を張り直す。 `#` は見出しマーカーと同じ文字なので、区別の条件が仕様の核心になる: - `#` の直前は**行頭または空白**であること - `#` の直後は空白でも `#` でもないこと `TAG_RE` は `inline_scanner`(タスク 1-7)からも使う。判定を 2 箇所に書くと 必ず片方だけ直され、サイドバーとエディタで見えるタグがずれる。 """ import re from d...
Toshiaki0315/hitofude
hitofude/core/tags.py
.py
787afaf17aafbf42
7.15
1
"""テンプレートの差し込み(E-4)。 議事録や日報の雛形から新しいノートを作るとき、日付や題名を作った瞬間に 埋める。雛形は vault の `templates/` に置いた**ただの `.md`**で、 独自形式ではない(R1 と同じ考え方。真実はファイル側にある)。 差し込めるのは 4 つだけ。増やすほど「覚えないと使えない道具」になる。 | 印 | 中身 | |---|---| | `{{date}}` | 日付。`{{date:%Y年%m月%d日}}` で書式を変えられる | | `{{time}}` | 時刻。同じく書式を指定できる | | `{{title}}` | 付ける題名 | | `{{cursor}}...
Toshiaki0315/hitofude
hitofude/core/template.py
.py
0217c34d9f08b271
7.15
1
"""Python 文字列と QString(UTF-16)の位置変換。 Python の str はコードポイント単位、Qt の QString は UTF-16 単位で数える。 🍎 や 𠮷 など BMP 外の文字は Python では 1 文字、UTF-16 では 2 単位 (サロゲートペア)になる。R4 の「`QTextCursor` の位置とソース文字列の オフセットが 1:1」は BMP 内でしか成り立たないため、core が返す位置を Qt の API(`setFormat` / `QTextCursor.setPosition`)へ渡す境界、および Qt から受け取った位置で Python 文字列を引く境界で、必...
Toshiaki0315/hitofude
hitofude/core/textpos.py
.py
5f0fd241d5c3a60a
7.15
1
"""`[[ノート名]]` の名前の扱い(E-6)。 ノート同士を繋ぐリンク。**CommonMark ではない**(`::ハイライト::` や Qiita 記法と同じ立場)。他のアプリで開けばただの文字に見えるが、 ソースが真実(R1)なので何も失われない。 **ID ではなく名前で結ぶ。** このアプリのタイトルは本文の H1 から導かれ、 ファイル名がそれに追従する(ADR-0005)。`[[01J8XZ...]]` と書かれたノートは 人が読めないし、手で書けない。名前で結ぶ代償は「題名を変えるとリンクが 切れる」ことだが、切れたリンクは押した先で作り直せる(ADR-0011)。 `core/` にあるので PySid...
Toshiaki0315/hitofude
hitofude/core/wikilink.py
.py
045ea094564ee4ec
7.15
1
"""貼り付け元から添付を取り出す(タスク A-2)。 **エディタの状態を要らない変換だけを置く。** どこへ保存するかは `storage/vault.py`、本文へ挿すのは `editor/editor_widget.py` の仕事。 """ import logging from pathlib import Path from PySide6.QtCore import QBuffer, QByteArray from PySide6.QtGui import QImage logger = logging.getLogger(__name__) # 落とされたファイルを画像として扱う拡張子。ここに無いものは素通...
Toshiaki0315/hitofude
hitofude/editor/attachments.py
.py
d3c0d71286423125
7.15
1
"""HTML / PDF へのエクスポート(spec §9 Phase 6 / ADR-0007)。 **`QTextDocument.setMarkdown()` は使わない。** 変換は `core/html.py` が markdown-it-py で行い、ここはその HTML を「ページに組む」「画像を埋める」 「PDF に流す」だけを受け持つ。 以前はここが R2 の唯一の例外だった。今は**アプリのどこからも `setMarkdown()` を呼ばない**(`tests/test_architecture.py` が見ている)。 理由は R2 の趣旨(往復変換の禁止)ではなく、あちらが記法を落とすため。 実測は A...
Toshiaki0315/hitofude
hitofude/editor/exporter.py
.py
7a735aca4713a579
7.15
1
"""本文に描く画像の読み込みとキャッシュ(タスク A-2)。 **毎回読み直さない。** 3024x1964 の PNG を読んで縮小すると 21ms かかり、 §6.6 の「打鍵 → 画面反映 16ms」を単独で超える。縮小結果を持ち回れば 0.05ms(実測)。ここが無いと本文中の画像表示は成立しない。 保管フォルダの外は読まない。本文は手で編集できるので、`../` や絶対パスで 任意のファイルを開かせない(`editor/exporter.py` と同じ判断)。 """ from collections import OrderedDict from pathlib import Path from PySide6...
Toshiaki0315/hitofude
hitofude/editor/image_cache.py
.py
3507be19db2fbf02
7.15
1
"""外の形式から取り込む(F 群)。 **ざっくり読んで手で直す**前提。元の見た目は再現しない(TASKS.md の F 群)。 PDF は **PySide6 同梱の QtPdf** で読む。依存が増えないのが決め手で、 py2app の除外にも入っていない(`docs/licenses.md`)。 R3 のとおり `core/` は PySide6 に触れないので、読み取りはここに置く。 **この層は「読む」だけ**で、文字を Markdown に整えるのは `core/imported.py`(F-1)の仕事。 **読めないことは壊れることではない。** 中身が PDF でなくても、暗号化されて いても、空を返して...
Toshiaki0315/hitofude
hitofude/editor/importer.py
.py
c747aa56cd651b4f
7.15
1
"""Enter / Tab の入力補助(spec §5.5)。 判断は**純関数**に閉じ込め、`QTextCursor` を触る部分と分けている。 入力補助は条件分岐が多く、GUI 越しに検査すると組み合わせを網羅できないため。 判定には `BlockData` に入っている `BlockInfo`(ハイライタが作った)を使う。 行を再解析しないので、コードフェンスの中かどうかも自動的に正しく効く。 フェンス内で効くのは**字下げの引き継ぎだけ**で、リストや引用の補助は 発火しない。 """ import re from dataclasses import dataclass from enum import Enum...
Toshiaki0315/hitofude
hitofude/editor/input_handler.py
.py
408dad867d45502c
7.15
1
"""数式の描画(I-1 / ADR-0020)。 LaTeX → SVG は **ziamath**(純 Python・約 3MB)。検討時は matplotlib (+60MB)が必須と見ていたが、TeX 品質のグリフがこの大きさで出る。 SVG → QPixmap は Qt 標準の QtSvg。1 式 6ms(初回)/ 1ms(フォントが 温まったあと)なので、変更ブロックだけの再ハイライト(R7)に収まる。 描き直さないよう、指定(式・大きさ・色・幅)ごとに絵を覚える。 """ import logging from collections import OrderedDict import ziamath from...
Toshiaki0315/hitofude
hitofude/editor/math_cache.py
.py
bdda9815cd5d84ff
7.15
1
"""PowerPoint への書き出し(F-5)。 **ざっくり作って手で整える**前提。凝ったレイアウトは狙わない。 割り方は `core/slides.py`(F-4)が決めていて、ここは組み立てだけを持つ。 分けてあるので、規則を変えたいときに触る場所が 1 つで済む。 置き方はユーザーと決めた。**`#` は表紙、`##` ごとに 1 枚、画像は右側。** 画像があるスライドは本文を左半分に寄せる(画像と重ならないように)。 **書き出しは止めない。** 画像が見つからなくても、保管フォルダの外を 指していても、そこだけ飛ばしてファイルを作る。1 枚のリンク切れで 書き出せないほうが困る。 """ import ...
Toshiaki0315/hitofude
hitofude/editor/pptx_export.py
.py
eaafca05300cc3b4
7.15
1
""" Example script demonstrating the tracer system with ChatSession and tools. This example shows how to use the tracer system to monitor an interactive chat session with LLMBroker and tools. When the user exits the session, the script displays a summary of all traced events. It also demonstrates how correlation_id...
svetzal/mojentic
code-playground/tracer_demo.py
.py
5938f30723100f64
7
0
import pytest from integration_checks.models import SimpleResponse, SimpleTool from mojentic.llm.gateways.anthropic import AnthropicGateway from mojentic.llm.gateways.models import LLMMessage, MessageRole # Using fixtures from conftest.py: # - SimpleResponse: Pydantic model for testing object validation # - SimpleTo...
svetzal/mojentic
integration_checks/anthropic_gateway_spec.py
.py
f7f5390e1291e66b
7.5
0
""" Example script demonstrating how to use the AsyncDispatcher, BaseAsyncAgent, and AsyncAggregatorAgent. This script shows how to create and use asynchronous agents with the AsyncDispatcher. """ import asyncio from pathlib import Path from typing import List from pydantic import BaseModel, Field from mojentic.age...
svetzal/mojentic
src/_examples/async_dispatcher_example.py
.py
232d359457773532
7
0
""" Example script demonstrating how to use the AsyncDispatcher with BaseAsyncLLMAgent. This script shows how to create and use asynchronous LLM agents with the AsyncDispatcher. """ import asyncio from typing import List from pydantic import BaseModel, Field from mojentic.agents.async_aggregator_agent import AsyncA...
svetzal/mojentic
src/_examples/async_llm_example.py
.py
58f6fa30bff15c24
7
0
""" Audit script that probes OpenAI models for their actual capabilities and compares against our hardcoded model registry. Usage: OPENAI_API_KEY=sk-... python src/_examples/audit_openai_capabilities.py OPENAI_API_KEY=sk-... python src/_examples/audit_openai_capabilities.py --cheap The --cheap flag skips expe...
svetzal/mojentic
src/_examples/audit_openai_capabilities.py
.py
3fa92e2493fa2354
7
0
""" Script to fetch current OpenAI models and update the registry with up-to-date model lists. """ import os from mojentic.llm.gateways.openai import OpenAIGateway def fetch_current_openai_models(): """Fetch the current list of OpenAI models.""" api_key = os.getenv("OPENAI_API_KEY") if not api_key: ...
svetzal/mojentic
src/_examples/fetch_openai_models.py
.py
6cb6ba0031f2fa7b
7
0
""" Demonstration of the enhanced OpenAI gateway with model registry system. This script shows how the new infrastructure automatically handles parameter adaptation for reasoning models vs chat models, provides detailed logging, and offers better error handling. """ from mojentic.llm.gateways.openai import OpenAIGate...
svetzal/mojentic
src/_examples/openai_gateway_enhanced_demo.py
.py
572682a56752171b
7
0
""" Parallel tool execution against the chat-completions broker. The sync :class:`LLMBroker` defaults to :class:`SerialToolRunner` for backward-compat. Opt into :class:`AsyncParallelToolRunner` to fan out when a single assistant turn requests several tool calls. Note: ``AsyncParallelToolRunner`` is async. With the sy...
svetzal/mojentic
src/_examples/parallel_tool_calls.py
.py
3b6c5ef857495380
7
0
"""Decision-making agent for the ReAct pattern. This agent evaluates the current context and decides on the next action to take. """ from typing import List from pydantic import BaseModel, Field from mojentic.agents.base_llm_agent import BaseLLMAgent from mojentic.event import Event from mojentic.llm import LLMBroke...
svetzal/mojentic
src/_examples/react/agents/decisioning_agent.py
.py
fb16a8c37a219755
7
0
"""Summarization agent for the ReAct pattern. This agent generates the final answer based on accumulated context. """ from typing import List from mojentic.agents.base_llm_agent import BaseLLMAgent from mojentic.event import Event from mojentic.llm import LLMBroker from mojentic.llm.gateways.models import LLMMessage ...
svetzal/mojentic
src/_examples/react/agents/summarization_agent.py
.py
58169f302be57fa9
7
0
"""Pytest configuration. Must run before any project import: redirects the SQLite history DB and the output directory into a temp folder so tests never touch the developer's real data/, and imports the app once for the whole session. """ import os import tempfile _TMP = tempfile.mkdtemp(prefix="unified-tts-test-") o...
manojkumar9121/unified-tts
tests/conftest.py
.py
af10a49eb2e09178
7.5
0
"""Integration tests for the HTTP API (no models required). Engine-specific imports are lazy, so these run with core deps only. """ import sqlite3 class TestPages: def test_index_serves_html(self, client): r = client.get("/") assert r.status_code == 200 assert "Unified TTS" in r.text ...
manojkumar9121/unified-tts
tests/test_api.py
.py
577f0a791fd96998
7.5
0
"""Tests for Audio8ServiceManager internals (no subprocess is started).""" import json import time from audio8_manager import HEALTH_TTL_SECONDS, Audio8ServiceManager, _HttpResponse class FakeRaw: status = 200 headers = {"content-type": "application/json"} def __init__(self, body: bytes): self....
manojkumar9121/unified-tts
tests/test_audio8_manager.py
.py
4d050bc8cbfd44f6
7.5
0
"""Guards against packaging regressions. * requirements.txt must stay in sync with pyproject.toml (the canonical spec). * The console-script entry point (``server:main``) must actually exist. """ import re from pathlib import Path import tomllib ROOT = Path(__file__).resolve().parent.parent def _requirements_line...
manojkumar9121/unified-tts
tests/test_packaging.py
.py
a5340cfef7ea9baa
7.5
0
"""Tests for pure text-processing helpers in tts_engine.""" import numpy as np import pytest from tts_engine import _hard_split, _time_stretch, chunk_text, split_sentences class TestSplitSentences: def test_empty(self): assert split_sentences("") == [] assert split_sentences(" ") == [] de...
manojkumar9121/unified-tts
tests/test_text_processing.py
.py
4627badfd799863e
7.5
0
"""Central configuration for CS2TH 汰换小助手. Runtime data is kept outside the installation directory so packaged builds remain read-only and upgrades do not discard user sessions. """ from __future__ import annotations import ctypes import os import sys from pathlib import Path from core.version import __version__ AP...
jonh352/CS2TH-TOOLS
config.py
.py
7d53d223004a1bf7
7
0
"""炼金页品质标签 - 从 SkinTemplate 获取皮肤品质""" import json import re import unicodedata from functools import cache from .data_utils import SkinTemplate, APPEARANCE, APPEARANCE_MAP from .skin_template_meta_load import iter_meta_skin_lines_in_order # Unicode 空白(\s)+ 常见零宽/格式字符(复制或 meta 中可能混入,\s 不一定覆盖) _WHITESPACE_AND_INVISIBLE...
jonh352/CS2TH-TOOLS
core/alchemy_quality.py
.py
945cba534e9986c5
7
0
"""app_settings.json 的基础读写。""" from __future__ import annotations from typing import Any, Callable, Mapping from config import APP_SETTINGS_FILE from .json_store import JsonDict, read_json_dict, update_json_dict def load_app_settings() -> JsonDict: """读取应用通用偏好;始终返回 dict。""" return read_json_dict(APP_SETTI...
jonh352/CS2TH-TOOLS
core/app_settings_store.py
.py
9389ba4c01917696
7
0
"""Cooperative cancellation helpers for long-running market collection.""" from __future__ import annotations import time from typing import Callable CancelCheck = Callable[[], bool] | None class CollectionCancelled(RuntimeError): """Raised when the user requests cancellation of a collection run.""" def rais...
jonh352/CS2TH-TOOLS
core/collection_cancel.py
.py
066d511206695bf0
7
0
"""库存页:按 meta 列表排除指定枪名(比对前去掉 Steam 名称中的磨损后缀)。""" from __future__ import annotations import json from config import INVENTORY_HIDE_NAMES_FILE from core.data_utils import APPEARANCE # Steam 英文市场名常见后缀,与 ``get_wear_level`` / ``APPEARANCE_MAP`` 一致 _WEAR_SUFFIX_EN = ( "Battle-Scarred", "Well-Worn", "Field-Tes...
jonh352/CS2TH-TOOLS
core/inventory_hide_names.py
.py
aa43ec0a9f09a5f2
7
0
"""UTF-8 JSON 文件读写辅助。""" from __future__ import annotations import json from pathlib import Path from typing import Any, Callable, Mapping JsonDict = dict[str, Any] def read_json_dict(path: Path | str) -> JsonDict: """读取 JSON 对象;文件缺失、损坏或根不是对象时返回空 dict。""" p = Path(path) try: if not p.is_file():...
jonh352/CS2TH-TOOLS
core/json_store.py
.py
4b4908d7a59ad376
7
0
"""app_settings.json 中的 Playwright 首选浏览器(chrome / msedge);供 core 启动浏览器时读取。""" from __future__ import annotations from config import APP_SETTINGS_PREFERRED_PLAYWRIGHT_CHANNEL_KEY from .app_settings_store import load_app_settings, update_app_settings PLAYWRIGHT_CHANNEL_CHROME = "chrome" PLAYWRIGHT_CHANNEL_MSEDGE = "m...
jonh352/CS2TH-TOOLS
core/playwright_channel_prefs.py
.py
80f551beceb6839f
7
0
"""``ProcessPoolExecutor`` 取消后对仍存活的 worker 子进程尽最大努力强杀。""" from __future__ import annotations import logging import multiprocessing.queues as mp_queues from concurrent.futures import ProcessPoolExecutor logger = logging.getLogger(__name__) _MP_FEEDER_PATCHED = False def _snapshot_pool_worker_processes(executor: Pro...
jonh352/CS2TH-TOOLS
core/process_pool_kill.py
.py
a1e3862e556de1de
7
0
"""炼金计算结果配方:读写 config.RECIPES_DIR(CACHE_DIR/recipes)下独立 JSON 文件。""" from __future__ import annotations import json import uuid import numpy as np from datetime import datetime, timezone from pathlib import Path from typing import Any from config import RECIPES_DIR SCHEMA_VERSION = 1 # 配方 ``substrates_display`` 单项可...
jonh352/CS2TH-TOOLS
core/saved_recipes.py
.py
e7e0841331ca93da
7
0
"""Map a target product float32 interval to valid input material intervals.""" from __future__ import annotations import bisect from core.data_utils import MID_VALUE_LIST, SkinTemplate def neighboring_purchase_interval( wear_value: float, *, min_float: float = 0.0, max_float: float = 1.0, ) -> tupl...
jonh352/CS2TH-TOOLS
core/special_wear_materials.py
.py
eef109338e3eb998
7.5
0
"""特殊磨损页:从 SkinTemplate*.jsonl 一次性构建「武器 | 皮肤」全名列表(不含磨损外观),结果仅驻留内存。""" from __future__ import annotations import json from .alchemy_quality import normalize_name from .skin_template_meta_load import iter_meta_skin_lines_in_order _mem_names: list[str] | None = None def _scan_names_from_disk() -> list[str]: seen...
jonh352/CS2TH-TOOLS
core/special_wear_names.py
.py
62dc662755e218fb
7.5
0
"""Steam 浏览器与会话相关异常。""" STEAM_FETCH_SESSION_EXPIRED = "__STEAM_FETCH_SESSION_EXPIRED__" STEAM_BROWSER_NOT_INSTALLED_MSG = "请先安装Edge或Chrome浏览器" STEAM_BROWSER_PROFILE_BUSY_MSG = ( "登录浏览器配置正被占用:请先关闭已打开的平台登录窗口," "或在任务管理器结束残留的 Edge/Chrome 进程后再试" ) class SteamSessionExpiredError(RuntimeError): """库存 API 返回会话无效...
jonh352/CS2TH-TOOLS
core/steam/errors.py
.py
02389049494731f0
7
0
"""库存 JSON 解析、展示字段与拉取编排。""" from __future__ import annotations import re import time from datetime import datetime, timezone from pathlib import Path from typing import Callable, Optional from zoneinfo import ZoneInfo from core.inventory_hide_names import ( is_inventory_item_hidden_by_name_list, load_invento...
jonh352/CS2TH-TOOLS
core/steam/inventory_pipeline.py
.py
8cda2d53aa6421cc
7
0
"""Playwright 持久化上下文:目录解析、启动参数、stealth 注入。""" from __future__ import annotations import os import shutil from pathlib import Path from config import ( PLAYWRIGHT_CHROME_USE_SYSTEM_USER_DATA, PLAYWRIGHT_CHROME_USER_DATA_DIR, PLAYWRIGHT_EDGE_USER_DATA_DIR, PLAYWRIGHT_MSEDGE_USE_SYSTEM_USER_DATA, PL...
jonh352/CS2TH-TOOLS
core/steam/launch.py
.py
98b7ff264ecbe71a
7
0
"""Disruption impact analysis. Deterministic set logic: which assignments of the active plan does this event touch, and what does it free up. The agent re-plans only the affected subset. """ EVENT_LIBRARY = { "wagon_breakdown": { "label": "Wagon breakdown", "describe": lambda p: f"Wagon {p['wagon_i...
A-Arzu/Alat-Freight
agent/tools/impact.py
.py
291c72466ae648e0
7
0
"""Hard-constraint pre-filter. Deterministic by design: the LLM only ever sees cargo-wagon pairings that are physically and legally possible. Every exclusion carries a reason so the agent trace can show its work. """ from core.clock import add_min, later from core.models import LOAD_MINUTES # cargo type -> acceptable ...
A-Arzu/Alat-Freight
agent/tools/prefilter.py
.py
4fd42b32e87b1677
7
0
"""FastAPI service: agent endpoints + dashboard API + static frontend. One container does everything on Cloud Run: POST /optimize morning batch plan (Cloud Scheduler / dashboard) POST /events disruption -> incremental re-plan GET /api/state full snapshot for th...
A-Arzu/Alat-Freight
api/main.py
.py
9b0665a0c91e77cd
7
0
"""Tiny time helpers. All timestamps in this app are naive local ISO strings ("YYYY-MM-DDTHH:MM"). The demo runs on a frozen "port clock" stored in meta.now so plans are reproducible no matter when you run it. """ from datetime import datetime, timedelta FMT = "%Y-%m-%dT%H:%M" def parse(s: str) -> datetime: retu...
A-Arzu/Alat-Freight
core/clock.py
.py
4142fb4b5d059233
7
0
"""Storage behind one small interface. MemoryStore - local dev / demo without any cloud dependency. FirestoreStore- Google Cloud Firestore (native mode), used on Cloud Run. Select with env STORE=memory|firestore (default: firestore when GOOGLE_CLOUD_PROJECT is set, else memory). """ import os import threading COLL...
A-Arzu/Alat-Freight
core/store.py
.py
7e94c42aca5e737f
7
0
""" benchmarks/conftest.py — shared fixtures for benchmark tests. These are isolated from `tests/conftest.py` so a benchmark run doesn't interfere with the regular test suite's env-var side effects. Goals: - In-memory Qdrant (`location=":memory:"`) for repeatability across hosts. - Mock encoder (no model download...
isaaclb98/image-search
benchmarks/conftest.py
.py
46b680d3d12434ff
7.5
0
""" benchmarks/test_indexing_throughput.py Measures images-per-second through the indexer using: - in-memory Qdrant (no network) - mock 1536-dim encoder (no model, no GPU) - synthetic JPEG corpus (no real photos) Goal: establish a stable baseline against which Tier-2.1 (concurrent PIL decode) can be compared. N...
isaaclb98/image-search
benchmarks/test_indexing_throughput.py
.py
a0c4d08e6b02203e
7.5
0
""" image_search_kernel._real_models Real-model registry entries. Imported lazily by `image_search_kernel.registry` so that the kernel package itself is importable on hosts without `torch` / `open_clip` / `transformers` installed. If any required runtime is missing, importing this module raises `ImportError`. The cal...
isaaclb98/image-search
image_search_kernel/_real_models.py
.py
14a74965c77b8907
7
0
""" image_search_kernel.vectors Vector arithmetic primitives used by both the search side (centroid math) and the indexer side (payload validation). No I/O, no model dependencies, no QdrantClient. Pure functions only. The kernel invariant: this module never imports anything except stdlib + (eventually) numpy. """ fr...
isaaclb98/image-search
image_search_kernel/vectors.py
.py
c99396e8be3e4c27
7
0
""" indexer/blurhash.py — LQIP (low-quality image placeholder) hashing. Blurhash encodes a small (e.g. 4×3) RGB thumbnail into a short string (~20-40 chars) that the browser can decode into a colored placeholder. We compute the hash at index time once and store it in the Qdrant payload next to the path; the client sid...
isaaclb98/image-search
indexer/blurhash.py
.py
fc14b0540798fd58
7
0
"""Image fingerprints used by the search-side Diversity ranker. The indexer stores two deliberately simple signals: * ``content_sha256`` identifies byte-for-byte duplicate files. * ``dhash`` is a compact perceptual fingerprint for resized grayscale structure. It catches common copies, recompressions, and small edi...
isaaclb98/image-search
indexer/fingerprints.py
.py
905e4b4270101c65
7
0
""" indexer/heal.py Qdrant-direct reconciliation CLI for finding points whose source file no longer exists under a filesystem tree. """ from __future__ import annotations import argparse import os import sys from dataclasses import dataclass, field from pathlib import Path from typing import Any from dotenv import ...
isaaclb98/image-search
indexer/heal.py
.py
d1852e95d3a54f54
7
0
""" indexer/image_loader.py Load + preprocess an image for embedding. Pipeline: 1. PIL.Image.open(path) — lazy decode 2. ImageOps.exif_transpose() — apply EXIF orientation 3. .convert("RGB") — drop alpha; SigLIP2 expects 3 channels 4. Letterbox resize to the registered model's resolution (e.g. 384x384 fo...
isaaclb98/image-search
indexer/image_loader.py
.py
e5ed4790931ffa72
7
0
""" indexer/run_pipeline.py — thin library wrapper around IndexerPipeline. `local_sync.py` is a feature-rich CLI with change-detection, prune, and backfill modes that predate the pipeline abstraction. Those features will migrate to the pipeline as separate phases in follow-on PRs. This module exposes the simplest pos...
isaaclb98/image-search
indexer/run_pipeline.py
.py
1ae097edf6c0c94e
7
0
""" indexer/sync_meta.py — Tiny shared module for sync state. When `indexer/sync.py` was removed (the old k8s scanner CLI), the shared constants and helpers it owned (META_COLLECTION, META_POINT_ID, ensure_sync_collections, write_meta) still had callers outside the deleted file — specifically: * search/index_db.py ...
isaaclb98/image-search
indexer/sync_meta.py
.py
99bcca5f2defb433
7
0
""" indexer/thumbnails.py — generate WebP thumbnails at index time. Thumbnails are 256×256 max dimension, WebP q50. Storage layout: {THUMBNAIL_DIR}/{prefix}/{point_id}.webp Two-level prefix (first 2 chars of point_id) avoids putting 2M files in one directory. ~8K files per bucket at 2M scale. """ from __future__ i...
isaaclb98/image-search
indexer/thumbnails.py
.py
af7b9cb51de90706
7
0
""" indexer/upsert.py Qdrant writes. Idempotent by design. The id strategy is: `sha1(f"{shard}::{path.as_posix()}").hexdigest()[:32]`. This means: - Re-running the indexer on the same folder produces the same ids (Qdrant skips on duplicate). - Different shards can hold the same path (different ids). - The 3...
isaaclb98/image-search
indexer/upsert.py
.py
c95f78f4561238a9
7
0
""" indexer/vision_encoder.py Thin wrapper around the model registry (§A3). The actual SigLIP2 loading lives in `image_search_kernel._real_models.OpenClipEmbedder`; this module exists only to preserve the historical `VisionEncoder(...)` API for callers (`local_sync.py`, the benchmark suite) and to centralize test-mode...
isaaclb98/image-search
indexer/vision_encoder.py
.py
98469540ac5633a6
7
0
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ MARS Beacon — Meta-fusion, Accessibility, Ranking & Security Audit. Audit SEO, RRF (Reciprocal Rank Fusion), WCAG e WAPT Copyright 2026 Paolo Pierno Licenza: Apache 2.0 """ from __future__ import annotations import json from typing import List from mars_core import ...
saulusprime/MARS
mars_schema.py
.py
23f35fc45fe22048
7
0
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ MARS Beacon — il catalogo dei testi di correzione (U3.1). Copyright 2026 Paolo Pierno Licenza: Apache 2.0 """ from __future__ import annotations import pytest import mars_core import mars_fixes import mars_schema import mars_tech from conftest import pagina from tes...
saulusprime/MARS
tests/test_fixes.py
.py
80f12e9cf38d1574
7.5
0
import logging import time import uuid from collections.abc import Callable from fastapi import FastAPI, Request, Response from starlette.middleware.base import BaseHTTPMiddleware from app.core.config import settings from app.core.redis_client import get_redis logger = logging.getLogger("nexus.access") # In-memory ...
aasish3187/Organisational-Agent
apps/api/app/core/middleware.py
.py
a173aec6f52f88e9
7.15
1
""" Alien Monitor AI — multi-provider LLM + live ecosystem state in the prompt. Uses the same provider ids / YAML shape as aicom (data/config/model_providers.yaml). """ from __future__ import annotations import json import os from pathlib import Path from typing import Any import httpx import yaml _MONITOR_ROOT = P...
alexar76/alien-monitor
backend/ai_assistant.py
.py
61431d7b9f187e29
7
0
"""Detect map-navigation intents from AI chat questions.""" from __future__ import annotations import re from typing import Any # Core nodes the monitor can focus — aliases cover the five base locales # (en / ru / es / fr / zh) plus common transliterations. NODE_ALIASES: dict[str, tuple[str, ...]] = { "skopos": ...
alexar76/alien-monitor
backend/ai_nav_actions.py
.py
db6feb9c9d8b88ad
7
0
"""In-memory Argus verifiable-run feed for the monitor. A live Argus instance POSTs its latest run to ``/api/argus/run``; the monitor attaches it to the ``argus`` node so clicking the node shows the real oracle calls, WARDEN blocks, hires and the sealed receipt. Until a live run is pushed, a representative DEFAULT run...
alexar76/alien-monitor
backend/argus_feed.py
.py
e836c98fc5a26bc4
7
0
"""ARGUS reference agent — topology anchor + graph links for Alien Monitor.""" from __future__ import annotations from typing import Any from argus_status import argus_public_url, argus_public_url_for_mode from ecosystem_layout import node_position def argus_node_spec(*, mode: str = "real") -> dict[str, Any]: ...
alexar76/alien-monitor
backend/argus_layers.py
.py
fa9cd7fdcb9c3a9f
7
0
"""Poll the live ARGUS HTTP /health and attach wallet + economy to the argus node.""" from __future__ import annotations import os from typing import Any import httpx from onchain_refs import make_ref from poll_cache import ttl_cached DEFAULT_ARGUS_URL = "http://127.0.0.1:8787" DEFAULT_ARGUS_UNI_URL = "http://127....
alexar76/alien-monitor
backend/argus_status.py
.py
023061642eecbe2a
7
0
"""BASANOS touchstone node — topology anchor + graph links for Alien Monitor. Placed on the contract side of the hub, next to the Solidity it actually reads: ``basanos/basanos/inventory.py`` resolves its root ids to ``acex/contracts/evm/src``, ``lottery/contracts/src``, ``contracts/evm/src`` and ``contracts/zk/verifie...
alexar76/alien-monitor
backend/basanos_layers.py
.py
d677e0996baa24f5
7
0
"""BASANOS — poll the Solidity touchstone for the monitor node. The agent's only write path is a paid ``POST /invoke`` that runs a scan, so this poller never touches it: a monitor that spends money to draw a node would bill the operator for every 1.5 s tick. What is left is genuinely observable — * ``/health`` — i...
alexar76/alien-monitor
backend/basanos_status.py
.py
1af098f748130b86
7
0
"""aimarket-bridges node — topology anchor + graph links for Alien Monitor. The ecosystem's third paid invoke channel. The hub and the mesh are already on the map; the bridges are the door through which a LangGraph, CrewAI or AutoGen agent walks into the same catalogue, and until now the map of the economy did not sho...
alexar76/alien-monitor
backend/bridges_layers.py
.py
217c14367850cbf0
7
0
"""DIOSCURI community twins — topology anchor + graph links for Alien Monitor.""" from __future__ import annotations import os from typing import Any from dioscuri_status import ( dioscuri_community_links, dioscuri_public_url, dioscuri_theoros_collaboration, dioscuri_twin_children, ) from ecosystem_l...
alexar76/alien-monitor
backend/dioscuri_layers.py
.py
0cb41f18d5143afa
7
0
"""Shared 3D anchors for the Alien Monitor ecosystem graph. Keeps static nodes and the oracle ring in separate sectors so pulsing coronas do not overlap (e.g. Colony vs Desktop Apps). """ from __future__ import annotations import math # Federation + discovered peer mini-ring FEDERATION_ANCHOR = (0.0, 8.0, 2.0) FEDE...
alexar76/alien-monitor
backend/ecosystem_layout.py
.py
3813b84ea870fd3c
7
0
""" Agents the factory built, as participants in the economy. The catalog already shows what the factory *produced*. This shows what those products are *doing*: a product that ships as an autonomous agent keeps running after release, invokes capabilities from the mesh, pays for them, and reports counters. One ball on ...
alexar76/alien-monitor
backend/factory_agents.py
.py
b85f57a3fc4e81bf
7
0
"""Sync AI-Factory catalog into star-cluster nodes (no overlapping product planets).""" from __future__ import annotations import logging import os import re from typing import Any import httpx logger = logging.getLogger(__name__) DEFAULT_APP_URL = "http://127.0.0.1:9081" DEFAULT_PUBLIC_FACTORY_URL = "https://magi...
alexar76/alien-monitor
backend/factory_products.py
.py
cb2209562bac2891
7
0
"""GAIA physical-oracle node — topology anchor + graph links for Alien Monitor.""" from __future__ import annotations from typing import Any from ecosystem_layout import node_position from gaia_status import gaia_links, gaia_public_url def gaia_node_spec(*, mode: str = "real") -> dict[str, Any]: """Static GAIA...
alexar76/alien-monitor
backend/gaia_layers.py
.py
27807804d37fcb6c
7
0
"""HEPHAESTUS studio node — topology anchor + graph links for Alien Monitor. Placed between the hub (where the signed catalogue is) and the factory (where the pipeline executor is), because that is literally what it does: read what is on sale, compose a graph, hand it to the executor, and show the bill of materials th...
alexar76/alien-monitor
backend/hephaestus_layers.py
.py
b2dfb6f919fb990f
7
0
"""HEPHAESTUS — poll real pipeline runs and catalogue readiness for the monitor node. The monitor could draw a topology of services that had, as far as anything observable went, never traded with each other: the pipeline executor signs a bill of materials per run and, until the read routes existed, nothing could fetch...
alexar76/alien-monitor
backend/hephaestus_status.py
.py
29e27c2570f0b025
7
0
"""Stamp every Alien Monitor node with the hub it belongs to. Operators need this on the detail card — which federation Hub owns / lists / settles for this surface. Rules: - A hub node belongs to itself. - Signal Hunt game → Signal Hunt Hub. - Use Cases portal → Competing Lab Hub. - Other competing-galaxy nodes → Com...
alexar76/alien-monitor
backend/hub_affiliation.py
.py
32eacb57c13c3abe
7
0
"""LOGOS node definition for the Alien Monitor ecosystem graph.""" from __future__ import annotations from ecosystem_layout import node_position def logos_node_spec() -> dict: return { "id": "logos", "label": "LOGOS", "group": "cognition", "icon": "🧠", "description": ( ...
alexar76/alien-monitor
backend/logos_layers.py
.py
d187ed2f57fe78af
7
0
"""Agent Lottery node — topology anchor + live financial metrics for the monitor.""" from __future__ import annotations import os from typing import Any DEFAULT_LOTTERY_URL = "https://lottery.modelmarket.dev" TITHE_RATE = 0.20 # Hub sponsor.yaml default routing-fee tithe def lottery_url() -> str: return (os.e...
alexar76/alien-monitor
backend/lottery_layers.py
.py
118138420f2a3d59
7
0
"""METIS cognitive layer — topology anchor + graph links for Alien Monitor.""" from __future__ import annotations from typing import Any from ecosystem_layout import node_position from metis_status import metis_links, metis_public_url def metis_node_spec(*, mode: str = "real") -> dict[str, Any]: """Static METI...
alexar76/alien-monitor
backend/metis_layers.py
.py
276a6430fec1ed69
7
0
"""Poll METIS ``GET /health`` and proxy chat to its OpenAI-compatible API. Everything here is best-effort and offline-safe: if Metis is not running the node simply shows ``offline`` and the chat proxy returns a friendly error — the rest of the monitor is unaffected (Metis and the monitor are independent). """ from __...
alexar76/alien-monitor
backend/metis_status.py
.py
74c900838eecca27
7
0