trackops 2.0.3 → 2.0.5
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 +21 -21
- package/README.md +695 -402
- package/bin/trackops.js +116 -116
- package/lib/config.js +326 -326
- package/lib/control.js +208 -208
- package/lib/env.js +244 -244
- package/lib/init.js +325 -325
- package/lib/locale.js +24 -0
- package/lib/opera-bootstrap.js +941 -874
- package/lib/opera.js +494 -477
- package/lib/preferences.js +74 -74
- package/lib/registry.js +214 -196
- package/lib/release.js +56 -56
- package/lib/runtime-state.js +144 -144
- package/lib/server.js +312 -207
- package/lib/skills.js +74 -57
- package/lib/workspace.js +260 -260
- package/locales/en.json +192 -166
- package/locales/es.json +192 -166
- package/package.json +61 -58
- package/scripts/postinstall-locale.js +21 -21
- package/scripts/skills-marketplace-smoke.js +124 -124
- package/scripts/smoke-tests.js +558 -554
- package/scripts/sync-skill-version.js +21 -21
- package/scripts/validate-skill.js +103 -103
- package/skills/trackops/SKILL.md +126 -122
- package/skills/trackops/agents/openai.yaml +7 -7
- package/skills/trackops/locales/en/SKILL.md +126 -122
- package/skills/trackops/locales/en/references/activation.md +94 -75
- package/skills/trackops/locales/en/references/troubleshooting.md +73 -55
- package/skills/trackops/locales/en/references/workflow.md +55 -32
- package/skills/trackops/references/activation.md +94 -75
- package/skills/trackops/references/troubleshooting.md +73 -55
- package/skills/trackops/references/workflow.md +55 -32
- package/skills/trackops/skill.json +29 -29
- package/templates/hooks/post-checkout +2 -2
- package/templates/hooks/post-commit +2 -2
- package/templates/hooks/post-merge +2 -2
- package/templates/opera/agent.md +28 -27
- package/templates/opera/architecture/dependency-graph.md +24 -24
- package/templates/opera/architecture/runtime-automation.md +24 -24
- package/templates/opera/architecture/runtime-operations.md +34 -34
- package/templates/opera/en/agent.md +22 -21
- package/templates/opera/en/architecture/dependency-graph.md +24 -24
- package/templates/opera/en/architecture/runtime-automation.md +24 -24
- package/templates/opera/en/architecture/runtime-operations.md +34 -34
- package/templates/opera/en/reviews/delivery-audit.md +18 -18
- package/templates/opera/en/reviews/integration-audit.md +18 -18
- package/templates/opera/en/router.md +24 -19
- package/templates/opera/references/autonomy-and-recovery.md +117 -117
- package/templates/opera/references/opera-cycle.md +193 -193
- package/templates/opera/registry.md +28 -28
- package/templates/opera/reviews/delivery-audit.md +18 -18
- package/templates/opera/reviews/integration-audit.md +18 -18
- package/templates/opera/router.md +54 -49
- package/templates/skills/changelog-updater/SKILL.md +69 -69
- package/templates/skills/commiter/SKILL.md +99 -99
- package/templates/skills/opera-contract-auditor/SKILL.md +38 -38
- package/templates/skills/opera-contract-auditor/locales/en/SKILL.md +38 -38
- package/templates/skills/opera-policy-guard/SKILL.md +26 -26
- package/templates/skills/opera-policy-guard/locales/en/SKILL.md +26 -26
- package/templates/skills/opera-skill/SKILL.md +279 -0
- package/templates/skills/opera-skill/locales/en/SKILL.md +279 -0
- package/templates/skills/opera-skill/locales/en/references/phase-dod.md +138 -0
- package/templates/skills/opera-skill/references/phase-dod.md +138 -0
- package/templates/skills/project-starter-skill/SKILL.md +150 -131
- package/templates/skills/project-starter-skill/locales/en/SKILL.md +143 -105
- package/templates/skills/project-starter-skill/references/opera-cycle.md +195 -193
- package/ui/css/base.css +284 -266
- package/ui/css/charts.css +425 -327
- package/ui/css/components.css +1107 -570
- package/ui/css/onboarding.css +133 -0
- package/ui/css/panels.css +345 -406
- package/ui/css/terminal.css +125 -0
- package/ui/css/timeline.css +58 -0
- package/ui/css/tokens.css +284 -227
- package/ui/favicon.svg +5 -5
- package/ui/index.html +99 -96
- package/ui/js/api.js +49 -13
- package/ui/js/app.js +28 -32
- package/ui/js/charts.js +526 -0
- package/ui/js/console-logger.js +172 -172
- package/ui/js/filters.js +247 -0
- package/ui/js/icons.js +129 -104
- package/ui/js/keyboard.js +229 -0
- package/ui/js/onboarding.js +33 -42
- package/ui/js/router.js +142 -125
- package/ui/js/theme.js +100 -100
- package/ui/js/time-tracker.js +248 -248
- package/ui/js/views/board.js +84 -114
- package/ui/js/views/dashboard.js +870 -0
- package/ui/js/views/flash.js +47 -47
- package/ui/js/views/projects.js +745 -0
- package/ui/js/views/scrum.js +476 -0
- package/ui/js/views/settings.js +153 -203
- package/ui/js/views/sidebar.js +37 -31
- package/ui/js/views/tasks.js +218 -101
- package/ui/js/views/timeline.js +265 -0
- package/ui/js/views/topbar.js +94 -107
- package/ui/app.js +0 -950
- package/ui/js/views/insights.js +0 -340
- package/ui/js/views/overview.js +0 -369
- package/ui/styles.css +0 -688
package/lib/preferences.js
CHANGED
|
@@ -1,74 +1,74 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
const config = require("./config");
|
|
4
|
-
const runtimeState = require("./runtime-state");
|
|
5
|
-
const { setLocale, t } = require("./i18n");
|
|
6
|
-
const { normalizeLocale } = require("./locale");
|
|
7
|
-
|
|
8
|
-
function formatLocaleSource(source) {
|
|
9
|
-
return t(`locale.source.${String(source || "").trim()}`) || source || t("locale.none");
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
function resolveProjectLocale(root) {
|
|
13
|
-
const context = config.resolveWorkspaceContext(root || process.cwd());
|
|
14
|
-
if (!context) return null;
|
|
15
|
-
try {
|
|
16
|
-
return config.getLocale(config.loadControl(context));
|
|
17
|
-
} catch (_error) {
|
|
18
|
-
return null;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
function cmdLocale(args = [], root) {
|
|
23
|
-
const sub = args[0];
|
|
24
|
-
const projectLocale = resolveProjectLocale(root);
|
|
25
|
-
const doctor = runtimeState.doctorLocale(projectLocale);
|
|
26
|
-
setLocale(doctor.effectiveLocale);
|
|
27
|
-
|
|
28
|
-
if (sub === "get" || !sub) {
|
|
29
|
-
console.log(`${t("locale.effective")}: ${doctor.effectiveLocale}`);
|
|
30
|
-
console.log(`${t("locale.source")}: ${formatLocaleSource(doctor.source)}`);
|
|
31
|
-
console.log(`${t("locale.global")}: ${doctor.globalLocale || t("locale.none")}`);
|
|
32
|
-
if (doctor.projectLocale) {
|
|
33
|
-
console.log(`${t("locale.project")}: ${doctor.projectLocale}`);
|
|
34
|
-
}
|
|
35
|
-
return;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
if (sub === "set") {
|
|
39
|
-
const nextLocale = normalizeLocale(args[1]);
|
|
40
|
-
if (!nextLocale) {
|
|
41
|
-
throw new Error(t("locale.invalid", { value: String(args[1] || "") }));
|
|
42
|
-
}
|
|
43
|
-
runtimeState.writeRuntimeState({ locale: nextLocale, localeSource: "manual" });
|
|
44
|
-
setLocale(nextLocale);
|
|
45
|
-
console.log(t("locale.updated", { locale: nextLocale }));
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
console.log(t("cli.usage.locale"));
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
function cmdDoctor(args = [], root) {
|
|
53
|
-
const sub = args[0];
|
|
54
|
-
if (sub !== "locale") {
|
|
55
|
-
console.log(t("cli.usage.doctor"));
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
const projectLocale = resolveProjectLocale(root);
|
|
60
|
-
const doctor = runtimeState.doctorLocale(projectLocale);
|
|
61
|
-
setLocale(doctor.effectiveLocale);
|
|
62
|
-
console.log(`${t("locale.effective")}: ${doctor.effectiveLocale}`);
|
|
63
|
-
console.log(`${t("locale.source")}: ${formatLocaleSource(doctor.source)}`);
|
|
64
|
-
console.log(`${t("locale.global")}: ${doctor.globalLocale || t("locale.none")}`);
|
|
65
|
-
console.log(`${t("locale.project")}: ${doctor.projectLocale || t("locale.none")}`);
|
|
66
|
-
console.log(`${t("locale.env")}: ${doctor.envLocale || t("locale.none")}`);
|
|
67
|
-
console.log(`${t("locale.system")}: ${doctor.systemLocale}`);
|
|
68
|
-
console.log(`${t("locale.runtimeFile")}: ${doctor.runtimeFile}`);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
module.exports = {
|
|
72
|
-
cmdLocale,
|
|
73
|
-
cmdDoctor,
|
|
74
|
-
};
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const config = require("./config");
|
|
4
|
+
const runtimeState = require("./runtime-state");
|
|
5
|
+
const { setLocale, t } = require("./i18n");
|
|
6
|
+
const { normalizeLocale } = require("./locale");
|
|
7
|
+
|
|
8
|
+
function formatLocaleSource(source) {
|
|
9
|
+
return t(`locale.source.${String(source || "").trim()}`) || source || t("locale.none");
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function resolveProjectLocale(root) {
|
|
13
|
+
const context = config.resolveWorkspaceContext(root || process.cwd());
|
|
14
|
+
if (!context) return null;
|
|
15
|
+
try {
|
|
16
|
+
return config.getLocale(config.loadControl(context));
|
|
17
|
+
} catch (_error) {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function cmdLocale(args = [], root) {
|
|
23
|
+
const sub = args[0];
|
|
24
|
+
const projectLocale = resolveProjectLocale(root);
|
|
25
|
+
const doctor = runtimeState.doctorLocale(projectLocale);
|
|
26
|
+
setLocale(doctor.effectiveLocale);
|
|
27
|
+
|
|
28
|
+
if (sub === "get" || !sub) {
|
|
29
|
+
console.log(`${t("locale.effective")}: ${doctor.effectiveLocale}`);
|
|
30
|
+
console.log(`${t("locale.source")}: ${formatLocaleSource(doctor.source)}`);
|
|
31
|
+
console.log(`${t("locale.global")}: ${doctor.globalLocale || t("locale.none")}`);
|
|
32
|
+
if (doctor.projectLocale) {
|
|
33
|
+
console.log(`${t("locale.project")}: ${doctor.projectLocale}`);
|
|
34
|
+
}
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (sub === "set") {
|
|
39
|
+
const nextLocale = normalizeLocale(args[1]);
|
|
40
|
+
if (!nextLocale) {
|
|
41
|
+
throw new Error(t("locale.invalid", { value: String(args[1] || "") }));
|
|
42
|
+
}
|
|
43
|
+
runtimeState.writeRuntimeState({ locale: nextLocale, localeSource: "manual" });
|
|
44
|
+
setLocale(nextLocale);
|
|
45
|
+
console.log(t("locale.updated", { locale: nextLocale }));
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
console.log(t("cli.usage.locale"));
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function cmdDoctor(args = [], root) {
|
|
53
|
+
const sub = args[0];
|
|
54
|
+
if (sub !== "locale") {
|
|
55
|
+
console.log(t("cli.usage.doctor"));
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const projectLocale = resolveProjectLocale(root);
|
|
60
|
+
const doctor = runtimeState.doctorLocale(projectLocale);
|
|
61
|
+
setLocale(doctor.effectiveLocale);
|
|
62
|
+
console.log(`${t("locale.effective")}: ${doctor.effectiveLocale}`);
|
|
63
|
+
console.log(`${t("locale.source")}: ${formatLocaleSource(doctor.source)}`);
|
|
64
|
+
console.log(`${t("locale.global")}: ${doctor.globalLocale || t("locale.none")}`);
|
|
65
|
+
console.log(`${t("locale.project")}: ${doctor.projectLocale || t("locale.none")}`);
|
|
66
|
+
console.log(`${t("locale.env")}: ${doctor.envLocale || t("locale.none")}`);
|
|
67
|
+
console.log(`${t("locale.system")}: ${doctor.systemLocale}`);
|
|
68
|
+
console.log(`${t("locale.runtimeFile")}: ${doctor.runtimeFile}`);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
module.exports = {
|
|
72
|
+
cmdLocale,
|
|
73
|
+
cmdDoctor,
|
|
74
|
+
};
|
package/lib/registry.js
CHANGED
|
@@ -1,196 +1,214 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
const fs = require("fs");
|
|
4
|
-
const os = require("os");
|
|
5
|
-
const path = require("path");
|
|
6
|
-
|
|
7
|
-
const config = require("./config");
|
|
8
|
-
const { t } = require("./i18n");
|
|
9
|
-
|
|
10
|
-
const REGISTRY_DIR = path.join(os.homedir(), ".codex", "trackops");
|
|
11
|
-
const REGISTRY_FILE = path.join(REGISTRY_DIR, "registry.json");
|
|
12
|
-
|
|
13
|
-
function nowIso() {
|
|
14
|
-
return new Date().toISOString();
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
function slugify(value) {
|
|
18
|
-
return String(value || "")
|
|
19
|
-
.normalize("NFD")
|
|
20
|
-
.replace(/[\u0300-\u036f]/g, "")
|
|
21
|
-
.toLowerCase()
|
|
22
|
-
.replace(/[^a-z0-9]+/g, "-")
|
|
23
|
-
.replace(/^-+|-+$/g, "")
|
|
24
|
-
.slice(0, 48);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
function shortHash(value) {
|
|
28
|
-
let hash = 0;
|
|
29
|
-
const input = String(value || "");
|
|
30
|
-
for (let index = 0; index < input.length; index += 1) {
|
|
31
|
-
hash = (hash * 31 + input.charCodeAt(index)) >>> 0;
|
|
32
|
-
}
|
|
33
|
-
return hash.toString(36).slice(0, 6);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
function ensureRegistryDir() {
|
|
37
|
-
fs.mkdirSync(REGISTRY_DIR, { recursive: true });
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
function loadRegistry() {
|
|
41
|
-
ensureRegistryDir();
|
|
42
|
-
if (!fs.existsSync(REGISTRY_FILE)) {
|
|
43
|
-
return { version: 2, updatedAt: nowIso(), projects: [] };
|
|
44
|
-
}
|
|
45
|
-
const registry = JSON.parse(fs.readFileSync(REGISTRY_FILE, "utf8"));
|
|
46
|
-
if (!registry.version) registry.version = 1;
|
|
47
|
-
return registry;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
function saveRegistry(registry) {
|
|
51
|
-
ensureRegistryDir();
|
|
52
|
-
registry.updatedAt = nowIso();
|
|
53
|
-
fs.writeFileSync(REGISTRY_FILE, `${JSON.stringify(registry, null, 2)}\n`, "utf8");
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
function isProjectInstalled(rootDir) {
|
|
57
|
-
const context = config.resolveWorkspaceContext(rootDir);
|
|
58
|
-
return Boolean(context && fs.existsSync(context.controlFile));
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
function inspectProject(rootDir) {
|
|
62
|
-
const context = config.resolveWorkspaceContext(rootDir) || config.createLegacyContext(rootDir);
|
|
63
|
-
const root = context.workspaceRoot;
|
|
64
|
-
const controlStateFile = context.controlFile;
|
|
65
|
-
|
|
66
|
-
if (!fs.existsSync(controlStateFile)) {
|
|
67
|
-
throw new Error(`Project '${root}' does not have trackops installed.`);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
let packageJson = {};
|
|
71
|
-
const packageFile = context.packageFile;
|
|
72
|
-
if (fs.existsSync(packageFile)) {
|
|
73
|
-
packageJson = JSON.parse(fs.readFileSync(packageFile, "utf8"));
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
const controlState = JSON.parse(fs.readFileSync(controlStateFile, "utf8"));
|
|
77
|
-
const projectName =
|
|
78
|
-
controlState.meta?.projectName || packageJson.displayName || packageJson.name || path.basename(root);
|
|
79
|
-
|
|
80
|
-
return {
|
|
81
|
-
id: `${slugify(projectName) || "project"}-${shortHash(root)}`,
|
|
82
|
-
name: projectName,
|
|
83
|
-
root,
|
|
84
|
-
workspaceRoot: root,
|
|
85
|
-
appRoot: context.appRoot,
|
|
86
|
-
opsRoot: context.opsRoot,
|
|
87
|
-
layout: context.layout,
|
|
88
|
-
packageName: packageJson.name || null,
|
|
89
|
-
controlStateFile,
|
|
90
|
-
registeredAt: nowIso(),
|
|
91
|
-
lastSeenAt: nowIso(),
|
|
92
|
-
};
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
function registerProject(rootDir) {
|
|
96
|
-
const registry = loadRegistry();
|
|
97
|
-
const entry = inspectProject(rootDir);
|
|
98
|
-
const existingIndex = registry.projects.findIndex((p) => (p.workspaceRoot || p.root) === entry.workspaceRoot);
|
|
99
|
-
|
|
100
|
-
if (existingIndex >= 0) {
|
|
101
|
-
registry.projects[existingIndex] = {
|
|
102
|
-
...registry.projects[existingIndex],
|
|
103
|
-
...entry,
|
|
104
|
-
registeredAt: registry.projects[existingIndex].registeredAt || entry.registeredAt,
|
|
105
|
-
lastSeenAt: nowIso(),
|
|
106
|
-
};
|
|
107
|
-
} else {
|
|
108
|
-
registry.projects.push(entry);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
registry.projects.sort((a, b) => a.name.localeCompare(b.name));
|
|
112
|
-
saveRegistry(registry);
|
|
113
|
-
return registry.projects.find((p) => (p.workspaceRoot || p.root) === entry.workspaceRoot);
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
function unregisterProject(rootDir) {
|
|
117
|
-
const context = config.resolveWorkspaceContext(rootDir) || config.createLegacyContext(rootDir);
|
|
118
|
-
const root = context.workspaceRoot;
|
|
119
|
-
const registry = loadRegistry();
|
|
120
|
-
registry.projects = registry.projects.filter((p) => (p.workspaceRoot || p.root) !== root);
|
|
121
|
-
saveRegistry(registry);
|
|
122
|
-
return registry;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
function
|
|
126
|
-
const registry = loadRegistry();
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
const
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
);
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
function
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const fs = require("fs");
|
|
4
|
+
const os = require("os");
|
|
5
|
+
const path = require("path");
|
|
6
|
+
|
|
7
|
+
const config = require("./config");
|
|
8
|
+
const { t } = require("./i18n");
|
|
9
|
+
|
|
10
|
+
const REGISTRY_DIR = path.join(os.homedir(), ".codex", "trackops");
|
|
11
|
+
const REGISTRY_FILE = path.join(REGISTRY_DIR, "registry.json");
|
|
12
|
+
|
|
13
|
+
function nowIso() {
|
|
14
|
+
return new Date().toISOString();
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function slugify(value) {
|
|
18
|
+
return String(value || "")
|
|
19
|
+
.normalize("NFD")
|
|
20
|
+
.replace(/[\u0300-\u036f]/g, "")
|
|
21
|
+
.toLowerCase()
|
|
22
|
+
.replace(/[^a-z0-9]+/g, "-")
|
|
23
|
+
.replace(/^-+|-+$/g, "")
|
|
24
|
+
.slice(0, 48);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function shortHash(value) {
|
|
28
|
+
let hash = 0;
|
|
29
|
+
const input = String(value || "");
|
|
30
|
+
for (let index = 0; index < input.length; index += 1) {
|
|
31
|
+
hash = (hash * 31 + input.charCodeAt(index)) >>> 0;
|
|
32
|
+
}
|
|
33
|
+
return hash.toString(36).slice(0, 6);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function ensureRegistryDir() {
|
|
37
|
+
fs.mkdirSync(REGISTRY_DIR, { recursive: true });
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function loadRegistry() {
|
|
41
|
+
ensureRegistryDir();
|
|
42
|
+
if (!fs.existsSync(REGISTRY_FILE)) {
|
|
43
|
+
return { version: 2, updatedAt: nowIso(), projects: [] };
|
|
44
|
+
}
|
|
45
|
+
const registry = JSON.parse(fs.readFileSync(REGISTRY_FILE, "utf8"));
|
|
46
|
+
if (!registry.version) registry.version = 1;
|
|
47
|
+
return registry;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function saveRegistry(registry) {
|
|
51
|
+
ensureRegistryDir();
|
|
52
|
+
registry.updatedAt = nowIso();
|
|
53
|
+
fs.writeFileSync(REGISTRY_FILE, `${JSON.stringify(registry, null, 2)}\n`, "utf8");
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function isProjectInstalled(rootDir) {
|
|
57
|
+
const context = config.resolveWorkspaceContext(rootDir);
|
|
58
|
+
return Boolean(context && fs.existsSync(context.controlFile));
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function inspectProject(rootDir) {
|
|
62
|
+
const context = config.resolveWorkspaceContext(rootDir) || config.createLegacyContext(rootDir);
|
|
63
|
+
const root = context.workspaceRoot;
|
|
64
|
+
const controlStateFile = context.controlFile;
|
|
65
|
+
|
|
66
|
+
if (!fs.existsSync(controlStateFile)) {
|
|
67
|
+
throw new Error(`Project '${root}' does not have trackops installed.`);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
let packageJson = {};
|
|
71
|
+
const packageFile = context.packageFile;
|
|
72
|
+
if (fs.existsSync(packageFile)) {
|
|
73
|
+
packageJson = JSON.parse(fs.readFileSync(packageFile, "utf8"));
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const controlState = JSON.parse(fs.readFileSync(controlStateFile, "utf8"));
|
|
77
|
+
const projectName =
|
|
78
|
+
controlState.meta?.projectName || packageJson.displayName || packageJson.name || path.basename(root);
|
|
79
|
+
|
|
80
|
+
return {
|
|
81
|
+
id: `${slugify(projectName) || "project"}-${shortHash(root)}`,
|
|
82
|
+
name: projectName,
|
|
83
|
+
root,
|
|
84
|
+
workspaceRoot: root,
|
|
85
|
+
appRoot: context.appRoot,
|
|
86
|
+
opsRoot: context.opsRoot,
|
|
87
|
+
layout: context.layout,
|
|
88
|
+
packageName: packageJson.name || null,
|
|
89
|
+
controlStateFile,
|
|
90
|
+
registeredAt: nowIso(),
|
|
91
|
+
lastSeenAt: nowIso(),
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function registerProject(rootDir) {
|
|
96
|
+
const registry = loadRegistry();
|
|
97
|
+
const entry = inspectProject(rootDir);
|
|
98
|
+
const existingIndex = registry.projects.findIndex((p) => (p.workspaceRoot || p.root) === entry.workspaceRoot);
|
|
99
|
+
|
|
100
|
+
if (existingIndex >= 0) {
|
|
101
|
+
registry.projects[existingIndex] = {
|
|
102
|
+
...registry.projects[existingIndex],
|
|
103
|
+
...entry,
|
|
104
|
+
registeredAt: registry.projects[existingIndex].registeredAt || entry.registeredAt,
|
|
105
|
+
lastSeenAt: nowIso(),
|
|
106
|
+
};
|
|
107
|
+
} else {
|
|
108
|
+
registry.projects.push(entry);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
registry.projects.sort((a, b) => a.name.localeCompare(b.name));
|
|
112
|
+
saveRegistry(registry);
|
|
113
|
+
return registry.projects.find((p) => (p.workspaceRoot || p.root) === entry.workspaceRoot);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
function unregisterProject(rootDir) {
|
|
117
|
+
const context = config.resolveWorkspaceContext(rootDir) || config.createLegacyContext(rootDir);
|
|
118
|
+
const root = context.workspaceRoot;
|
|
119
|
+
const registry = loadRegistry();
|
|
120
|
+
registry.projects = registry.projects.filter((p) => (p.workspaceRoot || p.root) !== root);
|
|
121
|
+
saveRegistry(registry);
|
|
122
|
+
return registry;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
function unregisterById(projectId) {
|
|
126
|
+
const registry = loadRegistry();
|
|
127
|
+
registry.projects = registry.projects.filter((p) => p.id !== projectId);
|
|
128
|
+
saveRegistry(registry);
|
|
129
|
+
return registry;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
function purgeUnavailable() {
|
|
133
|
+
const registry = loadRegistry();
|
|
134
|
+
const before = registry.projects.length;
|
|
135
|
+
registry.projects = registry.projects.filter((p) => isProjectInstalled(p.workspaceRoot || p.root));
|
|
136
|
+
const removed = before - registry.projects.length;
|
|
137
|
+
saveRegistry(registry);
|
|
138
|
+
return { removed, registry };
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
function listProjects() {
|
|
142
|
+
const registry = loadRegistry();
|
|
143
|
+
return registry.projects.map((project) => {
|
|
144
|
+
const available = isProjectInstalled(project.root);
|
|
145
|
+
return { ...project, available };
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
function resolveProject(projectRef, fallbackRoot) {
|
|
150
|
+
const projects = listProjects();
|
|
151
|
+
|
|
152
|
+
if (!projectRef) {
|
|
153
|
+
if (fallbackRoot) {
|
|
154
|
+
const resolved = config.resolveWorkspaceContext(fallbackRoot);
|
|
155
|
+
const target = resolved ? resolved.workspaceRoot : path.resolve(fallbackRoot);
|
|
156
|
+
return projects.find((p) => (p.workspaceRoot || p.root) === target) || null;
|
|
157
|
+
}
|
|
158
|
+
return projects[0] || null;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
const normalizedRef = path.resolve(projectRef);
|
|
162
|
+
return (
|
|
163
|
+
projects.find((p) => p.id === projectRef) ||
|
|
164
|
+
projects.find((p) => (p.workspaceRoot || p.root) === normalizedRef) ||
|
|
165
|
+
null
|
|
166
|
+
);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/* ── CLI commands ── */
|
|
170
|
+
|
|
171
|
+
function cmdRegister(root) {
|
|
172
|
+
const project = registerProject(root);
|
|
173
|
+
console.log(`${t("init.registered")} ${project.name}`);
|
|
174
|
+
console.log(project.root);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
function cmdList() {
|
|
178
|
+
const projects = listProjects();
|
|
179
|
+
if (!projects.length) {
|
|
180
|
+
console.log("No registered projects.");
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
projects.forEach((project, index) => {
|
|
184
|
+
console.log(`${index + 1}. ${project.name}`);
|
|
185
|
+
console.log(` id: ${project.id}`);
|
|
186
|
+
console.log(` root: ${project.workspaceRoot || project.root}`);
|
|
187
|
+
console.log(` app: ${project.appRoot}`);
|
|
188
|
+
console.log(` ops: ${project.opsRoot}`);
|
|
189
|
+
console.log(` available: ${project.available ? "yes" : "no"}`);
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
function cmdWhere() {
|
|
194
|
+
console.log(REGISTRY_FILE);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
module.exports = {
|
|
198
|
+
REGISTRY_DIR,
|
|
199
|
+
REGISTRY_FILE,
|
|
200
|
+
inspectProject,
|
|
201
|
+
isProjectInstalled,
|
|
202
|
+
listProjects,
|
|
203
|
+
loadRegistry,
|
|
204
|
+
purgeUnavailable,
|
|
205
|
+
registerProject,
|
|
206
|
+
resolveProject,
|
|
207
|
+
saveRegistry,
|
|
208
|
+
slugify,
|
|
209
|
+
unregisterById,
|
|
210
|
+
unregisterProject,
|
|
211
|
+
cmdRegister,
|
|
212
|
+
cmdList,
|
|
213
|
+
cmdWhere,
|
|
214
|
+
};
|
package/lib/release.js
CHANGED
|
@@ -1,56 +1,56 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
const { spawnSync } = require("child_process");
|
|
4
|
-
const config = require("./config");
|
|
5
|
-
|
|
6
|
-
function git(args, cwd) {
|
|
7
|
-
return spawnSync("git", args, { cwd, encoding: "utf8" });
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
function runGit(args, cwd, errorMessage) {
|
|
11
|
-
const result = git(args, cwd);
|
|
12
|
-
if (result.status !== 0) {
|
|
13
|
-
throw new Error(result.stderr || result.stdout || errorMessage);
|
|
14
|
-
}
|
|
15
|
-
return result.stdout.trim();
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
function parseArgs(args = []) {
|
|
19
|
-
return {
|
|
20
|
-
push: args.includes("--push"),
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
function cmdRelease(root, args = []) {
|
|
25
|
-
const context = config.ensureContext(root);
|
|
26
|
-
if (context.layout !== "split") {
|
|
27
|
-
throw new Error("trackops release requires a split workspace.");
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
const options = parseArgs(args);
|
|
31
|
-
const status = runGit(["status", "--porcelain"], context.workspaceRoot, "git status failed");
|
|
32
|
-
if (context.publish.requireCleanWorktree && status.trim()) {
|
|
33
|
-
throw new Error("trackops release requires a clean git worktree.");
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const currentBranch = runGit(["branch", "--show-current"], context.workspaceRoot, "git branch failed");
|
|
37
|
-
if (currentBranch !== context.branches.development) {
|
|
38
|
-
throw new Error(`trackops release must run from '${context.branches.development}'.`);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
const splitCommit = runGit(
|
|
42
|
-
["subtree", "split", "--prefix", context.publish.sourceDir, context.branches.development],
|
|
43
|
-
context.workspaceRoot,
|
|
44
|
-
"git subtree split failed",
|
|
45
|
-
);
|
|
46
|
-
|
|
47
|
-
runGit(["branch", "-f", context.branches.publish, splitCommit], context.workspaceRoot, "git branch update failed");
|
|
48
|
-
|
|
49
|
-
if (options.push) {
|
|
50
|
-
runGit(["push", "origin", context.branches.publish, "--force-with-lease"], context.workspaceRoot, "git push failed");
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
console.log(`Release branch '${context.branches.publish}' updated from '${context.branches.development}'.`);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
module.exports = { cmdRelease };
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const { spawnSync } = require("child_process");
|
|
4
|
+
const config = require("./config");
|
|
5
|
+
|
|
6
|
+
function git(args, cwd) {
|
|
7
|
+
return spawnSync("git", args, { cwd, encoding: "utf8" });
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
function runGit(args, cwd, errorMessage) {
|
|
11
|
+
const result = git(args, cwd);
|
|
12
|
+
if (result.status !== 0) {
|
|
13
|
+
throw new Error(result.stderr || result.stdout || errorMessage);
|
|
14
|
+
}
|
|
15
|
+
return result.stdout.trim();
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function parseArgs(args = []) {
|
|
19
|
+
return {
|
|
20
|
+
push: args.includes("--push"),
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function cmdRelease(root, args = []) {
|
|
25
|
+
const context = config.ensureContext(root);
|
|
26
|
+
if (context.layout !== "split") {
|
|
27
|
+
throw new Error("trackops release requires a split workspace.");
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const options = parseArgs(args);
|
|
31
|
+
const status = runGit(["status", "--porcelain"], context.workspaceRoot, "git status failed");
|
|
32
|
+
if (context.publish.requireCleanWorktree && status.trim()) {
|
|
33
|
+
throw new Error("trackops release requires a clean git worktree.");
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const currentBranch = runGit(["branch", "--show-current"], context.workspaceRoot, "git branch failed");
|
|
37
|
+
if (currentBranch !== context.branches.development) {
|
|
38
|
+
throw new Error(`trackops release must run from '${context.branches.development}'.`);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const splitCommit = runGit(
|
|
42
|
+
["subtree", "split", "--prefix", context.publish.sourceDir, context.branches.development],
|
|
43
|
+
context.workspaceRoot,
|
|
44
|
+
"git subtree split failed",
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
runGit(["branch", "-f", context.branches.publish, splitCommit], context.workspaceRoot, "git branch update failed");
|
|
48
|
+
|
|
49
|
+
if (options.push) {
|
|
50
|
+
runGit(["push", "origin", context.branches.publish, "--force-with-lease"], context.workspaceRoot, "git push failed");
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
console.log(`Release branch '${context.branches.publish}' updated from '${context.branches.development}'.`);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
module.exports = { cmdRelease };
|