gentle-pi 1.0.2 → 1.0.4

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 (76) hide show
  1. package/README.md +65 -12
  2. package/assets/agents/jd-judge-a.md +1 -1
  3. package/assets/agents/jd-judge-b.md +1 -1
  4. package/assets/agents/review-readability.md +1 -1
  5. package/assets/agents/review-refuter.md +17 -9
  6. package/assets/agents/review-reliability.md +1 -1
  7. package/assets/agents/review-resilience.md +1 -1
  8. package/assets/agents/review-risk.md +1 -1
  9. package/assets/agents/review-validator.md +3 -3
  10. package/assets/agents/sdd-apply.md +7 -1
  11. package/assets/agents/sdd-status.md +7 -4
  12. package/assets/agents/sdd-tasks.md +11 -0
  13. package/assets/chains/sdd-full.chain.md +1 -1
  14. package/assets/migrations/managed-assets-v0.10.7.json +7 -0
  15. package/assets/orchestrator-delegation.md +4 -4
  16. package/assets/orchestrator.md +1 -1
  17. package/assets/support/sdd-status-contract.md +14 -4
  18. package/extensions/gentle-ai.ts +1772 -148
  19. package/lib/gentle-ai-binary.ts +89 -0
  20. package/lib/native-review-cli.ts +552 -0
  21. package/lib/review-authority-supersession.ts +1055 -0
  22. package/lib/review-candidate-view.ts +546 -0
  23. package/lib/review-compact-contract.ts +94 -7
  24. package/lib/review-compact-gate.ts +88 -4
  25. package/lib/review-compact-store.ts +24 -3
  26. package/lib/review-facade.ts +175 -24
  27. package/lib/review-refuter-adapter.ts +129 -0
  28. package/lib/review-snapshot.ts +42 -0
  29. package/lib/sdd-preflight.ts +9 -5
  30. package/lib/sdd-status.ts +197 -39
  31. package/package.json +2 -1
  32. package/scripts/gentle-ai-installer.mjs +225 -0
  33. package/scripts/install-gentle-ai.mjs +14 -0
  34. package/scripts/verify-package-files.mjs +6 -0
  35. package/skills/_shared/review-ledger-contract.md +9 -7
  36. package/skills/gentle-ai/SKILL.md +8 -6
  37. package/skills/judgment-day/SKILL.md +1 -1
  38. package/skills/judgment-day/references/prompts-and-formats.md +1 -1
  39. package/tests/artifact-language.test.ts +20 -0
  40. package/tests/fixtures/native-review-cli/v2.1.2/bind-sdd.json +25 -0
  41. package/tests/fixtures/native-review-cli/v2.1.2/finalize.json +8 -0
  42. package/tests/fixtures/native-review-cli/v2.1.2/sdd-status-engram.json +139 -0
  43. package/tests/fixtures/native-review-cli/v2.1.2/sdd-status.json +200 -0
  44. package/tests/fixtures/native-review-cli/v2.1.2/start.json +12 -0
  45. package/tests/fixtures/native-review-cli/v2.1.2/validate-allow.json +24 -0
  46. package/tests/fixtures/native-review-cli/v2.1.2/validate-deny-empty-context.json +20 -0
  47. package/tests/fixtures/native-review-cli/v2.1.2/validate-deny.json +28 -0
  48. package/tests/fixtures/native-review-cli/v2.1.3/bind-sdd.json +25 -0
  49. package/tests/fixtures/native-review-cli/v2.1.3/finalize.json +8 -0
  50. package/tests/fixtures/native-review-cli/v2.1.3/sdd-status-engram.json +139 -0
  51. package/tests/fixtures/native-review-cli/v2.1.3/sdd-status.json +200 -0
  52. package/tests/fixtures/native-review-cli/v2.1.3/start.json +14 -0
  53. package/tests/fixtures/native-review-cli/v2.1.3/validate-allow.json +24 -0
  54. package/tests/fixtures/native-review-cli/v2.1.3/validate-deny-empty-context.json +20 -0
  55. package/tests/fixtures/native-review-cli/v2.1.3/validate-deny.json +28 -0
  56. package/tests/fixtures/v0.10.7/assets/agents/sdd-apply.md +132 -0
  57. package/tests/gentle-ai-binary.test.ts +148 -0
  58. package/tests/gentle-ai-installer.test.ts +219 -0
  59. package/tests/native-review-cli.test.ts +675 -0
  60. package/tests/native-review-parity-runtime.test.ts +170 -0
  61. package/tests/package-manifest.test.ts +27 -2
  62. package/tests/review-authority-recovery-docs.test.ts +25 -0
  63. package/tests/review-authority-supersession.test.ts +581 -0
  64. package/tests/review-candidate-view.test.ts +288 -0
  65. package/tests/review-compact-contract.test.ts +36 -4
  66. package/tests/review-compact-gate.test.ts +236 -7
  67. package/tests/review-compact-store.test.ts +11 -0
  68. package/tests/review-controller-native-routing.test.ts +2280 -0
  69. package/tests/review-controller.test.ts +342 -28
  70. package/tests/review-facade.test.ts +129 -19
  71. package/tests/review-ledger-contract.test.ts +58 -5
  72. package/tests/review-refuter-adapter.test.ts +89 -0
  73. package/tests/review-snapshot.test.ts +25 -0
  74. package/tests/runtime-harness.mjs +23 -0
  75. package/tests/sdd-preflight.test.ts +78 -0
  76. package/tests/sdd-status.test.ts +127 -6
@@ -0,0 +1,89 @@
1
+ import { createHash } from "node:crypto";
2
+ import { existsSync, lstatSync, readFileSync } from "node:fs";
3
+ import { dirname, isAbsolute, join, relative, resolve } from "node:path";
4
+ import { resolveGentleAiReleaseAsset } from "../scripts/gentle-ai-installer.mjs";
5
+ import { fileURLToPath } from "node:url";
6
+
7
+ export const GENTLE_AI_BINARY_MISSING_CODE = "package-local-binary-missing";
8
+ export const GENTLE_AI_VERSION = "2.1.4";
9
+
10
+ export class PackageLocalGentleAiBinaryMissingError extends Error {
11
+ readonly code = GENTLE_AI_BINARY_MISSING_CODE;
12
+ constructor(path: string) {
13
+ super(
14
+ `${GENTLE_AI_BINARY_MISSING_CODE}: Gentle AI v${GENTLE_AI_VERSION} is not installed at ${path}. Reinstall gentle-pi, or use GENTLE_PI_SKIP_GENTLE_AI_INSTALL=1 only for development/offline installs.`,
15
+ );
16
+ this.name = "PackageLocalGentleAiBinaryMissingError";
17
+ }
18
+ }
19
+
20
+ export function gentleAiBinaryPath(
21
+ packageRoot = dirname(dirname(fileURLToPath(import.meta.url))),
22
+ platform = process.platform,
23
+ ): string {
24
+ return join(
25
+ resolve(packageRoot),
26
+ ".gentle-ai",
27
+ `v${GENTLE_AI_VERSION}`,
28
+ platform === "win32" ? "gentle-ai.exe" : "gentle-ai",
29
+ );
30
+ }
31
+
32
+ function sha256(value: Buffer): string {
33
+ return createHash("sha256").update(value).digest("hex");
34
+ }
35
+
36
+ function isConfined(path: string, directory: string): boolean {
37
+ const relativePath = relative(directory, path);
38
+ return relativePath !== "" && !relativePath.startsWith("..") && !isAbsolute(relativePath);
39
+ }
40
+
41
+ function assertRegularNonSymlink(path: string): void {
42
+ const details = lstatSync(path);
43
+ if (!details.isFile() || details.isSymbolicLink()) throw new Error("expected regular non-symlink file");
44
+ }
45
+
46
+ function assertPosixExecutable(path: string, platform: string): void {
47
+ if (platform !== "win32" && (lstatSync(path).mode & 0o111) === 0) {
48
+ throw new Error("expected executable POSIX binary");
49
+ }
50
+ }
51
+
52
+ export function resolveGentleAiBinary(
53
+ packageRoot = dirname(dirname(fileURLToPath(import.meta.url))),
54
+ platform = process.platform,
55
+ readBinary: (path: string) => Buffer = readFileSync,
56
+ ): string {
57
+ const binaryPath = gentleAiBinaryPath(packageRoot, platform);
58
+ const versionDirectory = dirname(binaryPath);
59
+ const manifestPath = join(versionDirectory, "integrity.json");
60
+ try {
61
+ if (!isAbsolute(binaryPath) || !isConfined(binaryPath, versionDirectory)) throw new Error("unconfined binary");
62
+ for (const path of [join(resolve(packageRoot), ".gentle-ai"), versionDirectory]) {
63
+ const details = lstatSync(path);
64
+ if (!details.isDirectory() || details.isSymbolicLink()) throw new Error("symlinked runtime directory");
65
+ }
66
+ assertRegularNonSymlink(binaryPath);
67
+ assertPosixExecutable(binaryPath, platform);
68
+ assertRegularNonSymlink(manifestPath);
69
+ const before = lstatSync(binaryPath);
70
+ const manifest = JSON.parse(readFileSync(manifestPath, "utf8")) as Record<string, unknown>;
71
+ const asset = resolveGentleAiReleaseAsset(platform, process.arch);
72
+ if (
73
+ Object.keys(manifest).length !== 4 ||
74
+ ["version", "asset", "assetSha256", "binarySha256"].some((key) => !(key in manifest)) ||
75
+ manifest.version !== GENTLE_AI_VERSION ||
76
+ manifest.asset !== asset.name ||
77
+ manifest.assetSha256 !== asset.sha256 ||
78
+ typeof manifest.binarySha256 !== "string" ||
79
+ !/^[0-9a-f]{64}$/.test(manifest.binarySha256) ||
80
+ sha256(readBinary(binaryPath)) !== manifest.binarySha256
81
+ ) throw new Error("invalid runtime integrity manifest");
82
+ const after = lstatSync(binaryPath);
83
+ if (before.dev !== after.dev || before.ino !== after.ino || before.size !== after.size || before.mtimeMs !== after.mtimeMs) throw new Error("runtime replaced during verification");
84
+ assertPosixExecutable(binaryPath, platform);
85
+ return binaryPath;
86
+ } catch {
87
+ throw new PackageLocalGentleAiBinaryMissingError(binaryPath);
88
+ }
89
+ }