@syngy/laoma-cli
v0.2.2
Published
Laoma command line tool
Readme
@syngy/laoma-cli
Laoma command line tool for account jcode login, profile team selection, and lftp-style CAD drawing file management.
Install
npm install -g @syngy/laoma-cliLogin
laoma-cli auth login
laoma-cli auth login --no-open
laoma-cli auth login --profile prod
laoma-cli auth whoami
laoma-cli auth logoutauth login creates an account jcode pairing session, prints a browser URL and
an 8-digit code, then polls until the web page confirms the session. The jcode is
not embedded in the URL. The CLI stores access and refresh tokens under the
selected local profile and refreshes the access token once on authenticated API
requests when the server reports unauthorized.
Profiles
laoma-cli auth profiles list --json
laoma-cli auth profiles current --json
laoma-cli auth profiles use prod
laoma-cli auth profiles delete stagingEvery command accepts --profile <name>. If omitted, the CLI uses the current
profile; if no current profile exists, it uses default.
Each profile stores one selected team. Select it once before managing CAD files:
laoma-cli --profile prod team list
laoma-cli --profile prod team use <teamId>
laoma-cli --profile prod team currentConfigure
configure manages drawing analysis configuration for the selected team. Cloud
category templates are preset category/parameter sets; importing a template
appends selected leaf categories and their parameters to the current team. It
does not create teams, folders, drawings, or sample drawings.
laoma-cli configure category-templates list
laoma-cli configure category-templates show <template-id>
laoma-cli configure categories import-template <template-id> --recommended --dry-run
laoma-cli configure categories import-template <template-id> --category <code> --accept-template-promptChoose exactly one import range: repeated --category <code>, --all, or
--recommended. --dry-run previews selected, existing, and new category codes
without changing remote configuration.
If the team already has a parsing prompt, imports keep that prompt. If no prompt
exists, pass --accept-template-prompt to use the cloud template prompt, or
--prompt-file <file> to provide one explicitly.
Global and category prompts
laoma-cli configure settings show --json
laoma-cli configure settings update --expected-version <version> --prompt-file ./global.md
laoma-cli configure categories list --json
laoma-cli configure categories show <category-id> --json
laoma-cli configure categories update <category-id> --expected-version <version> --prompt-file ./pcb.md --dry-run
laoma-cli configure categories update <category-id> --expected-version <version> --prompt-file ./pcb.mdUse the version from the corresponding show response. Initial global settings
can have version 0. settings controls the team's global prompt;
categories update --prompt-file controls only the selected category's prompt.
Analysis first classifies the drawing, then loads that category's prompt alongside
the built-in system prompt and team global prompt. The built-in prompt is not
editable through this CLI. Updating configuration does not reanalyze old drawings.
All new write commands support --dry-run to print the request without saving.
The caller must have the server's required team owner/admin permissions. Updates
preserve omitted fields and fail on version conflicts; inspect the latest values
before retrying. Successful updates return the saved configuration and new version.
Prompt files preserve Markdown text and must be nonempty UTF-8, at most 65536 bytes.
Use --clear-prompt or an explicit JSON "prompt": "" to clear a prompt. JSON
prompt, --prompt-file and --clear-prompt are mutually exclusive.
Category and parameter definitions
laoma-cli configure categories create --file ./category.json
laoma-cli configure categories update <category-id> --expected-version <version> --file ./category-patch.json
laoma-cli configure categories disable <category-id> --expected-version <version>
laoma-cli configure categories enable <category-id> --expected-version <version>
laoma-cli configure parameters list <category-id> --json
laoma-cli configure parameters show <category-id> <parameter-id> --json
laoma-cli configure parameters create <category-id> --file ./parameter.json
laoma-cli configure parameters update <category-id> <parameter-id> --expected-revision <revision> --file ./parameter-patch.json
laoma-cli configure parameters disable <category-id> <parameter-id> --expected-revision <revision>
laoma-cli configure parameters enable <category-id> <parameter-id> --expected-revision <revision>IDs come from list/show; names and codes cannot substitute for IDs. Parameters
use revision, not the category's version. Structural parameter changes can
return a new parameter ID: use the returned ID and revision for subsequent edits.
Categories and parameters support disabling and enabling, not physical deletion.
Example category.json (creation requires code and name):
{
"code": "pcb",
"name": "PCB",
"prompt": "技术要求按 Markdown 有序列表输出。",
"required_memo_types": [],
"meta": {},
"status": "enabled",
"sort_order": 0
}Also accepts parent_id; set it to null to move a category to the root.
Category creation supports --prompt-file instead of JSON prompt.
Example parameter.json (creation requires code, name, and data_type):
{
"code": "board_thickness",
"name": "板厚",
"data_type": "number",
"unit_code": "mm",
"required": true,
"validation_rules": { "minimum": "0" },
"description": "提取成品板厚",
"status": "enabled",
"sort_order": 0
}Data types: number, text, boolean, enum, json. validation_rules must
be an object valid for the selected type; the server validates units and rules.
Set unit_code to null to remove a unit. An existing parameter's code cannot
be changed. New categories/parameters default to enabled and sort order 0;
new parameters default to required: false.
Update JSON files contain only the fields to change. For example,
{"name":"成品板厚"} renames a parameter while preserving its type, unit and rules.
meta, required_memo_types, tag_names, and validation_rules replace their
entire respective values when supplied. Unknown fields and read-only fields
(such as id, version, revision, expected_version) are rejected. Do not
pass a raw show response as an update file.
Global settings also accept --file, with writable fields prompt,
allow_create_tag, and tag_names. For example:
# settings-patch.json: {"allow_create_tag":false,"tag_names":["PCB","待复核"]}
laoma-cli configure settings update --expected-version <version> --file ./settings-patch.jsonThe current tag revision is carried into the save request for concurrency checks.
New configuration commands resolve relative file paths against the profile's
lcd directory. Global --profile, --team-id, and host overrides apply as usual.
Filesystem Commands
laoma-cli pwd
laoma-cli cd /一期施工图
laoma-cli ls
laoma-cli mkdir 二期施工图
laoma-cli put ./A-01.dwg /一期施工图/A-01.dwg
laoma-cli get /一期施工图/A-01.dwg ./A-01.dwg
laoma-cli rm /一期施工图/A-01.dwg
laoma-cli mv /一期施工图/A-01.dwg /一期施工图/A-01-revB.dwg
laoma-cli rsync ./dwg /一期施工图 --dry-run
laoma-cli shellThe remote commands are modeled after lftp: pwd, cd, ls, mkdir,
put, get, rm, mv, rsync, and shell. Local navigation uses lpwd,
lcd, and lls.
laoma-cli lpwd
laoma-cli lcd ./dwg
laoma-cli llsUse global host overrides for local or non-production environments:
laoma-cli \
--api-base-url http://localhost:16081 \
--account-api-base-url https://account-api.syngy.cn \
--account-web-base-url https://account.syngy.cn \
auth login --no-openCredentials are stored under the account CLI auth config directory for
laoma-cli. Set LAOMA_CLI_HOME to redirect local storage for tests or isolated
runs.
Drawing import: submit → watch → inspect
put accepts a local file or a direct HTTP/HTTPS download URL. It returns a
durable import task, not a completed analysis. The destination directory must
already exist (mkdir creates it). Duplicate target names fail; the CLI does not
overwrite, merge or automatically rename drawings. Files must be nonempty and no
larger than 200 MiB.
laoma-cli put ./part.dwg /待报价/part.dwg --json
laoma-cli put 'https://example.com/part.dwg' /待报价/part.dwg --json
laoma-cli put 'https://example.com/download?signature=VALUE' /待报价/part.dwg --jsonFor local files, the receipt is returned after the source is uploaded and the task
is persisted. For URLs, it is returned after the request is persisted; the server
downloads the file independently of the CLI process. URLs must be public direct
file links on HTTP/HTTPS standard ports. Signed URLs are accepted, but web sharing
pages, embedded usernames/passwords and custom authentication headers are not.
The source URL is not included in normal receipts or progress. With no explicit
filename, only .dwg/.dxf URL path basenames are inferred; opaque URLs require
an explicit destination filename.
The receipt includes task_id, team_id, status, stage, stages,
target_path, a hint, and structured next_actions. A local upload can already
include drawing_id; URL imports may not have a drawing until source acquisition
finishes. IDs are opaque strings. The placeholders below must be replaced by IDs
from the actual response, never guessed:
laoma-cli task get <task-id> --json
laoma-cli task watch <task-id> --timeout 60s --json
laoma-cli drawing inspect <drawing-id> --revision <revision-id> --generation <generation-id> --jsonPrefer executing the returned next_actions argument array: it preserves the
profile, service addresses and team. --team-id <id> overrides the team for one
invocation without changing the profile's selected team. Use absolute local and
remote paths for automation that should not depend on saved lcd/cd state.
An import follows source acquisition → CAD processing → automatic analysis.
queued and running are nonterminal; succeeded, failed and stale are terminal.
CAD success alone does not finish the import. If analysis is not configured when
CAD processing completes, the task succeeds with stages.analysis.status=skipped
and an explicit reason; analysis_available=false means no automatic analysis
result was produced by this import. A later settings change or manual analysis does
not rewrite a completed task. Failed imports preserve any already-created drawing.
task get returns immediately. task watch waits up to 60 seconds by default;
--timeout accepts positive durations such as 1s, 60s, 5m (maximum 30m).
With --json, stdout contains one final task object and changed progress goes to
stderr. Wait timeout returns the latest observed state with wait_timed_out=true
and a resume action; it does not mark the server task failed. Repeat task watch
with the original ID to resume. Ctrl-C stops only local observation.
| Watch exit code | Meaning | | --- | --- | | 0 | Task succeeded, including an explicitly skipped analysis | | 1 | Task failed/stale, or the task query failed | | 2 | Invalid CLI input | | 3 | Local waiting deadline reached; server work is not canceled |
drawing inspect reads effective classification, parameters and memos in a
consistent database snapshot. --revision selects the business version, including
the current or a historical version; --generation checks its processing generation.
Omitting --revision selects the current version. Current values remain editable;
historical content is read-only, while drawing name and classification remain
shared across versions. Preserve quote inputs separately when a full historical
business snapshot is required. Parameter definitions/defaults are not actual values; missing values are
not zero. Memo units distinguish batch effort/cost, per-item cycle/cost, and
currency. Sources, versions, review state and stored evidence are retained.
get downloads the original file; it does not return structured parameters.
All workflow help is available without login or IDs:
laoma-cli --help
laoma-cli put --help-examples
laoma-cli task get --help-examples
laoma-cli task watch --help-examples
laoma-cli drawing inspect --help-examplesPricing formulas, comparison weights and manufacturing decisions belong to the agent's business knowledge, not this CLI. Never interpret parameter proximity or a successful upload as evidence that a quote is accurate.
Drawing Search
Search uses the same v1 expression syntax as the web search box. It searches the
selected profile's entire team, independently of pwd / cd. Login and
select a team first; help and local syntax validation do not require login.
laoma-cli search --help
laoma-cli search --query '平面图'
laoma-cli search --query 'label:建筑 label:已审核'
laoma-cli search --query '(label:建筑 OR label:结构) -label:已作废'
laoma-cli search --query 'label:"项目 A"'
laoma-cli search --query 'attr.长度>=10mm attr.长度<=20mm'
laoma-cli search --query 'attr.材质~钢'
laoma-cli search --query 'attr_id["属性ID"]>=10mm' --json
laoma-cli search --query='-label:已作废'
laoma-cli search --query='' --page 2 --page-size 20 --sort nameUse outer single quotes to protect spaces, parentheses, comparison operators,
and the inner double quotes from your system shell. --query='' explicitly
searches all drawings. --query is required; there is no implicit all-team search.
Default pagination is page 1, 50 results; page size supports 1–200. created
(default) sorts newest first; name sorts ascending. Pages are fetched individually.
Adjacent conditions mean AND. Precedence is parentheses, NOT / -, AND, then OR.
Names, labels, categories, folders, creation dates, uncategorized drawings, property
values and property states are supported. Run search --help for all forms.
The expression limit is 4096 UTF-8 bytes, 64 conditions, and 8 group levels.
Discover real IDs, category paths, property types, units, operators and enum values:
laoma-cli search fields
laoma-cli search fields --type tags
laoma-cli search fields --type categories
laoma-cli search fields --type parameters --jsonUse stable label_id, category_id, folder_id, or attr_id["ID"] references when
names are ambiguous. Numeric units must match the property's configured unit;
enum values must be valid options for the selected team.
Errors and scripts
Successful results go to stdout. Errors go to stderr with a nonzero exit status.
--json emits one JSON error object, including code, message, hint, and
example for search diagnostics. Syntax errors additionally include expression
and position: { start, end } (zero-based UTF-16 offsets, end exclusive). Local
syntax / query validation errors use exit code 2; API failures use exit code 1.
Authentication and network errors keep their own meaning rather than being
reported as syntax errors. Invalid expressions are never silently searched as
plain keywords. Server metadata errors suggest search fields to inspect the
current team's valid values; no server error location is fabricated.
laoma-cli search --query 'label:' --json
# Error: missing label value, with a valid label query example.Interactive shell
search and search fields are available inside laoma-cli shell:
laoma> search --query 'label:"项目 A" attr.长度>=10mm'
laoma> search fields --type parameters --jsonBatch mode respects semicolons inside quoted expressions:
laoma-cli shell -c 'search --query "label:建筑" --json; search fields --type tags'The built-in shell parses quotes and escapes but does not perform variable or command expansion, pipe execution, or redirection. Interactive errors return to the prompt; batch errors stop the batch with a nonzero exit status.
Drawing versions
A new upload creates V1. Replacing the CAD file creates V2, V3, and so on. Successful file receipt immediately selects the new current version in the upload transaction. CAD processing and automatic analysis run asynchronously; failure keeps this version current, and retrying does not create a business version. Current parameters, memos and tags can be edited directly without creating a business version. Historical version content is read-only. Name and classification belong to the drawing.
laoma-cli ls --json
laoma-cli drawing versions <folderId> <drawingId> --json
laoma-cli drawing get <folderId> <drawingId> --revision <revisionId> --json
laoma-cli drawing rename <folderId> <drawingId> 'New name' --expected-name 'Old name'
laoma-cli drawing replace <folderId> <drawingId> <currentRevisionId> ./updated.dwg --expected-version 2Read the latest revision_version using drawing get before replacement; the
example counter is illustrative. A replacement returns its new revision_id.
The response already identifies the new current version. Read that version to
inspect processing; drawing get without --revision returns the latest upload,
even if processing failed. Historical versions remain read-only. Conflicts are returned without automatic retry.
All filesystem and search commands select current_revision_id. Moving or removing
an entry affects the whole drawing. These commands also work inside shell.
等待在首次查询返回前超时时,JSON 包含 observation: "unavailable"、wait_timed_out: true 和续查动作;它不代表服务端失败。
临时询价与版本引用
- 本地/URL 上传使用
put → task watch → drawing inspect → search,无需发布。 - 临时图纸也是团队图纸,不自动过期;不再需要时显式
rm。候选检索应排除本次输入图纸,避免把自己当作历史案例。 revision_id选择业务版本,generation_id校验处理代次;重试解析不会生成新的业务版本。- 报价证据应保存参数、备注及其修订号和时间;当前版可编辑,因此只有 revision_id 不足以冻结报价事实。
- npm 0.2.x 使用无草稿协议,服务端必须先执行对应离线 schema 迁移并升级。
