@aiwg/cli 2026.10.11 → 2026.10.14

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 (174) hide show
  1. package/agentic/code/providers/model-catalog.v1.json +62 -12
  2. package/agentic/code/providers/pi/aiwg-bridge.ts +44 -1
  3. package/dist/src/artifacts/binding-target-identity.js +51 -0
  4. package/dist/src/artifacts/checksum-manifest.js +12 -0
  5. package/dist/src/artifacts/index-builder.js +11 -13
  6. package/dist/src/artifacts/query-engine.js +5 -11
  7. package/dist/src/cli/handlers/doctor-help.js +32 -0
  8. package/dist/src/cli/handlers/gates.js +19 -18
  9. package/dist/src/cli/handlers/models-help.js +7 -1
  10. package/dist/src/cli/handlers/models.js +3 -3
  11. package/dist/src/cli/handlers/script-runner.js +8 -5
  12. package/dist/src/cli/handlers/sessions-intake.js +104 -0
  13. package/dist/src/cli/handlers/sessions-tail.js +172 -0
  14. package/dist/src/cli/handlers/sessions.js +90 -17
  15. package/dist/src/cli/handlers/skill-lint.js +10 -3
  16. package/dist/src/cli/handlers/steward-format.js +100 -0
  17. package/dist/src/cli/handlers/steward-models.js +167 -0
  18. package/dist/src/cli/handlers/steward.js +14 -248
  19. package/dist/src/cli/handlers/use-bundle-counts.js +87 -0
  20. package/dist/src/cli/handlers/use-skill-assets.js +207 -0
  21. package/dist/src/cli/handlers/use.js +35 -216
  22. package/dist/src/cli/handlers/utilities.js +1 -24
  23. package/dist/src/config/aiwg-config.js +7 -0
  24. package/dist/src/config/authorization-cli.js +97 -0
  25. package/dist/src/config/cli-help.js +1 -0
  26. package/dist/src/config/cli.js +10 -1
  27. package/dist/src/decision/context-pruning-common.js +41 -0
  28. package/dist/src/decision/context-pruning-evaluation.js +366 -0
  29. package/dist/src/decision/context-pruning-pilot.js +431 -0
  30. package/dist/src/decision/context-pruning-types.js +19 -0
  31. package/dist/src/decision/context-pruning.js +5 -846
  32. package/dist/src/decision/ensemble/contract.js +17 -26
  33. package/dist/src/decision/ensemble-study/artifacts.js +5 -0
  34. package/dist/src/decision/ensemble-study/score.js +4 -3
  35. package/dist/src/decision/feature-export.js +3 -9
  36. package/dist/src/decision/heldout/collector.js +2 -2
  37. package/dist/src/decision/issue-triage/runtime.js +3 -9
  38. package/dist/src/decision/qualification/gates.js +2 -1
  39. package/dist/src/decision/qualification/release.js +6 -64
  40. package/dist/src/decision/routing/report.js +2 -0
  41. package/dist/src/decision/sdlc-screening.js +3 -5
  42. package/dist/src/decision/sensitivity/comparative.js +5 -3
  43. package/dist/src/extensions/manifest.js +8 -1
  44. package/dist/src/extensions/project-local-doctor.js +78 -2
  45. package/dist/src/extensions/validation.js +10 -11
  46. package/dist/src/gates/driver.js +6 -77
  47. package/dist/src/gates/evaluate.js +6 -23
  48. package/dist/src/gates/floors.js +4 -4
  49. package/dist/src/gates/index.js +3 -3
  50. package/dist/src/gates/lattice.js +26 -0
  51. package/dist/src/gates/registry.js +2 -1
  52. package/dist/src/gates/report.js +19 -7
  53. package/dist/src/gates/upstream-ceiling.js +111 -0
  54. package/dist/src/issues/audit-cli.js +120 -0
  55. package/dist/src/issues/audit-contract.js +64 -0
  56. package/dist/src/issues/audit-local.js +82 -0
  57. package/dist/src/issues/audit.js +220 -0
  58. package/dist/src/lint/rule-activation.js +15 -1
  59. package/dist/src/mission-protocol/canonical-codecs.js +270 -0
  60. package/dist/src/mission-protocol/codecs.js +22 -550
  61. package/dist/src/mission-protocol/health-trace-codecs.js +281 -0
  62. package/dist/src/mission-protocol/health-trace-types.js +43 -0
  63. package/dist/src/mission-protocol/types.js +2 -42
  64. package/dist/src/mission-protocol/worker-contract-json.js +10 -0
  65. package/dist/src/mission-protocol/worker-review-gate.js +100 -0
  66. package/dist/src/mission-protocol/worker-review-types.js +2 -0
  67. package/dist/src/models/catalog-policy.js +280 -0
  68. package/dist/src/models/index.js +1 -1
  69. package/dist/src/models/model-catalog.v1.json +62 -12
  70. package/dist/src/models/policy-resources.js +28 -0
  71. package/dist/src/models/provider-models.js +5 -8
  72. package/dist/src/models/provider-policy.js +10 -546
  73. package/dist/src/models/resolver.js +26 -8
  74. package/dist/src/models/router.js +15 -2
  75. package/dist/src/models/tiers.js +13 -0
  76. package/dist/src/models/types.js +0 -6
  77. package/dist/src/models/worker-ceilings.js +59 -0
  78. package/dist/src/models/worker-invocation-policy.js +243 -0
  79. package/dist/src/models/worker-plan.js +16 -20
  80. package/dist/src/models/worker-review-lineage.js +55 -0
  81. package/dist/src/models/worker-selection-policy.js +1 -1
  82. package/dist/src/models/wrapper-definitions.js +14 -0
  83. package/dist/src/models/wrapper-deployment.js +48 -25
  84. package/dist/src/models/wrapper-enforcement.js +72 -0
  85. package/dist/src/models/wrapper-route.js +6 -3
  86. package/dist/src/policy/authorization.js +1 -0
  87. package/dist/src/policy/hitl-check.js +80 -0
  88. package/dist/src/policy/hitl-config.js +63 -0
  89. package/dist/src/policy/hitl-receipt.js +57 -0
  90. package/dist/src/policy/hitl-types.js +4 -0
  91. package/dist/src/policy/hitl-validation.js +39 -0
  92. package/dist/src/policy/hitl.js +117 -0
  93. package/dist/src/rules/activation.d.mts +3 -1
  94. package/dist/src/rules/activation.mjs +23 -2
  95. package/dist/src/rules/gate-coverage.js +51 -0
  96. package/dist/src/rules/gate-references.js +16 -0
  97. package/dist/src/rules/rule-frontmatter.schema.json +7 -1
  98. package/dist/src/serve/worker-command-request.js +21 -4
  99. package/dist/src/serve/worker-invocation-preparation.js +3 -1
  100. package/dist/src/serve/worker-invocation.js +21 -10
  101. package/dist/src/sessions/adapters/deepseek-harness.js +1 -0
  102. package/dist/src/sessions/adapters/grok-build-native.js +269 -0
  103. package/dist/src/sessions/adapters/grok-build.js +57 -15
  104. package/dist/src/sessions/adapters/hermes-state-db.js +252 -0
  105. package/dist/src/sessions/adapters/hermes.js +42 -3
  106. package/dist/src/sessions/adapters/warp.js +1 -1
  107. package/dist/src/sessions/batch-import.js +10 -0
  108. package/dist/src/sessions/contracts.js +1 -1
  109. package/dist/src/sessions/discovery-capability.js +38 -0
  110. package/dist/src/sessions/importer.js +8 -251
  111. package/dist/src/sessions/index.js +4 -0
  112. package/dist/src/sessions/intake-dir.js +71 -0
  113. package/dist/src/sessions/normalization.js +251 -0
  114. package/dist/src/sessions/tail.js +91 -0
  115. package/dist/src/sessions/workspace-discovery.js +83 -7
  116. package/dist/src/skills/adapters/local.js +32 -9
  117. package/dist/src/skills/agent-skill-sidecar.js +28 -0
  118. package/dist/src/skills/agent-skills.js +6 -23
  119. package/dist/src/skills/claude-surface-projection.js +25 -0
  120. package/dist/src/skills/cli-display.js +33 -0
  121. package/dist/src/skills/cli.js +2 -26
  122. package/dist/src/skills/collision-discovery.js +84 -0
  123. package/dist/src/skills/deployer.js +26 -361
  124. package/dist/src/skills/deployment-ownership.js +74 -0
  125. package/dist/src/skills/deployment-policy.js +114 -0
  126. package/dist/src/skills/deployment-projection.js +152 -0
  127. package/dist/src/skills/deployment-types.js +20 -0
  128. package/dist/src/skills/doctor.js +2 -2
  129. package/dist/src/skills/exporter.js +8 -31
  130. package/dist/src/skills/importer.js +4 -26
  131. package/dist/src/skills/provider-extensions.js +41 -0
  132. package/dist/src/skills/registry.js +22 -7
  133. package/dist/src/skills/run.js +6 -0
  134. package/dist/src/skills/types.js +0 -8
  135. package/dist/src/skills/validator-resources.js +68 -0
  136. package/dist/src/skills/validator.js +6 -55
  137. package/dist/src/smiths/context-pipeline/parallelism-section.js +7 -3
  138. package/dist/src/storage/cli-migrate-options.js +125 -0
  139. package/dist/src/storage/cli-migrate.js +111 -0
  140. package/dist/src/storage/cli.js +4 -279
  141. package/dist/src/storage/migration-adapter.js +79 -0
  142. package/dist/src/storage/migration-copy.js +108 -0
  143. package/dist/src/storage/migration-protocol.js +14 -197
  144. package/dist/src/storage/migration-records.js +186 -0
  145. package/dist/src/storage/migration-types.js +12 -0
  146. package/dist/src/tracker/forge-http.js +2 -1
  147. package/dist/src/tracker/issue-pages.js +110 -0
  148. package/package.json +3 -1
  149. package/schemas/mission-v1.schema.json +335 -0
  150. package/schemas/models/model-catalog.v1.schema.json +19 -1
  151. package/schemas/models/model-config-compatibility.v1.schema.json +3 -2
  152. package/schemas/models/model-policy.v1.schema.json +1 -1
  153. package/tools/agents/providers/antigravity.mjs +3 -5
  154. package/tools/agents/providers/base.mjs +3 -3
  155. package/tools/agents/providers/claude.mjs +3 -5
  156. package/tools/agents/providers/codex.mjs +3 -5
  157. package/tools/agents/providers/copilot.mjs +3 -5
  158. package/tools/agents/providers/cursor.mjs +3 -5
  159. package/tools/agents/providers/factory.mjs +3 -5
  160. package/tools/agents/providers/grok-build.mjs +9 -7
  161. package/tools/agents/providers/model-wrapper.mjs +86 -0
  162. package/tools/agents/providers/omp.mjs +3 -1
  163. package/tools/agents/providers/openclaw.mjs +3 -5
  164. package/tools/agents/providers/opencode.mjs +3 -5
  165. package/tools/agents/providers/provider-paths-staging.mjs +44 -0
  166. package/tools/agents/providers/rule-binding-targets.mjs +146 -0
  167. package/tools/agents/providers/rule-delivery.mjs +9 -128
  168. package/tools/agents/providers/warp.mjs +3 -5
  169. package/tools/agents/providers/windsurf.mjs +3 -5
  170. package/tools/plugin/package-plugins.mjs +2 -2
  171. package/tools/skills/codex-skill-transform.mjs +232 -0
  172. package/tools/skills/deploy-skills-codex.mjs +8 -249
  173. package/tools/warp/warp-content.mjs +548 -0
  174. package/vscode-extension/schemas/aiwg.config.v1.json +177 -0
@@ -0,0 +1,91 @@
1
+ // Follow a native source through the importer's normalization and checkpoint rules.
2
+ import { setTimeout } from 'node:timers/promises';
3
+ import { SessionContractError, assertSessionResourceLimit, assertSupportedSchemaMajor, sha256 } from './contracts.js';
4
+ import { IncrementalSessionImporter } from './importer.js';
5
+ import { normalizeSessionBatch } from './normalization.js';
6
+ import { assertImportByteLimit, DEFAULT_IMPORT_BYTE_LIMITS } from './import-limits.js';
7
+ export function assertTailSupported(adapter) {
8
+ if (typeof adapter.stream !== 'function' || !adapter.supportedOperations.includes('stream')) {
9
+ throw new SessionContractError('UNSUPPORTED_PROVIDER', `sessions tail is unsupported for provider ${adapter.provider}: adapter has no stream operation`);
10
+ }
11
+ }
12
+ export async function tailSession(options) {
13
+ assertTailSupported(options.adapter);
14
+ assertSupportedSchemaMajor(options.source.sourceSchemaVersion, options.adapter.sourceSchemaMajor ?? 1);
15
+ if (options.workspaceId !== options.selectedSource.authorizedScope.workspaceId) {
16
+ throw new SessionContractError('SOURCE_NOT_AUTHORIZED', 'tail workspace is outside the authorized source scope');
17
+ }
18
+ const pollMs = options.pollMs ?? 500;
19
+ if (!Number.isInteger(pollMs) || pollMs < 1 || pollMs > 500) {
20
+ throw new SessionContractError('INVALID_ARGUMENT', 'tail poll interval must be between 1 and 500 ms');
21
+ }
22
+ let checkpoint = options.repository.getCheckpoint(options.source.sourceId, options.adapter.adapterVersion);
23
+ const port = {
24
+ getCheckpoint: () => checkpoint,
25
+ getBatchCheckpoint: () => null,
26
+ commitStagedImports: () => 0,
27
+ applyImport: (batch, next) => {
28
+ // Publish through the existing import transaction only with explicit opt-in.
29
+ const receipt = options.repository.applyImport(batch, next, true);
30
+ checkpoint = { ...next };
31
+ for (const event of batch.events) {
32
+ if (event.sessionId === options.sessionId)
33
+ options.onEvent(event);
34
+ }
35
+ return receipt;
36
+ },
37
+ };
38
+ const importer = new IncrementalSessionImporter(port);
39
+ while (!options.signal?.aborted) {
40
+ try {
41
+ if (options.import) {
42
+ await importer.import({
43
+ ...options, publish: true, batchRunId: undefined,
44
+ limits: { ...options.limits, batchSize: 1 },
45
+ });
46
+ }
47
+ else {
48
+ // Do not fingerprint or persist snapshots: export adapters may rewrite
49
+ // a JSON document as it grows. Each adapter owns its resume semantics.
50
+ for await (const record of options.adapter.stream(options.selectedSource, checkpoint ? { value: checkpoint.cursor } : undefined)) {
51
+ if (options.signal?.aborted)
52
+ return;
53
+ const serialized = JSON.stringify(record);
54
+ const limits = { ...DEFAULT_IMPORT_BYTE_LIMITS, ...options.limits };
55
+ assertImportByteLimit('maxRecordBytes', limits, Buffer.byteLength(serialized));
56
+ const count = (checkpoint?.recordsRead ?? 0) + 1;
57
+ assertSessionResourceLimit('maxRecords', options.limits?.maxRecords ?? 1_000_000, count);
58
+ const digest = sha256(serialized);
59
+ const runId = sha256([options.source.sourceId, options.adapter.adapterVersion,
60
+ count - 1, count, digest].join('\0'));
61
+ const { events } = normalizeSessionBatch(options, [record], [digest], runId);
62
+ checkpoint = { ...checkpoint, cursor: record.sourceCursor ?? String(count),
63
+ recordsRead: count, bytesRead: (checkpoint?.bytesRead ?? 0) + Buffer.byteLength(serialized) };
64
+ for (const event of events) {
65
+ if (event.sessionId === options.sessionId)
66
+ options.onEvent(event);
67
+ }
68
+ }
69
+ }
70
+ }
71
+ catch (error) {
72
+ if (options.signal?.aborted)
73
+ return;
74
+ // Some native JSONL adapters report an in-progress final line explicitly.
75
+ if (!(options.follow && error instanceof SessionContractError
76
+ && error.code === 'TRUNCATED_SOURCE'))
77
+ throw error;
78
+ }
79
+ await options.onPoll?.();
80
+ if (!options.follow || options.signal?.aborted)
81
+ return;
82
+ try {
83
+ await setTimeout(pollMs, undefined, { signal: options.signal });
84
+ }
85
+ catch (error) {
86
+ if (!options.signal?.aborted)
87
+ throw error;
88
+ }
89
+ }
90
+ }
91
+ //# sourceMappingURL=tail.js.map
@@ -4,6 +4,8 @@ import { basename, dirname, join, resolve } from 'node:path';
4
4
  import { inspectMuseNativeWorkspace } from './adapters/muse.js';
5
5
  import { readOmpSessionHeader } from './adapters/omp.js';
6
6
  import { grokbotConversationIdFromLocator } from './adapters/grokbot-locator.js';
7
+ import { GROK_BUILD_ACTIVE_FRESHNESS_MS, grokBuildLiveState, grokBuildSourceWorkspaceMatch, readGrokBuildActiveRegistry, } from './adapters/grok-build-native.js';
8
+ import { hermesSnapshotStagingDir } from './adapters/hermes-state-db.js';
7
9
  import { resolveOmpPaths } from '../providers/omp-paths.mjs';
8
10
  import { readAiwgConfig } from '../config/aiwg-config.js';
9
11
  import { SessionCoveragePreflightSchema, SessionContractError, sha256, } from './contracts.js';
@@ -15,7 +17,7 @@ import { matchSessionWorkspace } from './workspace-matching.js';
15
17
  import { matchImportExclusion, nativeSessionIdFromLocator, resolveImportExclusions } from './import-exclusions.js';
16
18
  export const DISCOVERY_MANIFEST_VERSION = '1.0.0';
17
19
  const MANUAL_EXPORT_PROVIDERS = new Set([
18
- 'copilot', 'hermes', 'opencode', 'openclaw', 'openhuman', 'grok-build',
20
+ 'copilot', 'opencode', 'openclaw', 'openhuman',
19
21
  'warp', 'devin-desktop', 'generic',
20
22
  ]);
21
23
  export async function discoverWorkspaceHistories(options) {
@@ -31,6 +33,8 @@ export async function discoverWorkspaceHistories(options) {
31
33
  ...(options.museRoot ? ['muse'] : []),
32
34
  ...(options.dshRoot ? ['deepseek-harness'] : []),
33
35
  ...(options.grokbotRoot ? ['grokbot'] : []),
36
+ ...(options.grokRoot ? ['grok-build'] : []),
37
+ ...(options.hermesRoot ? ['hermes'] : []),
34
38
  ];
35
39
  const savedRoots = options.authorizedRoots ?? options.refreshFrom?.authorizedRoots;
36
40
  const authorizedProviders = options.refreshFrom
@@ -68,6 +72,15 @@ export async function discoverWorkspaceHistories(options) {
68
72
  // no-filtering behavior already used for `pi`/`deepseek-harness`).
69
73
  { provider: 'grokbot', roots: options.grokbotRoot
70
74
  ? [resolve(options.grokbotRoot)] : [] },
75
+ // Grok Build authorizes the sessions directory itself, never Grok home:
76
+ // `<root>/<url-encoded cwd>/<id>/chat_history.jsonl`. No fallback through
77
+ // $HOME, GROK_HOME, or --provider-home grants access.
78
+ { provider: 'grok-build', roots: options.grokRoot
79
+ ? [resolve(options.grokRoot)] : [] },
80
+ // Hermes authorizes `<root>/state.db` for a read-only backup snapshot.
81
+ // Staging joins the scope below; nothing else under the root is read.
82
+ { provider: 'hermes', roots: options.hermesRoot
83
+ ? [resolve(options.hermesRoot)] : [] },
71
84
  {
72
85
  provider: 'claude',
73
86
  // Same scope rule as codex: configured providers keep their root grant
@@ -155,14 +168,17 @@ export async function discoverWorkspaceHistories(options) {
155
168
  }
156
169
  }
157
170
  if (availableRoots.length === 0) {
158
- const codexNeedsAuthorization = (entry.provider === 'codex' || entry.provider === 'omp'
171
+ const needsExplicitRoot = (entry.provider === 'codex' || entry.provider === 'omp'
159
172
  || entry.provider === 'deepseek-harness' || entry.provider === 'muse'
160
- || entry.provider === 'grokbot')
173
+ || entry.provider === 'grokbot' || entry.provider === 'grok-build'
174
+ || entry.provider === 'hermes')
161
175
  && entry.roots.length === 0;
162
- reports.set(entry.provider, providerReport(entry.provider, codexNeedsAuthorization ? 'export-required' : 'unavailable', codexNeedsAuthorization ? 'manual-export' : 'discoverable', [], codexNeedsAuthorization
176
+ const expectedFlag = entry.provider === 'deepseek-harness' ? 'dsh' : entry.provider;
177
+ const rootKind = entry.provider === 'hermes' ? 'Hermes home (state.db is snapshotted read-only)' : 'sessions root';
178
+ reports.set(entry.provider, providerReport(entry.provider, needsExplicitRoot ? 'export-required' : 'unavailable', needsExplicitRoot ? 'manual-export' : 'discoverable', [], needsExplicitRoot
163
179
  ? 'SHARED_ROOT_AUTHORIZATION_REQUIRED'
164
- : 'PROVIDER_ROOT_UNAVAILABLE', codexNeedsAuthorization
165
- ? `Pass --${entry.provider === 'deepseek-harness' ? 'dsh' : entry.provider}-root with an explicitly authorized sessions root.`
180
+ : 'PROVIDER_ROOT_UNAVAILABLE', needsExplicitRoot
181
+ ? `Pass --${expectedFlag}-root with an explicitly authorized ${rootKind}.`
166
182
  : `No authorized ${entry.provider} workspace history root was found.`));
167
183
  if (entry.provider === 'codex')
168
184
  reports.get(entry.provider).rootCounts = [...rootCounts.values()];
@@ -173,13 +189,48 @@ export async function discoverWorkspaceHistories(options) {
173
189
  workspaceId,
174
190
  allowedRoots: availableRoots,
175
191
  };
192
+ if (entry.provider === 'hermes') {
193
+ // The consistent snapshot is staged under owned workspace staging (the
194
+ // provider home stays read-only); staged locators need scope cover, and
195
+ // refresh must retain both the origin grant and the staging grant.
196
+ const staging = hermesSnapshotStagingDir(workspacePath);
197
+ if (!scope.allowedRoots.includes(staging))
198
+ scope.allowedRoots.push(staging);
199
+ authorizedRoots[entry.provider] = [...new Set([...availableRoots, staging])];
200
+ if (!rootCounts.has(staging)) {
201
+ rootCounts.set(staging, {
202
+ root: redactSourceLocator(staging), rootId: sha256(staging),
203
+ status: 'checked', sourceCount: 0, duplicateCount: 0,
204
+ });
205
+ }
206
+ }
176
207
  const providerSources = [];
177
208
  let matchedBySubfolder = 0;
178
209
  let matchedByWorktree = 0;
179
210
  const museSourceInspections = [];
211
+ // Grok Build live detection reads exactly one explicitly authorized file
212
+ // (never the sessions root's parent implicitly); absence means unknown.
213
+ let grokActiveRegistry = null;
214
+ let grokActiveRegistryLoaded = false;
215
+ const grokActiveEvidence = async () => {
216
+ if (grokActiveRegistryLoaded || entry.provider !== 'grok-build' || !options.grokActiveSessions)
217
+ return grokActiveRegistry;
218
+ grokActiveRegistryLoaded = true;
219
+ try {
220
+ grokActiveRegistry = await readGrokBuildActiveRegistry(resolve(options.grokActiveSessions), [resolve(options.grokActiveSessions)].map((file) => dirname(file)));
221
+ }
222
+ catch {
223
+ grokActiveRegistry = null;
224
+ }
225
+ return grokActiveRegistry;
226
+ };
180
227
  for await (const descriptor of adapter.discover(scope)) {
181
228
  const known = options.knownSources?.find(source => source.provider === descriptor.provider && source.locator === descriptor.locator);
182
- const nativeSessionId = known?.nativeSessionId ?? descriptor.nativeSessionId ?? nativeSessionIdFromLocator(descriptor);
229
+ // A Hermes projection holds many sessions, so its locator basename is
230
+ // never a session identity.
231
+ const nativeSessionId = entry.provider === 'hermes'
232
+ ? (known?.nativeSessionId ?? descriptor.nativeSessionId)
233
+ : (known?.nativeSessionId ?? descriptor.nativeSessionId ?? nativeSessionIdFromLocator(descriptor));
183
234
  const exclusion = matchImportExclusion({ ...descriptor, nativeSessionId }, exclusions);
184
235
  if (exclusion) {
185
236
  const locator = resolve(descriptor.locator);
@@ -224,6 +275,13 @@ export async function discoverWorkspaceHistories(options) {
224
275
  if (!workspaceMatch)
225
276
  continue;
226
277
  }
278
+ if (entry.provider === 'grok-build') {
279
+ // The url-encoded cwd directory is the only workspace evidence; an
280
+ // unresolvable or conflicting value never attaches to the caller.
281
+ workspaceMatch = await grokBuildSourceWorkspaceMatch(locator, workspacePath);
282
+ if (!workspaceMatch)
283
+ continue;
284
+ }
227
285
  const ompHeader = entry.provider === 'omp' ? await readOmpSessionHeader({ ...descriptor, sourceId: 'discovery', authorizedScope: scope }) : undefined;
228
286
  if (ompHeader) {
229
287
  workspaceMatch = await matchSessionWorkspace(ompHeader.cwd, workspacePath);
@@ -262,6 +320,24 @@ export async function discoverWorkspaceHistories(options) {
262
320
  rootCount.sourceCount += 1;
263
321
  const source = sourceFromDescriptor(descriptor, locator, authorizedRoot, details, fingerprint.digest);
264
322
  source.nativeSessionId = rolloutId ?? ompHeader?.id ?? nativeSessionId;
323
+ if (entry.provider === 'hermes') {
324
+ // A state.db projection holds many sessions; the locator basename is
325
+ // not a session identity.
326
+ delete source.nativeSessionId;
327
+ }
328
+ if (entry.provider === 'grok-build' && source.nativeSessionId) {
329
+ // Provider-reported activity only; histories stay usable without it.
330
+ const observedAt = options.createdAt ?? new Date().toISOString();
331
+ const registry = await grokActiveEvidence();
332
+ const evidence = grokBuildLiveState(registry, source.nativeSessionId);
333
+ source.liveEvidence = {
334
+ ...evidence,
335
+ observedAt,
336
+ expiresAt: evidence.state === 'active'
337
+ ? new Date(Date.parse(observedAt) + GROK_BUILD_ACTIVE_FRESHNESS_MS).toISOString()
338
+ : null,
339
+ };
340
+ }
265
341
  if (ompHeader)
266
342
  source.sourceId = sha256(['omp-native-source-v1', workspaceId, ompHeader.id].join('\0'));
267
343
  if (entry.provider === 'grokbot') {
@@ -9,6 +9,7 @@
9
9
  import fs from 'fs';
10
10
  import path from 'path';
11
11
  import { fileURLToPath } from 'url';
12
+ import { discoverLocalSkillOwners, higherLocalSkillOwner, selectSkillOwners } from '../collision-discovery.js';
12
13
  import { getProviderDefinition, resolveProviderPathValue, } from '../../providers/provider-definitions.js';
13
14
  const _scriptDir = path.dirname(fileURLToPath(import.meta.url));
14
15
  function resolveAiwgRoot() {
@@ -115,19 +116,28 @@ function deduplicateManifests(paths) {
115
116
  });
116
117
  }
117
118
  export class LocalAdapter {
119
+ discoveryOptions;
120
+ aiwgRoot;
118
121
  id = 'local';
119
122
  name = 'Local (AIWG Installation)';
120
123
  cachedSkills = null;
124
+ constructor(discoveryOptions, aiwgRoot = AIWG_ROOT) {
125
+ this.discoveryOptions = discoveryOptions;
126
+ this.aiwgRoot = aiwgRoot;
127
+ }
128
+ withLocalOwners(skills) {
129
+ return selectSkillOwners([...skills, ...discoverLocalSkillOwners(this.discoveryOptions ?? { projectDir: process.cwd() })]);
130
+ }
121
131
  async isAvailable() {
122
- return fs.existsSync(path.join(AIWG_ROOT, 'agentic', 'code'));
132
+ return fs.existsSync(path.join(this.aiwgRoot, 'agentic', 'code'));
123
133
  }
124
134
  async list() {
125
135
  if (this.cachedSkills)
126
- return this.cachedSkills;
136
+ return this.withLocalOwners(this.cachedSkills);
127
137
  const skills = [];
128
- const agenticDir = path.join(AIWG_ROOT, 'agentic', 'code');
138
+ const agenticDir = path.join(this.aiwgRoot, 'agentic', 'code');
129
139
  if (!fs.existsSync(agenticDir))
130
- return skills;
140
+ return this.withLocalOwners(skills);
131
141
  // Find all manifest.json files in frameworks/ and addons/
132
142
  const frameworksDir = path.join(agenticDir, 'frameworks');
133
143
  const addonsDir = path.join(agenticDir, 'addons');
@@ -163,6 +173,7 @@ export class LocalAdapter {
163
173
  name: skill.name,
164
174
  description: skill.description,
165
175
  source: 'local',
176
+ origin: 'aiwg-managed',
166
177
  package: packageName,
167
178
  platforms,
168
179
  installed: true,
@@ -202,6 +213,7 @@ export class LocalAdapter {
202
213
  name: skillName,
203
214
  description,
204
215
  source: 'local',
216
+ origin: 'aiwg-managed',
205
217
  package: packageName,
206
218
  platforms,
207
219
  installed: true,
@@ -212,7 +224,7 @@ export class LocalAdapter {
212
224
  }
213
225
  }
214
226
  this.cachedSkills = skills;
215
- return skills;
227
+ return this.withLocalOwners(skills);
216
228
  }
217
229
  async search(query) {
218
230
  const all = await this.list();
@@ -226,8 +238,10 @@ export class LocalAdapter {
226
238
  const match = all.find((s) => s.name === name);
227
239
  if (!match)
228
240
  return undefined;
241
+ if ('path' in match)
242
+ return match;
229
243
  // Find the SKILL.md for full details
230
- const agenticDir = path.join(AIWG_ROOT, 'agentic', 'code');
244
+ const agenticDir = path.join(this.aiwgRoot, 'agentic', 'code');
231
245
  const skillMdPaths = this.findSkillMds(agenticDir);
232
246
  const skillMdPath = skillMdPaths.find((p) => path.basename(path.dirname(p)) === name);
233
247
  const details = { ...match };
@@ -263,6 +277,11 @@ export class LocalAdapter {
263
277
  return details;
264
278
  }
265
279
  async install(name, options) {
280
+ const collision = higherLocalSkillOwner(name, 'aiwg-managed', {
281
+ ...this.discoveryOptions, projectDir: options.projectDir,
282
+ });
283
+ if (collision)
284
+ throw new Error(`${collision.origin}-owned skill "${name}" takes precedence over aiwg-managed-owned skill at ${collision.path}`);
266
285
  const details = await this.info(name);
267
286
  if (!details || !details.path) {
268
287
  throw new Error(`Skill '${name}' not found in local registry`);
@@ -280,16 +299,20 @@ export class LocalAdapter {
280
299
  }
281
300
  // Copy skill directory to target
282
301
  const sourceDir = path.dirname(details.path);
283
- fs.mkdirSync(targetDir, { recursive: true });
302
+ if (fs.existsSync(targetDir)) {
303
+ throw new Error(`project/user-owned target "${targetDir}" blocks aiwg-managed-owned skill "${name}"`);
304
+ }
305
+ fs.mkdirSync(path.dirname(targetDir), { recursive: true });
306
+ fs.mkdirSync(targetDir);
284
307
  const entries = fs.readdirSync(sourceDir, { withFileTypes: true });
285
308
  for (const entry of entries) {
286
309
  const srcPath = path.join(sourceDir, entry.name);
287
310
  const destPath = path.join(targetDir, entry.name);
288
311
  if (entry.isFile()) {
289
- fs.copyFileSync(srcPath, destPath);
312
+ fs.copyFileSync(srcPath, destPath, fs.constants.COPYFILE_EXCL);
290
313
  }
291
314
  else if (entry.isDirectory()) {
292
- fs.cpSync(srcPath, destPath, { recursive: true });
315
+ fs.cpSync(srcPath, destPath, { recursive: true, errorOnExist: true, force: false });
293
316
  }
294
317
  }
295
318
  // Codex `agents/openai.yaml` UI sidecar (#1129 PUW-028).
@@ -0,0 +1,28 @@
1
+ // Preserve non-portable skill metadata across the portable boundary.
2
+ import { AGENT_SKILLS_SIDECAR_SCHEMA } from './agent-skills.js';
3
+ export function createAgentSkillSidecar(document, provenance, validationProfile, trust) {
4
+ return {
5
+ $schema: AGENT_SKILLS_SIDECAR_SCHEMA,
6
+ schemaVersion: 1,
7
+ aiwg: structuredClone(document.aiwg),
8
+ ...(document.providers ? { providers: structuredClone(document.providers) } : {}),
9
+ provenance: structuredClone(provenance),
10
+ validationProfile,
11
+ trust: { ...trust },
12
+ };
13
+ }
14
+ /**
15
+ * Restore AIWG metadata omitted at a strict portability boundary. Portable
16
+ * content remains authoritative for standard fields, body, and resources.
17
+ */
18
+ export function restoreAgentSkillFromSidecar(standard, body, resources, sidecar) {
19
+ return {
20
+ standard: structuredClone(standard),
21
+ body,
22
+ resources: resources.map((resource) => ({ ...resource })),
23
+ aiwg: structuredClone(sidecar.aiwg),
24
+ ...(sidecar.providers ? { providers: structuredClone(sidecar.providers) } : {}),
25
+ unknownFields: [],
26
+ };
27
+ }
28
+ //# sourceMappingURL=agent-skill-sidecar.js.map
@@ -6,6 +6,9 @@
6
6
  *
7
7
  * @implements #1875
8
8
  */
9
+ import { CLAUDE_SKILL_FIELDS } from './provider-extensions.js';
10
+ export { CLAUDE_SKILL_FIELDS } from './provider-extensions.js';
11
+ export { createAgentSkillSidecar, restoreAgentSkillFromSidecar } from './agent-skill-sidecar.js';
9
12
  export const AGENT_SKILLS_BASELINE = {
10
13
  repository: 'agentskills/agentskills',
11
14
  revision: '38a2ff82958afee88dadf4831509e6f7e9d8ef4e',
@@ -85,10 +88,12 @@ export const AIWG_SKILL_CONTROL_FIELDS = [
85
88
  /**
86
89
  * Higher values win. This preserves the upstream project-over-user rule while
87
90
  * keeping explicitly imported skills ahead of AIWG's packaged defaults.
91
+ * Account-synced skills sit below operator ownership; see docs/skills/agent-skills.md.
88
92
  */
89
93
  export const AGENT_SKILL_COLLISION_PRECEDENCE = Object.freeze({
90
94
  project: 400,
91
95
  user: 300,
96
+ synced: 250,
92
97
  imported: 200,
93
98
  'aiwg-managed': 100,
94
99
  });
@@ -174,6 +179,7 @@ export function validateCompatibleAgentSkillMetadata(frontmatter, directoryName,
174
179
  const recognizedFields = new Set([
175
180
  ...STANDARD_SKILL_FIELDS,
176
181
  ...AIWG_SKILL_CONTROL_FIELDS,
182
+ ...CLAUDE_SKILL_FIELDS,
177
183
  ]);
178
184
  for (const key of Object.keys(frontmatter).sort()) {
179
185
  if (!recognizedFields.has(key)) {
@@ -223,27 +229,4 @@ export function equivalentPortableAllowedTools(aiwg) {
223
229
  }
224
230
  return aiwg.allowedTools.join(' ');
225
231
  }
226
- export function createAgentSkillSidecar(document, provenance, validationProfile, trust) {
227
- return {
228
- $schema: AGENT_SKILLS_SIDECAR_SCHEMA,
229
- schemaVersion: 1,
230
- aiwg: structuredClone(document.aiwg),
231
- provenance: structuredClone(provenance),
232
- validationProfile,
233
- trust: { ...trust },
234
- };
235
- }
236
- /**
237
- * Restore AIWG metadata omitted at a strict portability boundary. Portable
238
- * content remains authoritative for standard fields, body, and resources.
239
- */
240
- export function restoreAgentSkillFromSidecar(standard, body, resources, sidecar) {
241
- return {
242
- standard: structuredClone(standard),
243
- body,
244
- resources: resources.map((resource) => ({ ...resource })),
245
- aiwg: structuredClone(sidecar.aiwg),
246
- unknownFields: [],
247
- };
248
- }
249
232
  //# sourceMappingURL=agent-skills.js.map
@@ -0,0 +1,25 @@
1
+ /** Inspection only: account-enabled skills are a separate delivery mechanism. */
2
+ export function projectClaudeSkillSurfaces(body) {
3
+ const shell = /!`[^`]+`/.test(body);
4
+ return ['cli', 'desktop-code', 'cowork', 'cloud'].map((surface) => {
5
+ const local = surface === 'cli' || surface === 'desktop-code';
6
+ const shellStatus = local ? 'native' : surface === 'cowork' ? 'degraded' : 'unsupported';
7
+ return {
8
+ provider: 'claude',
9
+ surface,
10
+ status: local ? 'native' : 'unsupported',
11
+ ...(shell ? { shellInterpolation: shellStatus } : {}),
12
+ reasons: [
13
+ local
14
+ ? 'Reads filesystem SKILL.md bundles from .claude/skills.'
15
+ : 'Does not read local .claude/skills; requires skills enabled on the claude.ai account.',
16
+ ...(shell ? [local
17
+ ? '! shell interpolation is native; AIWG does not execute it during validation or deploy.'
18
+ : surface === 'cowork'
19
+ ? '! shell interpolation is degraded to a policy notice for account-enabled Cowork skills.'
20
+ : '! shell interpolation from a local skill is unsupported on cloud.'] : []),
21
+ ],
22
+ };
23
+ });
24
+ }
25
+ //# sourceMappingURL=claude-surface-projection.js.map
@@ -0,0 +1,33 @@
1
+ export function displaySkillCollisions(skill) {
2
+ for (const diagnostic of skill.diagnostics ?? []) {
3
+ console.log(` ${diagnostic.code}: ${diagnostic.message} (${diagnostic.file})`);
4
+ }
5
+ }
6
+ /**
7
+ * Format skill results as a table
8
+ */
9
+ export function displaySkillsTable(skills) {
10
+ if (skills.length === 0) {
11
+ console.log(' No skills found.');
12
+ return;
13
+ }
14
+ // Group by source
15
+ const bySource = new Map();
16
+ for (const skill of skills) {
17
+ const list = bySource.get(skill.source) || [];
18
+ list.push(skill);
19
+ bySource.set(skill.source, list);
20
+ }
21
+ for (const [source, sourceSkills] of bySource) {
22
+ console.log(`\n ${source} (${sourceSkills.length} skills):`);
23
+ console.log(' ' + '-'.repeat(70));
24
+ for (const skill of sourceSkills) {
25
+ const name = skill.name.padEnd(28);
26
+ const pkg = (skill.package || '').padEnd(18);
27
+ const desc = skill.description.slice(0, 40);
28
+ console.log(` ${name} ${pkg} ${desc}`);
29
+ displaySkillCollisions(skill);
30
+ }
31
+ }
32
+ }
33
+ //# sourceMappingURL=cli-display.js.map
@@ -11,6 +11,7 @@
11
11
  * @implements #539
12
12
  */
13
13
  import { spawn } from 'child_process';
14
+ import { displaySkillsTable, displaySkillCollisions } from './cli-display.js';
14
15
  import { searchSkills, listSkills, getSkillInfo, installSkill, publishSkill, importSkillSource, getAllAdapters, } from './registry.js';
15
16
  import { AgentSkillImportError } from './importer.js';
16
17
  import { AgentSkillDeploymentError, deployImportedAgentSkill, uninstallImportedAgentSkill, } from './deployer.js';
@@ -50,32 +51,6 @@ function parseFlags(args) {
50
51
  }
51
52
  return { provider, target, rest };
52
53
  }
53
- /**
54
- * Format skill results as a table
55
- */
56
- function displaySkillsTable(skills) {
57
- if (skills.length === 0) {
58
- console.log(' No skills found.');
59
- return;
60
- }
61
- // Group by source
62
- const bySource = new Map();
63
- for (const skill of skills) {
64
- const list = bySource.get(skill.source) || [];
65
- list.push(skill);
66
- bySource.set(skill.source, list);
67
- }
68
- for (const [source, sourceSkills] of bySource) {
69
- console.log(`\n ${source} (${sourceSkills.length} skills):`);
70
- console.log(' ' + '-'.repeat(70));
71
- for (const skill of sourceSkills) {
72
- const name = skill.name.padEnd(28);
73
- const pkg = (skill.package || '').padEnd(18);
74
- const desc = skill.description.slice(0, 40);
75
- console.log(` ${name} ${pkg} ${desc}`);
76
- }
77
- }
78
- }
79
54
  /**
80
55
  * Handle 'skills search' command
81
56
  */
@@ -121,6 +96,7 @@ async function handleInfo(args) {
121
96
  if (details.version)
122
97
  console.log(`Version: ${details.version}`);
123
98
  console.log(`Description: ${details.description}`);
99
+ displaySkillCollisions(details);
124
100
  if (details.platforms && details.platforms.length > 0) {
125
101
  console.log(`Platforms: ${details.platforms.join(', ')}`);
126
102
  }
@@ -0,0 +1,84 @@
1
+ // Discover local skill owners and resolve name collisions without executing skills.
2
+ import fs from 'node:fs';
3
+ import os from 'node:os';
4
+ import path from 'node:path';
5
+ import { parse } from 'yaml';
6
+ import { listProviderDefinitions } from '../providers/provider-definitions.js';
7
+ import { AGENT_SKILLS_BASELINE, AGENT_SKILL_COLLISION_PRECEDENCE, } from './agent-skills.js';
8
+ import { isManagedTarget } from './deployment-ownership.js';
9
+ export function localSkillRoots(options) {
10
+ const project = path.resolve(options.projectDir);
11
+ const home = path.resolve(options.homeDir ?? os.homedir());
12
+ const roots = new Map();
13
+ for (const { skillNamespace: ns } of listProviderDefinitions()) {
14
+ const base = ns.pathType === 'home-dir' ? home : project;
15
+ roots.set(path.resolve(base, ns.skillsBaseDir), ns.pathType === 'home-dir' ? 'user' : 'project');
16
+ }
17
+ roots.set(path.join(project, '.agents', 'skills'), 'project');
18
+ roots.set(path.join(project, '.claude', '.aiwg', 'skills'), 'project');
19
+ roots.set(path.join(home, '.claude', 'skills'), 'user');
20
+ roots.set(path.join(home, '.claude', 'skills', 'synced'), 'synced');
21
+ return roots;
22
+ }
23
+ export function discoverLocalSkillOwners(options) {
24
+ const skills = [];
25
+ for (const [root, origin] of localSkillRoots(options)) {
26
+ if (!fs.existsSync(root))
27
+ continue;
28
+ for (const entry of fs.readdirSync(root, { withFileTypes: true })) {
29
+ if (!entry.isDirectory())
30
+ continue;
31
+ const directory = path.join(root, entry.name);
32
+ const file = path.join(directory, 'SKILL.md');
33
+ if (!fs.existsSync(file))
34
+ continue;
35
+ try {
36
+ const content = fs.readFileSync(file, 'utf8');
37
+ const match = /^---\r?\n([\s\S]*?)\r?\n---/.exec(content);
38
+ const metadata = match ? parse(match[1]) : {};
39
+ const name = typeof metadata?.name === 'string' ? metadata.name : entry.name;
40
+ // Synced ownership is determined by its account cache root, never a marker.
41
+ const owner = origin !== 'synced' && isManagedTarget(directory, name)
42
+ ? 'aiwg-managed' : origin;
43
+ skills.push({
44
+ name, description: typeof metadata?.description === 'string' ? metadata.description : `Skill: ${name}`,
45
+ source: 'local', installed: true, origin: owner, path: file, content,
46
+ });
47
+ }
48
+ catch { /* Unreadable or malformed skills cannot be selected. */ }
49
+ }
50
+ }
51
+ return skills;
52
+ }
53
+ function rank(skill) {
54
+ return skill.origin ? AGENT_SKILL_COLLISION_PRECEDENCE[skill.origin] : 0;
55
+ }
56
+ export function skillCollisionDiagnostic(name, winner, loser, file) {
57
+ return {
58
+ code: 'AS_SKILL_COLLISION', severity: 'warning', file, yamlPath: '$.name',
59
+ message: `${winner}-owned skill "${name}" takes precedence over ${loser}-owned skill`,
60
+ upstreamBaseline: AGENT_SKILLS_BASELINE.revision,
61
+ remediation: 'Rename the skill or explicitly remove the higher-precedence collision.',
62
+ };
63
+ }
64
+ export function selectSkillOwners(skills) {
65
+ const selected = new Map();
66
+ // Path breaks equal-origin ties independently of filesystem enumeration order.
67
+ const sorted = [...skills].sort((a, b) => rank(b) - rank(a)
68
+ || (a.path ?? '').localeCompare(b.path ?? '') || a.name.localeCompare(b.name));
69
+ for (const skill of sorted) {
70
+ const winner = selected.get(skill.name);
71
+ if (!winner) {
72
+ selected.set(skill.name, { ...skill, diagnostics: [...(skill.diagnostics ?? [])] });
73
+ }
74
+ else if (winner.origin && skill.origin) {
75
+ winner.diagnostics.push(skillCollisionDiagnostic(skill.name, winner.origin, skill.origin, skill.path ?? ''));
76
+ winner.diagnostics.push(...(skill.diagnostics ?? []));
77
+ }
78
+ }
79
+ return [...selected.values()].sort((a, b) => a.name.localeCompare(b.name));
80
+ }
81
+ export function higherLocalSkillOwner(name, incoming, options) {
82
+ return selectSkillOwners(discoverLocalSkillOwners(options)).find(skill => skill.name === name && rank(skill) > AGENT_SKILL_COLLISION_PRECEDENCE[incoming]);
83
+ }
84
+ //# sourceMappingURL=collision-discovery.js.map