@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,253 @@
1
+ /**
2
+ * How an authoring closure serializes a failure into the plan-step vocabulary.
3
+ *
4
+ * The feature owns this: an authoring step that failed must report the same
5
+ * category, sentence, and recovery whether the failure came from authoring's
6
+ * own policy, from the canonical-materialization machinery underneath it, or
7
+ * from the workspace transaction around it. Nothing is supplied by the
8
+ * application, so no authoring operation carries a failure adapter in its
9
+ * requirements.
10
+ *
11
+ * Categories and detail sentences are the serialized contract of machine
12
+ * output; they are reproduced here verbatim from the families that construct
13
+ * them.
14
+ *
15
+ * @experimental This API is unstable and may change without notice.
16
+ */
17
+ import { OPERATION_ERROR_CATEGORIES, StepFailure, restorationIncompleteToStepFailure, workspaceStateReadFailureToStepFailure, workspaceTransactionFailureToStepFailure, } from "@agentxm/workspace-operations";
18
+ import { ArchiveIntegrityMismatch, CanonicalPackageProbeFailed, CreateDestinationExists, LifecyclePostconditionViolated, NativeMcpEntryRetirementFailed, PackageCopyFailed, PackageMaterializationFailed, ScaffoldedExtensionUnresolved, StagedPackageInvalid, } from "@agentxm/extension-materialization";
19
+ import { WorkspaceRestorationIncomplete, } from "@agentxm/workspace-transactions";
20
+ import { AuthoringFailed } from "./errors.js";
21
+ import { CreateDestinationInspectionFailed, CreateNameConfigured, ForkPackageConflict, ForkPackageFailed, ForkPackageInvalid, NativeImportConflict, NativeImportFailed, NativeImportInvalid, NativeImportUnsupported, } from "./authored-package-errors.js";
22
+ const CATEGORIES = new Set(OPERATION_ERROR_CATEGORIES);
23
+ const isCategory = (value) => typeof value === "string" && CATEGORIES.has(value);
24
+ const property = (failure, key) => key in failure ? Reflect.get(failure, key) : undefined;
25
+ /**
26
+ * A failure family this conversion does not name yet still carries its own
27
+ * decision: producers in the kernel record a category and a fact sentence, so
28
+ * both survive rather than being replaced with a generic sentence, and the
29
+ * failure itself stays in `cause` for the diagnostic chain.
30
+ */
31
+ const carriedFailure = (failure) => {
32
+ const carriedCategory = property(failure, "category");
33
+ const carriedDetail = property(failure, "detail");
34
+ return new StepFailure({
35
+ category: isCategory(carriedCategory) ? carriedCategory : "internal",
36
+ detail: typeof carriedDetail === "string"
37
+ ? carriedDetail
38
+ : `The authoring step failed with ${failure._tag}`,
39
+ cause: failure,
40
+ });
41
+ };
42
+ const materializationDetail = (failure) => {
43
+ switch (failure.step) {
44
+ case "recover":
45
+ return `Failed to recover interrupted canonical materialization at ${failure.path}`;
46
+ case "prepare-parent":
47
+ return `Failed to prepare canonical package parent for ${failure.path}`;
48
+ case "prepare-staging":
49
+ return `Failed to prepare canonical package staging at ${failure.path}`;
50
+ case "inspect":
51
+ return `Failed to inspect canonical package at ${failure.path}`;
52
+ case "replace":
53
+ return `Failed to replace canonical package at ${failure.path}`;
54
+ case "inspect-create-destination":
55
+ return `Failed to inspect create-only destination: ${failure.path}`;
56
+ }
57
+ };
58
+ const postconditionDetail = (failure) => {
59
+ switch (failure.postcondition) {
60
+ case "install-observable":
61
+ return `Installed ${failure.targetType} "${failure.targetName}" did not satisfy its observable contract`;
62
+ case "install-declared":
63
+ return `Installed ${failure.targetType} "${failure.targetName}" has no desired-state declaration`;
64
+ case "new-observable":
65
+ return `New ${failure.targetType} "${failure.targetName}" did not satisfy its observable contract`;
66
+ case "new-declared":
67
+ return `New ${failure.targetType} "${failure.targetName}" has no desired-state declaration`;
68
+ case "materialize-observable":
69
+ return `Reconciled ${failure.targetType} "${failure.targetName}" did not satisfy its observable contract`;
70
+ case "uninstall-remains-declared":
71
+ return `Uninstalled ${failure.targetType} "${failure.targetName}" remains declared`;
72
+ case "uninstall-observed-state":
73
+ return `Uninstalled ${failure.targetType} "${failure.targetName}" has an invalid observed postcondition`;
74
+ }
75
+ };
76
+ const WORKSPACE_STATE_READ_TAGS = new Set([
77
+ "SettingsDecodeError",
78
+ "SettingsParseError",
79
+ "SettingsIoError",
80
+ "LockfileIoError",
81
+ "LockfileParseError",
82
+ "LockfileDecodeError",
83
+ "LockfileVersionUnsupported",
84
+ "WorkspaceRootEscape",
85
+ ]);
86
+ const WORKSPACE_TRANSACTION_TAGS = new Set([
87
+ "WorkspaceSnapshotError",
88
+ "WorkspaceDirectoryError",
89
+ "TransitionLockError",
90
+ "TransitionLockUnavailable",
91
+ "WorkspaceTransitionCompromised",
92
+ ]);
93
+ const isWorkspaceStateReadFailure = (failure) => WORKSPACE_STATE_READ_TAGS.has(failure._tag);
94
+ const isWorkspaceTransactionFailure = (failure) => WORKSPACE_TRANSACTION_TAGS.has(failure._tag);
95
+ /**
96
+ * Serialize one authoring-closure failure into the plan-step vocabulary.
97
+ *
98
+ * Families this feature or the machinery beneath it constructs are rendered
99
+ * exactly; families the kernel already serializes are delegated to it; and
100
+ * anything else carries its producer's own category and sentence through.
101
+ */
102
+ export const authoringStepFailure = (failure) => {
103
+ if (failure instanceof StepFailure)
104
+ return failure;
105
+ if (failure instanceof AuthoringFailed) {
106
+ return new StepFailure({
107
+ category: failure.category,
108
+ detail: failure.detail,
109
+ ...(failure.recover === undefined && failure.suggestions === undefined
110
+ ? {}
111
+ : {
112
+ suggestions: [
113
+ ...(failure.recover === undefined ? [] : [{ description: failure.recover }]),
114
+ ...(failure.suggestions ?? []),
115
+ ],
116
+ }),
117
+ ...(failure.cause === undefined ? {} : { cause: failure.cause }),
118
+ });
119
+ }
120
+ if (failure instanceof CreateNameConfigured) {
121
+ return new StepFailure({
122
+ category: "conflict",
123
+ detail: `${failure.subject} '${failure.name}' already exists in settings`,
124
+ suggestions: [
125
+ {
126
+ description: `Choose a different name or remove the existing ${failure.subject.toLowerCase()} first`,
127
+ },
128
+ ],
129
+ });
130
+ }
131
+ if (failure instanceof CreateDestinationExists) {
132
+ return new StepFailure({
133
+ category: "conflict",
134
+ detail: `${failure.subject} destination already exists: ${failure.path}`,
135
+ suggestions: [
136
+ { description: "Choose a different name or remove the existing directory first" },
137
+ ],
138
+ });
139
+ }
140
+ if (failure instanceof CreateDestinationInspectionFailed) {
141
+ return new StepFailure({
142
+ category: "internal",
143
+ detail: `Failed to inspect create destination: ${failure.path}`,
144
+ cause: failure.cause,
145
+ });
146
+ }
147
+ if (failure instanceof ScaffoldedExtensionUnresolved) {
148
+ return new StepFailure({
149
+ category: "not_found",
150
+ detail: `Newly scaffolded ${failure.targetType} "${failure.targetName}" could not be resolved from its workspace source`,
151
+ });
152
+ }
153
+ if (failure instanceof LifecyclePostconditionViolated) {
154
+ return new StepFailure({ category: "internal", detail: postconditionDetail(failure) });
155
+ }
156
+ if (failure instanceof PackageMaterializationFailed) {
157
+ return new StepFailure({
158
+ category: "internal",
159
+ detail: materializationDetail(failure),
160
+ cause: failure.cause,
161
+ });
162
+ }
163
+ if (failure instanceof StagedPackageInvalid) {
164
+ return new StepFailure({
165
+ category: "validation",
166
+ detail: failure.kind === "missing"
167
+ ? `Staged package is missing required file: ${failure.file}`
168
+ : `Staged package path is not a file: ${failure.file}`,
169
+ ...(failure.cause === undefined ? {} : { cause: failure.cause }),
170
+ });
171
+ }
172
+ if (failure instanceof CanonicalPackageProbeFailed) {
173
+ return new StepFailure({
174
+ category: "internal",
175
+ detail: failure.detail,
176
+ cause: failure.cause,
177
+ });
178
+ }
179
+ if (failure instanceof PackageCopyFailed) {
180
+ return new StepFailure({
181
+ category: failure.severity,
182
+ detail: failure.detail,
183
+ cause: failure.cause,
184
+ });
185
+ }
186
+ if (failure instanceof NativeMcpEntryRetirementFailed) {
187
+ return new StepFailure({
188
+ category: failure.category,
189
+ detail: failure.detail,
190
+ ...(failure.cause === undefined ? {} : { cause: failure.cause }),
191
+ });
192
+ }
193
+ if (failure instanceof ArchiveIntegrityMismatch) {
194
+ return new StepFailure({
195
+ category: "validation",
196
+ detail: `${failure.subject} — the fetched archive does not match the accepted integrity. Verify the source and rerun, or update to accept a republished version.`,
197
+ });
198
+ }
199
+ if (failure instanceof ForkPackageInvalid) {
200
+ return new StepFailure({
201
+ category: "validation",
202
+ detail: failure.detail,
203
+ ...(failure.cause === undefined ? {} : { cause: failure.cause }),
204
+ });
205
+ }
206
+ if (failure instanceof ForkPackageConflict) {
207
+ return new StepFailure({ category: "conflict", detail: failure.detail });
208
+ }
209
+ if (failure instanceof ForkPackageFailed) {
210
+ return new StepFailure({
211
+ category: "internal",
212
+ detail: failure.detail,
213
+ cause: failure.cause,
214
+ });
215
+ }
216
+ if (failure instanceof NativeImportUnsupported) {
217
+ return new StepFailure({
218
+ category: "usage",
219
+ detail: `Native package import is not supported for ${failure.type}`,
220
+ });
221
+ }
222
+ if (failure instanceof NativeImportInvalid) {
223
+ return new StepFailure({
224
+ category: "validation",
225
+ detail: failure.detail,
226
+ ...(failure.cause === undefined ? {} : { cause: failure.cause }),
227
+ });
228
+ }
229
+ if (failure instanceof NativeImportConflict) {
230
+ return new StepFailure({
231
+ category: "conflict",
232
+ detail: `Import target already exists: ${failure.targetDir}`,
233
+ });
234
+ }
235
+ if (failure instanceof NativeImportFailed) {
236
+ return new StepFailure({
237
+ category: "internal",
238
+ detail: failure.detail,
239
+ cause: failure.cause,
240
+ });
241
+ }
242
+ if (failure instanceof WorkspaceRestorationIncomplete) {
243
+ return restorationIncompleteToStepFailure(failure);
244
+ }
245
+ if (isWorkspaceTransactionFailure(failure)) {
246
+ return workspaceTransactionFailureToStepFailure(failure);
247
+ }
248
+ if (isWorkspaceStateReadFailure(failure)) {
249
+ return workspaceStateReadFailureToStepFailure(failure);
250
+ }
251
+ return carriedFailure(failure);
252
+ };
253
+ //# sourceMappingURL=step-failure.js.map
@@ -0,0 +1,68 @@
1
+ /**
2
+ * @agentxm/extension-authoring deterministic test fixtures.
3
+ *
4
+ * A throwaway project workspace on a temporary directory, and the per-type
5
+ * creation request an authoring command is admitted with.
6
+ *
7
+ * The fixture is deliberately platform-free: composing the file system, the
8
+ * transport and the managers is the consumer's job, exactly as it is the
9
+ * application's, so this module stays importable from a published package
10
+ * rather than dragging a Node-only platform layer behind it. What it does own
11
+ * is the shape of an authored workspace on disk and the byte-exact snapshot a
12
+ * purity example compares against — two snapshots are equal only when every
13
+ * path and every byte is unchanged, so a preview that wrote anything at all
14
+ * fails rather than passing on a coarse comparison.
15
+ *
16
+ * Production source never imports this module.
17
+ *
18
+ * @experimental This API is unstable and may change without notice.
19
+ * @packageDocumentation
20
+ */
21
+ import * as Option from "effect/Option";
22
+ import type { CreatableExtensionType, CreateExtensionRequest } from "./create/create-extension.js";
23
+ /** Settings an authoring example seeds its workspace with. */
24
+ export interface AuthoringWorkspaceSettings {
25
+ readonly owner?: string;
26
+ readonly agents?: ReadonlyArray<string>;
27
+ }
28
+ export interface AuthoringWorkspace {
29
+ /** Absolute project root the workspace is anchored to. */
30
+ readonly root: string;
31
+ /** Read a workspace-relative file, or `undefined` when it is absent. */
32
+ readonly read: (relativePath: string) => string | undefined;
33
+ /** Write a workspace-relative file, creating parents. */
34
+ readonly write: (relativePath: string, contents: string) => void;
35
+ /** Whether a workspace-relative path exists. */
36
+ readonly exists: (relativePath: string) => boolean;
37
+ /** The decoded settings document. */
38
+ readonly settings: () => unknown;
39
+ /** Replace the settings document wholesale. */
40
+ readonly writeSettings: (value: unknown) => void;
41
+ /** The lockfile text, or an empty string when there is none. */
42
+ readonly lockfileText: () => string;
43
+ /** Every workspace-relative path that exists, sorted. */
44
+ readonly tree: () => ReadonlyArray<string>;
45
+ /**
46
+ * Byte-exact content of a subtree: workspace-relative path mapped to
47
+ * `"directory"` or `"file:<base64>"`. A missing root snapshots empty.
48
+ */
49
+ readonly snapshot: (relativePath?: string) => Readonly<Record<string, string>>;
50
+ readonly cleanup: () => void;
51
+ }
52
+ /**
53
+ * A temporary project workspace whose settings name an owner and the agents
54
+ * it configures, initialized the way `axm setup` leaves a project.
55
+ */
56
+ export declare const makeAuthoringWorkspace: (settings?: AuthoringWorkspaceSettings) => AuthoringWorkspace;
57
+ /**
58
+ * The creation request for one extension type, with the per-type options an
59
+ * example does not vary.
60
+ *
61
+ * The rules that sweep every type — create-only refusal, workspace ownership —
62
+ * are about what creation shares, not about what each scaffold takes, so the
63
+ * type-specific fields are supplied once here rather than in every example.
64
+ */
65
+ export declare const createRequestFor: (type: CreatableExtensionType, name: string, owner?: Option.Option<string>) => CreateExtensionRequest;
66
+ /** Every extension type a person can author in a workspace. */
67
+ export declare const CREATABLE_TYPES: readonly ["skill", "mcp-server", "subagent", "rule", "hook", "knowledge", "pack"];
68
+ //# sourceMappingURL=testing.d.ts.map
@@ -0,0 +1,135 @@
1
+ /**
2
+ * @agentxm/extension-authoring deterministic test fixtures.
3
+ *
4
+ * A throwaway project workspace on a temporary directory, and the per-type
5
+ * creation request an authoring command is admitted with.
6
+ *
7
+ * The fixture is deliberately platform-free: composing the file system, the
8
+ * transport and the managers is the consumer's job, exactly as it is the
9
+ * application's, so this module stays importable from a published package
10
+ * rather than dragging a Node-only platform layer behind it. What it does own
11
+ * is the shape of an authored workspace on disk and the byte-exact snapshot a
12
+ * purity example compares against — two snapshots are equal only when every
13
+ * path and every byte is unchanged, so a preview that wrote anything at all
14
+ * fails rather than passing on a coarse comparison.
15
+ *
16
+ * Production source never imports this module.
17
+ *
18
+ * @experimental This API is unstable and may change without notice.
19
+ * @packageDocumentation
20
+ */
21
+ import * as fs from "node:fs";
22
+ import * as os from "node:os";
23
+ import * as nodePath from "node:path";
24
+ import * as Option from "effect/Option";
25
+ const walk = (root, directory) => {
26
+ const entries = fs.existsSync(directory)
27
+ ? fs.readdirSync(directory, { withFileTypes: true })
28
+ : [];
29
+ return entries.flatMap((entry) => {
30
+ const absolute = nodePath.join(directory, entry.name);
31
+ const relative = nodePath.relative(root, absolute);
32
+ return entry.isDirectory() ? walk(root, absolute) : [relative];
33
+ });
34
+ };
35
+ /**
36
+ * A temporary project workspace whose settings name an owner and the agents
37
+ * it configures, initialized the way `axm setup` leaves a project.
38
+ */
39
+ export const makeAuthoringWorkspace = (settings = {}) => {
40
+ const root = fs.realpathSync(fs.mkdtempSync(nodePath.join(os.tmpdir(), "axm-authoring-")));
41
+ const absolute = (relativePath) => nodePath.join(root, relativePath);
42
+ const writeSettings = (value) => {
43
+ fs.writeFileSync(absolute("axm.json"), `${JSON.stringify(value, null, 2)}\n`);
44
+ };
45
+ writeSettings({
46
+ ...(settings.owner === undefined ? {} : { owner: settings.owner }),
47
+ agents: settings.agents ?? [],
48
+ });
49
+ const snapshot = (relativePath = ".") => {
50
+ const target = absolute(relativePath);
51
+ const entries = {};
52
+ if (!fs.existsSync(target))
53
+ return entries;
54
+ if (!fs.statSync(target).isDirectory()) {
55
+ entries["."] = `file:${fs.readFileSync(target).toString("base64")}`;
56
+ return entries;
57
+ }
58
+ const visit = (directory) => {
59
+ for (const entry of fs
60
+ .readdirSync(directory, { withFileTypes: true })
61
+ .sort((left, right) => left.name.localeCompare(right.name, "en"))) {
62
+ const child = nodePath.join(directory, entry.name);
63
+ const relative = nodePath.relative(target, child);
64
+ if (entry.isDirectory()) {
65
+ entries[relative] = "directory";
66
+ visit(child);
67
+ }
68
+ else {
69
+ entries[relative] = `file:${fs.readFileSync(child).toString("base64")}`;
70
+ }
71
+ }
72
+ };
73
+ visit(target);
74
+ return entries;
75
+ };
76
+ return {
77
+ root,
78
+ read: (relativePath) => fs.existsSync(absolute(relativePath))
79
+ ? fs.readFileSync(absolute(relativePath), "utf-8")
80
+ : undefined,
81
+ write: (relativePath, contents) => {
82
+ const target = absolute(relativePath);
83
+ fs.mkdirSync(nodePath.dirname(target), { recursive: true });
84
+ fs.writeFileSync(target, contents);
85
+ },
86
+ exists: (relativePath) => fs.existsSync(absolute(relativePath)),
87
+ settings: () => JSON.parse(fs.readFileSync(absolute("axm.json"), "utf-8")),
88
+ writeSettings,
89
+ lockfileText: () => fs.existsSync(absolute("axm-lock.yaml"))
90
+ ? fs.readFileSync(absolute("axm-lock.yaml"), "utf-8")
91
+ : "",
92
+ tree: () => [...walk(root, root)].sort(),
93
+ snapshot,
94
+ cleanup: () => {
95
+ fs.rmSync(root, { recursive: true, force: true });
96
+ },
97
+ };
98
+ };
99
+ /**
100
+ * The creation request for one extension type, with the per-type options an
101
+ * example does not vary.
102
+ *
103
+ * The rules that sweep every type — create-only refusal, workspace ownership —
104
+ * are about what creation shares, not about what each scaffold takes, so the
105
+ * type-specific fields are supplied once here rather than in every example.
106
+ */
107
+ export const createRequestFor = (type, name, owner = Option.none()) => {
108
+ switch (type) {
109
+ case "skill":
110
+ return { type, name, owner };
111
+ case "subagent":
112
+ return { type, name, owner };
113
+ case "pack":
114
+ return { type, name, owner };
115
+ case "rule":
116
+ return { type, name, owner, title: Option.none() };
117
+ case "knowledge":
118
+ return { type, name, owner, description: Option.none() };
119
+ case "hook":
120
+ return { type, name, owner, runtime: "bash", event: "tool.pre", matcher: Option.none() };
121
+ case "mcp-server":
122
+ return { type, name, owner, description: Option.none(), nonInteractive: true };
123
+ }
124
+ };
125
+ /** Every extension type a person can author in a workspace. */
126
+ export const CREATABLE_TYPES = [
127
+ "skill",
128
+ "mcp-server",
129
+ "subagent",
130
+ "rule",
131
+ "hook",
132
+ "knowledge",
133
+ "pack",
134
+ ];
135
+ //# sourceMappingURL=testing.js.map
@@ -0,0 +1,73 @@
1
+ /**
2
+ * Changing the version an authored manifest declares.
3
+ *
4
+ * A version is one field of one manifest the workspace authors, so this use
5
+ * case decides three things: that the named package really is authored here,
6
+ * what the next version is, and that nothing else in the manifest moves. The
7
+ * write runs inside the workspace transaction like every other authoring
8
+ * change, so an interrupted or failed bump restores the manifest rather than
9
+ * leaving a half-written file, and the operation reports the real resolution
10
+ * the transaction settled with.
11
+ *
12
+ * `prepare` reads the manifest, settles `from` and `to`, and writes nothing.
13
+ * `previewOrApply` resolves that candidate; a bump to the version the manifest
14
+ * already carries settles as unchanged rather than rewriting the file.
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 Path from "effect/Path";
21
+ import { type ExtensionType, type FqnInvalidError } from "@agentxm/extension-model/unstable/extensions";
22
+ import { type Version } from "@agentxm/extension-model/unstable/version-constraints";
23
+ import { type CandidateFingerprintFailed, type ExecutionCandidate, type PlanExecution } from "@agentxm/workspace-operations";
24
+ import { WorkspaceMutations, type ConfiguredAgentOutcomesProvider, type LockfileValidationError, type WorkspaceLockfileReadFailure, type WorkspaceSettingsReadFailure } from "@agentxm/workspace-state";
25
+ import { type WorkspaceTransactionScope } from "@agentxm/workspace-transactions";
26
+ import { AuthoringScopeUnsupported } from "../create/errors.js";
27
+ import { type AuthoredVersionError } from "./errors.js";
28
+ /** The relative bumps a manifest version can take. */
29
+ export type VersionBumpRule = "patch" | "minor" | "major" | "prerelease";
30
+ /** How the next version is decided: by rule, or stated exactly. */
31
+ export type AuthoredVersionChange = {
32
+ readonly _tag: "Increment";
33
+ readonly rule: VersionBumpRule;
34
+ } | {
35
+ readonly _tag: "Exact";
36
+ readonly version: string;
37
+ };
38
+ export interface ChangeAuthoredVersionRequest {
39
+ /** Owner-qualified identity of the authored package, as the person typed it. */
40
+ readonly fqn: string;
41
+ readonly change: AuthoredVersionChange;
42
+ }
43
+ /** What the version step requires when it runs. */
44
+ export type ChangeAuthoredVersionRequirements = FileSystem.FileSystem | Path.Path | WorkspaceTransactionScope;
45
+ /** A settled version change: the manifest is read, the next version decided, nothing written. */
46
+ export interface ChangeAuthoredVersionCandidate {
47
+ readonly type: ExtensionType;
48
+ /** Owner-qualified identity, canonically formatted. */
49
+ readonly fqn: string;
50
+ /** Workspace-relative path of the manifest that carries the version. */
51
+ readonly manifestPath: string;
52
+ readonly from: Version;
53
+ readonly to: Version;
54
+ /** Whether the request asks for a version the manifest already declares. */
55
+ readonly unchanged: boolean;
56
+ readonly execution: ExecutionCandidate<ChangeAuthoredVersionRequirements>;
57
+ }
58
+ /** Every failure settling a version change can surface before anything is written. */
59
+ export type ChangeAuthoredVersionFailure = AuthoredVersionError | AuthoringScopeUnsupported | LockfileValidationError | WorkspaceLockfileReadFailure | WorkspaceSettingsReadFailure | CandidateFingerprintFailed | FqnInvalidError;
60
+ /** Everything settling a version change reads before it freezes a candidate. */
61
+ export type PrepareChangeAuthoredVersionRequirements = FileSystem.FileSystem | Path.Path | WorkspaceMutations | ConfiguredAgentOutcomesProvider;
62
+ /** The plan a version change resolves. */
63
+ export declare const changeAuthoredVersionPlanName = "Update extension version";
64
+ /** Settle a version change without writing anything. */
65
+ export declare const prepareChangeAuthoredVersion: (request: ChangeAuthoredVersionRequest) => Effect.Effect<ChangeAuthoredVersionCandidate, ChangeAuthoredVersionFailure, PrepareChangeAuthoredVersionRequirements>;
66
+ /** Preview or apply a settled version change, resolving to one operation outcome. */
67
+ export declare const previewOrApplyChangeAuthoredVersion: (candidate: ChangeAuthoredVersionCandidate, execution: PlanExecution) => Effect.Effect<import("@agentxm/workspace-operations").OperationResolution<never>, WorkspaceSettingsReadFailure | import("@agentxm/workspace-operations").ApprovalRecoveryMissing | import("@agentxm/workspace-operations").PlanInteractionFailed | import("@agentxm/workspace-transactions").WorkspaceTransitionAcquireFailure, WorkspaceMutations | ConfiguredAgentOutcomesProvider | import("@agentxm/workspace-operations").OperationJournal | import("@agentxm/workspace-operations").ResolvePlanInteraction | import("@agentxm/workspace-transactions").FootprintRecorder | ChangeAuthoredVersionRequirements>;
68
+ /** The version-change use case: settle a request, then preview or apply it. */
69
+ export declare const ChangeAuthoredVersion: {
70
+ readonly prepare: (request: ChangeAuthoredVersionRequest) => Effect.Effect<ChangeAuthoredVersionCandidate, ChangeAuthoredVersionFailure, PrepareChangeAuthoredVersionRequirements>;
71
+ readonly previewOrApply: (candidate: ChangeAuthoredVersionCandidate, execution: PlanExecution) => Effect.Effect<import("@agentxm/workspace-operations").OperationResolution<never>, WorkspaceSettingsReadFailure | import("@agentxm/workspace-operations").ApprovalRecoveryMissing | import("@agentxm/workspace-operations").PlanInteractionFailed | import("@agentxm/workspace-transactions").WorkspaceTransitionAcquireFailure, WorkspaceMutations | ConfiguredAgentOutcomesProvider | import("@agentxm/workspace-operations").OperationJournal | import("@agentxm/workspace-operations").ResolvePlanInteraction | import("@agentxm/workspace-transactions").FootprintRecorder | ChangeAuthoredVersionRequirements>;
72
+ };
73
+ //# sourceMappingURL=change-authored-version.d.ts.map