37 Commits

Author SHA1 Message Date
xiaoju 7d0200fa15 docs: add implementation plan for @uncaged/workflow extraction
Refs #320
2026-05-05 10:16:33 +00:00
xiaoju 8dd82d99da refactor(core): remove WorkflowTrigger from SenseTrigger — shell only
Senses trigger shell commands only. Workflows are invoked via CLI.

SenseTrigger is now { command: string } — no discriminated union.

Closes #318

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-02 12:33:38 +00:00
xiaoju fc7fc9158c docs: update all docs/conventions for stateful sense, remove stale refs
Phase 4 of RFC #308: Stateful Sense refactor.

- CLAUDE.md: updated diagram, tables, examples (no more Signal)
- Cleaned stale Signal Bus / DrizzleDB / _signals / retention refs
  across READMEs, .cursor rules, copilot instructions, .knowledge
- Removed drizzle-orm from core package.json (no longer used)
- Updated pnpm-lock.yaml

Refs #308
2026-05-01 10:09:01 +00:00
xiaomo 49f3d91d1b chore: dead code cleanup — remove unused exports and fix stale docs
- Delete createEchoAgent (daemon, never referenced)
- Delete isDryRun (workflow-utils, deprecated, always false)
- Delete KNOWN_AGENT_ADAPTER_IDS (core, never referenced)
- Remove parseDurationStringToMs, labelSenseTrigger from core public API
- Remove spawnSafe re-export from workflow-utils
- Fix core/README.md stale API names
- Clean stale hermes-options.ts comment

Closes #302
2026-04-30 14:29:45 +00:00
xiaoju 9855eba894 docs: RFC-004 package architecture — shareable workflows, roles & senses 2026-04-29 13:29:53 +00:00
xiaoju 7de75b5df7 rfc-003: remove timeout from RoleSpec, it's an adapter concern
RoleSpec now has exactly 3 fields: adapter, prompt, meta.
Timeout belongs to adapter config — different timeouts = different adapter instances.

Refs #245
小橘 🍊(NEKO Team)
2026-04-29 08:34:00 +00:00
xiaoju 4be465918c rfc-003: adapter as direct function reference, not string
- RoleSpec.adapter: string → AgentFn (direct import)
- Each adapter exports default instance + factory
- No adapter map, no registry, no lookup — compile-time safety
- TypeScript catches missing adapters at import time

Refs #245
小橘 🍊(NEKO Team)
2026-04-29 08:23:59 +00:00
xiaoju 732669fab5 rfc-003: simplify agent layer — remove registry, roles declare adapter directly
- Remove nerve.yaml agents config (keep only extract + knowledge)
- RoleSpec.agent → RoleSpec.adapter
- buildWorkflowSpec receives adapter map directly
- Extract merge: 3-level → 2-level (global → role)
- Update open questions (embedding service resolved)

小橘 🍊(NEKO Team)
2026-04-29 08:11:54 +00:00
xiaoju ce5462cb59 feat(knowledge): integrate real embedding service
Replace placeholder fake embeddings with real embed service calls:
- Add embed-service.ts (remote API + cosine similarity + fallback)
- knowledge-db stores externally-provided embeddings
- sync.ts/query.ts now async, call embed service
- CLI commands updated for async API

WIP: tests need updating for async changes

Refs #234
2026-04-29 07:43:05 +00:00
xiaoju 18584641bd docs(rfc): RFC-003 — adapter packages + dynamic prompts
- Adapter packages: each adapter in own package (@nerve/adapter-cursor, etc.)
- AgentRegistry accepts adapter factories at construction (plugin model)
- Migration path: move spawn logic from workflow-utils to adapter packages
- Dynamic prompts: RoleSpec.prompt supports string | async function
- Workspace only installs adapters it uses

Ref: #234
2026-04-29 07:08:34 +00:00
xiaoju 623fb3cd3a fix(cli): knowledge query --repo flag, remove -r alias (conflicts with global remote flag)
- Rename -r to --repo for knowledge query scope
- Update RFC docs to match
- Fix biome format issues
- Add assertZodMetaSchemas export
- KNOWN_AGENT_ADAPTER_IDS: add cursor/hermes/codex

Self-tested: nerve knowledge sync + query work correctly
2026-04-29 06:02:24 +00:00
xiaoju 7a4e16381c docs(rfc): address review — resolve open questions, add error handling/hot-reload/context/validation
- model: auto = delegate to adapter's default strategy
- ExtractFn: retry once + throw ExtractError, three-level merge (global → agent → role)
- Agent hot-reload: AgentRegistry rebuilds on config change, running threads unaffected
- WorkflowContext: add workdir + AbortSignal
- Configuration validation: nerve validate checks agent name refs
- WorkflowSpec compile: runtime lazy compile at daemon startup/hot-reload
- Compatibility: existing hand-written Role functions continue to work (not breaking)
- Resolved 3 of 5 open questions, 2 remaining (long-term memory, embedding service)

Refs #233
2026-04-29 04:26:48 +00:00
xiaoju aecced587c docs(rfc): knowledge layer — built-in, local-first, repo-scoped
Replaces the Alysaril delegation with a built-in knowledge feature:
- knowledge.yaml at repo root with include/exclude
- knowledge.db (SQLite) stores chunks + embeddings locally
- Remote service only for embedding computation + content-hash cache
- In-memory cosine search (sufficient for project scale)
- CLI: nerve knowledge sync/query with -r and -g flags

Refs #233
2026-04-29 04:12:09 +00:00
xiaoju 3950f0e278 docs(rfc): add Knowledge Layer section — delegate to Alysaril
Project knowledge is not a nerve feature. Nerve runtime does not hardcode
knowledge paths; loading is a prompt concern. Adds Alysaril as the
independent knowledge base tool.

小橘 <xiaoju@shazhou.work>
2026-04-29 03:25:43 +00:00
xiaoju ea07c2c667 docs(rfc): RFC-003 agent configuration layer
Separates agent infrastructure (nerve.yaml) from workflow business logic.
Key decisions:
- Agent = domain capability, Role = scenario specialization
- Unified AgentFn protocol: (prompt, context) → string
- Independent extract layer for structured output
- Two-layer timeout (agent default, role override)
- No runtime fallback, fail fast

小橘 <xiaoju@shazhou.work>
2026-04-29 01:26:41 +00:00
xiaoju b269f76b33 refactor(daemon): rename reflex-scheduler → sense-scheduler
Rename ReflexScheduler to SenseScheduler, update all file names,
imports, comments, test descriptions, and log source values.

Fixes #202
2026-04-27 12:07:22 +00:00
tuanzi 0d0b139890 docs: add Khala MVP implementation plan 2026-04-25 04:44:22 +00:00
xiaoju 57881533a8 docs: fix publish skill — use pnpm publish for workspace:* conversion
小橘 <xiaoju@shazhou.work>
2026-04-23 00:43:51 +00:00
xiaoju b5913263e4 docs: add publish and setup skills
小橘 <xiaoju@shazhou.work>
2026-04-23 00:31:27 +00:00
xiaoju 9802f68380 docs: add RFC-002 Workflow Engine
Defines the workflow execution engine design:
- Thread lifecycle with event sourcing
- Concurrency control (drop/queue overflow)
- WorkflowManager, workflow worker process model
- IPC extension, crash recovery, hot reload
- 4-phase implementation plan

小橘 <xiaoju@shazhou.work>
2026-04-22 11:26:28 +00:00
xiaoju 852cad9c60 docs(rfc-001): archival watermark + workflow_runs materialized table
- Cold archival: meta table with archived_up_to watermark for crash-safe recovery
- Workflow state: workflow_runs materialized table (UPSERT in same txn as log write)
  - O(active) queries instead of full table scan
  - Derivable from logs if lost

小橘 <xiaoju@shazhou.work>
2026-04-22 08:15:28 +00:00
xiaoju f5c561173d docs(rfc-001): add Log concept, append-only storage architecture, workflow event sourcing
- §2.4: Log as data asset, not trigger source (anti-avalanche constraint)
- §3: Add Log to terminology table
- §5.4: New storage architecture section
  - Unified logs table (append-only SQLite)
  - Workflow state via event sourcing (no mutable tables)
  - Cold archival: >30d data exported to daily JSONL files
- §5.6: Error handling now writes logs instead of error signals
- §8: Directory structure updated with logs.db and archive/
- §10: Design principles updated (8 principles, +1 log rule)
- Thread outputs are now Logs, not Signals

小橘 <xiaoju@shazhou.work>
2026-04-22 08:06:09 +00:00
xiaoju 1949007c99 refactor: ban optional properties, use T|null + discriminated unions
- Add coding convention: no '?:', use explicit 'T | null'
- ReflexConfig → discriminated union (SenseReflexConfig | WorkflowReflexConfig)
- All optional fields → explicit null (throttle, timeout, interval, on, maxQueue, workflows)
- Add exactOptionalPropertyTypes to tsconfig
- Add lib: ES2022 to tsconfig
- Refactor validateReflexConfig to reduce cognitive complexity

小橘 <xiaoju@shazhou.work>
2026-04-22 07:33:14 +00:00
xiaoju a7126c453f chore: monorepo scaffolding — pnpm workspaces, biome, tsup, coding conventions
- packages/core, packages/cli, packages/daemon
- biome: noDefaultExport, useNodejsImportProtocol, noStaticOnlyClass
- docs/coding-conventions.md: 函数式优先,type over interface
2026-04-22 06:05:21 +00:00
xiaoju 643c353cc3 feat(rfc-001): 回应小墨 review — runtime 注入 db/peers、migration rollback、drizzle config、schema 新鲜度 2026-04-22 05:54:56 +00:00
xiaoju 8a3937f0e1 feat(rfc-001): Drizzle 作为 Sense schema 标准工具链
- schema.ts 为 single source of truth,migration 由 drizzle-kit 自动生成
- Sense 目录结构从单文件改为目录(schema.ts + index.ts + migrations/)
- 设计理由:开发者是 Coding Agent,确定性工具链优于概率模型自律
- 更新 §4.1 存储设计、§8 目录结构

小橘 <xiaoju@shazhou.work>
2026-04-22 05:36:17 +00:00
xiaoju 8379dae585 fix(rfc-001): 解决小墨 review 的生产风险问题
- 删除 Guard 表达式(when),条件判断由 Workflow 自己处理
- Workflow queue 加 max_queue 上限(默认 100)
- compute 超时改为两级:soft timeout + grace_period hard kill
- 热更新加 drain_timeout,防止长 thread 阻塞 reload

小橘 <xiaoju@shazhou.work>
2026-04-22 05:12:58 +00:00
xiaoju 6e49deaf99 refactor(rfc-001): Reflex 作为 Event Mesh,Sense 不知道 Workflow
- 删除 Sense → Workflow 桥接(ThreadStart payload),Sense 只产出数据
- Reflex 新增两种 action:TriggerCompute / StartWorkflow
- 引入 Event Mesh 概念:所有事件路由声明在 Reflex 中
- 更新依赖图、Haskell 类型签名、设计原则
- 删除 should-cleanup sense(改由 Reflex when 守卫实现)

小橘 <xiaoju@shazhou.work>
2026-04-22 05:02:14 +00:00
xiaoju aba4580ff6 docs: polish RFC — fix Signal definition for Maybe, dedupe YAML config, merge §7 into §5, renumber 2026-04-22 04:28:41 +00:00
xiaoju 99d5549630 docs: unify compute return type to Maybe (T | null) 2026-04-22 04:25:51 +00:00
xiaoju f08f37e14e docs: clarify engine as kernel/event-hub, worker isolation, signal bus in-memory 2026-04-22 04:21:32 +00:00
xiaoju 96c740d175 docs: add §5 runtime model (process isolation, persistence, hot reload, error handling) 2026-04-22 03:39:29 +00:00
xiaoju aa5b0c6349 docs: workflow concurrency/overflow, signal-thread boundary
Signal only kicks off Thread. Thread has its own event loop.
Thread output signals are execution logs for retrospection only.

小橘 <xiaoju@shazhou.work>
2026-04-22 03:12:42 +00:00
xiaoju 162c50b326 docs: Event → Signal terminology, add senses config with throttle, update reflex semantics
- Signal replaces Event/Observation as the term for Sense output
- Senses config in nerve.yaml for runtime properties (throttle)
- ReflexCondition: OnInterval | OnSignal [SenseId]
- OnDemand is engine-builtin, not declared

小橘 <xiaoju@shazhou.work>
2026-04-22 02:56:28 +00:00
xiaoju b3beaf5e19 docs: add reflex semantics — interval origin, event compensation, idempotency
小橘 <xiaoju@shazhou.work>
2026-04-22 02:46:17 +00:00
xiaoju a1785cf36a fix: remove unused type parameter from Sense compute
小橘 <xiaoju@shazhou.work>
2026-04-22 02:40:02 +00:00
xiaoju ec25c993d0 docs: RFC-001 Observation Engine — Sense, Reflex, Workflow
小橘 <xiaoju@shazhou.work>
2026-04-22 02:37:49 +00:00