trackops 2.0.4 → 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.
Files changed (90) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +695 -640
  3. package/bin/trackops.js +116 -116
  4. package/lib/config.js +326 -326
  5. package/lib/control.js +208 -208
  6. package/lib/env.js +244 -244
  7. package/lib/init.js +325 -325
  8. package/lib/locale.js +41 -41
  9. package/lib/opera-bootstrap.js +942 -936
  10. package/lib/opera.js +495 -486
  11. package/lib/preferences.js +74 -74
  12. package/lib/registry.js +214 -214
  13. package/lib/release.js +56 -56
  14. package/lib/runtime-state.js +144 -144
  15. package/lib/skills.js +74 -57
  16. package/lib/workspace.js +260 -260
  17. package/locales/en.json +192 -170
  18. package/locales/es.json +192 -170
  19. package/package.json +61 -58
  20. package/scripts/postinstall-locale.js +21 -21
  21. package/scripts/skills-marketplace-smoke.js +124 -124
  22. package/scripts/smoke-tests.js +558 -554
  23. package/scripts/sync-skill-version.js +21 -21
  24. package/scripts/validate-skill.js +103 -103
  25. package/skills/trackops/SKILL.md +126 -122
  26. package/skills/trackops/agents/openai.yaml +7 -7
  27. package/skills/trackops/locales/en/SKILL.md +126 -122
  28. package/skills/trackops/locales/en/references/activation.md +94 -90
  29. package/skills/trackops/locales/en/references/troubleshooting.md +73 -67
  30. package/skills/trackops/locales/en/references/workflow.md +55 -32
  31. package/skills/trackops/references/activation.md +94 -90
  32. package/skills/trackops/references/troubleshooting.md +73 -67
  33. package/skills/trackops/references/workflow.md +55 -32
  34. package/skills/trackops/skill.json +29 -29
  35. package/templates/hooks/post-checkout +2 -2
  36. package/templates/hooks/post-commit +2 -2
  37. package/templates/hooks/post-merge +2 -2
  38. package/templates/opera/agent.md +28 -27
  39. package/templates/opera/architecture/dependency-graph.md +24 -24
  40. package/templates/opera/architecture/runtime-automation.md +24 -24
  41. package/templates/opera/architecture/runtime-operations.md +34 -34
  42. package/templates/opera/en/agent.md +22 -21
  43. package/templates/opera/en/architecture/dependency-graph.md +24 -24
  44. package/templates/opera/en/architecture/runtime-automation.md +24 -24
  45. package/templates/opera/en/architecture/runtime-operations.md +34 -34
  46. package/templates/opera/en/reviews/delivery-audit.md +18 -18
  47. package/templates/opera/en/reviews/integration-audit.md +18 -18
  48. package/templates/opera/en/router.md +24 -19
  49. package/templates/opera/references/autonomy-and-recovery.md +117 -117
  50. package/templates/opera/references/opera-cycle.md +193 -193
  51. package/templates/opera/registry.md +28 -28
  52. package/templates/opera/reviews/delivery-audit.md +18 -18
  53. package/templates/opera/reviews/integration-audit.md +18 -18
  54. package/templates/opera/router.md +54 -49
  55. package/templates/skills/changelog-updater/SKILL.md +69 -69
  56. package/templates/skills/commiter/SKILL.md +99 -99
  57. package/templates/skills/opera-contract-auditor/SKILL.md +38 -38
  58. package/templates/skills/opera-contract-auditor/locales/en/SKILL.md +38 -38
  59. package/templates/skills/opera-policy-guard/SKILL.md +26 -26
  60. package/templates/skills/opera-policy-guard/locales/en/SKILL.md +26 -26
  61. package/templates/skills/opera-skill/SKILL.md +279 -0
  62. package/templates/skills/opera-skill/locales/en/SKILL.md +279 -0
  63. package/templates/skills/opera-skill/locales/en/references/phase-dod.md +138 -0
  64. package/templates/skills/opera-skill/references/phase-dod.md +138 -0
  65. package/templates/skills/project-starter-skill/SKILL.md +150 -131
  66. package/templates/skills/project-starter-skill/locales/en/SKILL.md +143 -105
  67. package/templates/skills/project-starter-skill/references/opera-cycle.md +195 -193
  68. package/ui/css/base.css +284 -284
  69. package/ui/css/charts.css +425 -425
  70. package/ui/css/components.css +1107 -1107
  71. package/ui/css/onboarding.css +133 -133
  72. package/ui/css/terminal.css +125 -125
  73. package/ui/css/timeline.css +58 -58
  74. package/ui/css/tokens.css +284 -284
  75. package/ui/favicon.svg +5 -5
  76. package/ui/index.html +99 -99
  77. package/ui/js/charts.js +526 -526
  78. package/ui/js/console-logger.js +172 -172
  79. package/ui/js/filters.js +247 -247
  80. package/ui/js/icons.js +129 -129
  81. package/ui/js/keyboard.js +229 -229
  82. package/ui/js/router.js +142 -142
  83. package/ui/js/theme.js +100 -100
  84. package/ui/js/time-tracker.js +248 -248
  85. package/ui/js/views/dashboard.js +870 -870
  86. package/ui/js/views/flash.js +47 -47
  87. package/ui/js/views/projects.js +745 -745
  88. package/ui/js/views/scrum.js +476 -476
  89. package/ui/js/views/settings.js +331 -331
  90. package/ui/js/views/timeline.js +265 -265
@@ -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,214 +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 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
- };
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
+ };