Skip to content

CLI: snippets — a working script becomes reusable tooling #224

Open

Description

@omridevk

Rewritten 2026-08-07. The CLI surface this hung on was rejected, and the promotion question now has an answer: the user approves. Unblocked — #255/#231/#232 have all landed.

What survives verbatim

  • Snippets live in conciv/snippets/, beside conciv/extensions/. conciv/ is committed user source; .conciv/ is gitignored run state holding absolute paths and 0600 files. A nested gitignore cannot re-include a file whose parent is excluded, so "git-visible snippets under .conciv/" was never true.
  • No shared index file. A single index is a read-modify-write that two concurrent saves clobber, and a crash between two writes desyncs it. Each snippet carries its own metadata beside it — a directory read is the listing.
  • Names are a portable slug: no separators, no traversal, no case-folding collisions. ../../x is a user error, not a write. Saving over an existing name is refused unless forced.
  • A description is recorded when given; a snippet saved without one lists a null description rather than a guess.

What changed: who promotes a run into a snippet

The original mechanism — conciv tools code '…' --save <name> — is gone. #223 is closed as rejected, and execution moved to the code-mode MCP server (docs/superpowers/specs/2026-08-04-one-tool-registry-design.md, packages/core/src/chat/code-mode.ts).

Promotion is a user approval decision, not a model action. The agent never saves a snippet by calling a tool; a successful run is offered to the user, and the user accepts or declines. This matches the cloudflare/mcp model where the application persists, never the model.

Note the mechanism is not a reuse of the existing approval: 'ask' gate (packages/core/src/chat/gate.ts). That gate fires before a call to decide whether it runs. Promotion fires after a run has already succeeded, to decide whether it is kept. Same principle — the user decides — but a distinct surface: a post-run promotion affordance, not a pre-call gate.

Open design questions, to settle before implementing

  1. Where the offer appears. The widget after a successful code-mode run, the CLI, or both. A run started by an agent in a headless session has no one to ask — does promotion simply not happen there, or is it queued for later review?
  2. What granularity is offered. A whole code-mode execution, or a user-selected slice of it.
  3. Where the name and description come from. User-typed at approval time, or agent-proposed and user-edited.
  4. Whether declining is remembered, so the same run is not offered repeatedly.

Acceptance criteria

  • Promotion requires an explicit user approval; no code path lets the agent persist a snippet on its own
  • A failing run is never offered for promotion
  • Declining writes nothing
  • Snippets land in conciv/snippets/ and a saved one is visible to plain git status
  • Metadata lives per snippet; there is no shared index to corrupt, and two concurrent saves both survive
  • A traversal or otherwise unportable name is refused as a user error
  • Saving over an existing name is refused unless forced
  • A snippet saved without a description lists a null description
  • Listing snippets is a directory read, and has a machine-readable form for agents
  • A saved snippet can be re-run by name, with arguments reaching it as a parameters binding

Design: docs/superpowers/specs/2026-08-04-cli-command-contract-design.md section 3b (location, index, and naming rules only — its tools code surface is superseded).

Related

Activity

  1. added
    ready-for-agent
    on Aug 4, 2026
  2. omridevk commented on Aug 4, 2026

    @omridevk
    ContributorAuthor

    Needs rework, not closure — the mechanism this ticket hung on is gone but the idea stands.

    conciv tools code --save no longer exists: conciv tools code was rejected and #223 is closed. Execution moved to a code-mode MCP server (docs/superpowers/specs/2026-08-04-one-tool-registry-design.md).

    What survives verbatim: snippets live in conciv/snippets/, beside conciv/extensions/, because conciv/ is committed user source and .conciv/ is gitignored run state; no shared index file, since a directory read is the listing and a single index is a read-modify-write two concurrent saves clobber; portable-slug names, no traversal, no silent overwrite.

    What has to change: who saves. In cloudflare/mcp's model the application persists a snippet, never the model — a promotion decision, not a tool the agent calls. So the trigger is no longer a CLI flag on a run. Reopen the design question of what promotes a successful execution into a saved snippet before implementing this.

    Blocked by the registry landing.

  3. omridevk commented on Aug 7, 2026

    @omridevk
    ContributorAuthor

    Promotion mechanism settled: reuse the existing ask registry.

    There is no run with nobody upstream. Every run has a sessionId, and that session has a human attached — so the approval bubbles to them, exactly as approval: 'ask' already does.

    The machinery exists and should be reused rather than reinvented:

    • packages/core/src/chat/ask.ts — createAskRegistry(), keyed by sessionId, with open / waitFor / reply / pending.
    • packages/core/src/chat/gate.ts:102-106 — asks.open(sessionId, approvalId) then await asks.waitFor(sessionId, approvalId, ASK_TIMEOUT_MS), blocking the call until the human decides.
    • packages/contract/src/contract.ts:109 — permissionDecision carries the answer back from the widget.

    Promotion differs from the gate only in when it fires: the gate asks before a call to decide whether it runs, promotion asks after a run succeeded to decide whether it is kept. Same registry, same session-keyed bubbling, different trigger point.

    Not MCP elicitation. Asking back through the harness was probed and is a dead end: claude auto-cancels elicitation in headless, codex cancels pre-tool, and opencode does not implement it. Conciv asks through its own channel.

    Resolves two of the open questions:

    1. Where the offer appears — the session's approval surface, via the ask registry. A run with no one watching is not a special case; it is the timeout case.
    2. What happens when nobody is there — ASK_TIMEOUT_MS is 120s and a timeout is a non-approval, so the snippet is not saved. No queue, no deferred review. Declining costs nothing because the run already succeeded and returned its result.

    Still open: what granularity is offered (a whole code-mode execution or a slice), where the name and description come from (user-typed at approval time, or agent-proposed and user-edited), and whether a decline is remembered so the same run is not re-offered.

  4. omridevk commented on Aug 7, 2026

    @omridevk
    ContributorAuthor

    TanStack already ships this feature. Platform-ladder finding — read before implementing.

    @tanstack/ai-code-mode-skills@0.3.13 ("Persistent runtime skill library for TanStack AI Code Mode agents") is the sibling of the @tanstack/ai-code-mode we already use in packages/core/src/chat/code-mode.ts:235. It is not currently installed.

    codeModeWithSkills() returns a registry containing execute_typescript, search_skills, get_skill, register_skill, and one callable tool per selected skill. Skill selection uses a cheap model bounded by maxSkillsInContext. It emits skill:registered, code_mode:skill_call, code_mode:skill_result, and code_mode:skill_error.

    SkillStorage (verified against the published types.d.ts) is:

    loadIndex()             // lightweight metadata, no code
    loadAll()               // full skills including code
    get(name)
    save(skill)             // create or update
    delete(name)
    search(query, options?)
    updateStats(name, success)
    trustStrategy?
    

    A Skill carries id, name (snake_case), description, code, inputSchema, outputSchema, usageHints, dependsOn, trustLevel, stats, createdAt, updatedAt — richer than the shape sketched in this ticket.

    Where their model conflicts with ours

    1. The model registers, and nothing gates it. Their system prompt instructs the LLM to call register_skill after producing useful code. Their trust ladder (untrusted → provisional at 10+ runs ≥90% → trusted at 100+ runs ≥95%, configurable via createCustomTrustStrategy) sounds like a gate but is not: the docs state plainly that "the trust level is metadata only — it does not currently gate execution." Untrusted skills still run.

    So their trust strategy does not satisfy the approval requirement recorded above. It answers "is this skill reliable?" — a statistical quality signal. It does not answer "should this code be written into a directory the project commits to git?", which is the actual risk when the target is conciv/snippets/.

    2. Their file storage uses a shared index — the exact thing this ticket rejected. createFileSkillStorage lays out:

    .skills/
      _index.json          <-- shared index
      skill_name/
        meta.json
        code.ts
    

    This ticket rejected a shared index because it is a read-modify-write that two concurrent saves clobber and a crash between writes desyncs. Adopting createFileSkillStorage verbatim reintroduces that. Their loadIndex() / loadAll() split is a real API distinction though, and worth keeping.

    Proposed shape

    Adopt the library, supply our own storage:

    • Use codeModeWithSkills() for the registry, search, selection, and the register_skill / get_skill / search_skills surface. Do not hand-roll any of it.
    • Implement SkillStorage ourselves rather than using createFileSkillStorage, so that:
      • save() is the approval seam — it requires the user approval recorded above (via the existing session-keyed ask registry) before anything is written, and writes nothing on decline or timeout.
      • the on-disk layout is conciv/snippets/, per-skill metadata, no _index.json — a directory read is the listing. loadIndex() is satisfied by reading each skill's metadata without its code.
    • Keep trustStrategy as what it actually is: a reliability signal surfaced to the user, never a substitute for approval.

    Still open

    • Whether register_skill should be exposed to the model at all, or whether the host observes a successful execute_typescript and offers promotion. Their design says the model asks; our approval ruling means the user still decides. Exposing the tool and gating save() is the smaller change and keeps their prompt/registry intact.
    • Granularity, and where name/description come from — their register_skill has the model propose name, description, usageHints, and both schemas, which is a reasonable default if the user edits at approval time.
    • Whether a decline is remembered.

    Before implementing, read docs/code-mode/code-mode-with-skills.md upstream and the package source; the notes above come from the published docs plus types.d.ts, not from a full source read.

  5. added
    enhancement
    help wanted
    on Aug 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementhelp wantedready-for-agent

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions