@theokit/cli 0.1.1
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/CHANGELOG.md +84 -0
- package/README.md +126 -0
- package/dist/bin/theokit.cjs +1557 -0
- package/dist/bin/theokit.cjs.map +1 -0
- package/dist/bin/theokit.js +1531 -0
- package/dist/bin/theokit.js.map +1 -0
- package/dist/index.cjs +1552 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +28 -0
- package/dist/index.d.ts +28 -0
- package/dist/index.js +1524 -0
- package/dist/index.js.map +1 -0
- package/package.json +63 -0
- package/templates/minimal/.env.example +14 -0
- package/templates/minimal/README.md +29 -0
- package/templates/minimal/package.json +21 -0
- package/templates/minimal/src/index.ts +38 -0
- package/templates/minimal/tsconfig.json +12 -0
- package/templates/ollama-local/.env.example +16 -0
- package/templates/ollama-local/README.md +46 -0
- package/templates/ollama-local/package.json +21 -0
- package/templates/ollama-local/src/index.ts +51 -0
- package/templates/ollama-local/tsconfig.json +12 -0
- package/templates/telegram-bot/.env.example +15 -0
- package/templates/telegram-bot/README.md +35 -0
- package/templates/telegram-bot/package.json +24 -0
- package/templates/telegram-bot/src/index.ts +66 -0
- package/templates/telegram-bot/tsconfig.json +12 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## [Unreleased]
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
|
|
7
|
+
- `theokit db` subcommand wrapping drizzle-kit (Plan `usetheo-orm-v1` Phase 6.5). Subcommands: `generate`, `migrate`, `studio`, `push`, `export-schema`, `check-schema-drift`. Schema commands consume `orm.config.ts` (default-exports `{ schema }`) and invoke `@theokit/orm/schema-export` to emit JSON Schema 7 per entity to `.theokit/schema/{entity}.schema.json`. `check-schema-drift` diffs fresh vs committed schemas and exits 1 on drift — wires into CI as a polyglot-safety gate.
|
|
8
|
+
|
|
9
|
+
## 2.0.0
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Updated dependencies
|
|
14
|
+
- @theokit/sdk@1.3.0
|
|
15
|
+
- @theokit/acp@2.0.0
|
|
16
|
+
|
|
17
|
+
## 1.0.0
|
|
18
|
+
|
|
19
|
+
### Patch Changes
|
|
20
|
+
|
|
21
|
+
- Updated dependencies
|
|
22
|
+
- @theokit/sdk@1.2.0
|
|
23
|
+
- @theokit/acp@1.0.0
|
|
24
|
+
|
|
25
|
+
## [Unreleased]
|
|
26
|
+
|
|
27
|
+
### Added (`theokit tasks` — observable async work registry, ADRs D361-D374)
|
|
28
|
+
|
|
29
|
+
- New top-level subcommand `theokit tasks {list|inspect|cancel}` reads the
|
|
30
|
+
`JsonFileTaskStore` at `$THEOKIT_HOME/tasks/` (fallback: `cwd/.theokit/tasks`).
|
|
31
|
+
Reports CLI exit codes: 0 success, 2 permission/IO, 3 invalid id grammar,
|
|
32
|
+
4 task not found.
|
|
33
|
+
- `theokit tasks list [--state S] [--kind K] [--json]` — table or JSON view.
|
|
34
|
+
- `theokit tasks inspect <id> [--json]` — full handle dump.
|
|
35
|
+
- `theokit tasks cancel <id> [--reason R]` — cross-process best-effort cancel via
|
|
36
|
+
the `cancelRequested` flag on the JSON-backed handle. The owning Node process
|
|
37
|
+
(the one that submitted the task) honors the flag at the next checkpoint
|
|
38
|
+
(EC-7). Queued tasks transition directly to `cancelled`. Terminal tasks
|
|
39
|
+
print `task already terminal` and exit 0.
|
|
40
|
+
- 12 unit tests under `tests/commands/tasks.test.ts` covering fresh-install
|
|
41
|
+
ENOENT (EC-6), invalid id grammar, not-found, and the 3 cancel paths.
|
|
42
|
+
|
|
43
|
+
### Added (`theokit acp` — ACP server adapter, ADRs D349-D360)
|
|
44
|
+
|
|
45
|
+
- New top-level subcommand `theokit acp` launches a stdio ACP server pointing at
|
|
46
|
+
the entry file's default-exported `SDKAgent` or factory. Used by Zed,
|
|
47
|
+
Cursor, Claude Desktop, and any [Agent Client Protocol](https://agentclientprotocol.com)
|
|
48
|
+
host.
|
|
49
|
+
- `--entry <path>` reuses the same resolver as `theokit dev` (D357). Default:
|
|
50
|
+
`src/index.ts` or `package.main`.
|
|
51
|
+
- `--permission ask|auto|deny` controls tool gate (default `ask`). `--trusted-tools`
|
|
52
|
+
bypass list. `--permission-timeout-ms` overrides the 60 s default (EC-2 absorbed).
|
|
53
|
+
- CJS/ESM interop fallback (`mod.default ?? mod`) so consumers using
|
|
54
|
+
`module.exports = factory` work without contortions (EC-4).
|
|
55
|
+
- `@theokit/acp` listed as an OPTIONAL peer dependency — install only when you
|
|
56
|
+
need the subcommand: `npm i @theokit/acp`.
|
|
57
|
+
- 4 new tests in `tests/commands/acp.test.ts` covering entry resolution, default
|
|
58
|
+
export fallback, permission flag validation.
|
|
59
|
+
|
|
60
|
+
### Added (Roadmap v1.4 #5 — `theokit setup gworkspace`, ADRs D340-D348)
|
|
61
|
+
|
|
62
|
+
- New top-level subcommand `theokit setup <domain>` (ADR D346) with `gworkspace`
|
|
63
|
+
as the first concrete domain. Future domains follow the same pattern.
|
|
64
|
+
- `packages/cli/src/commands/setup.ts` + `packages/cli/src/setup/gworkspace.ts` —
|
|
65
|
+
walkthrough that validates `~/.google-mcp/credentials.json` BEFORE delegating
|
|
66
|
+
to upstream `npx google-workspace-mcp setup` + `accounts add`.
|
|
67
|
+
- EC-1 (MUST FIX): rejects Web-type OAuth client up-front with actionable error.
|
|
68
|
+
- EC-2: rejects malformed JSON with parse-error message.
|
|
69
|
+
- EC-3: `--probe` mode caps each upstream call at 10s.
|
|
70
|
+
- Path-traversal guard on `--credentials-path` (D80 pattern).
|
|
71
|
+
- 8 new tests in `tests/setup/` (credentials-check + dispatch).
|
|
72
|
+
|
|
73
|
+
### Added (T0.1 — workspace scaffolding, Adoption Roadmap #1)
|
|
74
|
+
|
|
75
|
+
- New workspace package `@theokit/cli` — developer CLI for `@theokit/sdk`.
|
|
76
|
+
- `bin: theokit` registered; executable shim at `src/bin/theokit.ts`.
|
|
77
|
+
- Programmatic API: `main(argv): Promise<number>` returns exit code.
|
|
78
|
+
- Build-time constants `SDK_VERSION` / `CLI_VERSION` injected via tsup
|
|
79
|
+
`define` (EC-L fix — never `workspace:*` in scaffolded projects).
|
|
80
|
+
- `"files": ["dist", "templates", "README.md", ...]` in package.json
|
|
81
|
+
(EC-C MUST FIX — ensures templates ship in the published tarball).
|
|
82
|
+
- Smoke tests + tarball-contents guard.
|
|
83
|
+
|
|
84
|
+
Subcommand surface (`init`, `dev`, `inspect`, `eval`) ships in T1.1-T5.1.
|
package/README.md
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
# @theokit/cli — `theokit`
|
|
2
|
+
|
|
3
|
+
Developer CLI for `@theokit/sdk`. Four subcommands at v1: `init`, `dev`,
|
|
4
|
+
`inspect`, `eval`. Adoption Roadmap #1.
|
|
5
|
+
|
|
6
|
+
## Install
|
|
7
|
+
|
|
8
|
+
```bash
|
|
9
|
+
# One-shot scaffold via npx (recommended for first use):
|
|
10
|
+
npx @theokit/cli init my-bot
|
|
11
|
+
|
|
12
|
+
# Or install globally:
|
|
13
|
+
pnpm add -g @theokit/cli
|
|
14
|
+
theokit --help
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## `theokit init <project-name>`
|
|
18
|
+
|
|
19
|
+
Scaffold a new agent project from a bundled template.
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
theokit init my-bot --template minimal
|
|
23
|
+
theokit init local-rag --template ollama-local
|
|
24
|
+
theokit init my-bot-tg --template telegram-bot
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
**Templates:**
|
|
28
|
+
|
|
29
|
+
- `minimal` — smallest possible Agent.create + send + stream.
|
|
30
|
+
- `ollama-local` — 100% local via Ollama (no remote API key).
|
|
31
|
+
- `telegram-bot` — Telegram bot via `@theokit/gateway` + grammy.
|
|
32
|
+
|
|
33
|
+
**Flags:**
|
|
34
|
+
|
|
35
|
+
- `-t, --template <name>` — template to use (prompts if omitted).
|
|
36
|
+
- `-f, --force` — overwrite non-empty destination.
|
|
37
|
+
- `-y, --yes` — skip prompts (CI mode).
|
|
38
|
+
|
|
39
|
+
## `theokit dev`
|
|
40
|
+
|
|
41
|
+
Run your agent's entry point under `tsx --watch`.
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
theokit dev # auto-detects src/index.ts or package.main
|
|
45
|
+
theokit dev --entry src/bot.ts # explicit entry
|
|
46
|
+
theokit dev --env .env.local # custom env file (default: .env)
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## `theokit inspect`
|
|
50
|
+
|
|
51
|
+
List what the SDK sees: builtin providers, embedding adapters, gateway
|
|
52
|
+
adapters, discovered plugins.
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
theokit inspect
|
|
56
|
+
theokit inspect --json # machine-readable
|
|
57
|
+
theokit inspect --filter providers # narrow to one kind
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## `theokit eval`
|
|
61
|
+
|
|
62
|
+
Run a `eval.config.{ts,mjs}` against a real LLM and emit a markdown
|
|
63
|
+
report.
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
theokit eval # ./eval.config.ts → ./eval-report.md
|
|
67
|
+
theokit eval --config my-eval.ts --output reports/run1.md
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
**Example `eval.config.ts`:**
|
|
71
|
+
|
|
72
|
+
```ts
|
|
73
|
+
import type { EvalConfig } from "@theokit/cli";
|
|
74
|
+
|
|
75
|
+
export default {
|
|
76
|
+
dataset: [
|
|
77
|
+
{ input: "Say hello in one word.", expected: "hello" },
|
|
78
|
+
{ input: "What is 2+2?", expected: "4" },
|
|
79
|
+
],
|
|
80
|
+
scorers: [
|
|
81
|
+
{
|
|
82
|
+
name: "contains-expected",
|
|
83
|
+
score: (output, expected) =>
|
|
84
|
+
typeof expected === "string" && output.toLowerCase().includes(expected.toLowerCase())
|
|
85
|
+
? { score: 1 }
|
|
86
|
+
: { score: 0, reason: `expected "${expected}"` },
|
|
87
|
+
},
|
|
88
|
+
],
|
|
89
|
+
agent: {
|
|
90
|
+
apiKey: process.env.THEOKIT_API_KEY ?? "local",
|
|
91
|
+
model: { id: "ollama/llama3.2:3b" },
|
|
92
|
+
local: { cwd: process.cwd() },
|
|
93
|
+
},
|
|
94
|
+
} satisfies EvalConfig;
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
The eval runner v1 wraps `Agent.batch` (ADR D134); when Roadmap #2
|
|
98
|
+
ships, internals swap to `Eval.run` — your config keeps working.
|
|
99
|
+
|
|
100
|
+
## Exit codes
|
|
101
|
+
|
|
102
|
+
| Code | Meaning |
|
|
103
|
+
|---|---|
|
|
104
|
+
| 0 | Success |
|
|
105
|
+
| 1 | Unknown error |
|
|
106
|
+
| 2 | User error (bad flags, validation failure, etc.) |
|
|
107
|
+
|
|
108
|
+
## Architecture
|
|
109
|
+
|
|
110
|
+
See ADRs D193-D201 in `.claude/knowledge-base/adrs/`:
|
|
111
|
+
|
|
112
|
+
- D193: separate workspace package
|
|
113
|
+
- D194: commander routing
|
|
114
|
+
- D195: bin name `theokit`
|
|
115
|
+
- D196: bundled templates (offline-friendly)
|
|
116
|
+
- D197: `dev` via `tsx --watch`
|
|
117
|
+
- D198: `inspect` is read-only
|
|
118
|
+
- D199: `eval` v1 wraps `Agent.batch`
|
|
119
|
+
- D200: 3 initial templates
|
|
120
|
+
- D201: `Theokit.inspect.*` public API
|
|
121
|
+
|
|
122
|
+
## Requirements
|
|
123
|
+
|
|
124
|
+
- Node 22.12+.
|
|
125
|
+
- pnpm (recommended) or npm. Templates use pnpm scripts; npm/yarn
|
|
126
|
+
users can manually translate.
|