Finish live run readiness tooling
This commit is contained in:
@@ -48,7 +48,7 @@ jobs:
|
|||||||
- name: Run setup dry-run smoke
|
- name: Run setup dry-run smoke
|
||||||
run: printf '2\n2\n2\n' | MNEMAZINE_SETUP_DRYRUN=1 bash setup.sh
|
run: printf '2\n2\n2\n' | MNEMAZINE_SETUP_DRYRUN=1 bash setup.sh
|
||||||
- name: Run live preflight smoke
|
- name: Run live preflight smoke
|
||||||
run: MNEMAZINE_PREFLIGHT_ALLOW_EMPTY=1 MNEMAZINE_PREFLIGHT_SKIP_REMOTE=1 npm run preflight:live
|
run: MNEMAZINE_PREFLIGHT_ALLOW_EMPTY=1 MNEMAZINE_PREFLIGHT_SKIP_REMOTE=1 MNEMAZINE_PREFLIGHT_SKIP_LLM=1 npm run preflight:live
|
||||||
- name: Run release test suite
|
- name: Run release test suite
|
||||||
run: npm test
|
run: npm test
|
||||||
- name: Run release gate directly
|
- name: Run release gate directly
|
||||||
|
|||||||
@@ -176,22 +176,21 @@ Before a real live run, run the preflight:
|
|||||||
npm run preflight:live
|
npm run preflight:live
|
||||||
```
|
```
|
||||||
|
|
||||||
It checks that tracked code is clean, `HEAD` matches `origin/main`, local
|
It checks that tracked code is clean, `HEAD` matches `origin/main`, the LLM
|
||||||
security gates pass, the Desktop dry-run passes, and the inbox has active
|
provider is available, local security gates pass, the Desktop dry-run passes,
|
||||||
files. If preflight fails, do not run `npm start`; fix the cause first.
|
and the inbox has active files. If preflight fails, do not run `npm start`; fix
|
||||||
|
the cause first.
|
||||||
|
|
||||||
After a live run, inspect the result:
|
After a live run, inspect the result:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
cat .mnemazine/state/last-run.json
|
npm run last-run -- --require-ok
|
||||||
cat .mnemazine/state/last-action-brief.md
|
|
||||||
ls -t reports/* | head
|
|
||||||
npm run complete -- --require-deep
|
npm run complete -- --require-deep
|
||||||
```
|
```
|
||||||
|
|
||||||
If a strict run fails before archive, that is safe: source files stay in the
|
If a strict run fails before archive, that is safe: source files stay in the
|
||||||
inbox. Do not move or delete them by hand. Read
|
inbox. Do not move or delete them by hand. Read
|
||||||
`.mnemazine/state/last-run.json`, fix the cause, and run again.
|
`npm run last-run`, fix the cause, and run again.
|
||||||
|
|
||||||
## Website Ingestion
|
## Website Ingestion
|
||||||
|
|
||||||
|
|||||||
+6
-7
@@ -175,22 +175,21 @@ npm run protocol:desktop:dry-run
|
|||||||
npm run preflight:live
|
npm run preflight:live
|
||||||
```
|
```
|
||||||
|
|
||||||
Он проверяет, что код чистый, `HEAD` совпадает с `origin/main`, локальные
|
Он проверяет, что код чистый, `HEAD` совпадает с `origin/main`, LLM-провайдер
|
||||||
security gates зелёные, Desktop dry-run проходит, а в inbox есть активные
|
доступен, локальные security gates зелёные, Desktop dry-run проходит, а в inbox
|
||||||
файлы. Если preflight упал — `npm start` не запускай, сначала исправь причину.
|
есть активные файлы. Если preflight упал — `npm start` не запускай, сначала
|
||||||
|
исправь причину.
|
||||||
|
|
||||||
После live-прогона проверь итог:
|
После live-прогона проверь итог:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
cat .mnemazine/state/last-run.json
|
npm run last-run -- --require-ok
|
||||||
cat .mnemazine/state/last-action-brief.md
|
|
||||||
ls -t reports/* | head
|
|
||||||
npm run complete -- --require-deep
|
npm run complete -- --require-deep
|
||||||
```
|
```
|
||||||
|
|
||||||
Если строгий прогон падает до архива — это нормально и безопасно: исходники
|
Если строгий прогон падает до архива — это нормально и безопасно: исходники
|
||||||
остаются в inbox. Не переносите и не удаляйте их руками. Читай
|
остаются в inbox. Не переносите и не удаляйте их руками. Читай
|
||||||
`.mnemazine/state/last-run.json`, исправляй причину и запускай снова.
|
вывод `npm run last-run`, исправляй причину и запускай снова.
|
||||||
|
|
||||||
## Парсинг сайтов
|
## Парсинг сайтов
|
||||||
|
|
||||||
|
|||||||
+3
-3
@@ -3,7 +3,7 @@
|
|||||||
Mnemazine has two operating modes:
|
Mnemazine has two operating modes:
|
||||||
|
|
||||||
- **Conservative (default):** local-only. No network, no LLM, no external services. This is what `node scripts/mnemazine-run.mjs` and `npm run synthesize` do by default.
|
- **Conservative (default):** local-only. No network, no LLM, no external services. This is what `node scripts/mnemazine-run.mjs` and `npm run synthesize` do by default.
|
||||||
- **Deep (opt-in):** uses an LLM agent (Claude by default, Codex at parity) to atomize one source into many focused notes (README "one source → ~20 notes") and to verify claims against their sources.
|
- **Deep (opt-in):** uses an LLM agent (auto-select: Claude, otherwise Codex) to atomize one source into many focused notes (README "one source → ~20 notes") and to verify claims against their sources.
|
||||||
|
|
||||||
Deep mode is **off unless you ask for it**. Nothing in the default pipeline reaches the network or an LLM.
|
Deep mode is **off unless you ask for it**. Nothing in the default pipeline reaches the network or an LLM.
|
||||||
|
|
||||||
@@ -30,13 +30,13 @@ If deep mode is requested directly but no LLM engine is available, plain `node s
|
|||||||
|
|
||||||
## The LLM bridge
|
## The LLM bridge
|
||||||
|
|
||||||
All LLM calls go through one provider-abstracted module: `scripts/mnemazine-llm.mjs` (`llmJson(prompt, schema, {provider, tools})`). The **code-first engine is Claude** (headless `claude -p`); **Codex is kept at parity** — the same contract, so anything that works via Claude also works via Codex. There is no third LLM client. `mnemazine-codex.mjs` remains as a thin back-compat shim.
|
All LLM calls go through one provider-abstracted module: `scripts/mnemazine-llm.mjs` (`llmJson(prompt, schema, {provider, tools})`). When `MNEMAZINE_LLM` is unset, Mnemazine uses Claude CLI when available and falls back to Codex CLI otherwise. Pin the engine explicitly with `MNEMAZINE_LLM=claude` or `MNEMAZINE_LLM=codex`. There is no third LLM client. `mnemazine-codex.mjs` remains as a thin back-compat shim.
|
||||||
|
|
||||||
### Environment variables
|
### Environment variables
|
||||||
|
|
||||||
| Variable | Default | Purpose |
|
| Variable | Default | Purpose |
|
||||||
|----------|---------|---------|
|
|----------|---------|---------|
|
||||||
| `MNEMAZINE_LLM` | `claude` | Engine: `claude` (primary) or `codex` (parity). |
|
| `MNEMAZINE_LLM` | auto | Engine: `claude` or `codex`. When unset: Claude if available, otherwise Codex. |
|
||||||
| `MNEMAZINE_CLAUDE_BIN` | auto-discover | Claude CLI: auto-found via login-shell PATH, common installs (npm/Homebrew/standalone/Desktop), or VSCode. Override to pin. |
|
| `MNEMAZINE_CLAUDE_BIN` | auto-discover | Claude CLI: auto-found via login-shell PATH, common installs (npm/Homebrew/standalone/Desktop), or VSCode. Override to pin. |
|
||||||
| `MNEMAZINE_CODEX_BIN` | `/Applications/Codex.app/Contents/Resources/codex` | Path to the Codex binary. |
|
| `MNEMAZINE_CODEX_BIN` | `/Applications/Codex.app/Contents/Resources/codex` | Path to the Codex binary. |
|
||||||
| `MNEMAZINE_LLM_TIMEOUT_MS` | `420000` | Per-call timeout. |
|
| `MNEMAZINE_LLM_TIMEOUT_MS` | `420000` | Per-call timeout. |
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
У Mnemazine два режима работы:
|
У Mnemazine два режима работы:
|
||||||
|
|
||||||
- **Консервативный (по умолчанию):** только локально. Без сети, без LLM, без внешних сервисов. Так работают `node scripts/mnemazine-run.mjs` и `npm run synthesize` по умолчанию.
|
- **Консервативный (по умолчанию):** только локально. Без сети, без LLM, без внешних сервисов. Так работают `node scripts/mnemazine-run.mjs` и `npm run synthesize` по умолчанию.
|
||||||
- **Deep (по запросу):** использует LLM-агента (Claude по умолчанию, Codex в паритете), чтобы разбить один источник на много сфокусированных заметок (README «один источник → ~20 заметок») и проверить утверждения по их источникам.
|
- **Deep (по запросу):** использует LLM-агента (авто-выбор: Claude, иначе Codex), чтобы разбить один источник на много сфокусированных заметок (README «один источник → ~20 заметок») и проверить утверждения по их источникам.
|
||||||
|
|
||||||
Deep-режим **выключен, пока вы его не попросите**. Ничто в стандартном конвейере не выходит в сеть и не зовёт LLM.
|
Deep-режим **выключен, пока вы его не попросите**. Ничто в стандартном конвейере не выходит в сеть и не зовёт LLM.
|
||||||
|
|
||||||
@@ -30,13 +30,13 @@ npm run synthesize -- --deep
|
|||||||
|
|
||||||
## Мост LLM
|
## Мост LLM
|
||||||
|
|
||||||
Все вызовы LLM идут через один провайдер-абстрактный модуль: `scripts/mnemazine-llm.mjs` (`llmJson(prompt, schema, {provider, tools})`). **Движок в первую очередь — Claude** (headless `claude -p`); **Codex держится в паритете** — тот же контракт, поэтому всё, что работает через Claude, работает и через Codex. Третьего LLM-клиента нет. `mnemazine-codex.mjs` остаётся тонким shim'ом обратной совместимости.
|
Все вызовы LLM идут через один провайдер-абстрактный модуль: `scripts/mnemazine-llm.mjs` (`llmJson(prompt, schema, {provider, tools})`). Если `MNEMAZINE_LLM` не задан, Mnemazine берёт Claude CLI, когда он доступен, иначе Codex CLI. Можно зафиксировать движок явно: `MNEMAZINE_LLM=claude` или `MNEMAZINE_LLM=codex`. Третьего LLM-клиента нет. `mnemazine-codex.mjs` остаётся тонким shim'ом обратной совместимости.
|
||||||
|
|
||||||
### Переменные окружения
|
### Переменные окружения
|
||||||
|
|
||||||
| Переменная | По умолчанию | Назначение |
|
| Переменная | По умолчанию | Назначение |
|
||||||
|----------|---------|---------|
|
|----------|---------|---------|
|
||||||
| `MNEMAZINE_LLM` | `claude` | Движок: `claude` (primary) или `codex` (паритет). |
|
| `MNEMAZINE_LLM` | авто | Движок: `claude` или `codex`. Если не задан — Claude при наличии, иначе Codex. |
|
||||||
| `MNEMAZINE_CLAUDE_BIN` | авто | Claude CLI: авто-поиск через login-shell PATH, типовые установки (npm/Homebrew/standalone/Desktop), VSCode. Переопределите чтобы зафиксировать. |
|
| `MNEMAZINE_CLAUDE_BIN` | авто | Claude CLI: авто-поиск через login-shell PATH, типовые установки (npm/Homebrew/standalone/Desktop), VSCode. Переопределите чтобы зафиксировать. |
|
||||||
| `MNEMAZINE_CODEX_BIN` | `/Applications/Codex.app/Contents/Resources/codex` | Путь к бинарю Codex. |
|
| `MNEMAZINE_CODEX_BIN` | `/Applications/Codex.app/Contents/Resources/codex` | Путь к бинарю Codex. |
|
||||||
| `MNEMAZINE_LLM_TIMEOUT_MS` | `420000` | Таймаут одного вызова. |
|
| `MNEMAZINE_LLM_TIMEOUT_MS` | `420000` | Таймаут одного вызова. |
|
||||||
|
|||||||
@@ -76,13 +76,16 @@ npm run preflight:live
|
|||||||
```
|
```
|
||||||
|
|
||||||
Before a real `npm start`, this checks that tracked code is clean, `HEAD`
|
Before a real `npm start`, this checks that tracked code is clean, `HEAD`
|
||||||
matches `origin/main`, the local security audit passes, the Desktop dry-run
|
matches `origin/main`, the LLM provider is available, the local security audit
|
||||||
passes, and the inbox has active files. Empty inbox or dirty code is a failure.
|
passes, the Desktop dry-run passes, and the inbox has active files. Empty inbox,
|
||||||
To test the command itself without files, temporarily set
|
dirty code, or a missing LLM provider is a failure. To test the command itself
|
||||||
`MNEMAZINE_PREFLIGHT_ALLOW_EMPTY=1`.
|
without files, temporarily set `MNEMAZINE_PREFLIGHT_ALLOW_EMPTY=1`.
|
||||||
|
|
||||||
After a live run, inspect `.mnemazine/state/last-run.json`,
|
After a live run, inspect the result with:
|
||||||
`.mnemazine/state/last-action-brief.md`, and the newest files in `reports/`.
|
|
||||||
|
```bash
|
||||||
|
npm run last-run -- --require-ok
|
||||||
|
```
|
||||||
|
|
||||||
## Agent Skills
|
## Agent Skills
|
||||||
|
|
||||||
|
|||||||
@@ -76,12 +76,16 @@ npm run preflight:live
|
|||||||
```
|
```
|
||||||
|
|
||||||
Перед настоящим `npm start` команда проверяет чистоту tracked-кода, совпадение
|
Перед настоящим `npm start` команда проверяет чистоту tracked-кода, совпадение
|
||||||
с `origin/main`, локальный security audit, Desktop dry-run и наличие файлов в
|
с `origin/main`, доступность LLM-провайдера, локальный security audit, Desktop
|
||||||
inbox. Пустой inbox или грязный код — fail. Для проверки самой команды без
|
dry-run и наличие файлов в inbox. Пустой inbox, грязный код или недоступный LLM
|
||||||
файлов можно временно поставить `MNEMAZINE_PREFLIGHT_ALLOW_EMPTY=1`.
|
— fail. Для проверки самой команды без файлов можно временно поставить
|
||||||
|
`MNEMAZINE_PREFLIGHT_ALLOW_EMPTY=1`.
|
||||||
|
|
||||||
После live-прогона смотри `.mnemazine/state/last-run.json`,
|
После live-прогона смотри итог одной командой:
|
||||||
`.mnemazine/state/last-action-brief.md` и свежие файлы в `reports/`.
|
|
||||||
|
```bash
|
||||||
|
npm run last-run -- --require-ok
|
||||||
|
```
|
||||||
|
|
||||||
## Agent Skills
|
## Agent Skills
|
||||||
|
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
"audit:security": "npm audit --audit-level=moderate",
|
"audit:security": "npm audit --audit-level=moderate",
|
||||||
"audit:local": "bash scripts/mnemazine-audit-local.sh",
|
"audit:local": "bash scripts/mnemazine-audit-local.sh",
|
||||||
"preflight:live": "bash scripts/mnemazine-live-preflight.sh",
|
"preflight:live": "bash scripts/mnemazine-live-preflight.sh",
|
||||||
|
"last-run": "node scripts/mnemazine-live-status.mjs",
|
||||||
"selftest:security": "node scripts/mnemazine-verify.mjs --selftest && node scripts/mnemazine-webapp-server.mjs --selftest && node scripts/mnemazine-telegram-bot.mjs --selftest && node scripts/mnemazine-weekly-state.mjs --selftest",
|
"selftest:security": "node scripts/mnemazine-verify.mjs --selftest && node scripts/mnemazine-webapp-server.mjs --selftest && node scripts/mnemazine-telegram-bot.mjs --selftest && node scripts/mnemazine-weekly-state.mjs --selftest",
|
||||||
"run": "node scripts/mnemazine-run.mjs",
|
"run": "node scripts/mnemazine-run.mjs",
|
||||||
"protocol:desktop": "bash scripts/mnemazine-desktop-protocol.sh",
|
"protocol:desktop": "bash scripts/mnemazine-desktop-protocol.sh",
|
||||||
|
|||||||
@@ -32,6 +32,23 @@ if [ ! -f package-lock.json ]; then
|
|||||||
bad "package-lock.json missing; npm audit/ci are not reproducible"
|
bad "package-lock.json missing; npm audit/ci are not reproducible"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ "${MNEMAZINE_PREFLIGHT_SKIP_LLM:-0}" != "1" ]; then
|
||||||
|
provider_hint="${MNEMAZINE_LLM:-}"
|
||||||
|
if provider="$(node --input-type=module - "$provider_hint" <<'NODE'
|
||||||
|
import { activeProvider, llmAvailable } from './scripts/mnemazine-llm.mjs'
|
||||||
|
const provider = process.argv[2] || activeProvider()
|
||||||
|
if (!llmAvailable(provider)) process.exit(1)
|
||||||
|
console.log(provider)
|
||||||
|
NODE
|
||||||
|
)"; then
|
||||||
|
ok "llm provider available: $provider"
|
||||||
|
else
|
||||||
|
bad "llm provider unavailable; set MNEMAZINE_LLM=codex or install/configure Claude/Codex"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
warn "llm provider check skipped"
|
||||||
|
fi
|
||||||
|
|
||||||
if git rev-parse --is-inside-work-tree >/dev/null 2>&1; then
|
if git rev-parse --is-inside-work-tree >/dev/null 2>&1; then
|
||||||
dirty="$(git status --porcelain --untracked-files=no)"
|
dirty="$(git status --porcelain --untracked-files=no)"
|
||||||
if [ -n "$dirty" ]; then
|
if [ -n "$dirty" ]; then
|
||||||
|
|||||||
Executable
+170
@@ -0,0 +1,170 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
import { promises as fs } from 'node:fs'
|
||||||
|
import { existsSync } from 'node:fs'
|
||||||
|
import path from 'node:path'
|
||||||
|
|
||||||
|
const argv = process.argv.slice(2)
|
||||||
|
|
||||||
|
function arg(name, fallback = '') {
|
||||||
|
const hit = argv.find(a => a === `--${name}` || a.startsWith(`--${name}=`))
|
||||||
|
if (!hit) return fallback
|
||||||
|
return hit.includes('=') ? hit.split('=').slice(1).join('=') : argv[argv.indexOf(hit) + 1] || fallback
|
||||||
|
}
|
||||||
|
|
||||||
|
const JSON_OUT = argv.includes('--json')
|
||||||
|
const REQUIRE_OK = argv.includes('--require-ok')
|
||||||
|
const ROOT = path.resolve(arg('root', process.env.MNEMAZINE_ROOT || process.cwd()))
|
||||||
|
|
||||||
|
function expandHome(value) {
|
||||||
|
const home = process.env.HOME || ''
|
||||||
|
return String(value || '').replace(/^\$HOME(?=\/|$)/, home).replace(/^~(?=\/|$)/, home)
|
||||||
|
}
|
||||||
|
|
||||||
|
function unquote(value) {
|
||||||
|
const trimmed = String(value || '').trim()
|
||||||
|
if ((trimmed.startsWith('"') && trimmed.endsWith('"')) || (trimmed.startsWith("'") && trimmed.endsWith("'"))) {
|
||||||
|
return trimmed.slice(1, -1)
|
||||||
|
}
|
||||||
|
return trimmed
|
||||||
|
}
|
||||||
|
|
||||||
|
async function localConfig() {
|
||||||
|
const file = path.join(ROOT, '.mnemazine/config.local.sh')
|
||||||
|
const body = await fs.readFile(file, 'utf8').catch(() => '')
|
||||||
|
const out = {}
|
||||||
|
for (const line of body.split('\n')) {
|
||||||
|
const match = line.match(/^\s*(?:export\s+)?(MNEMAZINE_(?:INBOX|VAULT|REPORTS|STATE))=(.+?)\s*$/)
|
||||||
|
if (match) out[match[1]] = expandHome(unquote(match[2]))
|
||||||
|
}
|
||||||
|
return out
|
||||||
|
}
|
||||||
|
|
||||||
|
async function readJson(file, fallback = null) {
|
||||||
|
try { return JSON.parse(await fs.readFile(file, 'utf8')) } catch { return fallback }
|
||||||
|
}
|
||||||
|
|
||||||
|
async function activeCount(dir) {
|
||||||
|
let count = 0
|
||||||
|
for (const item of await fs.readdir(dir, { withFileTypes: true }).catch(() => [])) {
|
||||||
|
if (item.isFile() && !item.name.startsWith('.')) count += 1
|
||||||
|
}
|
||||||
|
return count
|
||||||
|
}
|
||||||
|
|
||||||
|
async function newestFile(dir, ext) {
|
||||||
|
const files = []
|
||||||
|
for (const item of await fs.readdir(dir, { withFileTypes: true }).catch(() => [])) {
|
||||||
|
if (!item.isFile() || !item.name.endsWith(ext)) continue
|
||||||
|
const file = path.join(dir, item.name)
|
||||||
|
files.push({ file, mtimeMs: (await fs.stat(file)).mtimeMs })
|
||||||
|
}
|
||||||
|
return files.sort((a, b) => b.mtimeMs - a.mtimeMs)[0]?.file || ''
|
||||||
|
}
|
||||||
|
|
||||||
|
function rel(file, root = ROOT) {
|
||||||
|
return file ? path.relative(root, file) || '.' : null
|
||||||
|
}
|
||||||
|
|
||||||
|
async function status(root = ROOT) {
|
||||||
|
const cfg = root === ROOT ? await localConfig() : {}
|
||||||
|
const stateDir = path.resolve(process.env.MNEMAZINE_STATE || cfg.MNEMAZINE_STATE || path.join(root, '.mnemazine/state'))
|
||||||
|
const reportsDir = path.resolve(process.env.MNEMAZINE_REPORTS || cfg.MNEMAZINE_REPORTS || path.join(root, 'reports'))
|
||||||
|
const inboxDir = path.resolve(process.env.MNEMAZINE_INBOX || cfg.MNEMAZINE_INBOX || path.join(root, 'inbox'))
|
||||||
|
const nestedInbox = path.join(inboxDir, 'mnemazine-inbox')
|
||||||
|
const lastRunFile = path.join(stateDir, 'last-run.json')
|
||||||
|
const briefFile = path.join(stateDir, 'last-action-brief.md')
|
||||||
|
const lastRun = await readJson(lastRunFile)
|
||||||
|
const latestHtml = await newestFile(reportsDir, '.html')
|
||||||
|
const latestMd = await newestFile(reportsDir, '.md')
|
||||||
|
const inbox = await activeCount(inboxDir)
|
||||||
|
const nested = existsSync(nestedInbox) ? await activeCount(nestedInbox) : 0
|
||||||
|
const failures = []
|
||||||
|
if (!lastRun) failures.push('last-run.json missing')
|
||||||
|
if (lastRun && !lastRun.ok) failures.push(lastRun.failure || (lastRun.failures || []).join('; ') || 'last run failed')
|
||||||
|
if (lastRun?.deep_required && !lastRun.deep) failures.push('strict run was not deep')
|
||||||
|
if (lastRun?.deep_required && lastRun?.synthesize?.degraded) failures.push('deep synthesis degraded')
|
||||||
|
if (lastRun?.deep_required && lastRun?.strict_archive_knowledge !== true) failures.push('strict archive gate missing')
|
||||||
|
if (!existsSync(briefFile)) failures.push('last-action-brief.md missing')
|
||||||
|
if (!latestHtml) failures.push('HTML report missing')
|
||||||
|
return {
|
||||||
|
ok: failures.length === 0,
|
||||||
|
failures,
|
||||||
|
inbox,
|
||||||
|
nested_inbox: nested,
|
||||||
|
last_run: lastRun ? {
|
||||||
|
ok: Boolean(lastRun.ok),
|
||||||
|
processed: Number(lastRun.processed || 0),
|
||||||
|
cached_only: Number(lastRun.cached_only || 0),
|
||||||
|
failed: Number(lastRun.failed || 0),
|
||||||
|
archived: Number(lastRun.archived || 0),
|
||||||
|
deep: Boolean(lastRun.deep),
|
||||||
|
deep_required: Boolean(lastRun.deep_required),
|
||||||
|
strict_archive_knowledge: Boolean(lastRun.strict_archive_knowledge),
|
||||||
|
atomized: Number(lastRun.synthesize?.atomized || 0),
|
||||||
|
enriched: Number(lastRun.synthesize?.enriched || 0),
|
||||||
|
started_at: lastRun.started_at || null,
|
||||||
|
finished_at: lastRun.finished_at || null
|
||||||
|
} : null,
|
||||||
|
paths: {
|
||||||
|
inbox: inboxDir,
|
||||||
|
state: rel(stateDir, root),
|
||||||
|
last_run: rel(lastRunFile, root),
|
||||||
|
brief: existsSync(briefFile) ? rel(briefFile, root) : null,
|
||||||
|
latest_html: rel(latestHtml, root),
|
||||||
|
latest_md: rel(latestMd, root)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function selftest() {
|
||||||
|
const temp = await fs.mkdtemp(path.join(process.env.TMPDIR || '/tmp', 'mnemazine-live-status-'))
|
||||||
|
await fs.mkdir(path.join(temp, '.mnemazine/state'), { recursive: true })
|
||||||
|
await fs.mkdir(path.join(temp, 'reports'), { recursive: true })
|
||||||
|
await fs.mkdir(path.join(temp, 'inbox'), { recursive: true })
|
||||||
|
await fs.writeFile(path.join(temp, '.mnemazine/state/last-action-brief.md'), '# Brief\n', 'utf8')
|
||||||
|
await fs.writeFile(path.join(temp, 'reports/live.html'), '<!doctype html><html></html>', 'utf8')
|
||||||
|
await fs.writeFile(path.join(temp, 'reports/live.md'), '# Report\n', 'utf8')
|
||||||
|
await fs.writeFile(path.join(temp, '.mnemazine/state/last-run.json'), JSON.stringify({
|
||||||
|
ok: true,
|
||||||
|
processed: 2,
|
||||||
|
cached_only: 1,
|
||||||
|
failed: 0,
|
||||||
|
archived: 3,
|
||||||
|
deep: true,
|
||||||
|
deep_required: true,
|
||||||
|
strict_archive_knowledge: true,
|
||||||
|
synthesize: { atomized: 2, enriched: 2 },
|
||||||
|
started_at: '2099-01-01T00:00:00.000Z',
|
||||||
|
finished_at: '2099-01-01T00:01:00.000Z'
|
||||||
|
}, null, 2), 'utf8')
|
||||||
|
const s = await status(temp)
|
||||||
|
await fs.rm(temp, { recursive: true, force: true })
|
||||||
|
if (!s.ok || s.last_run.processed !== 2 || s.last_run.archived !== 3) throw new Error('live status selftest failed')
|
||||||
|
console.log('live-status selftest ok')
|
||||||
|
}
|
||||||
|
|
||||||
|
function printText(s) {
|
||||||
|
const run = s.last_run
|
||||||
|
console.log(`Status: ${s.ok ? 'ok' : 'failed'}`)
|
||||||
|
if (s.failures.length) console.log(`Failures: ${s.failures.join('; ')}`)
|
||||||
|
console.log(`Inbox: ${s.inbox}${s.nested_inbox ? ` (+${s.nested_inbox} nested)` : ''}`)
|
||||||
|
if (run) {
|
||||||
|
console.log(`Run: processed=${run.processed} cached=${run.cached_only} failed=${run.failed} archived=${run.archived}`)
|
||||||
|
console.log(`Deep: ${run.deep ? 'yes' : 'no'} required=${run.deep_required ? 'yes' : 'no'} strict_archive=${run.strict_archive_knowledge ? 'yes' : 'no'}`)
|
||||||
|
console.log(`Atoms: atomized=${run.atomized} enriched=${run.enriched}`)
|
||||||
|
if (run.finished_at) console.log(`Finished: ${run.finished_at}`)
|
||||||
|
}
|
||||||
|
if (s.paths.latest_html) console.log(`Report: ${s.paths.latest_html}`)
|
||||||
|
if (s.paths.brief) console.log(`Brief: ${s.paths.brief}`)
|
||||||
|
if (s.paths.last_run) console.log(`State: ${s.paths.last_run}`)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (argv.includes('--selftest')) {
|
||||||
|
selftest().catch(error => { console.error(error.message || error); process.exit(1) })
|
||||||
|
} else {
|
||||||
|
status().then(s => {
|
||||||
|
if (JSON_OUT) console.log(JSON.stringify(s, null, 2))
|
||||||
|
else printText(s)
|
||||||
|
if (REQUIRE_OK && !s.ok) process.exit(1)
|
||||||
|
}).catch(error => { console.error(error.message || error); process.exit(1) })
|
||||||
|
}
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
// Provider-abstracted LLM bridge for Mnemazine. Code-first engine is Claude
|
// Provider-abstracted LLM bridge for Mnemazine. Code-first engine is Claude
|
||||||
// (headless `claude -p`); Codex is kept at parity (same llmJson contract) so
|
// (headless `claude -p`); Codex is kept at parity (same llmJson contract) so
|
||||||
// anything that works via Claude also works via Codex.
|
// anything that works via Claude also works via Codex.
|
||||||
// provider: MNEMAZINE_LLM = 'claude' (default) | 'codex'
|
// provider: MNEMAZINE_LLM = 'claude' | 'codex' (unset = auto: Claude, else Codex)
|
||||||
// Both run as schema-instructed, web-capable headless agents. Default pipeline
|
// Both run as schema-instructed, web-capable headless agents. Default pipeline
|
||||||
// never calls either — only the opt-in --deep path does.
|
// never calls either — only the opt-in --deep path does.
|
||||||
import { spawnSync, spawn } from 'node:child_process'
|
import { spawnSync, spawn } from 'node:child_process'
|
||||||
@@ -27,7 +27,7 @@ function runProc(bin, args, { input, timeoutMs, cwd } = {}) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const DEFAULT_PROVIDER = process.env.MNEMAZINE_LLM || 'claude'
|
const CONFIG_PROVIDER = process.env.MNEMAZINE_LLM || ''
|
||||||
const TIMEOUT_MS = Number(process.env.MNEMAZINE_LLM_TIMEOUT_MS || '420000')
|
const TIMEOUT_MS = Number(process.env.MNEMAZINE_LLM_TIMEOUT_MS || '420000')
|
||||||
const CODEX_BIN = process.env.MNEMAZINE_CODEX_BIN || '/Applications/Codex.app/Contents/Resources/codex'
|
const CODEX_BIN = process.env.MNEMAZINE_CODEX_BIN || '/Applications/Codex.app/Contents/Resources/codex'
|
||||||
|
|
||||||
@@ -73,11 +73,18 @@ function binExists(bin) {
|
|||||||
return which.status === 0 && Boolean(which.stdout.trim())
|
return which.status === 0 && Boolean(which.stdout.trim())
|
||||||
}
|
}
|
||||||
|
|
||||||
export function activeProvider(opts = {}) {
|
export function defaultProvider() {
|
||||||
return opts.provider || DEFAULT_PROVIDER
|
if (CONFIG_PROVIDER) return CONFIG_PROVIDER
|
||||||
|
if (binExists(resolveClaudeBin())) return 'claude'
|
||||||
|
if (binExists(CODEX_BIN)) return 'codex'
|
||||||
|
return 'claude'
|
||||||
}
|
}
|
||||||
|
|
||||||
export function llmAvailable(provider = DEFAULT_PROVIDER) {
|
export function activeProvider(opts = {}) {
|
||||||
|
return opts.provider || defaultProvider()
|
||||||
|
}
|
||||||
|
|
||||||
|
export function llmAvailable(provider = activeProvider()) {
|
||||||
return provider === 'codex' ? binExists(CODEX_BIN) : binExists(resolveClaudeBin())
|
return provider === 'codex' ? binExists(CODEX_BIN) : binExists(resolveClaudeBin())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -71,6 +71,7 @@ async function checkSyntax() {
|
|||||||
'scripts/mnemazine-digest.mjs',
|
'scripts/mnemazine-digest.mjs',
|
||||||
'scripts/mnemazine-report-quality-gate.mjs',
|
'scripts/mnemazine-report-quality-gate.mjs',
|
||||||
'scripts/mnemazine-complete-check.mjs',
|
'scripts/mnemazine-complete-check.mjs',
|
||||||
|
'scripts/mnemazine-live-status.mjs',
|
||||||
'scripts/mnemazine-release-check.mjs'
|
'scripts/mnemazine-release-check.mjs'
|
||||||
]
|
]
|
||||||
for (const script of scripts) {
|
for (const script of scripts) {
|
||||||
@@ -333,6 +334,7 @@ async function qualityAndPublicChecks() {
|
|||||||
await must('webapp selftest', process.execPath, ['scripts/mnemazine-webapp-server.mjs', '--selftest'])
|
await must('webapp selftest', process.execPath, ['scripts/mnemazine-webapp-server.mjs', '--selftest'])
|
||||||
await must('telegram bot selftest', process.execPath, ['scripts/mnemazine-telegram-bot.mjs', '--selftest'])
|
await must('telegram bot selftest', process.execPath, ['scripts/mnemazine-telegram-bot.mjs', '--selftest'])
|
||||||
await must('weekly state selftest', process.execPath, ['scripts/mnemazine-weekly-state.mjs', '--selftest'])
|
await must('weekly state selftest', process.execPath, ['scripts/mnemazine-weekly-state.mjs', '--selftest'])
|
||||||
|
await must('live status selftest', process.execPath, ['scripts/mnemazine-live-status.mjs', '--selftest'])
|
||||||
await must('demo vault quality', 'npm', ['run', 'quality', '--', '--vault', 'demo/vault'])
|
await must('demo vault quality', 'npm', ['run', 'quality', '--', '--vault', 'demo/vault'])
|
||||||
await reportQualityGateSmoke()
|
await reportQualityGateSmoke()
|
||||||
await completeGateSmoke()
|
await completeGateSmoke()
|
||||||
|
|||||||
@@ -7,14 +7,9 @@ cd "$ROOT"
|
|||||||
git pull --ff-only
|
git pull --ff-only
|
||||||
MNEMAZINE_FROM_SETUP=1 MNEMAZINE_SKIP_DEPS=1 bash install.sh
|
MNEMAZINE_FROM_SETUP=1 MNEMAZINE_SKIP_DEPS=1 bash install.sh
|
||||||
|
|
||||||
bash -n bin/mnemazine install.sh setup.sh scripts/mnemazine-desktop-protocol.sh scripts/mnemazine-telegram-sync.sh scripts/mnemazine-update.sh
|
npm run audit:local
|
||||||
node --check scripts/mnemazine-run.mjs
|
|
||||||
node --check scripts/mnemazine-complete-check.mjs
|
|
||||||
node --check scripts/mnemazine-synthesize.mjs
|
|
||||||
node --check scripts/mnemazine-verify.mjs
|
|
||||||
npm run selftest:security
|
|
||||||
npm run audit:security
|
|
||||||
|
|
||||||
echo "Mnemazine updated."
|
echo "Mnemazine updated."
|
||||||
|
echo "Preflight before live run: npm run preflight:live"
|
||||||
echo "Run from chat: Mnemazine"
|
echo "Run from chat: Mnemazine"
|
||||||
echo "Run from terminal: mnemazine"
|
echo "Run from terminal: mnemazine"
|
||||||
|
|||||||
Reference in New Issue
Block a user