@agentxm/extension-authoring 0.28.4-bootstrap.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,110 @@
1
+ # Functional Source License, Version 1.1, MIT Future License
2
+
3
+ ## Abbreviation
4
+
5
+ FSL-1.1-MIT
6
+
7
+ ## Notice
8
+
9
+ Copyright 2025-2026 AgentXM, Inc.
10
+
11
+ ## Terms and Conditions
12
+
13
+ ### Licensor ("We")
14
+
15
+ The party offering the Software under these Terms and Conditions.
16
+
17
+ ### The Software
18
+
19
+ The "Software" is each version of the software that we make available under
20
+ these Terms and Conditions, as indicated by our inclusion of these Terms and
21
+ Conditions with the Software.
22
+
23
+ ### License Grant
24
+
25
+ Subject to your compliance with this License Grant and the Patents,
26
+ Redistribution and Trademark clauses below, we hereby grant you the right to
27
+ use, copy, modify, create derivative works, publicly perform, publicly display
28
+ and redistribute the Software for any Permitted Purpose identified below.
29
+
30
+ ### Permitted Purpose
31
+
32
+ A Permitted Purpose is any purpose other than a Competing Use. A Competing Use
33
+ means making the Software available to others in a commercial product or
34
+ service that:
35
+
36
+ 1. substitutes for the Software;
37
+
38
+ 2. substitutes for any other product or service we offer using the Software
39
+ that exists as of the date we make the Software available; or
40
+
41
+ 3. offers the same or substantially similar functionality as the Software.
42
+
43
+ Permitted Purposes specifically include using the Software:
44
+
45
+ 1. for your internal use and access;
46
+
47
+ 2. for non-commercial education;
48
+
49
+ 3. for non-commercial research; and
50
+
51
+ 4. in connection with professional services that you provide to a licensee
52
+ using the Software in accordance with these Terms and Conditions.
53
+
54
+ ### Patents
55
+
56
+ To the extent your use for a Permitted Purpose would necessarily infringe our
57
+ patents, the license grant above includes a license under our patents. If you
58
+ make a claim against any party that the Software infringes or contributes to
59
+ the infringement of any patent, then your patent license to the Software ends
60
+ immediately.
61
+
62
+ ### Redistribution
63
+
64
+ The Terms and Conditions apply to all copies, modifications and derivatives of
65
+ the Software.
66
+
67
+ If you redistribute any copies, modifications or derivatives of the Software,
68
+ you must include a copy of or a link to these Terms and Conditions and not
69
+ remove any copyright notices provided in or with the Software.
70
+
71
+ ### Disclaimer
72
+
73
+ THE SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTIES OF ANY KIND, EXPRESS OR
74
+ IMPLIED, INCLUDING WITHOUT LIMITATION WARRANTIES OF FITNESS FOR A PARTICULAR
75
+ PURPOSE, MERCHANTABILITY, TITLE OR NON-INFRINGEMENT.
76
+
77
+ IN NO EVENT WILL WE HAVE ANY LIABILITY TO YOU ARISING OUT OF OR RELATED TO THE
78
+ SOFTWARE, INCLUDING INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES,
79
+ EVEN IF WE HAVE BEEN INFORMED OF THEIR POSSIBILITY IN ADVANCE.
80
+
81
+ ### Trademarks
82
+
83
+ Except for displaying the License Details and identifying us as the origin of
84
+ the Software, you have no right under these Terms and Conditions to use our
85
+ trademarks, trade names, service marks or product names.
86
+
87
+ ## Grant of Future License
88
+
89
+ We hereby irrevocably grant you an additional license to use the Software under
90
+ the MIT license that is effective on the second anniversary of the date we make
91
+ the Software available. On or after that date, you may use the Software under
92
+ the MIT license, in which case the following will apply:
93
+
94
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
95
+ this software and associated documentation files (the "Software"), to deal in
96
+ the Software without restriction, including without limitation the rights to
97
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
98
+ of the Software, and to permit persons to whom the Software is furnished to do
99
+ so, subject to the following conditions:
100
+
101
+ The above copyright notice and this permission notice shall be included in all
102
+ copies or substantial portions of the Software.
103
+
104
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
105
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
106
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
107
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
108
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
109
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
110
+ SOFTWARE.
@@ -0,0 +1,12 @@
1
+ import * as Effect from "effect/Effect";
2
+ import * as FileSystem from "effect/FileSystem";
3
+ import { CreateDestinationExists, CreateDestinationInspectionFailed, CreateNameConfigured } from "@agentxm/extension-workspace";
4
+ export interface CreateOnlyPreflightArgs {
5
+ readonly subject: string;
6
+ readonly name: string;
7
+ readonly configured: boolean;
8
+ readonly destinations: ReadonlyArray<string>;
9
+ }
10
+ /** Refuse every declared identity/path collision before a create operation mutates the workspace. */
11
+ export declare const preflightCreateOnly: (args: CreateOnlyPreflightArgs) => Effect.Effect<undefined, CreateNameConfigured | CreateDestinationExists | CreateDestinationInspectionFailed, FileSystem.FileSystem>;
12
+ //# sourceMappingURL=create-preflight.d.ts.map
@@ -0,0 +1,19 @@
1
+ import * as Effect from "effect/Effect";
2
+ import * as FileSystem from "effect/FileSystem";
3
+ import { CreateDestinationExists, CreateDestinationInspectionFailed, CreateNameConfigured, } from "@agentxm/extension-workspace";
4
+ /** Refuse every declared identity/path collision before a create operation mutates the workspace. */
5
+ export const preflightCreateOnly = Effect.fn("Extensions.preflightCreateOnly")(function* (args) {
6
+ if (args.configured) {
7
+ return yield* new CreateNameConfigured({ subject: args.subject, name: args.name });
8
+ }
9
+ const fs = yield* FileSystem.FileSystem;
10
+ for (const destination of args.destinations) {
11
+ const exists = yield* fs
12
+ .exists(destination)
13
+ .pipe(Effect.mapError((cause) => new CreateDestinationInspectionFailed({ path: destination, cause })));
14
+ if (exists) {
15
+ return yield* new CreateDestinationExists({ subject: args.subject, path: destination });
16
+ }
17
+ }
18
+ });
19
+ //# sourceMappingURL=create-preflight.js.map
@@ -0,0 +1,19 @@
1
+ import { type ExtensionName, type ExtensionType } from "@agentxm/extension-model/unstable/extensions/common";
2
+ import type { Handle } from "@agentxm/extension-model/unstable/extensions/handle";
3
+ export type DesiredPackageAuthority = "registry" | "workspace";
4
+ export interface DecodedDesiredExtensionIdentity {
5
+ readonly authority: DesiredPackageAuthority;
6
+ readonly owner: Handle;
7
+ readonly type: ExtensionType;
8
+ readonly name: ExtensionName;
9
+ readonly fqn: string;
10
+ }
11
+ /**
12
+ * Decode the source-qualified identity stored in the desired-state graph.
13
+ *
14
+ * This is deliberately narrower than source-locator parsing: desired graph
15
+ * identities are either validated Registry FQNs or `workspace:` followed by a
16
+ * validated FQN. Unknown authorities fail closed.
17
+ */
18
+ export declare const decodeDesiredExtensionIdentity: (identity: string) => DecodedDesiredExtensionIdentity | undefined;
19
+ //# sourceMappingURL=desired-identity.d.ts.map
@@ -0,0 +1,26 @@
1
+ import { parseExtensionFqnParts, } from "@agentxm/extension-model/unstable/extensions/common";
2
+ const workspacePrefix = "workspace:";
3
+ /**
4
+ * Decode the source-qualified identity stored in the desired-state graph.
5
+ *
6
+ * This is deliberately narrower than source-locator parsing: desired graph
7
+ * identities are either validated Registry FQNs or `workspace:` followed by a
8
+ * validated FQN. Unknown authorities fail closed.
9
+ */
10
+ export const decodeDesiredExtensionIdentity = (identity) => {
11
+ const authority = identity.startsWith(workspacePrefix)
12
+ ? "workspace"
13
+ : "registry";
14
+ const fqn = authority === "workspace" ? identity.slice(workspacePrefix.length) : identity;
15
+ const parsed = parseExtensionFqnParts(fqn);
16
+ if (parsed === undefined)
17
+ return undefined;
18
+ return {
19
+ authority,
20
+ owner: parsed.owner,
21
+ type: parsed.type,
22
+ name: parsed.name,
23
+ fqn,
24
+ };
25
+ };
26
+ //# sourceMappingURL=desired-identity.js.map
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Typed failures for the extension-authoring feature. The producer owns the
3
+ * category choice and user-facing wording; the application boundary converts
4
+ * the carried fields into its error envelope verbatim.
5
+ *
6
+ * @experimental This API is unstable and may change without notice.
7
+ */
8
+ import * as Schema from "effect/Schema";
9
+ declare const AuthoringFailed_base: Schema.Class<AuthoringFailed, Schema.TaggedStruct<"AuthoringFailed", {
10
+ readonly category: Schema.Literals<readonly ["conflict", "internal", "not_found", "validation"]>;
11
+ readonly detail: Schema.String;
12
+ readonly recover: Schema.optional<Schema.String>;
13
+ readonly suggestions: Schema.optional<Schema.$Array<Schema.Struct<{
14
+ readonly description: Schema.String;
15
+ readonly cmd: Schema.optional<Schema.String>;
16
+ readonly url: Schema.optional<Schema.String>;
17
+ }>>>;
18
+ readonly cause: Schema.optional<Schema.Unknown>;
19
+ }>, import("effect/Cause").YieldableError>;
20
+ /**
21
+ * An authoring policy step could not proceed. The carried fields mirror the
22
+ * application error envelope's inputs 1:1: `category` selects the code,
23
+ * `recover` folds into the leading suggested action, and `detail`,
24
+ * `suggestions`, and `cause` carry over verbatim.
25
+ */
26
+ export declare class AuthoringFailed extends AuthoringFailed_base {
27
+ }
28
+ export {};
29
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Typed failures for the extension-authoring feature. The producer owns the
3
+ * category choice and user-facing wording; the application boundary converts
4
+ * the carried fields into its error envelope verbatim.
5
+ *
6
+ * @experimental This API is unstable and may change without notice.
7
+ */
8
+ import * as Schema from "effect/Schema";
9
+ const CarriedSuggestedActionSchema = Schema.Struct({
10
+ description: Schema.String,
11
+ cmd: Schema.optional(Schema.String),
12
+ url: Schema.optional(Schema.String),
13
+ });
14
+ /**
15
+ * An authoring policy step could not proceed. The carried fields mirror the
16
+ * application error envelope's inputs 1:1: `category` selects the code,
17
+ * `recover` folds into the leading suggested action, and `detail`,
18
+ * `suggestions`, and `cause` carry over verbatim.
19
+ */
20
+ export class AuthoringFailed extends Schema.TaggedError()("AuthoringFailed", {
21
+ category: Schema.Literals(["conflict", "internal", "not_found", "validation"]),
22
+ detail: Schema.String,
23
+ recover: Schema.optional(Schema.String),
24
+ suggestions: Schema.optional(Schema.Array(CarriedSuggestedActionSchema)),
25
+ cause: Schema.optional(Schema.Unknown),
26
+ }) {
27
+ }
28
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1,31 @@
1
+ /**
2
+ * The application-supplied conversion from authoring failures to the plan
3
+ * step vocabulary. Error rendering is application-owned: the CLI implements
4
+ * this with the same dispatcher it uses at its output boundary, so step
5
+ * categories and details inside authoring operations stay byte-identical
6
+ * with rendered errors. The feature keeps only the requirement, never the
7
+ * mapping.
8
+ *
9
+ * @experimental This API is unstable and may change without notice.
10
+ */
11
+ import * as ServiceMap from "effect/Context";
12
+ import * as Effect from "effect/Effect";
13
+ import type { StepFailure } from "@agentxm/workspace-operations";
14
+ export interface AuthoringFailureAdapterService {
15
+ /**
16
+ * Serialize any failure an authoring operation can surface — kernel
17
+ * failures and the feature's own typed failures — into the plan-step
18
+ * vocabulary.
19
+ */
20
+ readonly toStepFailure: (failure: unknown) => StepFailure;
21
+ }
22
+ declare const AuthoringFailureAdapter_base: ServiceMap.ServiceClass<AuthoringFailureAdapter, "@agentxm/extension-authoring/failure-adapter/AuthoringFailureAdapter", AuthoringFailureAdapterService>;
23
+ export declare class AuthoringFailureAdapter extends AuthoringFailureAdapter_base {
24
+ }
25
+ /**
26
+ * Serialize every failure of one authoring operation into the plan-step
27
+ * vocabulary through the application-supplied adapter.
28
+ */
29
+ export declare const withAdaptedStepFailures: <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, StepFailure, R | AuthoringFailureAdapter>;
30
+ export {};
31
+ //# sourceMappingURL=failure-adapter.d.ts.map
@@ -0,0 +1,23 @@
1
+ /**
2
+ * The application-supplied conversion from authoring failures to the plan
3
+ * step vocabulary. Error rendering is application-owned: the CLI implements
4
+ * this with the same dispatcher it uses at its output boundary, so step
5
+ * categories and details inside authoring operations stay byte-identical
6
+ * with rendered errors. The feature keeps only the requirement, never the
7
+ * mapping.
8
+ *
9
+ * @experimental This API is unstable and may change without notice.
10
+ */
11
+ import * as ServiceMap from "effect/Context";
12
+ import * as Effect from "effect/Effect";
13
+ export class AuthoringFailureAdapter extends ServiceMap.Service()("@agentxm/extension-authoring/failure-adapter/AuthoringFailureAdapter") {
14
+ }
15
+ /**
16
+ * Serialize every failure of one authoring operation into the plan-step
17
+ * vocabulary through the application-supplied adapter.
18
+ */
19
+ export const withAdaptedStepFailures = (effect) => Effect.gen(function* () {
20
+ const adapter = yield* AuthoringFailureAdapter;
21
+ return yield* effect.pipe(Effect.mapError((failure) => adapter.toStepFailure(failure)));
22
+ });
23
+ //# sourceMappingURL=failure-adapter.js.map
@@ -0,0 +1,20 @@
1
+ import * as Effect from "effect/Effect";
2
+ import * as FileSystem from "effect/FileSystem";
3
+ import * as Path from "effect/Path";
4
+ import { ForkPackageConflict, ForkPackageFailed, ForkPackageInvalid } from "@agentxm/extension-workspace";
5
+ import { type FrontmatterParseFailure } from "@agentxm/registry-protocol/unstable/content/frontmatter";
6
+ import type { ExtensionFqnParts, ExtensionName, ExtensionType } from "@agentxm/extension-model/unstable/extensions/common";
7
+ import type { Handle } from "@agentxm/extension-model/unstable/extensions/handle";
8
+ export interface ForkExtensionPackageArgs {
9
+ readonly sourceDir: string;
10
+ readonly targetDir: string;
11
+ readonly sourceIdentity: {
12
+ readonly owner: Handle;
13
+ readonly type: ExtensionType;
14
+ readonly name: ExtensionName;
15
+ readonly version: string;
16
+ };
17
+ readonly target: ExtensionFqnParts;
18
+ }
19
+ export declare const forkExtensionPackage: (args: ForkExtensionPackageArgs) => Effect.Effect<void, ForkPackageInvalid | ForkPackageConflict | ForkPackageFailed | FrontmatterParseFailure, FileSystem.FileSystem | Path.Path>;
20
+ //# sourceMappingURL=fork-package.d.ts.map
@@ -0,0 +1,155 @@
1
+ import * as Effect from "effect/Effect";
2
+ import * as FileSystem from "effect/FileSystem";
3
+ import * as Option from "effect/Option";
4
+ import * as Path from "effect/Path";
5
+ import * as Schema from "effect/Schema";
6
+ import YAML from "yaml";
7
+ import { ForkPackageConflict, ForkPackageFailed, ForkPackageInvalid, } from "@agentxm/extension-workspace";
8
+ import { ManifestIdentitySchema, manifestFilenameForType, manifestSchemaForType, } from "@agentxm/registry-protocol/unstable/publish/manifest-policy";
9
+ import { copyExtensionDirectory } from "@agentxm/extension-workspace";
10
+ import { parseFrontmatterEffect, } from "@agentxm/registry-protocol/unstable/content/frontmatter";
11
+ const INITIAL_FORK_VERSION = "0.1.0";
12
+ const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
13
+ const readJson = (filePath) => Effect.gen(function* () {
14
+ const fs = yield* FileSystem.FileSystem;
15
+ const text = yield* fs
16
+ .readFileString(filePath)
17
+ .pipe(Effect.mapError((cause) => new ForkPackageInvalid({ detail: `Manifest could not be read: ${filePath}`, cause })));
18
+ return yield* Schema.decodeUnknownEffect(Schema.fromJsonString(Schema.Unknown))(text).pipe(Effect.mapError((cause) => new ForkPackageInvalid({ detail: `Manifest contains invalid JSON: ${filePath}`, cause })));
19
+ });
20
+ const validateSourceIdentity = (actual, expected) => actual.owner === expected.owner &&
21
+ actual.type === expected.type &&
22
+ actual.name === expected.name &&
23
+ actual.version === expected.version
24
+ ? Effect.void
25
+ : new ForkPackageConflict({
26
+ detail: `Fork source changed after it was resolved; expected ${expected.owner}/${expected.type}/${expected.name}@${expected.version}`,
27
+ });
28
+ const validateContainedSymlinks = (sourceRoot) => Effect.gen(function* () {
29
+ const fs = yield* FileSystem.FileSystem;
30
+ const path = yield* Path.Path;
31
+ const realRoot = yield* fs.realPath(sourceRoot).pipe(Effect.mapError((cause) => new ForkPackageInvalid({
32
+ detail: `Fork source could not be resolved: ${sourceRoot}`,
33
+ cause,
34
+ })));
35
+ const entries = yield* fs.readDirectory(sourceRoot, { recursive: true }).pipe(Effect.mapError((cause) => new ForkPackageInvalid({
36
+ detail: `Fork source could not be inspected: ${sourceRoot}`,
37
+ cause,
38
+ })));
39
+ yield* Effect.forEach(entries, (relativePath) => Effect.gen(function* () {
40
+ const entry = path.join(sourceRoot, relativePath);
41
+ const link = yield* fs.readLink(entry).pipe(Effect.option);
42
+ if (Option.isNone(link))
43
+ return;
44
+ const realTarget = yield* fs.realPath(entry).pipe(Effect.mapError((cause) => new ForkPackageInvalid({
45
+ detail: `Fork source contains an unresolved symlink: ${entry}`,
46
+ cause,
47
+ })));
48
+ const contained = realTarget === realRoot || realTarget.startsWith(`${realRoot}${path.sep}`);
49
+ if (!contained) {
50
+ return yield* new ForkPackageInvalid({
51
+ detail: `Fork source symlink escapes the package root: ${entry}`,
52
+ });
53
+ }
54
+ }), { concurrency: 16, discard: true });
55
+ });
56
+ const rewriteFrontmatterName = (filePath, targetName) => Effect.gen(function* () {
57
+ const fs = yield* FileSystem.FileSystem;
58
+ const content = yield* fs.readFileString(filePath).pipe(Effect.mapError((cause) => new ForkPackageInvalid({
59
+ detail: `Extension content could not be read: ${filePath}`,
60
+ cause,
61
+ })));
62
+ const parsed = yield* parseFrontmatterEffect(content);
63
+ if (!isRecord(parsed.frontmatter)) {
64
+ return yield* new ForkPackageInvalid({
65
+ detail: `Extension content must have YAML frontmatter: ${filePath}`,
66
+ });
67
+ }
68
+ const frontmatter = { ...parsed.frontmatter, name: targetName };
69
+ const yaml = YAML.stringify(frontmatter, { lineWidth: 0 }).trim();
70
+ const body = parsed.body.startsWith("\n") ? parsed.body : `\n${parsed.body}`;
71
+ yield* fs.writeFileString(filePath, `---\n${yaml}\n---${body}`).pipe(Effect.mapError((cause) => new ForkPackageFailed({
72
+ detail: `Extension frontmatter could not be rewritten: ${filePath}`,
73
+ cause,
74
+ })));
75
+ });
76
+ const rewriteTypeSpecificIdentity = (targetDir, source, target) => Effect.gen(function* () {
77
+ const fs = yield* FileSystem.FileSystem;
78
+ const path = yield* Path.Path;
79
+ switch (target.type) {
80
+ case "skill":
81
+ yield* rewriteFrontmatterName(path.join(targetDir, "src", "SKILL.md"), target.name).pipe(Effect.provideService(FileSystem.FileSystem, fs));
82
+ return;
83
+ case "subagent": {
84
+ const sourcePath = path.join(targetDir, "src", `${source.name}.md`);
85
+ const targetPath = path.join(targetDir, "src", `${target.name}.md`);
86
+ yield* rewriteFrontmatterName(sourcePath, target.name).pipe(Effect.provideService(FileSystem.FileSystem, fs));
87
+ if (sourcePath !== targetPath) {
88
+ yield* fs.rename(sourcePath, targetPath).pipe(Effect.mapError((cause) => new ForkPackageFailed({
89
+ detail: `Subagent content could not be renamed to ${target.name}.md`,
90
+ cause,
91
+ })));
92
+ }
93
+ return;
94
+ }
95
+ case "mcp-server":
96
+ case "rule":
97
+ case "hook":
98
+ case "knowledge":
99
+ case "pack":
100
+ return;
101
+ }
102
+ });
103
+ export const forkExtensionPackage = (args) => Effect.gen(function* () {
104
+ const fs = yield* FileSystem.FileSystem;
105
+ const path = yield* Path.Path;
106
+ if (args.sourceIdentity.type !== args.target.type) {
107
+ return yield* new ForkPackageInvalid({
108
+ detail: `Cannot fork ${args.sourceIdentity.type} as ${args.target.type}; source and target types must match`,
109
+ });
110
+ }
111
+ const targetExists = yield* fs.exists(args.targetDir).pipe(Effect.mapError((cause) => new ForkPackageFailed({
112
+ detail: `Fork target could not be inspected: ${args.targetDir}`,
113
+ cause,
114
+ })));
115
+ if (targetExists) {
116
+ return yield* new ForkPackageConflict({
117
+ detail: `Fork target already exists: ${args.targetDir}`,
118
+ });
119
+ }
120
+ const sourceManifestPath = path.join(args.sourceDir, manifestFilenameForType(args.sourceIdentity.type));
121
+ const raw = yield* readJson(sourceManifestPath).pipe(Effect.provideService(FileSystem.FileSystem, fs));
122
+ const identity = yield* Schema.decodeUnknownEffect(ManifestIdentitySchema)(raw).pipe(Effect.mapError((cause) => new ForkPackageInvalid({
123
+ detail: `Fork source manifest identity is invalid: ${sourceManifestPath}`,
124
+ cause,
125
+ })));
126
+ yield* validateSourceIdentity(identity, args.sourceIdentity);
127
+ if (!isRecord(raw)) {
128
+ return yield* new ForkPackageInvalid({
129
+ detail: `Fork source manifest must contain a JSON object: ${sourceManifestPath}`,
130
+ });
131
+ }
132
+ yield* validateContainedSymlinks(args.sourceDir).pipe(Effect.provideService(FileSystem.FileSystem, fs), Effect.provideService(Path.Path, path));
133
+ yield* copyExtensionDirectory(args.sourceDir, args.targetDir).pipe(Effect.mapError((cause) => new ForkPackageFailed({
134
+ detail: `Failed to copy AXM package from ${args.sourceDir} to ${args.targetDir}`,
135
+ cause,
136
+ })), Effect.provideService(FileSystem.FileSystem, fs), Effect.provideService(Path.Path, path));
137
+ const targetManifestPath = path.join(args.targetDir, manifestFilenameForType(args.target.type));
138
+ const rewritten = {
139
+ ...raw,
140
+ owner: args.target.owner,
141
+ type: args.target.type,
142
+ name: args.target.name,
143
+ version: INITIAL_FORK_VERSION,
144
+ };
145
+ yield* fs.writeFileString(targetManifestPath, `${JSON.stringify(rewritten, null, 2)}\n`).pipe(Effect.mapError((cause) => new ForkPackageFailed({
146
+ detail: `Fork target manifest could not be written: ${targetManifestPath}`,
147
+ cause,
148
+ })));
149
+ yield* rewriteTypeSpecificIdentity(args.targetDir, args.sourceIdentity, args.target).pipe(Effect.provideService(FileSystem.FileSystem, fs), Effect.provideService(Path.Path, path));
150
+ yield* Schema.decodeUnknownEffect(manifestSchemaForType(args.target.type))(rewritten).pipe(Effect.mapError((cause) => new ForkPackageInvalid({
151
+ detail: `Fork target manifest is invalid: ${targetManifestPath}`,
152
+ cause,
153
+ })));
154
+ });
155
+ //# sourceMappingURL=fork-package.js.map
@@ -0,0 +1,46 @@
1
+ /**
2
+ * New hook operation — scaffolds a new hook directory with the manifest and a
3
+ * starter entrypoint.
4
+ *
5
+ * @experimental This API is unstable and may change without notice.
6
+ */
7
+ import * as FileSystem from "effect/FileSystem";
8
+ import * as Path from "effect/Path";
9
+ import { AuthoringFailureAdapter } from "../failure-adapter.js";
10
+ import type { Handle } from "@agentxm/extension-model/unstable/extensions/handle";
11
+ import type { OperationHandler } from "@agentxm/workspace-operations";
12
+ import type { Operation } from "@agentxm/workspace-operations";
13
+ import { WorkspaceMutations } from "@agentxm/workspace-state";
14
+ import { type HookEvent, type HookRuntime } from "@agentxm/extension-model/unstable/hooks/manifest-schema";
15
+ /**
16
+ * Args for the new-hook operation.
17
+ */
18
+ export interface NewHookOperationArgs {
19
+ /** Hook name (validated, lowercase with hyphens). */
20
+ readonly name: string;
21
+ /** Owner (e.g., "@myorg"). */
22
+ readonly owner: Handle;
23
+ /** Interpreter family for the entrypoint. */
24
+ readonly runtime: HookRuntime;
25
+ /** Canonical hook event the scaffold binds to. */
26
+ readonly event: HookEvent;
27
+ /** Optional raw matcher (only meaningful for tool.pre/tool.post). */
28
+ readonly matcher: string | undefined;
29
+ }
30
+ /**
31
+ * Scaffold a new hook in the workspace.
32
+ *
33
+ * @experimental This API is unstable and may change without notice.
34
+ */
35
+ export type NewHookOperation = Operation<"new-hook", NewHookOperationArgs>;
36
+ /**
37
+ * New-hook operation handler.
38
+ *
39
+ * 1. Compute managed extension directory path
40
+ * 2. Check if the hook already exists (directory or settings entry)
41
+ * 3. Create the managed extension + src directories
42
+ * 4. Write hook.json manifest
43
+ * 5. Write starter entrypoint in src/
44
+ */
45
+ export declare const newHook: OperationHandler<NewHookOperation, FileSystem.FileSystem | Path.Path | WorkspaceMutations | AuthoringFailureAdapter>;
46
+ //# sourceMappingURL=new-hook.d.ts.map