trackops 2.0.0 → 2.0.2

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.
@@ -2,7 +2,7 @@
2
2
 
3
3
  ```mermaid
4
4
  flowchart TD
5
- A[Global runtime bootstrap] --> B[trackops init]
5
+ A[Explicit global runtime install] --> B[trackops init]
6
6
  B --> C[trackops opera install]
7
7
  C --> D{Routing}
8
8
  D -->|direct_cli| E[Direct intake]
@@ -104,6 +104,7 @@ Explica el flujo correcto:
104
104
 
105
105
  ```bash
106
106
  npx skills add Baxahaun/trackops
107
+ npm install -g trackops
107
108
  trackops init
108
109
  trackops opera install
109
110
  ```
@@ -122,6 +123,7 @@ Explica el flujo correcto:
122
123
 
123
124
  ```bash
124
125
  npx skills add Baxahaun/trackops
126
+ npm install -g trackops
125
127
  trackops init
126
128
  trackops opera install
127
129
  ```
@@ -97,6 +97,7 @@ Explain the correct flow:
97
97
 
98
98
  ```bash
99
99
  npx skills add Baxahaun/trackops
100
+ npm install -g trackops
100
101
  trackops init
101
102
  trackops opera install
102
103
  ```
@@ -1,203 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- const fs = require("fs");
4
- const os = require("os");
5
- const path = require("path");
6
- const { spawnSync } = require("child_process");
7
- const runtimeState = require("../../../lib/runtime-state");
8
-
9
- const EXIT_CODES = {
10
- READY: 0,
11
- PREREQ: 1,
12
- INSTALL: 2,
13
- UNVERIFIABLE: 3,
14
- };
15
-
16
- function getNpmCommand() {
17
- return process.platform === "win32" ? "npm.cmd" : "npm";
18
- }
19
-
20
- function readSkillConfig() {
21
- const skillFile = path.join(__dirname, "..", "skill.json");
22
- return JSON.parse(fs.readFileSync(skillFile, "utf8"));
23
- }
24
-
25
- function getHomeDir() {
26
- return process.env.TRACKOPS_BOOTSTRAP_HOME || os.homedir();
27
- }
28
-
29
- function getPrefixOverride() {
30
- return process.env.TRACKOPS_BOOTSTRAP_PREFIX || null;
31
- }
32
-
33
- function getInstallSource(config) {
34
- return process.env.TRACKOPS_BOOTSTRAP_INSTALL_SOURCE || `${config.npmPackage}@${config.trackopsVersion}`;
35
- }
36
-
37
- function parseMajor(version) {
38
- const major = Number(String(version || "").split(".")[0]);
39
- return Number.isFinite(major) ? major : null;
40
- }
41
-
42
- function hasSupportedNode() {
43
- const major = parseMajor(process.versions.node);
44
- return major != null && major >= 18;
45
- }
46
-
47
- function spawnChecked(command, args, extra = {}) {
48
- const shell = process.platform === "win32" && /\.(cmd|bat)$/i.test(command);
49
- return spawnSync(command, args, {
50
- encoding: "utf8",
51
- stdio: ["ignore", "pipe", "pipe"],
52
- shell,
53
- ...extra,
54
- });
55
- }
56
-
57
- function spawnNpm(args, extra = {}) {
58
- return spawnSync(getNpmCommand(), args, {
59
- encoding: "utf8",
60
- stdio: ["ignore", "pipe", "pipe"],
61
- shell: process.platform === "win32",
62
- ...extra,
63
- });
64
- }
65
-
66
- function resolvePrefixExecutables(prefix) {
67
- if (!prefix) return [];
68
- if (process.platform === "win32") {
69
- return [
70
- path.join(prefix, "trackops.cmd"),
71
- path.join(prefix, "trackops.exe"),
72
- path.join(prefix, "trackops"),
73
- ];
74
- }
75
- return [path.join(prefix, "bin", "trackops")];
76
- }
77
-
78
- function buildVerificationTargets(prefix) {
79
- const targets = [{ command: "trackops", via: "path" }];
80
- for (const candidate of resolvePrefixExecutables(prefix)) {
81
- targets.push({ command: candidate, via: "prefix" });
82
- }
83
- return targets;
84
- }
85
-
86
- function readInstalledVersion(prefix) {
87
- for (const target of buildVerificationTargets(prefix)) {
88
- const result = spawnChecked(target.command, ["--version"]);
89
- if (result.error || result.status !== 0) continue;
90
- const version = String(result.stdout || "").trim();
91
- if (version) {
92
- return { version, command: target.command, via: target.via };
93
- }
94
- }
95
- return null;
96
- }
97
-
98
- function verifyRuntime(expectedVersion, prefix) {
99
- const installed = readInstalledVersion(prefix);
100
- if (!installed) {
101
- return { ok: false, reason: "missing-command" };
102
- }
103
- if (installed.version !== expectedVersion) {
104
- return { ok: false, reason: "version-drift", installed };
105
- }
106
-
107
- const help = spawnChecked(installed.command, ["help"]);
108
- if (help.error || help.status !== 0) {
109
- return { ok: false, reason: "help-failed", installed };
110
- }
111
-
112
- return { ok: true, installed };
113
- }
114
-
115
- function ensureNpmAvailable() {
116
- const result = spawnNpm(["--version"]);
117
- return !result.error && result.status === 0;
118
- }
119
-
120
- function runInstall(config, prefix) {
121
- const installSource = getInstallSource(config);
122
- const args = ["install", "-g"];
123
- if (prefix) {
124
- args.push("--prefix", prefix);
125
- }
126
- args.push(installSource);
127
-
128
- const result = spawnNpm(args);
129
- return { ...result, installSource };
130
- }
131
-
132
- function writeRuntimeStamp(config, verification) {
133
- const previous = runtimeState.readRuntimeState();
134
- const payload = runtimeState.writeRuntimeState({
135
- ...previous,
136
- skill: config.name,
137
- skillVersion: config.skillVersion,
138
- runtimePackage: config.npmPackage,
139
- runtimeVersion: config.trackopsVersion,
140
- bootstrapPolicy: config.bootstrapPolicy,
141
- supportedAgentsV1: config.supportedAgentsV1,
142
- verifiedAt: new Date().toISOString(),
143
- verifiedWith: verification.installed.via,
144
- executable: verification.installed.command,
145
- });
146
- return payload;
147
- }
148
-
149
- function printInstallGuidance(prefix) {
150
- if (prefix) {
151
- console.error(`TrackOps was installed under the custom prefix '${prefix}'.`);
152
- console.error("Use that prefix's executable or add it to PATH before trying again.");
153
- return;
154
- }
155
-
156
- console.error("TrackOps was installed but could not be executed from PATH.");
157
- console.error("Add your npm global bin directory to PATH, reopen the terminal, and retry.");
158
- }
159
-
160
- async function main() {
161
- const config = readSkillConfig();
162
- const prefix = getPrefixOverride();
163
-
164
- if (!hasSupportedNode()) {
165
- console.error("TrackOps requires Node.js 18 or newer.");
166
- process.exit(EXIT_CODES.PREREQ);
167
- }
168
-
169
- if (!ensureNpmAvailable()) {
170
- console.error("npm is required to bootstrap the TrackOps runtime.");
171
- process.exit(EXIT_CODES.PREREQ);
172
- }
173
-
174
- const current = verifyRuntime(config.trackopsVersion, prefix);
175
- if (current.ok) {
176
- await runtimeState.ensureGlobalLocale({ interactive: false });
177
- writeRuntimeStamp(config, current);
178
- console.log(`TrackOps runtime ${config.trackopsVersion} is already ready.`);
179
- process.exit(EXIT_CODES.READY);
180
- }
181
-
182
- const install = runInstall(config, prefix);
183
- if (install.error || install.status !== 0) {
184
- console.error(`Failed to install ${install.installSource}.`);
185
- if (install.stderr) {
186
- console.error(install.stderr.trim());
187
- }
188
- process.exit(EXIT_CODES.INSTALL);
189
- }
190
-
191
- const verification = verifyRuntime(config.trackopsVersion, prefix);
192
- if (!verification.ok) {
193
- printInstallGuidance(prefix);
194
- process.exit(EXIT_CODES.UNVERIFIABLE);
195
- }
196
-
197
- await runtimeState.ensureGlobalLocale({ interactive: false });
198
- writeRuntimeStamp(config, verification);
199
- console.log(`TrackOps runtime ${config.trackopsVersion} is ready.`);
200
- process.exit(EXIT_CODES.READY);
201
- }
202
-
203
- main();