Skip to content

Skill preflight: agent must detect whether the nodespace CLI is installed and the daemon is healthy #1229

Closed

Description

@malibio

Problem

Under the skills+scripts direction (#1228), agents invoke NodeSpace by running the nodespace CLI (taught via @nodespaceai/skill's SKILL.md). Two failure modes are currently unhandled, and both produce raw errors the agent can't reason about:

  1. CLI not installed / not on $PATH — nodespace … returns command not found from the shell. This happens before any SKILL.md guidance is relevant, and the agent has no recovery path.
  2. Daemon not running — the CLI returns a connection error. (packages/cli/src/lib.rs already emits a helpful "Is the daemon running? Start it with nodespaced" — good, the agent can act on that.) But there's no instruction telling the agent to check health proactively before a batch of operations.

The concern: an agent that "knows about NodeSpace" via the skill still doesn't reliably know whether the tooling is present and healthy before it starts. Skill discovery (the agent seeing the skill exists) is separate from runtime availability (the binary + daemon actually working).

Proposed contract: skill preflight + self-diagnosis

In SKILL.md (the teacher):

  • Open with an explicit preflight the agent runs first: nodespace --version to confirm the CLI is installed, then nodespace diagnostics for daemon/db health.
  • Document what each failure means and the recovery path:
    • command not found → NodeSpace CLI isn't installed; tell the user to install it (don't silently fail).
    • connection error → daemon down; surface the CLI's own "start nodespaced" message to the user.
  • Make the preflight a precondition the agent checks before multi-step procedures, not per-call.

In the installer (@nodespaceai/skill):

  • At skill-install time, verify the nodespace binary resolves on $PATH; warn loudly if it doesn't, so the mismatch is caught before any agent session rather than mid-task.

In the CLI:

  • Confirm nodespace --version works without a running daemon (pure client-side; must not require the socket).
  • Ensure the "binary present but daemon down" error is consistently actionable (it already is for node ops — verify across all subcommands).

Acceptance criteria

  • SKILL.md documents a preflight (--version, diagnostics) with explicit failure→recovery guidance for both "not installed" and "daemon down"
  • nodespace --version succeeds with no daemon running
  • Skill installer warns if the nodespace binary is not on $PATH at install time
  • All CLI subcommands return an actionable "daemon not running" message (not a raw socket error)

Related

Activity

  1. malibio commented on May 29, 2026

    @malibio
    CollaboratorAuthor

    Frontend: 131 passed

  2. self-assigned this
    on May 29, 2026
  3. malibio commented on May 29, 2026

    @malibio
    CollaboratorAuthor

    Code Review — Skill Preflight (#1229)

    Branch: worktree-issue-1229-skill-preflight
    Reviewer: Principal Engineer (automated pragmatic review)
    Verdict: APPROVE with one improvement recommendation

    This is a clean, well-scoped implementation. Three files changed, all cohesive around a single purpose. Net-positive change. The findings below are triaged; nothing blocks merge.


    Requirements Validation

    Acceptance Criterion Status
    SKILL.md documents preflight (--version, diagnostics) with failure→recovery guidance PASS
    nodespace --version succeeds without a running daemon PASS (clap handles --version before run() dispatches to connect())
    Skill installer warns if binary is not on $PATH at install time PASS
    All CLI subcommands return an actionable "daemon not running" message PASS — all dispatch paths in lib.rs route through connect(), connect_import(), or connect_session(), each of which produces the same actionable error string. uninstall requires no daemon. No Rust changes were needed and the commit correctly explains why.

    Findings

    Suggested Improvements

    packages/skill/src/tests/installer.test.ts — Existing install() tests emit live stderr noise

    The six synchronous install(...) calls in the top-level describe('install') block (lines 72–133) use the module-level import, which is bound to the real child_process. When nodespace is not on PATH in the test environment (as observed during this review run), every install() call prints:

    WARNING: `nodespace` is not on $PATH. The skill will be installed, but the CLI
    must be installed and on $PATH before agents can use NodeSpace.
    ...
    

    This generates six identical WARNING lines in test output (confirmed by running bun run --cwd packages/skill test). The tests all pass, but the noise makes it harder to spot real warnings.

    Recommended fix: Add a vi.mock('node:child_process', ...) hoisted mock in beforeEach/afterEach for the existing describe('install') suite, or add a module-level vi.spyOn(process.stderr, 'write').mockImplementation(() => true) in beforeEach/afterEach on the whole suite. The describe('install PATH warning') tests already demonstrate the correct pattern with vi.doMock + resetModules for asserting the warning content — the existing install tests just need the noise suppressed.

    Nitpicks

    Nit: packages/skill/src/tests/installer.test.ts line 185–192 — misleading comment about CI env guard

    The comment reads: "In CI where the binary is absent this test is skipped via the env guard below." There is no env guard; the test always runs and accepts any boolean return. This is fine as a test strategy (the constraint is verified by the type check), but the comment is inaccurate and could confuse future readers. It should either be removed or rewritten to say: "This test only validates the return type is boolean — the actual value depends on whether the binary is installed in this environment."

    Nit: packages/skill/SKILL.md line 20 — partial error message match

    The failure recovery table lists the symptom as `Could not connect to nodespaced`. The actual CLI error is Could not connect to nodespaced at <path>.\nIs the daemon running? Start it with \nodespaced` in another terminal.The prefix matches so an agent reading the CLI output will recognize it, but aligning the table entry to the actual prefix (e.g., ``Could not connect to nodespaced at` ``) would prevent a false-negative if the CLI message is ever refactored.

    Nit: packages/skill/src/installer.ts — isNodespaceBinaryOnPath catches all errors, not just ENOENT

    The bare catch {} will also suppress a non-zero exit from a corrupt binary or a version flag that exits with an error code. This is acceptable for the current use case (binary found but broken → still warn user), but worth documenting in the JSDoc. The existing comment is good; one more sentence — "Note: a non-zero exit code is also treated as absent." — would be complete.


    Summary

    The implementation is minimal and correct: SKILL.md teaches the agent the right preflight pattern and recovery steps; isNodespaceBinaryOnPath is a clean, dependency-free probe exported for testability; the warning in install() fires at the right time (install time, not every invocation). The test coverage for the new paths is solid. The only actionable issue before merge is the stderr noise in the existing install() tests.

  4. added a commit that references this issue on Jun 22, 2026
    0c31320
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions