@halyard/cli 0.1.1 → 0.2.0

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.
Files changed (142) hide show
  1. package/README.md +115 -0
  2. package/dist/cli.js +30 -3
  3. package/dist/cli.js.map +1 -1
  4. package/dist/commands/api-keys.d.ts +3 -0
  5. package/dist/commands/api-keys.d.ts.map +1 -0
  6. package/dist/commands/api-keys.js +90 -0
  7. package/dist/commands/api-keys.js.map +1 -0
  8. package/dist/commands/hook.d.ts +6 -0
  9. package/dist/commands/hook.d.ts.map +1 -0
  10. package/dist/commands/hook.js +106 -0
  11. package/dist/commands/hook.js.map +1 -0
  12. package/dist/commands/login.d.ts +17 -0
  13. package/dist/commands/login.d.ts.map +1 -1
  14. package/dist/commands/login.js +170 -65
  15. package/dist/commands/login.js.map +1 -1
  16. package/dist/commands/orgs.d.ts +3 -0
  17. package/dist/commands/orgs.d.ts.map +1 -0
  18. package/dist/commands/orgs.js +102 -0
  19. package/dist/commands/orgs.js.map +1 -0
  20. package/dist/commands/push.d.ts.map +1 -1
  21. package/dist/commands/push.js +29 -6
  22. package/dist/commands/push.js.map +1 -1
  23. package/dist/commands/sessions.d.ts +3 -0
  24. package/dist/commands/sessions.d.ts.map +1 -0
  25. package/dist/commands/sessions.js +139 -0
  26. package/dist/commands/sessions.js.map +1 -0
  27. package/dist/commands/setup.d.ts +3 -0
  28. package/dist/commands/setup.d.ts.map +1 -0
  29. package/dist/commands/setup.js +58 -0
  30. package/dist/commands/setup.js.map +1 -0
  31. package/dist/commands/skills.d.ts +12 -0
  32. package/dist/commands/skills.d.ts.map +1 -0
  33. package/dist/commands/skills.js +171 -0
  34. package/dist/commands/skills.js.map +1 -0
  35. package/dist/commands/sync.d.ts.map +1 -1
  36. package/dist/commands/sync.js +51 -49
  37. package/dist/commands/sync.js.map +1 -1
  38. package/dist/commands/users.d.ts +13 -0
  39. package/dist/commands/users.d.ts.map +1 -0
  40. package/dist/commands/users.js +205 -0
  41. package/dist/commands/users.js.map +1 -0
  42. package/dist/commands/whoami.d.ts +21 -0
  43. package/dist/commands/whoami.d.ts.map +1 -0
  44. package/dist/commands/whoami.js +77 -0
  45. package/dist/commands/whoami.js.map +1 -0
  46. package/dist/lib/api-client.d.ts +64 -2
  47. package/dist/lib/api-client.d.ts.map +1 -1
  48. package/dist/lib/api-client.js +32 -7
  49. package/dist/lib/api-client.js.map +1 -1
  50. package/dist/lib/auth.d.ts +43 -6
  51. package/dist/lib/auth.d.ts.map +1 -1
  52. package/dist/lib/auth.js +106 -25
  53. package/dist/lib/auth.js.map +1 -1
  54. package/dist/lib/config-files.d.ts +6 -0
  55. package/dist/lib/config-files.d.ts.map +1 -0
  56. package/dist/lib/config-files.js +27 -0
  57. package/dist/lib/config-files.js.map +1 -0
  58. package/dist/lib/config.d.ts +13 -7
  59. package/dist/lib/config.d.ts.map +1 -1
  60. package/dist/lib/config.js +22 -8
  61. package/dist/lib/config.js.map +1 -1
  62. package/dist/lib/copilot-export.d.ts +31 -0
  63. package/dist/lib/copilot-export.d.ts.map +1 -0
  64. package/dist/lib/copilot-export.js +129 -0
  65. package/dist/lib/copilot-export.js.map +1 -0
  66. package/dist/lib/discovery.d.ts +60 -2
  67. package/dist/lib/discovery.d.ts.map +1 -1
  68. package/dist/lib/discovery.js +187 -15
  69. package/dist/lib/discovery.js.map +1 -1
  70. package/dist/lib/hook-discovery.d.ts +43 -0
  71. package/dist/lib/hook-discovery.d.ts.map +1 -0
  72. package/dist/lib/hook-discovery.js +90 -0
  73. package/dist/lib/hook-discovery.js.map +1 -0
  74. package/dist/lib/hook-input.d.ts +36 -0
  75. package/dist/lib/hook-input.d.ts.map +1 -0
  76. package/dist/lib/hook-input.js +161 -0
  77. package/dist/lib/hook-input.js.map +1 -0
  78. package/dist/lib/hook-runner.d.ts +48 -0
  79. package/dist/lib/hook-runner.d.ts.map +1 -0
  80. package/dist/lib/hook-runner.js +306 -0
  81. package/dist/lib/hook-runner.js.map +1 -0
  82. package/dist/lib/http.d.ts +18 -0
  83. package/dist/lib/http.d.ts.map +1 -0
  84. package/dist/lib/http.js +54 -0
  85. package/dist/lib/http.js.map +1 -0
  86. package/dist/lib/opencode-export.d.ts +22 -0
  87. package/dist/lib/opencode-export.d.ts.map +1 -0
  88. package/dist/lib/opencode-export.js +53 -0
  89. package/dist/lib/opencode-export.js.map +1 -0
  90. package/dist/lib/output.d.ts +27 -0
  91. package/dist/lib/output.d.ts.map +1 -0
  92. package/dist/lib/output.js +74 -0
  93. package/dist/lib/output.js.map +1 -0
  94. package/dist/lib/preflight.d.ts +35 -0
  95. package/dist/lib/preflight.d.ts.map +1 -0
  96. package/dist/lib/preflight.js +54 -0
  97. package/dist/lib/preflight.js.map +1 -0
  98. package/dist/lib/repo-binding.d.ts +43 -0
  99. package/dist/lib/repo-binding.d.ts.map +1 -0
  100. package/dist/lib/repo-binding.js +158 -0
  101. package/dist/lib/repo-binding.js.map +1 -0
  102. package/dist/lib/repo-identity.d.ts +29 -0
  103. package/dist/lib/repo-identity.d.ts.map +1 -0
  104. package/dist/lib/repo-identity.js +113 -0
  105. package/dist/lib/repo-identity.js.map +1 -0
  106. package/dist/lib/setup-hooks.d.ts +41 -0
  107. package/dist/lib/setup-hooks.d.ts.map +1 -0
  108. package/dist/lib/setup-hooks.js +276 -0
  109. package/dist/lib/setup-hooks.js.map +1 -0
  110. package/dist/lib/setup.d.ts +47 -0
  111. package/dist/lib/setup.d.ts.map +1 -0
  112. package/dist/lib/setup.js +179 -0
  113. package/dist/lib/setup.js.map +1 -0
  114. package/dist/lib/skill-batches.d.ts +16 -0
  115. package/dist/lib/skill-batches.d.ts.map +1 -0
  116. package/dist/lib/skill-batches.js +35 -0
  117. package/dist/lib/skill-batches.js.map +1 -0
  118. package/dist/lib/skill-files.d.ts +4 -0
  119. package/dist/lib/skill-files.d.ts.map +1 -0
  120. package/dist/lib/skill-files.js +36 -0
  121. package/dist/lib/skill-files.js.map +1 -0
  122. package/dist/lib/skill-fingerprint.d.ts +55 -0
  123. package/dist/lib/skill-fingerprint.d.ts.map +1 -0
  124. package/dist/lib/skill-fingerprint.js +204 -0
  125. package/dist/lib/skill-fingerprint.js.map +1 -0
  126. package/dist/lib/skills-discovery.d.ts +57 -0
  127. package/dist/lib/skills-discovery.d.ts.map +1 -0
  128. package/dist/lib/skills-discovery.js +157 -0
  129. package/dist/lib/skills-discovery.js.map +1 -0
  130. package/dist/lib/skills-sync.d.ts +66 -0
  131. package/dist/lib/skills-sync.d.ts.map +1 -0
  132. package/dist/lib/skills-sync.js +251 -0
  133. package/dist/lib/skills-sync.js.map +1 -0
  134. package/dist/lib/sync-runner.d.ts +56 -0
  135. package/dist/lib/sync-runner.d.ts.map +1 -0
  136. package/dist/lib/sync-runner.js +106 -0
  137. package/dist/lib/sync-runner.js.map +1 -0
  138. package/dist/lib/sync-state.d.ts +36 -6
  139. package/dist/lib/sync-state.d.ts.map +1 -1
  140. package/dist/lib/sync-state.js +41 -11
  141. package/dist/lib/sync-state.js.map +1 -1
  142. package/package.json +16 -8
package/README.md ADDED
@@ -0,0 +1,115 @@
1
+ # @halyard/cli
2
+
3
+ Command-line companion for [Halyard](https://usehalyard.ai) — scaffold Halyard into your repo for Claude Code, Cursor, and Codex, and sync your coding-agent sessions back to the platform.
4
+
5
+ `halyard sync` discovers sessions from **Claude Code** (`~/.claude/projects/`), **Codex CLI** (`~/.codex/sessions/`), **Gemini CLI** (`~/.gemini/tmp/*/chats/`), **OpenCode** (via `opencode export`), and **GitHub Copilot CLI** (`~/.copilot/session-store.db`, Node ≥ 22.13). Each session becomes searchable knowledge plus per-person work metrics — cost (USD), turns, duration, tokens, and tool activity.
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ npm install -g @halyard/cli
11
+ # or run without installing
12
+ bunx @halyard/cli <command>
13
+ pnpm dlx @halyard/cli <command>
14
+ ```
15
+
16
+ ## Commands
17
+
18
+ ```bash
19
+ halyard setup # Scaffold Halyard into the current repo (alias: init)
20
+ halyard login # Authenticate via your browser
21
+ halyard sync # Upload new session logs to Halyard
22
+ halyard push # Push a single session file
23
+ halyard whoami # Show the authenticated user, org, and repo binding
24
+ halyard skills # Discover local agent skills (SKILL.md folders) and sync them to Halyard
25
+ ```
26
+
27
+ Run `halyard --help` for the full list of flags.
28
+
29
+ ## Repo binding (`.halyard.json`)
30
+
31
+ A committed `.halyard.json` at the repo root binds the repo to one organization:
32
+
33
+ ```json
34
+ { "org": "halyard-studio" }
35
+ ```
36
+
37
+ Create it with `halyard setup --org <slug>` (add `--force` to rebind an already-bound
38
+ repo). The binding is discovered by walking up from the current directory; detached
39
+ git worktrees fall back to the main checkout's binding via `git rev-parse
40
+ --git-common-dir`.
41
+
42
+ In a bound repo:
43
+
44
+ - `halyard sync` uploads only sessions whose working directory resolves to the same
45
+ repository (matched by git common dir, then by normalized `remote.origin.url`).
46
+ Sessions whose repo can't be determined are skipped and counted; `halyard sync --all`
47
+ restores machine-wide sync.
48
+ - `halyard sync` and `halyard push` print `Syncing <scope> → <org>` before uploading
49
+ and hard-fail if your credentials belong to a different org than the binding —
50
+ re-run `halyard login` inside the repo to fix that.
51
+ - `halyard login` stores workspace-scoped credentials for the bound org (see below).
52
+
53
+ Without a binding, `sync` keeps the old machine-wide behavior and prints a notice.
54
+
55
+ ## Credentials
56
+
57
+ Resolution order for every command:
58
+
59
+ 1. `HALYARD_TOKEN` env var — an `sk_halyard_...` API key (or raw token) for
60
+ headless/CI use. API keys are bound to one org server-side; the CLI cannot
61
+ verify that org against a repo binding, so it warns instead of hard-failing.
62
+ 2. `~/.halyard/credentials/<orgId>.json` — per-org OAuth chains, matched against
63
+ the repo binding's org slug. Written by `halyard login` inside a bound repo.
64
+ 3. `~/.halyard/credentials.json` — the legacy/default chain, written by
65
+ `halyard login` outside a bound repo and used by `halyard orgs switch`.
66
+
67
+ Token refresh always writes back to the same file the credentials were read from.
68
+ Set `HALYARD_HOME` to relocate the state directory (defaults to `~/.halyard`).
69
+
70
+ ## Environment variables
71
+
72
+ | Variable | Purpose |
73
+ | ----------------- | ------------------------------------------------------------- |
74
+ | `HALYARD_TOKEN` | API key / token override for headless use (beats stored auth) |
75
+ | `HALYARD_API_URL` | Default for `--api-url` (the flag still wins) |
76
+ | `HALYARD_HOME` | State directory override (default `~/.halyard`) |
77
+
78
+ ## Upload every session automatically
79
+
80
+ ```bash
81
+ halyard setup --org <your-org-slug>
82
+ ```
83
+
84
+ `setup --org` binds the repo (see above) and writes a launcher, `.halyard/hook.sh`, plus session-start / session-end hook config for **Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot CLI, OpenCode and Grok Build**. Each hook runs `halyard hook`, which uploads the transcript that just finished at session end and sweeps this repo's earlier transcripts that never uploaded at session start. Commit the generated files and every clone gets the behaviour. Re-running `setup` is idempotent; `--no-hooks` skips this part.
85
+
86
+ `halyard hook` reads the client's hook payload from stdin, resolves credentials the same way `sync` and `push` do (`HALYARD_TOKEN` from the environment or the repo's `.env`, then the per-org login for the bound org, then the default login), skips instead of uploading when login credentials belong to another org than `.halyard.json`, never blocks the agent, and logs to `~/.halyard/hooks.log`. Claude and Codex sweeps use the same repo-scoped matching as `halyard sync`. Run `halyard hook --help` for the flags.
87
+
88
+ Upload happens at session **end**, not on every turn: the ingest endpoint keeps the first upload it sees for a session id. See [`docs/agent-session-upload.md`](https://github.com/halyard-labs/halyard/blob/main/docs/agent-session-upload.md) for the per-client details.
89
+
90
+ ## Sync your agent skills
91
+
92
+ ```bash
93
+ halyard skills list # every SKILL.md folder on this machine, with its fingerprint
94
+ halyard skills sync # upload new or changed skills to the bound org
95
+ halyard skills sync --scope project --dry-run
96
+ ```
97
+
98
+ `skills sync` scans the directories every harness reads — user-level (`~/.claude/skills`, `~/.agents/skills`, `~/.codex/skills`, `~/.cursor/skills`, `~/.gemini/skills`, `~/.copilot/skills`, OpenCode, Amp, Windsurf, Grok, Kiro, Cline, Factory) and repo-level (`.claude/skills`, `.agents/skills`, `.github/skills`, …) — de-duplicates symlink aliases by real path, fingerprints each folder (sha256 over every file, not just `SKILL.md`), and uploads what changed. Each skill becomes a `PROCESS` knowledge entry, searchable by every agent connected to the org. Re-runs are free: unchanged skills are skipped from the local ledger, and the server compares the fingerprint again for anything the ledger missed. The session-start hook syncs the repo's committed skills automatically (`HALYARD_SKILLS_SYNC=0` turns that off); personal skills only go up when you run the command. See [`docs/agent-skills-sync.md`](https://github.com/halyard-labs/halyard/blob/main/docs/agent-skills-sync.md).
99
+
100
+ ### Headless and cloud environments
101
+
102
+ Set `HALYARD_TOKEN` to an API key in the environment (one key per environment; keys are bound to one organization):
103
+
104
+ ```bash
105
+ halyard api-keys create --name "my-repo-ci" # prints sk_halyard_… once
106
+ export HALYARD_TOKEN=sk_halyard_…
107
+ halyard sync --provider claude # or push <file>
108
+ ```
109
+
110
+ Where to set it: Claude Code on the web → environment variables; Codex Cloud → environment variables (not secrets, which are removed before the agent phase); Cursor cloud agents → dashboard Secrets; GitHub Copilot coding agent → Agents secrets; GitHub Actions → `secrets.HALYARD_TOKEN` and a final `if: always()` step running `halyard sync`.
111
+
112
+ ## Learn more
113
+
114
+ - Product: [usehalyard.ai](https://usehalyard.ai)
115
+ - Docs & sign-in: [app.usehalyard.ai](https://app.usehalyard.ai)
package/dist/cli.js CHANGED
@@ -1,17 +1,44 @@
1
1
  #!/usr/bin/env node
2
+ import { readFileSync } from 'node:fs';
2
3
  import { Command } from 'commander';
3
4
  import { DEFAULT_API_URL } from './lib/config.js';
4
5
  import { loginCommand } from './commands/login.js';
5
6
  import { syncCommand } from './commands/sync.js';
6
7
  import { pushCommand } from './commands/push.js';
8
+ import { setupCommand } from './commands/setup.js';
9
+ import { whoamiCommand } from './commands/whoami.js';
10
+ import { apiKeysCommand } from './commands/api-keys.js';
11
+ import { usersCommand } from './commands/users.js';
12
+ import { orgsCommand } from './commands/orgs.js';
13
+ import { sessionsCommand } from './commands/sessions.js';
14
+ import { hookCommand } from './commands/hook.js';
15
+ import { skillsCommand } from './commands/skills.js';
16
+ function resolveVersion() {
17
+ try {
18
+ const packageJson = JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf-8'));
19
+ return packageJson.version;
20
+ }
21
+ catch {
22
+ return typeof __HALYARD_CLI_VERSION__ === 'string' ? __HALYARD_CLI_VERSION__ : '0.0.0-dev';
23
+ }
24
+ }
7
25
  const program = new Command();
8
26
  program
9
27
  .name('halyard')
10
- .description('Sync coding session logs to Halyard')
11
- .version('0.1.0')
12
- .option('--api-url <url>', 'Halyard API URL', DEFAULT_API_URL);
28
+ .description('Set up Halyard in your repo and sync coding session logs and agent skills')
29
+ .version(resolveVersion())
30
+ .option('--api-url <url>', 'Halyard API URL (env: HALYARD_API_URL)', process.env['HALYARD_API_URL'] ?? DEFAULT_API_URL)
31
+ .option('--json', 'Output raw JSON');
32
+ program.addCommand(setupCommand());
13
33
  program.addCommand(loginCommand());
14
34
  program.addCommand(syncCommand());
15
35
  program.addCommand(pushCommand());
36
+ program.addCommand(whoamiCommand());
37
+ program.addCommand(apiKeysCommand());
38
+ program.addCommand(usersCommand());
39
+ program.addCommand(orgsCommand());
40
+ program.addCommand(sessionsCommand());
41
+ program.addCommand(hookCommand());
42
+ program.addCommand(skillsCommand());
16
43
  program.parse();
17
44
  //# sourceMappingURL=cli.js.map
package/dist/cli.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAEhD,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAA;AAE7B,OAAO;KACJ,IAAI,CAAC,SAAS,CAAC;KACf,WAAW,CA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eysCommand(): Command;
3
+ //# sourceMappingURL=api-keys.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api-keys.d.ts","sourceRoot":"","sources":["../../src/commands/api-keys.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAsBnC,wBAAgB,cAAc,IAAI,OAAO,CAkGxC"}
@@ -0,0 +1,90 @@
1
+ import { Command } from 'commander';
2
+ import { apiFetch, ApiError } from '../lib/http.js';
3
+ import { printTable, printJson, formatDate, confirm, fail } from '../lib/output.js';
4
+ export function apiKeysCommand() {
5
+ const apiKeys = new Command('api-keys').description('Manage API keys (requires `halyard login`; keys belong to the current organization)');
6
+ apiKeys
7
+ .command('create')
8
+ .description('Create a new API key. The secret is shown once and cannot be retrieved again.')
9
+ .requiredOption('--name <name>', 'Display name for the key')
10
+ .action(async function () {
11
+ const globalOpts = this.optsWithGlobals();
12
+ const apiUrl = globalOpts.apiUrl;
13
+ const name = this.opts().name;
14
+ let key;
15
+ try {
16
+ key = await apiFetch(apiUrl, '/api/v1/api-keys', {
17
+ method: 'POST',
18
+ body: { name },
19
+ });
20
+ }
21
+ catch (err) {
22
+ fail(err instanceof Error ? err.message : String(err));
23
+ }
24
+ if (globalOpts.json) {
25
+ printJson(key);
26
+ return;
27
+ }
28
+ console.log(`Created API key "${key.name}" (${key.id})`);
29
+ console.log('');
30
+ console.log(` ${key.secret}`);
31
+ console.log('');
32
+ console.log('Store this secret now - it will not be shown again.');
33
+ console.log('Use it via the HALYARD_TOKEN environment variable.');
34
+ });
35
+ apiKeys
36
+ .command('list')
37
+ .description('List your active API keys')
38
+ .action(async function () {
39
+ const globalOpts = this.optsWithGlobals();
40
+ const apiUrl = globalOpts.apiUrl;
41
+ let response;
42
+ try {
43
+ response = await apiFetch(apiUrl, '/api/v1/api-keys');
44
+ }
45
+ catch (err) {
46
+ fail(err instanceof Error ? err.message : String(err));
47
+ }
48
+ if (globalOpts.json) {
49
+ printJson(response);
50
+ return;
51
+ }
52
+ if (response.keys.length === 0) {
53
+ console.log('No API keys. Create one with `halyard api-keys create --name <name>`.');
54
+ return;
55
+ }
56
+ printTable(response.keys, [
57
+ { key: 'id', header: 'ID' },
58
+ { key: 'name', header: 'NAME' },
59
+ { key: 'prefix', header: 'PREFIX', format: (v) => `${String(v)}...` },
60
+ { key: 'lastUsedAt', header: 'LAST USED', format: formatDate },
61
+ { key: 'createdAt', header: 'CREATED', format: formatDate },
62
+ ]);
63
+ });
64
+ apiKeys
65
+ .command('revoke')
66
+ .description('Revoke an API key (immediate; the key stops authenticating on its next use)')
67
+ .argument('<id>', 'API key ID (from `halyard api-keys list`)')
68
+ .option('-f, --force', 'Skip the confirmation prompt')
69
+ .action(async function (id) {
70
+ const globalOpts = this.optsWithGlobals();
71
+ const apiUrl = globalOpts.apiUrl;
72
+ const force = !!this.opts().force;
73
+ const confirmed = await confirm(`Revoke API key ${id}? This cannot be undone.`, { force });
74
+ if (!confirmed) {
75
+ fail('Aborted.');
76
+ }
77
+ try {
78
+ await apiFetch(apiUrl, `/api/v1/api-keys/${id}`, { method: 'DELETE' });
79
+ }
80
+ catch (err) {
81
+ if (err instanceof ApiError && err.status === 404) {
82
+ fail('API key not found (or not yours).');
83
+ }
84
+ fail(err instanceof Error ? err.message : String(err));
85
+ }
86
+ console.log('Key revoked.');
87
+ });
88
+ return apiKeys;
89
+ }
90
+ //# sourceMappingURL=api-keys.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api-keys.js","sourceRoot":"","sources":["../../src/commands/api-keys.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AACnD,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,UAAU,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAA;AAoBnF,MAAM,UAAU,cAAc;IAC5B,MAAM,O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ached child through this
3
+ * variable, because the child has no stdin. */
4
+ export declare const HOOK_INPUT_ENV = "HALYARD_HOOK_INPUT";
5
+ export declare function hookCommand(): Command;
6
+ //# sourceMappingURL=hook.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hook.d.ts","sourceRoot":"","sources":["../../src/commands/hook.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAYnC;gDACgD;AAChD,eAAO,MAAM,cAAc,uBAAuB,CAAA;AAoFlD,wBAAgB,WAAW,IAAI,OAAO,CA0BrC"}
@@ -0,0 +1,106 @@
1
+ import { spawn } from 'node:child_process';
2
+ import { homedir } from 'node:os';
3
+ import { join } from 'node:path';
4
+ import { Command } from 'commander';
5
+ import { halyardDir } from '../lib/config.js';
6
+ import { HOOK_CLIENTS, isHookClient, normalizeEvent, parseHookInput, } from '../lib/hook-input.js';
7
+ import { HookLogger, runHook } from '../lib/hook-runner.js';
8
+ /** The parent passes the hook payload to its detached child through this
9
+ * variable, because the child has no stdin. */
10
+ export const HOOK_INPUT_ENV = 'HALYARD_HOOK_INPUT';
11
+ const STDIN_TIMEOUT_MS = 2000;
12
+ function readStdin(timeoutMs) {
13
+ return new Promise((resolve) => {
14
+ let data = '';
15
+ const finish = () => {
16
+ clearTimeout(timer);
17
+ process.stdin.pause();
18
+ resolve(data);
19
+ };
20
+ const timer = setTimeout(finish, timeoutMs);
21
+ process.stdin.setEncoding('utf8');
22
+ process.stdin.on('data', (chunk) => {
23
+ data += chunk;
24
+ });
25
+ process.stdin.on('end', finish);
26
+ process.stdin.on('error', finish);
27
+ });
28
+ }
29
+ function parseEvent(value) {
30
+ if (value === 'start' || value === 'end' || value === 'sweep')
31
+ return value;
32
+ return value ? normalizeEvent(value) : null;
33
+ }
34
+ function childArgs(opts, apiUrl, event) {
35
+ const args = [process.argv[1] ?? '', '--api-url', apiUrl, 'hook', '--event', event];
36
+ if (opts.client)
37
+ args.push('--client', opts.client);
38
+ if (opts.root)
39
+ args.push('--root', opts.root);
40
+ if (opts.transcript)
41
+ args.push('--transcript', opts.transcript);
42
+ if (opts.dryRun)
43
+ args.push('--dry-run');
44
+ return args;
45
+ }
46
+ /** Run the upload in a background process so the host's hook budget is never
47
+ * hit (Codex caps SessionEnd at 3s) and session start is never delayed. */
48
+ function detach(args, input) {
49
+ const child = spawn(process.execPath, args, {
50
+ detached: true,
51
+ stdio: 'ignore',
52
+ env: { ...process.env, [HOOK_INPUT_ENV]: input },
53
+ });
54
+ child.unref();
55
+ }
56
+ async function execute(opts, apiUrl) {
57
+ if (process.env['HALYARD_SESSION_UPLOAD'] === '0')
58
+ return;
59
+ const input = process.env[HOOK_INPUT_ENV] ?? (process.stdin.isTTY ? '' : await readStdin(STDIN_TIMEOUT_MS));
60
+ const event = parseEvent(opts.event) ?? normalizeEvent(parseHookInput(input).event);
61
+ if (!event)
62
+ return;
63
+ const client = opts.client && isHookClient(opts.client) ? opts.client : undefined;
64
+ if (event === 'start' || (event === 'end' && opts.detach)) {
65
+ detach(childArgs(opts, apiUrl, event === 'start' ? 'sweep' : 'end'), input);
66
+ return;
67
+ }
68
+ await runHook({
69
+ input,
70
+ client,
71
+ event,
72
+ root: opts.root,
73
+ transcript: opts.transcript,
74
+ dryRun: !!opts.dryRun,
75
+ apiUrl,
76
+ halyardDir: halyardDir(),
77
+ homeDir: homedir(),
78
+ env: process.env,
79
+ cwd: process.cwd(),
80
+ });
81
+ }
82
+ export function hookCommand() {
83
+ return new Command('hook')
84
+ .description('Agent lifecycle hook: upload the session that just ended, or sweep unsynced ones (wired by `halyard setup`)')
85
+ .option('--client <name>', `Client (${HOOK_CLIENTS.join(', ')}); auto-detected when omitted`)
86
+ .option('--event <event>', 'start | end | sweep (defaults to the event in the hook payload)')
87
+ .option('--root <dir>', "Repository root (defaults to the client's project dir or cwd)")
88
+ .option('--transcript <path>', 'Transcript to upload (defaults to the hook payload)')
89
+ .option('--detach', 'Upload in a background process and return immediately')
90
+ .option('--dry-run', 'Log what would be uploaded without uploading')
91
+ .action(async function () {
92
+ const opts = this.opts();
93
+ const apiUrl = this.optsWithGlobals().apiUrl;
94
+ try {
95
+ await execute(opts, apiUrl);
96
+ }
97
+ catch (err) {
98
+ new HookLogger(join(halyardDir(), 'hooks.log'), `${opts.client ?? '?'}/${opts.event ?? '?'}`).log(`error: ${err instanceof Error ? err.message : String(err)}`);
99
+ }
100
+ // Gemini CLI blocks unless a hook prints JSON on stdout.
101
+ if (opts.client === 'gemini' || process.env['GEMINI_PROJECT_DIR'])
102
+ console.log('{}');
103
+ process.exitCode = 0;
104
+ });
105
+ }
106
+ //# sourceMappingURL=hook.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hook.js","sourceRoot":"","sources":["../../src/commands/hook.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAC1C,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAChC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAC7C,OAAO,EACL,YAAY,EACZ,YAAY,EACZ,cAAc,EACd,cAAc,GAGf,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAA;AAE3D;gDACgD;AAChD,MAAM,CAAC,MAAM,cAAc,GAAG,oBAAoB,CAAA;AAClD,MAAM,gBAAgB,GAAG,IAAI,CAAA;AAW7B,SAAS,SAAS,CAAC,SAAiB;IAClC,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QAC7B,IAAI,IAAI,GAAG,EAAE,CAAA;QACb,MAAM,MAAM,GAAG,GAAG,EAAE;YAClB,YAAY,CAAC,KAAK,CAAC,CAAA;YACnB,OAAO,CAAC,KAAK,CAAC,KAAK,EAAE,C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EAC/B,GAAG,IAAI,CAAC,MAAM,IAAI,GAAG,IAAI,IAAI,CAAC,KAAK,IAAI,GAAG,EAAE,CAC7C,CAAC,GAAG,CAAC,UAAU,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAA;QACrE,CAAC;QACD,yDAAyD;QACzD,IAAI,IAAI,CAAC,MAAM,KAAK,QAAQ,IAAI,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC;YAAE,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;QACpF,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAA;IACtB,CAAC,CAAC,CAAA;AACN,CAAC"}
@@ -1,3 +1,20 @@
1
1
  import { Command } from 'commander';
2
+ import { refreshToken, type Credentials } from '../lib/auth.js';
3
+ import { type RepoBinding } from '../lib/repo-binding.js';
2
4
  export declare function loginCommand(): Command;
5
+ export interface PersistLoginOptions {
6
+ creds: Credentials;
7
+ binding: RepoBinding | null;
8
+ /** Injectable for tests */
9
+ fetchImpl?: typeof fetch;
10
+ refreshImpl?: typeof refreshToken;
11
+ }
12
+ /**
13
+ * Persist freshly exchanged tokens. In an unbound repo this is the legacy
14
+ * behavior (write ~/.halyard/credentials.json). In a bound repo, resolve the
15
+ * binding's org slug against /api/v1/organizations, reissue workspace-scoped
16
+ * tokens when needed, and save to the per-org store.
17
+ * Returns the success message to print; throws on failure.
18
+ */
19
+ export declare function persistLogin(options: PersistLoginOptions): Promise<string>;
3
20
  //# sourceMappingURL=login.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"login.d.ts","sourceRoot":"","sources":["../../src/commands/login.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAkBnC,wBAAgB,YAAY,IAAI,OAAO,CAmKtC"}
1
+ {"version":3,"file":"login.d.ts","sourceRoot":"","sources":["../../src/commands/login.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAEnC,OAAO,EAEL,YAAY,EAGZ,KAAK,WAAW,EACjB,MAAM,gBAAgB,CAAA;AACvB,OAAO,EAAmB,KAAK,WAAW,EAAE,MAAM,wBAAwB,CAAA;AA8D1E,wBAAgB,YAAY,IAAI,OAAO,CA6KtC;AASD,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,WAAW,CAAA;IAClB,OAAO,EAAE,WAAW,GAAG,IAAI,CAAA;IAC3B,2BAA2B;IAC3B,SAAS,CAAC,EAAE,OAAO,KAAK,CAAA;IACxB,WAAW,CAAC,EAAE,OAAO,YAAY,CAAA;CAClC;AAED;;;;;;GAMG;AACH,wBAAsB,YAAY,CAAC,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,MAAM,CAAC,CAsChF"}