traits 0.4.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (106) hide show
  1. package/Assessment.ts +14 -0
  2. package/LICENSE +203 -0
  3. package/Source.ts +13 -0
  4. package/Trait.ts +51 -0
  5. package/TraitConflict.ts +52 -0
  6. package/TraitDerivation.ts +137 -0
  7. package/TraitEvaluation.ts +69 -0
  8. package/TraitStore.ts +88 -0
  9. package/TraitsConfig.ts +57 -0
  10. package/TraitsContext.ts +11 -0
  11. package/_util/Approval.ts +59 -0
  12. package/_util/Git.ts +25 -0
  13. package/_util/TraitsConfigProvider.ts +22 -0
  14. package/_util/TraitsTelemetry.ts +20 -0
  15. package/_util/words.ts +555 -0
  16. package/commands/init.ts +73 -0
  17. package/dist/Assessment.d.ts +12 -0
  18. package/dist/Assessment.d.ts.map +1 -0
  19. package/dist/Assessment.js +12 -0
  20. package/dist/Assessment.js.map +1 -0
  21. package/dist/Source.d.ts +21 -0
  22. package/dist/Source.d.ts.map +1 -0
  23. package/dist/Source.js +10 -0
  24. package/dist/Source.js.map +1 -0
  25. package/dist/Trait.d.ts +12 -0
  26. package/dist/Trait.d.ts.map +1 -0
  27. package/dist/Trait.js +44 -0
  28. package/dist/Trait.js.map +1 -0
  29. package/dist/TraitConflict.d.ts +56 -0
  30. package/dist/TraitConflict.d.ts.map +1 -0
  31. package/dist/TraitConflict.js +47 -0
  32. package/dist/TraitConflict.js.map +1 -0
  33. package/dist/TraitDerivation.d.ts +99 -0
  34. package/dist/TraitDerivation.d.ts.map +1 -0
  35. package/dist/TraitDerivation.js +109 -0
  36. package/dist/TraitDerivation.js.map +1 -0
  37. package/dist/TraitEvaluation.d.ts +68 -0
  38. package/dist/TraitEvaluation.d.ts.map +1 -0
  39. package/dist/TraitEvaluation.js +61 -0
  40. package/dist/TraitEvaluation.js.map +1 -0
  41. package/dist/TraitStore.d.ts +17 -0
  42. package/dist/TraitStore.d.ts.map +1 -0
  43. package/dist/TraitStore.js +57 -0
  44. package/dist/TraitStore.js.map +1 -0
  45. package/dist/TraitsConfig.d.ts +14 -0
  46. package/dist/TraitsConfig.d.ts.map +1 -0
  47. package/dist/TraitsConfig.js +40 -0
  48. package/dist/TraitsConfig.js.map +1 -0
  49. package/dist/TraitsContext.d.ts +11 -0
  50. package/dist/TraitsContext.d.ts.map +1 -0
  51. package/dist/TraitsContext.js +4 -0
  52. package/dist/TraitsContext.js.map +1 -0
  53. package/dist/_util/Approval.d.ts +28 -0
  54. package/dist/_util/Approval.d.ts.map +1 -0
  55. package/dist/_util/Approval.js +48 -0
  56. package/dist/_util/Approval.js.map +1 -0
  57. package/dist/_util/Git.d.ts +15 -0
  58. package/dist/_util/Git.d.ts.map +1 -0
  59. package/dist/_util/Git.js +17 -0
  60. package/dist/_util/Git.js.map +1 -0
  61. package/dist/_util/TraitsConfigProvider.d.ts +3 -0
  62. package/dist/_util/TraitsConfigProvider.d.ts.map +1 -0
  63. package/dist/_util/TraitsConfigProvider.js +17 -0
  64. package/dist/_util/TraitsConfigProvider.js.map +1 -0
  65. package/dist/_util/TraitsTelemetry.d.ts +3 -0
  66. package/dist/_util/TraitsTelemetry.d.ts.map +1 -0
  67. package/dist/_util/TraitsTelemetry.js +12 -0
  68. package/dist/_util/TraitsTelemetry.js.map +1 -0
  69. package/dist/_util/words.d.ts +2 -0
  70. package/dist/_util/words.d.ts.map +1 -0
  71. package/dist/_util/words.js +556 -0
  72. package/dist/_util/words.js.map +1 -0
  73. package/dist/commands/init.d.ts +4 -0
  74. package/dist/commands/init.d.ts.map +1 -0
  75. package/dist/commands/init.js +67 -0
  76. package/dist/commands/init.js.map +1 -0
  77. package/dist/index.d.ts +10 -0
  78. package/dist/index.d.ts.map +1 -0
  79. package/dist/index.js +10 -0
  80. package/dist/index.js.map +1 -0
  81. package/dist/main.d.ts +3 -0
  82. package/dist/main.d.ts.map +1 -0
  83. package/dist/main.js +73 -0
  84. package/dist/main.js.map +1 -0
  85. package/dist/package.json +53 -0
  86. package/dist/toolkit/CheckTraits.d.ts +79 -0
  87. package/dist/toolkit/CheckTraits.d.ts.map +1 -0
  88. package/dist/toolkit/CheckTraits.js +110 -0
  89. package/dist/toolkit/CheckTraits.js.map +1 -0
  90. package/dist/toolkit/DeriveTrait.d.ts +108 -0
  91. package/dist/toolkit/DeriveTrait.d.ts.map +1 -0
  92. package/dist/toolkit/DeriveTrait.js +54 -0
  93. package/dist/toolkit/DeriveTrait.js.map +1 -0
  94. package/dist/toolkit/toolkit.d.ts +3 -0
  95. package/dist/toolkit/toolkit.d.ts.map +1 -0
  96. package/dist/toolkit/toolkit.js +6 -0
  97. package/dist/toolkit/toolkit.js.map +1 -0
  98. package/index.ts +9 -0
  99. package/main.ts +113 -0
  100. package/package.json +46 -0
  101. package/skills/traits/SKILL.md +307 -0
  102. package/toolkit/CheckTraits.ts +150 -0
  103. package/toolkit/DeriveTrait.ts +59 -0
  104. package/toolkit/toolkit.ts +9 -0
  105. 1289345811335-0.8567837113514543/lib/traits.js +0 -662
  106. 1289345811335-0.8567837113514543/package.json +0 -7
@@ -0,0 +1,59 @@
1
+ import { Schema as S, String } from "effect"
2
+ import { AiError, DecisionModel, LanguageModel, McpSchema, Tool, Toolkit } from "effect/ai"
3
+
4
+ import { derive, TraitDerivation } from "../TraitDerivation.ts"
5
+ import { TraitsContext } from "../TraitsContext.ts"
6
+ import { TraitStore, TraitStoreError } from "../TraitStore.ts"
7
+
8
+ export const DeriveTrait = Tool.make("derive_trait", {
9
+ description: String.stripMargin(`
10
+ | Use after a user correction, reusable coding preference, or explicit request to remember a convention.
11
+ | Recognize preferences across turns, including approval of a suggested alternative idiom; do not require the words "always" or "trait".
12
+ | Err on the side of proposing a rule unless an existing trait clearly covers its exact scope. Call this tool with the draft first; do not ask separately beforehand.
13
+ | An explicit request to save the rule counts as approval; approval to change code alone does not.
14
+ | Native clients receive an approval form. ApprovalRequired means use the interactive question tool with Save, Revise, and Skip choices and its free-text option.
15
+ | Include the full returned message. Retry with the exact same body and target and approved: true only after Save; revise and request approval again for changed text.
16
+ | RevisionRequired contains feedback; revise and resubmit. Declined means stop without writing. Never retry automatically after a decline.
17
+ | If Revise supplies no concrete feedback, ask for revision details with the interactive question UI and free text. Do not guess or set approved: true.
18
+ | Keep the proposal pending through related work and return to it afterward unless cancelled; obtain fresh approval of the complete revised body.
19
+ | First decide whether the feedback generalizes beyond the current task and inspect existing trait files for coverage.
20
+ | Supply a concise, standalone rule as proposedTrait, preserving its scope and exceptions; omit headings and unnecessary examples.
21
+ | Compare against all stored traits. Only a distinct proposal is saved as a new trait.
22
+ | Inconclusive returns relationship findings and blocks all writes; clarify ambiguity or revise the proposal before retrying.
23
+ | Confirmed conflicts enter reconciliation within this tool. Approval shows affected trait IDs/bodies, removals, the proposal, and replacement policy.
24
+ | Nothing is replaced before approval. After approval, generate compatible standalone replacements, save them, then delete only the conflicting originals.
25
+ | The proposal takes precedence only in direct conflicts; preserve unrelated requirements, scopes, and exceptions. Resolved returns saved replacements.
26
+ | Do not submit the same proposal again after Resolved: it is already incorporated. Inspect replacements and check relevant TypeScript files.
27
+ | Reconciliation is not transactional; on an error, inspect the store before retrying because some writes or removals may have completed.
28
+ | Covered returns the existing traits representing the proposal; reuse them without writing a duplicate.
29
+ | A single clarification candidate is selected automatically for approval; provide a complete replacement body preserving existing requirements and exceptions.
30
+ | Multiple clarification candidates return Clarification with those traits and the proposal without writing. Refine the proposal or clarify intent.
31
+ | The shared approval flow shows the existing and proposed bodies; ask in the client UI only if ApprovalRequired is returned.
32
+ | The tool rechecks all traits before updating, preserving the selected ID. Updated returns the saved trait.
33
+ | Never use approved: true for an unapproved replacement, and never resolve a mere clarification by deleting traits.
34
+ | Created returns the saved trait including its generated ID. Every response is one tagged TraitDerivation outcome, never a bare array or void.
35
+ | Then call check_traits on relevant TypeScript files, using returned trait IDs for focused reviews when appropriate.
36
+ `),
37
+ parameters: S.Struct({
38
+ proposedTrait: S.String.annotate({
39
+ description:
40
+ "The complete reusable rule to save, including scope and exceptions, rather than raw conversation text."
41
+ }),
42
+ approved: S.Boolean.pipe(S.optional).annotate({
43
+ description:
44
+ "Fallback approval for the exact proposal and automatically selected action shown to the user, including any existing trait being updated. Set true only after approval; native clients still receive a form. Does not bypass relationship checks."
45
+ })
46
+ }),
47
+ success: TraitDerivation,
48
+ failure: S.Union([AiError.AiError, TraitStoreError, McpSchema.ElicitationDeclined]),
49
+ dependencies: [DecisionModel.DecisionModel, LanguageModel.LanguageModel, TraitStore, TraitsContext]
50
+ })
51
+ .annotate(Tool.Title, "Derive Trait")
52
+ .annotate(Tool.Readonly, false)
53
+ .annotate(Tool.Destructive, true)
54
+
55
+ export const toolkit = Toolkit.make(DeriveTrait)
56
+
57
+ export const layer = toolkit.toLayer({
58
+ derive_trait: derive
59
+ })
@@ -0,0 +1,9 @@
1
+ import { Layer } from "effect"
2
+ import { McpServer, Toolkit } from "effect/ai"
3
+
4
+ import * as CheckTraits from "./CheckTraits.ts"
5
+ import * as DeriveTrait from "./DeriveTrait.ts"
6
+
7
+ export const toolkit = McpServer.toolkit(Toolkit.merge(DeriveTrait.toolkit, CheckTraits.toolkit)).pipe(
8
+ Layer.provide(Layer.mergeAll(DeriveTrait.layer, CheckTraits.layer))
9
+ )