pi-jscpd 0.1.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 (49) hide show
  1. package/CHANGELOG.md +99 -0
  2. package/CONTRIBUTING.md +144 -0
  3. package/LICENSE +21 -0
  4. package/README.md +231 -0
  5. package/SECURITY.md +93 -0
  6. package/docs/automatic-checkpoint.md +235 -0
  7. package/docs/compatibility.md +119 -0
  8. package/docs/effect-architecture.md +128 -0
  9. package/docs/fallow-coexistence.md +120 -0
  10. package/docs/overlay-interaction.md +347 -0
  11. package/docs/release.md +115 -0
  12. package/package.json +86 -0
  13. package/scripts/check-compatibility.mjs +103 -0
  14. package/skills/jscpd/SKILL.md +90 -0
  15. package/src/acknowledgements.ts +268 -0
  16. package/src/automatic.ts +396 -0
  17. package/src/baseline.ts +400 -0
  18. package/src/capability.ts +569 -0
  19. package/src/changed-files.ts +372 -0
  20. package/src/changed.ts +548 -0
  21. package/src/clone-identity.ts +373 -0
  22. package/src/config.ts +414 -0
  23. package/src/contract.ts +39 -0
  24. package/src/dispatch.ts +90 -0
  25. package/src/effect/clock.ts +10 -0
  26. package/src/effect/errors.ts +311 -0
  27. package/src/effect/filesystem.ts +240 -0
  28. package/src/effect/runtime-boundary.ts +25 -0
  29. package/src/effect/runtime-contract.ts +18 -0
  30. package/src/effect/services.ts +131 -0
  31. package/src/extension.ts +708 -0
  32. package/src/fallow.ts +479 -0
  33. package/src/finding-presentation.ts +73 -0
  34. package/src/index.ts +8 -0
  35. package/src/jscpd-report.ts +819 -0
  36. package/src/jscpd.ts +748 -0
  37. package/src/overlay.ts +1166 -0
  38. package/src/parser.ts +189 -0
  39. package/src/path-utils.ts +44 -0
  40. package/src/presentation.ts +232 -0
  41. package/src/process.ts +425 -0
  42. package/src/registry.ts +102 -0
  43. package/src/scan.ts +441 -0
  44. package/src/scheduler.ts +434 -0
  45. package/src/session-state.ts +229 -0
  46. package/src/status.ts +534 -0
  47. package/src/types.ts +334 -0
  48. package/src/value-utils.ts +14 -0
  49. package/src/verification.ts +220 -0
@@ -0,0 +1,131 @@
1
+ import { Context, type Effect } from "effect";
2
+ import type {
3
+ JscpdDeliveryFailure,
4
+ JscpdFileSystemFailure,
5
+ JscpdInvalidInput,
6
+ JscpdLimitExceeded,
7
+ JscpdOperationCancelled,
8
+ JscpdOperationTimedOut,
9
+ JscpdPersistenceFailure,
10
+ JscpdProcessFailure,
11
+ JscpdWorkspaceFailure,
12
+ } from "./errors.js";
13
+
14
+ /** Infrastructure required by application programs, independent of their host runner. */
15
+ export type JscpdWorkflowRequirements = JscpdClock | JscpdFileSystem | JscpdProcess;
16
+
17
+ export interface JscpdProcessRequest {
18
+ readonly stage: "probe" | "scan";
19
+ readonly executable: string;
20
+ readonly args: readonly string[];
21
+ readonly cwd: string;
22
+ readonly environment?: Readonly<Record<string, string | undefined>>;
23
+ readonly timeoutMs: number;
24
+ readonly maxOutputBytes: number;
25
+ readonly terminationGraceMs?: number;
26
+ readonly forceSettleMs?: number;
27
+ }
28
+
29
+ export interface JscpdProcessResult {
30
+ readonly exitCode: number;
31
+ readonly stdout: Uint8Array;
32
+ readonly stderr: Uint8Array;
33
+ }
34
+
35
+ export type JscpdProcessRunError =
36
+ | JscpdProcessFailure
37
+ | JscpdInvalidInput
38
+ | JscpdOperationCancelled
39
+ | JscpdOperationTimedOut
40
+ | JscpdLimitExceeded;
41
+
42
+ /** Shell-free, bounded execution whose implementation owns process-tree cleanup. */
43
+ export interface JscpdProcess {
44
+ readonly run: (
45
+ request: JscpdProcessRequest,
46
+ ) => Effect.Effect<JscpdProcessResult, JscpdProcessRunError>;
47
+ }
48
+
49
+ export const JscpdProcess = Context.GenericTag<JscpdProcess>("pi-jscpd/effect/Process");
50
+
51
+ export interface JscpdBoundedReadRequest {
52
+ readonly path: string;
53
+ readonly maxBytes: number;
54
+ readonly regularFileOnly: boolean;
55
+ readonly noFollow: boolean;
56
+ readonly offset?: number;
57
+ readonly length?: number;
58
+ readonly limitSubject: JscpdLimitExceeded["subject"];
59
+ }
60
+
61
+ export interface JscpdBoundedWriteRequest {
62
+ readonly path: string;
63
+ readonly bytes: Uint8Array;
64
+ readonly maxBytes: number;
65
+ readonly mode: number;
66
+ }
67
+
68
+ export interface JscpdFileMetadata {
69
+ readonly kind: "file" | "directory" | "symlink" | "other";
70
+ readonly size: number;
71
+ }
72
+
73
+ export type JscpdFileSystemError = JscpdFileSystemFailure | JscpdLimitExceeded;
74
+
75
+ /** Bounded filesystem capabilities; callers never receive an unbounded stream. */
76
+ export interface JscpdFileSystem {
77
+ readonly canonicalize: (path: string) => Effect.Effect<string, JscpdFileSystemFailure>;
78
+ readonly metadata: (path: string) => Effect.Effect<JscpdFileMetadata, JscpdFileSystemFailure>;
79
+ readonly read: (
80
+ request: JscpdBoundedReadRequest,
81
+ ) => Effect.Effect<Uint8Array, JscpdFileSystemError>;
82
+ readonly write: (request: JscpdBoundedWriteRequest) => Effect.Effect<void, JscpdFileSystemError>;
83
+ readonly makeTempDirectory: (
84
+ prefix: string,
85
+ ) => Effect.Effect<string, JscpdWorkspaceFailure | JscpdFileSystemFailure>;
86
+ readonly remove: (
87
+ path: string,
88
+ recursive: boolean,
89
+ ) => Effect.Effect<void, JscpdFileSystemFailure>;
90
+ }
91
+
92
+ export const JscpdFileSystem = Context.GenericTag<JscpdFileSystem>("pi-jscpd/effect/FileSystem");
93
+
94
+ /** Explicit time dependency for timeout, scheduling, and lifecycle tests. */
95
+ export interface JscpdClock {
96
+ readonly now: Effect.Effect<number>;
97
+ readonly sleep: (milliseconds: number) => Effect.Effect<void>;
98
+ }
99
+
100
+ export const JscpdClock = Context.GenericTag<JscpdClock>("pi-jscpd/effect/Clock");
101
+
102
+ export interface JscpdPiMessage {
103
+ readonly customType: string;
104
+ readonly content: string;
105
+ readonly display: boolean;
106
+ readonly details?: unknown;
107
+ }
108
+
109
+ export interface JscpdPiNotification {
110
+ readonly message: string;
111
+ readonly level: "info" | "warning" | "error";
112
+ }
113
+
114
+ /** Narrow host callbacks needed by application workflows; no Pi UI types leak below adapters. */
115
+ export interface JscpdPiPort {
116
+ readonly appendSessionEntry: (
117
+ customType: string,
118
+ data: unknown,
119
+ ) => Effect.Effect<void, JscpdPersistenceFailure>;
120
+ readonly sendMessage: (
121
+ message: JscpdPiMessage,
122
+ triggerTurn: false,
123
+ ) => Effect.Effect<void, JscpdDeliveryFailure>;
124
+ readonly notify: (notification: JscpdPiNotification) => Effect.Effect<void, JscpdDeliveryFailure>;
125
+ readonly setStatus: (
126
+ key: string,
127
+ text: string | undefined,
128
+ ) => Effect.Effect<void, JscpdDeliveryFailure>;
129
+ }
130
+
131
+ export const JscpdPiPort = Context.GenericTag<JscpdPiPort>("pi-jscpd/effect/PiPort");