@specset/cli 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@specset/cli",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "description": "Command-line interface for Specset — authenticate, run GraphQL queries, and chat with Specset project agents.",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://specset.com",
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: specset
3
- description: Core CLI for Specset — install, authenticate, switch organizations, and run GraphQL with `specset api`. Start here for any Specset task, and whenever a specset command fails with auth or org errors.
3
+ description: Core CLI for Specset — install or update the CLI, authenticate with a browser or device code, switch organizations, and run GraphQL with `specset api`. Start here for any Specset task, and whenever a specset command fails with auth or org errors.
4
4
  allowed-tools: Bash Read AskUserQuestion
5
5
  ---
6
6
 
@@ -17,6 +17,7 @@ This is the core skill — setup and mechanics only. Domain workflows live in si
17
17
  | Skill | Use for |
18
18
  |---|---|
19
19
  | `specset-search` | Finding anything across specs, drawings, submittals, RFIs, documents, and closeout records |
20
+ | `specset-tools` | Calling Specset's own retrieval tools directly (`specset tools`, `specset mcp`) — deeper than search, lighter than the in-app agent |
20
21
  | `specset-projects` | Creating projects, uploading spec/drawing PDFs, publishing spec and drawing sets |
21
22
  | `specset-submittals` | Submittal lifecycle, attachments, approvers, and AI compliance reviews |
22
23
  | `specset-rfis` | RFI logging, tracking, and responses |
@@ -28,25 +29,27 @@ This is the core skill — setup and mechanics only. Domain workflows live in si
28
29
 
29
30
  ## First-Run Setup
30
31
 
31
- Perform this setup yourself when the user asks to get started with Specset (or when a command fails because the CLI is missing or unauthenticated). Every step is idempotent — skip any that's already satisfied.
32
+ Perform this setup yourself when the user installs or updates the skill/plugin, asks to get started with Specset, or when a command fails because the CLI is missing or unauthenticated. Every step is idempotent — skip any that's already satisfied.
32
33
 
33
- 1. Ensure the CLI is installed:
34
+ 1. Ensure the CLI is installed and current. Installing or updating an agent skill/plugin does not upgrade an existing global npm package. Check the installed and published versions:
34
35
 
35
36
  ```bash
36
- which specset || npm install -g @specset/cli
37
+ specset --version 2>/dev/null || true
38
+ npm view @specset/cli version
37
39
  ```
38
40
 
39
- Requires Node.js 20+ with npm. If `npm` itself is missing, stop and ask the user to install Node.js (https://nodejs.org) first.
40
-
41
- 2. Check authentication with `specset auth status`. If not logged in, start the login flow — it opens the user's browser; tell them to complete sign-in there while the command waits:
41
+ If `specset` is missing or its version is older than the published version, update it and verify the result:
42
42
 
43
43
  ```bash
44
- specset login
44
+ npm install -g @specset/cli@latest
45
+ specset --version
45
46
  ```
46
47
 
47
- Login is interactive by design — never try to bypass it or handle credentials directly. Don't launch a login mid-task without telling the user what's happening.
48
+ Requires Node.js 20+ with npm. If `npm` itself is missing, stop and ask the user to install Node.js (https://nodejs.org) first. Do not replace a source-linked development CLI when its version is newer than npm.
48
49
 
49
- **On a headless machine** (container, SSH, CI — anywhere the browser isn't on this machine), use the device flow instead:
50
+ 2. Check authentication with `specset auth status`. If not logged in, choose the login mode based on whether the user can see a browser opened by this environment.
51
+
52
+ **If a visible browser is unavailable** — including remote or in-app agent sessions, SSH, containers, and CI — use device authentication from the outset:
50
53
 
51
54
  ```bash
52
55
  specset login --device
@@ -54,6 +57,14 @@ specset login --device
54
57
 
55
58
  It prints a short code and a link (`https://<host>/device?code=XXXX-XXXX`). Show both to the user and ask them to open the link on any device and approve; the command completes on its own once they do. The code expires after 15 minutes — if it does, run the command again for a fresh one.
56
59
 
60
+ When a visible browser is available on the same machine, use the browser flow and tell the user to complete sign-in there while the command waits:
61
+
62
+ ```bash
63
+ specset login
64
+ ```
65
+
66
+ Login is interactive by design — never try to bypass it or handle credentials directly. Don't launch a login mid-task without telling the user what's happening.
67
+
57
68
  3. Pick the active organization (required for org-scoped queries):
58
69
 
59
70
  ```bash
@@ -113,6 +124,20 @@ specset api --query '{ __type(name: "CreateSubmittalInput") { inputFields { name
113
124
 
114
125
  The domain skills document the operations that matter for each workflow, but they are not exhaustive — when an operation or argument doesn't match, introspect rather than guess.
115
126
 
127
+ ## Agent Tools and MCP
128
+
129
+ Beyond raw GraphQL, the CLI exposes Specset's own retrieval tools — semantic and keyword search over specs, drawings, submittals, RFIs, documents (plus closeout and schedule where enabled) — for an AI agent to call directly. Reach for these when you want the actual content to reason over, not just record previews.
130
+
131
+ - **As commands:** `specset tools list` to see what's available, then `specset tools run <name> --input '{...}'` (or `-F key=value`).
132
+ - **As a native MCP server:** `specset mcp` runs a stdio MCP server that surfaces these tools to an MCP client, reusing your CLI login, org, and host. Register it once:
133
+
134
+ ```bash
135
+ claude mcp add specset -- specset mcp # Claude Code
136
+ codex mcp add specset -- specset mcp # Codex
137
+ ```
138
+
139
+ See the `specset-tools` skill for the full workflow — project scoping, the `-F` JSON-parsing difference, and the `sb://` citation convention.
140
+
116
141
  ## Uploading Files
117
142
 
118
143
  Several workflows attach an uploaded file — submittal PDFs, RFI attachments, project documents, org logos. Files are uploaded directly to storage via a presigned URL, so attaching one is a three-step flow that needs `bash`, `curl`, and `jq`. The result is a **file id** you pass to whatever mutation consumes it.
@@ -176,4 +201,5 @@ Processing large PDF sets takes minutes; poll every 15–30 seconds and tell the
176
201
  - `No active organization selected` — run `specset org list`, then `specset org use <slug>`.
177
202
  - A lookup by id returns `null` without an error — the record usually belongs to a different org than the active one; check `specset auth status` and switch with `specset org use <slug>`.
178
203
  - Login hangs or the browser can't reach this machine (SSH, container, CI) — use `specset login --device`: it prints a code + link the user approves from any device.
204
+ - `specset --version` is older than `npm view @specset/cli version`, or a documented flag is missing — run `npm install -g @specset/cli@latest`, then verify with `specset --version`.
179
205
  - After upgrading the CLI (`npm i -g @specset/cli@latest`), refresh the skills with `specset skill install --target <claude|codex|chatgpt>`.
@@ -18,6 +18,8 @@ Remember Variable Limitations from the `specset` skill: `-F` sends **strings onl
18
18
  - **`quickSearch`** — fast flat matching against titles and identifiers; use when the user roughly knows the record's name or number.
19
19
  - **Precise lookups** — when the user already has a spec section number or drawing sheet number, skip search and fetch directly.
20
20
 
21
+ > Need the actual content, not just previews and IDs? The `specset-tools` skill exposes Specset's own retrieval tools (`specset tools run searchSpecSections`, `searchDrawingSheets`, `searchDocuments`, …), which return expanded, citation-anchored markdown. Use `search`/`quickSearch` here to locate records cheaply; reach for `specset-tools` when you need to read and reason over the content.
22
+
21
23
  ## Unified Search: `search`
22
24
 
23
25
  ```graphql
@@ -0,0 +1,80 @@
1
+ ---
2
+ name: specset-tools
3
+ description: Use when an agent should call Specset's own retrieval tools directly — semantic/keyword search and structured reads over specs, drawings, submittals, RFIs, documents, closeout, and schedule — via `specset tools` or a `specset mcp` server. Deeper than raw GraphQL search; lighter than delegating to the in-app agent.
4
+ allowed-tools: Bash Read AskUserQuestion
5
+ ---
6
+
7
+ # Specset Agent Tools (`specset tools`, `specset mcp`)
8
+
9
+ Requires the `specset` CLI, logged in with an active org. If a command fails with `command not found`, `Not logged in`, or `No active organization`, follow First-Run Setup in the `specset` skill.
10
+
11
+ These are the same read-only retrieval tools Specset's own in-app agent uses — exposed so external agents can call them directly. Everything here is read-only; nothing needs user confirmation.
12
+
13
+ ## When to use which surface
14
+
15
+ There are three tiers of Specset retrieval. Pick the lightest one that answers the question:
16
+
17
+ 1. **Typed GraphQL search** (`specset-search` skill: `search`, `quickSearch`, `specSectionByNumber`, …) — cheapest, returns previews and IDs. Best for "does X exist / find the record."
18
+ 2. **Agent tools** (this skill) — the middle tier. `searchSpecSections` / `searchDrawingSheets` / `searchDocuments` return expanded, citation-anchored markdown (the real retrieval), and the `get*Content` tools read full sections. Best when you need the actual content to reason over.
19
+ 3. **In-app agent** (`specset-agent` skill: `specset agent chat`) — heaviest. Delegates the whole question to Specset's agent, which reasons and synthesizes. Best when the answer needs cross-document judgment, not just retrieval.
20
+
21
+ ## Listing tools
22
+
23
+ ```bash
24
+ specset tools list
25
+ specset tools list --project <projectId|sb://project/...>
26
+ specset tools list --json # full input schemas
27
+ ```
28
+
29
+ The listing includes usage guidance and marks project-scoped tools. The exact set depends on the org (closeout and schedule tools require their SKUs) and on whether a project is in scope.
30
+
31
+ ## Running a tool
32
+
33
+ Provide input as a JSON object (`--input`) or as repeated `-F key=value` fields. **Unlike `specset api -F` (strings only), `specset tools run -F` JSON-parses each value**, so numbers, booleans, and lists work:
34
+
35
+ ```bash
36
+ # JSON input
37
+ specset tools run searchSpecSections \
38
+ --project <projectId> \
39
+ --input '{"query": "concrete curing requirements"}'
40
+
41
+ # Field form (values are JSON-parsed, string fallback)
42
+ specset tools run searchSpecSections --project <projectId> \
43
+ -F query="fire rating" -F keywords='["ASTM E119"]' -F limit=5
44
+
45
+ # Read a specific section's full content using an ID from a search result
46
+ specset tools run getSpecSectionContent -F id='sb://spec/....'
47
+ ```
48
+
49
+ Output is the tool's JSON payload (`{ success, message?, result? }`); a `{ success: false }` payload exits non-zero.
50
+
51
+ ### Identifiers are citation IDs, not links
52
+
53
+ Tool results embed identifiers shaped like `sb://spec/<uuid>` or `sb://drawing/<uuid>`. Pass them back into other tools verbatim (e.g. into `getSpecSectionContent`, `getDrawingSheet`). They are **not** web URLs — don't present them to a person as clickable links.
54
+
55
+ ### Project scoping
56
+
57
+ Most tools are project-scoped. Either pass `--project` (a UUID or `sb://project/...`), or include `projectId` in the tool input. Use `listProjects` to discover project IDs. With `--project` set, per-call `projectId` becomes optional.
58
+
59
+ ## MCP server (Claude Code, Codex, other MCP clients)
60
+
61
+ `specset mcp` runs a stdio MCP server that exposes these tools natively, reusing your CLI login, org, and host config. Register it once and the client can call the tools directly:
62
+
63
+ ```bash
64
+ # Claude Code
65
+ claude mcp add specset -- specset mcp
66
+ # Optionally pin a project and/or host:
67
+ claude mcp add specset -- specset mcp --project <projectId> --host https://app.specbook.ai
68
+
69
+ # Codex
70
+ codex mcp add specset -- specset mcp
71
+ ```
72
+
73
+ Notes:
74
+ - The server writes only the MCP protocol to stdout; diagnostics go to stderr.
75
+ - Scope (org, optional project, host) is fixed for the life of the server — restart it to change scope.
76
+ - If the session expires mid-run, tool calls return an actionable error; run `specset login` and restart the server.
77
+
78
+ ## Stability
79
+
80
+ This surface is experimental — tool names and input schemas may change. For automation you need to keep stable, prefer the typed `search` / `quickSearch` GraphQL queries in the `specset-search` skill.