@turri-dev/cli 0.1.6-next.10e70aa → 0.1.6

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/README.md CHANGED
@@ -190,7 +190,7 @@ Start at the [documentation index](docs/README.md), or go straight to a page:
190
190
  | | |
191
191
  | --- | --- |
192
192
  | [Installation](docs/installation.md) | doctor, what turri needs of this machine, **turri** and `pi`, environment variables |
193
- | [Examples](examples/README.md) | projects to build with turri step by step: cognio from an empty folder, a CLI, a backend service with conformance tests, a REST API integration |
193
+ | [Examples](examples/README.md) | projects to build with turri step by step: cognio from an empty folder, guestbook - a backend and a frontend in minutes - a CLI, a backend service with conformance tests, a REST API integration |
194
194
  | [Using **turri**](docs/using.md) | the conversation, skills, tools, pulses and regen, choosing models, the command line |
195
195
  | [The project config](docs/config.md) | `config.turri.yaml` and each stack's `config.turri.<stack>.yaml`: every key, models and their inheritance, conformance, the testing scripts, stacks and choosing one, the old `config.yaml` |
196
196
  | [Deploy](docs/deploy.md) | trying what is built: the last commit in `dist/<module>`, started on your machine, nothing installed without asking |
package/dist/cli.js CHANGED
@@ -19,7 +19,7 @@ import { dirname, join } from "node:path";
19
19
  import { fileURLToPath } from "node:url";
20
20
  import { CODING_MODEL_ENV, chatModels } from "./chat-models.js";
21
21
  import { readProjectConfig } from "./config.js";
22
- import { extensionInstalledGlobally, PACKAGE_ROOT, themesInstalledGlobally } from "./environment.js";
22
+ import { extensionInstalledGlobally, PACKAGE_ROOT, themesInstalledGlobally, versionLine } from "./environment.js";
23
23
  import { dropNoise } from "./quiet.js";
24
24
  /**
25
25
  * Start pi with this project's extension and themes already wired in.
@@ -92,6 +92,7 @@ const SETUP_COMMANDS = {
92
92
  const USAGE = [
93
93
  "usage: turri [options] open the conversation here: pi, with turri's tools and themes loaded",
94
94
  " turri <command> [args]",
95
+ " turri --version turri's version, and pi's",
95
96
  "",
96
97
  ` ${"options".padEnd(12)} --harness-model <m> the model you chat with --coding-model <m> the model renders run on`,
97
98
  ` ${"".padEnd(12)} --stack <name> build with config.turri.<name>.yaml over config.turri.yaml - here and in every command`,
@@ -139,6 +140,11 @@ if (command === "-h" || command === "--help") {
139
140
  console.log(USAGE);
140
141
  process.exit(0);
141
142
  }
143
+ // turri's version, not pi's alone: pi's --version would answer for it.
144
+ if (command === "-v" || command === "--version") {
145
+ console.log(versionLine());
146
+ process.exit(0);
147
+ }
142
148
  // turri alone is the conversation, and so is turri with pi's options - `turri -c`, `turri --harness-model <m>`. A word
143
149
  // turri does not know is an error below, not a conversation started on it.
144
150
  if (command === undefined || command.startsWith("-"))
@@ -68,6 +68,32 @@ export function turriOnPath() {
68
68
  const found = which.status === 0 ? which.stdout.trim().split("\n")[0] : undefined;
69
69
  return found === "" ? undefined : found;
70
70
  }
71
+ /** The version of the pi turri runs on, as Node finds it - undefined when it is not installed. */
72
+ export function piVersion() {
73
+ try {
74
+ // Its entry point, then up to the package.json that names it.
75
+ for (let dir = dirname(fileURLToPath(import.meta.resolve("@earendil-works/pi-coding-agent"))); dirname(dir) !== dir; dir = dirname(dir)) {
76
+ const file = join(dir, "package.json");
77
+ if (!existsSync(file))
78
+ continue;
79
+ const pkg = JSON.parse(readFileSync(file, "utf8"));
80
+ if (pkg.name === "@earendil-works/pi-coding-agent")
81
+ return pkg.version;
82
+ }
83
+ }
84
+ catch {
85
+ /* not installed: left out */
86
+ }
87
+ return undefined;
88
+ }
89
+ /**
90
+ * What `turri --version` prints: turri's version - from a clone, its commit too, as the banner says it - and pi's
91
+ * beside it. pi's own `--version` says only pi's, which read as turri's.
92
+ */
93
+ export function versionLine(identity = turriIdentity(), pi = piVersion() ?? null) {
94
+ const clone = identity.git_commit !== null ? `, from a clone, ${identity.git_commit.slice(0, 7)}${identity.git_dirty === true ? " with changes" : ""}` : "";
95
+ return `turri ${identity.version ?? "0.0.0"}${clone}${pi !== null ? ` (pi ${pi})` : ""}`;
96
+ }
71
97
  /** turri's version, and the commit when it runs from a clone. */
72
98
  export function turriIdentity() {
73
99
  let version = null;
@@ -17,7 +17,7 @@ turri init-config # a config.turri.yaml with the model you talk to and the one
17
17
  turri # pi, with turri's tools, skills and themes loaded
18
18
  ```
19
19
 
20
- The package is `@turri-dev/cli` - npm keeps the name `turri` back, as too like another package's - and the command it puts on your PATH is `turri`. `npm install -g @turri-dev/cli@next` gets the latest prerelease instead, built from the last commit on `main`.
20
+ The package is `@turri-dev/cli` - npm keeps the name `turri` back, as too like another package's - and the command it puts on your PATH is `turri`. `npm install -g @turri-dev/cli@next` gets the latest prerelease instead, built from the last commit on `main`. Installed again - `@latest` or `@next` - it replaces the one there. `turri --version` says which turri runs, and the pi under it: `turri 0.1.6 (pi 1.3.0)`, and from a clone its commit too.
21
21
 
22
22
  ## From a clone
23
23
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@turri-dev/cli",
3
- "version": "0.1.6-next.10e70aa",
3
+ "version": "0.1.6",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "repository": {