@open-agent-toolkit/cli 0.2.62 → 0.2.64

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 (145) hide show
  1. package/assets/bundle-metadata.json +1 -1
  2. package/assets/docs/cli-utilities/config-and-local-state.md +1 -0
  3. package/assets/docs/cli-utilities/configuration.md +10 -8
  4. package/assets/docs/cli-utilities/project-log.md +16 -0
  5. package/assets/docs/cli-utilities/tool-packs.md +83 -0
  6. package/assets/docs/cli-utilities/workflow-gates.md +124 -16
  7. package/assets/docs/contributing/skills.md +42 -7
  8. package/assets/docs/provider-sync/commands.md +3 -0
  9. package/assets/docs/provider-sync/instruction-sync.md +107 -0
  10. package/assets/docs/provider-sync/manifest-and-drift.md +105 -0
  11. package/assets/docs/reference/cli-reference.md +16 -6
  12. package/assets/docs/reference/oat-directory-structure.md +32 -31
  13. package/assets/docs/workflows/projects/lifecycle.md +45 -0
  14. package/assets/docs/workflows/projects/picking-up-projects.md +14 -0
  15. package/assets/docs/workflows/skills/explainer-kit.md +10 -4
  16. package/assets/docs/workflows/skills/repo-improve.md +15 -1
  17. package/assets/public-package-versions.json +4 -4
  18. package/assets/skills/create-agnostic-skill/SKILL.md +9 -7
  19. package/assets/skills/create-agnostic-skill/references/skill-template.md +9 -7
  20. package/assets/skills/oat-explainer-kit/SKILL.md +14 -1
  21. package/assets/skills/oat-explainer-kit/references/config-contract.md +12 -0
  22. package/assets/skills/oat-explainer-kit/references/lifecycle-contract.md +57 -10
  23. package/assets/skills/oat-explainer-kit/scripts/check-terminal-outcome.mjs +28 -5
  24. package/assets/skills/oat-explainer-kit/scripts/probe-recap-seams.mjs +371 -0
  25. package/assets/skills/oat-explainer-kit/scripts/resolve-intent.mjs +123 -1
  26. package/assets/skills/oat-project-autonomous/SKILL.md +10 -1
  27. package/assets/skills/oat-project-autonomous/references/gate-inventory.md +122 -121
  28. package/assets/skills/oat-project-complete/SKILL.md +134 -4
  29. package/assets/skills/oat-project-document/references/docs/autonomy-contract.md +122 -121
  30. package/assets/skills/oat-project-implement/SKILL.md +1 -1
  31. package/assets/skills/oat-project-implement/references/completion-and-closeout.md +38 -6
  32. package/assets/skills/oat-project-implement/references/docs/autonomy-contract.md +122 -121
  33. package/assets/skills/oat-project-lite/references/docs/autonomy-contract.md +122 -121
  34. package/assets/skills/oat-project-next/SKILL.md +62 -19
  35. package/assets/skills/oat-project-plan/SKILL.md +31 -5
  36. package/assets/skills/oat-project-pr-final/SKILL.md +281 -6
  37. package/assets/skills/oat-project-pr-final/references/docs/autonomy-contract.md +122 -121
  38. package/assets/skills/oat-project-progress/SKILL.md +12 -3
  39. package/assets/skills/oat-project-quick-start/SKILL.md +264 -4
  40. package/assets/skills/oat-project-quick-start/references/docs/autonomy-contract.md +122 -121
  41. package/assets/skills/oat-project-summary/SKILL.md +34 -23
  42. package/assets/skills/oat-repo-improve/SKILL.md +40 -5
  43. package/assets/skills/oat-repo-improve/references/plan-template.md +84 -7
  44. package/dist/agents/canonical/resolve.d.ts.map +1 -1
  45. package/dist/agents/canonical/resolve.js +25 -4
  46. package/dist/commands/config/index.d.ts +1 -0
  47. package/dist/commands/config/index.d.ts.map +1 -1
  48. package/dist/commands/config/index.js +401 -18
  49. package/dist/commands/doctor/index.d.ts +7 -0
  50. package/dist/commands/doctor/index.d.ts.map +1 -1
  51. package/dist/commands/doctor/index.js +10 -2
  52. package/dist/commands/gate/index.d.ts +3 -1
  53. package/dist/commands/gate/index.d.ts.map +1 -1
  54. package/dist/commands/gate/index.js +699 -211
  55. package/dist/commands/init/tools/index.d.ts.map +1 -1
  56. package/dist/commands/init/tools/index.js +68 -36
  57. package/dist/commands/init/tools/shared/skill-script-references.d.ts +126 -0
  58. package/dist/commands/init/tools/shared/skill-script-references.d.ts.map +1 -0
  59. package/dist/commands/init/tools/shared/skill-script-references.js +311 -0
  60. package/dist/commands/instructions/instructions.types.d.ts +63 -0
  61. package/dist/commands/instructions/instructions.types.d.ts.map +1 -1
  62. package/dist/commands/instructions/instructions.utils.d.ts +51 -2
  63. package/dist/commands/instructions/instructions.utils.d.ts.map +1 -1
  64. package/dist/commands/instructions/instructions.utils.js +201 -4
  65. package/dist/commands/instructions/sync/sync.d.ts.map +1 -1
  66. package/dist/commands/instructions/sync/sync.js +12 -1
  67. package/dist/commands/instructions/validate/validate.d.ts.map +1 -1
  68. package/dist/commands/instructions/validate/validate.js +12 -1
  69. package/dist/commands/project/log/append.d.ts +195 -0
  70. package/dist/commands/project/log/append.d.ts.map +1 -1
  71. package/dist/commands/project/log/append.js +1034 -11
  72. package/dist/commands/shared/frontmatter.d.ts +51 -0
  73. package/dist/commands/shared/frontmatter.d.ts.map +1 -1
  74. package/dist/commands/shared/frontmatter.js +118 -6
  75. package/dist/commands/status/index.d.ts.map +1 -1
  76. package/dist/commands/status/index.js +5 -3
  77. package/dist/commands/sync/index.d.ts +14 -0
  78. package/dist/commands/sync/index.d.ts.map +1 -1
  79. package/dist/commands/sync/index.js +21 -0
  80. package/dist/commands/tools/info/index.d.ts.map +1 -1
  81. package/dist/commands/tools/info/index.js +14 -1
  82. package/dist/commands/tools/info/info-tool.d.ts +12 -0
  83. package/dist/commands/tools/info/info-tool.d.ts.map +1 -1
  84. package/dist/commands/tools/info/info-tool.js +54 -6
  85. package/dist/commands/tools/info/skill-views.d.ts +86 -0
  86. package/dist/commands/tools/info/skill-views.d.ts.map +1 -0
  87. package/dist/commands/tools/info/skill-views.js +383 -0
  88. package/dist/commands/tools/install/index.d.ts.map +1 -1
  89. package/dist/commands/tools/install/index.js +3 -25
  90. package/dist/commands/tools/list/list-tools.d.ts +2 -0
  91. package/dist/commands/tools/list/list-tools.d.ts.map +1 -1
  92. package/dist/commands/tools/list/list-tools.js +23 -4
  93. package/dist/commands/tools/remove/index.d.ts.map +1 -1
  94. package/dist/commands/tools/remove/index.js +35 -42
  95. package/dist/commands/tools/remove/remove-tools.d.ts +3 -2
  96. package/dist/commands/tools/remove/remove-tools.d.ts.map +1 -1
  97. package/dist/commands/tools/remove/remove-tools.js +14 -4
  98. package/dist/commands/tools/shared/auto-sync.d.ts +12 -1
  99. package/dist/commands/tools/shared/auto-sync.d.ts.map +1 -1
  100. package/dist/commands/tools/shared/auto-sync.js +20 -4
  101. package/dist/commands/tools/shared/format-pack-inventory.d.ts +12 -1
  102. package/dist/commands/tools/shared/format-pack-inventory.d.ts.map +1 -1
  103. package/dist/commands/tools/shared/format-pack-inventory.js +48 -6
  104. package/dist/commands/tools/shared/in-process-sync.d.ts +11 -0
  105. package/dist/commands/tools/shared/in-process-sync.d.ts.map +1 -0
  106. package/dist/commands/tools/shared/in-process-sync.js +79 -0
  107. package/dist/commands/tools/shared/pack-evidence.d.ts +78 -2
  108. package/dist/commands/tools/shared/pack-evidence.d.ts.map +1 -1
  109. package/dist/commands/tools/shared/pack-evidence.js +96 -2
  110. package/dist/commands/tools/shared/pack-lifecycle-outcome.d.ts +11 -0
  111. package/dist/commands/tools/shared/pack-lifecycle-outcome.d.ts.map +1 -1
  112. package/dist/commands/tools/shared/pack-lifecycle-outcome.js +24 -3
  113. package/dist/commands/tools/shared/pack-provider-evidence.d.ts +73 -0
  114. package/dist/commands/tools/shared/pack-provider-evidence.d.ts.map +1 -0
  115. package/dist/commands/tools/shared/pack-provider-evidence.js +161 -0
  116. package/dist/commands/tools/shared/provider-context.d.ts +88 -0
  117. package/dist/commands/tools/shared/provider-context.d.ts.map +1 -0
  118. package/dist/commands/tools/shared/provider-context.js +77 -0
  119. package/dist/commands/tools/shared/provider-reachability.d.ts +93 -0
  120. package/dist/commands/tools/shared/provider-reachability.d.ts.map +1 -0
  121. package/dist/commands/tools/shared/provider-reachability.js +358 -0
  122. package/dist/commands/tools/shared/sync-evidence.d.ts +57 -0
  123. package/dist/commands/tools/shared/sync-evidence.d.ts.map +1 -0
  124. package/dist/commands/tools/shared/sync-evidence.js +147 -0
  125. package/dist/commands/tools/update/index.d.ts +0 -4
  126. package/dist/commands/tools/update/index.d.ts.map +1 -1
  127. package/dist/commands/tools/update/index.js +22 -40
  128. package/dist/commands/tools/update/update-tools.d.ts.map +1 -1
  129. package/dist/commands/tools/update/update-tools.js +23 -8
  130. package/dist/config/json.d.ts +36 -0
  131. package/dist/config/json.d.ts.map +1 -1
  132. package/dist/config/json.js +135 -3
  133. package/dist/config/oat-config.d.ts +41 -0
  134. package/dist/config/oat-config.d.ts.map +1 -1
  135. package/dist/config/oat-config.js +111 -0
  136. package/dist/drift/index.d.ts +2 -0
  137. package/dist/drift/index.d.ts.map +1 -1
  138. package/dist/drift/index.js +1 -0
  139. package/dist/drift/skill-view-diagnostic.d.ts +197 -0
  140. package/dist/drift/skill-view-diagnostic.d.ts.map +1 -0
  141. package/dist/drift/skill-view-diagnostic.js +343 -0
  142. package/dist/validation/skills.d.ts +1 -0
  143. package/dist/validation/skills.d.ts.map +1 -1
  144. package/dist/validation/skills.js +181 -19
  145. package/package.json +2 -2
@@ -0,0 +1,197 @@
1
+ import type { ManifestEntryV2 } from '../manifest/manifest.types.js';
2
+ import type { ProviderRegistration, ProviderScopeContext } from '../providers/shared/registry.js';
3
+ import type { ConcreteScope, ContentType } from '../shared/types.js';
4
+ import type { DriftReport, DriftState } from './drift.types.js';
5
+ /**
6
+ * Resolution-time classification of one canonical skill against one provider
7
+ * view.
8
+ *
9
+ * This is a new field that sits *beside* the unchanged {@link DriftState}, not
10
+ * a replacement for it: `detectDrift` answers "does the tracked view still
11
+ * match?", which presupposes a manifest entry. The headline case this module
12
+ * exists for — a canonical skill nobody ever synced — has no manifest entry at
13
+ * all, so its provider and path identity come from the provider scope context
14
+ * and the adapter mappings instead.
15
+ *
16
+ * - `missing-additive`: active, supported, nothing tracked, nothing on disk at
17
+ * the expected path. The only true projection gap.
18
+ * - `removed`: tracked, but the provider file is gone.
19
+ * - `modified`: tracked, and the provider file diverged.
20
+ * - `in-sync`: the view matches the canonical skill (including a native-read
21
+ * provider, whose view *is* the canonical file).
22
+ * - `untracked`: something exists at the expected path with no manifest entry.
23
+ * Reported as such rather than as missing, because nothing is absent.
24
+ * - `unverified`: the view's state is unknown — either a manifest entry arrived
25
+ * with no drift observation, or reading this one view failed and the
26
+ * observation carries the redacted reason. Never `untracked`, which would
27
+ * contradict `tracked: true` on the same record.
28
+ * - `inactive`, `unsupported`, `excluded`: no projection is expected at all, so
29
+ * none of these ever carries a sync suggestion.
30
+ *
31
+ * Reachability today: `unsupported` needs a registered adapter with no `skill`
32
+ * mapping for the scope, and every shipped adapter maps skills in both scopes;
33
+ * `excluded` needs a canonical-path filter that the `oat tools info` wiring
34
+ * never passes. Both are defensive branches, covered by fixtures rather than by
35
+ * a live CLI path, and they exist so a future adapter or filter cannot be
36
+ * silently misreported as a projection gap. `unverified` is reachable: an
37
+ * unreadable provider path makes `detectDrift` throw, and that one view
38
+ * degrades to `unverified` with its reason.
39
+ */
40
+ export type SkillViewClass = 'in-sync' | 'missing-additive' | 'removed' | 'modified' | 'untracked' | 'unverified' | 'inactive' | 'unsupported' | 'excluded';
41
+ /**
42
+ * Where a provider's view of one canonical skill is expected to live.
43
+ *
44
+ * Derived from the adapter's scope mappings, so it exists whether or not a
45
+ * manifest entry does. Deliberately carries no `strategy`: the concrete
46
+ * symlink/copy choice for an *untracked* projection is resolved by the sync
47
+ * engine from config at sync time (`resolveStrategy` in
48
+ * `engine/compute-plan.ts`), and re-deriving that precedence here could
49
+ * contradict it. A tracked projection carries its real strategy on the
50
+ * manifest entry, which is what the version-comparability rule needs.
51
+ */
52
+ export interface ExpectedProjection {
53
+ provider: string;
54
+ /** Scope-relative path, matching the manifest's `providerPath` convention. */
55
+ providerPath: string;
56
+ contentKind: ContentType;
57
+ /**
58
+ * The provider reads canonical content in place (`nativeRead` mapping), so
59
+ * the "view" is the canonical file and there is nothing to project.
60
+ */
61
+ nativeRead: boolean;
62
+ /** Set when a canonical-path filter keeps this skill out of the projection. */
63
+ excludedReason?: string;
64
+ }
65
+ /**
66
+ * How the projected view's own version declaration read.
67
+ *
68
+ * Carries the shared resolver's verdict rather than just a string: a
69
+ * `conflict`, `unusable`, or `malformed` declaration is a parse artifact, and
70
+ * a copy must never be reported as stale on that evidence.
71
+ */
72
+ export interface ProjectedSkillVersion {
73
+ version: string | null;
74
+ state: 'resolved' | 'absent' | 'conflict' | 'unusable' | 'malformed';
75
+ conflict?: {
76
+ metadata: string;
77
+ topLevel: string;
78
+ };
79
+ }
80
+ /** One provider's observed reality for the expected projection. */
81
+ export interface SkillViewObservation {
82
+ projection: ExpectedProjection;
83
+ /** The manifest entry keyed by (canonicalPath, provider), when tracked. */
84
+ manifestEntry: ManifestEntryV2 | null;
85
+ /** `detectDrift` output; only available when a manifest entry exists. */
86
+ drift: DriftReport | null;
87
+ /** Whether anything exists at the expected provider path. */
88
+ viewPresent: boolean;
89
+ /**
90
+ * Set when reading *this* view failed, carrying the already-redacted reason.
91
+ *
92
+ * A per-view read failure — `detectDrift` throwing on an unreadable provider
93
+ * path, for instance — says nothing about the other providers in the same
94
+ * scope, so it degrades one row instead of the whole section.
95
+ */
96
+ unavailableReason?: string;
97
+ /**
98
+ * Version read from the provider copy, with the resolver's verdict. Only
99
+ * meaningful for `copy` entries.
100
+ */
101
+ projectedVersion?: ProjectedSkillVersion;
102
+ }
103
+ export interface SkillViewDiagnostic {
104
+ skill: string;
105
+ scope: ConcreteScope;
106
+ provider: string;
107
+ viewClass: SkillViewClass;
108
+ /** Unchanged `DriftState`; `null` when no manifest entry allowed detection. */
109
+ driftState: DriftState | null;
110
+ /**
111
+ * Scope-relative path this row is about; `null` when no view is expected.
112
+ *
113
+ * When a manifest entry tracks the view at a path that is not the adapter's
114
+ * expected projection path, this is the *manifest's* path, because that is
115
+ * the path the drift verdict, the version, and the detail all describe. The
116
+ * expected path then travels separately in `expectedProviderPath`.
117
+ */
118
+ providerPath: string | null;
119
+ /**
120
+ * The adapter's expected projection path, present only when the manifest
121
+ * tracks the view somewhere else.
122
+ *
123
+ * Absent on every ordinary row: a row whose manifest entry sits at the
124
+ * expected path has one path, not two.
125
+ */
126
+ expectedProviderPath?: string;
127
+ tracked: boolean;
128
+ strategy: ManifestEntryV2['strategy'] | null;
129
+ nativeRead: boolean;
130
+ canonicalVersion: string | null;
131
+ viewVersion: string | null;
132
+ /** Versions are comparable only for `copy` views that exist. */
133
+ versionComparable: boolean;
134
+ /**
135
+ * How the view's own version declaration read. `conflict`, `unusable`, and
136
+ * `malformed` are why a comparison may have been withheld.
137
+ */
138
+ versionEvidence?: ProjectedSkillVersion['state'];
139
+ /** Narrowest safe repair: one concrete scope, never `--scope all`. */
140
+ suggestion: string | null;
141
+ detail: string;
142
+ }
143
+ export interface SkillViewDiagnosis {
144
+ skill: string;
145
+ scope: ConcreteScope;
146
+ /**
147
+ * `unknown-skill` is a distinct top-level result from a skill that exists
148
+ * canonically but reaches no provider view, so missing distribution is never
149
+ * confused with a name the repository does not have.
150
+ *
151
+ * `unavailable` means the diagnostic's own inputs could not be read (an
152
+ * unreadable or invalid manifest, for instance). It is reported in the
153
+ * section with its reason and never raised as a command failure: this
154
+ * diagnostic is additive evidence, so it must not take down the tool detail
155
+ * of the very user whose sync state is already broken.
156
+ */
157
+ result: 'diagnosed' | 'unknown-skill' | 'unavailable';
158
+ /** Why the diagnosis is `unavailable`; scope-root paths are redacted. */
159
+ reason?: string;
160
+ views: SkillViewDiagnostic[];
161
+ }
162
+ /**
163
+ * Builds the expected provider path for one canonical skill, per registered
164
+ * adapter that maps skills in this scope.
165
+ *
166
+ * Mirrors the engine's own derivation (`providerDir` + entry name in
167
+ * `computeSyncPlan`). A canonical skill is a directory, and the engine applies
168
+ * `providerExtension` only to file entries, so the directory name is carried
169
+ * through unchanged.
170
+ *
171
+ * `allowedCanonicalPaths` mirrors `computeSyncPlan`'s filter of the same name:
172
+ * a targeted sync narrows the plan to specific canonical paths. No durable
173
+ * config excludes a canonical skill today, so the `oat tools info` wiring
174
+ * passes nothing; the parameter exists so that a filtered projection is
175
+ * reported as `excluded` rather than as a projection gap.
176
+ */
177
+ export declare function resolveExpectedSkillProjections(input: {
178
+ skillName: string;
179
+ scope: ConcreteScope;
180
+ registrations: readonly ProviderRegistration[];
181
+ allowedCanonicalPaths?: readonly string[];
182
+ }): ExpectedProjection[];
183
+ /**
184
+ * Maps one canonical skill onto one diagnostic per registered provider for a
185
+ * single concrete scope. Pure: every filesystem, manifest, and drift fact is
186
+ * supplied by the caller.
187
+ */
188
+ export declare function diagnoseSkillViews(input: {
189
+ skillName: string;
190
+ scope: ConcreteScope;
191
+ /** Whether the canonical skill exists in this scope. */
192
+ canonicalPresent: boolean;
193
+ canonicalVersion: string | null;
194
+ providerScopeContext: ProviderScopeContext;
195
+ observations: readonly SkillViewObservation[];
196
+ }): SkillViewDiagnosis;
197
+ //# sourceMappingURL=skill-view-diagnostic.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"skill-view-diagnostic.d.ts","sourceRoot":"","sources":["../../src/drift/skill-view-diagnostic.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAEhE,OAAO,KAAK,EACV,oBAAoB,EACpB,oBAAoB,EACrB,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAEhE,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE7D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,MAAM,MAAM,cAAc,GACtB,SAAS,GACT,kBAAkB,GAClB,SAAS,GACT,UAAU,GACV,WAAW,GACX,YAAY,GACZ,UAAU,GACV,aAAa,GACb,UAAU,CAAC;AAEf;;;;;;;;;;GAUG;AACH,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,MAAM,CAAC;IACjB,8EAA8E;IAC9E,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,WAAW,CAAC;IACzB;;;OAGG;IACH,UAAU,EAAE,OAAO,CAAC;IACpB,+EAA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EAAE,OAAO,CAAC;IAC3B;;;OAGG;IACH,eAAe,CAAC,EAAE,qBAAqB,CAAC,OAAO,CAAC,CAAC;IACjD,sEAAsE;IACtE,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,aAAa,CAAC;IACrB;;;;;;;;;;OAUG;IACH,MAAM,EAAE,WAAW,GAAG,eAAe,GAAG,aAAa,CAAC;IACtD,yEAAyE;IACzE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,mBAAmB,EAAE,CAAC;CAC9B;AAeD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,+BAA+B,CAAC,KAAK,EAAE;IACrD,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,aAAa,CAAC;IACrB,aAAa,EAAE,SAAS,oBAAoB,EAAE,CAAC;IAC/C,qBAAqB,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CAC3C,GAAG,kBAAkB,EAAE,CAwBvB;AAoLD;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE;IACxC,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,aAAa,CAAC;IACrB,wDAAwD;IACxD,gBAAgB,EAAE,OAAO,CAAC;IAC1B,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,oBAAoB,EAAE,oBAAoB,CAAC;IAC3C,YAAY,EAAE,SAAS,oBAAoB,EAAE,CAAC;CAC/C,GAAG,kBAAkB,CA+JrB"}
@@ -0,0 +1,343 @@
1
+ import { join } from 'node:path';
2
+ const CANONICAL_SKILL_DIR = join('.agents', 'skills');
3
+ function skillMappingFor(registration, scope) {
4
+ const mappings = scope === 'project'
5
+ ? registration.adapter.projectMappings
6
+ : registration.adapter.userMappings;
7
+ return mappings.find(({ contentType }) => contentType === 'skill');
8
+ }
9
+ /**
10
+ * Builds the expected provider path for one canonical skill, per registered
11
+ * adapter that maps skills in this scope.
12
+ *
13
+ * Mirrors the engine's own derivation (`providerDir` + entry name in
14
+ * `computeSyncPlan`). A canonical skill is a directory, and the engine applies
15
+ * `providerExtension` only to file entries, so the directory name is carried
16
+ * through unchanged.
17
+ *
18
+ * `allowedCanonicalPaths` mirrors `computeSyncPlan`'s filter of the same name:
19
+ * a targeted sync narrows the plan to specific canonical paths. No durable
20
+ * config excludes a canonical skill today, so the `oat tools info` wiring
21
+ * passes nothing; the parameter exists so that a filtered projection is
22
+ * reported as `excluded` rather than as a projection gap.
23
+ */
24
+ export function resolveExpectedSkillProjections(input) {
25
+ const canonicalPath = join(CANONICAL_SKILL_DIR, input.skillName);
26
+ const excluded = input.allowedCanonicalPaths !== undefined &&
27
+ !input.allowedCanonicalPaths.includes(canonicalPath);
28
+ const projections = [];
29
+ for (const registration of input.registrations) {
30
+ const mapping = skillMappingFor(registration, input.scope);
31
+ if (!mapping)
32
+ continue;
33
+ projections.push({
34
+ provider: registration.adapter.name,
35
+ providerPath: join(mapping.providerDir, input.skillName),
36
+ contentKind: 'skill',
37
+ nativeRead: mapping.nativeRead,
38
+ ...(excluded
39
+ ? {
40
+ excludedReason: `targeted sync filter does not include ${canonicalPath}`,
41
+ }
42
+ : {}),
43
+ });
44
+ }
45
+ return projections;
46
+ }
47
+ function driftReasonText(state) {
48
+ return state.status === 'drifted' ? state.reason : state.status;
49
+ }
50
+ function versionNote(strategy) {
51
+ if (strategy === 'symlink') {
52
+ return ' The view is a symlink to the canonical file, so it has no separate version.';
53
+ }
54
+ if (strategy === 'collection') {
55
+ return ' The view is inherited from a collection alias, so it has no separate version.';
56
+ }
57
+ return '';
58
+ }
59
+ /** Names a version declaration the resolver could not take at face value. */
60
+ function projectedVersionNote(projected, withheld) {
61
+ if (!projected)
62
+ return '';
63
+ if (projected.state === 'conflict' && projected.conflict) {
64
+ const declaration = `The projected SKILL.md declares metadata.version ${projected.conflict.metadata} and top-level version ${projected.conflict.topLevel}; reconcile the two fields.`;
65
+ // The resolver is deterministic — it takes `metadata.version` — so a
66
+ // conflicting copy can genuinely be stale. When the comparison is
67
+ // withheld, say the check was skipped rather than implying the view is
68
+ // fine; when the resolved value agrees with canonical, nothing was
69
+ // withheld and claiming otherwise would be its own falsehood.
70
+ return withheld
71
+ ? ` ${declaration} A self-contradicting declaration is not usable as evidence, so the version comparison was skipped: a real difference from canonical would not be reported here.`
72
+ : ` ${declaration} The shared resolver takes metadata.version, which is the version compared above.`;
73
+ }
74
+ if (projected.state === 'unusable') {
75
+ return ' The projected SKILL.md declares a version that cannot be read, so no version comparison is made.';
76
+ }
77
+ if (projected.state === 'malformed') {
78
+ return ' The projected SKILL.md frontmatter does not parse, so no version comparison is made.';
79
+ }
80
+ return '';
81
+ }
82
+ /**
83
+ * Says which path this row is really about when the manifest disagrees with the
84
+ * adapter.
85
+ *
86
+ * The manifest is keyed by `(canonicalPath, provider)` and never by path, so an
87
+ * entry can point somewhere other than the adapter's expected projection while a
88
+ * healthy file sits at the expected path — reachable after a `providerDir`
89
+ * change or from a manifest written under an older layout. Attaching the drift
90
+ * verdict for the tracked path to a row labelled with the expected path made the
91
+ * row state something false about a file that exists, so the row names the
92
+ * tracked path and this note says what the expected path looks like instead.
93
+ */
94
+ function divergentPathNote(observation) {
95
+ const tracked = observation.manifestEntry?.providerPath;
96
+ if (tracked === undefined ||
97
+ tracked === observation.projection.providerPath) {
98
+ return '';
99
+ }
100
+ // `viewPresent` is only evidence when the observation succeeded: a failed
101
+ // read leaves it at its default, and reporting that default as absence would
102
+ // replace one false claim about the expected path with another.
103
+ const expectedPathNote = observation.unavailableReason !== undefined
104
+ ? 'Whether anything exists at the expected path was not established.'
105
+ : observation.viewPresent
106
+ ? 'Something does exist at the expected path, and this row says nothing about it.'
107
+ : 'Nothing exists at the expected path either.';
108
+ return ` The manifest tracks this view at ${tracked}, which is not the expected projection path ${observation.projection.providerPath}; the state, path, and version above all describe the tracked path. ${expectedPathNote} Syncing this scope re-projects the skill to the expected path.`;
109
+ }
110
+ function classify(observation, isActive) {
111
+ const { projection, manifestEntry, drift, viewPresent } = observation;
112
+ if (!isActive) {
113
+ return {
114
+ viewClass: 'inactive',
115
+ detail: 'Provider is not active in this scope, so nothing is projected.',
116
+ };
117
+ }
118
+ if (observation.unavailableReason !== undefined) {
119
+ // `unverified` is the honest class: a read failure is not evidence of a
120
+ // projection gap, and reporting one as `missing-additive` or `removed`
121
+ // would send the user to a sync that fixes nothing.
122
+ return {
123
+ viewClass: 'unverified',
124
+ detail: `The diagnostic could not read this view, so its state is unverified: ${observation.unavailableReason}`,
125
+ };
126
+ }
127
+ if (projection.excludedReason !== undefined) {
128
+ return {
129
+ viewClass: 'excluded',
130
+ detail: `Excluded from this scope's projection: ${projection.excludedReason}.`,
131
+ };
132
+ }
133
+ if (projection.nativeRead) {
134
+ return {
135
+ viewClass: 'in-sync',
136
+ detail: 'Provider reads the canonical skill in place; there is no separate view to sync or version to compare.',
137
+ };
138
+ }
139
+ if (!manifestEntry) {
140
+ if (viewPresent) {
141
+ return {
142
+ viewClass: 'untracked',
143
+ detail: 'An untracked file occupies the expected path. Stray detection skips provider entries whose name matches a canonical entry, so "oat status" does not report it as a stray; it reports the untracked projection as missing instead. Inspect the path and remove it if it is not wanted, then sync the scope; no repair is suggested here because a sync could overwrite content OAT does not own.',
144
+ };
145
+ }
146
+ return {
147
+ viewClass: 'missing-additive',
148
+ detail: 'Canonical skill has never been projected to this view: no manifest entry and nothing at the expected path.',
149
+ };
150
+ }
151
+ if (!drift) {
152
+ // A tracked entry must never be labelled `untracked`: the same record
153
+ // reports `tracked: true`, and the two together are self-contradictory.
154
+ return {
155
+ viewClass: 'unverified',
156
+ detail: 'A manifest entry tracks this view but no drift observation accompanied it, so its state is unverified.',
157
+ };
158
+ }
159
+ if (drift.state.status === 'missing') {
160
+ return {
161
+ viewClass: 'removed',
162
+ detail: 'The manifest tracks this view but the provider file is gone from disk.',
163
+ };
164
+ }
165
+ if (drift.state.status === 'drifted') {
166
+ return {
167
+ viewClass: 'modified',
168
+ detail: `The tracked view diverged from the canonical skill (${driftReasonText(drift.state)}).`,
169
+ };
170
+ }
171
+ if (drift.state.status === 'in_sync') {
172
+ return {
173
+ viewClass: 'in-sync',
174
+ // A copy is only known to match the content recorded at its last sync:
175
+ // `detectDrift` compares it against the manifest hash, so a canonical
176
+ // edit that was never re-synced leaves both sides agreeing. Say exactly
177
+ // that rather than claiming canonical equality the check cannot support.
178
+ detail: manifestEntry.strategy === 'copy'
179
+ ? 'The tracked copy still matches the content recorded at its last sync; a canonical edit that was never re-synced is not visible in the manifest hash.'
180
+ : 'The tracked view matches the canonical skill.',
181
+ };
182
+ }
183
+ // `detectDrift` never returns `stray` for a keyed entry; treat any such
184
+ // report as unmanaged rather than inventing a projection gap.
185
+ return {
186
+ viewClass: 'untracked',
187
+ detail: 'The provider file is reported as an unmanaged stray.',
188
+ };
189
+ }
190
+ const REPAIRABLE = [
191
+ 'missing-additive',
192
+ 'removed',
193
+ 'modified',
194
+ ];
195
+ /**
196
+ * Maps one canonical skill onto one diagnostic per registered provider for a
197
+ * single concrete scope. Pure: every filesystem, manifest, and drift fact is
198
+ * supplied by the caller.
199
+ */
200
+ export function diagnoseSkillViews(input) {
201
+ if (!input.canonicalPresent) {
202
+ return {
203
+ skill: input.skillName,
204
+ scope: input.scope,
205
+ result: 'unknown-skill',
206
+ views: [],
207
+ };
208
+ }
209
+ const active = new Set(input.providerScopeContext.activeProviders);
210
+ const byProvider = new Map(input.observations.map((observation) => [
211
+ observation.projection.provider,
212
+ observation,
213
+ ]));
214
+ const views = [];
215
+ for (const registration of input.providerScopeContext.registrations) {
216
+ const provider = registration.adapter.name;
217
+ const observation = byProvider.get(provider);
218
+ if (!observation) {
219
+ views.push({
220
+ skill: input.skillName,
221
+ scope: input.scope,
222
+ provider,
223
+ viewClass: 'unsupported',
224
+ driftState: null,
225
+ providerPath: null,
226
+ tracked: false,
227
+ strategy: null,
228
+ nativeRead: false,
229
+ canonicalVersion: input.canonicalVersion,
230
+ viewVersion: null,
231
+ versionComparable: false,
232
+ suggestion: null,
233
+ detail: `Provider has no ${input.scope} skill mapping, so no view is expected.`,
234
+ });
235
+ continue;
236
+ }
237
+ const isActive = active.has(provider);
238
+ const classification = classify(observation, isActive);
239
+ const strategy = observation.manifestEntry?.strategy ?? null;
240
+ const nativeRead = observation.projection.nativeRead;
241
+ // A drift verdict computed for the manifest's path may only appear on a row
242
+ // that names that path. The divergence is reported wherever the manifest
243
+ // entry is what drives the row: an inactive, excluded, or natively read
244
+ // provider has no drift verdict to misattribute.
245
+ const trackedPath = observation.manifestEntry?.providerPath;
246
+ const pathDiverges = trackedPath !== undefined &&
247
+ trackedPath !== observation.projection.providerPath &&
248
+ isActive &&
249
+ !nativeRead &&
250
+ observation.projection.excludedReason === undefined;
251
+ const copyViewReadable = strategy === 'copy' &&
252
+ !nativeRead &&
253
+ (classification.viewClass === 'modified' ||
254
+ classification.viewClass === 'in-sync');
255
+ const projected = observation.projectedVersion;
256
+ const resolvedViewVersion = copyViewReadable
257
+ ? (projected?.version ?? null)
258
+ : null;
259
+ const versionState = projected?.state ?? 'absent';
260
+ // A declaration the resolver could not read, or one that contradicts
261
+ // itself while disagreeing with canonical, is not usable as evidence of
262
+ // divergence. Report no comparable version instead of a stale claim.
263
+ const untrustworthyVersion = versionState === 'unusable' ||
264
+ versionState === 'malformed' ||
265
+ (versionState === 'conflict' &&
266
+ resolvedViewVersion !== input.canonicalVersion);
267
+ const viewVersion = untrustworthyVersion ? null : resolvedViewVersion;
268
+ const versionComparable = copyViewReadable && viewVersion !== null;
269
+ // `detectDrift` compares a copy against the hash recorded at the last
270
+ // sync, so a copy that was never re-synced after a canonical edit matches
271
+ // its own manifest entry and reads as `in_sync`. Two different versions
272
+ // are proof the view is not the canonical content, whatever the manifest
273
+ // agrees with. `driftState` still reports exactly what the detector said.
274
+ const staleCopy = versionComparable &&
275
+ versionState === 'resolved' &&
276
+ classification.viewClass === 'in-sync' &&
277
+ input.canonicalVersion !== null &&
278
+ viewVersion !== null &&
279
+ viewVersion !== input.canonicalVersion;
280
+ // The mirror case: the detector reports a copy as drifted while its
281
+ // version matches canonical. That is the expected state after a
282
+ // copy-strategy sync, because the OAT-managed banner and `.oat-generated`
283
+ // sentinel are not accounted for in the manifest hash
284
+ // (BL-260908-make-copy-strategy-skill), and no sync clears it.
285
+ //
286
+ // Suppressing the repair here is a conservative heuristic, not a proof:
287
+ // equal versions do not establish equal bodies, so an edit to either side
288
+ // that kept the version reaches this branch too, and a sync would fix
289
+ // that one. The detail therefore says which case it cannot distinguish
290
+ // and names the concrete scope command, rather than claiming the content
291
+ // is current.
292
+ const unrepairableCopy = versionComparable &&
293
+ classification.viewClass === 'modified' &&
294
+ input.canonicalVersion !== null &&
295
+ viewVersion === input.canonicalVersion;
296
+ const { viewClass, detail } = staleCopy
297
+ ? {
298
+ viewClass: 'modified',
299
+ detail: `The tracked copy still matches the hash recorded at its last sync, but its version (${viewVersion}) differs from the canonical version (${input.canonicalVersion}), so the view is stale.`,
300
+ }
301
+ : unrepairableCopy
302
+ ? {
303
+ viewClass: 'modified',
304
+ detail: `The detector reports this copy as drifted while its version still matches canonical (${input.canonicalVersion}). That is expected after a copy-strategy sync until BL-260908-make-copy-strategy-skill lands: the OAT-managed banner and ".oat-generated" sentinel are not accounted for in the manifest hash, and no sync clears it. Equal versions do not prove the bodies match, so if either side was edited without a version change, compare them and run "oat sync --scope ${input.scope}" yourself.`,
305
+ }
306
+ : classification;
307
+ views.push({
308
+ skill: input.skillName,
309
+ scope: input.scope,
310
+ provider,
311
+ viewClass,
312
+ driftState: observation.drift?.state ?? null,
313
+ providerPath: pathDiverges
314
+ ? trackedPath
315
+ : observation.projection.providerPath,
316
+ ...(pathDiverges
317
+ ? { expectedProviderPath: observation.projection.providerPath }
318
+ : {}),
319
+ tracked: observation.manifestEntry !== null,
320
+ strategy,
321
+ nativeRead,
322
+ canonicalVersion: input.canonicalVersion,
323
+ viewVersion,
324
+ versionComparable,
325
+ ...(copyViewReadable ? { versionEvidence: versionState } : {}),
326
+ // The narrowest safe repair is the single concrete scope where the gap
327
+ // was observed. `--scope all` would widen a one-scope repair into a
328
+ // two-scope write.
329
+ suggestion: REPAIRABLE.includes(viewClass) && !unrepairableCopy
330
+ ? `oat sync --scope ${input.scope}`
331
+ : null,
332
+ detail: `${versionComparable ? detail : `${detail}${versionNote(strategy)}`}${copyViewReadable
333
+ ? projectedVersionNote(projected, untrustworthyVersion)
334
+ : ''}${pathDiverges ? divergentPathNote(observation) : ''}`,
335
+ });
336
+ }
337
+ return {
338
+ skill: input.skillName,
339
+ scope: input.scope,
340
+ result: 'diagnosed',
341
+ views,
342
+ };
343
+ }
@@ -2,6 +2,7 @@ export interface ValidationFinding {
2
2
  file: string;
3
3
  message: string;
4
4
  severity?: 'error' | 'warning';
5
+ code?: string;
5
6
  }
6
7
  export interface ValidateOatSkillsResult {
7
8
  validatedSkillCount: number;
@@ -1 +1 @@
1
- {"version":3,"file":"skills.d.ts","sourceRoot":"","sources":["../../src/validation/skills.ts"],"names":[],"mappings":"AAOA,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;CAChC;AAED,MAAM,WAAW,uBAAuB;IACtC,mBAAmB,EAAE,MAAM,CAAC;IAC5B,QAAQ,EAAE,iBAAiB,EAAE,CAAC;CAC/B;AAED,MAAM,WAAW,uCAAuC;IACtD,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,sCAAsC;IACrD,mBAAmB,EAAE,MAAM,CAAC;IAC5B,QAAQ,EAAE,iBAAiB,EAAE,CAAC;CAC/B;AAED,MAAM,WAAW,wBAAwB;IACvC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,cAAc,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CACpC;A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