@invictus-group-ai/hooks 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.
- package/LICENSE +21 -0
- package/README.md +130 -0
- package/dist/bin.d.ts +11 -0
- package/dist/bin.d.ts.map +1 -0
- package/dist/bin.js +37 -0
- package/dist/bin.js.map +1 -0
- package/dist/engine.d.ts +53 -0
- package/dist/engine.d.ts.map +1 -0
- package/dist/engine.js +182 -0
- package/dist/engine.js.map +1 -0
- package/dist/git/post-commit.d.ts +43 -0
- package/dist/git/post-commit.d.ts.map +1 -0
- package/dist/git/post-commit.js +166 -0
- package/dist/git/post-commit.js.map +1 -0
- package/dist/git/pre-push.d.ts +43 -0
- package/dist/git/pre-push.d.ts.map +1 -0
- package/dist/git/pre-push.js +102 -0
- package/dist/git/pre-push.js.map +1 -0
- package/dist/git/prepare-commit-msg.d.ts +97 -0
- package/dist/git/prepare-commit-msg.d.ts.map +1 -0
- package/dist/git/prepare-commit-msg.js +623 -0
- package/dist/git/prepare-commit-msg.js.map +1 -0
- package/dist/git-activate.d.ts +25 -0
- package/dist/git-activate.d.ts.map +1 -0
- package/dist/git-activate.js +75 -0
- package/dist/git-activate.js.map +1 -0
- package/dist/hooks/db-guard.d.ts +31 -0
- package/dist/hooks/db-guard.d.ts.map +1 -0
- package/dist/hooks/db-guard.js +290 -0
- package/dist/hooks/db-guard.js.map +1 -0
- package/dist/hooks/index.d.ts +16 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/index.js +24 -0
- package/dist/hooks/index.js.map +1 -0
- package/dist/hooks/journal-nudge.d.ts +14 -0
- package/dist/hooks/journal-nudge.d.ts.map +1 -0
- package/dist/hooks/journal-nudge.js +60 -0
- package/dist/hooks/journal-nudge.js.map +1 -0
- package/dist/hooks/loc-recorder.d.ts +79 -0
- package/dist/hooks/loc-recorder.d.ts.map +1 -0
- package/dist/hooks/loc-recorder.js +183 -0
- package/dist/hooks/loc-recorder.js.map +1 -0
- package/dist/hooks/metrics-capture.d.ts +34 -0
- package/dist/hooks/metrics-capture.d.ts.map +1 -0
- package/dist/hooks/metrics-capture.js +275 -0
- package/dist/hooks/metrics-capture.js.map +1 -0
- package/dist/hooks/secret-guard.d.ts +19 -0
- package/dist/hooks/secret-guard.d.ts.map +1 -0
- package/dist/hooks/secret-guard.js +163 -0
- package/dist/hooks/secret-guard.js.map +1 -0
- package/dist/hooks/session-boot.d.ts +17 -0
- package/dist/hooks/session-boot.d.ts.map +1 -0
- package/dist/hooks/session-boot.js +123 -0
- package/dist/hooks/session-boot.js.map +1 -0
- package/dist/hooks/stop-gate.d.ts +17 -0
- package/dist/hooks/stop-gate.d.ts.map +1 -0
- package/dist/hooks/stop-gate.js +97 -0
- package/dist/hooks/stop-gate.js.map +1 -0
- package/dist/hooks/typecheck-on-edit.d.ts +18 -0
- package/dist/hooks/typecheck-on-edit.d.ts.map +1 -0
- package/dist/hooks/typecheck-on-edit.js +110 -0
- package/dist/hooks/typecheck-on-edit.js.map +1 -0
- package/dist/i18n/en.d.ts +45 -0
- package/dist/i18n/en.d.ts.map +1 -0
- package/dist/i18n/en.js +53 -0
- package/dist/i18n/en.js.map +1 -0
- package/dist/i18n/index.d.ts +35 -0
- package/dist/i18n/index.d.ts.map +1 -0
- package/dist/i18n/index.js +56 -0
- package/dist/i18n/index.js.map +1 -0
- package/dist/i18n/pt-BR.d.ts +12 -0
- package/dist/i18n/pt-BR.d.ts.map +1 -0
- package/dist/i18n/pt-BR.js +50 -0
- package/dist/i18n/pt-BR.js.map +1 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +12 -0
- package/dist/index.js.map +1 -0
- package/dist/kit-cli.d.ts +36 -0
- package/dist/kit-cli.d.ts.map +1 -0
- package/dist/kit-cli.js +68 -0
- package/dist/kit-cli.js.map +1 -0
- package/dist/metrics-schema.d.ts +215 -0
- package/dist/metrics-schema.d.ts.map +1 -0
- package/dist/metrics-schema.js +83 -0
- package/dist/metrics-schema.js.map +1 -0
- package/dist/shared.d.ts +81 -0
- package/dist/shared.d.ts.map +1 -0
- package/dist/shared.js +276 -0
- package/dist/shared.js.map +1 -0
- package/githooks/prepare-commit-msg +30 -0
- package/githooks/prepare-commit-msg.cmd +16 -0
- package/package.json +71 -0
- package/settings-template.json +97 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"en.d.ts","sourceRoot":"","sources":["../../src/i18n/en.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,eAAO,MAAM,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiDL,CAAC;AAEX,8EAA8E;AAC9E,MAAM,MAAM,UAAU,GAAG,MAAM,OAAO,EAAE,CAAC"}
|
package/dist/i18n/en.js
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* EN hook-message catalog — the CANONICAL source (D-003, ARCHITECTURE §9).
|
|
3
|
+
* Same catalog pattern as packages/kit/src/i18n: `MessageKey` is derived from
|
|
4
|
+
* this object, and pt-BR.ts is typed `Record<MessageKey, string>`, so a
|
|
5
|
+
* missing or extra translation FAILS THE BUILD (`tsc` runs before every test).
|
|
6
|
+
*
|
|
7
|
+
* TRANSLATION CONTRACT: the parts the agent must OBEY (workflow instructions
|
|
8
|
+
* like "write the migration to db/migrations/…", "run the invi-journal
|
|
9
|
+
* skill") keep IDENTICAL MEANING across languages — translate, never
|
|
10
|
+
* paraphrase. Machine tokens (paths, file names, skill names, `-- UP` /
|
|
11
|
+
* `-- DOWN`, `$VAR`, pattern/field names) are never translated.
|
|
12
|
+
*/
|
|
13
|
+
export const en = {
|
|
14
|
+
// ---- secret-guard (PreToolUse block, stderr + exit 2) ----
|
|
15
|
+
'secretGuard.blocked': 'Invictus secret-guard blocked this {tool} call: possible secret(s) detected.',
|
|
16
|
+
'secretGuard.finding': ' - {pattern} in {field}: {redacted}',
|
|
17
|
+
'secretGuard.more': ' … and {n} more',
|
|
18
|
+
'secretGuard.never': 'Never write live credentials into code, commands, or tracked files.',
|
|
19
|
+
'secretGuard.instead': 'Instead: put the value in a git-ignored .env file (or the environment) and reference it as $VAR / process.env.VAR.',
|
|
20
|
+
'secretGuard.falsePositive': 'False positive? Add a matching regex line to .invictus/secretsignore and retry.',
|
|
21
|
+
// ---- db-guard (PreToolUse block, stderr + exit 2) ----
|
|
22
|
+
'dbGuard.blocked': 'Invictus db-guard blocked a direct database write:',
|
|
23
|
+
'dbGuard.reason': ' - {reason}',
|
|
24
|
+
'dbGuard.workflowIntro': "Database mutations are the human's responsibility. Use the migration-file workflow instead:",
|
|
25
|
+
'dbGuard.step1': ' 1. Write the SQL/DDL to a new file: db/migrations/<YYYYMMDDHHMMSS>_<short_description>.sql',
|
|
26
|
+
'dbGuard.step2': ' 2. Include both sections: "-- UP" (the change) and "-- DOWN" (the rollback).',
|
|
27
|
+
'dbGuard.step3': ' 3. Tell the user the migration file is ready for review — a human applies it.',
|
|
28
|
+
'dbGuard.readOnly': 'Read-only commands (SELECT, EXPLAIN, \\d, --dry-run, status) are allowed.',
|
|
29
|
+
// ---- typecheck-on-edit (PostToolUse warn, stderr + exit 2) ----
|
|
30
|
+
'typecheck.header': 'Invictus typecheck-on-edit: tsc reports errors after editing {file} (project: {tsconfig}).',
|
|
31
|
+
'typecheck.omitted': '… {n} more line(s) omitted.',
|
|
32
|
+
'typecheck.warnOnly': 'This is a warning — the edit was applied. Fix the type errors before moving on.',
|
|
33
|
+
// ---- stop-gate (Stop block, stderr + exit 2) ----
|
|
34
|
+
'stopGate.blocked': 'Invictus stop-gate: commits were made this session but the journal has no entry since the last commit. ' +
|
|
35
|
+
'Run the invi-journal skill to checkpoint (what changed, key decisions, next step) before stopping. ' +
|
|
36
|
+
'This gate fires at most once per session.',
|
|
37
|
+
// ---- journal-nudge (PostToolUse additionalContext JSON) ----
|
|
38
|
+
'journalNudge.context': 'A git commit was just created but the Invictus journal has no entry from the last 5 minutes. ' +
|
|
39
|
+
'Run the invi-journal skill now to checkpoint: what this commit did, why, any decisions made, ' +
|
|
40
|
+
"and the next step. Keep it short — the journal is the team's memory spine.",
|
|
41
|
+
// ---- session-boot (SessionStart stdout context, clean markdown) ----
|
|
42
|
+
'sessionBoot.title': '## Invictus session context',
|
|
43
|
+
'sessionBoot.memory': '### Memory (journal/MEMORY.md)',
|
|
44
|
+
'sessionBoot.journal': '### Journal — {file}',
|
|
45
|
+
'sessionBoot.git': '### Git',
|
|
46
|
+
'sessionBoot.branch': '- Branch: `{branch}`',
|
|
47
|
+
'sessionBoot.workingTree': '- Working tree: {staged} staged, {modified} modified, {untracked} untracked',
|
|
48
|
+
'sessionBoot.recentCommits': '- Recent commits:',
|
|
49
|
+
'sessionBoot.todos': '### Open TODOs',
|
|
50
|
+
'sessionBoot.empty': '_No journal, git history, or TODOs found yet — fresh workspace._',
|
|
51
|
+
'sessionBoot.githooksActivated': '- Git hooks activated in this clone (core.hooksPath → .githooks, executable bit). If `git status` shows a mode change under .githooks/, commit it: later clones then come up active.',
|
|
52
|
+
};
|
|
53
|
+
//# sourceMappingURL=en.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"en.js","sourceRoot":"","sources":["../../src/i18n/en.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,MAAM,CAAC,MAAM,EAAE,GAAG;IAChB,6DAA6D;IAC7D,qBAAqB,EAAE,8EAA8E;IACrG,qBAAqB,EAAE,sCAAsC;IAC7D,kBAAkB,EAAE,kBAAkB;IACtC,mBAAmB,EAAE,qEAAqE;IAC1F,qBAAqB,EACnB,oHAAoH;IACtH,2BAA2B,EACzB,iFAAiF;IAEnF,yDAAyD;IACzD,iBAAiB,EAAE,oDAAoD;IACvE,gBAAgB,EAAE,cAAc;IAChC,uBAAuB,EAAE,6FAA6F;IACtH,eAAe,EAAE,8FAA8F;IAC/G,eAAe,EAAE,gFAAgF;IACjG,eAAe,EAAE,iFAAiF;IAClG,kBAAkB,EAAE,2EAA2E;IAE/F,kEAAkE;IAClE,kBAAkB,EAAE,4FAA4F;IAChH,mBAAmB,EAAE,6BAA6B;IAClD,oBAAoB,EAAE,iFAAiF;IAEvG,oDAAoD;IACpD,kBAAkB,EAChB,yGAAyG;QACzG,qGAAqG;QACrG,2CAA2C;IAE7C,+DAA+D;IAC/D,sBAAsB,EACpB,+FAA+F;QAC/F,+FAA+F;QAC/F,4EAA4E;IAE9E,uEAAuE;IACvE,mBAAmB,EAAE,6BAA6B;IAClD,oBAAoB,EAAE,gCAAgC;IACtD,qBAAqB,EAAE,sBAAsB;IAC7C,iBAAiB,EAAE,SAAS;IAC5B,oBAAoB,EAAE,sBAAsB;IAC5C,yBAAyB,EAAE,6EAA6E;IACxG,2BAA2B,EAAE,mBAAmB;IAChD,mBAAmB,EAAE,gBAAgB;IACrC,mBAAmB,EAAE,kEAAkE;IACvF,+BAA+B,EAC7B,sLAAsL;CAChL,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hook-message i18n (D-003, ARCHITECTURE §9) — same catalog pattern as
|
|
3
|
+
* packages/kit/src/i18n, self-contained (hooks must not depend on the kit).
|
|
4
|
+
*
|
|
5
|
+
* Hooks resolve the render language from the client repo's
|
|
6
|
+
* `manifest.language.render`; when the manifest is absent or the tag is
|
|
7
|
+
* unrecognized they FALL BACK TO pt-BR (the D-003 default client language).
|
|
8
|
+
* `INVICTUS_LANG` overrides for tests/debugging.
|
|
9
|
+
*
|
|
10
|
+
* The compile-time completeness check lives in the catalogs themselves:
|
|
11
|
+
* `MessageKey = keyof typeof en` and pt-BR is `Record<MessageKey, string>` —
|
|
12
|
+
* a missing or extra key fails the package build.
|
|
13
|
+
*/
|
|
14
|
+
import type { MessageKey } from './en.js';
|
|
15
|
+
export type { MessageKey } from './en.js';
|
|
16
|
+
export { en } from './en.js';
|
|
17
|
+
export { ptBR } from './pt-BR.js';
|
|
18
|
+
export type Lang = 'en' | 'pt-BR';
|
|
19
|
+
export declare const DEFAULT_RENDER_LANG: Lang;
|
|
20
|
+
export type Params = Record<string, string | number>;
|
|
21
|
+
export type Translate = (key: MessageKey, params?: Params) => string;
|
|
22
|
+
/** `pt*` → pt-BR, `en*` → en, anything else → null. */
|
|
23
|
+
export declare function normalizeLang(tag: string | null | undefined): Lang | null;
|
|
24
|
+
/** Interpolate `{param}` placeholders; unknown placeholders are left as-is. */
|
|
25
|
+
export declare function interpolate(template: string, params?: Params): string;
|
|
26
|
+
/** Build the `t()` function for one resolved language. */
|
|
27
|
+
export declare function makeT(lang: Lang): Translate;
|
|
28
|
+
/**
|
|
29
|
+
* Resolve the render language for a hook run:
|
|
30
|
+
* `INVICTUS_LANG` env override > `manifest.language.render` > pt-BR.
|
|
31
|
+
*/
|
|
32
|
+
export declare function resolveRenderLang(projectDir: string, env?: NodeJS.ProcessEnv): Lang;
|
|
33
|
+
/** One-call translator for a hook: manifest render language of `projectDir`. */
|
|
34
|
+
export declare function translatorFor(projectDir: string, env?: NodeJS.ProcessEnv): Translate;
|
|
35
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/i18n/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAIH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAG1C,YAAY,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAC1C,OAAO,EAAE,EAAE,EAAE,MAAM,SAAS,CAAC;AAC7B,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAElC,MAAM,MAAM,IAAI,GAAG,IAAI,GAAG,OAAO,CAAC;AAElC,eAAO,MAAM,mBAAmB,EAAE,IAAc,CAAC;AAIjD,MAAM,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,CAAC;AACrD,MAAM,MAAM,SAAS,GAAG,CAAC,GAAG,EAAE,UAAU,EAAE,MAAM,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC;AAErE,uDAAuD;AACvD,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,IAAI,GAAG,IAAI,CAMzE;AAED,+EAA+E;AAC/E,wBAAgB,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAKrE;AAED,0DAA0D;AAC1D,wBAAgB,KAAK,CAAC,IAAI,EAAE,IAAI,GAAG,SAAS,CAG3C;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,MAAM,EAAE,GAAG,GAAE,MAAM,CAAC,UAAe,GAAG,IAAI,CAMvF;AAED,gFAAgF;AAChF,wBAAgB,aAAa,CAAC,UAAU,EAAE,MAAM,EAAE,GAAG,GAAE,MAAM,CAAC,UAAe,GAAG,SAAS,CAExF"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hook-message i18n (D-003, ARCHITECTURE §9) — same catalog pattern as
|
|
3
|
+
* packages/kit/src/i18n, self-contained (hooks must not depend on the kit).
|
|
4
|
+
*
|
|
5
|
+
* Hooks resolve the render language from the client repo's
|
|
6
|
+
* `manifest.language.render`; when the manifest is absent or the tag is
|
|
7
|
+
* unrecognized they FALL BACK TO pt-BR (the D-003 default client language).
|
|
8
|
+
* `INVICTUS_LANG` overrides for tests/debugging.
|
|
9
|
+
*
|
|
10
|
+
* The compile-time completeness check lives in the catalogs themselves:
|
|
11
|
+
* `MessageKey = keyof typeof en` and pt-BR is `Record<MessageKey, string>` —
|
|
12
|
+
* a missing or extra key fails the package build.
|
|
13
|
+
*/
|
|
14
|
+
import { readManifestSafe } from '../shared.js';
|
|
15
|
+
import { en } from './en.js';
|
|
16
|
+
import { ptBR } from './pt-BR.js';
|
|
17
|
+
export { en } from './en.js';
|
|
18
|
+
export { ptBR } from './pt-BR.js';
|
|
19
|
+
export const DEFAULT_RENDER_LANG = 'pt-BR';
|
|
20
|
+
const CATALOGS = { en, 'pt-BR': ptBR };
|
|
21
|
+
/** `pt*` → pt-BR, `en*` → en, anything else → null. */
|
|
22
|
+
export function normalizeLang(tag) {
|
|
23
|
+
if (typeof tag !== 'string')
|
|
24
|
+
return null;
|
|
25
|
+
const lower = tag.trim().toLowerCase();
|
|
26
|
+
if (lower === 'en' || lower.startsWith('en-') || lower.startsWith('en_'))
|
|
27
|
+
return 'en';
|
|
28
|
+
if (lower === 'pt' || lower.startsWith('pt-') || lower.startsWith('pt_'))
|
|
29
|
+
return 'pt-BR';
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
/** Interpolate `{param}` placeholders; unknown placeholders are left as-is. */
|
|
33
|
+
export function interpolate(template, params) {
|
|
34
|
+
if (!params)
|
|
35
|
+
return template;
|
|
36
|
+
return template.replace(/\{([A-Za-z0-9_-]+)\}/g, (whole, name) => name in params ? String(params[name]) : whole);
|
|
37
|
+
}
|
|
38
|
+
/** Build the `t()` function for one resolved language. */
|
|
39
|
+
export function makeT(lang) {
|
|
40
|
+
const catalog = CATALOGS[lang];
|
|
41
|
+
return (key, params) => interpolate(catalog[key], params);
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Resolve the render language for a hook run:
|
|
45
|
+
* `INVICTUS_LANG` env override > `manifest.language.render` > pt-BR.
|
|
46
|
+
*/
|
|
47
|
+
export function resolveRenderLang(projectDir, env = {}) {
|
|
48
|
+
return (normalizeLang(env.INVICTUS_LANG) ??
|
|
49
|
+
normalizeLang(readManifestSafe(projectDir)?.language.render) ??
|
|
50
|
+
DEFAULT_RENDER_LANG);
|
|
51
|
+
}
|
|
52
|
+
/** One-call translator for a hook: manifest render language of `projectDir`. */
|
|
53
|
+
export function translatorFor(projectDir, env = {}) {
|
|
54
|
+
return makeT(resolveRenderLang(projectDir, env));
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/i18n/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,EAAE,EAAE,MAAM,SAAS,CAAC;AAE7B,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAGlC,OAAO,EAAE,EAAE,EAAE,MAAM,SAAS,CAAC;AAC7B,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAIlC,MAAM,CAAC,MAAM,mBAAmB,GAAS,OAAO,CAAC;AAEjD,MAAM,QAAQ,GAA6C,EAAE,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;AAKjF,uDAAuD;AACvD,MAAM,UAAU,aAAa,CAAC,GAA8B;IAC1D,IAAI,OAAO,GAAG,KAAK,QAAQ;QAAE,OAAO,IAAI,CAAC;IACzC,MAAM,KAAK,GAAG,GAAG,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IACvC,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC;IACtF,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC;QAAE,OAAO,OAAO,CAAC;IACzF,OAAO,IAAI,CAAC;AACd,CAAC;AAED,+EAA+E;AAC/E,MAAM,UAAU,WAAW,CAAC,QAAgB,EAAE,MAAe;IAC3D,IAAI,CAAC,MAAM;QAAE,OAAO,QAAQ,CAAC;IAC7B,OAAO,QAAQ,CAAC,OAAO,CAAC,uBAAuB,EAAE,CAAC,KAAK,EAAE,IAAY,EAAE,EAAE,CACvE,IAAI,IAAI,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAC9C,CAAC;AACJ,CAAC;AAED,0DAA0D;AAC1D,MAAM,UAAU,KAAK,CAAC,IAAU;IAC9B,MAAM,OAAO,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC;IAC/B,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE,CAAC,WAAW,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,CAAC;AAC5D,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,iBAAiB,CAAC,UAAkB,EAAE,MAAyB,EAAE;IAC/E,OAAO,CACL,aAAa,CAAC,GAAG,CAAC,aAAa,CAAC;QAChC,aAAa,CAAC,gBAAgB,CAAC,UAAU,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC;QAC5D,mBAAmB,CACpB,CAAC;AACJ,CAAC;AAED,gFAAgF;AAChF,MAAM,UAAU,aAAa,CAAC,UAAkB,EAAE,MAAyB,EAAE;IAC3E,OAAO,KAAK,CAAC,iBAAiB,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC,CAAC;AACnD,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Catálogo pt-BR das mensagens de hook (D-003). Traduções fiéis do EN
|
|
3
|
+
* canônico: o CONTEÚDO que o agente precisa obedecer mantém significado
|
|
4
|
+
* idêntico — tradução, nunca paráfrase. Tokens de máquina (caminhos, nomes
|
|
5
|
+
* de skill, `-- UP`/`-- DOWN`, `$VAR`, nomes de padrão/campo) não mudam.
|
|
6
|
+
*
|
|
7
|
+
* A anotação `Record<MessageKey, string>` é a checagem de completude em tempo
|
|
8
|
+
* de compilação: chave faltante OU sobrando aqui quebra o `tsc` do build.
|
|
9
|
+
*/
|
|
10
|
+
import type { MessageKey } from './en.js';
|
|
11
|
+
export declare const ptBR: Record<MessageKey, string>;
|
|
12
|
+
//# sourceMappingURL=pt-BR.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pt-BR.d.ts","sourceRoot":"","sources":["../../src/i18n/pt-BR.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAE1C,eAAO,MAAM,IAAI,EAAE,MAAM,CAAC,UAAU,EAAE,MAAM,CAiD3C,CAAC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Catálogo pt-BR das mensagens de hook (D-003). Traduções fiéis do EN
|
|
3
|
+
* canônico: o CONTEÚDO que o agente precisa obedecer mantém significado
|
|
4
|
+
* idêntico — tradução, nunca paráfrase. Tokens de máquina (caminhos, nomes
|
|
5
|
+
* de skill, `-- UP`/`-- DOWN`, `$VAR`, nomes de padrão/campo) não mudam.
|
|
6
|
+
*
|
|
7
|
+
* A anotação `Record<MessageKey, string>` é a checagem de completude em tempo
|
|
8
|
+
* de compilação: chave faltante OU sobrando aqui quebra o `tsc` do build.
|
|
9
|
+
*/
|
|
10
|
+
export const ptBR = {
|
|
11
|
+
// ---- secret-guard ----
|
|
12
|
+
'secretGuard.blocked': 'Invictus secret-guard bloqueou esta chamada de {tool}: possível(is) segredo(s) detectado(s).',
|
|
13
|
+
'secretGuard.finding': ' - {pattern} em {field}: {redacted}',
|
|
14
|
+
'secretGuard.more': ' … e mais {n}',
|
|
15
|
+
'secretGuard.never': 'Nunca escreva credenciais reais em código, comandos ou arquivos versionados.',
|
|
16
|
+
'secretGuard.instead': 'Em vez disso: coloque o valor em um arquivo .env fora do git (ou no ambiente) e referencie-o como $VAR / process.env.VAR.',
|
|
17
|
+
'secretGuard.falsePositive': 'Falso positivo? Adicione uma linha de regex correspondente em .invictus/secretsignore e tente de novo.',
|
|
18
|
+
// ---- db-guard ----
|
|
19
|
+
'dbGuard.blocked': 'Invictus db-guard bloqueou uma escrita direta no banco de dados:',
|
|
20
|
+
'dbGuard.reason': ' - {reason}',
|
|
21
|
+
'dbGuard.workflowIntro': 'Mutações de banco de dados são responsabilidade humana. Use o fluxo de arquivo de migração:',
|
|
22
|
+
'dbGuard.step1': ' 1. Escreva o SQL/DDL em um arquivo novo: db/migrations/<YYYYMMDDHHMMSS>_<descricao_curta>.sql',
|
|
23
|
+
'dbGuard.step2': ' 2. Inclua as duas seções: "-- UP" (a mudança) e "-- DOWN" (o rollback).',
|
|
24
|
+
'dbGuard.step3': ' 3. Avise o usuário que o arquivo de migração está pronto para revisão — um humano o aplica.',
|
|
25
|
+
'dbGuard.readOnly': 'Comandos somente leitura (SELECT, EXPLAIN, \\d, --dry-run, status) são permitidos.',
|
|
26
|
+
// ---- typecheck-on-edit ----
|
|
27
|
+
'typecheck.header': 'Invictus typecheck-on-edit: o tsc reporta erros após a edição de {file} (projeto: {tsconfig}).',
|
|
28
|
+
'typecheck.omitted': '… mais {n} linha(s) omitida(s).',
|
|
29
|
+
'typecheck.warnOnly': 'Isto é um aviso — a edição foi aplicada. Corrija os erros de tipo antes de seguir em frente.',
|
|
30
|
+
// ---- stop-gate ----
|
|
31
|
+
'stopGate.blocked': 'Invictus stop-gate: houve commits nesta sessão, mas o diário não tem nenhuma entrada desde o último commit. ' +
|
|
32
|
+
'Execute a skill invi-journal para registrar um checkpoint (o que mudou, decisões-chave, próximo passo) antes de parar. ' +
|
|
33
|
+
'Este gate dispara no máximo uma vez por sessão.',
|
|
34
|
+
// ---- journal-nudge ----
|
|
35
|
+
'journalNudge.context': 'Um commit git acabou de ser criado, mas o diário Invictus não tem nenhuma entrada dos últimos 5 minutos. ' +
|
|
36
|
+
'Execute a skill invi-journal agora para registrar um checkpoint: o que este commit fez, por quê, ' +
|
|
37
|
+
'as decisões tomadas e o próximo passo. Seja breve — o diário é a espinha de memória do time.',
|
|
38
|
+
// ---- session-boot ----
|
|
39
|
+
'sessionBoot.title': '## Contexto de sessão Invictus',
|
|
40
|
+
'sessionBoot.memory': '### Memória (journal/MEMORY.md)',
|
|
41
|
+
'sessionBoot.journal': '### Diário — {file}',
|
|
42
|
+
'sessionBoot.git': '### Git',
|
|
43
|
+
'sessionBoot.branch': '- Branch: `{branch}`',
|
|
44
|
+
'sessionBoot.workingTree': '- Árvore de trabalho: {staged} em stage, {modified} modificado(s), {untracked} não rastreado(s)',
|
|
45
|
+
'sessionBoot.recentCommits': '- Commits recentes:',
|
|
46
|
+
'sessionBoot.todos': '### TODOs abertos',
|
|
47
|
+
'sessionBoot.empty': '_Nenhum diário, histórico git ou TODO encontrado ainda — workspace novo._',
|
|
48
|
+
'sessionBoot.githooksActivated': '- Hooks de git ativados neste clone (core.hooksPath → .githooks, permissão de execução). Se o `git status` mostrar mudança de modo em .githooks/, commite: assim os próximos clones já vêm ativos.',
|
|
49
|
+
};
|
|
50
|
+
//# sourceMappingURL=pt-BR.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pt-BR.js","sourceRoot":"","sources":["../../src/i18n/pt-BR.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,MAAM,CAAC,MAAM,IAAI,GAA+B;IAC9C,yBAAyB;IACzB,qBAAqB,EAAE,8FAA8F;IACrH,qBAAqB,EAAE,sCAAsC;IAC7D,kBAAkB,EAAE,gBAAgB;IACpC,mBAAmB,EAAE,8EAA8E;IACnG,qBAAqB,EACnB,2HAA2H;IAC7H,2BAA2B,EACzB,wGAAwG;IAE1G,qBAAqB;IACrB,iBAAiB,EAAE,kEAAkE;IACrF,gBAAgB,EAAE,cAAc;IAChC,uBAAuB,EAAE,6FAA6F;IACtH,eAAe,EAAE,iGAAiG;IAClH,eAAe,EAAE,2EAA2E;IAC5F,eAAe,EAAE,+FAA+F;IAChH,kBAAkB,EAAE,oFAAoF;IAExG,8BAA8B;IAC9B,kBAAkB,EAAE,gGAAgG;IACpH,mBAAmB,EAAE,iCAAiC;IACtD,oBAAoB,EAAE,8FAA8F;IAEpH,sBAAsB;IACtB,kBAAkB,EAChB,8GAA8G;QAC9G,yHAAyH;QACzH,iDAAiD;IAEnD,0BAA0B;IAC1B,sBAAsB,EACpB,2GAA2G;QAC3G,mGAAmG;QACnG,8FAA8F;IAEhG,yBAAyB;IACzB,mBAAmB,EAAE,gCAAgC;IACrD,oBAAoB,EAAE,iCAAiC;IACvD,qBAAqB,EAAE,qBAAqB;IAC5C,iBAAiB,EAAE,SAAS;IAC5B,oBAAoB,EAAE,sBAAsB;IAC5C,yBAAyB,EAAE,iGAAiG;IAC5H,2BAA2B,EAAE,qBAAqB;IAClD,mBAAmB,EAAE,mBAAmB;IACxC,mBAAmB,EAAE,2EAA2E;IAChG,+BAA+B,EAC7B,oMAAoM;CACvM,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @invictus-group-ai/hooks — the 9-hook engine (8 Claude Code hooks + the git-side
|
|
3
|
+
* commit-metrics encoder). See ARCHITECTURE §7 for the binding contracts.
|
|
4
|
+
*/
|
|
5
|
+
export { runEngine } from './engine.js';
|
|
6
|
+
export type { EngineResult, HookContext, HookModule } from './engine.js';
|
|
7
|
+
export { HOOKS } from './hooks/index.js';
|
|
8
|
+
export { secretGuard, dbGuard, typecheckOnEdit, sessionBoot, metricsCapture, journalNudge, stopGate, locRecorder, } from './hooks/index.js';
|
|
9
|
+
export { agentLocPath, diffLineCounts, estimateLoc } from './hooks/loc-recorder.js';
|
|
10
|
+
export type { AgentLocEntry } from './hooks/loc-recorder.js';
|
|
11
|
+
export { aggregateAgentLoc, runPrepareCommitMsg, splitStagedLoc } from './git/prepare-commit-msg.js';
|
|
12
|
+
export type { AgentFileTotals } from './git/prepare-commit-msg.js';
|
|
13
|
+
export { sessionEndDataSchema, tokenCountsSchema, modelTag } from './metrics-schema.js';
|
|
14
|
+
export type { SessionEndData, TokenCounts } from './metrics-schema.js';
|
|
15
|
+
export { en, ptBR, makeT, normalizeLang, interpolate, resolveRenderLang, translatorFor, DEFAULT_RENDER_LANG, } from './i18n/index.js';
|
|
16
|
+
export type { Lang, MessageKey, Params, Translate } from './i18n/index.js';
|
|
17
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzE,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,OAAO,EACL,WAAW,EACX,OAAO,EACP,eAAe,EACf,WAAW,EACX,cAAc,EACd,YAAY,EACZ,QAAQ,EACR,WAAW,GACZ,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACpF,YAAY,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AACrG,YAAY,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACxF,YAAY,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACvE,OAAO,EACL,EAAE,EACF,IAAI,EACJ,KAAK,EACL,aAAa,EACb,WAAW,EACX,iBAAiB,EACjB,aAAa,EACb,mBAAmB,GACpB,MAAM,iBAAiB,CAAC;AACzB,YAAY,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @invictus-group-ai/hooks — the 9-hook engine (8 Claude Code hooks + the git-side
|
|
3
|
+
* commit-metrics encoder). See ARCHITECTURE §7 for the binding contracts.
|
|
4
|
+
*/
|
|
5
|
+
export { runEngine } from './engine.js';
|
|
6
|
+
export { HOOKS } from './hooks/index.js';
|
|
7
|
+
export { secretGuard, dbGuard, typecheckOnEdit, sessionBoot, metricsCapture, journalNudge, stopGate, locRecorder, } from './hooks/index.js';
|
|
8
|
+
export { agentLocPath, diffLineCounts, estimateLoc } from './hooks/loc-recorder.js';
|
|
9
|
+
export { aggregateAgentLoc, runPrepareCommitMsg, splitStagedLoc } from './git/prepare-commit-msg.js';
|
|
10
|
+
export { sessionEndDataSchema, tokenCountsSchema, modelTag } from './metrics-schema.js';
|
|
11
|
+
export { en, ptBR, makeT, normalizeLang, interpolate, resolveRenderLang, translatorFor, DEFAULT_RENDER_LANG, } from './i18n/index.js';
|
|
12
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,OAAO,EACL,WAAW,EACX,OAAO,EACP,eAAe,EACf,WAAW,EACX,cAAc,EACd,YAAY,EACZ,QAAQ,EACR,WAAW,GACZ,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAEpF,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAErG,OAAO,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAExF,OAAO,EACL,EAAE,EACF,IAAI,EACJ,KAAK,EACL,aAAa,EACb,WAAW,EACX,iBAAiB,EACjB,aAAa,EACb,mBAAmB,GACpB,MAAM,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Locating and launching the kit CLI (`invi`) from inside the hook engine.
|
|
3
|
+
*
|
|
4
|
+
* The hooks shell out to `invi sync` rather than importing the sync module:
|
|
5
|
+
* this package cannot depend on the kit (the kit depends on it), and the CLI
|
|
6
|
+
* path is the one actually covered by tests — a second in-process
|
|
7
|
+
* implementation would be a second thing to keep correct.
|
|
8
|
+
*/
|
|
9
|
+
/** `<repo>/node_modules/@invictus-group-ai/orchestra/bin/invi.js`, or null. */
|
|
10
|
+
export declare function findKitCli(root: string): string | null;
|
|
11
|
+
/** True when `invi keys provision` configured this machine for a platform. */
|
|
12
|
+
export declare function isProvisioned(root: string): boolean;
|
|
13
|
+
/** A session start never triggers a sync more often than this. */
|
|
14
|
+
export declare const BACKGROUND_SYNC_MIN_INTERVAL_SEC: number;
|
|
15
|
+
export type SpawnLike = (command: string, args: string[], options: {
|
|
16
|
+
cwd: string;
|
|
17
|
+
detached: boolean;
|
|
18
|
+
stdio: 'ignore';
|
|
19
|
+
windowsHide: boolean;
|
|
20
|
+
env: NodeJS.ProcessEnv;
|
|
21
|
+
}) => {
|
|
22
|
+
unref(): void;
|
|
23
|
+
};
|
|
24
|
+
export type BackgroundSyncOutcome = 'started' | 'skipped' | 'not-configured' | 'no-cli' | 'too-soon' | 'failed';
|
|
25
|
+
/**
|
|
26
|
+
* Start `invi sync` detached, so the session never waits on the network.
|
|
27
|
+
*
|
|
28
|
+
* Before this, metrics left the machine only on `git push`: a developer who
|
|
29
|
+
* works for days without pushing had days of sessions sitting on disk. A
|
|
30
|
+
* session start is the other moment worth using — frequent, and nothing waits
|
|
31
|
+
* on it. Throttled by a stamp under `.invictus/local/` so rapid restarts do
|
|
32
|
+
* not stack syncs. Every failure is silent: this is best-effort by design, and
|
|
33
|
+
* the push remains the guaranteed path.
|
|
34
|
+
*/
|
|
35
|
+
export declare function startBackgroundSync(root: string, env: NodeJS.ProcessEnv, spawnImpl?: SpawnLike, nowMs?: number): BackgroundSyncOutcome;
|
|
36
|
+
//# sourceMappingURL=kit-cli.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kit-cli.d.ts","sourceRoot":"","sources":["../src/kit-cli.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAOH,+EAA+E;AAC/E,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAGtD;AAED,8EAA8E;AAC9E,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAEnD;AAED,kEAAkE;AAClE,eAAO,MAAM,gCAAgC,QAAU,CAAC;AAExD,MAAM,MAAM,SAAS,GAAG,CACtB,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,EAAE,EACd,OAAO,EAAE;IACP,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,OAAO,CAAC;IAClB,KAAK,EAAE,QAAQ,CAAC;IAChB,WAAW,EAAE,OAAO,CAAC;IACrB,GAAG,EAAE,MAAM,CAAC,UAAU,CAAC;CACxB,KACE;IAAE,KAAK,IAAI,IAAI,CAAA;CAAE,CAAC;AAEvB,MAAM,MAAM,qBAAqB,GAAG,SAAS,GAAG,SAAS,GAAG,gBAAgB,GAAG,QAAQ,GAAG,UAAU,GAAG,QAAQ,CAAC;AAEhH;;;;;;;;;GASG;AACH,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,MAAM,EACZ,GAAG,EAAE,MAAM,CAAC,UAAU,EACtB,SAAS,GAAE,SAAyC,EACpD,KAAK,GAAE,MAAmB,GACzB,qBAAqB,CA4BvB"}
|
package/dist/kit-cli.js
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Locating and launching the kit CLI (`invi`) from inside the hook engine.
|
|
3
|
+
*
|
|
4
|
+
* The hooks shell out to `invi sync` rather than importing the sync module:
|
|
5
|
+
* this package cannot depend on the kit (the kit depends on it), and the CLI
|
|
6
|
+
* path is the one actually covered by tests — a second in-process
|
|
7
|
+
* implementation would be a second thing to keep correct.
|
|
8
|
+
*/
|
|
9
|
+
import { spawn } from 'node:child_process';
|
|
10
|
+
import { existsSync, statSync, writeFileSync } from 'node:fs';
|
|
11
|
+
import { join } from 'node:path';
|
|
12
|
+
import { ensureDir } from './shared.js';
|
|
13
|
+
/** `<repo>/node_modules/@invictus-group-ai/orchestra/bin/invi.js`, or null. */
|
|
14
|
+
export function findKitCli(root) {
|
|
15
|
+
const candidate = join(root, 'node_modules', '@invictus-group-ai', 'orchestra', 'bin', 'invi.js');
|
|
16
|
+
return existsSync(candidate) ? candidate : null;
|
|
17
|
+
}
|
|
18
|
+
/** True when `invi keys provision` configured this machine for a platform. */
|
|
19
|
+
export function isProvisioned(root) {
|
|
20
|
+
return existsSync(join(root, '.invictus', 'local', 'client.json'));
|
|
21
|
+
}
|
|
22
|
+
/** A session start never triggers a sync more often than this. */
|
|
23
|
+
export const BACKGROUND_SYNC_MIN_INTERVAL_SEC = 10 * 60;
|
|
24
|
+
/**
|
|
25
|
+
* Start `invi sync` detached, so the session never waits on the network.
|
|
26
|
+
*
|
|
27
|
+
* Before this, metrics left the machine only on `git push`: a developer who
|
|
28
|
+
* works for days without pushing had days of sessions sitting on disk. A
|
|
29
|
+
* session start is the other moment worth using — frequent, and nothing waits
|
|
30
|
+
* on it. Throttled by a stamp under `.invictus/local/` so rapid restarts do
|
|
31
|
+
* not stack syncs. Every failure is silent: this is best-effort by design, and
|
|
32
|
+
* the push remains the guaranteed path.
|
|
33
|
+
*/
|
|
34
|
+
export function startBackgroundSync(root, env, spawnImpl = spawn, nowMs = Date.now()) {
|
|
35
|
+
if (env['INVICTUS_SKIP_SYNC'])
|
|
36
|
+
return 'skipped';
|
|
37
|
+
if (!isProvisioned(root))
|
|
38
|
+
return 'not-configured';
|
|
39
|
+
const cli = findKitCli(root);
|
|
40
|
+
if (cli === null)
|
|
41
|
+
return 'no-cli';
|
|
42
|
+
const stamp = join(root, '.invictus', 'local', 'last-background-sync');
|
|
43
|
+
try {
|
|
44
|
+
if (nowMs - statSync(stamp).mtimeMs < BACKGROUND_SYNC_MIN_INTERVAL_SEC * 1000)
|
|
45
|
+
return 'too-soon';
|
|
46
|
+
}
|
|
47
|
+
catch {
|
|
48
|
+
/* never ran on this machine */
|
|
49
|
+
}
|
|
50
|
+
try {
|
|
51
|
+
if (!ensureDir(join(root, '.invictus', 'local')))
|
|
52
|
+
return 'failed';
|
|
53
|
+
writeFileSync(stamp, `${Math.floor(nowMs / 1000)}\n`, 'utf8');
|
|
54
|
+
const child = spawnImpl(process.execPath, [cli, 'sync'], {
|
|
55
|
+
cwd: root,
|
|
56
|
+
detached: true,
|
|
57
|
+
stdio: 'ignore',
|
|
58
|
+
windowsHide: true,
|
|
59
|
+
env,
|
|
60
|
+
});
|
|
61
|
+
child.unref();
|
|
62
|
+
return 'started';
|
|
63
|
+
}
|
|
64
|
+
catch {
|
|
65
|
+
return 'failed';
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=kit-cli.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kit-cli.js","sourceRoot":"","sources":["../src/kit-cli.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC9D,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,+EAA+E;AAC/E,MAAM,UAAU,UAAU,CAAC,IAAY;IACrC,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,EAAE,cAAc,EAAE,oBAAoB,EAAE,WAAW,EAAE,KAAK,EAAE,SAAS,CAAC,CAAC;IAClG,OAAO,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC;AAClD,CAAC;AAED,8EAA8E;AAC9E,MAAM,UAAU,aAAa,CAAC,IAAY;IACxC,OAAO,UAAU,CAAC,IAAI,CAAC,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,aAAa,CAAC,CAAC,CAAC;AACrE,CAAC;AAED,kEAAkE;AAClE,MAAM,CAAC,MAAM,gCAAgC,GAAG,EAAE,GAAG,EAAE,CAAC;AAgBxD;;;;;;;;;GASG;AACH,MAAM,UAAU,mBAAmB,CACjC,IAAY,EACZ,GAAsB,EACtB,YAAuB,KAA6B,EACpD,QAAgB,IAAI,CAAC,GAAG,EAAE;IAE1B,IAAI,GAAG,CAAC,oBAAoB,CAAC;QAAE,OAAO,SAAS,CAAC;IAChD,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC;QAAE,OAAO,gBAAgB,CAAC;IAClD,MAAM,GAAG,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC;IAC7B,IAAI,GAAG,KAAK,IAAI;QAAE,OAAO,QAAQ,CAAC;IAElC,MAAM,KAAK,GAAG,IAAI,CAAC,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,sBAAsB,CAAC,CAAC;IACvE,IAAI,CAAC;QACH,IAAI,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,OAAO,GAAG,gCAAgC,GAAG,IAAI;YAAE,OAAO,UAAU,CAAC;IACnG,CAAC;IAAC,MAAM,CAAC;QACP,+BAA+B;IACjC,CAAC;IAED,IAAI,CAAC;QACH,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,EAAE,WAAW,EAAE,OAAO,CAAC,CAAC;YAAE,OAAO,QAAQ,CAAC;QAClE,aAAa,CAAC,KAAK,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QAC9D,MAAM,KAAK,GAAG,SAAS,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,GAAG,EAAE,MAAM,CAAC,EAAE;YACvD,GAAG,EAAE,IAAI;YACT,QAAQ,EAAE,IAAI;YACd,KAAK,EAAE,QAAQ;YACf,WAAW,EAAE,IAAI;YACjB,GAAG;SACJ,CAAC,CAAC;QACH,KAAK,CAAC,KAAK,EAAE,CAAC;QACd,OAAO,SAAS,CAAC;IACnB,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,QAAQ,CAAC;IAClB,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shape of the `session.end` event payload written by the `metrics-capture`
|
|
3
|
+
* hook and consumed by the git-side `prepare-commit-msg` encoder.
|
|
4
|
+
*
|
|
5
|
+
* Single producer / single consumer, one schema — the trailer is DERIVED
|
|
6
|
+
* from these log entries, never computed twice (ARCHITECTURE §5).
|
|
7
|
+
* Metrics, never content: no prompt text, no file paths, no names.
|
|
8
|
+
*/
|
|
9
|
+
import { z } from 'zod';
|
|
10
|
+
export declare const tokenCountsSchema: z.ZodObject<{
|
|
11
|
+
/** input tokens */ i: z.ZodNumber;
|
|
12
|
+
/** output tokens */ o: z.ZodNumber;
|
|
13
|
+
/** cache-read tokens */ cr: z.ZodNumber;
|
|
14
|
+
/** cache-write (creation) tokens */ cw: z.ZodNumber;
|
|
15
|
+
}, "strict", z.ZodTypeAny, {
|
|
16
|
+
i: number;
|
|
17
|
+
o: number;
|
|
18
|
+
cr: number;
|
|
19
|
+
cw: number;
|
|
20
|
+
}, {
|
|
21
|
+
i: number;
|
|
22
|
+
o: number;
|
|
23
|
+
cr: number;
|
|
24
|
+
cw: number;
|
|
25
|
+
}>;
|
|
26
|
+
export type TokenCounts = z.infer<typeof tokenCountsSchema>;
|
|
27
|
+
/**
|
|
28
|
+
* `data` of a `session.end` event. `.passthrough()` keeps unknown fields so
|
|
29
|
+
* newer producers do not break older consumers (forward compatibility).
|
|
30
|
+
*/
|
|
31
|
+
export declare const sessionEndDataSchema: z.ZodObject<{
|
|
32
|
+
/**
|
|
33
|
+
* Which hook event produced this entry. `PreCommit` is the snapshot taken
|
|
34
|
+
* on PreToolUse just before the agent runs `git commit`: without it a
|
|
35
|
+
* commit made mid-session found no snapshot yet and shipped no trailer.
|
|
36
|
+
*/
|
|
37
|
+
event: z.ZodEnum<["SessionEnd", "SubagentStop", "PreCommit"]>;
|
|
38
|
+
/** Claude Code SessionEnd `reason` (e.g. `clear`, `logout`), if any. */
|
|
39
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
40
|
+
/** Token counts summed over the transcript. */
|
|
41
|
+
t: z.ZodObject<{
|
|
42
|
+
/** input tokens */ i: z.ZodNumber;
|
|
43
|
+
/** output tokens */ o: z.ZodNumber;
|
|
44
|
+
/** cache-read tokens */ cr: z.ZodNumber;
|
|
45
|
+
/** cache-write (creation) tokens */ cw: z.ZodNumber;
|
|
46
|
+
}, "strict", z.ZodTypeAny, {
|
|
47
|
+
i: number;
|
|
48
|
+
o: number;
|
|
49
|
+
cr: number;
|
|
50
|
+
cw: number;
|
|
51
|
+
}, {
|
|
52
|
+
i: number;
|
|
53
|
+
o: number;
|
|
54
|
+
cr: number;
|
|
55
|
+
cw: number;
|
|
56
|
+
}>;
|
|
57
|
+
/** Model mix, percent by short model tag (≤16 chars per tag). */
|
|
58
|
+
m: z.ZodRecord<z.ZodString, z.ZodNumber>;
|
|
59
|
+
/** Full id of the dominant model (for the Assisted-by trailer). */
|
|
60
|
+
model: z.ZodOptional<z.ZodString>;
|
|
61
|
+
/** Agent CLI at `name@version` (e.g. `claude-code@2.1.200`). */
|
|
62
|
+
tool: z.ZodOptional<z.ZodString>;
|
|
63
|
+
/** Estimated cost in integer cents (0 when the transcript has no costUSD). */
|
|
64
|
+
usdCents: z.ZodNumber;
|
|
65
|
+
/** User prompts observed in the transcript. */
|
|
66
|
+
prompts: z.ZodNumber;
|
|
67
|
+
/** Tool calls observed in the transcript. */
|
|
68
|
+
toolCalls: z.ZodNumber;
|
|
69
|
+
/**
|
|
70
|
+
* Edit-tool (Write|Edit|MultiEdit|NotebookEdit) calls that completed —
|
|
71
|
+
* their `tool_use` got a `tool_result` that is not a denial. Optional:
|
|
72
|
+
* entries written by hooks ≤0.2.0 predate the field.
|
|
73
|
+
*/
|
|
74
|
+
acc: z.ZodOptional<z.ZodNumber>;
|
|
75
|
+
/**
|
|
76
|
+
* Edit-tool calls denied before running: `tool_result` with
|
|
77
|
+
* `is_error: true` carrying a user-rejection / permission-denial text
|
|
78
|
+
* (or a `toolDenialKind` on the transcript line), plus edits killed by
|
|
79
|
+
* an explicit `[Request interrupted by user for tool use]` marker.
|
|
80
|
+
*/
|
|
81
|
+
rej: z.ZodOptional<z.ZodNumber>;
|
|
82
|
+
/**
|
|
83
|
+
* Active seconds: sum of consecutive transcript-timestamp gaps < 5 min
|
|
84
|
+
* (gaps ≥ 5 min count as idle). Always ≤ durSec. Optional: entries
|
|
85
|
+
* written by hooks ≤0.2.0 predate the field (consumers fall back to
|
|
86
|
+
* durSec — the old `act = dur` behavior).
|
|
87
|
+
*/
|
|
88
|
+
actSec: z.ZodOptional<z.ZodNumber>;
|
|
89
|
+
/** Wall-clock seconds between the first and last transcript timestamps. */
|
|
90
|
+
durSec: z.ZodNumber;
|
|
91
|
+
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
92
|
+
/**
|
|
93
|
+
* Which hook event produced this entry. `PreCommit` is the snapshot taken
|
|
94
|
+
* on PreToolUse just before the agent runs `git commit`: without it a
|
|
95
|
+
* commit made mid-session found no snapshot yet and shipped no trailer.
|
|
96
|
+
*/
|
|
97
|
+
event: z.ZodEnum<["SessionEnd", "SubagentStop", "PreCommit"]>;
|
|
98
|
+
/** Claude Code SessionEnd `reason` (e.g. `clear`, `logout`), if any. */
|
|
99
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
100
|
+
/** Token counts summed over the transcript. */
|
|
101
|
+
t: z.ZodObject<{
|
|
102
|
+
/** input tokens */ i: z.ZodNumber;
|
|
103
|
+
/** output tokens */ o: z.ZodNumber;
|
|
104
|
+
/** cache-read tokens */ cr: z.ZodNumber;
|
|
105
|
+
/** cache-write (creation) tokens */ cw: z.ZodNumber;
|
|
106
|
+
}, "strict", z.ZodTypeAny, {
|
|
107
|
+
i: number;
|
|
108
|
+
o: number;
|
|
109
|
+
cr: number;
|
|
110
|
+
cw: number;
|
|
111
|
+
}, {
|
|
112
|
+
i: number;
|
|
113
|
+
o: number;
|
|
114
|
+
cr: number;
|
|
115
|
+
cw: number;
|
|
116
|
+
}>;
|
|
117
|
+
/** Model mix, percent by short model tag (≤16 chars per tag). */
|
|
118
|
+
m: z.ZodRecord<z.ZodString, z.ZodNumber>;
|
|
119
|
+
/** Full id of the dominant model (for the Assisted-by trailer). */
|
|
120
|
+
model: z.ZodOptional<z.ZodString>;
|
|
121
|
+
/** Agent CLI at `name@version` (e.g. `claude-code@2.1.200`). */
|
|
122
|
+
tool: z.ZodOptional<z.ZodString>;
|
|
123
|
+
/** Estimated cost in integer cents (0 when the transcript has no costUSD). */
|
|
124
|
+
usdCents: z.ZodNumber;
|
|
125
|
+
/** User prompts observed in the transcript. */
|
|
126
|
+
prompts: z.ZodNumber;
|
|
127
|
+
/** Tool calls observed in the transcript. */
|
|
128
|
+
toolCalls: z.ZodNumber;
|
|
129
|
+
/**
|
|
130
|
+
* Edit-tool (Write|Edit|MultiEdit|NotebookEdit) calls that completed —
|
|
131
|
+
* their `tool_use` got a `tool_result` that is not a denial. Optional:
|
|
132
|
+
* entries written by hooks ≤0.2.0 predate the field.
|
|
133
|
+
*/
|
|
134
|
+
acc: z.ZodOptional<z.ZodNumber>;
|
|
135
|
+
/**
|
|
136
|
+
* Edit-tool calls denied before running: `tool_result` with
|
|
137
|
+
* `is_error: true` carrying a user-rejection / permission-denial text
|
|
138
|
+
* (or a `toolDenialKind` on the transcript line), plus edits killed by
|
|
139
|
+
* an explicit `[Request interrupted by user for tool use]` marker.
|
|
140
|
+
*/
|
|
141
|
+
rej: z.ZodOptional<z.ZodNumber>;
|
|
142
|
+
/**
|
|
143
|
+
* Active seconds: sum of consecutive transcript-timestamp gaps < 5 min
|
|
144
|
+
* (gaps ≥ 5 min count as idle). Always ≤ durSec. Optional: entries
|
|
145
|
+
* written by hooks ≤0.2.0 predate the field (consumers fall back to
|
|
146
|
+
* durSec — the old `act = dur` behavior).
|
|
147
|
+
*/
|
|
148
|
+
actSec: z.ZodOptional<z.ZodNumber>;
|
|
149
|
+
/** Wall-clock seconds between the first and last transcript timestamps. */
|
|
150
|
+
durSec: z.ZodNumber;
|
|
151
|
+
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
152
|
+
/**
|
|
153
|
+
* Which hook event produced this entry. `PreCommit` is the snapshot taken
|
|
154
|
+
* on PreToolUse just before the agent runs `git commit`: without it a
|
|
155
|
+
* commit made mid-session found no snapshot yet and shipped no trailer.
|
|
156
|
+
*/
|
|
157
|
+
event: z.ZodEnum<["SessionEnd", "SubagentStop", "PreCommit"]>;
|
|
158
|
+
/** Claude Code SessionEnd `reason` (e.g. `clear`, `logout`), if any. */
|
|
159
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
160
|
+
/** Token counts summed over the transcript. */
|
|
161
|
+
t: z.ZodObject<{
|
|
162
|
+
/** input tokens */ i: z.ZodNumber;
|
|
163
|
+
/** output tokens */ o: z.ZodNumber;
|
|
164
|
+
/** cache-read tokens */ cr: z.ZodNumber;
|
|
165
|
+
/** cache-write (creation) tokens */ cw: z.ZodNumber;
|
|
166
|
+
}, "strict", z.ZodTypeAny, {
|
|
167
|
+
i: number;
|
|
168
|
+
o: number;
|
|
169
|
+
cr: number;
|
|
170
|
+
cw: number;
|
|
171
|
+
}, {
|
|
172
|
+
i: number;
|
|
173
|
+
o: number;
|
|
174
|
+
cr: number;
|
|
175
|
+
cw: number;
|
|
176
|
+
}>;
|
|
177
|
+
/** Model mix, percent by short model tag (≤16 chars per tag). */
|
|
178
|
+
m: z.ZodRecord<z.ZodString, z.ZodNumber>;
|
|
179
|
+
/** Full id of the dominant model (for the Assisted-by trailer). */
|
|
180
|
+
model: z.ZodOptional<z.ZodString>;
|
|
181
|
+
/** Agent CLI at `name@version` (e.g. `claude-code@2.1.200`). */
|
|
182
|
+
tool: z.ZodOptional<z.ZodString>;
|
|
183
|
+
/** Estimated cost in integer cents (0 when the transcript has no costUSD). */
|
|
184
|
+
usdCents: z.ZodNumber;
|
|
185
|
+
/** User prompts observed in the transcript. */
|
|
186
|
+
prompts: z.ZodNumber;
|
|
187
|
+
/** Tool calls observed in the transcript. */
|
|
188
|
+
toolCalls: z.ZodNumber;
|
|
189
|
+
/**
|
|
190
|
+
* Edit-tool (Write|Edit|MultiEdit|NotebookEdit) calls that completed —
|
|
191
|
+
* their `tool_use` got a `tool_result` that is not a denial. Optional:
|
|
192
|
+
* entries written by hooks ≤0.2.0 predate the field.
|
|
193
|
+
*/
|
|
194
|
+
acc: z.ZodOptional<z.ZodNumber>;
|
|
195
|
+
/**
|
|
196
|
+
* Edit-tool calls denied before running: `tool_result` with
|
|
197
|
+
* `is_error: true` carrying a user-rejection / permission-denial text
|
|
198
|
+
* (or a `toolDenialKind` on the transcript line), plus edits killed by
|
|
199
|
+
* an explicit `[Request interrupted by user for tool use]` marker.
|
|
200
|
+
*/
|
|
201
|
+
rej: z.ZodOptional<z.ZodNumber>;
|
|
202
|
+
/**
|
|
203
|
+
* Active seconds: sum of consecutive transcript-timestamp gaps < 5 min
|
|
204
|
+
* (gaps ≥ 5 min count as idle). Always ≤ durSec. Optional: entries
|
|
205
|
+
* written by hooks ≤0.2.0 predate the field (consumers fall back to
|
|
206
|
+
* durSec — the old `act = dur` behavior).
|
|
207
|
+
*/
|
|
208
|
+
actSec: z.ZodOptional<z.ZodNumber>;
|
|
209
|
+
/** Wall-clock seconds between the first and last transcript timestamps. */
|
|
210
|
+
durSec: z.ZodNumber;
|
|
211
|
+
}, z.ZodTypeAny, "passthrough">>;
|
|
212
|
+
export type SessionEndData = z.infer<typeof sessionEndDataSchema>;
|
|
213
|
+
/** Shorten a model id to a trailer-safe tag: strip `claude-`, date suffix, cap 16. */
|
|
214
|
+
export declare function modelTag(modelId: string): string;
|
|
215
|
+
//# sourceMappingURL=metrics-schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"metrics-schema.d.ts","sourceRoot":"","sources":["../src/metrics-schema.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,eAAO,MAAM,iBAAiB;IAE1B,mBAAmB;IACnB,oBAAoB;IACpB,wBAAwB;IACxB,oCAAoC;;;;;;;;;;;EAE7B,CAAC;AAEZ,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAE5D;;;GAGG;AACH,eAAO,MAAM,oBAAoB;IAE7B;;;;OAIG;;IAEH,wEAAwE;;IAExE,+CAA+C;;QAvB/C,mBAAmB;QACnB,oBAAoB;QACpB,wBAAwB;QACxB,oCAAoC;;;;;;;;;;;;IAsBpC,iEAAiE;;IAEjE,mEAAmE;;IAEnE,gEAAgE;;IAMhE,8EAA8E;;IAE9E,+CAA+C;;IAE/C,6CAA6C;;IAE7C;;;;OAIG;;IAEH;;;;;OAKG;;IAEH;;;;;OAKG;;IAEH,2EAA2E;;;IA9C3E;;;;OAIG;;IAEH,wEAAwE;;IAExE,+CAA+C;;QAvB/C,mBAAmB;QACnB,oBAAoB;QACpB,wBAAwB;QACxB,oCAAoC;;;;;;;;;;;;IAsBpC,iEAAiE;;IAEjE,mEAAmE;;IAEnE,gEAAgE;;IAMhE,8EAA8E;;IAE9E,+CAA+C;;IAE/C,6CAA6C;;IAE7C;;;;OAIG;;IAEH;;;;;OAKG;;IAEH;;;;;OAKG;;IAEH,2EAA2E;;;IA9C3E;;;;OAIG;;IAEH,wEAAwE;;IAExE,+CAA+C;;QAvB/C,mBAAmB;QACnB,oBAAoB;QACpB,wBAAwB;QACxB,oCAAoC;;;;;;;;;;;;IAsBpC,iEAAiE;;IAEjE,mEAAmE;;IAEnE,gEAAgE;;IAMhE,8EAA8E;;IAE9E,+CAA+C;;IAE/C,6CAA6C;;IAE7C;;;;OAIG;;IAEH;;;;;OAKG;;IAEH;;;;;OAKG;;IAEH,2EAA2E;;gCAG/D,CAAC;AAEjB,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAElE,sFAAsF;AACtF,wBAAgB,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAMhD"}
|