@davesheffer/hunch 1.47.1 → 1.48.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 +105 -201
- package/NOTICE +10 -3
- package/README.md +8 -6
- package/dist/cli/index.js +31 -14
- package/dist/core/correction.js +4 -3
- package/dist/core/format.d.ts +3 -1
- package/dist/core/format.js +14 -2
- package/dist/core/reviewMemory.d.ts +1 -1
- package/dist/core/subagentrole.d.ts +6 -0
- package/dist/core/subagentrole.js +32 -0
- package/dist/extractors/parse.js +20 -30
- package/dist/integrations/hooks.js +10 -8
- package/dist/store/hunchStore.d.ts +10 -6
- package/dist/store/hunchStore.js +96 -27
- package/dist/synthesis/prContext.d.ts +75 -0
- package/dist/synthesis/prContext.js +265 -0
- package/dist/synthesis/provider.d.ts +38 -0
- package/dist/synthesis/provider.js +110 -13
- package/dist/synthesis/synthesize.d.ts +14 -0
- package/dist/synthesis/synthesize.js +46 -6
- package/package.json +2 -2
- package/server.json +2 -2
package/LICENSE
CHANGED
|
@@ -1,201 +1,105 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
-
distribution, then any Derivative Works that You distribute must
|
|
108
|
-
include a readable copy of the attribution notices contained
|
|
109
|
-
within such NOTICE file, excluding those notices that do not
|
|
110
|
-
pertain to any part of the Derivative Works, in at least one
|
|
111
|
-
of the following places: within a NOTICE text file distributed
|
|
112
|
-
as part of the Derivative Works; within the Source form or
|
|
113
|
-
documentation, if provided along with the Derivative Works; or,
|
|
114
|
-
within a display generated by the Derivative Works, if and
|
|
115
|
-
wherever such third-party notices normally appear. The contents
|
|
116
|
-
of the NOTICE file are for informational purposes only and
|
|
117
|
-
do not modify the License. You may add Your own attribution
|
|
118
|
-
notices within Derivative Works that You distribute, alongside
|
|
119
|
-
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
-
that such additional attribution notices cannot be construed
|
|
121
|
-
as modifying the License.
|
|
122
|
-
|
|
123
|
-
You may add Your own copyright statement to Your modifications and
|
|
124
|
-
may provide additional or different license terms and conditions
|
|
125
|
-
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
-
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
-
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
-
the conditions stated in this License.
|
|
129
|
-
|
|
130
|
-
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
-
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
-
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
-
this License, without any additional terms or conditions.
|
|
134
|
-
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
-
the terms of any separate license agreement you may have executed
|
|
136
|
-
with Licensor regarding such Contributions.
|
|
137
|
-
|
|
138
|
-
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
-
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
-
except as required for reasonable and customary use in describing the
|
|
141
|
-
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
-
|
|
143
|
-
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
-
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
-
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
-
implied, including, without limitation, any warranties or conditions
|
|
148
|
-
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
-
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
-
appropriateness of using or redistributing the Work and assume any
|
|
151
|
-
risks associated with Your exercise of permissions under this License.
|
|
152
|
-
|
|
153
|
-
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
-
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
-
unless required by applicable law (such as deliberate and grossly
|
|
156
|
-
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
-
liable to You for damages, including any direct, indirect, special,
|
|
158
|
-
incidental, or consequential damages of any character arising as a
|
|
159
|
-
result of this License or out of the use or inability to use the
|
|
160
|
-
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
-
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
-
other commercial damages or losses), even if such Contributor
|
|
163
|
-
has been advised of the possibility of such damages.
|
|
164
|
-
|
|
165
|
-
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
-
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
-
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
-
or other liability obligations and/or rights consistent with this
|
|
169
|
-
License. However, in accepting such obligations, You may act only
|
|
170
|
-
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
-
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
-
defend, and hold each Contributor harmless for any liability
|
|
173
|
-
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
-
of your accepting any such warranty or additional liability.
|
|
175
|
-
|
|
176
|
-
END OF TERMS AND CONDITIONS
|
|
177
|
-
|
|
178
|
-
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
-
|
|
180
|
-
To apply the Apache License to your work, attach the following
|
|
181
|
-
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
-
replaced with your own identifying information. (Don't include
|
|
183
|
-
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
-
comment syntax for the file format. We also recommend that a
|
|
185
|
-
file or class name and description of purpose be included on the
|
|
186
|
-
same "printed page" as the copyright notice for easier
|
|
187
|
-
identification within third-party archives.
|
|
188
|
-
|
|
189
|
-
Copyright 2026 Dave Sheffer
|
|
190
|
-
|
|
191
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
-
you may not use this file except in compliance with the License.
|
|
193
|
-
You may obtain a copy of the License at
|
|
194
|
-
|
|
195
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
-
|
|
197
|
-
Unless required by applicable law or agreed to in writing, software
|
|
198
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
-
See the License for the specific language governing permissions and
|
|
201
|
-
limitations under the License.
|
|
1
|
+
# Functional Source License, Version 1.1, ALv2 Future License
|
|
2
|
+
|
|
3
|
+
## Abbreviation
|
|
4
|
+
|
|
5
|
+
FSL-1.1-ALv2
|
|
6
|
+
|
|
7
|
+
## Notice
|
|
8
|
+
|
|
9
|
+
Copyright 2026 Dave Sheffer
|
|
10
|
+
|
|
11
|
+
## Terms and Conditions
|
|
12
|
+
|
|
13
|
+
### Licensor ("We")
|
|
14
|
+
|
|
15
|
+
The party offering the Software under these Terms and Conditions.
|
|
16
|
+
|
|
17
|
+
### The Software
|
|
18
|
+
|
|
19
|
+
The "Software" is each version of the software that we make available under
|
|
20
|
+
these Terms and Conditions, as indicated by our inclusion of these Terms and
|
|
21
|
+
Conditions with the Software.
|
|
22
|
+
|
|
23
|
+
### License Grant
|
|
24
|
+
|
|
25
|
+
Subject to your compliance with this License Grant and the Patents,
|
|
26
|
+
Redistribution and Trademark clauses below, we hereby grant you the right to
|
|
27
|
+
use, copy, modify, create derivative works, publicly perform, publicly display
|
|
28
|
+
and redistribute the Software for any Permitted Purpose identified below.
|
|
29
|
+
|
|
30
|
+
### Permitted Purpose
|
|
31
|
+
|
|
32
|
+
A Permitted Purpose is any purpose other than a Competing Use. A Competing Use
|
|
33
|
+
means making the Software available to others in a commercial product or
|
|
34
|
+
service that:
|
|
35
|
+
|
|
36
|
+
1. substitutes for the Software;
|
|
37
|
+
|
|
38
|
+
2. substitutes for any other product or service we offer using the Software
|
|
39
|
+
that exists as of the date we make the Software available; or
|
|
40
|
+
|
|
41
|
+
3. offers the same or substantially similar functionality as the Software.
|
|
42
|
+
|
|
43
|
+
Permitted Purposes specifically include using the Software:
|
|
44
|
+
|
|
45
|
+
1. for your internal use and access;
|
|
46
|
+
|
|
47
|
+
2. for non-commercial education;
|
|
48
|
+
|
|
49
|
+
3. for non-commercial research; and
|
|
50
|
+
|
|
51
|
+
4. in connection with professional services that you provide to a licensee
|
|
52
|
+
using the Software in accordance with these Terms and Conditions.
|
|
53
|
+
|
|
54
|
+
### Patents
|
|
55
|
+
|
|
56
|
+
To the extent your use for a Permitted Purpose would necessarily infringe our
|
|
57
|
+
patents, the license grant above includes a license under our patents. If you
|
|
58
|
+
make a claim against any party that the Software infringes or contributes to
|
|
59
|
+
the infringement of any patent, then your patent license to the Software ends
|
|
60
|
+
immediately.
|
|
61
|
+
|
|
62
|
+
### Redistribution
|
|
63
|
+
|
|
64
|
+
The Terms and Conditions apply to all copies, modifications and derivatives of
|
|
65
|
+
the Software.
|
|
66
|
+
|
|
67
|
+
If you redistribute any copies, modifications or derivatives of the Software,
|
|
68
|
+
you must include a copy of or a link to these Terms and Conditions and not
|
|
69
|
+
remove any copyright notices provided in or with the Software.
|
|
70
|
+
|
|
71
|
+
### Disclaimer
|
|
72
|
+
|
|
73
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTIES OF ANY KIND, EXPRESS OR
|
|
74
|
+
IMPLIED, INCLUDING WITHOUT LIMITATION WARRANTIES OF FITNESS FOR A PARTICULAR
|
|
75
|
+
PURPOSE, MERCHANTABILITY, TITLE OR NON-INFRINGEMENT.
|
|
76
|
+
|
|
77
|
+
IN NO EVENT WILL WE HAVE ANY LIABILITY TO YOU ARISING OUT OF OR RELATED TO THE
|
|
78
|
+
SOFTWARE, INCLUDING INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES,
|
|
79
|
+
EVEN IF WE HAVE BEEN INFORMED OF THEIR POSSIBILITY IN ADVANCE.
|
|
80
|
+
|
|
81
|
+
### Trademarks
|
|
82
|
+
|
|
83
|
+
Except for displaying the License Details and identifying us as the origin of
|
|
84
|
+
the Software, you have no right under these Terms and Conditions to use our
|
|
85
|
+
trademarks, trade names, service marks or product names.
|
|
86
|
+
|
|
87
|
+
## Grant of Future License
|
|
88
|
+
|
|
89
|
+
We hereby irrevocably grant you an additional license to use the Software under
|
|
90
|
+
the Apache License, Version 2.0 that is effective on the second anniversary of
|
|
91
|
+
the date we make the Software available. On or after that date, you may use the
|
|
92
|
+
Software under the Apache License, Version 2.0, in which case the following
|
|
93
|
+
will apply:
|
|
94
|
+
|
|
95
|
+
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
|
96
|
+
this file except in compliance with the License.
|
|
97
|
+
|
|
98
|
+
You may obtain a copy of the License at
|
|
99
|
+
|
|
100
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
101
|
+
|
|
102
|
+
Unless required by applicable law or agreed to in writing, software distributed
|
|
103
|
+
under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
|
104
|
+
CONDITIONS OF ANY KIND, either express or implied. See the License for the
|
|
105
|
+
specific language governing permissions and limitations under the License.
|
package/NOTICE
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
Hunch — Engineering Memory and Change Gate
|
|
2
2
|
Copyright 2026 Dave Sheffer
|
|
3
3
|
|
|
4
|
-
This product is licensed under the
|
|
5
|
-
See the LICENSE file for the full
|
|
6
|
-
|
|
4
|
+
This product is licensed under the Functional Source License, Version 1.1,
|
|
5
|
+
ALv2 Future License (FSL-1.1-ALv2). See the LICENSE file for the full text,
|
|
6
|
+
or https://fsl.software. Each version becomes available under the Apache
|
|
7
|
+
License, Version 2.0 on the second anniversary of its release.
|
|
8
|
+
|
|
9
|
+
Versions released before the switch to FSL-1.1-ALv2 remain available under
|
|
10
|
+
the license they shipped with (Apache-2.0 from v0.15.2, MIT before that).
|
|
11
|
+
|
|
12
|
+
The Python client in clients/python is licensed separately under the Apache
|
|
13
|
+
License, Version 2.0; see clients/python/LICENSE.
|
package/README.md
CHANGED
|
@@ -4,7 +4,13 @@
|
|
|
4
4
|
|
|
5
5
|
[](https://www.npmjs.com/package/@davesheffer/hunch)
|
|
6
6
|
[](https://github.com/davesheffer/hunch)
|
|
7
|
-
[](LICENSE)
|
|
8
|
+
|
|
9
|
+
[](https://www.youtube.com/watch?v=m2PM6pV7D9Y)
|
|
10
|
+
|
|
11
|
+
▶ **[Watch Hunch Memory in 2 minutes](https://www.youtube.com/watch?v=m2PM6pV7D9Y)**, then the [7-episode series](https://www.youtube.com/playlist?list=PLIXqtdE0LcNI) on setup, hooks, memory capture, delivery, rules, drift and teams.
|
|
12
|
+
|
|
13
|
+

|
|
8
14
|
|
|
9
15
|
A new agent session should not mean explaining the project all over again. A second agent should be able to check a recorded decision, see the evidence behind completed work, and find an outstanding commitment.
|
|
10
16
|
|
|
@@ -12,10 +18,6 @@ Hunch keeps that record in Git and makes the relevant parts available to your ag
|
|
|
12
18
|
|
|
13
19
|
The goal is simple: agents working from the same maintained record, with sources they can inspect. Hunch supplies memory and checks; the assistant still does the work.
|
|
14
20
|
|
|
15
|
-
[](https://www.youtube.com/watch?v=m2PM6pV7D9Y)
|
|
16
|
-
|
|
17
|
-
▶ **[Watch Hunch Memory in 2 minutes](https://www.youtube.com/watch?v=m2PM6pV7D9Y)**, then the [7-episode series](https://www.youtube.com/playlist?list=PLIXqtdE0LcNI) on setup, hooks, memory capture, delivery, rules, drift and teams.
|
|
18
|
-
|
|
19
21
|
## Start with your coding assistant
|
|
20
22
|
|
|
21
23
|
Requires **Node 22.13+** and a Git repository.
|
|
@@ -196,4 +198,4 @@ Profiles retain their revision, sources, confidence, and freshness.
|
|
|
196
198
|
- [VS Code extension](vscode-extension/README.md)
|
|
197
199
|
- [Contributing](CONTRIBUTING.md)
|
|
198
200
|
|
|
199
|
-
Apache-2.0
|
|
201
|
+
[FSL-1.1-ALv2](LICENSE) (Functional Source License). Use it, modify it, and run it for your own work, internal or commercial; you can't make it available to others in a commercial product or service that competes with Hunch or with services built on it (see Permitted Purpose in [LICENSE](LICENSE)). Each release converts to Apache-2.0 two years after it ships. Releases before this change keep the license they shipped with.
|
package/dist/cli/index.js
CHANGED
|
@@ -23,7 +23,8 @@ import { Command } from "commander";
|
|
|
23
23
|
import { hunchPaths, hunchPathsForDir, findRoot, toPosixTarget, isDir, realpathNorm, repoRelativeTarget } from "../core/paths.js";
|
|
24
24
|
import { writeFileAtomic } from "../core/io.js";
|
|
25
25
|
import { boundedSpawnSync } from "../core/boundedSpawn.js";
|
|
26
|
-
import { looksLikeCorrection, CORRECTION_NUDGE } from "../core/correction.js";
|
|
26
|
+
import { looksLikeCorrection, CORRECTION_NUDGE, stripHostBlocks } from "../core/correction.js";
|
|
27
|
+
import { roleHasHunchTools } from "../core/subagentrole.js";
|
|
27
28
|
import { HUNCH_VERSION } from "../core/version.js";
|
|
28
29
|
import { registerIntegrationCommands } from "./integrations.js";
|
|
29
30
|
import { registerTaskReportCommands } from "./taskReport.js";
|
|
@@ -856,7 +857,7 @@ program
|
|
|
856
857
|
if (ctxWarning !== null)
|
|
857
858
|
console.log(ctxWarning);
|
|
858
859
|
}
|
|
859
|
-
let written = 0, skipped = 0, llm = 0, heuristic = 0;
|
|
860
|
+
let written = 0, skipped = 0, llm = 0, heuristic = 0, fellBack = 0;
|
|
860
861
|
const home = store.captureHome(false);
|
|
861
862
|
// The per-commit cost is the Claude synthesis spawn; run several at once. Safe:
|
|
862
863
|
// each commit drafts independently and writes its OWN decision file atomically,
|
|
@@ -868,11 +869,17 @@ program
|
|
|
868
869
|
if (r.status === "written") {
|
|
869
870
|
written++;
|
|
870
871
|
// Any non-deterministic provider (claude/codex/cursor/ensemble) is an LLM draft.
|
|
871
|
-
|
|
872
|
+
// A provider failure that fell back is counted apart from the commits the
|
|
873
|
+
// significance gate sent to the heuristic on purpose (issue #561).
|
|
874
|
+
if (r.fallbackReason)
|
|
875
|
+
fellBack++;
|
|
876
|
+
else if (r.provider && r.provider !== "deterministic")
|
|
872
877
|
llm++;
|
|
873
878
|
else
|
|
874
879
|
heuristic++;
|
|
875
|
-
process.stdout.write(` ✓ ${sha.slice(0, 8)} ${r.decision?.title.slice(0, 64) ?? ""}\n`);
|
|
880
|
+
process.stdout.write(` ${r.fallbackReason ? "⚠" : "✓"} ${sha.slice(0, 8)} ${r.decision?.title.slice(0, 64) ?? ""}\n`);
|
|
881
|
+
if (r.fallbackReason)
|
|
882
|
+
process.stdout.write(` heuristic draft instead: ${r.fallbackReason}\n`);
|
|
876
883
|
}
|
|
877
884
|
else
|
|
878
885
|
skipped++;
|
|
@@ -884,7 +891,8 @@ program
|
|
|
884
891
|
pumpMemoryHome(store, root, home, `hunch: backfill ${written} decision(s)`);
|
|
885
892
|
// Honest tally of where the tokens went: trivial commits are seeded by the
|
|
886
893
|
// free deterministic heuristic, only substantive ones spend the LLM.
|
|
887
|
-
|
|
894
|
+
const fellBackNote = fellBack ? `, ${fellBack} heuristic after the LLM failed` : "";
|
|
895
|
+
console.log(`Done: ${written} decision(s) seeded (${llm} via LLM, ${heuristic} heuristic${fellBackNote}), ${skipped} skipped (trivial/not substantive/already-captured).`);
|
|
888
896
|
store.close();
|
|
889
897
|
});
|
|
890
898
|
// ---- sync (post-commit hook) ----------------------------------------------
|
|
@@ -947,6 +955,8 @@ program
|
|
|
947
955
|
store.reindex();
|
|
948
956
|
if (!opts.quiet)
|
|
949
957
|
console.log(`✓ captured decision ${r.decision?.id} via ${r.provider}: "${r.decision?.title}"`);
|
|
958
|
+
if (!opts.quiet && r.fallbackReason)
|
|
959
|
+
console.log(` ⚠ heuristic draft instead: ${r.fallbackReason}`);
|
|
950
960
|
}
|
|
951
961
|
else if (!opts.quiet) {
|
|
952
962
|
console.log(`· skipped: ${r.reason}`);
|
|
@@ -2083,7 +2093,7 @@ program
|
|
|
2083
2093
|
else {
|
|
2084
2094
|
console.log(`Top matches for "${q}"${how}:\n`);
|
|
2085
2095
|
for (const h of hits)
|
|
2086
|
-
console.log(formatSearchHit(h, isStateKind(h.kind) ? store.resolve(h.ref)?.record : undefined));
|
|
2096
|
+
console.log(formatSearchHit(h, isStateKind(h.kind) || h.kind === "decisions" ? store.resolve(h.ref)?.record : undefined));
|
|
2087
2097
|
}
|
|
2088
2098
|
store.close();
|
|
2089
2099
|
});
|
|
@@ -5456,9 +5466,11 @@ program
|
|
|
5456
5466
|
return flat.length > max ? `${flat.slice(0, max - 1).trimEnd()}…` : flat;
|
|
5457
5467
|
};
|
|
5458
5468
|
const type = (evt.agent_type ?? "").toLowerCase();
|
|
5469
|
+
// A role whose tool list leaves out Hunch's MCP tools is not told to call them.
|
|
5470
|
+
const tools = roleHasHunchTools(root, evt.agent_type ?? "");
|
|
5459
5471
|
const L = [];
|
|
5460
5472
|
const served = [];
|
|
5461
|
-
const route = routedCwd
|
|
5473
|
+
const route = routedCwd && tools
|
|
5462
5474
|
? `Worktree routing: call hunch_context first with cwd: ${JSON.stringify(routedCwd)}, and pass the same cwd to hunch_task, hunch_report, and every Hunch capture/write call in this delegated task.`
|
|
5463
5475
|
: null;
|
|
5464
5476
|
const activeProvider = provider;
|
|
@@ -5478,8 +5490,9 @@ program
|
|
|
5478
5490
|
served.push({ kind: "components", record_id: c.id, token_cost: Math.ceil([...line].length / 4) });
|
|
5479
5491
|
}
|
|
5480
5492
|
if (components.length > 12)
|
|
5481
|
-
L.push(`…and ${components.length - 12} more — hunch_structure() for the full map.`);
|
|
5482
|
-
|
|
5493
|
+
L.push(`…and ${components.length - 12} more${tools ? " — hunch_structure() for the full map" : ""}.`);
|
|
5494
|
+
if (tools)
|
|
5495
|
+
L.push("Orient: hunch_structure(target) · hunch_why(target) · hunch_context(task).");
|
|
5483
5496
|
}
|
|
5484
5497
|
else if (/plan|architect|design/.test(type)) {
|
|
5485
5498
|
// A plan drafted blind re-proposes what the graph already rejected.
|
|
@@ -5496,7 +5509,8 @@ program
|
|
|
5496
5509
|
L.push(line);
|
|
5497
5510
|
served.push({ kind: "decisions", record_id: d.id, token_cost: Math.ceil([...line].length / 4) });
|
|
5498
5511
|
}
|
|
5499
|
-
|
|
5512
|
+
if (tools)
|
|
5513
|
+
L.push("Before finalizing a plan: hunch_why(target) · hunch_current_decision(topic) · hunch_check_constraints(scope).");
|
|
5500
5514
|
}
|
|
5501
5515
|
else {
|
|
5502
5516
|
const sevRank = { blocking: 0, warning: 1, advisory: 2 };
|
|
@@ -5514,8 +5528,9 @@ program
|
|
|
5514
5528
|
served.push({ kind: "constraints", record_id: c.id, token_cost: Math.ceil([...line].length / 4) });
|
|
5515
5529
|
}
|
|
5516
5530
|
if (constraints.length > 8)
|
|
5517
|
-
L.push(`…and ${constraints.length - 8} more — hunch_check_constraints(scope) for your files.`);
|
|
5518
|
-
|
|
5531
|
+
L.push(`…and ${constraints.length - 8} more${tools ? " — hunch_check_constraints(scope) for your files" : "; the edit hook shows the ones your files touch"}.`);
|
|
5532
|
+
if (tools)
|
|
5533
|
+
L.push("Before editing: hunch_check_constraints(scope) · hunch_why(target). Orient: hunch_context(task).");
|
|
5519
5534
|
}
|
|
5520
5535
|
if (route)
|
|
5521
5536
|
L.push(route);
|
|
@@ -7768,19 +7783,21 @@ function promptTaskSelection(root, store, provider, evt) {
|
|
|
7768
7783
|
const taskId = hookReportTaskId(root, provider, evt);
|
|
7769
7784
|
if (!taskId)
|
|
7770
7785
|
return "";
|
|
7786
|
+
// Host-injected blocks (reminders, browser instructions) are not the task the human named.
|
|
7787
|
+
const humanText = stripHostBlocks(evt.prompt ?? "");
|
|
7771
7788
|
const selection = selectForTask(liveSelectionRecords({
|
|
7772
7789
|
decisions: store.recs("decisions"),
|
|
7773
7790
|
bugs: store.recs("bugs"),
|
|
7774
7791
|
constraints: store.recs("constraints"),
|
|
7775
7792
|
findings: store.recs("findings"),
|
|
7776
|
-
}),
|
|
7793
|
+
}), humanText, { root, pathExists: (p) => existsSync(join(root, p)) });
|
|
7777
7794
|
// Same task id again (a notification alias) keeps its own earlier selection; a
|
|
7778
7795
|
// new task that CONTINUES the session's previous one inherits that task's
|
|
7779
7796
|
// selection only on a bare follow-up ("continue", "go on"), so it is not left
|
|
7780
7797
|
// ungrounded. A substantive prompt names its own task: a same-session prompt
|
|
7781
7798
|
// inside the continuation window must not hide memory behind an old selection.
|
|
7782
7799
|
let previous = loadTaskSelection(taskId);
|
|
7783
|
-
if (!previous && isBareFollowUp(
|
|
7800
|
+
if (!previous && isBareFollowUp(humanText)) {
|
|
7784
7801
|
try {
|
|
7785
7802
|
const continues = readTaskReport(root, taskId).task.continues;
|
|
7786
7803
|
previous = continues ? loadTaskSelection(continues) : null;
|
package/dist/core/correction.js
CHANGED
|
@@ -30,11 +30,12 @@ const CORRECTION_PATTERNS = [
|
|
|
30
30
|
/\b(not like that|don'?t do (that|this)( again)?|stop doing (that|this))\b/i,
|
|
31
31
|
];
|
|
32
32
|
/** Host-generated blocks a prompt can carry: a background task's completion
|
|
33
|
-
* (`<task-notification>`, which also wraps a subagent's hand-back report)
|
|
34
|
-
* injected context (`<system-reminder>`, hook output)
|
|
33
|
+
* (`<task-notification>`, which also wraps a subagent's hand-back report),
|
|
34
|
+
* injected context (`<system-reminder>`, hook output) and the browser
|
|
35
|
+
* extension's standing instructions (`<browser_instruction>`). Their words are not the
|
|
35
36
|
* human's, so "never use X" quoted from a constraint is not a correction. A tag
|
|
36
37
|
* left unclosed drops only the rest of its own line, never the human's text below. */
|
|
37
|
-
const HOST_TAGS = "task-notification|system-reminder|local-command-stdout|local-command-stderr|command-message|command-name|command-args";
|
|
38
|
+
const HOST_TAGS = "task-notification|system-reminder|local-command-stdout|local-command-stderr|command-message|command-name|command-args|browser_instruction";
|
|
38
39
|
const HOST_BLOCK = new RegExp(`<(${HOST_TAGS})>[\\s\\S]*?<\\/\\1>`, "gi");
|
|
39
40
|
const HOST_OPEN_LINE = new RegExp(`<(?:${HOST_TAGS})>[^\\n]*`, "gi");
|
|
40
41
|
/** The prompt with host-generated blocks removed: what the human actually typed. */
|
package/dist/core/format.d.ts
CHANGED
|
@@ -7,7 +7,9 @@ export declare function formatContext(ctx: AssembledContext, options?: DeliveryO
|
|
|
7
7
|
/** One search hit as `hunch query` / hunch_query print it (headline + indented detail line).
|
|
8
8
|
* Graph records keep their `[kind] id — title` shape; a nuryel.state/1 hit renders through
|
|
9
9
|
* renderStateLine (`[commitment/in_force] customer:Site:7 — "send report" due … (owner …)`)
|
|
10
|
-
* with the record id on the detail line, so both readers say the same thing.
|
|
10
|
+
* with the record id on the detail line, so both readers say the same thing. A decision that
|
|
11
|
+
* is no longer accepted says so in its tag (`[decisions · superseded → dec_new]`), so a
|
|
12
|
+
* reader never takes a history hit for the current rule. */
|
|
11
13
|
export declare function formatSearchHit(hit: SearchHit, record: unknown): string;
|
|
12
14
|
/** Render a StructureView as a compact orientation brief (hunch_structure). */
|
|
13
15
|
export declare function formatStructure(v: StructureView): string;
|
package/dist/core/format.js
CHANGED
|
@@ -6,12 +6,24 @@ export function formatContext(ctx, options = {}) {
|
|
|
6
6
|
/** One search hit as `hunch query` / hunch_query print it (headline + indented detail line).
|
|
7
7
|
* Graph records keep their `[kind] id — title` shape; a nuryel.state/1 hit renders through
|
|
8
8
|
* renderStateLine (`[commitment/in_force] customer:Site:7 — "send report" due … (owner …)`)
|
|
9
|
-
* with the record id on the detail line, so both readers say the same thing.
|
|
9
|
+
* with the record id on the detail line, so both readers say the same thing. A decision that
|
|
10
|
+
* is no longer accepted says so in its tag (`[decisions · superseded → dec_new]`), so a
|
|
11
|
+
* reader never takes a history hit for the current rule. */
|
|
10
12
|
export function formatSearchHit(hit, record) {
|
|
11
13
|
if (isStateKind(hit.kind) && record) {
|
|
12
14
|
return `• ${renderStateLine(hit.kind, record)}\n ${hit.ref}`;
|
|
13
15
|
}
|
|
14
|
-
return `• [${hit.kind}] ${hit.ref} — ${hit.title}\n ${hit.snippet}`;
|
|
16
|
+
return `• [${hit.kind}${decisionStatusTag(hit.kind, record)}] ${hit.ref} — ${hit.title}\n ${hit.snippet}`;
|
|
17
|
+
}
|
|
18
|
+
function decisionStatusTag(kind, record) {
|
|
19
|
+
if (kind !== "decisions" || !record)
|
|
20
|
+
return "";
|
|
21
|
+
const { status, superseded_by, valid_to } = record;
|
|
22
|
+
if (superseded_by)
|
|
23
|
+
return ` · superseded → ${superseded_by}`;
|
|
24
|
+
if (status && status !== "accepted")
|
|
25
|
+
return ` · ${status}`;
|
|
26
|
+
return valid_to ? ` · closed ${valid_to.slice(0, 10)}` : "";
|
|
15
27
|
}
|
|
16
28
|
/** Render a StructureView as a compact orientation brief (hunch_structure). */
|
|
17
29
|
export function formatStructure(v) {
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/** Whether a delegated agent can call Hunch's MCP tools. A named role defined in
|
|
2
|
+
* `.claude/agents/<type>.md` (project first, then user) with a `tools:` list that
|
|
3
|
+
* names no `mcp__hunch` tool and no wildcard cannot: telling it to call
|
|
4
|
+
* hunch_why only costs it a failed lookup. Built-in and unknown types inherit
|
|
5
|
+
* the parent's tools. */
|
|
6
|
+
export declare function roleHasHunchTools(root: string, agentType: string, home?: string): boolean;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { readFileSync } from "node:fs";
|
|
2
|
+
import { homedir } from "node:os";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
/** Whether a delegated agent can call Hunch's MCP tools. A named role defined in
|
|
5
|
+
* `.claude/agents/<type>.md` (project first, then user) with a `tools:` list that
|
|
6
|
+
* names no `mcp__hunch` tool and no wildcard cannot: telling it to call
|
|
7
|
+
* hunch_why only costs it a failed lookup. Built-in and unknown types inherit
|
|
8
|
+
* the parent's tools. */
|
|
9
|
+
export function roleHasHunchTools(root, agentType, home = homedir()) {
|
|
10
|
+
const type = agentType.trim();
|
|
11
|
+
if (!type || !/^[\w.-]+$/.test(type))
|
|
12
|
+
return true;
|
|
13
|
+
for (const dir of [join(root, ".claude", "agents"), join(home, ".claude", "agents")]) {
|
|
14
|
+
let text;
|
|
15
|
+
try {
|
|
16
|
+
text = readFileSync(join(dir, `${type}.md`), "utf8");
|
|
17
|
+
}
|
|
18
|
+
catch {
|
|
19
|
+
continue;
|
|
20
|
+
}
|
|
21
|
+
const front = /^?---\r?\n([\s\S]*?)\r?\n---/.exec(text)?.[1];
|
|
22
|
+
if (!front)
|
|
23
|
+
return true;
|
|
24
|
+
// A block list continues on indented "- x" lines; a flow list runs to its "]".
|
|
25
|
+
const tools = /^tools:[ \t]*(\[[^\]]*\]?|.*(?:\r?\n[ \t]+-.*)*)/m.exec(front)?.[1];
|
|
26
|
+
if (tools === undefined || !tools.trim())
|
|
27
|
+
return true;
|
|
28
|
+
return /\*|mcp__hunch/.test(tools);
|
|
29
|
+
}
|
|
30
|
+
return true;
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=subagentrole.js.map
|