Files
passepartout/org/channel-cli.org
Amr Gharbeia 8fd56dece3 v0.8.2: cleanup + prose + structure + decomposition + budget + errors
Phase 1 — dedup + hardening (~9 items):
- Remove duplicate *skill-registry* defvar from core-skills
- Merge *backend-registry* into *probabilistic-backends*, delete backend-register
- Remove inject-stimulus alias, standardize on stimulus-inject
- Add pre-eval sandbox (skill-source-scan) blocks restricted symbols before eval
- Remove dead plist-get function; remove duplicate json-alist-to-plist export
- Fix read-framed-message whitespace DoS (4096-iteration max)
- Add *read-eval* nil to dispatcher-approvals-process read-from-string (RCE)
- Add test-op to ASDF; update .asd version 0.4.3→0.7.2

Phase 2 — prose + contracts + reorder:
- Split ROADMAP: 2623→1089 lines (TODO only), CHANGELOG: 260→1528 lines (full DONE history, 14 versions reverse chron)
- Add Contracts + Overview to 6 channel files + embedding-native + programming-standards + symbolic-scope
- Reorder 28 .org files: Contract → Test Suite → Implementation (TDD order)
- Add 7-phase inline prose to think() in core-reason
- Expand USER_MANUAL: 183→461 lines (10 new sections)

Phase 3 — decomposition + export organization:
- Decompose think() into think-assemble-prompt, think-call-llm, think-parse-response orchestrator
- Organize 188 exports into 16 grouped sections by module

Phase 4 — budget enforcement + error protocol:
- Per-session budget enforcement (SESSION_BUDGET_USD env var, budget-exhausted-p, guard in think-call-llm)
- Error condition hierarchy (6 conditions: pipeline-error, llm-error, gate-error, budget-error, protocol-error)
- Restarts in loop-process: skip-signal, use-fallback, abort-pipeline
2026-05-13 09:17:48 -04:00

2.3 KiB

SKILL: CLI Gateway (org-skill-cli-gateway.org)

Overview

The CLI Gateway is the simplest interface to Passepartout — raw stdin/stdout over TCP. It connects to the daemon's framed protocol and translates between terminal input/output and the plist-based communication format. No TUI, no ncurses, no dependencies beyond a TCP socket. Every other gateway (TUI, Emacs, Telegram) builds on this same protocol.

Contract

  1. (channel-cli-input text): wraps text in a :user-input envelope with :source :CLI and injects into the pipeline via stimulus-inject.

Test Suite

(eval-when (:compile-toplevel :load-toplevel :execute)
  (ql:quickload :fiveam :silent t))

(defpackage :passepartout-channel-cli-tests
  (:use :cl :passepartout)
  (:export #:cli-suite))

(in-package :passepartout-channel-cli-tests)

(fiveam:def-suite cli-suite :description "Verification of the CLI Gateway")
(fiveam:in-suite cli-suite)

(fiveam:test test-channel-cli-input-format
  "Contract 1: channel-cli-input injects a properly formed signal without error."
  (handler-case
      (progn (channel-cli-input "hello") (fiveam:pass))
    (error (c)
      (fiveam:fail "channel-cli-input crashed: ~a" c))))

Load-Time Sanity Check

Verifies the function exists and can be called at load time without depending on FiveAM macro resolution in the jailed package.

(handler-case
    (progn (channel-cli-input "test-load") (log-message "CLI: Load-time test OK"))
  (error (c) (log-message "CLI: Load-time test FAILED: ~a" c)))

Implementation

Package Context

(in-package :passepartout)

CLI Command Handling

;; REPL-VERIFIED: 2026-05-03T13:00:00

(defun channel-cli-input (text)
  "Processes raw text from the command line."
  (stimulus-inject (list :type :EVENT 
                         :payload (list :sensor :user-input :text text) 
                         :meta (list :source :CLI))))

Skill Registration

(defskill :passepartout-channel-cli
  :priority 100
  :trigger (lambda (ctx) (eq (getf (getf ctx :meta) :source) :CLI))
  :deterministic (lambda (action ctx) (declare (ignore ctx)) action))