@elmundi/ship-cli 0.14.2 → 0.15.4

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 (39) hide show
  1. package/README.md +17 -16
  2. package/bin/shipctl.mjs +4 -80
  3. package/lib/commands/feedback.mjs +1 -1
  4. package/lib/commands/help.mjs +47 -131
  5. package/lib/commands/init.mjs +17 -250
  6. package/lib/commands/knowledge.mjs +25 -328
  7. package/lib/commands/preflight.mjs +213 -0
  8. package/lib/commands/run.mjs +298 -119
  9. package/lib/commands/trigger.mjs +95 -10
  10. package/lib/config/schema.mjs +73 -11
  11. package/lib/http.mjs +0 -2
  12. package/lib/runtime/routines.mjs +39 -0
  13. package/lib/templates.mjs +2 -2
  14. package/lib/verify/checks/agents-on-disk.mjs +5 -28
  15. package/lib/verify/registry.mjs +7 -8
  16. package/package.json +1 -1
  17. package/lib/artifacts/fs-index.mjs +0 -230
  18. package/lib/cache/store.mjs +0 -422
  19. package/lib/commands/bootstrap.mjs +0 -4
  20. package/lib/commands/callback.mjs +0 -742
  21. package/lib/commands/docs.mjs +0 -90
  22. package/lib/commands/kickoff.mjs +0 -192
  23. package/lib/commands/lanes.mjs +0 -566
  24. package/lib/commands/manifest-catalog.mjs +0 -251
  25. package/lib/commands/migrate.mjs +0 -204
  26. package/lib/commands/new.mjs +0 -452
  27. package/lib/commands/patterns.mjs +0 -160
  28. package/lib/commands/process.mjs +0 -388
  29. package/lib/commands/search.mjs +0 -43
  30. package/lib/commands/sync.mjs +0 -824
  31. package/lib/config/migrate.mjs +0 -223
  32. package/lib/find-ship-root.mjs +0 -75
  33. package/lib/process/specialist-prompt-contract.mjs +0 -171
  34. package/lib/state/lockfile.mjs +0 -180
  35. package/lib/vendor/run-agent.workflow.yml +0 -254
  36. package/lib/verify/checks/artifacts-up-to-date.mjs +0 -78
  37. package/lib/verify/checks/cache-integrity.mjs +0 -51
  38. package/lib/verify/checks/gitignore-cache.mjs +0 -51
  39. package/lib/verify/checks/rules-markers.mjs +0 -135
@@ -1,90 +0,0 @@
1
- import { apiPost } from "../http.mjs";
2
-
3
- /**
4
- * Documentation files only: fetch markdown by repo path, retro feedback.
5
- * @param {{ baseUrl: string; json: boolean }} ctx
6
- * @param {string[]} args
7
- */
8
- export async function docsCommand(ctx, args) {
9
- const [sub, ...rest] = args;
10
- if (!sub || sub === "help") {
11
- console.log(`Usage:
12
- shipctl docs fetch <repo-relative-path>
13
- shipctl docs feedback --title "..." --summary "..." [--recommendation "line"]... [--source-context "..."]
14
-
15
- Vector search: shipctl search <query>
16
- Catalog bodies: shipctl pattern|tool|collection fetch <id>
17
-
18
- Global flags: --base-url URL --json`);
19
- return;
20
- }
21
-
22
- if (sub === "fetch") {
23
- const p = rest.join(" ").trim();
24
- if (!p) {
25
- console.error("fetch: repo-relative path required (markdown/text under the Ship tree).");
26
- process.exit(1);
27
- }
28
- const data = await apiPost(ctx.baseUrl, "/fetch", { path: p });
29
- if (ctx.json) console.log(JSON.stringify(data, null, 2));
30
- else {
31
- const title = data.path ?? data.id ?? "document";
32
- console.log(`# ${title}\n`);
33
- console.log(data.content);
34
- }
35
- return;
36
- }
37
-
38
- if (sub === "feedback") {
39
- const opts = parseFeedbackArgs(rest);
40
- if (opts.title.length < 5 || opts.summary.length < 10) {
41
- console.error("feedback: --title (min 5) and --summary (min 10) are required.");
42
- process.exit(1);
43
- }
44
- const body = {
45
- title: opts.title,
46
- summary: opts.summary,
47
- recommendations: opts.recommendations,
48
- source_context: opts.sourceContext || null,
49
- };
50
- const data = await apiPost(ctx.baseUrl, "/feedback", body);
51
- if (ctx.json) console.log(JSON.stringify(data, null, 2));
52
- else {
53
- console.log(`Created: ${data.issue_url} (#${data.issue_number})`);
54
- if (data.redactions_applied) console.log(`Redactions applied: ${data.redactions_applied}`);
55
- }
56
- return;
57
- }
58
-
59
- console.error(`Unknown docs subcommand: ${sub}`);
60
- process.exit(1);
61
- }
62
-
63
- /** @param {string[]} rest */
64
- function parseFeedbackArgs(rest) {
65
- let title = "";
66
- let summary = "";
67
- /** @type {string[]} */
68
- const recommendations = [];
69
- let sourceContext = "";
70
- for (let i = 0; i < rest.length; i++) {
71
- const a = rest[i];
72
- if (a === "--title" && rest[i + 1]) {
73
- title = rest[++i];
74
- continue;
75
- }
76
- if (a === "--summary" && rest[i + 1]) {
77
- summary = rest[++i];
78
- continue;
79
- }
80
- if (a === "--recommendation" && rest[i + 1]) {
81
- recommendations.push(rest[++i]);
82
- continue;
83
- }
84
- if (a === "--source-context" && rest[i + 1]) {
85
- sourceContext = rest[++i];
86
- continue;
87
- }
88
- }
89
- return { title, summary, recommendations, sourceContext };
90
- }
@@ -1,192 +0,0 @@
1
- /**
2
- * `shipctl kickoff` — print the markdown body of the `kickoff` pattern
3
- * (or another pattern id) for piping into the customer’s agent in CI.
4
- *
5
- * Resolution order for the methodology host:
6
- * 1. Global `--base-url` (methodology API root, same as `pattern fetch`).
7
- * 2. `.ship/config.yml` → `api.base_url` with `/api/methodology` appended
8
- * when absent.
9
- * 3. `SHIP_API_BASE` / default public host.
10
- *
11
- * When the process cwd (or `--cwd`) is inside the Ship monorepo, we read
12
- * `artifacts/patterns/<id>/ARTIFACT.md` from disk so local dev matches prod.
13
- */
14
-
15
- import path from "node:path";
16
- import { fetchArtifact } from "../http.mjs";
17
- import { readConfig, findShipRoot } from "../config/io.mjs";
18
- import { resolveShipRepoRootForCatalog } from "../find-ship-root.mjs";
19
- import { readArtifactFile } from "../artifacts/fs-index.mjs";
20
-
21
- function printKickoffHelp() {
22
- console.log(`shipctl kickoff — print a pattern body for piping into your agent (CI).
23
-
24
- USAGE
25
- shipctl kickoff [--pattern <id>] [--version <semver>] [--raw] [--json] [--cwd <dir>]
26
-
27
- DEFAULTS
28
- --pattern common-kickoff
29
-
30
- FLAGS
31
- --pattern Catalog pattern id (folder under artifacts/patterns/).
32
- --version Optional pinned version (POST /fetch).
33
- --raw Print the full ARTIFACT.md including YAML front matter.
34
- --json Emit { pattern_id, body, agent_provider? } JSON.
35
- --cwd Repo root to find .ship/config.yml (default: search upward).
36
-
37
- The default output is markdown body only (front matter stripped) on stdout.
38
- When .ship/config.yml sets stack.agent.provider, a one-line hint is written
39
- to stderr so logs show which agent the repo is wired for — unless --json.
40
-
41
- EXAMPLE (workflow step)
42
- shipctl kickoff --pattern common-kickoff > kickoff.md
43
- # …concatenate workload pattern + kickoff.md into your agent invocation…
44
- `);
45
- }
46
-
47
- function stripFrontmatter(full) {
48
- if (!full || !full.startsWith("---\n")) return full;
49
- const end = full.indexOf("\n---\n", 4);
50
- if (end === -1) return full;
51
- return full.slice(end + "\n---\n".length);
52
- }
53
-
54
- /** @param {string} methodologyBase */
55
- function resolveMethodologyBase(ctx, config) {
56
- const fromFlag = ctx.baseUrl;
57
- const raw = config?.api?.base_url;
58
- if (typeof raw === "string" && raw.trim()) {
59
- const u = raw.replace(/\/$/, "");
60
- return u.includes("/api/methodology") ? u : `${u}/api/methodology`;
61
- }
62
- return fromFlag;
63
- }
64
-
65
- function parseKickoffArgs(rest) {
66
- const out = {
67
- patternId: "common-kickoff",
68
- version: null,
69
- raw: false,
70
- json: false,
71
- help: false,
72
- cwd: process.cwd(),
73
- };
74
- const copy = [...rest];
75
- while (copy.length) {
76
- const a = copy[0];
77
- if (a === "--help" || a === "-h") {
78
- out.help = true;
79
- copy.shift();
80
- continue;
81
- }
82
- if (a === "--raw") {
83
- out.raw = true;
84
- copy.shift();
85
- continue;
86
- }
87
- if (a === "--json") {
88
- out.json = true;
89
- copy.shift();
90
- continue;
91
- }
92
- if (a === "--pattern" && copy[1]) {
93
- copy.shift();
94
- out.patternId = String(copy.shift());
95
- continue;
96
- }
97
- if (a.startsWith("--pattern=")) {
98
- out.patternId = a.slice("--pattern=".length);
99
- copy.shift();
100
- continue;
101
- }
102
- if (a === "--version" && copy[1]) {
103
- copy.shift();
104
- out.version = String(copy.shift());
105
- continue;
106
- }
107
- if (a.startsWith("--version=")) {
108
- out.version = a.slice("--version=".length);
109
- copy.shift();
110
- continue;
111
- }
112
- if (a === "--cwd" && copy[1]) {
113
- copy.shift();
114
- out.cwd = path.resolve(String(copy.shift()));
115
- continue;
116
- }
117
- if (a.startsWith("--cwd=")) {
118
- out.cwd = path.resolve(a.slice("--cwd=".length));
119
- copy.shift();
120
- continue;
121
- }
122
- console.error(`unknown argument: ${a}\nRun: shipctl kickoff --help`);
123
- process.exit(2);
124
- }
125
- return out;
126
- }
127
-
128
- export async function kickoffCommand(ctx, rest) {
129
- const args = parseKickoffArgs(rest);
130
- if (args.help) {
131
- printKickoffHelp();
132
- return;
133
- }
134
-
135
- const ctx2 = ctx;
136
-
137
- /** @type {object|null} */
138
- let config = null;
139
- const root = findShipRoot(args.cwd);
140
- if (root) {
141
- try {
142
- config = readConfig(root).config;
143
- } catch {
144
- config = null;
145
- }
146
- }
147
-
148
- const methodologyBase = resolveMethodologyBase(ctx2, config);
149
- const agentProvider =
150
- config?.stack?.agent && typeof config.stack.agent === "object"
151
- ? config.stack.agent.provider
152
- : null;
153
-
154
- /** @type {string|undefined} */
155
- let fullText;
156
- const shipRepo = resolveShipRepoRootForCatalog();
157
- if (shipRepo) {
158
- const file = readArtifactFile(shipRepo, "pattern", args.patternId);
159
- if (file) fullText = file.content;
160
- }
161
- if (fullText === undefined) {
162
- const { content } = await fetchArtifact(
163
- methodologyBase,
164
- "pattern",
165
- args.patternId,
166
- args.version || undefined,
167
- );
168
- fullText = content;
169
- }
170
-
171
- const body = args.raw ? fullText : stripFrontmatter(fullText);
172
-
173
- if (args.json) {
174
- console.log(
175
- JSON.stringify(
176
- {
177
- pattern_id: args.patternId,
178
- body,
179
- agent_provider: agentProvider || null,
180
- },
181
- null,
182
- 2,
183
- ),
184
- );
185
- return;
186
- }
187
-
188
- if (agentProvider && typeof agentProvider === "string") {
189
- console.error(`# ship: stack.agent.provider=${agentProvider}`);
190
- }
191
- process.stdout.write(body.endsWith("\n") ? body : `${body}\n`);
192
- }