@davesheffer/hunch 1.45.2 → 1.47.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.
Files changed (91) hide show
  1. package/dist/cli/index.js +290 -353
  2. package/dist/cli/invocation.d.ts +22 -13
  3. package/dist/cli/invocation.js +49 -29
  4. package/dist/cli/verify.d.ts +28 -0
  5. package/dist/cli/verify.js +265 -0
  6. package/dist/constitution/delta.js +2 -2
  7. package/dist/constitution/experiment.d.ts +1 -1
  8. package/dist/constitution/sourceMutation.js +28 -18
  9. package/dist/core/agenthook.js +26 -6
  10. package/dist/core/boundedSpawn.d.ts +57 -0
  11. package/dist/core/boundedSpawn.js +321 -0
  12. package/dist/core/commitrepair.d.ts +43 -138
  13. package/dist/core/commitrepair.js +76 -167
  14. package/dist/core/config.d.ts +6 -0
  15. package/dist/core/config.js +1 -0
  16. package/dist/core/correction.js +9 -9
  17. package/dist/core/delivery.d.ts +6 -1
  18. package/dist/core/delivery.js +71 -5
  19. package/dist/core/docanchors.js +9 -9
  20. package/dist/core/drift.js +22 -27
  21. package/dist/core/escalations.d.ts +16 -58
  22. package/dist/core/escalations.js +39 -121
  23. package/dist/core/glob.d.ts +7 -7
  24. package/dist/core/glob.js +12 -11
  25. package/dist/core/groundingLag.d.ts +2 -9
  26. package/dist/core/groundingLag.js +5 -11
  27. package/dist/core/groundingMerge.d.ts +2 -7
  28. package/dist/core/groundingMerge.js +35 -54
  29. package/dist/core/migrate.d.ts +10 -1
  30. package/dist/core/migrate.js +17 -6
  31. package/dist/core/paths.d.ts +17 -24
  32. package/dist/core/paths.js +37 -43
  33. package/dist/core/projectDna.js +11 -1
  34. package/dist/core/refrepair.d.ts +2 -1
  35. package/dist/core/refrepair.js +4 -4
  36. package/dist/core/relativeImports.js +6 -2
  37. package/dist/core/repairqueue.d.ts +17 -34
  38. package/dist/core/repairqueue.js +48 -98
  39. package/dist/core/taskSelection.js +48 -6
  40. package/dist/core/testSelection.d.ts +122 -0
  41. package/dist/core/testSelection.js +588 -0
  42. package/dist/core/types.d.ts +3 -3
  43. package/dist/core/types.js +1 -1
  44. package/dist/extractors/diff.d.ts +4 -4
  45. package/dist/extractors/diff.js +25 -29
  46. package/dist/extractors/git.d.ts +8 -23
  47. package/dist/extractors/git.js +77 -95
  48. package/dist/extractors/helm.d.ts +10 -0
  49. package/dist/extractors/helm.js +43 -59
  50. package/dist/extractors/indexer.d.ts +6 -0
  51. package/dist/extractors/indexer.js +168 -184
  52. package/dist/extractors/k8sManifest.d.ts +23 -80
  53. package/dist/extractors/k8sManifest.js +319 -690
  54. package/dist/extractors/languages.d.ts +37 -37
  55. package/dist/extractors/languages.js +83 -54
  56. package/dist/extractors/nativeTreeSitter.d.ts +4 -4
  57. package/dist/extractors/nativeTreeSitter.js +17 -14
  58. package/dist/extractors/parse.d.ts +27 -13
  59. package/dist/extractors/parse.js +120 -56
  60. package/dist/extractors/workspaces.js +3 -1
  61. package/dist/integrations/claudemd.js +1 -0
  62. package/dist/integrations/gitignore.js +3 -5
  63. package/dist/integrations/health.d.ts +6 -0
  64. package/dist/integrations/health.js +33 -12
  65. package/dist/integrations/hooks.d.ts +13 -16
  66. package/dist/integrations/hooks.js +31 -30
  67. package/dist/integrations/mergeDriver.js +18 -17
  68. package/dist/integrations/optout.d.ts +3 -0
  69. package/dist/integrations/optout.js +17 -0
  70. package/dist/integrations/providers.d.ts +6 -2
  71. package/dist/integrations/providers.js +19 -2
  72. package/dist/integrations/team.js +4 -2
  73. package/dist/integrations/uninstall.d.ts +10 -4
  74. package/dist/integrations/uninstall.js +22 -18
  75. package/dist/mcp/server.d.ts +4 -5
  76. package/dist/mcp/server.js +107 -81
  77. package/dist/serve/app.js +9 -1
  78. package/dist/serve/config.js +5 -0
  79. package/dist/serve/writelock.d.ts +3 -1
  80. package/dist/serve/writelock.js +17 -3
  81. package/dist/store/hunchStore.d.ts +2 -1
  82. package/dist/store/hunchStore.js +20 -23
  83. package/dist/store/jsonStore.d.ts +13 -3
  84. package/dist/store/jsonStore.js +37 -13
  85. package/dist/store/stateBinding.js +17 -4
  86. package/dist/synthesis/provider.d.ts +19 -21
  87. package/dist/synthesis/provider.js +93 -154
  88. package/dist/synthesis/synthesize.d.ts +8 -8
  89. package/dist/synthesis/synthesize.js +33 -50
  90. package/package.json +3 -3
  91. package/server.json +2 -2
@@ -1,25 +1,3 @@
1
- /**
2
- * Deterministic text scan for Kubernetes manifest cross-resource references —
3
- * NOT a tree-sitter walk. Confirmed directly (not assumed): parsing a realistic
4
- * templated Deployment with this repo's own tree-sitter-yaml bundle showed a
5
- * same-line templated scalar (`name: {{ include "x" . }}`) parses cleanly, but
6
- * a block-form injection on its own line (`labels:\n {{- include ... }}` — the
7
- * pattern real charts use for metadata.labels and spec.selector) collapses the
8
- * WHOLE REST OF THE DOCUMENT'S error recovery into a flat, unstructured ERROR
9
- * node. Real charts place such an injection early (right after metadata.name),
10
- * so it would poison parsing for every field-path this module needs further
11
- * down the same document. parseSource() (parse.ts) also never exposes its
12
- * tree-sitter tree to callers at all -- helm.ts's own text-scan precedent
13
- * exists for the same reason.
14
- *
15
- * This is a line-oriented, indentation-tracking scanner (not flat regex, unlike
16
- * helm.ts's `{{ }}`-action scan) because K8s field-paths are nested block
17
- * structure (`spec.template.spec.containers[].env[].valueFrom.secretKeyRef.name`)
18
- * that a flat scan can't reconstruct. It never interprets `{{ }}` as YAML syntax
19
- * at all -- a `{{ ... }}` on a line's value side is just that line's raw value
20
- * text, same-line or block-form alike -- so it is immune to the exact failure
21
- * mode that broke tree-sitter.
22
- */
23
1
  export type ManifestNameRef = {
24
2
  form: "literal";
25
3
  value: string;
@@ -31,72 +9,37 @@ export type ManifestNameRef = {
31
9
  atChar: number;
32
10
  endChar: number;
33
11
  };
34
- interface K8sReferenceCandidate {
35
- /** Fixed literal for most kinds ("ConfigMap", "Secret", "PersistentVolumeClaim",
36
- * "Service"); for an ownerReferences entry, the reference's OWN `kind` field
37
- * value (data-dependent, not statically known). */
38
- refKind: string;
39
- name: ManifestNameRef;
40
- /** The namespace this reference resolves IN, or null for "unknown" (see
41
- * literalNamespace). Kubernetes name references are same-namespace by
42
- * definition, so this defaults to the referring DOCUMENT's own namespace;
43
- * the one shape that can legitimately point elsewhere (a Gateway API
44
- * `backendRefs[].namespace` sibling) overrides it. */
45
- namespace: string | null;
12
+ export interface K8sManifestDocument {
13
+ resource: {
14
+ kind: string;
15
+ name: ManifestNameRef;
16
+ namespace: string | null;
17
+ startChar: number;
18
+ endChar: number;
19
+ } | null;
20
+ references: Array<{
21
+ refKind: string;
22
+ name: ManifestNameRef;
23
+ namespace: string | null;
24
+ }>;
25
+ selector: Record<string, string> | null;
26
+ labels: Record<string, string> | null;
46
27
  }
47
- type ManifestLabelMap = Record<string, string>;
48
- interface K8sResourceDoc {
49
- kind: string;
50
- name: ManifestNameRef;
51
- /** `metadata.namespace` when it is a plain literal, else null = UNKNOWN (see
52
- * literalNamespace). Cluster-scoped kinds need no special case: they simply
53
- * never carry the field, so they are unknown and compatible with anything. */
28
+ export interface KustomizationInfo {
54
29
  namespace: string | null;
55
- startChar: number;
56
- endChar: number;
57
- }
58
- export interface K8sManifestDocument {
59
- resource: K8sResourceDoc | null;
60
- references: K8sReferenceCandidate[];
61
- selector: ManifestLabelMap | null;
62
- labels: ManifestLabelMap | null;
30
+ resources: string[];
63
31
  }
64
- /** Namespace compatibility per the product rule: a MISSING (unknown) namespace
65
- * matches anything; two DIFFERENT literal namespaces block the edge. */
66
- export declare function namespacesCompatible(a: string | null, b: string | null): boolean;
67
- /** Where a kind's pod spec lives -- factored once so container/volume field
68
- * paths below aren't hand-duplicated per kind. */
69
32
  export declare const POD_SPEC_PATH_BY_KIND: Record<string, string>;
70
33
  export declare const LABELS_PATH_BY_KIND: Record<string, string>;
71
- /** `namespace` is a Kustomize transformer namespace for this file (from
72
- * kustomizeNamespaces): undefined = no transformer, null = UNKNOWN (two
73
- * kustomizations render this file into different namespaces). */
74
34
  export declare function extractK8sManifest(source: string, opts?: {
75
35
  namespace?: string | null;
76
36
  }): K8sManifestDocument[];
77
- export interface KustomizationInfo {
78
- /** Top-level `namespace:` when it is a valid literal namespace, else null. */
79
- namespace: string | null;
80
- /** `resources:` entries exactly as written (paths relative to the kustomization's directory). */
81
- resources: string[];
82
- }
37
+ export declare function namespacesCompatible(a: string | null, b: string | null): boolean;
83
38
  export declare function isKustomizationFile(path: string): boolean;
84
- /** Reads only the two top-level fields the namespace transformer needs:
85
- * `namespace:` and the `resources:` list (block `- item` lines or a one-line
86
- * flow `[a, b]`). One linear pass; everything else in the file is ignored. */
87
39
  export declare function extractKustomization(source: string): KustomizationInfo;
88
- /** The Kustomize namespace each manifest file is rendered into, keyed by repo
89
- * path. `kustomizations` is keyed by the kustomization's DIRECTORY ("" for
90
- * the repo root); `files` is the indexed file set.
91
- *
92
- * A `resources:` entry naming a file applies the namespace to that file; an
93
- * entry naming a directory that holds its own kustomization is a base, and
94
- * the referring (outer) kustomization's namespace wins over the base's, as
95
- * Kustomize applies the overlay transformer to the base's output. Only
96
- * kustomizations no other kustomization references are rendered as roots.
97
- * A file rendered into two different namespaces (one base shared by dev and
98
- * prod overlays, the common layout) maps to null = UNKNOWN; a file rendered
99
- * only without any transformer is absent. Not modelled: remote resources,
100
- * `components:`, the deprecated `bases:` field, and globs. */
40
+ /**
41
+ * Effective namespace per manifest file after Kustomize's namespace transformer.
42
+ * A file reached with conflicting namespaces maps to null; a file that is only
43
+ * ever kept as written (or never rendered) is absent.
44
+ */
101
45
  export declare function kustomizeNamespaces(kustomizations: ReadonlyMap<string, KustomizationInfo>, files: ReadonlySet<string>): Map<string, string | null>;
102
- export {};