@pmelab/gtd 6.0.0 → 6.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/README.md CHANGED
@@ -76,6 +76,10 @@ Four commands drive it:
76
76
  `<commitish>..HEAD` (e.g. a colleague's PR branch), reusing the workflow's
77
77
  existing review/feedback machinery over that diff.
78
78
 
79
+ `gtd version` (or `gtd --version`/`-v`) prints the installed version and exits;
80
+ `gtd help` (or `gtd --help`/`-h`) prints the command list. Both short-circuit
81
+ before any repo work, so they run anywhere.
82
+
79
83
  The loop is one beat, repeated: run `gtd next --json` and dispatch on `kind` —
80
84
  `"message"` means it's a human's move (stop and hand off); `"script"` means the
81
85
  driver runs `content` itself, then steps its actor; `"prompt"` means feed
@@ -190291,6 +190291,21 @@ const SEARCH_PLACES = [
190291
190291
  "gtd.config.yaml"
190292
190292
  ];
190293
190293
  /**
190294
+ * The shared cosmiconfig explorer used by every config lookup. `searchStrategy:
190295
+ * 'none'` makes `.search(dir)` inspect only that single directory (no internal
190296
+ * walking), so callers drive the cwd→home walk themselves via `walkUp`.
190297
+ */
190298
+ const makeExplorer = () => (0, import_dist.cosmiconfig)("gtd", {
190299
+ searchPlaces: SEARCH_PLACES,
190300
+ searchStrategy: "none",
190301
+ loaders: {
190302
+ noExt: yamlLoader,
190303
+ ".json": jsonLoader,
190304
+ ".yaml": yamlLoader,
190305
+ ".yml": yamlLoader
190306
+ }
190307
+ });
190308
+ /**
190294
190309
  * Load and deep-merge every config level from cwd up the directory chain.
190295
190310
  * Innermost (cwd) wins. Returns the merged plain object (undecoded).
190296
190311
  */
@@ -190298,16 +190313,7 @@ const loadMerged = (root) => tryPromise({
190298
190313
  try: async () => {
190299
190314
  const home = homedir();
190300
190315
  const chain = walkUp(root, home);
190301
- const explorer = (0, import_dist.cosmiconfig)("gtd", {
190302
- searchPlaces: SEARCH_PLACES,
190303
- searchStrategy: "none",
190304
- loaders: {
190305
- noExt: yamlLoader,
190306
- ".json": jsonLoader,
190307
- ".yaml": yamlLoader,
190308
- ".yml": yamlLoader
190309
- }
190310
- });
190316
+ const explorer = makeExplorer();
190311
190317
  const levels = [];
190312
190318
  for (let i = chain.length - 1; i >= 0; i--) {
190313
190319
  const dir = chain[i];
@@ -190322,30 +190328,15 @@ const loadMerged = (root) => tryPromise({
190322
190328
  catch: (e) => e instanceof Error ? e : new Error(String(e))
190323
190329
  });
190324
190330
  /**
190325
- * Reuses the same `walkUp` + `searchStrategy: "none"` cosmiconfig explorer as
190326
- * `loadMerged` to detect whether ANY level of the cwd→root walk carries a gtd
190327
- * config. Returns `true` on the first non-empty `search(dir)` result. Exported
190328
- * so `gtd init` (src/program.ts) can refuse to overwrite an existing config.
190331
+ * Detect whether a gtd config lives at THIS single directory — no `walkUp`, so
190332
+ * a global `~/.gtdrc` or an ancestor project's config does NOT count. Exported
190333
+ * so `gtd init` (src/program.ts) refuses only when it would overwrite the
190334
+ * repo's OWN config, not when a global default layer merely exists upstream.
190329
190335
  */
190330
- const anyConfigPresent = (root) => tryPromise({
190336
+ const configPresentAt = (dir) => tryPromise({
190331
190337
  try: async () => {
190332
- const home = homedir();
190333
- const chain = walkUp(root, home);
190334
- const explorer = (0, import_dist.cosmiconfig)("gtd", {
190335
- searchPlaces: SEARCH_PLACES,
190336
- searchStrategy: "none",
190337
- loaders: {
190338
- noExt: yamlLoader,
190339
- ".json": jsonLoader,
190340
- ".yaml": yamlLoader,
190341
- ".yml": yamlLoader
190342
- }
190343
- });
190344
- for (const dir of chain) {
190345
- const result = await explorer.search(dir);
190346
- if (result && !result.isEmpty) return true;
190347
- }
190348
- return false;
190338
+ const result = await makeExplorer().search(dir);
190339
+ return Boolean(result && !result.isEmpty);
190349
190340
  },
190350
190341
  catch: (e) => e instanceof Error ? e : new Error(String(e))
190351
190342
  });
@@ -204198,6 +204189,8 @@ Commands:
204198
204189
  mermaid Print the active workflow's shape as Mermaid
204199
204190
  stateDiagram-v2 source (no mutation)
204200
204191
  lsp Start the LSP server for .gtd/ steering files (stdio)
204192
+ version Print version and exit
204193
+ help Print this help and exit
204201
204194
 
204202
204195
  Options:
204203
204196
  --json Output structured JSON instead of plain text
@@ -204312,7 +204305,7 @@ const runInitCommand = (argv, json, write) => gen(function* () {
204312
204305
  const fs = yield* FileSystem;
204313
204306
  yield* assertRunningFromRepoRoot(git, fs);
204314
204307
  const { root } = yield* Cwd;
204315
- if (yield* anyConfigPresent(root)) return yield* fail$2(/* @__PURE__ */ new Error("gtd init: a gtd config already exists — remove it before re-initializing"));
204308
+ if (yield* configPresentAt(root)) return yield* fail$2(/* @__PURE__ */ new Error("gtd init: a gtd config already exists — remove it before re-initializing"));
204316
204309
  yield* fs.writeFileString(join(root, ".gtdrc.json"), renderInitConfig(name)).pipe(mapError$1((e) => e instanceof Error ? e : new Error(String(e))));
204317
204310
  if (json) write(JSON.stringify({
204318
204311
  written: ".gtdrc.json",
@@ -204664,17 +204657,19 @@ const KNOWN_SUBCOMMANDS = [
204664
204657
  "mermaid"
204665
204658
  ];
204666
204659
  /**
204667
- * `--version`/`-v` or `--help`/`-h`: short-circuits before any git or state
204668
- * work, so it works outside a repo too. Exported so main.ts can run the same
204669
- * check synchronously BEFORE the Effect runtime builds any layer — layer
204670
- * construction must never observe a version/help invocation.
204660
+ * `--version`/`-v`/`version` or `--help`/`-h`/`help`: short-circuits before any
204661
+ * git or state work, so it works outside a repo too. The bare `version`/`help`
204662
+ * subcommands are equivalent to their flag forms. Exported so main.ts can run
204663
+ * the same check synchronously BEFORE the Effect runtime builds any layer —
204664
+ * layer construction must never observe a version/help invocation.
204671
204665
  */
204672
204666
  const runVersionOrHelp = (argv, write) => {
204673
- if (argv.includes("--version") || argv.includes("-v")) {
204667
+ const positional = argv.slice(2).find((a) => !a.startsWith("--"));
204668
+ if (argv.includes("--version") || argv.includes("-v") || positional === "version") {
204674
204669
  write(GTD_VERSION + "\n");
204675
204670
  return true;
204676
204671
  }
204677
- if (argv.includes("--help") || argv.includes("-h")) {
204672
+ if (argv.includes("--help") || argv.includes("-h") || positional === "help") {
204678
204673
  write(HELP_TEXT);
204679
204674
  return true;
204680
204675
  }
package/docs/cli.md CHANGED
@@ -29,6 +29,8 @@ Commands:
29
29
  mermaid Print the active workflow's shape as Mermaid
30
30
  stateDiagram-v2 source (no mutation)
31
31
  lsp Start the LSP server for .gtd/ steering files (stdio)
32
+ version Print version and exit
33
+ help Print this help and exit
32
34
 
33
35
  Options:
34
36
  --json Output structured JSON instead of plain text
@@ -38,11 +40,12 @@ Options:
38
40
  --help, -h Print this help and exit
39
41
  ```
40
42
 
41
- `--version` (`-v`) and `--help` (`-h`) short-circuit before any git or
42
- repository-state work — they run outside a repo and in any repo state. Bare
43
- `gtd` (no subcommand) is a usage error: it prints the help text and exits 1
44
- without touching the repository. Every other command must be run from the
45
- **repository root** — gtd derives the workflow, pending changes, and process
43
+ `--version` (`-v`) / `gtd version` and `--help` (`-h`) / `gtd help`
44
+ short-circuit before any git or repository-state work — they run outside a repo
45
+ and in any repo state (the bare subcommands are exact equivalents of their flag
46
+ forms). Bare `gtd` (no subcommand) is a usage error: it prints the help text and
47
+ exits 1 without touching the repository. Every other command must be run from
48
+ the **repository root** — gtd derives the workflow, pending changes, and process
46
49
  history relative to cwd, so it refuses with a clear error if invoked from a
47
50
  subdirectory.
48
51
 
@@ -70,7 +73,8 @@ fails with `gtd: no workflow configured — run \`gtd init <simple|advanced>\`
70
73
 
71
74
  The file is written **uncommitted**; review and commit it before your first
72
75
  `gtd step` (an uncommitted `.gtdrc.json` is a pending change the initial state
73
- would otherwise capture). `gtd init` refuses if any gtd config already exists,
76
+ would otherwise capture). `gtd init` refuses if the repo root already has its
77
+ own gtd config (a global/ancestor config, e.g. `~/.gtdrc`, does not count),
74
78
  requires the repository root, and — with `gtd lsp` — is one of the two commands
75
79
  that run with no workflow configured. `--json` prints
76
80
  `{"written":".gtdrc.json","workflow":"<name>"}`. See
@@ -438,5 +442,6 @@ the plain-text one.
438
442
  - **Repository root invocation.** Every state subcommand (`step`/`review`/
439
443
  `next`/`status`/`mermaid`) must run from the git repository root — the
440
444
  workflow, pending changes, and process history are resolved against the
441
- process cwd. `--help`/`--version`, `format`, and `lsp` skip this guard
442
- entirely (and any git/`.gtdrc` dependency along with it).
445
+ process cwd. `--help`/`--version` (and the `help`/`version` subcommands),
446
+ `format`, and `lsp` skip this guard entirely (and any git/`.gtdrc` dependency
447
+ along with it).
@@ -668,10 +668,11 @@ chosen bundled template's whole workflow inline under a `workflow:` key, plus a
668
668
 
669
669
  The file is written **uncommitted** — review it, then commit it before your
670
670
  first `gtd step` (an uncommitted `.gtdrc.json` is a pending change the initial
671
- state's `* **` edge would otherwise capture). `gtd init` refuses if any gtd
672
- config already exists (remove it first to re-init), requires the repository
673
- root, and is one of the two commands (with `gtd lsp`) that run with no workflow
674
- configured. A state command run before `gtd init` fails with:
671
+ state's `* **` edge would otherwise capture). `gtd init` refuses if the repo
672
+ root already has its OWN gtd config (remove it first to re-init; a
673
+ global/ancestor config such as `~/.gtdrc` does not count), requires the
674
+ repository root, and is one of the two commands (with `gtd lsp`) that run with
675
+ no workflow configured. A state command run before `gtd init` fails with:
675
676
 
676
677
  ```
677
678
  gtd: no workflow configured — run `gtd init <simple|advanced>` to create .gtdrc.json
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pmelab/gtd",
3
- "version": "6.0.0",
3
+ "version": "6.1.1",
4
4
  "private": false,
5
5
  "description": "Git-aware CLI that emits the next prompt for an autonomous coding agent based on the current repository state",
6
6
  "bin": {