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.
Files changed (103) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +695 -402
  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 +24 -0
  9. package/lib/opera-bootstrap.js +941 -874
  10. package/lib/opera.js +494 -477
  11. package/lib/preferences.js +74 -74
  12. package/lib/registry.js +214 -196
  13. package/lib/release.js +56 -56
  14. package/lib/runtime-state.js +144 -144
  15. package/lib/server.js +312 -207
  16. package/lib/skills.js +74 -57
  17. package/lib/workspace.js +260 -260
  18. package/locales/en.json +192 -166
  19. package/locales/es.json +192 -166
  20. package/package.json +61 -58
  21. package/scripts/postinstall-locale.js +21 -21
  22. package/scripts/skills-marketplace-smoke.js +124 -124
  23. package/scripts/smoke-tests.js +558 -554
  24. package/scripts/sync-skill-version.js +21 -21
  25. package/scripts/validate-skill.js +103 -103
  26. package/skills/trackops/SKILL.md +126 -122
  27. package/skills/trackops/agents/openai.yaml +7 -7
  28. package/skills/trackops/locales/en/SKILL.md +126 -122
  29. package/skills/trackops/locales/en/references/activation.md +94 -75
  30. package/skills/trackops/locales/en/references/troubleshooting.md +73 -55
  31. package/skills/trackops/locales/en/references/workflow.md +55 -32
  32. package/skills/trackops/references/activation.md +94 -75
  33. package/skills/trackops/references/troubleshooting.md +73 -55
  34. package/skills/trackops/references/workflow.md +55 -32
  35. package/skills/trackops/skill.json +29 -29
  36. package/templates/hooks/post-checkout +2 -2
  37. package/templates/hooks/post-commit +2 -2
  38. package/templates/hooks/post-merge +2 -2
  39. package/templates/opera/agent.md +28 -27
  40. package/templates/opera/architecture/dependency-graph.md +24 -24
  41. package/templates/opera/architecture/runtime-automation.md +24 -24
  42. package/templates/opera/architecture/runtime-operations.md +34 -34
  43. package/templates/opera/en/agent.md +22 -21
  44. package/templates/opera/en/architecture/dependency-graph.md +24 -24
  45. package/templates/opera/en/architecture/runtime-automation.md +24 -24
  46. package/templates/opera/en/architecture/runtime-operations.md +34 -34
  47. package/templates/opera/en/reviews/delivery-audit.md +18 -18
  48. package/templates/opera/en/reviews/integration-audit.md +18 -18
  49. package/templates/opera/en/router.md +24 -19
  50. package/templates/opera/references/autonomy-and-recovery.md +117 -117
  51. package/templates/opera/references/opera-cycle.md +193 -193
  52. package/templates/opera/registry.md +28 -28
  53. package/templates/opera/reviews/delivery-audit.md +18 -18
  54. package/templates/opera/reviews/integration-audit.md +18 -18
  55. package/templates/opera/router.md +54 -49
  56. package/templates/skills/changelog-updater/SKILL.md +69 -69
  57. package/templates/skills/commiter/SKILL.md +99 -99
  58. package/templates/skills/opera-contract-auditor/SKILL.md +38 -38
  59. package/templates/skills/opera-contract-auditor/locales/en/SKILL.md +38 -38
  60. package/templates/skills/opera-policy-guard/SKILL.md +26 -26
  61. package/templates/skills/opera-policy-guard/locales/en/SKILL.md +26 -26
  62. package/templates/skills/opera-skill/SKILL.md +279 -0
  63. package/templates/skills/opera-skill/locales/en/SKILL.md +279 -0
  64. package/templates/skills/opera-skill/locales/en/references/phase-dod.md +138 -0
  65. package/templates/skills/opera-skill/references/phase-dod.md +138 -0
  66. package/templates/skills/project-starter-skill/SKILL.md +150 -131
  67. package/templates/skills/project-starter-skill/locales/en/SKILL.md +143 -105
  68. package/templates/skills/project-starter-skill/references/opera-cycle.md +195 -193
  69. package/ui/css/base.css +284 -266
  70. package/ui/css/charts.css +425 -327
  71. package/ui/css/components.css +1107 -570
  72. package/ui/css/onboarding.css +133 -0
  73. package/ui/css/panels.css +345 -406
  74. package/ui/css/terminal.css +125 -0
  75. package/ui/css/timeline.css +58 -0
  76. package/ui/css/tokens.css +284 -227
  77. package/ui/favicon.svg +5 -5
  78. package/ui/index.html +99 -96
  79. package/ui/js/api.js +49 -13
  80. package/ui/js/app.js +28 -32
  81. package/ui/js/charts.js +526 -0
  82. package/ui/js/console-logger.js +172 -172
  83. package/ui/js/filters.js +247 -0
  84. package/ui/js/icons.js +129 -104
  85. package/ui/js/keyboard.js +229 -0
  86. package/ui/js/onboarding.js +33 -42
  87. package/ui/js/router.js +142 -125
  88. package/ui/js/theme.js +100 -100
  89. package/ui/js/time-tracker.js +248 -248
  90. package/ui/js/views/board.js +84 -114
  91. package/ui/js/views/dashboard.js +870 -0
  92. package/ui/js/views/flash.js +47 -47
  93. package/ui/js/views/projects.js +745 -0
  94. package/ui/js/views/scrum.js +476 -0
  95. package/ui/js/views/settings.js +153 -203
  96. package/ui/js/views/sidebar.js +37 -31
  97. package/ui/js/views/tasks.js +218 -101
  98. package/ui/js/views/timeline.js +265 -0
  99. package/ui/js/views/topbar.js +94 -107
  100. package/ui/app.js +0 -950
  101. package/ui/js/views/insights.js +0 -340
  102. package/ui/js/views/overview.js +0 -369
  103. package/ui/styles.css +0 -688
package/lib/workspace.js CHANGED
@@ -1,260 +1,260 @@
1
- #!/usr/bin/env node
2
-
3
- const fs = require("fs");
4
- const path = require("path");
5
- const { spawnSync } = require("child_process");
6
-
7
- const config = require("./config");
8
- const registry = require("./registry");
9
- const env = require("./env");
10
-
11
- const OPS_ARTIFACTS = [
12
- "project_control.json",
13
- "task_plan.md",
14
- "progress.md",
15
- "findings.md",
16
- "genesis.md",
17
- ".agent",
18
- ".agents",
19
- ".githooks",
20
- ".tmp",
21
- ];
22
-
23
- function nowStamp() {
24
- return new Date().toISOString().replace(/[:.]/g, "-");
25
- }
26
-
27
- function git(args, cwd) {
28
- return spawnSync("git", args, { cwd, encoding: "utf8" });
29
- }
30
-
31
- function isIgnorableDirtyLine(line) {
32
- const normalized = String(line || "").replace(/\\/g, "/");
33
- return normalized.endsWith(".tmp/project-control-runtime.json");
34
- }
35
-
36
- function isRetryableMoveError(error) {
37
- return ["EPERM", "EXDEV", "EBUSY", "ENOTEMPTY"].includes(error?.code);
38
- }
39
-
40
- function assertCleanGit(root, allowDirty = false) {
41
- const status = git(["status", "--porcelain"], root);
42
- const dirtyLines = String(status.stdout || "")
43
- .split(/\r?\n/)
44
- .filter(Boolean)
45
- .filter((line) => !isIgnorableDirtyLine(line));
46
- if (!allowDirty && dirtyLines.length > 0) {
47
- throw new Error("Workspace migration requires a clean git worktree.");
48
- }
49
- }
50
-
51
- function createBackupBranch(root) {
52
- const name = `backup/trackops-workspace-${nowStamp()}`;
53
- const result = git(["branch", name], root);
54
- if (result.status !== 0) {
55
- throw new Error(result.stderr || `Could not create backup branch ${name}`);
56
- }
57
- return name;
58
- }
59
-
60
- function buildManifest() {
61
- return {
62
- version: 1,
63
- layout: "split",
64
- appDir: config.DEFAULT_APP_DIR,
65
- opsDir: config.DEFAULT_OPS_DIR,
66
- env: {
67
- rootFile: ".env",
68
- exampleFile: ".env.example",
69
- appBridgeFile: "app/.env",
70
- bridgeMode: "symlink-or-copy",
71
- },
72
- branches: {
73
- development: config.DEFAULT_DEV_BRANCH,
74
- publish: config.DEFAULT_PUBLISH_BRANCH,
75
- },
76
- publish: {
77
- mode: "subtree-flatten",
78
- sourceDir: config.DEFAULT_APP_DIR,
79
- includeRootFiles: [".env.example"],
80
- requireCleanWorktree: true,
81
- },
82
- };
83
- }
84
-
85
- function ensureRootGitignore(workspaceRoot) {
86
- const gitignorePath = path.join(workspaceRoot, ".gitignore");
87
- const required = ["/.env", "/app/.env", "/ops/.tmp/"];
88
- let lines = [];
89
- if (fs.existsSync(gitignorePath)) {
90
- lines = fs.readFileSync(gitignorePath, "utf8").split(/\r?\n/);
91
- }
92
- for (const entry of required) {
93
- if (!lines.includes(entry)) lines.push(entry);
94
- }
95
- fs.writeFileSync(gitignorePath, `${lines.filter(Boolean).join("\n")}\n`, "utf8");
96
- }
97
-
98
- function stripOpsScripts(packageFile) {
99
- if (!fs.existsSync(packageFile)) return;
100
- const pkg = JSON.parse(fs.readFileSync(packageFile, "utf8"));
101
- if (!pkg.scripts) return;
102
- ["ops", "ops:help", "ops:dashboard", "ops:status", "ops:next", "ops:sync", "ops:repo"].forEach((key) => {
103
- delete pkg.scripts[key];
104
- });
105
- fs.writeFileSync(packageFile, `${JSON.stringify(pkg, null, 2)}\n`, "utf8");
106
- }
107
-
108
- function moveEntry(fromPath, toPath) {
109
- if (!fs.existsSync(fromPath)) return;
110
- fs.mkdirSync(path.dirname(toPath), { recursive: true });
111
- try {
112
- fs.renameSync(fromPath, toPath);
113
- } catch (error) {
114
- if (!isRetryableMoveError(error)) throw error;
115
- const stat = fs.statSync(fromPath);
116
- if (stat.isDirectory()) {
117
- fs.cpSync(fromPath, toPath, { recursive: true, force: true });
118
- fs.rmSync(fromPath, { recursive: true, force: true });
119
- return;
120
- }
121
- fs.copyFileSync(fromPath, toPath);
122
- fs.rmSync(fromPath, { force: true });
123
- }
124
- }
125
-
126
- function shouldResumePartialMigration(root, manifest) {
127
- if (!fs.existsSync(path.join(root, config.WORKSPACE_MANIFEST))) return false;
128
- const excluded = new Set([
129
- ".git",
130
- config.WORKSPACE_MANIFEST,
131
- manifest.appDir,
132
- manifest.opsDir,
133
- ".env",
134
- ".env.example",
135
- ]);
136
- const hasPendingOps = OPS_ARTIFACTS.some((entry) => fs.existsSync(path.join(root, entry)));
137
- const hasPendingAppEntries = fs.readdirSync(root, { withFileTypes: true })
138
- .some((entry) => !excluded.has(entry.name));
139
- return hasPendingOps || hasPendingAppEntries;
140
- }
141
-
142
- function migrateWorkspace(rootDir, options = {}) {
143
- const resolved = config.resolveWorkspaceContext(rootDir);
144
- if (!resolved) {
145
- throw new Error("workspace migrate only applies to legacy TrackOps projects.");
146
- }
147
-
148
- const root = resolved.workspaceRoot;
149
- let manifest;
150
- if (resolved.layout === "legacy") {
151
- manifest = buildManifest();
152
- } else {
153
- manifest = config.loadWorkspaceManifest(resolved) || buildManifest();
154
- if (!shouldResumePartialMigration(root, manifest)) {
155
- throw new Error("workspace migrate only applies to legacy TrackOps projects.");
156
- }
157
- }
158
-
159
- assertCleanGit(root, options.allowDirty === true);
160
- const backupBranch = createBackupBranch(root);
161
-
162
- const appDir = path.join(root, manifest.appDir);
163
- const opsDir = path.join(root, manifest.opsDir);
164
- fs.mkdirSync(appDir, { recursive: true });
165
- fs.mkdirSync(opsDir, { recursive: true });
166
- config.saveWorkspaceManifest(config.createSplitContext(root, manifest), manifest);
167
-
168
- for (const entry of OPS_ARTIFACTS) {
169
- moveEntry(path.join(root, entry), path.join(opsDir, entry));
170
- }
171
-
172
- const excluded = new Set([
173
- ".git",
174
- config.WORKSPACE_MANIFEST,
175
- manifest.appDir,
176
- manifest.opsDir,
177
- ".env",
178
- ".env.example",
179
- ]);
180
-
181
- const topLevel = fs.readdirSync(root, { withFileTypes: true });
182
- for (const entry of topLevel) {
183
- if (excluded.has(entry.name)) continue;
184
- moveEntry(path.join(root, entry.name), path.join(appDir, entry.name));
185
- }
186
-
187
- ensureRootGitignore(root);
188
- stripOpsScripts(path.join(appDir, "package.json"));
189
-
190
- const context = config.createSplitContext(root, manifest);
191
- const control = config.loadControl(context);
192
- control.meta = control.meta || {};
193
- control.meta.workspace = {
194
- layout: "split",
195
- workspaceRoot: ".",
196
- appDir: manifest.appDir,
197
- opsDir: manifest.opsDir,
198
- developmentBranch: manifest.branches.development,
199
- publishBranch: manifest.branches.publish,
200
- publishMode: manifest.publish.mode,
201
- };
202
- control.meta.environment = {
203
- ...(control.meta.environment || {}),
204
- rootEnvFile: ".env",
205
- exampleFile: ".env.example",
206
- appBridgeFile: "app/.env",
207
- bridgeMode: "symlink-or-copy",
208
- requiredKeys: control.meta.environment?.requiredKeys || [],
209
- optionalKeys: control.meta.environment?.optionalKeys || [],
210
- lastAuditAt: control.meta.environment?.lastAuditAt || null,
211
- };
212
- config.saveControl(context, control);
213
- env.syncEnvironment(context, control);
214
- const controlApi = require("./control");
215
- controlApi.syncDocs(context, config.loadControl(context));
216
- controlApi.refreshRepoRuntime(context, { quiet: true });
217
-
218
- const hookConfig = git(["config", "core.hooksPath", "ops/.githooks"], root);
219
- if (hookConfig.status !== 0) {
220
- throw new Error(hookConfig.stderr || "Could not update git hooks path.");
221
- }
222
-
223
- registry.registerProject(root);
224
- return { root, backupBranch, context };
225
- }
226
-
227
- function status(contextOrRoot) {
228
- const context = config.ensureContext(contextOrRoot);
229
- console.log("Workspace:");
230
- console.log(` Layout: ${context.layout}`);
231
- console.log(` Root: ${context.workspaceRoot}`);
232
- console.log(` App: ${context.appRoot}`);
233
- console.log(` Ops: ${context.opsRoot}`);
234
- if (context.manifestFile) {
235
- console.log(` Manifest: ${context.manifestFile}`);
236
- }
237
- console.log(` Control: ${context.controlFile}`);
238
- }
239
-
240
- function cmdStatus(root) {
241
- status(root);
242
- }
243
-
244
- function cmdMigrate(root, args = []) {
245
- const allowDirty = args.includes("--allow-dirty");
246
- const result = migrateWorkspace(root, { allowDirty });
247
- console.log(`Workspace migrated: ${result.root}`);
248
- console.log(`Backup branch: ${result.backupBranch}`);
249
- }
250
-
251
- module.exports = {
252
- OPS_ARTIFACTS,
253
- buildManifest,
254
- ensureRootGitignore,
255
- stripOpsScripts,
256
- migrateWorkspace,
257
- status,
258
- cmdStatus,
259
- cmdMigrate,
260
- };
1
+ #!/usr/bin/env node
2
+
3
+ const fs = require("fs");
4
+ const path = require("path");
5
+ const { spawnSync } = require("child_process");
6
+
7
+ const config = require("./config");
8
+ const registry = require("./registry");
9
+ const env = require("./env");
10
+
11
+ const OPS_ARTIFACTS = [
12
+ "project_control.json",
13
+ "task_plan.md",
14
+ "progress.md",
15
+ "findings.md",
16
+ "genesis.md",
17
+ ".agent",
18
+ ".agents",
19
+ ".githooks",
20
+ ".tmp",
21
+ ];
22
+
23
+ function nowStamp() {
24
+ return new Date().toISOString().replace(/[:.]/g, "-");
25
+ }
26
+
27
+ function git(args, cwd) {
28
+ return spawnSync("git", args, { cwd, encoding: "utf8" });
29
+ }
30
+
31
+ function isIgnorableDirtyLine(line) {
32
+ const normalized = String(line || "").replace(/\\/g, "/");
33
+ return normalized.endsWith(".tmp/project-control-runtime.json");
34
+ }
35
+
36
+ function isRetryableMoveError(error) {
37
+ return ["EPERM", "EXDEV", "EBUSY", "ENOTEMPTY"].includes(error?.code);
38
+ }
39
+
40
+ function assertCleanGit(root, allowDirty = false) {
41
+ const status = git(["status", "--porcelain"], root);
42
+ const dirtyLines = String(status.stdout || "")
43
+ .split(/\r?\n/)
44
+ .filter(Boolean)
45
+ .filter((line) => !isIgnorableDirtyLine(line));
46
+ if (!allowDirty && dirtyLines.length > 0) {
47
+ throw new Error("Workspace migration requires a clean git worktree.");
48
+ }
49
+ }
50
+
51
+ function createBackupBranch(root) {
52
+ const name = `backup/trackops-workspace-${nowStamp()}`;
53
+ const result = git(["branch", name], root);
54
+ if (result.status !== 0) {
55
+ throw new Error(result.stderr || `Could not create backup branch ${name}`);
56
+ }
57
+ return name;
58
+ }
59
+
60
+ function buildManifest() {
61
+ return {
62
+ version: 1,
63
+ layout: "split",
64
+ appDir: config.DEFAULT_APP_DIR,
65
+ opsDir: config.DEFAULT_OPS_DIR,
66
+ env: {
67
+ rootFile: ".env",
68
+ exampleFile: ".env.example",
69
+ appBridgeFile: "app/.env",
70
+ bridgeMode: "symlink-or-copy",
71
+ },
72
+ branches: {
73
+ development: config.DEFAULT_DEV_BRANCH,
74
+ publish: config.DEFAULT_PUBLISH_BRANCH,
75
+ },
76
+ publish: {
77
+ mode: "subtree-flatten",
78
+ sourceDir: config.DEFAULT_APP_DIR,
79
+ includeRootFiles: [".env.example"],
80
+ requireCleanWorktree: true,
81
+ },
82
+ };
83
+ }
84
+
85
+ function ensureRootGitignore(workspaceRoot) {
86
+ const gitignorePath = path.join(workspaceRoot, ".gitignore");
87
+ const required = ["/.env", "/app/.env", "/ops/.tmp/"];
88
+ let lines = [];
89
+ if (fs.existsSync(gitignorePath)) {
90
+ lines = fs.readFileSync(gitignorePath, "utf8").split(/\r?\n/);
91
+ }
92
+ for (const entry of required) {
93
+ if (!lines.includes(entry)) lines.push(entry);
94
+ }
95
+ fs.writeFileSync(gitignorePath, `${lines.filter(Boolean).join("\n")}\n`, "utf8");
96
+ }
97
+
98
+ function stripOpsScripts(packageFile) {
99
+ if (!fs.existsSync(packageFile)) return;
100
+ const pkg = JSON.parse(fs.readFileSync(packageFile, "utf8"));
101
+ if (!pkg.scripts) return;
102
+ ["ops", "ops:help", "ops:dashboard", "ops:status", "ops:next", "ops:sync", "ops:repo"].forEach((key) => {
103
+ delete pkg.scripts[key];
104
+ });
105
+ fs.writeFileSync(packageFile, `${JSON.stringify(pkg, null, 2)}\n`, "utf8");
106
+ }
107
+
108
+ function moveEntry(fromPath, toPath) {
109
+ if (!fs.existsSync(fromPath)) return;
110
+ fs.mkdirSync(path.dirname(toPath), { recursive: true });
111
+ try {
112
+ fs.renameSync(fromPath, toPath);
113
+ } catch (error) {
114
+ if (!isRetryableMoveError(error)) throw error;
115
+ const stat = fs.statSync(fromPath);
116
+ if (stat.isDirectory()) {
117
+ fs.cpSync(fromPath, toPath, { recursive: true, force: true });
118
+ fs.rmSync(fromPath, { recursive: true, force: true });
119
+ return;
120
+ }
121
+ fs.copyFileSync(fromPath, toPath);
122
+ fs.rmSync(fromPath, { force: true });
123
+ }
124
+ }
125
+
126
+ function shouldResumePartialMigration(root, manifest) {
127
+ if (!fs.existsSync(path.join(root, config.WORKSPACE_MANIFEST))) return false;
128
+ const excluded = new Set([
129
+ ".git",
130
+ config.WORKSPACE_MANIFEST,
131
+ manifest.appDir,
132
+ manifest.opsDir,
133
+ ".env",
134
+ ".env.example",
135
+ ]);
136
+ const hasPendingOps = OPS_ARTIFACTS.some((entry) => fs.existsSync(path.join(root, entry)));
137
+ const hasPendingAppEntries = fs.readdirSync(root, { withFileTypes: true })
138
+ .some((entry) => !excluded.has(entry.name));
139
+ return hasPendingOps || hasPendingAppEntries;
140
+ }
141
+
142
+ function migrateWorkspace(rootDir, options = {}) {
143
+ const resolved = config.resolveWorkspaceContext(rootDir);
144
+ if (!resolved) {
145
+ throw new Error("workspace migrate only applies to legacy TrackOps projects.");
146
+ }
147
+
148
+ const root = resolved.workspaceRoot;
149
+ let manifest;
150
+ if (resolved.layout === "legacy") {
151
+ manifest = buildManifest();
152
+ } else {
153
+ manifest = config.loadWorkspaceManifest(resolved) || buildManifest();
154
+ if (!shouldResumePartialMigration(root, manifest)) {
155
+ throw new Error("workspace migrate only applies to legacy TrackOps projects.");
156
+ }
157
+ }
158
+
159
+ assertCleanGit(root, options.allowDirty === true);
160
+ const backupBranch = createBackupBranch(root);
161
+
162
+ const appDir = path.join(root, manifest.appDir);
163
+ const opsDir = path.join(root, manifest.opsDir);
164
+ fs.mkdirSync(appDir, { recursive: true });
165
+ fs.mkdirSync(opsDir, { recursive: true });
166
+ config.saveWorkspaceManifest(config.createSplitContext(root, manifest), manifest);
167
+
168
+ for (const entry of OPS_ARTIFACTS) {
169
+ moveEntry(path.join(root, entry), path.join(opsDir, entry));
170
+ }
171
+
172
+ const excluded = new Set([
173
+ ".git",
174
+ config.WORKSPACE_MANIFEST,
175
+ manifest.appDir,
176
+ manifest.opsDir,
177
+ ".env",
178
+ ".env.example",
179
+ ]);
180
+
181
+ const topLevel = fs.readdirSync(root, { withFileTypes: true });
182
+ for (const entry of topLevel) {
183
+ if (excluded.has(entry.name)) continue;
184
+ moveEntry(path.join(root, entry.name), path.join(appDir, entry.name));
185
+ }
186
+
187
+ ensureRootGitignore(root);
188
+ stripOpsScripts(path.join(appDir, "package.json"));
189
+
190
+ const context = config.createSplitContext(root, manifest);
191
+ const control = config.loadControl(context);
192
+ control.meta = control.meta || {};
193
+ control.meta.workspace = {
194
+ layout: "split",
195
+ workspaceRoot: ".",
196
+ appDir: manifest.appDir,
197
+ opsDir: manifest.opsDir,
198
+ developmentBranch: manifest.branches.development,
199
+ publishBranch: manifest.branches.publish,
200
+ publishMode: manifest.publish.mode,
201
+ };
202
+ control.meta.environment = {
203
+ ...(control.meta.environment || {}),
204
+ rootEnvFile: ".env",
205
+ exampleFile: ".env.example",
206
+ appBridgeFile: "app/.env",
207
+ bridgeMode: "symlink-or-copy",
208
+ requiredKeys: control.meta.environment?.requiredKeys || [],
209
+ optionalKeys: control.meta.environment?.optionalKeys || [],
210
+ lastAuditAt: control.meta.environment?.lastAuditAt || null,
211
+ };
212
+ config.saveControl(context, control);
213
+ env.syncEnvironment(context, control);
214
+ const controlApi = require("./control");
215
+ controlApi.syncDocs(context, config.loadControl(context));
216
+ controlApi.refreshRepoRuntime(context, { quiet: true });
217
+
218
+ const hookConfig = git(["config", "core.hooksPath", "ops/.githooks"], root);
219
+ if (hookConfig.status !== 0) {
220
+ throw new Error(hookConfig.stderr || "Could not update git hooks path.");
221
+ }
222
+
223
+ registry.registerProject(root);
224
+ return { root, backupBranch, context };
225
+ }
226
+
227
+ function status(contextOrRoot) {
228
+ const context = config.ensureContext(contextOrRoot);
229
+ console.log("Workspace:");
230
+ console.log(` Layout: ${context.layout}`);
231
+ console.log(` Root: ${context.workspaceRoot}`);
232
+ console.log(` App: ${context.appRoot}`);
233
+ console.log(` Ops: ${context.opsRoot}`);
234
+ if (context.manifestFile) {
235
+ console.log(` Manifest: ${context.manifestFile}`);
236
+ }
237
+ console.log(` Control: ${context.controlFile}`);
238
+ }
239
+
240
+ function cmdStatus(root) {
241
+ status(root);
242
+ }
243
+
244
+ function cmdMigrate(root, args = []) {
245
+ const allowDirty = args.includes("--allow-dirty");
246
+ const result = migrateWorkspace(root, { allowDirty });
247
+ console.log(`Workspace migrated: ${result.root}`);
248
+ console.log(`Backup branch: ${result.backupBranch}`);
249
+ }
250
+
251
+ module.exports = {
252
+ OPS_ARTIFACTS,
253
+ buildManifest,
254
+ ensureRootGitignore,
255
+ stripOpsScripts,
256
+ migrateWorkspace,
257
+ status,
258
+ cmdStatus,
259
+ cmdMigrate,
260
+ };