@senior-skills/core 1.0.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.
Files changed (177) hide show
  1. package/dist/application/agent-selection.d.ts +42 -0
  2. package/dist/application/agent-selection.d.ts.map +1 -0
  3. package/dist/application/agent-selection.js +143 -0
  4. package/dist/application/agent-selection.js.map +1 -0
  5. package/dist/application/apply-skill-updates.d.ts +10 -0
  6. package/dist/application/apply-skill-updates.d.ts.map +1 -0
  7. package/dist/application/apply-skill-updates.js +75 -0
  8. package/dist/application/apply-skill-updates.js.map +1 -0
  9. package/dist/application/check-updates.d.ts +40 -0
  10. package/dist/application/check-updates.d.ts.map +1 -0
  11. package/dist/application/check-updates.js +130 -0
  12. package/dist/application/check-updates.js.map +1 -0
  13. package/dist/application/context.d.ts +28 -0
  14. package/dist/application/context.d.ts.map +1 -0
  15. package/dist/application/context.js +2 -0
  16. package/dist/application/context.js.map +1 -0
  17. package/dist/application/create-skill.d.ts +33 -0
  18. package/dist/application/create-skill.d.ts.map +1 -0
  19. package/dist/application/create-skill.js +58 -0
  20. package/dist/application/create-skill.js.map +1 -0
  21. package/dist/application/diagnose.d.ts +44 -0
  22. package/dist/application/diagnose.d.ts.map +1 -0
  23. package/dist/application/diagnose.js +228 -0
  24. package/dist/application/diagnose.js.map +1 -0
  25. package/dist/application/install-skills.d.ts +59 -0
  26. package/dist/application/install-skills.d.ts.map +1 -0
  27. package/dist/application/install-skills.js +191 -0
  28. package/dist/application/install-skills.js.map +1 -0
  29. package/dist/application/list-installed.d.ts +39 -0
  30. package/dist/application/list-installed.d.ts.map +1 -0
  31. package/dist/application/list-installed.js +68 -0
  32. package/dist/application/list-installed.js.map +1 -0
  33. package/dist/application/package-loader.d.ts +42 -0
  34. package/dist/application/package-loader.d.ts.map +1 -0
  35. package/dist/application/package-loader.js +320 -0
  36. package/dist/application/package-loader.js.map +1 -0
  37. package/dist/application/publish-skill.d.ts +41 -0
  38. package/dist/application/publish-skill.d.ts.map +1 -0
  39. package/dist/application/publish-skill.js +112 -0
  40. package/dist/application/publish-skill.js.map +1 -0
  41. package/dist/application/remove-skills.d.ts +34 -0
  42. package/dist/application/remove-skills.d.ts.map +1 -0
  43. package/dist/application/remove-skills.js +95 -0
  44. package/dist/application/remove-skills.js.map +1 -0
  45. package/dist/application/resolution-source.d.ts +25 -0
  46. package/dist/application/resolution-source.d.ts.map +1 -0
  47. package/dist/application/resolution-source.js +60 -0
  48. package/dist/application/resolution-source.js.map +1 -0
  49. package/dist/application/resolve-suggestions.d.ts +17 -0
  50. package/dist/application/resolve-suggestions.d.ts.map +1 -0
  51. package/dist/application/resolve-suggestions.js +77 -0
  52. package/dist/application/resolve-suggestions.js.map +1 -0
  53. package/dist/application/search-skills.d.ts +36 -0
  54. package/dist/application/search-skills.d.ts.map +1 -0
  55. package/dist/application/search-skills.js +78 -0
  56. package/dist/application/search-skills.js.map +1 -0
  57. package/dist/application/update-skills.d.ts +55 -0
  58. package/dist/application/update-skills.d.ts.map +1 -0
  59. package/dist/application/update-skills.js +115 -0
  60. package/dist/application/update-skills.js.map +1 -0
  61. package/dist/application/validate-package.d.ts +27 -0
  62. package/dist/application/validate-package.d.ts.map +1 -0
  63. package/dist/application/validate-package.js +165 -0
  64. package/dist/application/validate-package.js.map +1 -0
  65. package/dist/application/workspace.d.ts +22 -0
  66. package/dist/application/workspace.d.ts.map +1 -0
  67. package/dist/application/workspace.js +66 -0
  68. package/dist/application/workspace.js.map +1 -0
  69. package/dist/domain/agent.d.ts +89 -0
  70. package/dist/domain/agent.d.ts.map +1 -0
  71. package/dist/domain/agent.js +20 -0
  72. package/dist/domain/agent.js.map +1 -0
  73. package/dist/domain/errors.d.ts +91 -0
  74. package/dist/domain/errors.d.ts.map +1 -0
  75. package/dist/domain/errors.js +121 -0
  76. package/dist/domain/errors.js.map +1 -0
  77. package/dist/domain/integrity.d.ts +19 -0
  78. package/dist/domain/integrity.d.ts.map +1 -0
  79. package/dist/domain/integrity.js +0 -0
  80. package/dist/domain/integrity.js.map +1 -0
  81. package/dist/domain/js-literal.d.ts +22 -0
  82. package/dist/domain/js-literal.d.ts.map +1 -0
  83. package/dist/domain/js-literal.js +221 -0
  84. package/dist/domain/js-literal.js.map +1 -0
  85. package/dist/domain/lockfile.d.ts +36 -0
  86. package/dist/domain/lockfile.d.ts.map +1 -0
  87. package/dist/domain/lockfile.js +148 -0
  88. package/dist/domain/lockfile.js.map +1 -0
  89. package/dist/domain/manifest.d.ts +96 -0
  90. package/dist/domain/manifest.d.ts.map +1 -0
  91. package/dist/domain/manifest.js +448 -0
  92. package/dist/domain/manifest.js.map +1 -0
  93. package/dist/domain/path-safety.d.ts +19 -0
  94. package/dist/domain/path-safety.d.ts.map +1 -0
  95. package/dist/domain/path-safety.js +125 -0
  96. package/dist/domain/path-safety.js.map +1 -0
  97. package/dist/domain/posix-path.d.ts +28 -0
  98. package/dist/domain/posix-path.d.ts.map +1 -0
  99. package/dist/domain/posix-path.js +84 -0
  100. package/dist/domain/posix-path.js.map +1 -0
  101. package/dist/domain/receipt.d.ts +41 -0
  102. package/dist/domain/receipt.d.ts.map +1 -0
  103. package/dist/domain/receipt.js +93 -0
  104. package/dist/domain/receipt.js.map +1 -0
  105. package/dist/domain/registry-index.d.ts +41 -0
  106. package/dist/domain/registry-index.d.ts.map +1 -0
  107. package/dist/domain/registry-index.js +150 -0
  108. package/dist/domain/registry-index.js.map +1 -0
  109. package/dist/domain/resolver.d.ts +54 -0
  110. package/dist/domain/resolver.d.ts.map +1 -0
  111. package/dist/domain/resolver.js +238 -0
  112. package/dist/domain/resolver.js.map +1 -0
  113. package/dist/domain/skill-document.d.ts +16 -0
  114. package/dist/domain/skill-document.d.ts.map +1 -0
  115. package/dist/domain/skill-document.js +60 -0
  116. package/dist/domain/skill-document.js.map +1 -0
  117. package/dist/domain/skill-package.d.ts +43 -0
  118. package/dist/domain/skill-package.d.ts.map +1 -0
  119. package/dist/domain/skill-package.js +63 -0
  120. package/dist/domain/skill-package.js.map +1 -0
  121. package/dist/domain/skill-ref.d.ts +30 -0
  122. package/dist/domain/skill-ref.d.ts.map +1 -0
  123. package/dist/domain/skill-ref.js +119 -0
  124. package/dist/domain/skill-ref.js.map +1 -0
  125. package/dist/domain/validation.d.ts +30 -0
  126. package/dist/domain/validation.d.ts.map +1 -0
  127. package/dist/domain/validation.js +32 -0
  128. package/dist/domain/validation.js.map +1 -0
  129. package/dist/domain/version.d.ts +23 -0
  130. package/dist/domain/version.d.ts.map +1 -0
  131. package/dist/domain/version.js +81 -0
  132. package/dist/domain/version.js.map +1 -0
  133. package/dist/domain/workflow-document.d.ts +23 -0
  134. package/dist/domain/workflow-document.d.ts.map +1 -0
  135. package/dist/domain/workflow-document.js +56 -0
  136. package/dist/domain/workflow-document.js.map +1 -0
  137. package/dist/index.d.ts +47 -0
  138. package/dist/index.d.ts.map +1 -0
  139. package/dist/index.js +45 -0
  140. package/dist/index.js.map +1 -0
  141. package/dist/ports/agent-adapter.d.ts +65 -0
  142. package/dist/ports/agent-adapter.d.ts.map +1 -0
  143. package/dist/ports/agent-adapter.js +28 -0
  144. package/dist/ports/agent-adapter.js.map +1 -0
  145. package/dist/ports/config-store.d.ts +27 -0
  146. package/dist/ports/config-store.d.ts.map +1 -0
  147. package/dist/ports/config-store.js +2 -0
  148. package/dist/ports/config-store.js.map +1 -0
  149. package/dist/ports/infrastructure.d.ts +123 -0
  150. package/dist/ports/infrastructure.d.ts.map +1 -0
  151. package/dist/ports/infrastructure.js +9 -0
  152. package/dist/ports/infrastructure.js.map +1 -0
  153. package/dist/ports/installation.d.ts +86 -0
  154. package/dist/ports/installation.d.ts.map +1 -0
  155. package/dist/ports/installation.js +2 -0
  156. package/dist/ports/installation.js.map +1 -0
  157. package/dist/ports/skill-registry.d.ts +74 -0
  158. package/dist/ports/skill-registry.d.ts.map +1 -0
  159. package/dist/ports/skill-registry.js +2 -0
  160. package/dist/ports/skill-registry.js.map +1 -0
  161. package/dist/ports/updates.d.ts +31 -0
  162. package/dist/ports/updates.d.ts.map +1 -0
  163. package/dist/ports/updates.js +4 -0
  164. package/dist/ports/updates.js.map +1 -0
  165. package/dist/testing/doubles.d.ts +127 -0
  166. package/dist/testing/doubles.d.ts.map +1 -0
  167. package/dist/testing/doubles.js +299 -0
  168. package/dist/testing/doubles.js.map +1 -0
  169. package/dist/testing/in-memory-file-system.d.ts +61 -0
  170. package/dist/testing/in-memory-file-system.d.ts.map +1 -0
  171. package/dist/testing/in-memory-file-system.js +297 -0
  172. package/dist/testing/in-memory-file-system.js.map +1 -0
  173. package/dist/testing/index.d.ts +10 -0
  174. package/dist/testing/index.d.ts.map +1 -0
  175. package/dist/testing/index.js +10 -0
  176. package/dist/testing/index.js.map +1 -0
  177. package/package.json +37 -0
@@ -0,0 +1,42 @@
1
+ import type { AgentDetection, AgentTarget, InstallScope, LocationContext } from '../domain/agent.ts';
2
+ import { type PackageKind } from '../domain/manifest.ts';
3
+ import type { AgentAdapter, DetectionContext } from '../ports/agent-adapter.ts';
4
+ import type { ApplicationContext } from './context.ts';
5
+ export declare const ALL_AGENTS = "all";
6
+ export interface AgentSelectionOptions {
7
+ /** Values from `--agent`. Empty means "auto-detect". `all` selects every known adapter. */
8
+ readonly agents?: readonly string[];
9
+ readonly scope: InstallScope;
10
+ /** Explicit `--project-root`, else discovered. */
11
+ readonly projectRoot?: string;
12
+ /** Start directory for project discovery. Defaults to the process cwd. */
13
+ readonly startDir?: string;
14
+ }
15
+ export interface AgentSelection {
16
+ /** Every root the selected agents expose, one per agent and package kind. */
17
+ readonly targets: readonly AgentTarget[];
18
+ readonly adapters: readonly AgentAdapter[];
19
+ readonly detections: readonly AgentDetection[];
20
+ readonly scope: InstallScope;
21
+ readonly projectRoot?: string;
22
+ }
23
+ /** Runs detection for every registered adapter, regardless of selection. Used by `doctor`. */
24
+ export declare function detectionContext(ctx: ApplicationContext): DetectionContext;
25
+ export declare function detectAgents(ctx: ApplicationContext): Promise<readonly AgentDetection[]>;
26
+ /**
27
+ * Turns `--agent` / `--global` / `--project` into concrete directories.
28
+ *
29
+ * Auto-detection deliberately requires *strong* evidence. A stray `.claude/` directory in a
30
+ * repository is weak evidence: it is reported, but it never silently redirects an install to
31
+ * an agent the user does not actually run.
32
+ */
33
+ export declare function selectAgents(ctx: ApplicationContext, options: AgentSelectionOptions): Promise<AgentSelection>;
34
+ /**
35
+ * Every root one agent exposes in a scope: one per package kind it supports.
36
+ *
37
+ * `list`, `uninstall` and `doctor` want all of them — a name the user gives could be a
38
+ * skill or a command. `install` narrows to the kind of the package it is about to write.
39
+ */
40
+ export declare function targetsFor(ctx: ApplicationContext, adapter: AgentAdapter, scope: InstallScope, projectRoot: string | undefined): readonly AgentTarget[];
41
+ export declare function locationContext(ctx: ApplicationContext, adapter: AgentAdapter, scope: InstallScope, projectRoot: string | undefined, kind?: PackageKind): LocationContext;
42
+ //# sourceMappingURL=agent-selection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent-selection.d.ts","sourceRoot":"","sources":["../../src/application/agent-selection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,WAAW,EACX,YAAY,EACZ,eAAe,EAChB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAuC,KAAK,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAE9F,OAAO,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAChF,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAGvD,eAAO,MAAM,UAAU,QAAQ,CAAC;AAEhC,MAAM,WAAW,qBAAqB;IACpC,2FAA2F;IAC3F,QAAQ,CAAC,MAAM,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACpC,QAAQ,CAAC,KAAK,EAAE,YAAY,CAAC;IAC7B,kDAAkD;IAClD,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,0EAA0E;IAC1E,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED,MAAM,WAAW,cAAc;IAC7B,6EAA6E;IAC7E,QAAQ,CAAC,OAAO,EAAE,SAAS,WAAW,EAAE,CAAC;IACzC,QAAQ,CAAC,QAAQ,EAAE,SAAS,YAAY,EAAE,CAAC;IAC3C,QAAQ,CAAC,UAAU,EAAE,SAAS,cAAc,EAAE,CAAC;IAC/C,QAAQ,CAAC,KAAK,EAAE,YAAY,CAAC;IAC7B,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;CAC/B;AAED,8FAA8F;AAC9F,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,kBAAkB,GAAG,gBAAgB,CAE1E;AAED,wBAAsB,YAAY,CAAC,GAAG,EAAE,kBAAkB,GAAG,OAAO,CAAC,SAAS,cAAc,EAAE,CAAC,CAG9F;AAED;;;;;;GAMG;AACH,wBAAsB,YAAY,CAChC,GAAG,EAAE,kBAAkB,EACvB,OAAO,EAAE,qBAAqB,GAC7B,OAAO,CAAC,cAAc,CAAC,CA6BzB;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CACxB,GAAG,EAAE,kBAAkB,EACvB,OAAO,EAAE,YAAY,EACrB,KAAK,EAAE,YAAY,EACnB,WAAW,EAAE,MAAM,GAAG,SAAS,GAC9B,SAAS,WAAW,EAAE,CAoBxB;AAED,wBAAgB,eAAe,CAC7B,GAAG,EAAE,kBAAkB,EACvB,OAAO,EAAE,YAAY,EACrB,KAAK,EAAE,YAAY,EACnB,WAAW,EAAE,MAAM,GAAG,SAAS,EAC/B,IAAI,GAAE,WAAkC,GACvC,eAAe,CAiBjB"}
@@ -0,0 +1,143 @@
1
+ import { DEFAULT_PACKAGE_KIND, PACKAGE_KINDS } from "../domain/manifest.js";
2
+ import { AgentSkillsError, ErrorCode } from "../domain/errors.js";
3
+ import { findProjectRoot, requireProjectRoot } from "./workspace.js";
4
+ export const ALL_AGENTS = 'all';
5
+ /** Runs detection for every registered adapter, regardless of selection. Used by `doctor`. */
6
+ export function detectionContext(ctx) {
7
+ return { env: ctx.env, fs: ctx.fs, commands: ctx.commands };
8
+ }
9
+ export async function detectAgents(ctx) {
10
+ const detection = detectionContext(ctx);
11
+ return Promise.all(ctx.agents.all().map((adapter) => adapter.detect(detection)));
12
+ }
13
+ /**
14
+ * Turns `--agent` / `--global` / `--project` into concrete directories.
15
+ *
16
+ * Auto-detection deliberately requires *strong* evidence. A stray `.claude/` directory in a
17
+ * repository is weak evidence: it is reported, but it never silently redirects an install to
18
+ * an agent the user does not actually run.
19
+ */
20
+ export async function selectAgents(ctx, options) {
21
+ const requested = (options.agents ?? []).filter((value) => value.trim() !== '');
22
+ const detections = await detectAgents(ctx);
23
+ const adapters = requested.length === 0
24
+ ? autoSelect(ctx, detections)
25
+ : requested.includes(ALL_AGENTS)
26
+ ? enabledAdapters(ctx)
27
+ : resolveExplicit(ctx, requested);
28
+ const projectRoot = options.scope === 'project'
29
+ ? (options.projectRoot ??
30
+ (await requireProjectRoot(ctx.fs, options.startDir ?? ctx.env.cwd(), ctx.env.homeDir())))
31
+ : (options.projectRoot ??
32
+ (await findProjectRoot(ctx.fs, options.startDir ?? ctx.env.cwd(), ctx.env.homeDir())));
33
+ const targets = adapters.flatMap((adapter) => targetsFor(ctx, adapter, options.scope, projectRoot));
34
+ return {
35
+ targets,
36
+ adapters,
37
+ detections,
38
+ scope: options.scope,
39
+ ...(projectRoot === undefined ? {} : { projectRoot }),
40
+ };
41
+ }
42
+ /**
43
+ * Every root one agent exposes in a scope: one per package kind it supports.
44
+ *
45
+ * `list`, `uninstall` and `doctor` want all of them — a name the user gives could be a
46
+ * skill or a command. `install` narrows to the kind of the package it is about to write.
47
+ */
48
+ export function targetsFor(ctx, adapter, scope, projectRoot) {
49
+ const targets = [];
50
+ for (const kind of PACKAGE_KINDS) {
51
+ const location = adapter.locationFor(kind, scope, locationContext(ctx, adapter, scope, projectRoot, kind));
52
+ if (location === undefined)
53
+ continue;
54
+ targets.push({
55
+ agentId: adapter.id,
56
+ displayName: adapter.displayName,
57
+ scope,
58
+ kind,
59
+ ...location,
60
+ });
61
+ }
62
+ return targets;
63
+ }
64
+ export function locationContext(ctx, adapter, scope, projectRoot, kind = DEFAULT_PACKAGE_KIND) {
65
+ const agentConfig = ctx.config.agents[adapter.id];
66
+ // `globalRoot`/`projectRoot` name the *skills* root; other kinds keep the agent's own
67
+ // convention rather than being redirected into a directory meant for skills.
68
+ const overrideRoot = kind !== 'skill'
69
+ ? undefined
70
+ : scope === 'global'
71
+ ? agentConfig?.globalRoot
72
+ : agentConfig?.projectRoot;
73
+ return {
74
+ homeDir: ctx.env.homeDir(),
75
+ env: ctx.env.env(),
76
+ ...(projectRoot === undefined ? {} : { projectRoot }),
77
+ ...(overrideRoot === undefined ? {} : { overrideRoot }),
78
+ };
79
+ }
80
+ function enabledAdapters(ctx) {
81
+ const enabled = ctx.agents
82
+ .all()
83
+ .filter((adapter) => ctx.config.agents[adapter.id]?.enabled !== false);
84
+ if (enabled.length > 0)
85
+ return enabled;
86
+ throw new AgentSkillsError(ErrorCode.NO_AGENT_DETECTED, 'Every known agent is disabled in config', {
87
+ hints: ['Enable one in ~/.senior-skills/config.json under "agents"'],
88
+ });
89
+ }
90
+ function autoSelect(ctx, detections) {
91
+ const installed = detections.filter((detection) => detection.installed);
92
+ const adapters = installed
93
+ .map((detection) => ctx.agents.find(detection.agentId))
94
+ .filter((adapter) => adapter !== undefined)
95
+ .filter((adapter) => ctx.config.agents[adapter.id]?.enabled !== false);
96
+ if (adapters.length > 0)
97
+ return adapters;
98
+ const weak = detections.filter((detection) => detection.strength === 'weak');
99
+ throw new AgentSkillsError(ErrorCode.NO_AGENT_DETECTED, 'No supported coding agents detected', {
100
+ details: [
101
+ '',
102
+ 'Supported agents:',
103
+ ...ctx.agents
104
+ .all()
105
+ .map((adapter) => ` - ${adapter.displayName} (--agent ${adapter.aliases[0] ?? adapter.id})`),
106
+ ...(weak.length === 0
107
+ ? []
108
+ : [
109
+ '',
110
+ 'Found weak evidence for:',
111
+ ...weak.map((detection) => ` - ${detection.agentId}: ${detection.evidence.map((item) => item.detail).join(', ')}`),
112
+ ]),
113
+ ],
114
+ hints: [
115
+ 'Use --agent to select one explicitly, e.g. --agent claude',
116
+ 'senior-skills doctor to see what detection found',
117
+ ],
118
+ data: { detections },
119
+ });
120
+ }
121
+ function resolveExplicit(ctx, requested) {
122
+ const resolved = [];
123
+ for (const value of requested) {
124
+ const adapter = ctx.agents.find(value);
125
+ if (adapter === undefined) {
126
+ throw new AgentSkillsError(ErrorCode.UNKNOWN_AGENT, `Unknown agent "${value}"`, {
127
+ details: [
128
+ '',
129
+ 'Known agents:',
130
+ ...ctx.agents
131
+ .all()
132
+ .map((known) => ` ${known.id}${known.aliases.length > 0 ? ` (${known.aliases.join(', ')})` : ''}`),
133
+ ` ${ALL_AGENTS} — every known agent`,
134
+ ],
135
+ data: { requested: value, known: ctx.agents.ids() },
136
+ });
137
+ }
138
+ if (!resolved.some((existing) => existing.id === adapter.id))
139
+ resolved.push(adapter);
140
+ }
141
+ return resolved;
142
+ }
143
+ //# sourceMappingURL=agent-selection.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent-selection.js","sourceRoot":"","sources":["../../src/application/agent-selection.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,oBAAoB,EAAE,aAAa,EAAoB,MAAM,uBAAuB,CAAC;AAC9F,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAGlE,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAErE,MAAM,CAAC,MAAM,UAAU,GAAG,KAAK,CAAC;AAqBhC,8FAA8F;AAC9F,MAAM,UAAU,gBAAgB,CAAC,GAAuB;IACtD,OAAO,EAAE,GAAG,EAAE,GAAG,CAAC,GAAG,EAAE,EAAE,EAAE,GAAG,CAAC,EAAE,EAAE,QAAQ,EAAE,GAAG,CAAC,QAAQ,EAAE,CAAC;AAC9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{ type InstallReport } from './install-skills.ts';
4
+ /** Apply exactly the releases and destinations reviewed in the notification. */
5
+ export declare class ApplySkillUpdates {
6
+ private readonly ctx;
7
+ constructor(ctx: ApplicationContext);
8
+ execute(notices: readonly SkillUpdateNotice[]): Promise<readonly InstallReport[]>;
9
+ }
10
+ //# sourceMappingURL=apply-skill-updates.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"apply-skill-updates.d.ts","sourceRoot":"","sources":["../../src/application/apply-skill-updates.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AACvD,OAAO,EAAsC,KAAK,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAE7F,gFAAgF;AAChF,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAqB;gBAE7B,GAAG,EAAE,kBAAkB;IAI7B,OAAO,CAAC,OAAO,EAAE,SAAS,iBAAiB,EAAE,GAAG,OAAO,CAAC,SAAS,aAAa,EAAE,CAAC;CA8ExF"}
@@ -0,0 +1,75 @@
1
+ import { AgentSkillsError, ErrorCode } from "../domain/errors.js";
2
+ import { compareVersions, satisfies } from "../domain/version.js";
3
+ import { InstallSkills } from "./install-skills.js";
4
+ /** Apply exactly the releases and destinations reviewed in the notification. */
5
+ export class ApplySkillUpdates {
6
+ ctx;
7
+ constructor(ctx) {
8
+ this.ctx = ctx;
9
+ }
10
+ async execute(notices) {
11
+ for (const notice of notices) {
12
+ const current = await this.ctx.installer.read(notice.target, notice.name);
13
+ if (current === undefined ||
14
+ current.unmanaged ||
15
+ current.version !== notice.current ||
16
+ current.registry !== notice.registry) {
17
+ throw new AgentSkillsError(ErrorCode.USAGE, `Installation changed since checking ${notice.name}`, {
18
+ hints: ['Run senior-skills list and check for updates again'],
19
+ });
20
+ }
21
+ }
22
+ // Group only identical releases/destinations. Never install a listed skill into an agent
23
+ // that did not have it, or merge two registries that happen to publish the same name.
24
+ const groups = new Map();
25
+ for (const notice of notices) {
26
+ const key = JSON.stringify([
27
+ notice.name,
28
+ notice.version,
29
+ notice.registry,
30
+ notice.target.scope,
31
+ notice.projectRoot,
32
+ ]);
33
+ groups.set(key, [...(groups.get(key) ?? []), notice]);
34
+ }
35
+ const plans = [];
36
+ for (const group of groups.values()) {
37
+ const first = group[0];
38
+ plans.push({
39
+ refs: [`${first.name}@${first.version}`],
40
+ registry: first.registry,
41
+ agents: group.map((item) => item.target.agentId),
42
+ scope: first.target.scope,
43
+ projectRoot: first.projectRoot,
44
+ force: false,
45
+ });
46
+ }
47
+ // Preview all groups before the first write. A compatible direct update must not sneak
48
+ // in a breaking upgrade (or downgrade) of an already installed dependency.
49
+ for (const plan of plans) {
50
+ const preview = await new InstallSkills(this.ctx).execute({ ...plan, dryRun: true });
51
+ for (const result of preview.results) {
52
+ const from = result.previousVersion;
53
+ if (from === undefined || compareVersions(from, result.version) === 0)
54
+ continue;
55
+ const approved = notices.some((item) => item.name === result.name &&
56
+ item.version === result.version &&
57
+ item.target.agentId === result.agentId &&
58
+ item.target.scope === result.scope);
59
+ if (compareVersions(from, result.version) > 0 ||
60
+ (!satisfies(result.version, `^${from}`) && !approved)) {
61
+ throw new AgentSkillsError(ErrorCode.USAGE, `Dependency ${result.name} would change from ${from} to ${result.version}`, {
62
+ hints: [
63
+ 'Review the full plan with senior-skills update --major --dry-run before updating',
64
+ ],
65
+ });
66
+ }
67
+ }
68
+ }
69
+ const reports = [];
70
+ for (const plan of plans)
71
+ reports.push(await new InstallSkills(this.ctx).execute(plan));
72
+ return reports;
73
+ }
74
+ }
75
+ //# sourceMappingURL=apply-skill-updates.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"apply-skill-updates.js","sourceRoot":"","sources":["../../src/application/apply-skill-updates.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,qBAAqB,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AAM,CAAC,OAAO;oBAC/B,IAAI,CAAC,MAAM,CAAC,OAAO,KAAK,MAAM,CAAC,OAAO;oBACtC,IAAI,CAAC,MAAM,CAAC,KAAK,KAAK,MAAM,CAAC,KAAK,CACrC,CAAC;gBACF,IACE,eAAe,CAAC,IAAI,EAAE,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC;oBACzC,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,OAAO,EAAE,IAAI,IAAI,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,EACrD,CAAC;oBACD,MAAM,IAAI,gBAAgB,CACxB,SAAS,CAAC,KAAK,EACf,cAAc,MAAM,CAAC,IAAI,sBAAsB,IAAI,OAAO,MAAM,CAAC,OAAO,EAAE,EAC1E;wBACE,KAAK,EAAE;4BACL,kFAAkF;yBACnF;qBACF,CACF,CAAC;gBACJ,CAAC;YACH,CAAC;QACH,CAAC;QACD,MAAM,OAAO,GAAoB,EAAE,CAAC;QACpC,KAAK,MAAM,IAAI,IAAI,KAAK;YAAE,OAAO,CAAC,IAAI,CAAC,MAAM,IAAI,aAAa,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;QACxF,OAAO,OAAO,CAAC;IACjB,CAAC;CACF"}
@@ -0,0 +1,40 @@
1
+ import type { AgentTarget } from '../domain/agent.ts';
2
+ import { type SemanticVersion } from '../domain/version.ts';
3
+ import { type ToolUpdater, type UpdateStateStore } from '../ports/updates.ts';
4
+ import type { ApplicationContext } from './context.ts';
5
+ import { type ListOptions } from './list-installed.ts';
6
+ export declare const UPDATE_REMINDER_MS: number;
7
+ export interface UpdateNotice {
8
+ readonly id: string;
9
+ readonly current: SemanticVersion;
10
+ readonly version: SemanticVersion;
11
+ }
12
+ export interface SkillUpdateNotice extends UpdateNotice {
13
+ readonly name: string;
14
+ readonly registry: string;
15
+ readonly target: AgentTarget;
16
+ readonly projectRoot?: string;
17
+ readonly modified: boolean;
18
+ /** Also covers breaking 0.x changes, following update's ^current policy. */
19
+ readonly requiresMajor: boolean;
20
+ }
21
+ export interface UpdateNotices {
22
+ readonly tool?: UpdateNotice;
23
+ readonly skills: readonly SkillUpdateNotice[];
24
+ }
25
+ /** Metadata-only checks. A failed lookup is advisory and never substitutes another registry. */
26
+ export declare class CheckUpdates {
27
+ private readonly ctx;
28
+ private readonly tool;
29
+ private readonly store;
30
+ constructor(ctx: ApplicationContext, tool: ToolUpdater, store: UpdateStateStore);
31
+ execute(options?: ListOptions & {
32
+ skipSkills?: boolean;
33
+ registry?: string;
34
+ }): Promise<UpdateNotices>;
35
+ dismiss(notices: readonly UpdateNotice[]): Promise<void>;
36
+ remindLater(notices: readonly UpdateNotice[]): Promise<void>;
37
+ private load;
38
+ private save;
39
+ }
40
+ //# sourceMappingURL=check-updates.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"check-updates.d.ts","sourceRoot":"","sources":["../../src/application/check-updates.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAML,KAAK,eAAe,EACrB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAEL,KAAK,WAAW,EAEhB,KAAK,gBAAgB,EACtB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AACvD,OAAO,EAAiB,KAAK,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAEtE,eAAO,MAAM,kBAAkB,QAAsB,CAAC;AAEtD,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,OAAO,EAAE,eAAe,CAAC;IAClC,QAAQ,CAAC,OAAO,EAAE,eAAe,CAAC;CACnC;AAED,MAAM,WAAW,iBAAkB,SAAQ,YAAY;IACrD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;IAC7B,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAC3B,4EAA4E;IAC5E,QAAQ,CAAC,aAAa,EAAE,OAAO,CAAC;CACjC;AAED,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,IAAI,CAAC,EAAE,YAAY,CAAC;IAC7B,QAAQ,CAAC,MAAM,EAAE,SAAS,iBAAiB,EAAE,CAAC;CAC/C;AAED,gGAAgG;AAChG,qBAAa,YAAY;IACvB,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAqB;IACzC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAc;IACnC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAmB;gBAE7B,GAAG,EAAE,kBAAkB,EAAE,IAAI,EAAE,WAAW,EAAE,KAAK,EAAE,gBAAgB;IAMzE,OAAO,CACX,OAAO,GAAE,WAAW,GAAG;QAAE,UAAU,CAAC,EAAE,OAAO,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAO,GACtE,OAAO,CAAC,aAAa,CAAC;IAyGnB,OAAO,CAAC,OAAO,EAAE,SAAS,YAAY,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAQxD,WAAW,CAAC,OAAO,EAAE,SAAS,YAAY,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;YAOpD,IAAI;YAIJ,IAAI;CAKnB"}
@@ -0,0 +1,130 @@
1
+ import { compareVersions, isPrerelease, maxSatisfying, parseVersion, satisfies, } from "../domain/version.js";
2
+ import { emptyUpdateState, } from "../ports/updates.js";
3
+ import { ListInstalled } from "./list-installed.js";
4
+ export const UPDATE_REMINDER_MS = 24 * 60 * 60 * 1000;
5
+ /** Metadata-only checks. A failed lookup is advisory and never substitutes another registry. */
6
+ export class CheckUpdates {
7
+ ctx;
8
+ tool;
9
+ store;
10
+ constructor(ctx, tool, store) {
11
+ this.ctx = ctx;
12
+ this.tool = tool;
13
+ this.store = store;
14
+ }
15
+ async execute(options = {}) {
16
+ const state = await this.load();
17
+ const now = this.ctx.clock.now().getTime();
18
+ const visible = (id) => !state.dismissed.includes(id) && (state.deferred[id] ?? 0) <= now;
19
+ const lookup = async (key, ttl, fetch) => {
20
+ const cached = state.checks[key];
21
+ if (cached !== undefined && now >= cached.checkedAt && now - cached.checkedAt < ttl) {
22
+ return cached.versions;
23
+ }
24
+ try {
25
+ const versions = await fetch();
26
+ state.checks[key] = { checkedAt: now, versions };
27
+ return versions;
28
+ }
29
+ catch (error) {
30
+ this.ctx.logger.debug('Update check unavailable', error);
31
+ // Do not retry on every invocation or announce stale metadata after a failed refresh.
32
+ state.checks[key] = { checkedAt: now, versions: [] };
33
+ return [];
34
+ }
35
+ };
36
+ const current = parseVersion(this.ctx.toolVersion.slice(this.ctx.toolVersion.lastIndexOf('@') + 1));
37
+ const latest = (await lookup('tool', UPDATE_REMINDER_MS, async () => {
38
+ const version = await this.tool.latestVersion();
39
+ return version === undefined ? [] : [version];
40
+ }))[0];
41
+ const toolId = JSON.stringify(['tool', latest]);
42
+ const tool = latest !== undefined && compareVersions(latest, current) > 0 && visible(toolId)
43
+ ? { id: toolId, current, version: latest }
44
+ : undefined;
45
+ const skills = [];
46
+ if (!options.skipSkills) {
47
+ const installed = await new ListInstalled(this.ctx).execute(options);
48
+ const failedRegistries = new Set();
49
+ for (const { target, skills: entries } of installed.entries) {
50
+ if (this.ctx.config.agents[target.agentId]?.enabled === false)
51
+ continue;
52
+ for (const entry of entries) {
53
+ if (entry.unmanaged ||
54
+ (options.registry !== undefined && entry.registry !== options.registry))
55
+ continue;
56
+ const registry = this.ctx.registry.named(entry.registry);
57
+ if (registry === undefined)
58
+ continue;
59
+ const config = this.ctx.config.registries.find((item) => item.name === entry.registry);
60
+ const origin = [entry.registry, config?.url, config?.ref, config?.kind];
61
+ const key = JSON.stringify([...origin, entry.name]);
62
+ const versions = await lookup(key, Math.max(60, this.ctx.config.cache.ttlSeconds) * 1000, async () => {
63
+ if (failedRegistries.has(entry.registry))
64
+ return [];
65
+ try {
66
+ return (await registry.versions(entry.name))
67
+ .filter((item) => !item.deprecated && !isPrerelease(item.version))
68
+ .map((item) => item.version);
69
+ }
70
+ catch (error) {
71
+ failedRegistries.add(entry.registry);
72
+ throw error;
73
+ }
74
+ });
75
+ const compatible = maxSatisfying(versions, `^${entry.version}`);
76
+ const newest = maxSatisfying(versions, '*');
77
+ for (const version of new Set([compatible, newest])) {
78
+ if (version === undefined || compareVersions(version, entry.version) <= 0)
79
+ continue;
80
+ const id = JSON.stringify([
81
+ 'skill',
82
+ target.agentId,
83
+ target.root,
84
+ ...origin,
85
+ entry.name,
86
+ version,
87
+ ]);
88
+ if (!visible(id))
89
+ continue;
90
+ skills.push({
91
+ id,
92
+ name: entry.name,
93
+ current: entry.version,
94
+ version,
95
+ target,
96
+ registry: entry.registry,
97
+ projectRoot: installed.projectRoot,
98
+ modified: entry.modified,
99
+ requiresMajor: !satisfies(version, `^${entry.version}`),
100
+ });
101
+ }
102
+ }
103
+ }
104
+ }
105
+ await this.save(state);
106
+ return { tool, skills };
107
+ }
108
+ async dismiss(notices) {
109
+ const state = await this.load();
110
+ await this.save({
111
+ ...state,
112
+ dismissed: [...new Set([...state.dismissed, ...notices.map((item) => item.id)])],
113
+ });
114
+ }
115
+ async remindLater(notices) {
116
+ const state = await this.load();
117
+ for (const notice of notices)
118
+ state.deferred[notice.id] = this.ctx.clock.now().getTime() + UPDATE_REMINDER_MS;
119
+ await this.save(state);
120
+ }
121
+ async load() {
122
+ return this.store.load().catch(() => emptyUpdateState());
123
+ }
124
+ async save(state) {
125
+ await this.store
126
+ .save(state)
127
+ .catch((error) => this.ctx.logger.debug('Could not save update reminders', error));
128
+ }
129
+ }
130
+ //# sourceMappingURL=check-updates.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"check-updates.js","sourceRoot":"","sources":["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,GAAG,MAAM,IAAI,CAAC,IAAI,EAAE,CAAC;QAChC,KAAK,MAAM,MAAM,IAAI,OAAO;YAC1B,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,OAAO,EAAE,GAAG,kBAAkB,CAAC;QAClF,MAAM,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACzB,CAAC;IAEO,KAAK,CAAC,IAAI;QAChB,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,gBAAgB,EAAE,CAAC,CAAC;IAC3D,CAAC;IAEO,KAAK,CAAC,IAAI,CAAC,KAAkB;QACnC,MAAM,IAAI,CAAC,KAAK;aACb,IAAI,CAAC,KAAK,CAAC;aACX,KAAK,CAAC,CAAC,KAAc,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,iCAAiC,EAAE,KAAK,CAAC,CAAC,CAAC;IAChG,CAAC;CACF"}
@@ -0,0 +1,28 @@
1
+ import type { AgentSkillsConfig } from '../ports/config-store.ts';
2
+ import type { AgentCatalog } from '../ports/agent-adapter.ts';
3
+ import type { InstallationEngine } from '../ports/installation.ts';
4
+ import type { FederatedRegistry } from '../ports/skill-registry.ts';
5
+ import type { Clock, CommandRunner, Environment, FileSystem, Logger } from '../ports/infrastructure.ts';
6
+ /**
7
+ * Everything the application services need, assembled once by the CLI's composition root.
8
+ *
9
+ * A context object rather than per-service constructor arguments: eight services each taking
10
+ * the same seven collaborators is noise, and the bundle makes it obvious that no service
11
+ * reaches for anything outside this set.
12
+ */
13
+ export interface ApplicationContext {
14
+ readonly agents: AgentCatalog;
15
+ /** Usually a `RegistryFederation` over the configured registries. */
16
+ readonly registry: FederatedRegistry;
17
+ readonly installer: InstallationEngine;
18
+ readonly fs: FileSystem;
19
+ readonly env: Environment;
20
+ /** Used for agent detection probes and by the git registry. */
21
+ readonly commands: CommandRunner;
22
+ readonly clock: Clock;
23
+ readonly logger: Logger;
24
+ readonly config: AgentSkillsConfig;
25
+ /** Version string recorded in lockfiles and receipts, e.g. `@senior-skills/cli@1.0.0`. */
26
+ readonly toolVersion: string;
27
+ }
28
+ //# sourceMappingURL=context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/application/context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AACnE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AACpE,OAAO,KAAK,EACV,KAAK,EACL,aAAa,EACb,WAAW,EACX,UAAU,EACV,MAAM,EACP,MAAM,4BAA4B,CAAC;AAEpC;;;;;;GAMG;AACH,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAC9B,qEAAqE;IACrE,QAAQ,CAAC,QAAQ,EAAE,iBAAiB,CAAC;IACrC,QAAQ,CAAC,SAAS,EAAE,kBAAkB,CAAC;IACvC,QAAQ,CAAC,EAAE,EAAE,UAAU,CAAC;IACxB,QAAQ,CAAC,GAAG,EAAE,WAAW,CAAC;IAC1B,+DAA+D;IAC/D,QAAQ,CAAC,QAAQ,EAAE,aAAa,CAAC;IACjC,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,MAAM,EAAE,iBAAiB,CAAC;IACnC,0FAA0F;IAC1F,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;CAC9B"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/application/context.ts"],"names":[],"mappings":""}
@@ -0,0 +1,33 @@
1
+ import { type PackageKind } from '../domain/manifest.ts';
2
+ import type { ApplicationContext } from './context.ts';
3
+ export interface CreateOptions {
4
+ readonly name: string;
5
+ /** Defaults to `skill`. */
6
+ readonly kind?: PackageKind;
7
+ /** Parent directory. Defaults to the process cwd. */
8
+ readonly directory?: string;
9
+ readonly description?: string;
10
+ readonly license?: string;
11
+ readonly author?: string;
12
+ readonly dryRun?: boolean;
13
+ }
14
+ export interface CreateReport {
15
+ readonly name: string;
16
+ readonly kind: PackageKind;
17
+ readonly directory: string;
18
+ readonly files: readonly string[];
19
+ readonly dryRun: boolean;
20
+ }
21
+ /**
22
+ * Scaffolds a new skill package.
23
+ *
24
+ * The generated package is deliberately *valid but incomplete*: `senior-skills validate` on a
25
+ * fresh scaffold passes with warnings pointing at the placeholder text, so an author's first
26
+ * experience of the validator is a useful checklist rather than a wall of errors.
27
+ */
28
+ export declare class CreateSkill {
29
+ private readonly ctx;
30
+ constructor(ctx: ApplicationContext);
31
+ execute(options: CreateOptions): Promise<CreateReport>;
32
+ }
33
+ //# sourceMappingURL=create-skill.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-skill.d.ts","sourceRoot":"","sources":["../../src/application/create-skill.ts"],"names":[],"mappings":"AACA,OAAO,EAAwB,KAAK,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAI/E,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAEvD,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,2BAA2B;IAC3B,QAAQ,CAAC,IAAI,CAAC,EAAE,WAAW,CAAC;IAC5B,qDAAqD;IACrD,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;CAC3B;AAED,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC;IAC3B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;IAClC,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;CAC1B;AAED;;;;;;GAMG;AACH,qBAAa,WAAW;IACtB,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAqB;gBAE7B,GAAG,EAAE,kBAAkB;IAI7B,OAAO,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,YAAY,CAAC;CA4C7D"}
@@ -0,0 +1,58 @@
1
+ import { AgentSkillsError, ErrorCode } from "../domain/errors.js";
2
+ import { DEFAULT_PACKAGE_KIND } from "../domain/manifest.js";
3
+ import { assertValidSkillName } from "../domain/skill-ref.js";
4
+ import { decodeText } from "../domain/skill-package.js";
5
+ import { scaffoldPackage } from "./package-loader.js";
6
+ /**
7
+ * Scaffolds a new skill package.
8
+ *
9
+ * The generated package is deliberately *valid but incomplete*: `senior-skills validate` on a
10
+ * fresh scaffold passes with warnings pointing at the placeholder text, so an author's first
11
+ * experience of the validator is a useful checklist rather than a wall of errors.
12
+ */
13
+ export class CreateSkill {
14
+ ctx;
15
+ constructor(ctx) {
16
+ this.ctx = ctx;
17
+ }
18
+ async execute(options) {
19
+ assertValidSkillName(options.name);
20
+ const parent = this.ctx.fs.resolve(options.directory ?? this.ctx.env.cwd());
21
+ const directory = this.ctx.fs.join(parent, options.name);
22
+ if (await this.ctx.fs.exists(directory)) {
23
+ throw new AgentSkillsError(ErrorCode.USAGE, `${directory} already exists`, {
24
+ hints: ['Choose another name, or remove the existing directory first'],
25
+ data: { directory },
26
+ });
27
+ }
28
+ const kind = options.kind ?? DEFAULT_PACKAGE_KIND;
29
+ const files = scaffoldPackage(options.name, {
30
+ kind,
31
+ ...(options.description === undefined ? {} : { description: options.description }),
32
+ ...(options.license === undefined ? {} : { license: options.license }),
33
+ ...(options.author === undefined ? {} : { author: options.author }),
34
+ });
35
+ if (options.dryRun !== true) {
36
+ for (const file of files) {
37
+ const absolute = this.ctx.fs.join(directory, ...file.path.split('/'));
38
+ await this.ctx.fs.mkdirp(this.ctx.fs.dirname(absolute));
39
+ await this.ctx.fs.writeFile(absolute, decodeText(file.bytes));
40
+ }
41
+ // Conventional empty directories, created so the author sees where things go. A command
42
+ // installs as a single file, so it has nowhere to put them.
43
+ if (kind === 'skill') {
44
+ for (const extra of ['examples', 'scripts']) {
45
+ await this.ctx.fs.mkdirp(this.ctx.fs.join(directory, extra));
46
+ }
47
+ }
48
+ }
49
+ return {
50
+ name: options.name,
51
+ kind,
52
+ directory,
53
+ files: files.map((file) => file.path),
54
+ dryRun: options.dryRun === true,
55
+ };
56
+ }
57
+ }
58
+ //# sourceMappingURL=create-skill.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-skill.js","sourceRoot":"","sources":["../../src/application/create-skill.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAClE,OAAO,EAAE,oBAAoB,EAAoB,MAAM,uBAAuB,CAAC;AAC/E,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAuBtD;;;;;;GAMG;AACH,MAAM,OAAO,WAAW;IACL,GAAG,CAAqB;IAEzC,YAAY,GAAuB;QACjC,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;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