diff --git a/dist/bin.js b/dist/bin.js index 7af0905..4168043 100644 --- a/dist/bin.js +++ b/dist/bin.js @@ -2,7 +2,7 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); /** - * inkreach — CLI for operating inkreach-teable. + * inkreach-teable — CLI for operating inkreach-teable. * * Entry point. Sets up the global commander program and mounts command groups. */ @@ -14,10 +14,10 @@ const resources_1 = require("./commands/resources"); const extras_1 = require("./commands/extras"); const program = new commander_1.Command(); program - .name('inkreach') + .name('inkreach-teable') .description('Operate inkreach-teable: tables, fields, records, views, and the self-built automation engine (8 triggers + 6 actions).\n' + 'Use --json for machine-readable output (agent parsing).') - .version(`inkreach ${package_json_1.version}`, '-v, --version'); + .version(`inkreach-teable ${package_json_1.version}`, '-v, --version'); // Global options (highest precedence over config file + env). program .option('--endpoint ', 'Backend URL (default http://localhost:3000)') diff --git a/dist/commands/auth.js b/dist/commands/auth.js index 7f7daaa..f372aa6 100644 --- a/dist/commands/auth.js +++ b/dist/commands/auth.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.authCommand = void 0; /** - * `inkreach auth` — authentication & config commands. + * `inkreach-teable auth` — authentication & config commands. */ const commander_1 = require("commander"); const ctx_1 = require("../lib/ctx"); @@ -115,7 +115,7 @@ function authCommand() { ['token', created.token], ['', ''], ['note', 'Save this token now — it cannot be retrieved again.'], - ['use', 'inkreach auth login --token '], + ['use', 'inkreach-teable auth login --token '], ]); } })); diff --git a/dist/commands/extras.js b/dist/commands/extras.js index 328d892..7d688c2 100644 --- a/dist/commands/extras.js +++ b/dist/commands/extras.js @@ -2,10 +2,10 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.sqlCommand = exports.fireCommand = exports.runsCommand = exports.secretCommand = void 0; /** - * `inkreach secret` — manage workflow automation secrets. - * `inkreach runs` — execution history. - * `inkreach fire` — manual trigger testing (button-click / webhook). - * `inkreach sql` — read-only SQL queries. + * `inkreach-teable secret` — manage workflow automation secrets. + * `inkreach-teable runs` — execution history. + * `inkreach-teable fire` — manual trigger testing (button-click / webhook). + * `inkreach-teable sql` — read-only SQL queries. */ const commander_1 = require("commander"); const ctx_1 = require("../lib/ctx"); diff --git a/dist/commands/resources.js b/dist/commands/resources.js index 64a1bd1..a397053 100644 --- a/dist/commands/resources.js +++ b/dist/commands/resources.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.baseResourceCommands = void 0; /** - * `inkreach base|table|field|record|view` — resource CRUD commands. + * `inkreach-teable base|table|field|record|view` — resource CRUD commands. * * These endpoints are compatible with official teable open-api. */ diff --git a/dist/commands/workflow.js b/dist/commands/workflow.js index 55cbef2..25dbb06 100644 --- a/dist/commands/workflow.js +++ b/dist/commands/workflow.js @@ -2,9 +2,9 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.buildActionConfig = exports.actionCommand = exports.buildTriggerConfig = exports.triggerCommand = exports.workflowCommand = void 0; /** - * `inkreach workflow` — workflow CRUD + lifecycle. - * `inkreach trigger` — set the trigger node's type & config. - * `inkreach action` — add/update/delete action nodes. + * `inkreach-teable workflow` — workflow CRUD + lifecycle. + * `inkreach-teable trigger` — set the trigger node's type & config. + * `inkreach-teable action` — add/update/delete action nodes. * * All node-mutating commands operate via PUT /node (whole-graph replacement), * so they internally GET the full graph, mutate, then PUT it back. @@ -109,7 +109,7 @@ function workflowCommand() { ['name', wf.name], ['baseId', wf.baseId], ['', ''], - ['next', `inkreach trigger set ${wf.id} --type ...`], + ['next', `inkreach-teable trigger set ${wf.id} --type ...`], ]); } })); @@ -264,7 +264,7 @@ function triggerCommand() { ['triggerType', opts.type], ['config', JSON.stringify(config)], ['', ''], - ['next', `inkreach action add ${workflowId} --type script ...`], + ['next', `inkreach-teable action add ${workflowId} --type script ...`], ]); } })); @@ -400,7 +400,7 @@ function actionCommand() { ['type', opts.type], ['config', JSON.stringify(config)], ['', ''], - ['next', `inkreach workflow activate ${workflowId}`], + ['next', `inkreach-teable workflow activate ${workflowId}`], ]); } })); diff --git a/dist/lib/config.js b/dist/lib/config.js index 42eb4b1..70a7be5 100644 --- a/dist/lib/config.js +++ b/dist/lib/config.js @@ -25,16 +25,16 @@ var __importStar = (this && this.__importStar) || function (mod) { Object.defineProperty(exports, "__esModule", { value: true }); exports.configPath = exports.resolveConfig = exports.writeConfigFile = exports.readConfigFile = exports.DEFAULT_ENDPOINT = void 0; /** - * Config storage for inkreach CLI. + * Config storage for inkreach-teable CLI. * - * Stores endpoint + token at ~/.inkreach/config.json, with environment variable - * overrides INKREACH_ENDPOINT / INKREACH_TOKEN. The --endpoint / --token / --base-id + * Stores endpoint + token at ~/.inkreach-teable/config.json, with environment variable + * overrides INKREACH_TEABLE_ENDPOINT / INKREACH_TEABLE_TOKEN. The --endpoint / --token / --base-id * global flags take the highest precedence (handled by resolveOptions()). */ const fs = __importStar(require("node:fs")); const path = __importStar(require("node:path")); const os = __importStar(require("node:os")); -const CONFIG_DIR = path.join(os.homedir(), '.inkreach'); +const CONFIG_DIR = path.join(os.homedir(), '.inkreach-teable'); const CONFIG_FILE = path.join(CONFIG_DIR, 'config.json'); exports.DEFAULT_ENDPOINT = 'http://localhost:3000'; function readConfigFile() { @@ -59,11 +59,11 @@ function resolveConfig(overrides) { const file = readConfigFile(); return { endpoint: overrides?.endpoint || - process.env.INKREACH_ENDPOINT || + process.env.INKREACH_TEABLE_ENDPOINT || file.endpoint || exports.DEFAULT_ENDPOINT, - token: overrides?.token || process.env.INKREACH_TOKEN || file.token || '', - baseId: overrides?.baseId || process.env.INKREACH_BASE_ID || file.baseId, + token: overrides?.token || process.env.INKREACH_TEABLE_TOKEN || file.token || '', + baseId: overrides?.baseId || process.env.INKREACH_TEABLE_BASE_ID || file.baseId, }; } exports.resolveConfig = resolveConfig; diff --git a/dist/lib/ctx.js b/dist/lib/ctx.js index d42616a..df58a5c 100644 --- a/dist/lib/ctx.js +++ b/dist/lib/ctx.js @@ -65,7 +65,7 @@ function findRoot(cmd) { function requireBaseId(ctx, flagVal) { const baseId = flagVal || ctx.baseId; if (!baseId) { - throw new client_1.ApiError(0, 'MISSING_BASE_ID', 'No base id. Pass --base-id , set a default with `inkreach auth login --base-id `, or export INKREACH_BASE_ID.'); + throw new client_1.ApiError(0, 'MISSING_BASE_ID', 'No base id. Pass --base-id , set a default with `inkreach-teable auth login --base-id `, or export INKREACH_TEABLE_BASE_ID.'); } return baseId; } diff --git a/docs/cli-skill-design.md b/docs/cli-skill-design.md index 27f6efa..da75e13 100644 --- a/docs/cli-skill-design.md +++ b/docs/cli-skill-design.md @@ -8,7 +8,7 @@ inkreach-teable(本项目)自研了一套自动化(workflow)引擎,与官方 teable 的自动化**完全不兼容**: -| 维度 | 官方 teable | 本项目(inkreach) | +| 维度 | 官方 teable | 本项目(inkreach-teable) | |---|---|---| | 过滤条件键名 | `filter` | `conditions` | | 监听字段键名 | `watchFieldIds` | `fieldIds` | @@ -19,11 +19,11 @@ inkreach-teable(本项目)自研了一套自动化(workflow)引擎,与 官方 `teable` CLI(v0.6.22)按官方契约调用,**无法操作本项目自动化**(已实测:列自动化时 404/契约不匹配)。表格/字段/记录/视图的 REST API 则与官方完全兼容。 -**结论**:必须自研一个 `inkreach` CLI 包装本项目真实契约,并配套一个 skill 教 Agent 如何使用。 +**结论**:必须自研一个 `inkreach-teable` CLI 包装本项目真实契约,并配套一个 skill 教 Agent 如何使用。 ## 2. 目标 -1. **`inkreach` CLI**(`packages/inkreach-cli/`):Node.js 命令行工具,封装本项目全部 REST API,重点是自研自动化契约。 +1. **`inkreach-teable` CLI**(`packages/inkreach-cli/`):Node.js 命令行工具,封装本项目全部 REST API,重点是自研自动化契约。 2. **`inkreach-teable-ops` skill**(`.agents/skills/inkreach-teable-ops/`):教 Agent 何时用哪个 CLI 命令、配置表格与自动化的正确姿势、本项目的部署/开发约定。 3. **端到端验证**:在本地实例真实跑通"建表 → 建自动化 → 配 buttonClick 触发器 → 激活 → 查执行历史"全链路。 @@ -34,14 +34,14 @@ inkreach-teable(本项目)自研了一套自动化(workflow)引擎,与 - **运行时**:Node.js(无额外运行时依赖,项目已是 Node 栈)。 - **框架**:`commander`(成熟、零学习成本、官方 teable CLI 也用 commander)。 - **HTTP**:`node:https`/`node:http`(**不用** `fetch`——Node v24 全局 fetch 会吞 Authorization 头,这是本会话已确认的坑)。封装一个 `request()`。 -- **配置存储**:`~/.inkreach/config.json`(endpoint + token),支持环境变量覆盖 `INKREACH_ENDPOINT` / `INKREACH_TOKEN`。 +- **配置存储**:`~/.inkreach-teable/config.json`(endpoint + token),支持环境变量覆盖 `INKREACH_TEABLE_ENDPOINT` / `INKREACH_TEABLE_TOKEN`。 - **输出**:默认人类可读(表格/着色),`--json` 输出原始 JSON 供 Agent 解析。 - **零运行时依赖**优先(commander 是唯一依赖),便于 `node bin.js` 直接跑、便于打包。 ### 3.2 命令树 ``` -inkreach [全局选项] <命令> +inkreach-teable [全局选项] <命令> 全局选项: --endpoint 覆盖配置的 endpoint(默认 http://localhost:3000) @@ -142,7 +142,7 @@ YAML frontmatter(name + 极详细的 description 触发条件)+ 以下章节 ├── SKILL.md 入口 ├── metadata.json 版本元数据 ├── scripts/ -│ └── install.sh 安装/升级 inkreach CLI(pnpm build + link) +│ └── install.sh 安装/升级 inkreach-teable CLI(pnpm build + link) └── guides/ 与 api-reference/ 按需加载 ├── guides/ │ ├── instance-access.md 本实例访问信息(endpoint、服务状态、凭据获取) @@ -177,14 +177,14 @@ YAML frontmatter(name + 极详细的 description 触发条件)+ 以下章节 ## 6. 验证标准 -- `inkreach auth status` 返回当前用户。 -- `inkreach workflow list --base-id bseeZR7yiDNeMPCa4CN` 列出自动化。 -- `inkreach workflow create --name "CLI测试" --base-id bseeZR7yiDNeMPCa4CN` 创建成功。 -- `inkreach trigger set --type buttonClick --table-id tblXXX --field-ids '["fldXXX"]'` 正确配置。 -- `inkreach action add --type script --code '...'` 正确添加节点。 -- `inkreach workflow activate ` 激活成功(返回 snapshotId)。 -- `inkreach fire button-click ...` 触发执行。 -- `inkreach runs list ` 能看到刚才的执行。 +- `inkreach-teable auth status` 返回当前用户。 +- `inkreach-teable workflow list --base-id bseeZR7yiDNeMPCa4CN` 列出自动化。 +- `inkreach-teable workflow create --name "CLI测试" --base-id bseeZR7yiDNeMPCa4CN` 创建成功。 +- `inkreach-teable trigger set --type buttonClick --table-id tblXXX --field-ids '["fldXXX"]'` 正确配置。 +- `inkreach-teable action add --type script --code '...'` 正确添加节点。 +- `inkreach-teable workflow activate ` 激活成功(返回 snapshotId)。 +- `inkreach-teable fire button-click ...` 触发执行。 +- `inkreach-teable runs list ` 能看到刚才的执行。 - skill 被 Agent 正确加载(出现在 available_skills)。 ## 7. 非目标 diff --git a/package.json b/package.json index d695e7a..3f9817d 100644 --- a/package.json +++ b/package.json @@ -1,11 +1,11 @@ { "name": "@inkreach/teable-cli", "version": "0.1.0", - "description": "CLI for operating inkreach-teable: tables, fields, records, views, and the self-built automation engine (8 triggers + 6 actions).", + "description": "CLI (command: inkreach-teable) for operating inkreach-teable: tables, fields, records, views, and the self-built automation engine (8 triggers + 6 actions).", "license": "MIT", "type": "commonjs", "bin": { - "inkreach": "./dist/bin.js" + "inkreach-teable": "./dist/bin.js" }, "main": "dist/bin.js", "scripts": { diff --git a/src/bin.ts b/src/bin.ts index e97fa96..5ef1e09 100644 --- a/src/bin.ts +++ b/src/bin.ts @@ -1,6 +1,6 @@ #!/usr/bin/env node /** - * inkreach — CLI for operating inkreach-teable. + * inkreach-teable — CLI for operating inkreach-teable. * * Entry point. Sets up the global commander program and mounts command groups. */ @@ -14,12 +14,12 @@ import { secretCommand, runsCommand, fireCommand, sqlCommand } from './commands/ const program = new Command(); program - .name('inkreach') + .name('inkreach-teable') .description( 'Operate inkreach-teable: tables, fields, records, views, and the self-built automation engine (8 triggers + 6 actions).\n' + 'Use --json for machine-readable output (agent parsing).' ) - .version(`inkreach ${version}`, '-v, --version'); + .version(`inkreach-teable ${version}`, '-v, --version'); // Global options (highest precedence over config file + env). program diff --git a/src/commands/auth.ts b/src/commands/auth.ts index b4eb336..cb74cc2 100644 --- a/src/commands/auth.ts +++ b/src/commands/auth.ts @@ -1,5 +1,5 @@ /** - * `inkreach auth` — authentication & config commands. + * `inkreach-teable auth` — authentication & config commands. */ import { Command } from 'commander'; import { run, requireBaseId } from '../lib/ctx'; @@ -126,7 +126,7 @@ export function authCommand(): Command { ['token', created.token], ['', ''], ['note', 'Save this token now — it cannot be retrieved again.'], - ['use', 'inkreach auth login --token '], + ['use', 'inkreach-teable auth login --token '], ]); } }) diff --git a/src/commands/extras.ts b/src/commands/extras.ts index 926fe61..9ce8b44 100644 --- a/src/commands/extras.ts +++ b/src/commands/extras.ts @@ -1,8 +1,8 @@ /** - * `inkreach secret` — manage workflow automation secrets. - * `inkreach runs` — execution history. - * `inkreach fire` — manual trigger testing (button-click / webhook). - * `inkreach sql` — read-only SQL queries. + * `inkreach-teable secret` — manage workflow automation secrets. + * `inkreach-teable runs` — execution history. + * `inkreach-teable fire` — manual trigger testing (button-click / webhook). + * `inkreach-teable sql` — read-only SQL queries. */ import { Command } from 'commander'; import { run, requireBaseId } from '../lib/ctx'; diff --git a/src/commands/resources.ts b/src/commands/resources.ts index c84b80f..8dc90bd 100644 --- a/src/commands/resources.ts +++ b/src/commands/resources.ts @@ -1,5 +1,5 @@ /** - * `inkreach base|table|field|record|view` — resource CRUD commands. + * `inkreach-teable base|table|field|record|view` — resource CRUD commands. * * These endpoints are compatible with official teable open-api. */ diff --git a/src/commands/workflow.ts b/src/commands/workflow.ts index 0f33792..d06042d 100644 --- a/src/commands/workflow.ts +++ b/src/commands/workflow.ts @@ -1,7 +1,7 @@ /** - * `inkreach workflow` — workflow CRUD + lifecycle. - * `inkreach trigger` — set the trigger node's type & config. - * `inkreach action` — add/update/delete action nodes. + * `inkreach-teable workflow` — workflow CRUD + lifecycle. + * `inkreach-teable trigger` — set the trigger node's type & config. + * `inkreach-teable action` — add/update/delete action nodes. * * All node-mutating commands operate via PUT /node (whole-graph replacement), * so they internally GET the full graph, mutate, then PUT it back. @@ -123,7 +123,7 @@ export function workflowCommand(): Command { ['name', wf.name], ['baseId', wf.baseId], ['', ''], - ['next', `inkreach trigger set ${wf.id} --type ...`], + ['next', `inkreach-teable trigger set ${wf.id} --type ...`], ]); } }) @@ -296,7 +296,7 @@ export function triggerCommand(): Command { ['triggerType', opts.type], ['config', JSON.stringify(config)], ['', ''], - ['next', `inkreach action add ${workflowId} --type script ...`], + ['next', `inkreach-teable action add ${workflowId} --type script ...`], ]); } }) @@ -432,7 +432,7 @@ export function actionCommand(): Command { ['type', opts.type], ['config', JSON.stringify(config)], ['', ''], - ['next', `inkreach workflow activate ${workflowId}`], + ['next', `inkreach-teable workflow activate ${workflowId}`], ]); } }) diff --git a/src/lib/config.ts b/src/lib/config.ts index cd6174a..0a86e84 100644 --- a/src/lib/config.ts +++ b/src/lib/config.ts @@ -1,8 +1,8 @@ /** - * Config storage for inkreach CLI. + * Config storage for inkreach-teable CLI. * - * Stores endpoint + token at ~/.inkreach/config.json, with environment variable - * overrides INKREACH_ENDPOINT / INKREACH_TOKEN. The --endpoint / --token / --base-id + * Stores endpoint + token at ~/.inkreach-teable/config.json, with environment variable + * overrides INKREACH_TEABLE_ENDPOINT / INKREACH_TEABLE_TOKEN. The --endpoint / --token / --base-id * global flags take the highest precedence (handled by resolveOptions()). */ import * as fs from 'node:fs'; @@ -15,7 +15,7 @@ export interface IConfig { baseId?: string; } -const CONFIG_DIR = path.join(os.homedir(), '.inkreach'); +const CONFIG_DIR = path.join(os.homedir(), '.inkreach-teable'); const CONFIG_FILE = path.join(CONFIG_DIR, 'config.json'); export const DEFAULT_ENDPOINT = 'http://localhost:3000'; @@ -42,11 +42,11 @@ export function resolveConfig(overrides?: Partial): IConfig { return { endpoint: overrides?.endpoint || - process.env.INKREACH_ENDPOINT || + process.env.INKREACH_TEABLE_ENDPOINT || file.endpoint || DEFAULT_ENDPOINT, - token: overrides?.token || process.env.INKREACH_TOKEN || file.token || '', - baseId: overrides?.baseId || process.env.INKREACH_BASE_ID || file.baseId, + token: overrides?.token || process.env.INKREACH_TEABLE_TOKEN || file.token || '', + baseId: overrides?.baseId || process.env.INKREACH_TEABLE_BASE_ID || file.baseId, }; } diff --git a/src/lib/ctx.ts b/src/lib/ctx.ts index 14a45e6..e91b90f 100644 --- a/src/lib/ctx.ts +++ b/src/lib/ctx.ts @@ -85,7 +85,7 @@ export function requireBaseId(ctx: Ctx, flagVal?: string): string { throw new ApiError( 0, 'MISSING_BASE_ID', - 'No base id. Pass --base-id , set a default with `inkreach auth login --base-id `, or export INKREACH_BASE_ID.' + 'No base id. Pass --base-id , set a default with `inkreach-teable auth login --base-id `, or export INKREACH_TEABLE_BASE_ID.' ); } return baseId;