@okfit/profiles 0.1.0 → 0.3.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.
- package/BodyProvenance.js +44 -0
- package/Derivation.js +200 -0
- package/GitHistory.js +107 -0
- package/Profile.js +38 -0
- package/Profiles.js +27 -0
- package/Provenance.js +94 -0
- package/README.md +163 -3
- package/SoftwareProject.js +170 -0
- package/index.d.ts +429 -6
- package/index.js +7 -14
- package/package.json +6 -4
package/index.d.ts
CHANGED
|
@@ -1,21 +1,444 @@
|
|
|
1
|
-
|
|
1
|
+
import { Context, Crypto, DateTime, Effect, FileSystem, Layer, Option, Path, PlatformError, Schema } from "effect";
|
|
2
|
+
import { Git, GitCommandError, NotARepositoryError, UnknownRefError } from "@effected/git";
|
|
3
|
+
import { Actor, Diagnostic, DiagnosticRange, LoadedBundle, OkfitConfig } from "@okfit/core";
|
|
4
|
+
import { ChildProcessSpawner } from "effect/unstable/process";
|
|
5
|
+
//#region src/BodyProvenance.d.ts
|
|
2
6
|
/**
|
|
3
|
-
*
|
|
7
|
+
* The body is at HEAD and last changed in the commit described here (P-9).
|
|
8
|
+
* `at` is that commit's author date (P-4); `committedAt` and the author
|
|
9
|
+
* identity are carried for callers that want a history-based policy later (P-40).
|
|
10
|
+
* `creating` is true exactly when the winning entry is also the oldest entry
|
|
11
|
+
* of the path's history — the commit that created the path (S-9).
|
|
4
12
|
*
|
|
5
|
-
* @
|
|
13
|
+
* @public
|
|
14
|
+
*/
|
|
15
|
+
export declare const BodyCommitted: Schema.TaggedStruct<"committed", {
|
|
16
|
+
readonly at: Schema.Codec<import("effect/DateTime").Utc, string, never, never>;
|
|
17
|
+
readonly sha: Schema.String;
|
|
18
|
+
readonly committedAt: Schema.Codec<import("effect/DateTime").Utc, string, never, never>;
|
|
19
|
+
readonly authorName: Schema.String;
|
|
20
|
+
readonly authorEmail: Schema.String;
|
|
21
|
+
readonly creating: Schema.Boolean;
|
|
22
|
+
}>;
|
|
23
|
+
/**
|
|
24
|
+
* The body has no usable commit (P-9): `untracked` means HEAD does not contain
|
|
25
|
+
* the path, `dirty` means the on-disk body differs from HEAD's blob, `unborn`
|
|
26
|
+
* means HEAD has no commits (P-11).
|
|
27
|
+
*
|
|
28
|
+
* @public
|
|
6
29
|
*/
|
|
30
|
+
export declare const BodyUncommitted: Schema.TaggedStruct<"uncommitted", {
|
|
31
|
+
readonly reason: Schema.Literals<readonly ["untracked", "dirty", "unborn"]>;
|
|
32
|
+
}>;
|
|
7
33
|
/**
|
|
8
|
-
*
|
|
34
|
+
* What {@link Derivation.generatedAt} reports. A schema so the value also
|
|
35
|
+
* serialises for MCP later without adaptation. Derivation never substitutes
|
|
36
|
+
* `now`; the uncommitted policy is the caller's (P-10).
|
|
9
37
|
*
|
|
10
38
|
* @public
|
|
11
39
|
*/
|
|
12
|
-
declare const
|
|
40
|
+
export declare const BodyProvenance: Schema.Union<readonly [Schema.TaggedStruct<"committed", {
|
|
41
|
+
readonly at: Schema.Codec<import("effect/DateTime").Utc, string, never, never>;
|
|
42
|
+
readonly sha: Schema.String;
|
|
43
|
+
readonly committedAt: Schema.Codec<import("effect/DateTime").Utc, string, never, never>;
|
|
44
|
+
readonly authorName: Schema.String;
|
|
45
|
+
readonly authorEmail: Schema.String;
|
|
46
|
+
readonly creating: Schema.Boolean;
|
|
47
|
+
}>, Schema.TaggedStruct<"uncommitted", {
|
|
48
|
+
readonly reason: Schema.Literals<readonly ["untracked", "dirty", "unborn"]>;
|
|
49
|
+
}>]>;
|
|
50
|
+
/**
|
|
51
|
+
* The type of {@link (BodyProvenance:variable)}.
|
|
52
|
+
*
|
|
53
|
+
* @public
|
|
54
|
+
*/
|
|
55
|
+
export type BodyProvenance = typeof BodyProvenance.Type;
|
|
56
|
+
/**
|
|
57
|
+
* Why a body is uncommitted (P-9).
|
|
58
|
+
*
|
|
59
|
+
* @public
|
|
60
|
+
*/
|
|
61
|
+
type UncommittedReason = typeof BodyUncommitted.fields.reason.Type;
|
|
62
|
+
//#endregion
|
|
63
|
+
//#region src/GitHistory.d.ts
|
|
64
|
+
declare const PathHistoryEntry_base: Schema.Class<PathHistoryEntry, Schema.Struct<{
|
|
65
|
+
readonly sha: Schema.String;
|
|
66
|
+
readonly authoredAt: Schema.Codec<import("effect/DateTime").Utc, string, never, never>;
|
|
67
|
+
readonly committedAt: Schema.Codec<import("effect/DateTime").Utc, string, never, never>;
|
|
68
|
+
readonly authorName: Schema.String;
|
|
69
|
+
readonly authorEmail: Schema.String;
|
|
70
|
+
readonly path: Schema.String;
|
|
71
|
+
}>, {}>;
|
|
72
|
+
/**
|
|
73
|
+
* One record of the path log, newest first (P-3, P-5): the commit, both dates decoded through core's
|
|
74
|
+
* `Timestamp` (`%aI` / `%cI`, strict ISO with an offset; the `Type` is `DateTime.Utc`, P-4), the author
|
|
75
|
+
* identity, and the repository-relative posix path the blob had at that commit (the `--name-only` line).
|
|
76
|
+
* @public
|
|
77
|
+
*/
|
|
78
|
+
export declare class PathHistoryEntry extends PathHistoryEntry_base {}
|
|
79
|
+
declare const GitHistoryError_base: Schema.Class<GitHistoryError, Schema.TaggedStruct<"GitHistoryError", {
|
|
80
|
+
/** The argv without the leading `git`. */
|
|
81
|
+
readonly args: Schema.$Array<Schema.String>;
|
|
82
|
+
/** The working directory the command ran in. */
|
|
83
|
+
readonly cwd: Schema.String;
|
|
84
|
+
/** git's exit code; absent when git never produced one. */
|
|
85
|
+
readonly exitCode: Schema.optionalKey<Schema.Number>;
|
|
86
|
+
/** git's stderr, captured under `LC_ALL=C`. */
|
|
87
|
+
readonly stderr: Schema.String;
|
|
88
|
+
/** Spawn failure text, `timed out after 30s`, or `Git.log`'s own absorbed-failure detail. */
|
|
89
|
+
readonly detail: Schema.optionalKey<Schema.String>;
|
|
90
|
+
}>, import("effect/Cause").YieldableError>;
|
|
91
|
+
/**
|
|
92
|
+
* Profiles' own spawn failure, shaped like `@effected/git`'s `GitCommandError` (P-12). Raised by
|
|
93
|
+
* `GitHistory.layer` for any `GitCommandError` `Git.log` produces, including the one `Git.log`
|
|
94
|
+
* itself synthesizes when its own spawn timeout expires.
|
|
95
|
+
* @public
|
|
96
|
+
*/
|
|
97
|
+
export declare class GitHistoryError extends GitHistoryError_base {
|
|
98
|
+
get message(): string;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Options for `pathLog`; `limit` becomes `Git.log`'s `--max-count=<n>` (P-3, P-8).
|
|
102
|
+
* @public
|
|
103
|
+
*/
|
|
104
|
+
interface PathLogOptions {
|
|
105
|
+
readonly limit?: number;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* The service shape. `cwd` is any directory inside the repository; `path` is relative to `cwd` (git
|
|
109
|
+
* pathspec semantics). The result is newest first, and empty when no commit contains the path or HEAD is
|
|
110
|
+
* unborn (P-11).
|
|
111
|
+
* @public
|
|
112
|
+
*/
|
|
113
|
+
interface GitHistoryShape {
|
|
114
|
+
readonly pathLog: (cwd: string, path: string, options?: PathLogOptions) => Effect.Effect<ReadonlyArray<PathHistoryEntry>, GitHistoryError | NotARepositoryError>;
|
|
115
|
+
}
|
|
116
|
+
declare const GitHistory_base: Context.ServiceClass<GitHistory, "@okfit/profiles/GitHistory", GitHistoryShape>;
|
|
117
|
+
/**
|
|
118
|
+
* A path-scoped, date-bearing log: `Git.log` reads the whole repository history, and this adapter scopes
|
|
119
|
+
* it to one path (`--follow`, `--diff-merges=first-parent`) and decodes it into `PathHistoryEntry`.
|
|
120
|
+
* Delegates to `Git.log` as of `@effected/git` 0.12.0 (P-1, spec deviation retired).
|
|
121
|
+
* @public
|
|
122
|
+
*/
|
|
123
|
+
export declare class GitHistory extends GitHistory_base {
|
|
124
|
+
/**
|
|
125
|
+
* Live layer (P-1, P-5, P-11): one `Git.log` call per `pathLog`, resolved once at construction like
|
|
126
|
+
* `Git.layer` itself, so every member's `R` is `never`. `Git.log` already degrades an unborn `HEAD` and
|
|
127
|
+
* an unmatched pathspec to the empty array and classifies `not a git repository` as `NotARepositoryError`
|
|
128
|
+
* (both pass through unchanged); every other failure becomes `GitHistoryError`, including the one
|
|
129
|
+
* `Git.log` itself produces when its own 30 s spawn timeout expires (`@effected/git`'s `GIT_TIMEOUT`
|
|
130
|
+
* ceiling, not this adapter's) — `Git.log` never lets a bare `Cause.TimeoutError` escape. The CLI
|
|
131
|
+
* provides `ChildProcessSpawner` through `NodeServices.layer` (P-30).
|
|
132
|
+
*/
|
|
133
|
+
static readonly layer: Layer.Layer<GitHistory, never, ChildProcessSpawner.ChildProcessSpawner>;
|
|
134
|
+
/**
|
|
135
|
+
* Scripted double (P-32): responses keyed by the `path` argument exactly as passed to `pathLog`. A call
|
|
136
|
+
* whose path has no entry DIES with `GitHistory.makeTest: pathLog(<path>) was called but not scripted`,
|
|
137
|
+
* mirroring `Git.makeTest`; `limit` is honoured by slicing. Models none of the live semantics.
|
|
138
|
+
*/
|
|
139
|
+
static readonly makeTest: (script: Readonly<Record<string, ReadonlyArray<PathHistoryEntry>>>) => GitHistoryShape;
|
|
140
|
+
/**
|
|
141
|
+
* `Layer.succeed(GitHistory, GitHistory.makeTest(script))`. Mints a fresh layer per call: bind it to a
|
|
142
|
+
* `const`, since layers memoize by reference.
|
|
143
|
+
*/
|
|
144
|
+
static readonly layerTest: (script: Readonly<Record<string, ReadonlyArray<PathHistoryEntry>>>) => Layer.Layer<GitHistory>;
|
|
145
|
+
}
|
|
146
|
+
//#endregion
|
|
147
|
+
//#region src/Derivation.d.ts
|
|
148
|
+
/**
|
|
149
|
+
* Who is writing now. Explicit, never read from the environment (P-16).
|
|
150
|
+
*
|
|
151
|
+
* @public
|
|
152
|
+
*/
|
|
153
|
+
type Writer = "agent" | "human";
|
|
154
|
+
declare const HumanActorUnresolvedError_base: Schema.Class<HumanActorUnresolvedError, Schema.TaggedStruct<"HumanActorUnresolvedError", {
|
|
155
|
+
readonly userName: Schema.optionalKey<Schema.String>;
|
|
156
|
+
readonly userEmail: Schema.optionalKey<Schema.String>;
|
|
157
|
+
}>, import("effect/Cause").YieldableError>;
|
|
158
|
+
/**
|
|
159
|
+
* git has no identity to derive a `human:` actor from (P-13 step 4).
|
|
160
|
+
* `userName` and `userEmail` are the trimmed `configGet` answers when git had
|
|
161
|
+
* them and absent keys otherwise (decision 53: not `name`/`email`, since every
|
|
162
|
+
* Effect error class carries the class name on its own prototype and a field
|
|
163
|
+
* literally named `name` would shadow `error.name` when present); test for
|
|
164
|
+
* git's answer with `Object.hasOwn(error, "userName")`.
|
|
165
|
+
*
|
|
166
|
+
* @public
|
|
167
|
+
*/
|
|
168
|
+
export declare class HumanActorUnresolvedError extends HumanActorUnresolvedError_base {
|
|
169
|
+
get message(): string;
|
|
170
|
+
}
|
|
171
|
+
declare const AgentActorUnconfiguredError_base: Schema.Class<AgentActorUnconfiguredError, Schema.TaggedStruct<"AgentActorUnconfiguredError", {}>, import("effect/Cause").YieldableError>;
|
|
172
|
+
/**
|
|
173
|
+
* The writer is an agent but `actors.agent` is not configured (P-17); the
|
|
174
|
+
* profile never sets it.
|
|
175
|
+
*
|
|
176
|
+
* @public
|
|
177
|
+
*/
|
|
178
|
+
export declare class AgentActorUnconfiguredError extends AgentActorUnconfiguredError_base {
|
|
179
|
+
get message(): string;
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Options for {@link Derivation.generatedAt} (P-39).
|
|
183
|
+
*
|
|
184
|
+
* @public
|
|
185
|
+
*/
|
|
186
|
+
interface GeneratedAtOptions {
|
|
187
|
+
/** ABSOLUTE path to the concept file on disk. */
|
|
188
|
+
readonly file: string;
|
|
189
|
+
/** Reserved (P-48): accepted and ignored in phase 1; no key affects the walk. */
|
|
190
|
+
readonly config?: OkfitConfig;
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Everything {@link Derivation.generatedAt} can fail with: profiles' own
|
|
194
|
+
* `GitHistoryError`, the `@effected/git` peer's errors (P-12), and the
|
|
195
|
+
* `PlatformError` of `realPath`/`readFileString` on `file`.
|
|
196
|
+
*
|
|
197
|
+
* @public
|
|
198
|
+
*/
|
|
199
|
+
type GeneratedAtError = GitHistoryError | GitCommandError | NotARepositoryError | UnknownRefError | PlatformError.PlatformError;
|
|
200
|
+
/**
|
|
201
|
+
* Options for {@link Derivation.generatedBy} (P-16, P-45).
|
|
202
|
+
*
|
|
203
|
+
* @public
|
|
204
|
+
*/
|
|
205
|
+
interface GeneratedByOptions {
|
|
206
|
+
readonly writer: Writer;
|
|
207
|
+
/** Any directory inside the repository; every `Git` member takes a cwd and profiles never reads `process.cwd()`. */
|
|
208
|
+
readonly cwd: string;
|
|
209
|
+
/** Merged or raw; only `actors` is read. */
|
|
210
|
+
readonly config: OkfitConfig;
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Everything {@link Derivation.generatedBy} can fail with.
|
|
214
|
+
*
|
|
215
|
+
* @public
|
|
216
|
+
*/
|
|
217
|
+
type GeneratedByError = AgentActorUnconfiguredError | HumanActorUnresolvedError | GitCommandError | NotARepositoryError | UnknownRefError;
|
|
218
|
+
/**
|
|
219
|
+
* Trimmed `user.name` / `user.email` as `Git.configGet` answers them; a key is absent when git has no value.
|
|
220
|
+
*
|
|
221
|
+
* @public
|
|
222
|
+
*/
|
|
223
|
+
interface GitIdentity {
|
|
224
|
+
readonly name?: string;
|
|
225
|
+
readonly email?: string;
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Spec 5.4 derivation rules for the `software-project` profile, package-global
|
|
229
|
+
* (P-38). Pure members take every input as an argument; effectful members
|
|
230
|
+
* require `Git`, `GitHistory` and, for the worktree read, `FileSystem` and
|
|
231
|
+
* `Path` (P-30). Never writes, never reads `generated.by` (P-40).
|
|
232
|
+
*
|
|
233
|
+
* @public
|
|
234
|
+
*/
|
|
235
|
+
export declare class Derivation {
|
|
236
|
+
private constructor();
|
|
237
|
+
/**
|
|
238
|
+
* `FrontmatterSource.split(text).body`, then CRLF and lone CR to LF, then trailing whitespace at end of
|
|
239
|
+
* text removed (P-6). Pure. Applied to both sides of every comparison so `core.autocrlf` worktrees compare clean.
|
|
240
|
+
*/
|
|
241
|
+
static readonly body: (text: string) => string;
|
|
242
|
+
/**
|
|
243
|
+
* Lowercase 64-char hex sha256 of `Derivation.body(text)`, through `effect`'s platform-agnostic
|
|
244
|
+
* `Crypto` service (issue #19). Same normalization as `body`, so a frontmatter-only edit or a
|
|
245
|
+
* `core.autocrlf` worktree never changes the digest.
|
|
246
|
+
*/
|
|
247
|
+
static readonly bodyDigest: (text: string) => Effect.Effect<string, PlatformError.PlatformError, Crypto.Crypto>;
|
|
248
|
+
/**
|
|
249
|
+
* Spec 5.4 rule 2 as P-2 (DERIVE option C). Steps:
|
|
250
|
+
* 1. `root = Git.repoRoot(dirname(file))`: a file outside any repository surfaces `NotARepositoryError`;
|
|
251
|
+
* submodules and worktrees work because the question is asked from the file's directory (P-39).
|
|
252
|
+
* 2. `realPath` both (rev-parse is symlink-resolved), then the repo-relative posix path via `Path` (P-39).
|
|
253
|
+
* 3. `worktree = body(readFileString(file))`.
|
|
254
|
+
* 4. `Git.show(realRoot, "HEAD", rel)`: `UnknownRefError` is `uncommitted { unborn }` (P-11), `Option.none`
|
|
255
|
+
* is `uncommitted { untracked }` (P-47), a body differing from `worktree` is `uncommitted { dirty }` (P-9).
|
|
256
|
+
* The comparison is against HEAD's blob, never the newest log entry (P-46).
|
|
257
|
+
* 5. `entries = GitHistory.pathLog(realRoot, rel)` newest first (P-5, P-46); `[]` is `uncommitted { unborn }`.
|
|
258
|
+
* 6. One `Git.show` per older blob (P-8), newest first: the first entry whose body differs from the next
|
|
259
|
+
* older entry's body wins, else the oldest entry (the creating commit). "Previous" is the previous entry
|
|
260
|
+
* of the simplified `--follow` history, not the true parent (P-7). The newest entry's body is never
|
|
261
|
+
* re-fetched: `head.blob`, already confirmed equal to `worktree` by step 4, is reused (decision 56).
|
|
262
|
+
* `Option.none` for an older entry counts as "differs", never a defect (decision 56).
|
|
263
|
+
* `config` is reserved and ignored (P-48). Never writes, never reads `by` (P-40).
|
|
264
|
+
*/
|
|
265
|
+
static readonly generatedAt: (options: GeneratedAtOptions) => Effect.Effect<BodyProvenance, GeneratedAtError, Git | GitHistory | FileSystem.FileSystem | Path.Path>;
|
|
266
|
+
/**
|
|
267
|
+
* P-13 / P-14, pure. Candidates: the email local part (returned as written, lower-cased only for matching)
|
|
268
|
+
* and the `user.name` slug. Order, first hit wins: (1) a `human:` entry of `humans` whose id equals a
|
|
269
|
+
* candidate case-insensitively, returned verbatim; (2) `human:<local>`; (3) `human:<slug>`; (4) none.
|
|
270
|
+
* The result is branded through core's `Actor` codec and always passes it.
|
|
271
|
+
*/
|
|
272
|
+
static readonly humanActorId: (identity: GitIdentity, humans: ReadonlyArray<Actor>) => Option.Option<Actor>;
|
|
273
|
+
/**
|
|
274
|
+
* Spec 5.4 rule 1 (P-16, P-45). `"agent"`: `config.actors.agent`, else {@link AgentActorUnconfiguredError}
|
|
275
|
+
* (P-17). `"human"`: `Git.configGet(cwd, "user.name")` and `Git.configGet(cwd, "user.email")` in merged
|
|
276
|
+
* scope (P-15) through {@link Derivation.humanActorId}; none is {@link HumanActorUnresolvedError}.
|
|
277
|
+
* Answers only "who is writing now" (P-40).
|
|
278
|
+
*/
|
|
279
|
+
static readonly generatedBy: (options: GeneratedByOptions) => Effect.Effect<Actor, GeneratedByError, Git>;
|
|
280
|
+
/**
|
|
281
|
+
* P-19, pure: `from` plus `config.lifecycle.default_stale_after`, falling back to `OkfitConfig.DEFAULTS`'
|
|
282
|
+
* 90 days. `from` is the caller's: `generated.at` when committed, else its own `now`.
|
|
283
|
+
*/
|
|
284
|
+
static readonly staleAfter: (from: DateTime.Utc, config: OkfitConfig) => DateTime.Utc;
|
|
285
|
+
}
|
|
286
|
+
//#endregion
|
|
287
|
+
//#region src/Profile.d.ts
|
|
288
|
+
/**
|
|
289
|
+
* Names of the profiles this package ships (P-38).
|
|
290
|
+
*
|
|
291
|
+
* @public
|
|
292
|
+
*/
|
|
293
|
+
export declare const PROFILE_NAMES: readonly ["software-project"];
|
|
13
294
|
/**
|
|
14
295
|
* A profile name shipped by this package.
|
|
15
296
|
*
|
|
16
297
|
* @public
|
|
17
298
|
*/
|
|
18
299
|
type ProfileName = (typeof PROFILE_NAMES)[number];
|
|
300
|
+
/**
|
|
301
|
+
* One concept directory of a profile's bundle layout (P-26). Each directory
|
|
302
|
+
* carries its own `index.md`; `type` is the `types.<Name>` key held there.
|
|
303
|
+
*
|
|
304
|
+
* @public
|
|
305
|
+
*/
|
|
306
|
+
interface LayoutDirectory {
|
|
307
|
+
readonly directory: string;
|
|
308
|
+
readonly type: string;
|
|
309
|
+
}
|
|
310
|
+
/**
|
|
311
|
+
* Scaffolding data for `okfit init` (spec 5.2); never part of `OkfitConfig`
|
|
312
|
+
* (P-26). What the CLI writes into these files is the CLI plan's concern.
|
|
313
|
+
*
|
|
314
|
+
* @public
|
|
315
|
+
*/
|
|
316
|
+
interface Layout {
|
|
317
|
+
readonly root: {
|
|
318
|
+
readonly index: "index.md";
|
|
319
|
+
readonly log: "log.md";
|
|
320
|
+
readonly project: "project.md";
|
|
321
|
+
};
|
|
322
|
+
readonly directories: ReadonlyArray<LayoutDirectory>;
|
|
323
|
+
}
|
|
324
|
+
/**
|
|
325
|
+
* Profile-owned diagnostic codes (P-21). Core's `LintCode` is untouched; all
|
|
326
|
+
* three are severity `error` and are not configurable.
|
|
327
|
+
*
|
|
328
|
+
* @public
|
|
329
|
+
*/
|
|
330
|
+
export declare const ProfileDiagnosticCode: Schema.Literals<readonly ["project-missing", "project-multiple", "project-not-at-root"]>;
|
|
331
|
+
/**
|
|
332
|
+
* The type of `ProfileDiagnosticCode`.
|
|
333
|
+
*
|
|
334
|
+
* @public
|
|
335
|
+
*/
|
|
336
|
+
export type ProfileDiagnosticCode = typeof ProfileDiagnosticCode.Type;
|
|
337
|
+
/**
|
|
338
|
+
* Same fields as core's `Diagnostic` with a profile code; a `Schema.Struct`
|
|
339
|
+
* per P-21/P-51. `file` is the bundle-relative posix path, `""` for the
|
|
340
|
+
* bundle-level `project-missing`. `range` is never set in phase 1.
|
|
341
|
+
*
|
|
342
|
+
* @public
|
|
343
|
+
*/
|
|
344
|
+
export declare const ProfileDiagnostic: Schema.Struct<{
|
|
345
|
+
readonly file: Schema.String;
|
|
346
|
+
readonly range: Schema.optionalKey<typeof DiagnosticRange>;
|
|
347
|
+
readonly code: Schema.Literals<readonly ["project-missing", "project-multiple", "project-not-at-root"]>;
|
|
348
|
+
readonly severity: Schema.Literals<readonly ["error", "warning", "info"]>;
|
|
349
|
+
readonly message: Schema.String;
|
|
350
|
+
}>;
|
|
351
|
+
/**
|
|
352
|
+
* The type of `ProfileDiagnostic`.
|
|
353
|
+
*
|
|
354
|
+
* @public
|
|
355
|
+
*/
|
|
356
|
+
export type ProfileDiagnostic = typeof ProfileDiagnostic.Type;
|
|
357
|
+
/**
|
|
358
|
+
* A named profile (P-38): a partial `OkfitConfig` the CLI merges as
|
|
359
|
+
* `DEFAULTS < profile < file`, a scaffolding `Layout`, and a pure `check`
|
|
360
|
+
* over a loaded bundle run after `Validate.all`.
|
|
361
|
+
*
|
|
362
|
+
* @public
|
|
363
|
+
*/
|
|
364
|
+
interface Profile {
|
|
365
|
+
readonly name: ProfileName;
|
|
366
|
+
readonly config: OkfitConfig;
|
|
367
|
+
readonly layout: Layout;
|
|
368
|
+
readonly check: (bundle: LoadedBundle) => ReadonlyArray<ProfileDiagnostic>;
|
|
369
|
+
}
|
|
370
|
+
//#endregion
|
|
371
|
+
//#region src/Profiles.d.ts
|
|
372
|
+
/**
|
|
373
|
+
* The profile registry (P-38). No third-party registration in phase 1; the
|
|
374
|
+
* `DEFAULTS < profile < file` merge is the CLI's (D-28).
|
|
375
|
+
*
|
|
376
|
+
* @public
|
|
377
|
+
*/
|
|
378
|
+
export declare class Profiles {
|
|
379
|
+
private constructor();
|
|
380
|
+
/** The `software-project` profile (spec 5). */
|
|
381
|
+
static readonly softwareProject: Profile;
|
|
382
|
+
/**
|
|
383
|
+
* `Option.none` for `"none"`, unknown names and anything not in
|
|
384
|
+
* `PROFILE_NAMES`; the CLI decides what that means (P-38). Exact match only.
|
|
385
|
+
*/
|
|
386
|
+
static readonly get: (name: string) => Option.Option<Profile>;
|
|
387
|
+
}
|
|
388
|
+
//#endregion
|
|
389
|
+
//#region src/Provenance.d.ts
|
|
390
|
+
/**
|
|
391
|
+
* A profiles-owned lint over committed provenance (S-8). NOT a `Profile`
|
|
392
|
+
* member and NOT a `ProfileDiagnostic` -- it returns core `Diagnostic`s with
|
|
393
|
+
* code `"generated-at-drift"`, a real `LintCode` member, so `severityFor`,
|
|
394
|
+
* the `[lint]` table, the renderers, the hook, and the MCP tool treat it
|
|
395
|
+
* like every other lint (S-7). `Profile.check` and `ProfileDiagnosticCode`
|
|
396
|
+
* are unchanged.
|
|
397
|
+
*
|
|
398
|
+
* Two tiers per concept (issue #19, body-digest design): when
|
|
399
|
+
* `generated.body_sha256` is present, drift is decided ENTIRELY by comparing it to
|
|
400
|
+
* `Derivation.bodyDigest` of the concept's current source -- no git call at
|
|
401
|
+
* all, so this works for a dirty worktree too (that is the point: an edited
|
|
402
|
+
* body is caught immediately, before it is even committed) and survives a
|
|
403
|
+
* squash/rebase merge that only rewrites commit dates, since the body
|
|
404
|
+
* itself, and therefore its digest, never changed. When `body_sha256` is
|
|
405
|
+
* absent (an un-migrated concept), this falls back to the original
|
|
406
|
+
* git-derived date comparison against `Derivation.generatedAt`, preserving
|
|
407
|
+
* `--skip-provenance`'s meaning for bundles that have not run `okfit sync`
|
|
408
|
+
* since this field was introduced.
|
|
409
|
+
*
|
|
410
|
+
* The tier-2 fallback returns `[]` the moment a `NotARepositoryError`
|
|
411
|
+
* surfaces: a bundle outside git has nothing to derive for any concept still
|
|
412
|
+
* on tier 2, so the first occurrence short-circuits the whole walk, not just
|
|
413
|
+
* the concept that triggered it (S-8). Emits no `range` (S-12, Judge note
|
|
414
|
+
* 7): `Diagnostic.range` is `Schema.optionalKey` and is simply omitted.
|
|
415
|
+
*
|
|
416
|
+
* `Provenance.lint` is total over severity (S-28, amending Judge note 3):
|
|
417
|
+
* when `OkfitConfig.severityFor(config, "generated-at-drift")` resolves to
|
|
418
|
+
* `"off"`, it returns `[]` before any per-concept work and before any git
|
|
419
|
+
* call, so it is safe to call at any severity and never needs to cast
|
|
420
|
+
* `"off"` away. `validate/run.ts` (the CLI) still gates on `"off"` before
|
|
421
|
+
* calling at all; the two agree by construction (both skip the walk).
|
|
422
|
+
*
|
|
423
|
+
* A third, optional options argument carries `skipGitTier`: when `true`, a
|
|
424
|
+
* concept that falls through to tier 2 (no `generated.body_sha256`
|
|
425
|
+
* recorded) is skipped entirely -- no `Derivation.generatedAt` call, no
|
|
426
|
+
* git spawn at all -- while tier 1 still runs, unaffected, for every
|
|
427
|
+
* concept that DOES carry a digest. This is a runtime skip, not a
|
|
428
|
+
* type-level narrowing: the R channel still lists `Git | GitHistory` even
|
|
429
|
+
* when every call happens to skip them, since the type describes what the
|
|
430
|
+
* function CAN require, not what one particular call ends up using.
|
|
431
|
+
* Defaults to `false`, so every existing caller keeps its current
|
|
432
|
+
* behavior unchanged.
|
|
433
|
+
*
|
|
434
|
+
* @public
|
|
435
|
+
*/
|
|
436
|
+
export declare class Provenance {
|
|
437
|
+
private constructor();
|
|
438
|
+
static readonly lint: (bundle: LoadedBundle, config: OkfitConfig, options?: {
|
|
439
|
+
readonly skipGitTier?: boolean;
|
|
440
|
+
}) => Effect.Effect<ReadonlyArray<Diagnostic>, GitHistoryError | GitCommandError | UnknownRefError | PlatformError.PlatformError, Git | GitHistory | FileSystem.FileSystem | Path.Path | Crypto.Crypto>;
|
|
441
|
+
}
|
|
19
442
|
//#endregion
|
|
20
|
-
export {
|
|
443
|
+
export type { GeneratedAtError, GeneratedAtOptions, GeneratedByError, GeneratedByOptions, GitHistoryShape, GitIdentity, Layout, LayoutDirectory, PathLogOptions, Profile, ProfileName, UncommittedReason, Writer };
|
|
21
444
|
//# sourceMappingURL=index.d.ts.map
|
package/index.js
CHANGED
|
@@ -1,15 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Names of the profiles this package ships.
|
|
9
|
-
*
|
|
10
|
-
* @public
|
|
11
|
-
*/
|
|
12
|
-
const PROFILE_NAMES = ["software-project"];
|
|
1
|
+
import { BodyCommitted, BodyProvenance, BodyUncommitted } from "./BodyProvenance.js";
|
|
2
|
+
import { GitHistory, GitHistoryError, PathHistoryEntry } from "./GitHistory.js";
|
|
3
|
+
import { AgentActorUnconfiguredError, Derivation, HumanActorUnresolvedError } from "./Derivation.js";
|
|
4
|
+
import { PROFILE_NAMES, ProfileDiagnostic, ProfileDiagnosticCode } from "./Profile.js";
|
|
5
|
+
import { Profiles } from "./Profiles.js";
|
|
6
|
+
import { Provenance } from "./Provenance.js";
|
|
13
7
|
|
|
14
|
-
|
|
15
|
-
export { PROFILE_NAMES };
|
|
8
|
+
export { AgentActorUnconfiguredError, BodyCommitted, BodyProvenance, BodyUncommitted, Derivation, GitHistory, GitHistoryError, HumanActorUnresolvedError, PROFILE_NAMES, PathHistoryEntry, ProfileDiagnostic, ProfileDiagnosticCode, Profiles, Provenance };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@okfit/profiles",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Named OKF configuration profiles for okfit, starting with the software-project profile.",
|
|
6
6
|
"keywords": [
|
|
@@ -34,9 +34,11 @@
|
|
|
34
34
|
},
|
|
35
35
|
"./package.json": "./package.json"
|
|
36
36
|
},
|
|
37
|
-
"
|
|
38
|
-
"@
|
|
39
|
-
"
|
|
37
|
+
"peerDependencies": {
|
|
38
|
+
"@effected/git": "^0.12.0",
|
|
39
|
+
"@effected/markdown": "^0.9.0",
|
|
40
|
+
"@okfit/core": "^0.3.0",
|
|
41
|
+
"effect": "4.0.0-rc.112"
|
|
40
42
|
},
|
|
41
43
|
"engines": {
|
|
42
44
|
"node": ">=24.11.0"
|