@primitive.ai/prim 0.1.0-alpha.64 → 0.1.0-alpha.66
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/README.md +5 -4
- package/dist/{chunk-VYGY3OOX.js → chunk-BDGQEJA5.js} +1 -1
- package/dist/{chunk-7X7SFOPJ.js → chunk-CPSE3Y3T.js} +63 -1
- package/dist/{chunk-LNU44OJV.js → chunk-CZ24W5QU.js} +2 -1
- package/dist/{chunk-MCPHIB4W.js → chunk-DR66XM5L.js} +250 -96
- package/dist/{chunk-XTNMSS4C.js → chunk-TDRXHBEX.js} +15 -0
- package/dist/hooks/post-commit.js +2 -2
- package/dist/hooks/post-rewrite.js +194 -0
- package/dist/hooks/post-tool-use.js +7 -7
- package/dist/hooks/pre-tool-use.js +2 -2
- package/dist/hooks/prim-hook.js +17 -17
- package/dist/hooks/session-start.js +8 -3
- package/dist/index.js +156 -70
- package/package.json +5 -4
package/dist/index.js
CHANGED
|
@@ -1,4 +1,23 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
bindRepository,
|
|
4
|
+
compareSemver,
|
|
5
|
+
ensureEffectivePostCommitHook,
|
|
6
|
+
ensureEffectivePostRewriteHook,
|
|
7
|
+
ensurePostCommitHookAtPath,
|
|
8
|
+
ensurePostRewriteHookAtPath,
|
|
9
|
+
inspectEffectivePostCommitHook,
|
|
10
|
+
inspectEffectivePostRewriteHook,
|
|
11
|
+
postCommitHookBlock,
|
|
12
|
+
postRewriteHookBlock,
|
|
13
|
+
printJson,
|
|
14
|
+
registerSkillCommands,
|
|
15
|
+
resolveRepositoryBinding,
|
|
16
|
+
uninstallPostCommitHookAtPath,
|
|
17
|
+
uninstallPostRewriteHookAtPath,
|
|
18
|
+
uninstallProjectPostCommitHook,
|
|
19
|
+
uninstallProjectPostRewriteHook
|
|
20
|
+
} from "./chunk-DR66XM5L.js";
|
|
2
21
|
import {
|
|
3
22
|
bold,
|
|
4
23
|
boundedHealthError,
|
|
@@ -14,6 +33,9 @@ import {
|
|
|
14
33
|
daemonOrDirectGet,
|
|
15
34
|
formatDecisionsWarning
|
|
16
35
|
} from "./chunk-WS3MCNFD.js";
|
|
36
|
+
import {
|
|
37
|
+
fetchFeedbackCapability
|
|
38
|
+
} from "./chunk-KHZNYEUV.js";
|
|
17
39
|
import {
|
|
18
40
|
JOURNAL_DIR,
|
|
19
41
|
SESSIONS_DIR,
|
|
@@ -23,22 +45,6 @@ import {
|
|
|
23
45
|
pendingJournalStats,
|
|
24
46
|
readMovesFromPath
|
|
25
47
|
} from "./chunk-HIMWM526.js";
|
|
26
|
-
import {
|
|
27
|
-
bindRepository,
|
|
28
|
-
compareSemver,
|
|
29
|
-
ensureEffectivePostCommitHook,
|
|
30
|
-
ensurePostCommitHookAtPath,
|
|
31
|
-
inspectEffectivePostCommitHook,
|
|
32
|
-
postCommitHookBlock,
|
|
33
|
-
printJson,
|
|
34
|
-
registerSkillCommands,
|
|
35
|
-
resolveRepositoryBinding,
|
|
36
|
-
uninstallPostCommitHookAtPath,
|
|
37
|
-
uninstallProjectPostCommitHook
|
|
38
|
-
} from "./chunk-MCPHIB4W.js";
|
|
39
|
-
import {
|
|
40
|
-
fetchFeedbackCapability
|
|
41
|
-
} from "./chunk-KHZNYEUV.js";
|
|
42
48
|
import {
|
|
43
49
|
inspectWorkspaceId
|
|
44
50
|
} from "./chunk-UVIWZWM6.js";
|
|
@@ -49,7 +55,7 @@ import {
|
|
|
49
55
|
packageVersion,
|
|
50
56
|
pinnedHookCommand,
|
|
51
57
|
warmBinCache
|
|
52
|
-
} from "./chunk-
|
|
58
|
+
} from "./chunk-CZ24W5QU.js";
|
|
53
59
|
import {
|
|
54
60
|
canonicalGitRoot,
|
|
55
61
|
canonicalRepositoryPath,
|
|
@@ -59,7 +65,7 @@ import {
|
|
|
59
65
|
isValidRepoSyncId,
|
|
60
66
|
repoSyncId,
|
|
61
67
|
setRepoActive
|
|
62
|
-
} from "./chunk-
|
|
68
|
+
} from "./chunk-TDRXHBEX.js";
|
|
63
69
|
import {
|
|
64
70
|
HttpError,
|
|
65
71
|
REFRESH_TOKEN_PATH,
|
|
@@ -97,22 +103,57 @@ async function applyActivation(active) {
|
|
|
97
103
|
);
|
|
98
104
|
process.exit(1);
|
|
99
105
|
}
|
|
106
|
+
let phase = active ? "post-commit hook coverage" : "local deactivation";
|
|
100
107
|
try {
|
|
101
|
-
let
|
|
108
|
+
let binding;
|
|
102
109
|
let postCommitHook;
|
|
110
|
+
let postRewriteHook;
|
|
103
111
|
if (active) {
|
|
104
112
|
postCommitHook = ensureEffectivePostCommitHook(root).path;
|
|
105
|
-
|
|
113
|
+
try {
|
|
114
|
+
postRewriteHook = ensureEffectivePostRewriteHook(root).path;
|
|
115
|
+
} catch (error) {
|
|
116
|
+
const detail = error instanceof Error ? error.message : String(error);
|
|
117
|
+
process.stderr.write(`[prim] post-rewrite hook coverage is degraded: ${detail}
|
|
118
|
+
`);
|
|
119
|
+
}
|
|
120
|
+
phase = "repository binding";
|
|
121
|
+
binding = await bindRepository(root);
|
|
122
|
+
phase = "local activation";
|
|
106
123
|
}
|
|
107
124
|
setRepoActive(root, active);
|
|
108
125
|
await daemonRequest("statusline_invalidate", {}, { timeoutMs: 250 });
|
|
109
|
-
|
|
126
|
+
if (binding?.status === "pending") {
|
|
127
|
+
process.stderr.write(`[prim] Prim is enabled locally in ${root}
|
|
128
|
+
`);
|
|
129
|
+
process.stderr.write(
|
|
130
|
+
`[prim] repository ${binding.repositoryFullName} is not connected to Primitive; Moves still ingest into the team graph without repository-specific file attribution, Conflict Gate verification, or commit correlation
|
|
131
|
+
`
|
|
132
|
+
);
|
|
133
|
+
process.stderr.write(
|
|
134
|
+
`[prim] ask an organization owner or administrator to grant Primitive's GitHub App access to this repository through Primitive's GitHub App onboarding; binding retries automatically at the next agent SessionStart
|
|
135
|
+
`
|
|
136
|
+
);
|
|
137
|
+
} else {
|
|
138
|
+
process.stderr.write(`[prim] prim ${active ? "enabled" : "disabled"} in ${root}
|
|
110
139
|
`);
|
|
111
|
-
|
|
140
|
+
}
|
|
141
|
+
printJson({
|
|
142
|
+
active,
|
|
143
|
+
repo: root,
|
|
144
|
+
...binding ? {
|
|
145
|
+
bindingStatus: binding.status,
|
|
146
|
+
repositoryFullName: binding.repositoryFullName,
|
|
147
|
+
...binding.status === "connected" ? { repoSyncId: binding.repoSyncId } : {}
|
|
148
|
+
} : {},
|
|
149
|
+
...postCommitHook ? { postCommitHook } : {},
|
|
150
|
+
...postRewriteHook ? { postRewriteHook } : {}
|
|
151
|
+
});
|
|
112
152
|
} catch (err) {
|
|
113
153
|
const detail = err instanceof Error ? err.message : String(err);
|
|
114
154
|
process.stderr.write(
|
|
115
|
-
`[prim] failed to
|
|
155
|
+
active ? `[prim] failed to enable prim during ${phase}: ${detail}
|
|
156
|
+
` : `[prim] failed to disable prim: ${detail}
|
|
116
157
|
`
|
|
117
158
|
);
|
|
118
159
|
process.exit(1);
|
|
@@ -3917,7 +3958,28 @@ function checkWorkspaceIdentity() {
|
|
|
3917
3958
|
};
|
|
3918
3959
|
}
|
|
3919
3960
|
}
|
|
3920
|
-
function classifyRepositoryBinding(value,
|
|
3961
|
+
function classifyRepositoryBinding(value, current, active) {
|
|
3962
|
+
if (current.status === "pending") {
|
|
3963
|
+
if (value !== void 0) {
|
|
3964
|
+
return {
|
|
3965
|
+
name: "repo-binding",
|
|
3966
|
+
status: "fail",
|
|
3967
|
+
detail: `local repository binding is stale for ${current.repositoryFullName} \u2014 run \`prim enable\``
|
|
3968
|
+
};
|
|
3969
|
+
}
|
|
3970
|
+
if (!active) {
|
|
3971
|
+
return {
|
|
3972
|
+
name: "repo-binding",
|
|
3973
|
+
status: "fail",
|
|
3974
|
+
detail: "passive capture is inactive \u2014 run `prim enable`"
|
|
3975
|
+
};
|
|
3976
|
+
}
|
|
3977
|
+
return {
|
|
3978
|
+
name: "repo-binding",
|
|
3979
|
+
status: "warn",
|
|
3980
|
+
detail: `${current.repositoryFullName} is not connected to Primitive \u2014 local capture is active, but file scoping, Conflict Gate verification, and commit correlation are unavailable; ask an organization owner/admin to grant the Primitive GitHub App access (retried automatically next SessionStart)`
|
|
3981
|
+
};
|
|
3982
|
+
}
|
|
3921
3983
|
if (!isValidRepoSyncId(value)) {
|
|
3922
3984
|
return {
|
|
3923
3985
|
name: "repo-binding",
|
|
@@ -3925,7 +3987,7 @@ function classifyRepositoryBinding(value, currentServerValue) {
|
|
|
3925
3987
|
detail: "missing or invalid local prim.repoSyncId \u2014 run `prim enable`"
|
|
3926
3988
|
};
|
|
3927
3989
|
}
|
|
3928
|
-
if (
|
|
3990
|
+
if (value !== current.repoSyncId) {
|
|
3929
3991
|
return {
|
|
3930
3992
|
name: "repo-binding",
|
|
3931
3993
|
status: "fail",
|
|
@@ -3935,50 +3997,49 @@ function classifyRepositoryBinding(value, currentServerValue) {
|
|
|
3935
3997
|
return {
|
|
3936
3998
|
name: "repo-binding",
|
|
3937
3999
|
status: "ok",
|
|
3938
|
-
detail:
|
|
4000
|
+
detail: "local repository binding matches the current server binding"
|
|
3939
4001
|
};
|
|
3940
4002
|
}
|
|
3941
4003
|
async function checkRepositoryBinding() {
|
|
3942
4004
|
const root = process.cwd();
|
|
3943
4005
|
const local = repoSyncId(root);
|
|
3944
|
-
const localCheck = classifyRepositoryBinding(local);
|
|
3945
|
-
if (localCheck.status === "fail") return localCheck;
|
|
3946
4006
|
try {
|
|
3947
4007
|
const current = await resolveRepositoryBinding(root, {
|
|
3948
4008
|
signal: AbortSignal.timeout(CONNECTIVITY_TIMEOUT_MS),
|
|
3949
4009
|
quietRefresh: true
|
|
3950
4010
|
});
|
|
3951
|
-
return classifyRepositoryBinding(local, current
|
|
4011
|
+
return classifyRepositoryBinding(local, current, isRepoActiveForCapture(root));
|
|
3952
4012
|
} catch (error) {
|
|
3953
|
-
const
|
|
4013
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
4014
|
+
const detail = boundedHealthError(`could not verify the current repository binding \u2014 ${message}`) ?? "could not verify the current repository binding";
|
|
3954
4015
|
return {
|
|
3955
4016
|
name: "repo-binding",
|
|
3956
4017
|
status: "fail",
|
|
3957
|
-
detail
|
|
4018
|
+
detail
|
|
3958
4019
|
};
|
|
3959
4020
|
}
|
|
3960
4021
|
}
|
|
3961
|
-
function
|
|
4022
|
+
function classifyManagedHook(hookName, inspection) {
|
|
3962
4023
|
if (inspection.covered) {
|
|
3963
4024
|
return {
|
|
3964
|
-
name:
|
|
4025
|
+
name: hookName,
|
|
3965
4026
|
status: "ok",
|
|
3966
4027
|
detail: `effective and executable \xB7 ${inspection.kind} \xB7 ${inspection.hookPath}`
|
|
3967
4028
|
};
|
|
3968
4029
|
}
|
|
3969
4030
|
return {
|
|
3970
|
-
name:
|
|
4031
|
+
name: hookName,
|
|
3971
4032
|
status: "fail",
|
|
3972
4033
|
detail: `${inspection.reason ?? "uncovered"} \xB7 ${inspection.hookPath}`
|
|
3973
4034
|
};
|
|
3974
4035
|
}
|
|
3975
|
-
function
|
|
4036
|
+
function checkManagedHook(hookName, inspect) {
|
|
3976
4037
|
try {
|
|
3977
|
-
return
|
|
4038
|
+
return classifyManagedHook(hookName, inspect());
|
|
3978
4039
|
} catch (error) {
|
|
3979
4040
|
const detail = error instanceof Error ? error.message : String(error);
|
|
3980
4041
|
return {
|
|
3981
|
-
name:
|
|
4042
|
+
name: hookName,
|
|
3982
4043
|
status: /not a git repository/iu.test(detail) ? "warn" : "fail",
|
|
3983
4044
|
detail: detail.slice(0, 120)
|
|
3984
4045
|
};
|
|
@@ -4104,7 +4165,8 @@ async function collectChecks() {
|
|
|
4104
4165
|
checkFeedbackHooks(),
|
|
4105
4166
|
checkWorkspaceIdentity(),
|
|
4106
4167
|
await checkRepositoryBinding(),
|
|
4107
|
-
|
|
4168
|
+
checkManagedHook("post-commit", inspectEffectivePostCommitHook),
|
|
4169
|
+
checkManagedHook("post-rewrite", inspectEffectivePostRewriteHook),
|
|
4108
4170
|
...backend,
|
|
4109
4171
|
await checkFeedbackCapability()
|
|
4110
4172
|
];
|
|
@@ -4488,7 +4550,8 @@ import { dirname as dirname4, join as join7, resolve as resolve2 } from "path";
|
|
|
4488
4550
|
import { Option as Option3 } from "commander";
|
|
4489
4551
|
var PRE_COMMIT = { hookName: "pre-commit", binName: "prim-pre-commit" };
|
|
4490
4552
|
var POST_COMMIT = { hookName: "post-commit", binName: "prim-post-commit" };
|
|
4491
|
-
var
|
|
4553
|
+
var POST_REWRITE = { hookName: "post-rewrite", binName: "prim-post-rewrite" };
|
|
4554
|
+
var HOOKS = [PRE_COMMIT, POST_COMMIT, POST_REWRITE];
|
|
4492
4555
|
var GIT_TIMEOUT_MS = 1e3;
|
|
4493
4556
|
function blockMarkers(spec) {
|
|
4494
4557
|
return {
|
|
@@ -4517,6 +4580,7 @@ ${hookShim(spec.binName)}
|
|
|
4517
4580
|
}
|
|
4518
4581
|
function huskyBlock(spec) {
|
|
4519
4582
|
if (spec.hookName === POST_COMMIT.hookName) return postCommitHookBlock();
|
|
4583
|
+
if (spec.hookName === POST_REWRITE.hookName) return postRewriteHookBlock();
|
|
4520
4584
|
const { start, end } = blockMarkers(spec);
|
|
4521
4585
|
return `${start}
|
|
4522
4586
|
${hookShim(spec.binName)}
|
|
@@ -4524,6 +4588,7 @@ ${end}`;
|
|
|
4524
4588
|
}
|
|
4525
4589
|
function gatedBlock(spec) {
|
|
4526
4590
|
if (spec.hookName === POST_COMMIT.hookName) return postCommitHookBlock();
|
|
4591
|
+
if (spec.hookName === POST_REWRITE.hookName) return postRewriteHookBlock();
|
|
4527
4592
|
const { start, end } = blockMarkers(spec);
|
|
4528
4593
|
return `${start}
|
|
4529
4594
|
${gatedShim(spec.binName)}
|
|
@@ -4661,7 +4726,6 @@ var PASSTHROUGH_HOOKS = [
|
|
|
4661
4726
|
"post-checkout",
|
|
4662
4727
|
"post-merge",
|
|
4663
4728
|
"pre-push",
|
|
4664
|
-
"post-rewrite",
|
|
4665
4729
|
"pre-auto-gc",
|
|
4666
4730
|
"push-to-checkout",
|
|
4667
4731
|
"sendemail-validate",
|
|
@@ -4671,11 +4735,13 @@ var PASSTHROUGH_HOOKS = [
|
|
|
4671
4735
|
// with a query protocol, not a lifecycle event, so a bare exec stub is wrong.)
|
|
4672
4736
|
];
|
|
4673
4737
|
function globalHookScript(spec) {
|
|
4674
|
-
const chainExit = spec.hookName ===
|
|
4675
|
-
const
|
|
4676
|
-
const
|
|
4738
|
+
const chainExit = spec.hookName === PRE_COMMIT.hookName ? "|| exit $?" : "|| true";
|
|
4739
|
+
const managedBlock = spec.hookName === POST_COMMIT.hookName ? postCommitHookBlock() : spec.hookName === POST_REWRITE.hookName ? postRewriteHookBlock() : void 0;
|
|
4740
|
+
const invocation = managedBlock ?? gatedShim(spec.binName);
|
|
4741
|
+
const managedRepoGuard = managedBlock ? ` && ! grep -Fq '${blockMarkers(spec).start}' "$repo_hook" 2>/dev/null` : "";
|
|
4742
|
+
const beforeComments = managedBlock ? `${invocation}
|
|
4677
4743
|
` : "";
|
|
4678
|
-
const afterComments =
|
|
4744
|
+
const afterComments = managedBlock ? "" : `${invocation}
|
|
4679
4745
|
`;
|
|
4680
4746
|
return `#!/bin/sh
|
|
4681
4747
|
${beforeComments}# prim global ${spec.hookName} hook (core.hooksPath) \u2014 managed by prim; do not edit.
|
|
@@ -4685,7 +4751,7 @@ ${beforeComments}# prim global ${spec.hookName} hook (core.hooksPath) \u2014 man
|
|
|
4685
4751
|
# hook regardless, so inactive repos are unaffected.
|
|
4686
4752
|
${afterComments}common_dir=$(git rev-parse --git-common-dir 2>/dev/null) || exit 0
|
|
4687
4753
|
repo_hook="$common_dir/hooks/${spec.hookName}"
|
|
4688
|
-
if [ -x "$repo_hook" ] && ! grep -q '${PRIM_MANAGED_MARK}' "$repo_hook" 2>/dev/null; then
|
|
4754
|
+
if [ -x "$repo_hook" ] && ! grep -q '${PRIM_MANAGED_MARK}' "$repo_hook" 2>/dev/null${managedRepoGuard}; then
|
|
4689
4755
|
"$repo_hook" "$@" ${chainExit}
|
|
4690
4756
|
fi
|
|
4691
4757
|
exit 0
|
|
@@ -4711,6 +4777,8 @@ function writeOwnHooks() {
|
|
|
4711
4777
|
const path = resolve2(PRIM_GIT_HOOKS_DIR, spec.hookName);
|
|
4712
4778
|
if (spec.hookName === POST_COMMIT.hookName) {
|
|
4713
4779
|
ensurePostCommitHookAtPath(path, globalHookScript(spec));
|
|
4780
|
+
} else if (spec.hookName === POST_REWRITE.hookName) {
|
|
4781
|
+
writeFileSync4(path, globalHookScript(spec), { mode: 493 });
|
|
4714
4782
|
} else {
|
|
4715
4783
|
writeFileSync4(path, globalHookScript(spec), { mode: 493 });
|
|
4716
4784
|
}
|
|
@@ -4724,6 +4792,10 @@ function appendPrimBlock(hookPath, spec) {
|
|
|
4724
4792
|
ensurePostCommitHookAtPath(hookPath);
|
|
4725
4793
|
return;
|
|
4726
4794
|
}
|
|
4795
|
+
if (spec.hookName === POST_REWRITE.hookName) {
|
|
4796
|
+
ensurePostRewriteHookAtPath(hookPath);
|
|
4797
|
+
return;
|
|
4798
|
+
}
|
|
4727
4799
|
mergePrimBlock(hookPath, gatedBlock(spec), spec.binName);
|
|
4728
4800
|
}
|
|
4729
4801
|
function stripPrimBlock(hookPath, spec) {
|
|
@@ -4731,6 +4803,10 @@ function stripPrimBlock(hookPath, spec) {
|
|
|
4731
4803
|
uninstallPostCommitHookAtPath(hookPath);
|
|
4732
4804
|
return;
|
|
4733
4805
|
}
|
|
4806
|
+
if (spec.hookName === POST_REWRITE.hookName) {
|
|
4807
|
+
uninstallPostRewriteHookAtPath(hookPath);
|
|
4808
|
+
return;
|
|
4809
|
+
}
|
|
4734
4810
|
if (!existsSync7(hookPath)) return;
|
|
4735
4811
|
const existing = readFileSync6(hookPath, "utf-8");
|
|
4736
4812
|
const primCreated = existing.includes(PRIM_CREATED_MARK);
|
|
@@ -4810,22 +4886,29 @@ function uninstallGlobalHooks() {
|
|
|
4810
4886
|
console.log("No prim global git hooks found.");
|
|
4811
4887
|
}
|
|
4812
4888
|
function installHooks(gitRoot, target) {
|
|
4813
|
-
|
|
4814
|
-
|
|
4815
|
-
|
|
4816
|
-
|
|
4817
|
-
installToDotGit(gitRoot, spec);
|
|
4818
|
-
}
|
|
4889
|
+
if (target === "husky") {
|
|
4890
|
+
installToHusky(gitRoot, PRE_COMMIT);
|
|
4891
|
+
} else {
|
|
4892
|
+
installToDotGit(gitRoot, PRE_COMMIT);
|
|
4819
4893
|
}
|
|
4820
4894
|
const postCommit = ensureEffectivePostCommitHook(gitRoot);
|
|
4821
4895
|
console.log(
|
|
4822
4896
|
`${postCommit.changed ? "Installed" : "Refreshed"} effective post-commit hook at ${postCommit.path}.`
|
|
4823
4897
|
);
|
|
4898
|
+
try {
|
|
4899
|
+
const postRewrite = ensureEffectivePostRewriteHook(gitRoot);
|
|
4900
|
+
console.log(
|
|
4901
|
+
`${postRewrite.changed ? "Installed" : "Refreshed"} effective post-rewrite hook at ${postRewrite.path}.`
|
|
4902
|
+
);
|
|
4903
|
+
} catch (error) {
|
|
4904
|
+
const detail = error instanceof Error ? error.message : String(error);
|
|
4905
|
+
console.error(`[prim] post-rewrite hook coverage is degraded: ${detail}`);
|
|
4906
|
+
}
|
|
4824
4907
|
}
|
|
4825
4908
|
function registerHooksCommands(program2) {
|
|
4826
4909
|
const hooks = program2.command("hooks").description("Manage git hooks");
|
|
4827
4910
|
hooks.command("install").description(
|
|
4828
|
-
"Install the prim git hooks \u2014 pre-commit + post-commit (auto-detects Husky; use --target to override)"
|
|
4911
|
+
"Install the prim git hooks \u2014 pre-commit + post-commit + post-rewrite (auto-detects Husky; use --target to override)"
|
|
4829
4912
|
).addOption(
|
|
4830
4913
|
new Option3("--target <where>", "install destination; bypasses Husky detection").choices([
|
|
4831
4914
|
"husky",
|
|
@@ -4883,27 +4966,30 @@ function registerHooksCommands(program2) {
|
|
|
4883
4966
|
}
|
|
4884
4967
|
const gitRoot = getGitRoot();
|
|
4885
4968
|
const hooksDir = projectHooksDir(gitRoot);
|
|
4886
|
-
|
|
4887
|
-
|
|
4888
|
-
|
|
4889
|
-
|
|
4890
|
-
|
|
4891
|
-
}
|
|
4892
|
-
|
|
4893
|
-
|
|
4894
|
-
|
|
4969
|
+
const preCommitPath = resolve2(hooksDir, PRE_COMMIT.hookName);
|
|
4970
|
+
if (!existsSync7(preCommitPath)) {
|
|
4971
|
+
console.log(`No ${PRE_COMMIT.hookName} hook found.`);
|
|
4972
|
+
} else if (containsPrimHook(readFileSync6(preCommitPath, "utf-8"), PRE_COMMIT.binName)) {
|
|
4973
|
+
unlinkSync2(preCommitPath);
|
|
4974
|
+
console.log(`Removed ${PRE_COMMIT.hookName} hook at ${preCommitPath}`);
|
|
4975
|
+
} else {
|
|
4976
|
+
console.log(
|
|
4977
|
+
`Left ${PRE_COMMIT.hookName} hook at ${preCommitPath} untouched (not a prim hook).`
|
|
4978
|
+
);
|
|
4979
|
+
}
|
|
4980
|
+
for (const [hookName, uninstall] of [
|
|
4981
|
+
[POST_COMMIT.hookName, uninstallProjectPostCommitHook],
|
|
4982
|
+
[POST_REWRITE.hookName, uninstallProjectPostRewriteHook]
|
|
4983
|
+
]) {
|
|
4984
|
+
const result = uninstall(gitRoot);
|
|
4985
|
+
if (!result.changed) {
|
|
4986
|
+
console.log(`No Prim ${hookName} block found at ${result.path}.`);
|
|
4987
|
+
} else if (result.removedFile) {
|
|
4988
|
+
console.log(`Removed Prim-created ${hookName} hook at ${result.path}.`);
|
|
4895
4989
|
} else {
|
|
4896
|
-
console.log(`
|
|
4990
|
+
console.log(`Removed the Prim ${hookName} block from ${result.path}.`);
|
|
4897
4991
|
}
|
|
4898
4992
|
}
|
|
4899
|
-
const postCommit = uninstallProjectPostCommitHook(gitRoot);
|
|
4900
|
-
if (!postCommit.changed) {
|
|
4901
|
-
console.log(`No Prim post-commit block found at ${postCommit.path}.`);
|
|
4902
|
-
} else if (postCommit.removedFile) {
|
|
4903
|
-
console.log(`Removed Prim-created post-commit hook at ${postCommit.path}.`);
|
|
4904
|
-
} else {
|
|
4905
|
-
console.log(`Removed the Prim post-commit block from ${postCommit.path}.`);
|
|
4906
|
-
}
|
|
4907
4993
|
});
|
|
4908
4994
|
}
|
|
4909
4995
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@primitive.ai/prim",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.66",
|
|
4
4
|
"description": "CLI for Primitive's decision graph — passive decision capture, conflict gate, and team presence",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -31,6 +31,7 @@
|
|
|
31
31
|
"prim": "dist/index.js",
|
|
32
32
|
"prim-pre-commit": "dist/hooks/pre-commit.js",
|
|
33
33
|
"prim-post-commit": "dist/hooks/post-commit.js",
|
|
34
|
+
"prim-post-rewrite": "dist/hooks/post-rewrite.js",
|
|
34
35
|
"prim-hook": "dist/hooks/prim-hook.js",
|
|
35
36
|
"prim-pre-tool-use": "dist/hooks/pre-tool-use.js",
|
|
36
37
|
"prim-post-tool-use": "dist/hooks/post-tool-use.js",
|
|
@@ -47,9 +48,9 @@
|
|
|
47
48
|
"SKILL.md"
|
|
48
49
|
],
|
|
49
50
|
"scripts": {
|
|
50
|
-
"build": "tsup src/index.ts src/hooks/pre-commit.ts src/hooks/post-commit.ts src/hooks/prim-hook.ts src/hooks/pre-tool-use.ts src/hooks/post-tool-use.ts src/hooks/session-start.ts src/hooks/session-end.ts --format esm --clean && tsup src/statusline-main.ts src/daemon/server.ts --format esm --splitting false",
|
|
51
|
-
"postbuild": "chmod +x ./dist/index.js ./dist/statusline-main.js ./dist/hooks/pre-commit.js ./dist/hooks/post-commit.js ./dist/hooks/prim-hook.js ./dist/hooks/pre-tool-use.js ./dist/hooks/post-tool-use.js ./dist/hooks/session-start.js ./dist/hooks/session-end.js ./dist/daemon/server.js",
|
|
52
|
-
"dev": "tsup src/index.ts src/statusline-main.ts src/hooks/pre-commit.ts src/hooks/post-commit.ts src/hooks/prim-hook.ts src/hooks/pre-tool-use.ts src/hooks/post-tool-use.ts src/hooks/session-start.ts src/hooks/session-end.ts src/daemon/server.ts --format esm --watch --clean --splitting false",
|
|
51
|
+
"build": "tsup src/index.ts src/hooks/pre-commit.ts src/hooks/post-commit.ts src/hooks/post-rewrite.ts src/hooks/prim-hook.ts src/hooks/pre-tool-use.ts src/hooks/post-tool-use.ts src/hooks/session-start.ts src/hooks/session-end.ts --format esm --clean && tsup src/statusline-main.ts src/daemon/server.ts --format esm --splitting false",
|
|
52
|
+
"postbuild": "chmod +x ./dist/index.js ./dist/statusline-main.js ./dist/hooks/pre-commit.js ./dist/hooks/post-commit.js ./dist/hooks/post-rewrite.js ./dist/hooks/prim-hook.js ./dist/hooks/pre-tool-use.js ./dist/hooks/post-tool-use.js ./dist/hooks/session-start.js ./dist/hooks/session-end.js ./dist/daemon/server.js",
|
|
53
|
+
"dev": "tsup src/index.ts src/statusline-main.ts src/hooks/pre-commit.ts src/hooks/post-commit.ts src/hooks/post-rewrite.ts src/hooks/prim-hook.ts src/hooks/pre-tool-use.ts src/hooks/post-tool-use.ts src/hooks/session-start.ts src/hooks/session-end.ts src/daemon/server.ts --format esm --watch --clean --splitting false",
|
|
53
54
|
"clean": "rm -rf dist coverage",
|
|
54
55
|
"lint": "biome check src/",
|
|
55
56
|
"format": "biome check --fix src/",
|