@agentxm/extension-authoring 0.28.11 → 0.28.13

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 (75) hide show
  1. package/dist/src/adopt/adopt-extension.d.ts +71 -0
  2. package/dist/src/adopt/adopt-extension.js +174 -0
  3. package/dist/src/authored-declaration.d.ts +49 -0
  4. package/dist/src/authored-declaration.js +86 -0
  5. package/dist/src/authored-package-errors.d.ts +91 -0
  6. package/dist/src/authored-package-errors.js +36 -0
  7. package/dist/src/create/authoring-owner.d.ts +54 -0
  8. package/dist/src/create/authoring-owner.js +93 -0
  9. package/dist/src/create/create-extension.d.ts +127 -0
  10. package/dist/src/create/create-extension.js +440 -0
  11. package/dist/src/create/errors.d.ts +59 -0
  12. package/dist/src/create/errors.js +54 -0
  13. package/dist/src/create/scaffold-name.d.ts +15 -0
  14. package/dist/src/create/scaffold-name.js +16 -0
  15. package/dist/src/create/scaffolds/hook.d.ts +19 -0
  16. package/dist/src/create/scaffolds/hook.js +118 -0
  17. package/dist/src/create/scaffolds/knowledge.d.ts +14 -0
  18. package/dist/src/create/scaffolds/knowledge.js +45 -0
  19. package/dist/src/create/scaffolds/mcp-server.d.ts +17 -0
  20. package/dist/src/create/scaffolds/mcp-server.js +57 -0
  21. package/dist/src/create/scaffolds/pack.d.ts +13 -0
  22. package/dist/src/create/scaffolds/pack.js +37 -0
  23. package/dist/src/create/scaffolds/rule.d.ts +14 -0
  24. package/dist/src/create/scaffolds/rule.js +46 -0
  25. package/dist/src/create/scaffolds/scaffold.d.ts +51 -0
  26. package/dist/src/create/scaffolds/scaffold.js +45 -0
  27. package/dist/src/create/scaffolds/skill.d.ts +12 -0
  28. package/dist/src/create/scaffolds/skill.js +47 -0
  29. package/dist/src/create/scaffolds/subagent.d.ts +12 -0
  30. package/dist/src/create/scaffolds/subagent.js +47 -0
  31. package/dist/src/create-preflight.d.ts +3 -2
  32. package/dist/src/create-preflight.js +2 -1
  33. package/dist/src/errors.d.ts +1 -1
  34. package/dist/src/errors.js +1 -1
  35. package/dist/src/fork/fork-extension.d.ts +87 -0
  36. package/dist/src/fork/fork-extension.js +253 -0
  37. package/dist/src/fork-package.d.ts +2 -2
  38. package/dist/src/fork-package.js +4 -4
  39. package/dist/src/import/import-native-extension.d.ts +119 -0
  40. package/dist/src/import/import-native-extension.js +310 -0
  41. package/dist/src/import-native-package.d.ts +2 -2
  42. package/dist/src/import-native-package.js +4 -4
  43. package/dist/src/index.d.ts +20 -11
  44. package/dist/src/index.js +26 -13
  45. package/dist/src/packs/add-to-pack.d.ts +2 -2
  46. package/dist/src/packs/add-to-pack.js +4 -3
  47. package/dist/src/packs/change-pack-membership.d.ts +56 -0
  48. package/dist/src/packs/change-pack-membership.js +246 -0
  49. package/dist/src/packs/configured-pack-selector.d.ts +24 -0
  50. package/dist/src/packs/configured-pack-selector.js +53 -0
  51. package/dist/src/packs/glob.d.ts +14 -0
  52. package/dist/src/packs/glob.js +44 -0
  53. package/dist/src/packs/membership-errors.d.ts +122 -0
  54. package/dist/src/packs/membership-errors.js +47 -0
  55. package/dist/src/packs/remove-from-pack.d.ts +2 -2
  56. package/dist/src/packs/remove-from-pack.js +4 -3
  57. package/dist/src/step-failure.d.ts +31 -0
  58. package/dist/src/step-failure.js +253 -0
  59. package/dist/src/testing.d.ts +68 -0
  60. package/dist/src/testing.js +135 -0
  61. package/dist/src/version/change-authored-version.d.ts +73 -0
  62. package/dist/src/version/change-authored-version.js +224 -0
  63. package/dist/src/version/errors.d.ts +65 -0
  64. package/dist/src/version/errors.js +73 -0
  65. package/package.json +23 -8
  66. package/dist/src/desired-identity.d.ts +0 -19
  67. package/dist/src/desired-identity.js +0 -26
  68. package/dist/src/failure-adapter.d.ts +0 -31
  69. package/dist/src/failure-adapter.js +0 -23
  70. package/dist/src/hooks/new-hook.d.ts +0 -46
  71. package/dist/src/hooks/new-hook.js +0 -164
  72. package/dist/src/packs/new-pack.d.ts +0 -37
  73. package/dist/src/packs/new-pack.js +0 -90
  74. package/dist/src/skills/new-skill.d.ts +0 -38
  75. package/dist/src/skills/new-skill.js +0 -102
@@ -0,0 +1,310 @@
1
+ /**
2
+ * Importing native, unmanaged content as an authored AXM package.
3
+ *
4
+ * Three routes share one decision: a native skill directory or file, a native
5
+ * subagent document, and a native MCP connection declared in an agent's own
6
+ * config all become a workspace-authored package that carries the identity the
7
+ * person asked for, not the identity the native content happened to have. The
8
+ * native source is never modified — except for an MCP connection, whose native
9
+ * declaration is retired only after the managed package validates, because
10
+ * leaving both would give one connection two owners.
11
+ *
12
+ * `prepare` settles the identity, the destination, and the activation, and
13
+ * stages the converted package into a scoped temporary directory; nothing
14
+ * under the workspace is written. `previewOrApply` resolves that candidate.
15
+ *
16
+ * @experimental This API is unstable and may change without notice.
17
+ */
18
+ import * as Effect from "effect/Effect";
19
+ import * as FileSystem from "effect/FileSystem";
20
+ import * as Option from "effect/Option";
21
+ import * as Path from "effect/Path";
22
+ import { ExtensionManagers, McpSecretStore, buildAuthoredExtensionStep, copyExtensionDirectory, createCanonicalDirectory, materializeAuthoredMcpServer, recoverCanonicalDirectory, retireNativeMcpEntry, } from "@agentxm/extension-materialization";
23
+ import { extensionTypeToPlural, formatFqn, parseFqn, } from "@agentxm/extension-model/unstable/extensions";
24
+ import { MCP_SERVER_MANIFEST_FILENAME, MCP_SERVER_MANIFEST_SCHEMA_URL, MCP_SERVER_REGISTRY_SERVER_SCHEMA_URL, } from "@agentxm/extension-model/unstable/mcps/manifest-schema";
25
+ import { decodeVersionSync } from "@agentxm/extension-model/unstable/version-constraints";
26
+ import { SourceHostProviders, WorkspaceCatalog, acquireExternalSource, resolveSource, } from "@agentxm/extension-sources";
27
+ import { operationPresentation, prepareExecutionCandidate, resolveExecutionCandidate, } from "@agentxm/workspace-operations";
28
+ import { WorkspaceMutations, computePackageContentHash, } from "@agentxm/workspace-state";
29
+ import { authoredDeclaration } from "../authored-declaration.js";
30
+ import { preflightCreateOnly } from "../create-preflight.js";
31
+ import { AuthoringFailed } from "../errors.js";
32
+ import { requireAuthoredOwner, settingsRelativePath } from "../create/authoring-owner.js";
33
+ import { AuthoringScopeUnsupported, } from "../create/errors.js";
34
+ import { importNativeExtensionPackage } from "../import-native-package.js";
35
+ import { authoringStepFailure } from "../step-failure.js";
36
+ /** The version an imported package starts at. */
37
+ const INITIAL_IMPORT_VERSION = decodeVersionSync("0.1.0");
38
+ /** Build the import step with the requirements this use case keeps in `R`. */
39
+ const importStep = (manager, args) => buildAuthoredExtensionStep(manager, args);
40
+ /** The plan a native import resolves. */
41
+ export const importNativeExtensionPlanName = (type) => type === "mcp-server" ? "Import MCP server package" : "Import native extension";
42
+ /**
43
+ * The one connection a package conversion may represent.
44
+ *
45
+ * Converting requires an unambiguous subject: a config the agents disagree
46
+ * about, a discovery that found no connection or several, and a local command
47
+ * that no manifest can express are three different refusals, each recoverable
48
+ * in a different way.
49
+ */
50
+ const selectNativeMcpCandidate = (discovery) => {
51
+ if (discovery.conflicts.length > 0) {
52
+ return Effect.fail(new AuthoringFailed({
53
+ category: "conflict",
54
+ detail: `MCP package import has ${discovery.conflicts.length} conflicted native candidate(s)`,
55
+ }));
56
+ }
57
+ const candidate = discovery.candidates[0];
58
+ if (candidate === undefined || discovery.candidates.length !== 1) {
59
+ return Effect.fail(new AuthoringFailed({
60
+ category: "validation",
61
+ detail: discovery.candidates.length === 0
62
+ ? "No losslessly importable unmanaged MCP server was found"
63
+ : "MCP package import requires exactly one unmanaged server candidate",
64
+ }));
65
+ }
66
+ if (Option.isNone(candidate.remote)) {
67
+ return Effect.fail(new AuthoringFailed({
68
+ category: "usage",
69
+ detail: "This MCP command cannot be represented losslessly as a managed package; import it inline without --as",
70
+ }));
71
+ }
72
+ return Effect.succeed({
73
+ candidate,
74
+ url: candidate.remote.value.url,
75
+ headers: candidate.remote.value.headers,
76
+ });
77
+ };
78
+ /** The manifest a converted native connection is published as. */
79
+ const convertedMcpManifest = (args) => ({
80
+ $schema: MCP_SERVER_MANIFEST_SCHEMA_URL,
81
+ owner: args.owner,
82
+ type: "mcp-server",
83
+ name: args.name,
84
+ version: INITIAL_IMPORT_VERSION,
85
+ description: `Imported MCP server ${args.nativeName}`,
86
+ server: {
87
+ $schema: MCP_SERVER_REGISTRY_SERVER_SCHEMA_URL,
88
+ name: `local.axm/${args.name}`,
89
+ description: `Imported MCP server ${args.nativeName}`,
90
+ version: INITIAL_IMPORT_VERSION,
91
+ remotes: [
92
+ {
93
+ type: "streamable-http",
94
+ url: args.url,
95
+ ...(Object.keys(args.headers).length === 0
96
+ ? {}
97
+ : {
98
+ headers: Object.entries(args.headers).map(([name, value]) => ({ name, value })),
99
+ }),
100
+ },
101
+ ],
102
+ },
103
+ });
104
+ /**
105
+ * Convert a native skill or subagent by staging the rewritten package now and
106
+ * pinning its content hash, so content that changes between preview and apply
107
+ * refuses instead of landing.
108
+ */
109
+ const nativeConversion = Effect.fn("ImportNativeExtension.nativeConversion")(function* (args) {
110
+ const fs = yield* FileSystem.FileSystem;
111
+ const path = yield* Path.Path;
112
+ const source = yield* resolveSource(args.request.source);
113
+ const acquired = yield* acquireExternalSource(source);
114
+ const stagingRoot = yield* fs.makeTempDirectoryScoped({ prefix: "axm-import-" }).pipe(Effect.mapError((cause) => new AuthoringFailed({
115
+ category: "internal",
116
+ detail: "Import staging directory could not be created",
117
+ cause,
118
+ })));
119
+ const stagedPackage = path.join(stagingRoot, "package");
120
+ yield* importNativeExtensionPackage({
121
+ sourcePath: acquired.directory,
122
+ targetDir: stagedPackage,
123
+ target: args.target,
124
+ });
125
+ const stagedHash = yield* computePackageContentHash(stagedPackage);
126
+ return {
127
+ origin: acquired.origin,
128
+ env: {},
129
+ nativeTargets: [],
130
+ requiredFiles: undefined,
131
+ populate: (publicationPath) => copyExtensionDirectory(stagedPackage, publicationPath).pipe(Effect.mapError((cause) => new AuthoringFailed({
132
+ category: "internal",
133
+ detail: "Prepared import could not be staged",
134
+ cause,
135
+ }))),
136
+ validate: (publicationPath) => computePackageContentHash(publicationPath).pipe(Effect.flatMap((currentHash) => currentHash === stagedHash
137
+ ? Effect.void
138
+ : new AuthoringFailed({
139
+ category: "conflict",
140
+ detail: "Prepared import content changed before it could be applied",
141
+ }))),
142
+ retireNative: Effect.void,
143
+ };
144
+ });
145
+ /**
146
+ * Convert one discovered native MCP connection into a manifest, and retire
147
+ * every native declaration of it once the managed package validates.
148
+ */
149
+ const mcpConversion = Effect.fn("ImportNativeExtension.mcpConversion")(function* (args) {
150
+ const { candidate, url, headers } = yield* selectNativeMcpCandidate(args.request.discovery);
151
+ const manifest = convertedMcpManifest({
152
+ owner: args.owner,
153
+ name: args.name,
154
+ nativeName: candidate.name,
155
+ url,
156
+ headers,
157
+ });
158
+ const entries = [...candidate.entries].sort((left, right) => left.filePath === right.filePath
159
+ ? left.name.localeCompare(right.name)
160
+ : left.filePath.localeCompare(right.filePath));
161
+ return {
162
+ origin: candidate.name,
163
+ env: candidate.env,
164
+ nativeTargets: Array.from(new Set(entries.map((entry) => entry.filePath))).sort(),
165
+ requiredFiles: [MCP_SERVER_MANIFEST_FILENAME],
166
+ populate: (stagingPath) => Effect.gen(function* () {
167
+ const fs = yield* FileSystem.FileSystem;
168
+ const path = yield* Path.Path;
169
+ yield* fs
170
+ .writeFileString(path.join(stagingPath, MCP_SERVER_MANIFEST_FILENAME), `${JSON.stringify(manifest, null, 2)}\n`)
171
+ .pipe(Effect.mapError((cause) => new AuthoringFailed({
172
+ category: "internal",
173
+ detail: "MCP package manifest could not be staged",
174
+ cause,
175
+ })));
176
+ }),
177
+ validate: undefined,
178
+ retireNative: Effect.forEach(entries, retireNativeMcpEntry, { discard: true }),
179
+ };
180
+ });
181
+ // -----------------------------------------------------------------------------
182
+ // prepare
183
+ // -----------------------------------------------------------------------------
184
+ /** Settle a native import and stage its converted content, writing nothing. */
185
+ export const prepareImportNativeExtension = Effect.fn("ImportNativeExtension.prepare")(function* (request) {
186
+ const ws = yield* WorkspaceMutations;
187
+ const path = yield* Path.Path;
188
+ const managers = yield* ExtensionManagers;
189
+ const target = yield* Effect.fromResult(parseFqn(request.target));
190
+ if (target.type !== request.type) {
191
+ return yield* new AuthoringFailed({
192
+ category: "validation",
193
+ detail: `Expected a ${extensionTypeToPlural[request.type]} target FQN, got ${request.target}`,
194
+ });
195
+ }
196
+ yield* requireAuthoredOwner(target.owner, { subject: "package", command: "import" });
197
+ if (ws.layout.scope !== "project") {
198
+ return yield* new AuthoringScopeUnsupported({ subject: "import", scope: ws.layout.scope });
199
+ }
200
+ const name = target.name;
201
+ const fqn = formatFqn(target);
202
+ const targetDir = path.join(ws.layout.authoredRoot(target.type), name);
203
+ const authoredPath = path.relative(ws.baseDir, targetDir);
204
+ const settingsPath = settingsRelativePath(path, ws);
205
+ const subject = request.type === "mcp-server" ? "MCP package" : "Import target";
206
+ const createOnly = preflightCreateOnly({
207
+ subject,
208
+ name,
209
+ configured: false,
210
+ destinations: [targetDir],
211
+ });
212
+ yield* createOnly;
213
+ const declaration = authoredDeclaration(ws, target.type, name);
214
+ const current = yield* declaration.read;
215
+ const settled = request.type === "mcp-server"
216
+ ? yield* mcpConversion({ request, owner: target.owner, name })
217
+ : yield* nativeConversion({ request, target });
218
+ const enabled = request.type === "mcp-server"
219
+ ? request.enable
220
+ : request.enable || Option.getOrElse(current.enabled, () => false);
221
+ const env = request.type === "mcp-server" ? settled.env : current.env;
222
+ const artifact = {
223
+ path: authoredPath,
224
+ scope: ws.scope,
225
+ version: INITIAL_IMPORT_VERSION,
226
+ change: "created",
227
+ targets: [
228
+ { path: authoredPath, change: "created" },
229
+ { path: settingsPath, change: "created" },
230
+ ...settled.nativeTargets.map((filePath) => ({
231
+ path: path.relative(ws.baseDir, filePath),
232
+ change: "updated",
233
+ })),
234
+ ],
235
+ };
236
+ const common = {
237
+ toStepFailure: authoringStepFailure,
238
+ location: targetDir,
239
+ ...(settled.nativeTargets.length === 0 ? {} : { transactionTargets: settled.nativeTargets }),
240
+ versionRange: Option.none(),
241
+ label: `Import ${settled.origin} -> ${fqn}`,
242
+ message: `Imported ${fqn}`,
243
+ enabled,
244
+ allowConfiguredSourceTransition: true,
245
+ markAuthored: declaration.declare({ enabled: true, env }),
246
+ finalizeAuthored: declaration
247
+ .declare({ enabled, env })
248
+ .pipe(Effect.andThen(settled.retireNative), Effect.asVoid),
249
+ plannedArtifact: artifact,
250
+ buildArtifact: () => Effect.succeed(artifact),
251
+ preflight: Effect.gen(function* () {
252
+ yield* recoverCanonicalDirectory({ baseDir: ws.baseDir, canonicalPath: targetDir });
253
+ yield* createOnly;
254
+ }),
255
+ scaffold: createCanonicalDirectory({
256
+ baseDir: ws.baseDir,
257
+ canonicalPath: targetDir,
258
+ subject,
259
+ ...(settled.requiredFiles === undefined ? {} : { requiredFiles: settled.requiredFiles }),
260
+ populate: settled.populate,
261
+ ...(settled.validate === undefined ? {} : { validate: settled.validate }),
262
+ }).pipe(Effect.asVoid),
263
+ };
264
+ const step = (() => {
265
+ switch (request.type) {
266
+ case "skill":
267
+ return importStep(managers.skill, { ...common, target: { type: "skill", name } });
268
+ case "subagent":
269
+ return importStep(managers.subagent, { ...common, target: { type: "subagent", name } });
270
+ case "mcp-server":
271
+ return importStep(managers["mcp-server"], {
272
+ ...common,
273
+ target: { type: "mcp-server", name },
274
+ materializeWhenDisabled: true,
275
+ materializeInstall: (ref) => materializeAuthoredMcpServer({ ref, nonInteractive: request.nonInteractive }),
276
+ });
277
+ }
278
+ })();
279
+ const plan = {
280
+ _tag: "Plan",
281
+ name: importNativeExtensionPlanName(request.type),
282
+ description: Option.some(request.type === "mcp-server"
283
+ ? `Losslessly convert ${settled.origin} into ${fqn}; native MCP config is replaced only after managed validation`
284
+ : `Losslessly convert ${settled.origin} into ${fqn}; the native source remains unchanged and the import starts ${enabled ? "enabled" : "disabled"}`),
285
+ presentation: operationPresentation({ imperative: "import", past: "Imported", gerund: "Importing" }, target.type),
286
+ jobs: [{ concurrency: 1, steps: [step] }],
287
+ };
288
+ return {
289
+ type: request.type,
290
+ fqn,
291
+ owner: target.owner,
292
+ name,
293
+ origin: settled.origin,
294
+ authoredPath,
295
+ settingsPath,
296
+ enabled,
297
+ execution: yield* prepareExecutionCandidate(plan),
298
+ };
299
+ });
300
+ // -----------------------------------------------------------------------------
301
+ // previewOrApply
302
+ // -----------------------------------------------------------------------------
303
+ /** Preview or apply a settled native import, resolving to one operation outcome. */
304
+ export const previewOrApplyImportNativeExtension = (candidate, execution) => resolveExecutionCandidate(candidate.execution, execution);
305
+ /** The native-import use case: settle a request, then preview or apply it. */
306
+ export const ImportNativeExtension = {
307
+ prepare: prepareImportNativeExtension,
308
+ previewOrApply: previewOrApplyImportNativeExtension,
309
+ };
310
+ //# sourceMappingURL=import-native-extension.js.map
@@ -2,8 +2,8 @@ import * as Effect from "effect/Effect";
2
2
  import * as FileSystem from "effect/FileSystem";
3
3
  import * as Path from "effect/Path";
4
4
  import type { ExtensionFqnParts } from "@agentxm/extension-model/unstable/extensions/common";
5
- import { type FrontmatterParseFailure } from "@agentxm/registry-protocol/unstable/content/frontmatter";
6
- import { NativeImportConflict, NativeImportFailed, NativeImportInvalid, NativeImportUnsupported } from "@agentxm/extension-workspace";
5
+ import { type FrontmatterParseFailure } from "@agentxm/extension-content";
6
+ import { NativeImportConflict, NativeImportFailed, NativeImportInvalid, NativeImportUnsupported } from "./authored-package-errors.js";
7
7
  export interface ImportNativeExtensionPackageArgs {
8
8
  readonly sourcePath: string;
9
9
  readonly targetDir: string;
@@ -3,10 +3,10 @@ import * as FileSystem from "effect/FileSystem";
3
3
  import * as Path from "effect/Path";
4
4
  import * as Schema from "effect/Schema";
5
5
  import YAML from "yaml";
6
- import { manifestFilenameForType, manifestSchemaForType, } from "@agentxm/registry-protocol/unstable/publish/manifest-policy";
7
- import { parseFrontmatterEffect, } from "@agentxm/registry-protocol/unstable/content/frontmatter";
8
- import { copyExtensionDirectory } from "@agentxm/extension-workspace";
9
- import { NativeImportConflict, NativeImportFailed, NativeImportInvalid, NativeImportUnsupported, } from "@agentxm/extension-workspace";
6
+ import { manifestFilenameForType, manifestSchemaForType } from "@agentxm/extension-content";
7
+ import { parseFrontmatterEffect } from "@agentxm/extension-content";
8
+ import { copyExtensionDirectory } from "@agentxm/extension-materialization";
9
+ import { NativeImportConflict, NativeImportFailed, NativeImportInvalid, NativeImportUnsupported, } from "./authored-package-errors.js";
10
10
  const NATIVE_IMPORT_VERSION = "0.1.0";
11
11
  const MANIFEST_FILENAMES = new Set([
12
12
  "skill.json",
@@ -1,22 +1,31 @@
1
1
  /**
2
- * Extension-authoring feature: new-extension scaffolding, fork, native
3
- * import, authored identity decoding, and authored pack membership. The
4
- * application supplies the failure adapter that serializes authoring
5
- * failures into the plan-step vocabulary.
2
+ * Extension-authoring feature: creating new authored packages, forking and
3
+ * importing existing ones, authored identity decoding, and authored pack
4
+ * membership. Every use case settles its decisions in a `prepare` phase that
5
+ * writes nothing and resolves them in `previewOrApply`; failures are typed
6
+ * and carry the facts a person needs to recover.
6
7
  *
7
8
  * @experimental All exports from this module are unstable and may change without notice.
8
9
  * @packageDocumentation
9
10
  */
10
11
  export { AuthoringFailed } from "./errors.js";
11
- export { AuthoringFailureAdapter, withAdaptedStepFailures, type AuthoringFailureAdapterService, } from "./failure-adapter.js";
12
- export { decodeDesiredExtensionIdentity, type DecodedDesiredExtensionIdentity, type DesiredPackageAuthority, } from "./desired-identity.js";
12
+ export { CreateDestinationInspectionFailed, CreateNameConfigured, ForkPackageConflict, ForkPackageFailed, ForkPackageInvalid, NativeImportConflict, NativeImportFailed, NativeImportInvalid, NativeImportUnsupported, type AuthoredPackageError, } from "./authored-package-errors.js";
13
+ export { authoringStepFailure, type AuthoringStepFailure } from "./step-failure.js";
13
14
  export { forkExtensionPackage, type ForkExtensionPackageArgs } from "./fork-package.js";
14
15
  export { importNativeExtensionPackage, type ImportNativeExtensionPackageArgs, type NativeImportError, } from "./import-native-package.js";
15
16
  export { preflightCreateOnly, type CreateOnlyPreflightArgs } from "./create-preflight.js";
17
+ export { authoredDeclaration, type AuthoredDeclaration, type AuthoredDeclarationState, } from "./authored-declaration.js";
16
18
  export { markerFqnForRef, type MarkerFqnRef } from "./marker-fqn.js";
17
- export { newSkill, type NewSkillOperation, type NewSkillOperationArgs, } from "./skills/new-skill.js";
18
- export { newHook, type NewHookOperation, type NewHookOperationArgs } from "./hooks/new-hook.js";
19
- export { newPack, type NewPackOperation, type NewPackOperationArgs } from "./packs/new-pack.js";
20
- export { addToPack, type AddToPackOperation, type AddToPackOperationArgs, } from "./packs/add-to-pack.js";
21
- export { removeFromPack, type RemoveFromPackOperation, type RemoveFromPackOperationArgs, } from "./packs/remove-from-pack.js";
19
+ export { CreateExtension, createExtensionPlanName, prepareCreateExtension, previewOrApplyCreateExtension, type CreatableExtensionType, type CreateExtensionCandidate, type CreateExtensionFailure, type CreateExtensionRequest, type CreateExtensionRequirements, type CreateHookRequest, type CreateKnowledgeRequest, type CreateMcpServerRequest, type CreatePackRequest, type CreateRuleRequest, type CreateSkillRequest, type CreateSubagentRequest, type PrepareCreateExtensionRequirements, } from "./create/create-extension.js";
20
+ export { AuthoringOwnerMismatch, AuthoringOwnerRequired, AuthoringScopeUnsupported, ScaffoldNameInvalid, } from "./create/errors.js";
21
+ export { requireAuthoredOwner, resolveAuthoringOwner, settingsRelativePath, type AuthoringOwner, type AuthoringTarget, } from "./create/authoring-owner.js";
22
+ export { SCAFFOLD_NAME_MAX_LENGTH, SCAFFOLD_NAME_PATTERN, isValidScaffoldName, normalizeScaffoldOwner, } from "./create/scaffold-name.js";
23
+ export { hookEntrypointFilename } from "./create/scaffolds/hook.js";
24
+ export { ChangePackMembership, packMembershipPlanName, preparePackMembership, previewOrApplyPackMembership, type PackMembershipCandidate, type PackMembershipChange, type PackMembershipRequest, type PackMembershipRequirements, type PackMembershipUnchanged, } from "./packs/change-pack-membership.js";
25
+ export { PackGraphInvalid, PackManifestUnavailable, PackMemberAmbiguous, PackMemberNotDeclared, PackMemberNotFound, PackMemberUnmanaged, PackNotAuthored, PackNotConfigured, PackOwnerUnconfigured, PackSelectorAmbiguous, PackSelectorNotAPack, PackSourceMissing, type PackMembershipError, } from "./packs/membership-errors.js";
26
+ export { ForkExtension, forkExtensionPlanName, prepareForkExtension, previewOrApplyForkExtension, type ForkExtensionCandidate, type ForkExtensionFailure, type ForkExtensionRequest, type ForkExtensionRequirements, type PrepareForkExtensionRequirements, } from "./fork/fork-extension.js";
27
+ export { AdoptExtension, adoptExtensionPlanName, prepareAdoptExtension, previewOrApplyAdoptExtension, type AdoptExtensionCandidate, type AdoptExtensionFailure, type AdoptExtensionRequest, type AdoptExtensionRequirements, type PrepareAdoptExtensionRequirements, } from "./adopt/adopt-extension.js";
28
+ export { ImportNativeExtension, importNativeExtensionPlanName, prepareImportNativeExtension, previewOrApplyImportNativeExtension, type ImportNativeExtensionCandidate, type ImportNativeExtensionFailure, type ImportNativeExtensionRequest, type ImportNativeExtensionRequirements, type ImportNativeMcpServerRequest, type ImportNativeSkillRequest, type ImportNativeSubagentRequest, type NativeImportType, type NativeMcpCandidate, type NativeMcpDiscovery, type PrepareImportNativeExtensionRequirements, } from "./import/import-native-extension.js";
29
+ export { ChangeAuthoredVersion, changeAuthoredVersionPlanName, prepareChangeAuthoredVersion, previewOrApplyChangeAuthoredVersion, type AuthoredVersionChange, type ChangeAuthoredVersionCandidate, type ChangeAuthoredVersionFailure, type ChangeAuthoredVersionRequest, type ChangeAuthoredVersionRequirements, type PrepareChangeAuthoredVersionRequirements, type VersionBumpRule, } from "./version/change-authored-version.js";
30
+ export { AuthoredManifestUnavailable, VersionTargetIdentityMismatch, VersionTargetInvalid, VersionTargetNotAuthored, type AuthoredVersionError, } from "./version/errors.js";
22
31
  //# sourceMappingURL=index.d.ts.map
package/dist/src/index.js CHANGED
@@ -1,24 +1,37 @@
1
1
  /**
2
- * Extension-authoring feature: new-extension scaffolding, fork, native
3
- * import, authored identity decoding, and authored pack membership. The
4
- * application supplies the failure adapter that serializes authoring
5
- * failures into the plan-step vocabulary.
2
+ * Extension-authoring feature: creating new authored packages, forking and
3
+ * importing existing ones, authored identity decoding, and authored pack
4
+ * membership. Every use case settles its decisions in a `prepare` phase that
5
+ * writes nothing and resolves them in `previewOrApply`; failures are typed
6
+ * and carry the facts a person needs to recover.
6
7
  *
7
8
  * @experimental All exports from this module are unstable and may change without notice.
8
9
  * @packageDocumentation
9
10
  */
10
11
  export { AuthoringFailed } from "./errors.js";
11
- export { AuthoringFailureAdapter, withAdaptedStepFailures, } from "./failure-adapter.js";
12
- export { decodeDesiredExtensionIdentity, } from "./desired-identity.js";
12
+ export { CreateDestinationInspectionFailed, CreateNameConfigured, ForkPackageConflict, ForkPackageFailed, ForkPackageInvalid, NativeImportConflict, NativeImportFailed, NativeImportInvalid, NativeImportUnsupported, } from "./authored-package-errors.js";
13
+ export { authoringStepFailure } from "./step-failure.js";
13
14
  export { forkExtensionPackage } from "./fork-package.js";
14
15
  export { importNativeExtensionPackage, } from "./import-native-package.js";
15
16
  export { preflightCreateOnly } from "./create-preflight.js";
17
+ export { authoredDeclaration, } from "./authored-declaration.js";
16
18
  export { markerFqnForRef } from "./marker-fqn.js";
17
- // Scaffolding operations
18
- export { newSkill, } from "./skills/new-skill.js";
19
- export { newHook } from "./hooks/new-hook.js";
20
- export { newPack } from "./packs/new-pack.js";
21
- // Authored pack membership operations
22
- export { addToPack, } from "./packs/add-to-pack.js";
23
- export { removeFromPack, } from "./packs/remove-from-pack.js";
19
+ // Creating a new authored extension
20
+ export { CreateExtension, createExtensionPlanName, prepareCreateExtension, previewOrApplyCreateExtension, } from "./create/create-extension.js";
21
+ export { AuthoringOwnerMismatch, AuthoringOwnerRequired, AuthoringScopeUnsupported, ScaffoldNameInvalid, } from "./create/errors.js";
22
+ export { requireAuthoredOwner, resolveAuthoringOwner, settingsRelativePath, } from "./create/authoring-owner.js";
23
+ export { SCAFFOLD_NAME_MAX_LENGTH, SCAFFOLD_NAME_PATTERN, isValidScaffoldName, normalizeScaffoldOwner, } from "./create/scaffold-name.js";
24
+ export { hookEntrypointFilename } from "./create/scaffolds/hook.js";
25
+ // Changing an authored pack's membership
26
+ export { ChangePackMembership, packMembershipPlanName, preparePackMembership, previewOrApplyPackMembership, } from "./packs/change-pack-membership.js";
27
+ export { PackGraphInvalid, PackManifestUnavailable, PackMemberAmbiguous, PackMemberNotDeclared, PackMemberNotFound, PackMemberUnmanaged, PackNotAuthored, PackNotConfigured, PackOwnerUnconfigured, PackSelectorAmbiguous, PackSelectorNotAPack, PackSourceMissing, } from "./packs/membership-errors.js";
28
+ // Forking a managed package into workspace authorship
29
+ export { ForkExtension, forkExtensionPlanName, prepareForkExtension, previewOrApplyForkExtension, } from "./fork/fork-extension.js";
30
+ // Adopting an acquired package into workspace authorship
31
+ export { AdoptExtension, adoptExtensionPlanName, prepareAdoptExtension, previewOrApplyAdoptExtension, } from "./adopt/adopt-extension.js";
32
+ // Importing native content as an authored package
33
+ export { ImportNativeExtension, importNativeExtensionPlanName, prepareImportNativeExtension, previewOrApplyImportNativeExtension, } from "./import/import-native-extension.js";
34
+ // Changing an authored manifest's version
35
+ export { ChangeAuthoredVersion, changeAuthoredVersionPlanName, prepareChangeAuthoredVersion, previewOrApplyChangeAuthoredVersion, } from "./version/change-authored-version.js";
36
+ export { AuthoredManifestUnavailable, VersionTargetIdentityMismatch, VersionTargetInvalid, VersionTargetNotAuthored, } from "./version/errors.js";
24
37
  //# sourceMappingURL=index.js.map
@@ -7,11 +7,11 @@
7
7
  */
8
8
  import * as FileSystem from "effect/FileSystem";
9
9
  import * as Path from "effect/Path";
10
- import { AuthoringFailureAdapter } from "../failure-adapter.js";
11
10
  import type { Handle } from "@agentxm/extension-model/unstable/extensions";
12
11
  import type { OperationHandler } from "@agentxm/workspace-operations";
13
12
  import type { Operation } from "@agentxm/workspace-operations";
14
13
  import { WorkspaceMutations } from "@agentxm/workspace-state";
14
+ import { WorkspaceTransactionScope } from "@agentxm/workspace-transactions";
15
15
  /**
16
16
  * Args for the add-to-pack operation.
17
17
  */
@@ -40,5 +40,5 @@ export type AddToPackOperation = Operation<"add-to-pack", AddToPackOperationArgs
40
40
  * 4. Apply additions to manifest
41
41
  * 5. Write updated manifest
42
42
  */
43
- export declare const addToPack: OperationHandler<AddToPackOperation, FileSystem.FileSystem | Path.Path | WorkspaceMutations | AuthoringFailureAdapter>;
43
+ export declare const addToPack: OperationHandler<AddToPackOperation, FileSystem.FileSystem | Path.Path | WorkspaceMutations | WorkspaceTransactionScope>;
44
44
  //# sourceMappingURL=add-to-pack.d.ts.map
@@ -10,8 +10,9 @@ import * as Path from "effect/Path";
10
10
  import * as Effect from "effect/Effect";
11
11
  import * as Schema from "effect/Schema";
12
12
  import { AuthoringFailed } from "../errors.js";
13
- import { AuthoringFailureAdapter, withAdaptedStepFailures } from "../failure-adapter.js";
13
+ import { authoringStepFailure } from "../step-failure.js";
14
14
  import { WorkspaceMutations } from "@agentxm/workspace-state";
15
+ import { WorkspaceTransactionScope, runWorkspaceTransaction, } from "@agentxm/workspace-transactions";
15
16
  import { isWorkspaceSourceLocator } from "@agentxm/extension-model/unstable/sources/workspace";
16
17
  import { PACK_MANIFEST_FILENAME, PackManifestSchema, } from "@agentxm/extension-model/unstable/packs/manifest-schema";
17
18
  import { packManifestArtifact } from "./artifact.js";
@@ -52,7 +53,7 @@ export const addToPack = (op) => Effect.gen(function* () {
52
53
  return { result: "success", message: "No pack entries added" };
53
54
  }
54
55
  const manifestPath = path.join(ws.layout.authoredRoot("pack"), packName, PACK_MANIFEST_FILENAME);
55
- yield* ws.runTransaction({
56
+ yield* runWorkspaceTransaction({
56
57
  targets: [manifestPath],
57
58
  transition: Effect.gen(function* () {
58
59
  // Read and stale-check under the workspace lock.
@@ -143,5 +144,5 @@ export const addToPack = (op) => Effect.gen(function* () {
143
144
  fileCount: 1,
144
145
  }),
145
146
  };
146
- }).pipe(withAdaptedStepFailures);
147
+ }).pipe(Effect.mapError(authoringStepFailure));
147
148
  //# sourceMappingURL=add-to-pack.js.map
@@ -0,0 +1,56 @@
1
+ /**
2
+ * Changing which extensions an authored pack declares.
3
+ *
4
+ * A pack's membership is a manifest an author owns, so both directions share
5
+ * one use case: find the pack the selector names, confirm the workspace
6
+ * authors it, read the manifest under a plan-time hash, decide which members
7
+ * the selector resolves to, and reduce that to a delta. An empty delta is a
8
+ * settled outcome, not a failure.
9
+ *
10
+ * @experimental This API is unstable and may change without notice.
11
+ */
12
+ import * as Effect from "effect/Effect";
13
+ import * as FileSystem from "effect/FileSystem";
14
+ import * as Path from "effect/Path";
15
+ import { type ExecutionCandidate, type PlanExecution } from "@agentxm/workspace-operations";
16
+ import { WorkspaceMutations } from "@agentxm/workspace-state";
17
+ import type { WorkspaceTransactionScope } from "@agentxm/workspace-transactions";
18
+ import { PackGraphInvalid, PackManifestUnavailable, PackMemberAmbiguous, PackMemberNotDeclared, PackMemberNotFound, PackMemberUnmanaged, PackNotAuthored, PackOwnerUnconfigured, PackSourceMissing } from "./membership-errors.js";
19
+ export interface PackMembershipRequest {
20
+ /** Which direction the membership changes. */
21
+ readonly change: "add" | "remove";
22
+ /** Configured pack name, or an owner-qualified pack identity. */
23
+ readonly pack: string;
24
+ /** A member name, an owner-qualified identity, or a glob pattern. */
25
+ readonly selector: string;
26
+ }
27
+ /** What a membership step requires when it runs. */
28
+ export type PackMembershipRequirements = FileSystem.FileSystem | Path.Path | WorkspaceMutations | WorkspaceTransactionScope;
29
+ export interface PackMembershipChange {
30
+ readonly _tag: "Change";
31
+ readonly change: "add" | "remove";
32
+ /** Configured name of the pack being edited. */
33
+ readonly pack: string;
34
+ /** Owner-qualified identities the manifest gains or loses, sorted. */
35
+ readonly members: ReadonlyArray<string>;
36
+ readonly execution: ExecutionCandidate<PackMembershipRequirements>;
37
+ }
38
+ export interface PackMembershipUnchanged {
39
+ readonly _tag: "NoChange";
40
+ readonly change: "add" | "remove";
41
+ readonly pack: string;
42
+ }
43
+ /** A settled membership request: either a delta to resolve, or nothing to do. */
44
+ export type PackMembershipCandidate = PackMembershipChange | PackMembershipUnchanged;
45
+ /** Settle a membership change without writing anything. */
46
+ export declare const preparePackMembership: (request: PackMembershipRequest) => Effect.Effect<PackMembershipChange | PackMembershipUnchanged, import("@agentxm/workspace-state").SettingsIoError | import("@agentxm/workspace-state").SettingsParseError | import("@agentxm/workspace-state").SettingsDecodeError | import("@agentxm/workspace-state").WorkspaceRootEscape | import("@agentxm/workspace-state").LockfileIoError | import("@agentxm/workspace-state").LockfileParseError | import("@agentxm/workspace-state").LockfileDecodeError | import("@agentxm/workspace-state").LockfileVersionUnsupported | import("@agentxm/workspace-state").LockfileValidationError | import("@agentxm/workspace-state").PathTraversalDetected | import("@agentxm/workspace-state").LockEntrySourceMissing | import("@agentxm/workspace-state").LockEntryUrlInvalid | import("@agentxm/workspace-state").LockEntryNameInvalid | import("@agentxm/workspace-state").LockEntryEndpointConflict | import("@agentxm/workspace-state").LockEntrySourceTypeConflict | import("@agentxm/workspace-state").AcceptedResolutionMissing | import("@agentxm/workspace-state").InlineExtensionSourceMissing | import("@agentxm/workspace-state").PackageContentHashFailed | import("@agentxm/workspace-state").WorkspaceSourceInvalid | import("@agentxm/workspace-operations").CandidateFingerprintFailed | import("./membership-errors.js").PackSelectorNotAPack | import("./membership-errors.js").PackNotConfigured | import("./membership-errors.js").PackSelectorAmbiguous | PackSourceMissing | PackNotAuthored | PackOwnerUnconfigured | PackManifestUnavailable | PackGraphInvalid | PackMemberAmbiguous | PackMemberUnmanaged | PackMemberNotFound | PackMemberNotDeclared, FileSystem.FileSystem | Path.Path | WorkspaceMutations | import("@agentxm/workspace-state").ConfiguredAgentOutcomesProvider>;
47
+ /** The plan a membership change of this direction resolves. */
48
+ export declare const packMembershipPlanName: (change: "add" | "remove") => string;
49
+ /** Preview or apply a settled membership change. */
50
+ export declare const previewOrApplyPackMembership: (candidate: PackMembershipChange, execution: PlanExecution) => Effect.Effect<import("@agentxm/workspace-operations").OperationResolution<never>, import("@agentxm/workspace-state").WorkspaceSettingsReadFailure | import("@agentxm/workspace-operations").ApprovalRecoveryMissing | import("@agentxm/workspace-operations").PlanInteractionFailed | import("@agentxm/workspace-transactions").WorkspaceTransitionAcquireFailure, import("@agentxm/workspace-state").ConfiguredAgentOutcomesProvider | import("@agentxm/workspace-operations").OperationJournal | import("@agentxm/workspace-operations").ResolvePlanInteraction | import("@agentxm/workspace-transactions").FootprintRecorder | PackMembershipRequirements>;
51
+ /** The pack-membership use case: settle a request, then preview or apply it. */
52
+ export declare const ChangePackMembership: {
53
+ readonly prepare: (request: PackMembershipRequest) => Effect.Effect<PackMembershipChange | PackMembershipUnchanged, import("@agentxm/workspace-state").SettingsIoError | import("@agentxm/workspace-state").SettingsParseError | import("@agentxm/workspace-state").SettingsDecodeError | import("@agentxm/workspace-state").WorkspaceRootEscape | import("@agentxm/workspace-state").LockfileIoError | import("@agentxm/workspace-state").LockfileParseError | import("@agentxm/workspace-state").LockfileDecodeError | import("@agentxm/workspace-state").LockfileVersionUnsupported | import("@agentxm/workspace-state").LockfileValidationError | import("@agentxm/workspace-state").PathTraversalDetected | import("@agentxm/workspace-state").LockEntrySourceMissing | import("@agentxm/workspace-state").LockEntryUrlInvalid | import("@agentxm/workspace-state").LockEntryNameInvalid | import("@agentxm/workspace-state").LockEntryEndpointConflict | import("@agentxm/workspace-state").LockEntrySourceTypeConflict | import("@agentxm/workspace-state").AcceptedResolutionMissing | import("@agentxm/workspace-state").InlineExtensionSourceMissing | import("@agentxm/workspace-state").PackageContentHashFailed | import("@agentxm/workspace-state").WorkspaceSourceInvalid | import("@agentxm/workspace-operations").CandidateFingerprintFailed | import("./membership-errors.js").PackSelectorNotAPack | import("./membership-errors.js").PackNotConfigured | import("./membership-errors.js").PackSelectorAmbiguous | PackSourceMissing | PackNotAuthored | PackOwnerUnconfigured | PackManifestUnavailable | PackGraphInvalid | PackMemberAmbiguous | PackMemberUnmanaged | PackMemberNotFound | PackMemberNotDeclared, FileSystem.FileSystem | Path.Path | WorkspaceMutations | import("@agentxm/workspace-state").ConfiguredAgentOutcomesProvider>;
54
+ readonly previewOrApply: (candidate: PackMembershipChange, execution: PlanExecution) => Effect.Effect<import("@agentxm/workspace-operations").OperationResolution<never>, import("@agentxm/workspace-state").WorkspaceSettingsReadFailure | import("@agentxm/workspace-operations").ApprovalRecoveryMissing | import("@agentxm/workspace-operations").PlanInteractionFailed | import("@agentxm/workspace-transactions").WorkspaceTransitionAcquireFailure, import("@agentxm/workspace-state").ConfiguredAgentOutcomesProvider | import("@agentxm/workspace-operations").OperationJournal | import("@agentxm/workspace-operations").ResolvePlanInteraction | import("@agentxm/workspace-transactions").FootprintRecorder | PackMembershipRequirements>;
55
+ };
56
+ //# sourceMappingURL=change-pack-membership.d.ts.map