@indigoai-us/hq-cli 5.3.1 → 5.4.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 (141) hide show
  1. package/dist/bin/hq-auth-refresh.d.ts +13 -0
  2. package/dist/bin/hq-auth-refresh.d.ts.map +1 -0
  3. package/dist/bin/hq-auth-refresh.js +27 -0
  4. package/dist/bin/hq-auth-refresh.js.map +1 -0
  5. package/dist/commands/auth.d.ts +17 -13
  6. package/dist/commands/auth.d.ts.map +1 -1
  7. package/dist/commands/auth.js +83 -238
  8. package/dist/commands/auth.js.map +1 -1
  9. package/dist/commands/cloud.d.ts +3 -12
  10. package/dist/commands/cloud.d.ts.map +1 -1
  11. package/dist/commands/cloud.js +55 -212
  12. package/dist/commands/cloud.js.map +1 -1
  13. package/dist/commands/login.d.ts +6 -0
  14. package/dist/commands/login.d.ts.map +1 -0
  15. package/dist/commands/login.js +25 -0
  16. package/dist/commands/login.js.map +1 -0
  17. package/dist/commands/logout.d.ts +6 -0
  18. package/dist/commands/logout.d.ts.map +1 -0
  19. package/dist/commands/logout.js +21 -0
  20. package/dist/commands/logout.js.map +1 -0
  21. package/dist/commands/onboard.d.ts +23 -0
  22. package/dist/commands/onboard.d.ts.map +1 -0
  23. package/dist/commands/onboard.js +142 -0
  24. package/dist/commands/onboard.js.map +1 -0
  25. package/dist/commands/pkg-install.d.ts +17 -0
  26. package/dist/commands/pkg-install.d.ts.map +1 -0
  27. package/dist/commands/pkg-install.js +144 -0
  28. package/dist/commands/pkg-install.js.map +1 -0
  29. package/dist/commands/pkg-list.d.ts +8 -0
  30. package/dist/commands/pkg-list.d.ts.map +1 -0
  31. package/dist/commands/pkg-list.js +70 -0
  32. package/dist/commands/pkg-list.js.map +1 -0
  33. package/dist/commands/pkg-remove.d.ts +10 -0
  34. package/dist/commands/pkg-remove.d.ts.map +1 -0
  35. package/dist/commands/pkg-remove.js +53 -0
  36. package/dist/commands/pkg-remove.js.map +1 -0
  37. package/dist/commands/pkg-update.d.ts +9 -0
  38. package/dist/commands/pkg-update.d.ts.map +1 -0
  39. package/dist/commands/pkg-update.js +124 -0
  40. package/dist/commands/pkg-update.js.map +1 -0
  41. package/dist/commands/team-sync.d.ts +14 -0
  42. package/dist/commands/team-sync.d.ts.map +1 -0
  43. package/dist/commands/team-sync.js +422 -0
  44. package/dist/commands/team-sync.js.map +1 -0
  45. package/dist/commands/whoami.d.ts +6 -0
  46. package/dist/commands/whoami.d.ts.map +1 -0
  47. package/dist/commands/whoami.js +29 -0
  48. package/dist/commands/whoami.js.map +1 -0
  49. package/dist/index.d.ts +1 -1
  50. package/dist/index.js +33 -13
  51. package/dist/index.js.map +1 -1
  52. package/dist/strategies/merge.js +2 -2
  53. package/dist/strategies/merge.js.map +1 -1
  54. package/dist/utils/auth.d.ts +27 -0
  55. package/dist/utils/auth.d.ts.map +1 -0
  56. package/dist/utils/auth.js +155 -0
  57. package/dist/utils/auth.js.map +1 -0
  58. package/dist/utils/cognito-session.d.ts +35 -0
  59. package/dist/utils/cognito-session.d.ts.map +1 -0
  60. package/dist/utils/cognito-session.js +72 -0
  61. package/dist/utils/cognito-session.js.map +1 -0
  62. package/dist/utils/git.js +1 -1
  63. package/dist/utils/git.js.map +1 -1
  64. package/dist/utils/hq-root.d.ts +10 -0
  65. package/dist/utils/hq-root.d.ts.map +1 -0
  66. package/dist/utils/hq-root.js +22 -0
  67. package/dist/utils/hq-root.js.map +1 -0
  68. package/dist/utils/integrity.d.ts +14 -0
  69. package/dist/utils/integrity.d.ts.map +1 -0
  70. package/dist/utils/integrity.js +40 -0
  71. package/dist/utils/integrity.js.map +1 -0
  72. package/dist/utils/manifest.d.ts.map +1 -1
  73. package/dist/utils/manifest.js +2 -5
  74. package/dist/utils/manifest.js.map +1 -1
  75. package/dist/utils/registry-client.d.ts +65 -0
  76. package/dist/utils/registry-client.d.ts.map +1 -0
  77. package/dist/utils/registry-client.js +102 -0
  78. package/dist/utils/registry-client.js.map +1 -0
  79. package/dist/utils/registry.d.ts +33 -0
  80. package/dist/utils/registry.d.ts.map +1 -0
  81. package/dist/utils/registry.js +58 -0
  82. package/dist/utils/registry.js.map +1 -0
  83. package/dist/utils/token-store.d.ts +28 -0
  84. package/dist/utils/token-store.d.ts.map +1 -0
  85. package/dist/utils/token-store.js +68 -0
  86. package/dist/utils/token-store.js.map +1 -0
  87. package/package.json +35 -45
  88. package/src/bin/hq-auth-refresh.ts +32 -0
  89. package/src/commands/add.ts +74 -0
  90. package/src/commands/auth.ts +153 -0
  91. package/src/commands/cloud.ts +125 -0
  92. package/src/commands/list.ts +66 -0
  93. package/src/commands/login.ts +29 -0
  94. package/src/commands/logout.ts +25 -0
  95. package/src/commands/pkg-install.ts +181 -0
  96. package/src/commands/pkg-list.ts +98 -0
  97. package/src/commands/pkg-remove.ts +71 -0
  98. package/src/commands/pkg-update.ts +189 -0
  99. package/src/commands/sync.ts +149 -0
  100. package/src/commands/team-sync.ts +629 -0
  101. package/src/commands/update.ts +71 -0
  102. package/src/commands/whoami.ts +38 -0
  103. package/src/index.ts +72 -0
  104. package/src/schemas/hq-package.schema.json +137 -0
  105. package/src/strategies/link.ts +62 -0
  106. package/src/strategies/merge.ts +142 -0
  107. package/src/types.ts +47 -0
  108. package/src/utils/auth.ts +193 -0
  109. package/src/utils/cognito-session.ts +94 -0
  110. package/src/utils/git.ts +74 -0
  111. package/src/utils/hq-root.ts +27 -0
  112. package/src/utils/integrity.ts +54 -0
  113. package/src/utils/manifest.ts +109 -0
  114. package/src/utils/registry-client.ts +204 -0
  115. package/src/utils/registry.ts +89 -0
  116. package/src/utils/token-store.ts +83 -0
  117. package/tsconfig.json +8 -0
  118. package/dist/commands/cloud-setup.d.ts +0 -19
  119. package/dist/commands/cloud-setup.d.ts.map +0 -1
  120. package/dist/commands/cloud-setup.js +0 -206
  121. package/dist/commands/cloud-setup.js.map +0 -1
  122. package/dist/commands/initial-upload.d.ts +0 -67
  123. package/dist/commands/initial-upload.d.ts.map +0 -1
  124. package/dist/commands/initial-upload.js +0 -205
  125. package/dist/commands/initial-upload.js.map +0 -1
  126. package/dist/sync-worker.d.ts +0 -11
  127. package/dist/sync-worker.d.ts.map +0 -1
  128. package/dist/sync-worker.js +0 -77
  129. package/dist/sync-worker.js.map +0 -1
  130. package/dist/utils/api-client.d.ts +0 -26
  131. package/dist/utils/api-client.d.ts.map +0 -1
  132. package/dist/utils/api-client.js +0 -87
  133. package/dist/utils/api-client.js.map +0 -1
  134. package/dist/utils/credentials.d.ts +0 -44
  135. package/dist/utils/credentials.d.ts.map +0 -1
  136. package/dist/utils/credentials.js +0 -101
  137. package/dist/utils/credentials.js.map +0 -1
  138. package/dist/utils/sync.d.ts +0 -125
  139. package/dist/utils/sync.d.ts.map +0 -1
  140. package/dist/utils/sync.js +0 -291
  141. package/dist/utils/sync.js.map +0 -1
@@ -1,77 +0,0 @@
1
- /**
2
- * Background sync worker for "hq sync start".
3
- *
4
- * Forked as a detached child process. Polls for changes at a configurable
5
- * interval and runs a full bidirectional sync each cycle.
6
- *
7
- * Usage (internal — called by cloud.ts):
8
- * node sync-worker.js <hqRoot> <intervalMs>
9
- */
10
- import { fullSync, readSyncState, writeSyncState, computeLocalManifest } from './utils/sync.js';
11
- const hqRoot = process.argv[2];
12
- const intervalMs = parseInt(process.argv[3] ?? '30000', 10);
13
- if (!hqRoot) {
14
- process.exit(1);
15
- }
16
- /** Run one sync cycle. */
17
- async function syncCycle() {
18
- try {
19
- const result = await fullSync(hqRoot);
20
- // Update state
21
- const manifest = computeLocalManifest(hqRoot);
22
- const state = readSyncState(hqRoot);
23
- state.running = true;
24
- state.pid = process.pid;
25
- state.lastSync = new Date().toISOString();
26
- state.fileCount = manifest.length;
27
- state.errors = result.errors;
28
- writeSyncState(hqRoot, state);
29
- }
30
- catch {
31
- // Log errors to state, but keep running
32
- try {
33
- const state = readSyncState(hqRoot);
34
- state.errors = ['Sync cycle failed — will retry next interval'];
35
- writeSyncState(hqRoot, state);
36
- }
37
- catch {
38
- // Can't even write state — just continue
39
- }
40
- }
41
- }
42
- /** Main loop. */
43
- async function run() {
44
- // Handle graceful shutdown
45
- process.on('SIGTERM', () => {
46
- try {
47
- const state = readSyncState(hqRoot);
48
- state.running = false;
49
- state.pid = undefined;
50
- writeSyncState(hqRoot, state);
51
- }
52
- catch {
53
- // Best-effort cleanup
54
- }
55
- process.exit(0);
56
- });
57
- process.on('SIGINT', () => {
58
- try {
59
- const state = readSyncState(hqRoot);
60
- state.running = false;
61
- state.pid = undefined;
62
- writeSyncState(hqRoot, state);
63
- }
64
- catch {
65
- // Best-effort cleanup
66
- }
67
- process.exit(0);
68
- });
69
- // Run first sync immediately
70
- await syncCycle();
71
- // Then poll at the configured interval
72
- setInterval(() => {
73
- void syncCycle();
74
- }, intervalMs);
75
- }
76
- void run();
77
- //# sourceMappingURL=sync-worker.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"sync-worker.js","sourceRoot":"","sources":["../src/sync-worker.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAEhG,MAAM,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAC/B,MAAM,UAAU,GAAG,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,OAAO,EAAE,EAAE,CAAC,CAAC;AAE5D,IAAI,CAAC,MAAM,EAAE,CAAC;IACZ,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC;AAED,0BAA0B;AAC1B,KAAK,UAAU,SAAS;IACtB,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,MAAM,CAAC,CAAC;QAEtC,eAAe;QACf,MAAM,QAAQ,GAAG,oBAAoB,CAAC,MAAM,CAAC,CAAC;QAC9C,MAAM,KAAK,GAAG,aAAa,CAAC,MA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AG,KAAK,CAAC;YACtB,KAAK,CAAC,GAAG,GAAG,SAAS,CAAC;YACtB,cAAc,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;QAChC,CAAC;QAAC,MAAM,CAAC;YACP,sBAAsB;QACxB,CAAC;QACD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC,CAAC,CAAC;IAEH,6BAA6B;IAC7B,MAAM,SAAS,EAAE,CAAC;IAElB,uCAAuC;IACvC,WAAW,CAAC,GAAG,EAAE;QACf,KAAK,SAAS,EAAE,CAAC;IACnB,CAAC,EAAE,UAAU,CAAC,CAAC;AACjB,CAAC;AAED,KAAK,GAAG,EAAE,CAAC"}
@@ -1,26 +0,0 @@
1
- /**
2
- * API client for hq-cloud.
3
- * Reads stored credentials and attaches Authorization header to all requests.
4
- *
5
- * Base URL resolution order:
6
- * 1. HQ_CLOUD_API_URL environment variable
7
- * 2. ~/.hq/config.json "apiUrl" field
8
- * 3. Default production URL
9
- */
10
- /**
11
- * Resolve the hq-cloud API base URL.
12
- */
13
- export declare function getApiUrl(): string;
14
- /** Standard response shape from the API */
15
- export interface ApiResponse<T = unknown> {
16
- ok: boolean;
17
- status: number;
18
- data?: T;
19
- error?: string;
20
- }
21
- /**
22
- * Make an authenticated request to the hq-cloud API.
23
- * Throws if not logged in. Returns parsed JSON response.
24
- */
25
- export declare function apiRequest<T = unknown>(method: string, urlPath: string, body?: unknown): Promise<ApiResponse<T>>;
26
- //# sourceMappingURL=api-client.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"api-client.d.ts","sourceRoot":"","sources":["../../src/utils/api-client.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAaH;;GAEG;AACH,wBAAgB,SAAS,IAAI,MAAM,CAqBlC;AAED,2CAA2C;AAC3C,MAAM,WAAW,WAAW,CAAC,CAAC,GAAG,OAAO;IACtC,EAAE,EAAE,OAAO,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,CAAC,CAAC;IACT,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;GAGG;AACH,wBAAsB,UAAU,CAAC,CAAC,GAAG,OAAO,EAC1C,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,EACf,IAAI,CAAC,EAAE,OAAO,GACb,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CA+CzB"}
@@ -1,87 +0,0 @@
1
- /**
2
- * API client for hq-cloud.
3
- * Reads stored credentials and attaches Authorization header to all requests.
4
- *
5
- * Base URL resolution order:
6
- * 1. HQ_CLOUD_API_URL environment variable
7
- * 2. ~/.hq/config.json "apiUrl" field
8
- * 3. Default production URL
9
- */
10
- import * as fs from 'fs';
11
- import * as path from 'path';
12
- import * as os from 'os';
13
- import { readCredentials } from './credentials.js';
14
- /** Default API base URL (production) */
15
- const DEFAULT_API_URL = 'https://api.hq.getindigo.ai';
16
- /** Path to optional config file */
17
- const CONFIG_PATH = path.join(os.homedir(), '.hq', 'config.json');
18
- /**
19
- * Resolve the hq-cloud API base URL.
20
- */
21
- export function getApiUrl() {
22
- // 1. Environment variable takes precedence
23
- if (process.env['HQ_CLOUD_API_URL']) {
24
- return process.env['HQ_CLOUD_API_URL'].replace(/\/+$/, '');
25
- }
26
- // 2. Config file
27
- try {
28
- if (fs.existsSync(CONFIG_PATH)) {
29
- const raw = fs.readFileSync(CONFIG_PATH, 'utf-8');
30
- const config = JSON.parse(raw);
31
- if (config.apiUrl) {
32
- return config.apiUrl.replace(/\/+$/, '');
33
- }
34
- }
35
- }
36
- catch {
37
- // Ignore config read errors
38
- }
39
- // 3. Default
40
- return DEFAULT_API_URL;
41
- }
42
- /**
43
- * Make an authenticated request to the hq-cloud API.
44
- * Throws if not logged in. Returns parsed JSON response.
45
- */
46
- export async function apiRequest(method, urlPath, body) {
47
- const creds = readCredentials();
48
- if (!creds) {
49
- throw new Error('Not logged in. Run "hq auth login" first.');
50
- }
51
- const baseUrl = getApiUrl();
52
- const url = `${baseUrl}${urlPath.startsWith('/') ? urlPath : '/' + urlPath}`;
53
- const headers = {
54
- 'Authorization': `Bearer ${creds.token}`,
55
- 'Content-Type': 'application/json',
56
- };
57
- const fetchOptions = {
58
- method,
59
- headers,
60
- };
61
- if (body !== undefined && method !== 'GET') {
62
- fetchOptions.body = JSON.stringify(body);
63
- }
64
- const response = await fetch(url, fetchOptions);
65
- let data;
66
- try {
67
- data = await response.json();
68
- }
69
- catch {
70
- // Response may not be JSON
71
- }
72
- if (!response.ok) {
73
- return {
74
- ok: false,
75
- status: response.status,
76
- error: data?.message
77
- ?? data?.error
78
- ?? `HTTP ${response.status}`,
79
- };
80
- }
81
- return {
82
- ok: true,
83
- status: response.status,
84
- data,
85
- };
86
- }
87
- //# sourceMappingURL=api-client.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"api-client.js","sourceRoot":"","sources":["../../src/utils/api-client.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAEnD,wCAAwC;AACxC,MAAM,eAAe,GAAG,6BAA6B,CAAC;AAEtD,mCAAmC;AACnC,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,aAAa,CAAC,CAAC;AAElE;;GAEG;AACH,MAAM,UAAU,SAAS;IACvB,2CAA2C;IAC3C,IAAI,OAAO,CAAC,GAAG,CAAC,kBAAkB,CAAC,EAAE,CAAC;QACpC,OAAO,OAAO,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;IAC7D,CAAC;IAED,iBAAiB;IACjB,IAAI,CAAC;QACH,IAAI,EAA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E,YAAY,CAAC,CAAC;IAEhD,IAAI,IAAmB,CAAC;IACxB,IAAI,CAAC;QACH,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAO,CAAC;IACpC,CAAC;IAAC,MAAM,CAAC;QACP,2BAA2B;IAC7B,CAAC;IAED,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;QACjB,OAAO;YACL,EAAE,EAAE,KAAK;YACT,MAAM,EAAE,QAAQ,CAAC,MAAM;YACvB,KAAK,EAAG,IAA2C,EAAE,OAAO;mBACtD,IAA2C,EAAE,KAAK;mBACnD,QAAQ,QAAQ,CAAC,MAAM,EAAE;SAC/B,CAAC;IACJ,CAAC;IAED,OAAO;QACL,EAAE,EAAE,IAAI;QACR,MAAM,EAAE,QAAQ,CAAC,MAAM;QACvB,IAAI;KACL,CAAC;AACJ,CAAC"}
@@ -1,44 +0,0 @@
1
- /**
2
- * Credential storage for HQ CLI authentication.
3
- * Stores Clerk auth tokens in ~/.hq/credentials.json.
4
- */
5
- /** Stored credential shape */
6
- export interface HqCredentials {
7
- /** Clerk session token (JWT) */
8
- token: string;
9
- /** Clerk user ID */
10
- userId: string;
11
- /** User's email (for display) */
12
- email?: string;
13
- /** When the token was stored (ISO string) */
14
- storedAt: string;
15
- /** When the token expires (ISO string, if known) */
16
- expiresAt?: string;
17
- }
18
- /**
19
- * Set the base directory for config files. Intended for testing only.
20
- */
21
- export declare function _setConfigHome(dir: string | null): void;
22
- /**
23
- * Read stored credentials. Returns null if not logged in or file is missing/corrupt.
24
- */
25
- export declare function readCredentials(): HqCredentials | null;
26
- /**
27
- * Write credentials to disk. Creates ~/.hq if needed.
28
- * File permissions are set to owner-only (0o600).
29
- */
30
- export declare function writeCredentials(creds: HqCredentials): void;
31
- /**
32
- * Clear stored credentials (logout).
33
- * Returns true if credentials were removed, false if none existed.
34
- */
35
- export declare function clearCredentials(): boolean;
36
- /**
37
- * Get the credentials file path (for display/debugging).
38
- */
39
- export declare function getCredentialsPath(): string;
40
- /**
41
- * Check if credentials are expired (if expiresAt is set).
42
- */
43
- export declare function isExpired(creds: HqCredentials): boolean;
44
- //# sourceMappingURL=credentials.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"credentials.d.ts","sourceRoot":"","sources":["../../src/utils/credentials.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,8BAA8B;AAC9B,MAAM,WAAW,aAAa;IAC5B,gCAAgC;IAChC,KAAK,EAAE,MAAM,CAAC;IACd,oBAAoB;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,iCAAiC;IACjC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,6CAA6C;IAC7C,QAAQ,EAAE,MAAM,CAAC;IACjB,oDAAoD;IACpD,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AASD;;GAEG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAEvD;AA8BD;;GAEG;AACH,wBAAgB,eAAe,IAAI,aAAa,GAAG,IAAI,CAetD;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,aAAa,GAAG,IAAI,CAI3D;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,IAAI,OAAO,CAO1C;AAED;;GAEG;AACH,wBAAgB,kBAAkB,IAAI,MAAM,CAE3C;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,aAAa,GAAG,OAAO,CAKvD"}
@@ -1,101 +0,0 @@
1
- /**
2
- * Credential storage for HQ CLI authentication.
3
- * Stores Clerk auth tokens in ~/.hq/credentials.json.
4
- */
5
- import * as fs from 'fs';
6
- import * as path from 'path';
7
- import * as os from 'os';
8
- /**
9
- * Override for the config directory base path.
10
- * Set via HQ_CONFIG_HOME env var or _setConfigHome (for testing).
11
- * When null, defaults to os.homedir().
12
- */
13
- let configHomeOverride = null;
14
- /**
15
- * Set the base directory for config files. Intended for testing only.
16
- */
17
- export function _setConfigHome(dir) {
18
- configHomeOverride = dir;
19
- }
20
- /**
21
- * Get the ~/.hq config directory path.
22
- * Respects HQ_CONFIG_HOME env var, _setConfigHome override, or defaults to ~/.hq.
23
- */
24
- function getConfigDir() {
25
- const base = configHomeOverride
26
- ?? process.env['HQ_CONFIG_HOME']
27
- ?? os.homedir();
28
- return path.join(base, '.hq');
29
- }
30
- /**
31
- * Get the credentials file path.
32
- */
33
- function getCredentialsFilePath() {
34
- return path.join(getConfigDir(), 'credentials.json');
35
- }
36
- /**
37
- * Ensure the config directory exists with restricted permissions.
38
- */
39
- function ensureConfigDir() {
40
- const dir = getConfigDir();
41
- if (!fs.existsSync(dir)) {
42
- fs.mkdirSync(dir, { recursive: true, mode: 0o700 });
43
- }
44
- }
45
- /**
46
- * Read stored credentials. Returns null if not logged in or file is missing/corrupt.
47
- */
48
- export function readCredentials() {
49
- try {
50
- const credPath = getCredentialsFilePath();
51
- if (!fs.existsSync(credPath)) {
52
- return null;
53
- }
54
- const raw = fs.readFileSync(credPath, 'utf-8');
55
- const creds = JSON.parse(raw);
56
- if (!creds.token || !creds.userId) {
57
- return null;
58
- }
59
- return creds;
60
- }
61
- catch {
62
- return null;
63
- }
64
- }
65
- /**
66
- * Write credentials to disk. Creates ~/.hq if needed.
67
- * File permissions are set to owner-only (0o600).
68
- */
69
- export function writeCredentials(creds) {
70
- ensureConfigDir();
71
- const content = JSON.stringify(creds, null, 2);
72
- fs.writeFileSync(getCredentialsFilePath(), content, { mode: 0o600 });
73
- }
74
- /**
75
- * Clear stored credentials (logout).
76
- * Returns true if credentials were removed, false if none existed.
77
- */
78
- export function clearCredentials() {
79
- const credPath = getCredentialsFilePath();
80
- if (!fs.existsSync(credPath)) {
81
- return false;
82
- }
83
- fs.unlinkSync(credPath);
84
- return true;
85
- }
86
- /**
87
- * Get the credentials file path (for display/debugging).
88
- */
89
- export function getCredentialsPath() {
90
- return getCredentialsFilePath();
91
- }
92
- /**
93
- * Check if credentials are expired (if expiresAt is set).
94
- */
95
- export function isExpired(creds) {
96
- if (!creds.expiresAt) {
97
- return false;
98
- }
99
- return new Date(creds.expiresAt) <= new Date();
100
- }
101
- //# sourceMappingURL=credentials.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"credentials.js","sourceRoot":"","sources":["../../src/utils/credentials.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AAgBzB;;;;GAIG;AACH,IAAI,kBAAkB,GAAkB,IAAI,CAAC;AAE7C;;GAEG;AACH,MAAM,UAAU,cAAc,CAAC,GAAkB;IAC/C,kBAAkB,GAAG,GAAG,CAAC;AAC3B,CAAC;AAED;;;GAGG;AACH,SAAS,YAAY;IACnB,MAAM,IAAI,GAAG,kBAAkB;WAC1B,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC;WAC7B,EAAE,CAAC,OAAO,EAAE,CAAC;IAClB,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;AAChC,CAAC;AAED;;GAEG;AACH,SAAS,sBAAsB;IAC7B,OAAO,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,EAAE,kBAAkB,CAAC,CAAC;AACvD,CAAC;AAED;;GAEG;AACH,SAAS,eAAe;IACtB,MAAM,GAAG,GAAG,YAAY,EAAE,CAAC;IAC3B,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;QACxB,EAAE,CAAC,SAAS,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;IACtD,CAAC;AACH,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,eAAe;IAC7B,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,sBAAsB,EAAE,CAAC;QAC1C,IAAI,CAAC,EAAE,CAAC,UAAU,C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AC,SAAS,CAAC,IAAI,IAAI,IAAI,EAAE,CAAC;AACjD,CAAC"}
@@ -1,125 +0,0 @@
1
- /**
2
- * Sync utilities for hq-cloud file synchronization.
3
- *
4
- * Provides local manifest computation, file hashing, upload/download helpers,
5
- * and diff computation via the API proxy. No AWS credentials needed — all
6
- * operations go through the authenticated hq-cloud API.
7
- */
8
- /**
9
- * Check whether a relative path should be ignored during sync.
10
- */
11
- export declare function shouldIgnore(relativePath: string): boolean;
12
- /**
13
- * Compute the SHA-256 hash of a file's contents.
14
- */
15
- export declare function hashFile(filePath: string): string;
16
- /**
17
- * Compute the SHA-256 hash of a buffer.
18
- */
19
- export declare function hashBuffer(content: Buffer): string;
20
- /** A single entry in the local file manifest. */
21
- export interface ManifestEntry {
22
- /** Relative path from HQ root (forward slashes) */
23
- path: string;
24
- /** SHA-256 hash of file content */
25
- hash: string;
26
- /** File size in bytes */
27
- size: number;
28
- /** Last modified time (ISO string) */
29
- lastModified: string;
30
- }
31
- /** Response from POST /api/files/sync */
32
- export interface SyncDiffResult {
33
- /** Relative paths that the client should upload (local is newer) */
34
- needsUpload: string[];
35
- /** Relative paths that the client should download (remote is newer) */
36
- needsDownload: string[];
37
- }
38
- /** Response from GET /api/files/quota */
39
- export interface QuotaInfo {
40
- used: number;
41
- limit: number;
42
- percentage: number;
43
- }
44
- /** Sync state persisted to .hq-cloud-sync.json */
45
- export interface CloudSyncState {
46
- /** Whether a background sync watcher is running */
47
- running: boolean;
48
- /** PID of the background watcher process (if running) */
49
- pid?: number;
50
- /** ISO timestamp of last successful sync */
51
- lastSync?: string;
52
- /** Number of files tracked at last sync */
53
- fileCount?: number;
54
- /** Errors from last sync attempt */
55
- errors: string[];
56
- }
57
- /**
58
- * Recursively walk a directory and collect all files, respecting ignore rules.
59
- * Returns paths relative to rootDir, using forward slashes.
60
- */
61
- export declare function walkDir(rootDir: string, subDir?: string): string[];
62
- /**
63
- * Compute the local file manifest for an HQ root directory.
64
- * Walks all non-ignored files, computes hashes, and returns manifest entries.
65
- */
66
- export declare function computeLocalManifest(hqRoot: string): ManifestEntry[];
67
- /**
68
- * Compute the diff between local and remote state via the API.
69
- * Sends the local manifest to POST /api/files/sync and receives
70
- * lists of files to upload and download.
71
- */
72
- export declare function syncDiff(hqRoot: string): Promise<SyncDiffResult>;
73
- /**
74
- * Upload a single file to the cloud via POST /api/files/upload.
75
- * File content is base64-encoded in the request body.
76
- */
77
- export declare function uploadFile(filePath: string, hqRoot: string): Promise<void>;
78
- /**
79
- * Download a single file from the cloud via GET /api/files/download.
80
- * Writes the file to the local HQ root, creating directories as needed.
81
- */
82
- export declare function downloadFile(remotePath: string, hqRoot: string): Promise<void>;
83
- /**
84
- * Get storage quota information from the API.
85
- */
86
- export declare function getQuota(): Promise<QuotaInfo>;
87
- /**
88
- * Get the path to the sync state file.
89
- */
90
- export declare function getSyncStatePath(hqRoot: string): string;
91
- /**
92
- * Read the persisted sync state. Returns a default state if no file exists.
93
- */
94
- export declare function readSyncState(hqRoot: string): CloudSyncState;
95
- /**
96
- * Write the sync state to disk.
97
- */
98
- export declare function writeSyncState(hqRoot: string, state: CloudSyncState): void;
99
- /**
100
- * Push all changed local files to the cloud.
101
- * Uses the sync diff endpoint to determine what needs uploading, then uploads each file.
102
- * Returns the number of files uploaded.
103
- */
104
- export declare function pushChanges(hqRoot: string): Promise<{
105
- uploaded: number;
106
- errors: string[];
107
- }>;
108
- /**
109
- * Pull all changed remote files to local.
110
- * Uses the sync diff endpoint to determine what needs downloading, then downloads each file.
111
- * Returns the number of files downloaded.
112
- */
113
- export declare function pullChanges(hqRoot: string): Promise<{
114
- downloaded: number;
115
- errors: string[];
116
- }>;
117
- /**
118
- * Run a full bidirectional sync: upload local changes, then download remote changes.
119
- */
120
- export declare function fullSync(hqRoot: string): Promise<{
121
- uploaded: number;
122
- downloaded: number;
123
- errors: string[];
124
- }>;
125
- //# sourceMappingURL=sync.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"sync.d.ts","sourceR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