A self-built CLI and companion agent skill for operating a deployed
inkreach-teable instance — configuring tables, fields, records, views, and
the project's OWN automation engine.
Why not the official 'teable' CLI:
inkreach-teable's automation is self-built with a different contract:
- conditions (not filter), fieldIds (not watchFieldIds)
- recordCondition (not recordMatchesConditions)
- webhook route /api/webhook/{baseId}/{wfId} (not the /base//workflow/ form)
- scheduledTime backend honors only timing.type + timing.interval
The official CLI targets the upstream contract and 404s/misconfigures here.
Table/field/record/view APIs ARE upstream-compatible, but automation is not.
inkreach CLI (packages/inkreach-cli/):
- Node.js + commander, zero extra runtime deps
- Uses node:http (NOT fetch — Node 24 fetch drops Authorization header)
- Commands: auth (login/status/token), base/table/field/record/view,
workflow (list/get/create/update/delete/activate/deactivate/test),
trigger set (8 types, builds correct config keys), action add/update/delete
(6 types), secret, runs (list/get/rerun), fire (button-click/webhook), sql
- --json mode for agent parsing; GET->modify->PUT whole-graph for node edits
- Verified end-to-end: create workflow -> set webhook trigger -> add script
action -> activate -> fire webhook -> runs list (succeeded)
inkreach-teable-ops skill (.agents/skills/inkreach-teable-ops/):
- SKILL.md entry: module map, routing rules, 11 key constraints (the real
contract keys), execution rules, error recovery
- guides/: cli-reference, automation-guide, tables-fields, instance-access,
development (build/restart, known gotchas)
- api-reference/: trigger-types (8 triggers, exact config), action-types
(6 actions, sandbox globals), field-types (21 types incl. Button)
- metadata.json + install.sh
46 lines
1.7 KiB
TypeScript
46 lines
1.7 KiB
TypeScript
/**
|
|
* Output formatting helpers.
|
|
*
|
|
* Two modes:
|
|
* - JSON mode (--json flag): print raw JSON, nothing else.
|
|
* - Human mode (default): pretty-print tables / key-values.
|
|
*/
|
|
export interface OutputOptions {
|
|
json: boolean;
|
|
}
|
|
|
|
/** Print as JSON (compact). Safe for agent parsing. */
|
|
export function printJson(value: unknown): void {
|
|
process.stdout.write(JSON.stringify(value) + '\n');
|
|
}
|
|
|
|
/** Print a human-readable table. columns: [{key, header, width?}]; rows: object[]. */
|
|
export function printTable(
|
|
columns: Array<{ key: string; header: string }>,
|
|
rows: Array<Record<string, unknown>>
|
|
): void {
|
|
const headers = columns.map((c) => c.header);
|
|
const widths = columns.map((c) => Math.max(c.header.length, ...rows.map((r) => String(r[c.key] ?? '').length)));
|
|
const sep = widths.map((w) => '-'.repeat(w)).join(' ');
|
|
const fmtRow = (r: Record<string, unknown>) =>
|
|
columns.map((c, i) => String(r[c.key] ?? '').padEnd(widths[i])).join(' ');
|
|
process.stdout.write(headers.map((h, i) => h.padEnd(widths[i])).join(' ') + '\n');
|
|
process.stdout.write(sep + '\n');
|
|
rows.forEach((r) => process.stdout.write(fmtRow(r) + '\n'));
|
|
}
|
|
|
|
/** Print key: value pairs vertically. */
|
|
export function printKv(pairs: Array<[string, unknown]>): void {
|
|
const width = Math.max(...pairs.map(([k]) => k.length));
|
|
pairs.forEach(([k, v]) => {
|
|
const val = typeof v === 'object' && v !== null ? JSON.stringify(v) : String(v ?? '');
|
|
process.stdout.write(`${k.padEnd(width)} ${val}\n`);
|
|
});
|
|
}
|
|
|
|
/** Truncate a long string to width, appending ellipsis. */
|
|
export function truncate(s: unknown, width = 40): string {
|
|
const str = String(s ?? '');
|
|
return str.length > width ? str.slice(0, width - 1) + '…' : str;
|
|
}
|