@thehumanpatternlab/hpl 0.0.1-alpha.5

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 (49) hide show
  1. package/README.md +42 -0
  2. package/dist/__tests__/config.test.js +22 -0
  3. package/dist/__tests__/outputContract.test.js +58 -0
  4. package/dist/bin/hpl.js +158 -0
  5. package/dist/cli/output.js +21 -0
  6. package/dist/cli/outputContract.js +32 -0
  7. package/dist/commands/notesSync.js +191 -0
  8. package/dist/commands/publish.js +36 -0
  9. package/dist/index.js +36 -0
  10. package/dist/lab.js +10 -0
  11. package/dist/lib/config.js +52 -0
  12. package/dist/lib/http.js +18 -0
  13. package/dist/lib/notes.js +62 -0
  14. package/dist/lib/output.js +21 -0
  15. package/dist/sdk/LabClient.js +94 -0
  16. package/dist/src/__tests__/config.test.js +22 -0
  17. package/dist/src/__tests__/outputContract.test.js +58 -0
  18. package/dist/src/cli/output.js +21 -0
  19. package/dist/src/cli/outputContract.js +32 -0
  20. package/dist/src/commands/capabilities.js +10 -0
  21. package/dist/src/commands/health.js +48 -0
  22. package/dist/src/commands/notes/get.js +48 -0
  23. package/dist/src/commands/notes/list.js +43 -0
  24. package/dist/src/commands/notesSync.js +191 -0
  25. package/dist/src/commands/version.js +12 -0
  26. package/dist/src/config.js +10 -0
  27. package/dist/src/contract/capabilities.js +15 -0
  28. package/dist/src/contract/envelope.js +16 -0
  29. package/dist/src/contract/exitCodes.js +21 -0
  30. package/dist/src/contract/intents.js +49 -0
  31. package/dist/src/contract/schema.js +59 -0
  32. package/dist/src/http/client.js +39 -0
  33. package/dist/src/index.js +36 -0
  34. package/dist/src/io.js +15 -0
  35. package/dist/src/lib/config.js +52 -0
  36. package/dist/src/lib/http.js +18 -0
  37. package/dist/src/lib/notes.js +62 -0
  38. package/dist/src/render/table.js +17 -0
  39. package/dist/src/render/text.js +40 -0
  40. package/dist/src/sdk/ApiError.js +10 -0
  41. package/dist/src/sdk/LabClient.js +101 -0
  42. package/dist/src/sync/summary.js +25 -0
  43. package/dist/src/sync/types.js +2 -0
  44. package/dist/src/types/labNotes.js +27 -0
  45. package/dist/src/utils/loadMarkdown.js +10 -0
  46. package/dist/sync/summary.js +25 -0
  47. package/dist/sync/types.js +2 -0
  48. package/dist/utils/loadMarkdown.js +10 -0
  49. package/package.json +70 -0
@@ -0,0 +1,25 @@
1
+ export function buildSyncSummary(results, dryRunMode) {
2
+ let synced = 0;
3
+ let dryRun = 0;
4
+ let failed = 0;
5
+ for (const r of results) {
6
+ if (r.status === "failed") {
7
+ failed++;
8
+ continue;
9
+ }
10
+ if (dryRunMode)
11
+ dryRun++;
12
+ else
13
+ synced++;
14
+ }
15
+ const total = results.length;
16
+ // Invariant: dry-run must never report synced writes
17
+ if (dryRunMode && synced > 0) {
18
+ throw new Error("Invariant violation: dry-run mode cannot produce synced > 0");
19
+ }
20
+ // Invariant: accounting must balance
21
+ if (synced + dryRun + failed !== total) {
22
+ throw new Error("SyncSummary invariant failed: counts do not add up to total");
23
+ }
24
+ return { synced, dryRun, failed, total };
25
+ }
@@ -0,0 +1,2 @@
1
+ // src/sync/types.ts
2
+ export {};
@@ -0,0 +1,10 @@
1
+ import fs from 'fs';
2
+ import matter from 'gray-matter';
3
+ export function loadMarkdown(filePath) {
4
+ const raw = fs.readFileSync(filePath, 'utf8');
5
+ const parsed = matter(raw);
6
+ return {
7
+ content: parsed.content.trim(),
8
+ metadata: parsed.data
9
+ };
10
+ }
package/package.json ADDED
@@ -0,0 +1,70 @@
1
+ {
2
+ "name": "@thehumanpatternlab/hpl",
3
+ "version": "0.0.1-alpha.5",
4
+ "description": "AI-forward, automation-safe SDK and CLI for the Human Pattern Lab",
5
+ "type": "module",
6
+ "license": "MIT",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/AdaInTheLab/the-human-pattern-lab-cli.git"
10
+ },
11
+ "homepage": "https://github.com/AdaInTheLab/the-human-pattern-lab-cli#readme",
12
+ "bugs": {
13
+ "url": "https://github.com/AdaInTheLab/the-human-pattern-lab-cli/issues"
14
+ },
15
+ "publishConfig": {
16
+ "access": "public"
17
+ },
18
+ "files": [
19
+ "dist",
20
+ "README.md",
21
+ "LICENSE"
22
+ ],
23
+ "bin": {
24
+ "hpl": "./dist/bin/hpl.js"
25
+ },
26
+ "main": "./dist/index.js",
27
+ "types": "./dist/index.d.ts",
28
+ "exports": {
29
+ ".": {
30
+ "types": "./dist/index.d.ts",
31
+ "import": "./dist/index.js"
32
+ }
33
+ },
34
+ "scripts": {
35
+ "dev": "tsx ./bin/hpl.ts",
36
+ "build": "tsc -p tsconfig.json",
37
+ "start": "node ./dist/bin/hpl.js",
38
+ "test": "vitest run",
39
+ "test:watch": "vitest",
40
+ "lint": "node -e \"console.log('lint: add eslint when ready')\""
41
+ },
42
+ "dependencies": {
43
+ "commander": "^12.1.0",
44
+ "gray-matter": "^4.0.3",
45
+ "zod": "^3.24.1"
46
+ },
47
+ "devDependencies": {
48
+ "@types/node": "^22.19.3",
49
+ "tsx": "^4.19.2",
50
+ "typescript": "^5.7.2",
51
+ "vitest": "^4.0.16"
52
+ },
53
+ "engines": {
54
+ "node": ">=18"
55
+ },
56
+ "keywords": [
57
+ "human-pattern-lab",
58
+ "hpl",
59
+ "ai",
60
+ "ai-forward",
61
+ "automation",
62
+ "automation-safe",
63
+ "cli",
64
+ "sdk",
65
+ "developer-tools",
66
+ "observability",
67
+ "notes",
68
+ "knowledge-systems"
69
+ ]
70
+ }