@rewrlution/papyrus-cli 0.0.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.
Files changed (125) hide show
  1. package/README.md +699 -0
  2. package/dist/cli.d.ts +2 -0
  3. package/dist/cli.js +16 -0
  4. package/dist/cli.js.map +1 -0
  5. package/dist/commands/auth/index.d.ts +2 -0
  6. package/dist/commands/auth/index.js +18 -0
  7. package/dist/commands/auth/index.js.map +1 -0
  8. package/dist/commands/auth/login.d.ts +1 -0
  9. package/dist/commands/auth/login.js +8 -0
  10. package/dist/commands/auth/login.js.map +1 -0
  11. package/dist/commands/auth/logout.d.ts +1 -0
  12. package/dist/commands/auth/logout.js +5 -0
  13. package/dist/commands/auth/logout.js.map +1 -0
  14. package/dist/commands/auth/register.d.ts +1 -0
  15. package/dist/commands/auth/register.js +8 -0
  16. package/dist/commands/auth/register.js.map +1 -0
  17. package/dist/commands/index.d.ts +2 -0
  18. package/dist/commands/index.js +3 -0
  19. package/dist/commands/index.js.map +1 -0
  20. package/dist/commands/journal/add.d.ts +2 -0
  21. package/dist/commands/journal/add.js +5 -0
  22. package/dist/commands/journal/add.js.map +1 -0
  23. package/dist/commands/journal/amend.d.ts +2 -0
  24. package/dist/commands/journal/amend.js +5 -0
  25. package/dist/commands/journal/amend.js.map +1 -0
  26. package/dist/commands/journal/edit.d.ts +6 -0
  27. package/dist/commands/journal/edit.js +60 -0
  28. package/dist/commands/journal/edit.js.map +1 -0
  29. package/dist/commands/journal/index.d.ts +2 -0
  30. package/dist/commands/journal/index.js +32 -0
  31. package/dist/commands/journal/index.js.map +1 -0
  32. package/dist/commands/journal/list.d.ts +1 -0
  33. package/dist/commands/journal/list.js +20 -0
  34. package/dist/commands/journal/list.js.map +1 -0
  35. package/dist/commands/journal/show.d.ts +2 -0
  36. package/dist/commands/journal/show.js +35 -0
  37. package/dist/commands/journal/show.js.map +1 -0
  38. package/dist/commands/journal/sync.d.ts +1 -0
  39. package/dist/commands/journal/sync.js +9 -0
  40. package/dist/commands/journal/sync.js.map +1 -0
  41. package/dist/commands/types.d.ts +9 -0
  42. package/dist/commands/types.js +2 -0
  43. package/dist/commands/types.js.map +1 -0
  44. package/dist/components/Browser.d.ts +29 -0
  45. package/dist/components/Browser.js +124 -0
  46. package/dist/components/Browser.js.map +1 -0
  47. package/dist/components/BrowserFooter.d.ts +6 -0
  48. package/dist/components/BrowserFooter.js +6 -0
  49. package/dist/components/BrowserFooter.js.map +1 -0
  50. package/dist/components/BrowserHeader.d.ts +6 -0
  51. package/dist/components/BrowserHeader.js +6 -0
  52. package/dist/components/BrowserHeader.js.map +1 -0
  53. package/dist/components/ColdStart.d.ts +6 -0
  54. package/dist/components/ColdStart.js +24 -0
  55. package/dist/components/ColdStart.js.map +1 -0
  56. package/dist/components/FormInput.d.ts +10 -0
  57. package/dist/components/FormInput.js +7 -0
  58. package/dist/components/FormInput.js.map +1 -0
  59. package/dist/components/JournalListView.d.ts +10 -0
  60. package/dist/components/JournalListView.js +40 -0
  61. package/dist/components/JournalListView.js.map +1 -0
  62. package/dist/components/JournalViewer.d.ts +32 -0
  63. package/dist/components/JournalViewer.js +146 -0
  64. package/dist/components/JournalViewer.js.map +1 -0
  65. package/dist/components/LoginForm.d.ts +1 -0
  66. package/dist/components/LoginForm.js +68 -0
  67. package/dist/components/LoginForm.js.map +1 -0
  68. package/dist/components/Logo.d.ts +1 -0
  69. package/dist/components/Logo.js +57 -0
  70. package/dist/components/Logo.js.map +1 -0
  71. package/dist/components/RegisterForm.d.ts +1 -0
  72. package/dist/components/RegisterForm.js +72 -0
  73. package/dist/components/RegisterForm.js.map +1 -0
  74. package/dist/components/StatusMessage.d.ts +7 -0
  75. package/dist/components/StatusMessage.js +19 -0
  76. package/dist/components/StatusMessage.js.map +1 -0
  77. package/dist/components/SyncProgress.d.ts +1 -0
  78. package/dist/components/SyncProgress.js +46 -0
  79. package/dist/components/SyncProgress.js.map +1 -0
  80. package/dist/lib/api/api-client.d.ts +23 -0
  81. package/dist/lib/api/api-client.js +111 -0
  82. package/dist/lib/api/api-client.js.map +1 -0
  83. package/dist/lib/api/index.d.ts +3 -0
  84. package/dist/lib/api/index.js +6 -0
  85. package/dist/lib/api/index.js.map +1 -0
  86. package/dist/lib/auth/index.d.ts +1 -0
  87. package/dist/lib/auth/index.js +2 -0
  88. package/dist/lib/auth/index.js.map +1 -0
  89. package/dist/lib/auth/require-auth.d.ts +67 -0
  90. package/dist/lib/auth/require-auth.js +107 -0
  91. package/dist/lib/auth/require-auth.js.map +1 -0
  92. package/dist/lib/storage/base-storage.d.ts +50 -0
  93. package/dist/lib/storage/base-storage.js +91 -0
  94. package/dist/lib/storage/base-storage.js.map +1 -0
  95. package/dist/lib/storage/config-store.d.ts +40 -0
  96. package/dist/lib/storage/config-store.js +63 -0
  97. package/dist/lib/storage/config-store.js.map +1 -0
  98. package/dist/lib/storage/index.d.ts +12 -0
  99. package/dist/lib/storage/index.js +13 -0
  100. package/dist/lib/storage/index.js.map +1 -0
  101. package/dist/lib/storage/journal-storage.d.ts +46 -0
  102. package/dist/lib/storage/journal-storage.js +78 -0
  103. package/dist/lib/storage/journal-storage.js.map +1 -0
  104. package/dist/lib/storage/sync-meta-store.d.ts +37 -0
  105. package/dist/lib/storage/sync-meta-store.js +50 -0
  106. package/dist/lib/storage/sync-meta-store.js.map +1 -0
  107. package/dist/lib/storage/token-store.d.ts +25 -0
  108. package/dist/lib/storage/token-store.js +40 -0
  109. package/dist/lib/storage/token-store.js.map +1 -0
  110. package/dist/lib/sync/sync-engine.d.ts +13 -0
  111. package/dist/lib/sync/sync-engine.js +96 -0
  112. package/dist/lib/sync/sync-engine.js.map +1 -0
  113. package/dist/utils/date.d.ts +58 -0
  114. package/dist/utils/date.js +117 -0
  115. package/dist/utils/date.js.map +1 -0
  116. package/dist/utils/editor.d.ts +2 -0
  117. package/dist/utils/editor.js +81 -0
  118. package/dist/utils/editor.js.map +1 -0
  119. package/dist/utils/template.d.ts +2 -0
  120. package/dist/utils/template.js +17 -0
  121. package/dist/utils/template.js.map +1 -0
  122. package/dist/utils/token.d.ts +20 -0
  123. package/dist/utils/token.js +64 -0
  124. package/dist/utils/token.js.map +1 -0
  125. package/package.json +53 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"template.js","sourceRoot":"","sources":["../../src/utils/template.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,eAAe,GAAG;;;;;;;;CAQ9B,CAAC;AAEF,MAAM,UAAU,qBAAqB,CAAC,OAAe;IACnD,OAAO,OAAO;SACX,KAAK,CAAC,IAAI,CAAC;SACX,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;SACnD,IAAI,CAAC,IAAI,CAAC;SACV,IAAI,EAAE,CAAC;AACZ,CAAC"}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Decodes JWT token and returns expiration date
3
+ * @param token - jwt token
4
+ * @returns expiration date in milliseconds
5
+ */
6
+ export declare function getTokenExpiration(token: string): Date | null;
7
+ export declare function isTokenExpired(token: string): boolean;
8
+ /**
9
+ * Check if token will expire within the given threshold
10
+ * @param token - access token
11
+ * @param thresholdHours - hours before expiration to consider "expiring soon"
12
+ * @returns
13
+ */
14
+ export declare function isTokenExpiringSoon(token: string, thresholdHours?: number): boolean;
15
+ /**
16
+ * Get time until token expiration in a human-readable format
17
+ * @param token - JWT token string
18
+ * @returns Human-readable time string or null if invalid/expired
19
+ */
20
+ export declare function getTimeUntilExpiration(token: string): string | null;
@@ -0,0 +1,64 @@
1
+ import { jwtDecode } from 'jwt-decode';
2
+ /**
3
+ * Decodes JWT token and returns expiration date
4
+ * @param token - jwt token
5
+ * @returns expiration date in milliseconds
6
+ */
7
+ export function getTokenExpiration(token) {
8
+ try {
9
+ const decoded = jwtDecode(token);
10
+ return new Date(decoded.exp * 1000); // convert seconds to milliseconds
11
+ }
12
+ catch {
13
+ return null; // invalid token
14
+ }
15
+ }
16
+ export function isTokenExpired(token) {
17
+ const expiration = getTokenExpiration(token);
18
+ if (!expiration)
19
+ return true; // treat invalid token as expired
20
+ return Date.now() >= expiration.getTime();
21
+ }
22
+ /**
23
+ * Check if token will expire within the given threshold
24
+ * @param token - access token
25
+ * @param thresholdHours - hours before expiration to consider "expiring soon"
26
+ * @returns
27
+ */
28
+ export function isTokenExpiringSoon(token, thresholdHours = 24) {
29
+ const expiration = getTokenExpiration(token);
30
+ if (!expiration)
31
+ return false;
32
+ const thresholdMs = thresholdHours * 60 * 60 * 1000; // milliseconds
33
+ const timeUntilExpiry = expiration.getTime() - Date.now();
34
+ return timeUntilExpiry > 0 && timeUntilExpiry <= thresholdMs;
35
+ }
36
+ /**
37
+ * Get time until token expiration in a human-readable format
38
+ * @param token - JWT token string
39
+ * @returns Human-readable time string or null if invalid/expired
40
+ */
41
+ export function getTimeUntilExpiration(token) {
42
+ const expiration = getTokenExpiration(token);
43
+ if (!expiration) {
44
+ return null;
45
+ }
46
+ const now = Date.now();
47
+ const timeUntilExpiration = expiration.getTime() - now;
48
+ if (timeUntilExpiration <= 0) {
49
+ return 'expired';
50
+ }
51
+ const hours = Math.floor(timeUntilExpiration / (1000 * 60 * 60));
52
+ const minutes = Math.floor((timeUntilExpiration % (1000 * 60 * 60)) / (1000 * 60));
53
+ if (hours > 24) {
54
+ const days = Math.floor(hours / 24);
55
+ return `${days} day${days > 1 ? 's' : ''}`;
56
+ }
57
+ else if (hours > 0) {
58
+ return `${hours} hour${hours > 1 ? 's' : ''}`;
59
+ }
60
+ else {
61
+ return `${minutes} minute${minutes > 1 ? 's' : ''}`;
62
+ }
63
+ }
64
+ //# sourceMappingURL=token.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"token.js","sourceRoot":"","sources":["../../src/utils/token.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAOvC;;;;GAIG;AACH,MAAM,UAAU,kBA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AAC;IAEvD,IAAI,mBAAmB,IAAI,CAAC,EAAE,CAAC;QAC7B,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,mBAAmB,GAAG,CAAC,IAAI,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC;IACjE,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CACxB,CAAC,mBAAmB,GAAG,CAAC,IAAI,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC,GAAG,CAAC,IAAI,GAAG,EAAE,CAAC,CACvD,CAAC;IAEF,IAAI,KAAK,GAAG,EAAE,EAAE,CAAC;QACf,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,EAAE,CAAC,CAAC;QACpC,OAAO,GAAG,IAAI,OAAO,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;IAC7C,CAAC;SAAM,IAAI,KAAK,GAAG,CAAC,EAAE,CAAC;QACrB,OAAO,GAAG,KAAK,QAAQ,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;IAChD,CAAC;SAAM,CAAC;QACN,OAAO,GAAG,OAAO,UAAU,OAAO,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;IACtD,CAAC;AACH,CAAC"}
package/package.json ADDED
@@ -0,0 +1,53 @@
1
+ {
2
+ "name": "@rewrlution/papyrus-cli",
3
+ "version": "0.0.1",
4
+ "description": "AI-powered developer journaling CLI",
5
+ "keywords": [
6
+ "journal",
7
+ "productivity"
8
+ ],
9
+ "license": "MIT",
10
+ "author": "rewrlution@gmail.com",
11
+ "engines": {
12
+ "node": ">=18"
13
+ },
14
+ "type": "module",
15
+ "bin": {
16
+ "pp": "./dist/cli.js",
17
+ "paper": "./dist/cli.js",
18
+ "papyrus": "./dist/cli.js"
19
+ },
20
+ "main": "./dist/index.js",
21
+ "types": "./dist/index.d.ts",
22
+ "files": [
23
+ "dist",
24
+ "README.md",
25
+ "LICENSE"
26
+ ],
27
+ "scripts": {
28
+ "build": "rimraf dist tsconfig.tsbuildinfo && tsc --build",
29
+ "dev": "tsx watch src/cli.tsx",
30
+ "start": "node dist/cli.js",
31
+ "test": "vitest run",
32
+ "prepublishOnly": "npm run build && npm run test"
33
+ },
34
+ "dependencies": {
35
+ "@rewrlution/papyrus-shared": "workspace:*",
36
+ "axios": "^1.13.2",
37
+ "chalk": "^5.6.2",
38
+ "commander": "^14.0.2",
39
+ "date-fns": "^4.1.0",
40
+ "env-paths": "^3.0.0",
41
+ "gray-matter": "^4.0.3",
42
+ "ink": "^6.6.0",
43
+ "ink-spinner": "^5.0.0",
44
+ "ink-text-input": "^6.0.0",
45
+ "jwt-decode": "^4.0.0",
46
+ "react": "^19.2.3"
47
+ },
48
+ "devDependencies": {
49
+ "@types/node": "^25.0.3",
50
+ "@types/react": "^19.2.7",
51
+ "tsx": "^4.21.0"
52
+ }
53
+ }