@invictus-group-ai/core 0.5.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.
@@ -0,0 +1,281 @@
1
+ /**
2
+ * Shared types for the Invictus AI kit.
3
+ *
4
+ * These mirror the binding contracts in ARCHITECTURE.md:
5
+ * - Manifest — §3 `.invictus/manifest.json`
6
+ * - FragmentMeta — §4 fragment front-matter (the parsed YAML object)
7
+ * - EventLogEntry — §5 append-only per-dev event log
8
+ * - TrailerPayload — §6 commit-trailer CBOR payload
9
+ * - HookInput/HookOutput — Claude Code hook stdin/stdout contracts (§7)
10
+ *
11
+ * Runtime validation for these types lives in `schemas.ts` (zod).
12
+ */
13
+ /** Pseudonymous developer ID: `d_` + first 8 hex chars of sha256(salt:email). */
14
+ export type DevId = string;
15
+ export interface ManifestFragment {
16
+ /** Fragment ID, `category/slug` (e.g. `stack/nextjs-app-router`). */
17
+ id: string;
18
+ /** Fragment version (semver). */
19
+ version: string;
20
+ /** Full sha256 (64 hex chars) of the installed fragment file — the key for three-way merge on update. */
21
+ sha256: string;
22
+ }
23
+ export interface ManifestDev {
24
+ /** Pseudonymous dev ID (`d_xxxxxxxx`). The email↔id map stays client-side. */
25
+ id: DevId;
26
+ /** sha256 hex of the normalized git email. Never the email itself. */
27
+ gitEmailHash: string;
28
+ }
29
+ export interface ManifestLanguage {
30
+ /** Canonical source language of installed content (always `en` today). */
31
+ source: string;
32
+ /** Language client-facing prose is rendered in (e.g. `pt-BR`). */
33
+ render: string;
34
+ }
35
+ export interface ManifestProject {
36
+ baseBranch: string;
37
+ protectedBranches: string[];
38
+ /** Ticket regex source (configurable; legacy-compatible default `tk\\d+`). Must compile as a RegExp. */
39
+ ticketPattern: string;
40
+ /** The client's #1 named failure class, captured at the init interview. */
41
+ catastrophicRisk: string;
42
+ /**
43
+ * Which forge hosts `origin`, when the hostname does not say so.
44
+ * A self-hosted GitLab at `git.acme.com.br` is indistinguishable from a
45
+ * GitHub Enterprise host by name alone, and guessing wrong yields a
46
+ * confidently broken compare URL. Absent = infer from the hostname.
47
+ */
48
+ forge?: 'github' | 'gitlab' | 'gitea' | 'bitbucket';
49
+ /** Per-workspace command map, e.g. `{ backend: { test: "...", build: "...", lint: "..." } }`. */
50
+ workspaces?: Record<string, Record<string, string>>;
51
+ }
52
+ export interface Manifest {
53
+ /** Manifest schema version. This library implements v1. */
54
+ schema: 1;
55
+ /** Kit version that produced this install (semver). */
56
+ kit: string;
57
+ /** ISO-8601 timestamp of installation. */
58
+ installedAt: string;
59
+ language: ManifestLanguage;
60
+ /** Detected CLIs with adapters installed (e.g. `["claude-code"]`). */
61
+ runtime: string[];
62
+ project: ManifestProject;
63
+ fragments: ManifestFragment[];
64
+ skills: string[];
65
+ hooks: string[];
66
+ devs: ManifestDev[];
67
+ }
68
+ export interface FragmentDetect {
69
+ /** Dependency matchers against package.json / pyproject / composer / *.csproj (name → range). */
70
+ deps?: Record<string, string>;
71
+ /** Glob matchers against repo files. */
72
+ files?: string[];
73
+ /** Detection score contribution. */
74
+ score?: number;
75
+ }
76
+ /**
77
+ * The parsed front-matter object of a content fragment. YAML parsing itself
78
+ * is the kit's job; core only validates the parsed object.
79
+ */
80
+ export interface FragmentMeta {
81
+ /** `category/slug`, e.g. `stack/nextjs-app-router`. */
82
+ id: string;
83
+ /** Semver. */
84
+ version: string;
85
+ /** Canonical language (`en`; `pt-BR` is rendered at init). */
86
+ lang: string;
87
+ summary: string;
88
+ detect?: FragmentDetect;
89
+ requires: string[];
90
+ conflicts: string[];
91
+ /** Declared token count. Ceilings per class: stack ≤900, domain ≤1100, base ≤600. */
92
+ tokens: number;
93
+ }
94
+ export declare const EVENT_TYPES: readonly ["session.start", "session.end", "task.commit", "decision", "checkpoint", "verify", "gate", "hook.error", "journal.note", "req.event", "task.event"];
95
+ export type EventType = (typeof EVENT_TYPES)[number];
96
+ /**
97
+ * One line of `.invictus/log/<devId>.jsonl`. Append-only.
98
+ *
99
+ * `h` is the first 12 hex chars of sha256 over the canonical JSON of the
100
+ * entry WITHOUT `h` (i.e. `{v, ts, dev, sid, type, data, prev}` with keys
101
+ * sorted recursively). `prev` is the previous entry's `h` by the same dev,
102
+ * or null for the first entry — a per-dev hash chain.
103
+ */
104
+ export interface EventLogEntry {
105
+ v: 1;
106
+ /** Unix timestamp, seconds. */
107
+ ts: number;
108
+ dev: DevId;
109
+ /** Session ID (or a short hash of it). */
110
+ sid: string;
111
+ type: EventType;
112
+ /** Type-specific payload. Must be JSON-serializable. Metrics, never content. */
113
+ data: Record<string, unknown>;
114
+ /** 12-hex sha256 prefix of this entry's canonical JSON (sans `h`). */
115
+ h: string;
116
+ /** Previous entry hash by this dev, or null for the chain head. */
117
+ prev: string | null;
118
+ }
119
+ /** Tokens since last commit: input / output / cacheRead / cacheWrite. */
120
+ export interface TrailerTokenCounts {
121
+ i: number;
122
+ o: number;
123
+ cr: number;
124
+ cw: number;
125
+ }
126
+ /** Lines of code: AI-added / AI-deleted / human-added / human-deleted. */
127
+ export interface TrailerLocCounts {
128
+ aa: number;
129
+ ad: number;
130
+ ha: number;
131
+ hd: number;
132
+ }
133
+ /**
134
+ * The CBOR payload behind the `Invictus:` commit trailer. Short keys are the
135
+ * wire format — do not rename. ≤350 bytes of CBOR before compression.
136
+ * No free text. No email/name/hostname ever (LGPD: git history is immutable).
137
+ */
138
+ export interface TrailerPayload {
139
+ /** Payload schema version. */
140
+ v: 1;
141
+ /** Kit version, e.g. `invictus@1.4.2` (adoption tracking). */
142
+ kit: string;
143
+ /** Agent CLI + version, e.g. `claude-code@2.1.x` (multi-CLI ready). */
144
+ tool: string;
145
+ /** Pseudonymous developer ID (`d_xxxxxxxx`). NEVER an email. */
146
+ dev: DevId;
147
+ /** Client/org ID, e.g. `c_acme`. */
148
+ cli_ent: string;
149
+ /** Unix timestamp, seconds. */
150
+ ts: number;
151
+ /** Session-ID short hashes (hex) contributing to this commit. */
152
+ s: string[];
153
+ /** Token counts since last commit. */
154
+ t: TrailerTokenCounts;
155
+ /** Estimated cost in CENTS (integer — CBOR floats are not supported). */
156
+ usd: number;
157
+ /** Model mix, percent by short model tag (e.g. `{ s5: 90, h45: 10 }`). */
158
+ m: Record<string, number>;
159
+ loc: TrailerLocCounts;
160
+ /** Prompt count. */
161
+ px: number;
162
+ /** Tool-call count. */
163
+ tl: number;
164
+ /** Edit-tool accepts. */
165
+ acc: number;
166
+ /** Edit-tool rejects. */
167
+ rej: number;
168
+ /** Active seconds (user + cli). */
169
+ act: number;
170
+ /** Wall-clock seconds. */
171
+ dur: number;
172
+ /** Requirement IDs this commit advances (PO layer), e.g. `["REQ-104"]`. */
173
+ req: string[];
174
+ /** Milestone/phase, GSD-compatible (e.g. `m2.p3`). Optional. */
175
+ ph?: string;
176
+ /** 12-hex sha256 prefix of the event-log entry this trailer summarizes. */
177
+ j: string;
178
+ /** Previous Invictus trailer payload hash by this dev in this repo (12 hex), or null. */
179
+ prev: string | null;
180
+ }
181
+ export type HookEventName = 'PreToolUse' | 'PostToolUse' | 'UserPromptSubmit' | 'Notification' | 'Stop' | 'SubagentStop' | 'PreCompact' | 'SessionStart' | 'SessionEnd';
182
+ /**
183
+ * What Claude Code writes to a hook's stdin (JSON). Every event carries
184
+ * `session_id`, `transcript_path`, `cwd`, `hook_event_name`; the rest is
185
+ * event-specific. Unknown extra fields are preserved (forward compatibility).
186
+ */
187
+ export interface HookInput {
188
+ session_id: string;
189
+ transcript_path: string;
190
+ cwd: string;
191
+ hook_event_name: HookEventName | (string & {});
192
+ /** Correlates with OTel events (Claude Code ≥2.1.196). */
193
+ prompt_id?: string;
194
+ /** PreToolUse / PostToolUse. */
195
+ tool_name?: string;
196
+ /** PreToolUse / PostToolUse: the tool's input object. */
197
+ tool_input?: Record<string, unknown>;
198
+ /** PostToolUse: the tool's result. */
199
+ tool_response?: unknown;
200
+ /**
201
+ * Stop / SubagentStop: true when the agent is already continuing because of
202
+ * a previous stop hook. A stop-gate MUST short-circuit on this (§7).
203
+ */
204
+ stop_hook_active?: boolean;
205
+ /** UserPromptSubmit: the prompt text. Never persist it (metrics, not content). */
206
+ prompt?: string;
207
+ /** SessionStart: `startup` | `resume` | `clear` | `compact`. */
208
+ source?: string;
209
+ /** SessionEnd: e.g. `clear`, `logout`, `prompt_input_exit`, `other`. */
210
+ reason?: string;
211
+ /** Notification: the notification message. */
212
+ message?: string;
213
+ /** PreCompact: `manual` | `auto`. */
214
+ trigger?: string;
215
+ /** PreCompact: user-provided instructions. */
216
+ custom_instructions?: string;
217
+ [key: string]: unknown;
218
+ }
219
+ /**
220
+ * Hook exit-code semantics (Claude Code contract):
221
+ * - 0 — success. stdout is injected as context ONLY for SessionStart and
222
+ * UserPromptSubmit; elsewhere it is shown in verbose mode only.
223
+ * - 2 — blocking error. stderr is fed back to Claude (PreToolUse: blocks the
224
+ * tool; Stop: blocks stopping; UserPromptSubmit: blocks the prompt).
225
+ * - anything else — non-blocking error; stderr is shown to the user and
226
+ * execution continues (fail-open in-session; the fail-closed net is
227
+ * `.githooks/` + CI).
228
+ */
229
+ export type HookExitCode = 0 | 1 | 2;
230
+ export declare const HOOK_EXIT: {
231
+ readonly SUCCESS: 0;
232
+ readonly NON_BLOCKING_ERROR: 1;
233
+ readonly BLOCK: 2;
234
+ };
235
+ export interface HookSpecificOutput {
236
+ /** Which event this output is for, e.g. `PostToolUse`. */
237
+ hookEventName: string;
238
+ /** Agent-visible advice (UserPromptSubmit, SessionStart, PostToolUse). */
239
+ additionalContext?: string;
240
+ /** PreToolUse fine-grained permission decision. */
241
+ permissionDecision?: 'allow' | 'deny' | 'ask';
242
+ permissionDecisionReason?: string;
243
+ }
244
+ /**
245
+ * The structured (stdout JSON) hook output form. Printing this JSON on
246
+ * stdout with exit code 0 gives finer control than bare exit codes.
247
+ */
248
+ export interface HookJsonOutput {
249
+ /** false stops Claude entirely after the hook (takes precedence over `decision`). */
250
+ continue?: boolean;
251
+ /** Shown to the user when `continue` is false. */
252
+ stopReason?: string;
253
+ /** Hide stdout from verbose/transcript mode. */
254
+ suppressOutput?: boolean;
255
+ /**
256
+ * PreToolUse (legacy form) / PostToolUse / Stop / SubagentStop:
257
+ * `block` feeds `reason` back to Claude; `approve` (PreToolUse only)
258
+ * bypasses the permission prompt.
259
+ */
260
+ decision?: 'approve' | 'block';
261
+ /** Required when decision is `block`: what Claude should do instead. */
262
+ reason?: string;
263
+ /** Message shown to the user (not to Claude). */
264
+ systemMessage?: string;
265
+ hookSpecificOutput?: HookSpecificOutput;
266
+ }
267
+ /**
268
+ * What a hook module returns to the dispatcher (packages/hooks):
269
+ * either plain exit-code semantics with raw streams, or the JSON form
270
+ * (implies exit 0, JSON printed on stdout).
271
+ */
272
+ export type HookOutput = {
273
+ mode: 'exit';
274
+ exitCode: HookExitCode;
275
+ stdout?: string;
276
+ stderr?: string;
277
+ } | {
278
+ mode: 'json';
279
+ json: HookJsonOutput;
280
+ };
281
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAMH,iFAAiF;AACjF,MAAM,MAAM,KAAK,GAAG,MAAM,CAAC;AAE3B,MAAM,WAAW,gBAAgB;IAC/B,qEAAqE;IACrE,EAAE,EAAE,MAAM,CAAC;IACX,iCAAiC;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB,yGAAyG;IACzG,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,WAAW;IAC1B,8EAA8E;IAC9E,EAAE,EAAE,KAAK,CAAC;IACV,sEAAsE;IACtE,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,gBAAgB;IAC/B,0EAA0E;IAC1E,MAAM,EAAE,MAAM,CAAC;IACf,kEAAkE;IAClE,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,eAAe;IAC9B,UAAU,EAAE,MAAM,CAAC;IACnB,iBAAiB,EAAE,MAAM,EAAE,CAA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AAkB,CAAC;CACzC;AAED;;;;GAIG;AACH,MAAM,MAAM,UAAU,GAClB;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,YAAY,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,GAC1E;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,cAAc,CAAA;CAAE,CAAC"}
package/dist/types.js ADDED
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Shared types for the Invictus AI kit.
3
+ *
4
+ * These mirror the binding contracts in ARCHITECTURE.md:
5
+ * - Manifest — §3 `.invictus/manifest.json`
6
+ * - FragmentMeta — §4 fragment front-matter (the parsed YAML object)
7
+ * - EventLogEntry — §5 append-only per-dev event log
8
+ * - TrailerPayload — §6 commit-trailer CBOR payload
9
+ * - HookInput/HookOutput — Claude Code hook stdin/stdout contracts (§7)
10
+ *
11
+ * Runtime validation for these types lives in `schemas.ts` (zod).
12
+ */
13
+ // ---------------------------------------------------------------------------
14
+ // Event log (ARCHITECTURE §5)
15
+ // ---------------------------------------------------------------------------
16
+ export const EVENT_TYPES = [
17
+ 'session.start',
18
+ 'session.end',
19
+ 'task.commit',
20
+ 'decision',
21
+ 'checkpoint',
22
+ 'verify',
23
+ 'gate',
24
+ /**
25
+ * An engine-internal hook failure (packages/hooks fail-open path).
26
+ * First-class since core 0.2.0 — entries written by kit ≤0.1.x carry it as
27
+ * a `gate` event with `data.kind = 'hook.error'`; those old entries remain
28
+ * schema-valid (readers looking for hook failures must accept both forms).
29
+ */
30
+ 'hook.error',
31
+ 'journal.note',
32
+ 'req.event',
33
+ /**
34
+ * Task lifecycle written by the `invi task` verbs (phase 3):
35
+ * `{ task, event: "created" | "state", ... }` — creation and state-machine
36
+ * transitions of `.invictus/tasks/<id>/` records (content/PIPELINE.md §1/§3).
37
+ * Payload is metrics, never content (ids, counts, state names — no titles).
38
+ */
39
+ 'task.event',
40
+ ];
41
+ export const HOOK_EXIT = {
42
+ SUCCESS: 0,
43
+ NON_BLOCKING_ERROR: 1,
44
+ BLOCK: 2,
45
+ };
46
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAmGH,8EAA8E;AAC9E,8BAA8B;AAC9B,8EAA8E;AAE9E,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,eAAe;IACf,aAAa;IACb,aAAa;IACb,UAAU;IACV,YAAY;IACZ,QAAQ;IACR,MAAM;IACN;;;;;OAKG;IACH,YAAY;IACZ,cAAc;IACd,WAAW;IACX;;;;;OAKG;IACH,YAAY;CACJ,CAAC;AAkKX,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB,OAAO,EAAE,CAAC;IACV,kBAAkB,EAAE,CAAC;IACrB,KAAK,EAAE,CAAC;CACA,CAAC"}
package/package.json ADDED
@@ -0,0 +1,83 @@
1
+ {
2
+ "name": "@invictus-group-ai/core",
3
+ "version": "0.5.0",
4
+ "description": "Invictus AI core library: shared schemas, append-only event log, HMAC-signed commit-trailer codec, manifest helpers, pseudonymous dev IDs.",
5
+ "license": "MIT",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/invictus-group-ai/invictus-orchestra.git",
9
+ "directory": "packages/core"
10
+ },
11
+ "homepage": "https://github.com/invictus-group-ai/invictus-orchestra/tree/main/packages/core#readme",
12
+ "bugs": {
13
+ "url": "https://github.com/invictus-group-ai/invictus-orchestra/issues"
14
+ },
15
+ "keywords": [
16
+ "invictus",
17
+ "ai-observability",
18
+ "event-log",
19
+ "commit-trailer",
20
+ "claude-code"
21
+ ],
22
+ "type": "module",
23
+ "engines": {
24
+ "node": ">=20"
25
+ },
26
+ "exports": {
27
+ ".": {
28
+ "types": "./dist/index.d.ts",
29
+ "default": "./dist/index.js"
30
+ },
31
+ "./types": {
32
+ "types": "./dist/types.d.ts",
33
+ "default": "./dist/types.js"
34
+ },
35
+ "./schemas": {
36
+ "types": "./dist/schemas.d.ts",
37
+ "default": "./dist/schemas.js"
38
+ },
39
+ "./cbor": {
40
+ "types": "./dist/cbor.d.ts",
41
+ "default": "./dist/cbor.js"
42
+ },
43
+ "./eventlog": {
44
+ "types": "./dist/eventlog.d.ts",
45
+ "default": "./dist/eventlog.js"
46
+ },
47
+ "./trailer": {
48
+ "types": "./dist/trailer.d.ts",
49
+ "default": "./dist/trailer.js"
50
+ },
51
+ "./manifest": {
52
+ "types": "./dist/manifest.d.ts",
53
+ "default": "./dist/manifest.js"
54
+ },
55
+ "./devid": {
56
+ "types": "./dist/devid.d.ts",
57
+ "default": "./dist/devid.js"
58
+ }
59
+ },
60
+ "files": [
61
+ "dist",
62
+ "README.md"
63
+ ],
64
+ "sideEffects": false,
65
+ "publishConfig": {
66
+ "access": "public",
67
+ "provenance": true
68
+ },
69
+ "scripts": {
70
+ "build": "tsc -p tsconfig.json",
71
+ "typecheck": "tsc --noEmit -p tsconfig.json",
72
+ "prepack": "npm run build",
73
+ "test": "vitest run"
74
+ },
75
+ "dependencies": {
76
+ "zod": "^3.24.1"
77
+ },
78
+ "devDependencies": {
79
+ "@types/node": "^22.10.0",
80
+ "typescript": "^5.7.2",
81
+ "vitest": "^3.0.0"
82
+ }
83
+ }