@pleri/olam-cli 0.1.159 → 0.1.161

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 (88) hide show
  1. package/README.md +11 -0
  2. package/dist/agent-stream/agent-sdk-to-chunks.js +3 -0
  3. package/dist/agent-stream/driver-runner.js +9 -4
  4. package/dist/agent-stream/host-driver-launch.js +48 -0
  5. package/dist/commands/bootstrap.d.ts +15 -0
  6. package/dist/commands/bootstrap.d.ts.map +1 -1
  7. package/dist/commands/bootstrap.js +30 -1
  8. package/dist/commands/bootstrap.js.map +1 -1
  9. package/dist/commands/flywheel/check-persona-skeleton.d.ts +30 -2
  10. package/dist/commands/flywheel/check-persona-skeleton.d.ts.map +1 -1
  11. package/dist/commands/flywheel/check-persona-skeleton.js +143 -6
  12. package/dist/commands/flywheel/check-persona-skeleton.js.map +1 -1
  13. package/dist/commands/flywheel/diversity-check.d.ts +12 -2
  14. package/dist/commands/flywheel/diversity-check.d.ts.map +1 -1
  15. package/dist/commands/flywheel/diversity-check.js +56 -6
  16. package/dist/commands/flywheel/diversity-check.js.map +1 -1
  17. package/dist/commands/flywheel/index.d.ts.map +1 -1
  18. package/dist/commands/flywheel/index.js +2 -0
  19. package/dist/commands/flywheel/index.js.map +1 -1
  20. package/dist/commands/flywheel/install-shims.d.ts +36 -3
  21. package/dist/commands/flywheel/install-shims.d.ts.map +1 -1
  22. package/dist/commands/flywheel/install-shims.js +118 -7
  23. package/dist/commands/flywheel/install-shims.js.map +1 -1
  24. package/dist/commands/flywheel/k10-measure.d.ts +12 -2
  25. package/dist/commands/flywheel/k10-measure.d.ts.map +1 -1
  26. package/dist/commands/flywheel/k10-measure.js +55 -6
  27. package/dist/commands/flywheel/k10-measure.js.map +1 -1
  28. package/dist/commands/flywheel/migrate-overlays.d.ts +115 -0
  29. package/dist/commands/flywheel/migrate-overlays.d.ts.map +1 -0
  30. package/dist/commands/flywheel/migrate-overlays.js +766 -0
  31. package/dist/commands/flywheel/migrate-overlays.js.map +1 -0
  32. package/dist/commands/flywheel/sanitize-persona-output.d.ts +33 -2
  33. package/dist/commands/flywheel/sanitize-persona-output.d.ts.map +1 -1
  34. package/dist/commands/flywheel/sanitize-persona-output.js +94 -6
  35. package/dist/commands/flywheel/sanitize-persona-output.js.map +1 -1
  36. package/dist/commands/memory/index.d.ts.map +1 -1
  37. package/dist/commands/memory/index.js +2 -0
  38. package/dist/commands/memory/index.js.map +1 -1
  39. package/dist/commands/memory/install-hooks.d.ts +22 -0
  40. package/dist/commands/memory/install-hooks.d.ts.map +1 -0
  41. package/dist/commands/memory/install-hooks.js +156 -0
  42. package/dist/commands/memory/install-hooks.js.map +1 -0
  43. package/dist/commands/skills-doctor.js +2 -2
  44. package/dist/commands/skills-doctor.js.map +1 -1
  45. package/dist/commands/skills-source.d.ts.map +1 -1
  46. package/dist/commands/skills-source.js +10 -0
  47. package/dist/commands/skills-source.js.map +1 -1
  48. package/dist/commands/skills.d.ts.map +1 -1
  49. package/dist/commands/skills.js +169 -1
  50. package/dist/commands/skills.js.map +1 -1
  51. package/dist/image-digests.json +7 -7
  52. package/dist/index.js +4361 -1768
  53. package/dist/lib/bootstrap-kubernetes.d.ts +42 -0
  54. package/dist/lib/bootstrap-kubernetes.d.ts.map +1 -0
  55. package/dist/lib/bootstrap-kubernetes.js +287 -0
  56. package/dist/lib/bootstrap-kubernetes.js.map +1 -0
  57. package/dist/lib/config.d.ts.map +1 -1
  58. package/dist/lib/config.js +6 -1
  59. package/dist/lib/config.js.map +1 -1
  60. package/dist/lib/flywheel-probes.d.ts +58 -0
  61. package/dist/lib/flywheel-probes.d.ts.map +1 -0
  62. package/dist/lib/flywheel-probes.js +163 -0
  63. package/dist/lib/flywheel-probes.js.map +1 -0
  64. package/dist/lib/shim-generator.d.ts +51 -0
  65. package/dist/lib/shim-generator.d.ts.map +1 -0
  66. package/dist/lib/shim-generator.js +88 -0
  67. package/dist/lib/shim-generator.js.map +1 -0
  68. package/dist/lib/skills-apply-overlays.d.ts +35 -0
  69. package/dist/lib/skills-apply-overlays.d.ts.map +1 -0
  70. package/dist/lib/skills-apply-overlays.js +243 -0
  71. package/dist/lib/skills-apply-overlays.js.map +1 -0
  72. package/dist/mcp-server.js +1106 -453
  73. package/hermes-bundle/version.json +1 -1
  74. package/host-cp/k8s/manifests/50-deployment.yaml +1 -1
  75. package/host-cp/k8s/manifests/auth-service/50-deployment.yaml +1 -1
  76. package/host-cp/k8s/manifests/kg-service/50-deployment.yaml +1 -1
  77. package/host-cp/k8s/manifests/mcp-auth-service/50-deployment.yaml +1 -1
  78. package/host-cp/k8s/manifests/memory-service/30-configmap.yaml +11 -0
  79. package/host-cp/k8s/manifests/memory-service/35-configmap-iii-config.yaml +76 -0
  80. package/host-cp/k8s/manifests/memory-service/50-deployment.yaml +11 -1
  81. package/host-cp/observability/grafana-port-forward.sh +273 -0
  82. package/host-cp/observability/kyverno-cardinality-mutate.sh +452 -0
  83. package/host-cp/observability/loki-ingest.sh +243 -0
  84. package/host-cp/observability/prom-no-double-grafana.sh +301 -0
  85. package/host-cp/src/crystallize-planning.mjs +261 -0
  86. package/host-cp/src/plan-chat-service.mjs +84 -2
  87. package/host-cp/src/planning-sessions.mjs +270 -0
  88. package/package.json +1 -1
@@ -1,14 +1,64 @@
1
1
  /**
2
- * `olam flywheel diversity-check` — stub registered in task A1.
3
- * Implementation lands in task A8 (port from `shared/engineering/scripts/diversity_check.py`).
2
+ * `olam flywheel diversity-check` — cross-persona Jaccard similarity CLI.
3
+ *
4
+ * Reads persona-prompt files from a glob; computes pairwise Jaccard; reports
5
+ * pairs exceeding the threshold (default 0.7). Used by /10x:learn write-path
6
+ * to detect silent convergence collapse across K1 personas.
7
+ *
8
+ * Exit codes:
9
+ * 0 = no convergence (all pairs below threshold)
10
+ * 1 = convergence detected (one or more pairs above threshold)
11
+ * 2 = unexpected error (no matching files / read failure)
12
+ *
13
+ * Plan reference: docs/plans/olam-flywheel-cli-namespace/phase-a-tasks.md § A8
4
14
  */
15
+ import { readFileSync } from 'node:fs';
16
+ import { basename } from 'node:path';
17
+ import { globSync } from 'node:fs';
18
+ import { crossPersonaCheck, formatRedivergencePrompt, DIVERSITY_THRESHOLD, } from '@olam/core/src/lib/diversity-check.js';
5
19
  export function registerFlywheelDiversityCheck(parent) {
6
20
  parent
7
21
  .command('diversity-check')
8
- .description('Cross-plan breadcrumb diversity aggregator (stub implemented in task A8)')
9
- .action(() => {
10
- console.error('olam flywheel diversity-check: not yet implemented (task A8). See docs/plans/olam-flywheel-cli-namespace/phase-a-tasks.md');
11
- process.exit(2);
22
+ .description('Cross-persona Jaccard similarity guardflag persona pairs above threshold')
23
+ .requiredOption('--glob <pattern>', 'glob pattern matching persona-prompt files')
24
+ .option('--threshold <0.0-1.0>', 'Jaccard threshold (default 0.7)')
25
+ .option('--json', 'emit findings as JSON instead of human-readable')
26
+ .action((opts) => {
27
+ const threshold = opts.threshold !== undefined ? Number.parseFloat(opts.threshold) : DIVERSITY_THRESHOLD;
28
+ if (!Number.isFinite(threshold) || threshold < 0 || threshold > 1) {
29
+ process.stderr.write(`[diversity-check-reject] --threshold must be 0.0-1.0; got ${JSON.stringify(opts.threshold)}\n`);
30
+ process.exit(2);
31
+ }
32
+ // Use Node 22+'s native glob (no extra dep).
33
+ const files = globSync(opts.glob);
34
+ if (files.length === 0) {
35
+ process.stderr.write(`[diversity-check-reject] no files matched glob: ${opts.glob}\n`);
36
+ process.exit(2);
37
+ }
38
+ const personas = new Map();
39
+ for (const filepath of files) {
40
+ try {
41
+ const body = readFileSync(filepath, 'utf8');
42
+ if (body.trim().length > 0) {
43
+ personas.set(basename(filepath, '.md'), body);
44
+ }
45
+ }
46
+ catch (err) {
47
+ process.stderr.write(`[diversity-check-error] cannot read ${filepath}: ${err instanceof Error ? err.message : 'unknown'}\n`);
48
+ process.exit(2);
49
+ }
50
+ }
51
+ const flagged = crossPersonaCheck(personas, threshold);
52
+ if (opts.json) {
53
+ process.stdout.write(JSON.stringify({ threshold, persona_count: personas.size, flagged }) + '\n');
54
+ }
55
+ else {
56
+ process.stdout.write(`[diversity-check] ${personas.size} personas; threshold ${threshold}; ${flagged.length} pair(s) over threshold\n`);
57
+ for (const { persona_a, persona_b, score } of flagged) {
58
+ process.stdout.write(`\n${formatRedivergencePrompt(persona_a, persona_b, score, undefined, undefined, threshold)}\n`);
59
+ }
60
+ }
61
+ process.exit(flagged.length > 0 ? 1 : 0);
12
62
  });
13
63
  }
14
64
  //# sourceMappingURL=diversity-check.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"diversity-check.js","sourceRoot":"","sources":["../../../src/commands/flywheel/diversity-check.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,MAAM,UAAU,8BAA8B,CAAC,MAAe;IAC5D,MAAM;SACH,OAAO,CAAC,iBAAiB,CAAC;SAC1B,WAAW,CAAC,4EAA4E,CAAC;SACzF,MAAM,CAAC,GAAG,EAAE;QACX,OAAO,CAAC,KAAK,CACX,2HAA2H,CAC5H,CAAC;QACF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC,CAAC,CAAC;AACP,CAAC"}
1
+ {"version":3,"file":"diversity-check.js","sourceRoot":"","sources":["../../../src/commands/flywheel/diversity-check.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAEnC,OAAO,EACL,iBAAiB,EACjB,wBAAwB,EACxB,mBAAmB,GACpB,MAAM,uCAAuC,CAAC;AAQ/C,MAAM,UAAU,8BAA8B,CAAC,MAAe;IAC5D,MAAM;SACH,OAAO,CAAC,iBAAiB,CAAC;SAC1B,WAAW,CAAC,6EAA6E,CAAC;SAC1F,cAAc,CAAC,kBAAkB,EAAE,4CAA4C,CAAC;SAChF,MAAM,CAAC,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AEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAWzC,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAgBvD"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/flywheel/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAYzC,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAiBvD"}
@@ -31,6 +31,7 @@ import { registerFlywheelCheckPersonaSkeleton } from './check-persona-skeleton.j
31
31
  import { registerFlywheelDiversityCheck } from './diversity-check.js';
32
32
  import { registerFlywheelPing } from './ping.js';
33
33
  import { registerFlywheelInstallShims } from './install-shims.js';
34
+ import { registerFlywheelMigrateOverlays } from './migrate-overlays.js';
34
35
  export function registerFlywheel(program) {
35
36
  const flywheel = program
36
37
  .command('flywheel')
@@ -44,5 +45,6 @@ export function registerFlywheel(program) {
44
45
  registerFlywheelDiversityCheck(flywheel);
45
46
  registerFlywheelPing(flywheel);
46
47
  registerFlywheelInstallShims(flywheel);
48
+ registerFlywheelMigrateOverlays(flywheel);
47
49
  }
48
50
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/flywheel/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAGH,OAAO,EAAE,8BAA8B,EAAE,MAAM,sBAAsB,CAAC;AACtE,OAAO,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AACxD,OAAO,EAAE,0BAA0B,EAAE,MAAM,kBAAkB,CAAC;AAC9D,OAAO,EAAE,0BAA0B,EAAE,MAAM,kBAAkB,CAAC;AAC9D,OAAO,EAAE,qCAAqC,EAAE,MAAM,8BAA8B,CAAC;AACrF,OAAO,EAAE,oCA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AAC;AACjD,OAAO,EAAE,4BAA4B,EAAE,MAAM,oBAAoB,CAAC;AAClE,OAAO,EAAE,+BAA+B,EAAE,MAAM,uBAAuB,CAAC;AAExE,MAAM,UAAU,gBAAgB,CAAC,OAAgB;IAC/C,MAAM,QAAQ,GAAG,OAAO;SACrB,OAAO,CAAC,UAAU,CAAC;SACnB,WAAW,CACV,qNAAqN,CACtN,CAAC;IAEJ,8BAA8B,CAAC,QAAQ,CAAC,CAAC;IACzC,uBAAuB,CAAC,QAAQ,CAAC,CAAC;IAClC,0BAA0B,CAAC,QAAQ,CAAC,CAAC;IACrC,0BAA0B,CAAC,QAAQ,CAAC,CAAC;IACrC,qCAAqC,CAAC,QAAQ,CAAC,CAAC;IAChD,oCAAoC,CAAC,QAAQ,CAAC,CAAC;IAC/C,8BAA8B,CAAC,QAAQ,CAAC,CAAC;IACzC,oBAAoB,CAAC,QAAQ,CAAC,CAAC;IAC/B,4BAA4B,CAAC,QAAQ,CAAC,CAAC;IACvC,+BAA+B,CAAC,QAAQ,CAAC,CAAC;AAC5C,CAAC"}
@@ -1,8 +1,41 @@
1
1
  /**
2
- * `olam flywheel install-shims` — stub registered in task A1.
3
- * Implementation lands in task A14 (writes delegating shims to ~/.claude/scripts/<name>;
4
- * detects existing non-shim files; auto-invoked as post-step in `olam skills source pull`).
2
+ * `olam flywheel install-shims` — write backwards-compat shims to ~/.claude/scripts/.
3
+ *
4
+ * Generates a bash shim per spec in SHIM_SPECS and writes it to
5
+ * ~/.claude/scripts/<basename>. Detects existing non-shim files (operator's
6
+ * own scripts or atlas-toolbox-shipped originals) and prompts/backs-up
7
+ * before overwriting. Idempotent — re-runs produce no diff when content
8
+ * matches.
9
+ *
10
+ * Replaces the A1 stub.
11
+ *
12
+ * Plan reference: docs/plans/olam-flywheel-cli-namespace/phase-a-tasks.md § A14
13
+ * Closes part of K1 OQ20 (correct hook-point for shim installation).
5
14
  */
6
15
  import type { Command } from 'commander';
16
+ export interface InstallShimsOptions {
17
+ force?: boolean;
18
+ dryRun?: boolean;
19
+ targetDir?: string;
20
+ }
21
+ export interface ShimInstallStatus {
22
+ basename: string;
23
+ action: 'written' | 'overwritten' | 'unchanged' | 'preserved-existing';
24
+ targetPath: string;
25
+ backupPath?: string;
26
+ }
27
+ export interface RefreshShimsResult {
28
+ results: ShimInstallStatus[];
29
+ written: number;
30
+ overwritten: number;
31
+ unchanged: number;
32
+ preserved: number;
33
+ }
34
+ /**
35
+ * Programmatic API for refreshing all shims. Used by:
36
+ * - `olam flywheel install-shims` CLI action (this file).
37
+ * - `olam skills source pull` post-step (B2 hook point).
38
+ */
39
+ export declare function refreshShims(opts?: InstallShimsOptions): RefreshShimsResult;
7
40
  export declare function registerFlywheelInstallShims(parent: Command): void;
8
41
  //# sourceMappingURL=install-shims.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"install-shims.d.ts","sourceRoot":"","sources":["../../../src/commands/flywheel/install-shims.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEzC,wBAAgB,4BAA4B,CAAC,MAAM,EAAE,OAAO,GAAG,IAAI,CAUlE"}
1
+ {"version":3,"file":"install-shims.d.ts","sourceRoot":"","sources":["../../../src/commands/flywheel/install-shims.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAKH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAKzC,MAAM,WAAW,mBAAmB;IAClC,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,iBAAiB;IAChC,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,SAAS,GAAG,aAAa,GAAG,WAAW,GAAG,oBAAoB,CAAC;IACvE,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,iBAAiB,EAAE,CAAC;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,IAAI,GAAE,mBAAwB,GAAG,kBAAkB,CAkB/E;AA8CD,wBAAgB,4BAA4B,CAAC,MAAM,EAAE,OAAO,GAAG,IAAI,CAoClE"}
@@ -1,15 +1,126 @@
1
1
  /**
2
- * `olam flywheel install-shims` — stub registered in task A1.
3
- * Implementation lands in task A14 (writes delegating shims to ~/.claude/scripts/<name>;
4
- * detects existing non-shim files; auto-invoked as post-step in `olam skills source pull`).
2
+ * `olam flywheel install-shims` — write backwards-compat shims to ~/.claude/scripts/.
3
+ *
4
+ * Generates a bash shim per spec in SHIM_SPECS and writes it to
5
+ * ~/.claude/scripts/<basename>. Detects existing non-shim files (operator's
6
+ * own scripts or atlas-toolbox-shipped originals) and prompts/backs-up
7
+ * before overwriting. Idempotent — re-runs produce no diff when content
8
+ * matches.
9
+ *
10
+ * Replaces the A1 stub.
11
+ *
12
+ * Plan reference: docs/plans/olam-flywheel-cli-namespace/phase-a-tasks.md § A14
13
+ * Closes part of K1 OQ20 (correct hook-point for shim installation).
5
14
  */
15
+ import { copyFileSync, existsSync, mkdirSync, readFileSync, statSync, writeFileSync } from 'node:fs';
16
+ import { homedir } from 'node:os';
17
+ import { dirname, join } from 'node:path';
18
+ import { SHIM_SPECS, generateShim } from '../../lib/shim-generator.js';
19
+ const SHIM_HEADER_MARKER = '# AUTO-GENERATED by `olam flywheel install-shims`';
20
+ /**
21
+ * Programmatic API for refreshing all shims. Used by:
22
+ * - `olam flywheel install-shims` CLI action (this file).
23
+ * - `olam skills source pull` post-step (B2 hook point).
24
+ */
25
+ export function refreshShims(opts = {}) {
26
+ const targetDir = opts.targetDir ?? join(homedir(), '.claude', 'scripts');
27
+ const results = [];
28
+ let written = 0;
29
+ let overwritten = 0;
30
+ let unchanged = 0;
31
+ let preserved = 0;
32
+ for (const spec of SHIM_SPECS) {
33
+ const result = installOne(spec, targetDir, opts);
34
+ results.push(result);
35
+ switch (result.action) {
36
+ case 'written':
37
+ written += 1;
38
+ break;
39
+ case 'overwritten':
40
+ overwritten += 1;
41
+ break;
42
+ case 'unchanged':
43
+ unchanged += 1;
44
+ break;
45
+ case 'preserved-existing':
46
+ preserved += 1;
47
+ break;
48
+ }
49
+ }
50
+ return { results, written, overwritten, unchanged, preserved };
51
+ }
52
+ function isOlamGeneratedShim(text) {
53
+ return text.includes(SHIM_HEADER_MARKER);
54
+ }
55
+ function installOne(spec, targetDir, opts) {
56
+ const targetPath = join(targetDir, spec.basename);
57
+ const newContent = generateShim(spec);
58
+ if (!existsSync(targetPath)) {
59
+ if (opts.dryRun !== true) {
60
+ mkdirSync(dirname(targetPath), { recursive: true });
61
+ writeFileSync(targetPath, newContent, { mode: 0o755 });
62
+ }
63
+ return { basename: spec.basename, action: 'written', targetPath };
64
+ }
65
+ const existing = readFileSync(targetPath, 'utf8');
66
+ if (existing === newContent) {
67
+ return { basename: spec.basename, action: 'unchanged', targetPath };
68
+ }
69
+ // Existing file with different content. If it's our generated shim (older
70
+ // version), overwrite freely. Otherwise it's operator/atlas-toolbox content
71
+ // — back up unless --force.
72
+ if (isOlamGeneratedShim(existing)) {
73
+ if (opts.dryRun !== true) {
74
+ writeFileSync(targetPath, newContent, { mode: 0o755 });
75
+ }
76
+ return { basename: spec.basename, action: 'overwritten', targetPath };
77
+ }
78
+ if (opts.force === true) {
79
+ const backupPath = `${targetPath}.shim-backup-${Math.floor(Date.now() / 1000)}`;
80
+ if (opts.dryRun !== true) {
81
+ copyFileSync(targetPath, backupPath);
82
+ writeFileSync(targetPath, newContent, { mode: 0o755 });
83
+ }
84
+ return { basename: spec.basename, action: 'overwritten', targetPath, backupPath };
85
+ }
86
+ // Without --force, preserve existing.
87
+ return { basename: spec.basename, action: 'preserved-existing', targetPath };
88
+ }
6
89
  export function registerFlywheelInstallShims(parent) {
7
90
  parent
8
91
  .command('install-shims')
9
- .description('Write delegating shims to ~/.claude/scripts/<name> (stub implemented in task A14)')
10
- .action(() => {
11
- console.error('olam flywheel install-shims: not yet implemented (task A14). See docs/plans/olam-flywheel-cli-namespace/phase-a-tasks.md');
12
- process.exit(2);
92
+ .description('Install backwards-compat bash shims under ~/.claude/scripts/ that delegate to olam flywheel <subcmd>')
93
+ .option('--force', 'overwrite existing non-shim files (backs them up to .shim-backup-<ts>)')
94
+ .option('--dry-run', 'preview which shims would be written without modifying disk')
95
+ .option('--target-dir <path>', 'override target directory (default: ~/.claude/scripts/); for tests')
96
+ .action((opts) => {
97
+ const targetDir = opts.targetDir ?? join(homedir(), '.claude', 'scripts');
98
+ const summary = refreshShims(opts);
99
+ const lines = [];
100
+ const dryRunSuffix = opts.dryRun === true ? ' (dry-run)' : '';
101
+ for (const result of summary.results) {
102
+ switch (result.action) {
103
+ case 'written':
104
+ lines.push(` WRITTEN ${result.targetPath}${dryRunSuffix}`);
105
+ break;
106
+ case 'overwritten':
107
+ lines.push(` OVERWRITTEN ${result.targetPath}${dryRunSuffix}${result.backupPath !== undefined ? ` (backup: ${result.backupPath})` : ''}`);
108
+ break;
109
+ case 'unchanged':
110
+ lines.push(` UNCHANGED ${result.targetPath}`);
111
+ break;
112
+ case 'preserved-existing':
113
+ lines.push(` PRESERVED ${result.targetPath} (existing non-shim file; use --force to overwrite + backup)`);
114
+ break;
115
+ }
116
+ }
117
+ process.stdout.write(`olam flywheel install-shims → ${targetDir}\n`);
118
+ for (const line of lines)
119
+ process.stdout.write(line + '\n');
120
+ process.stdout.write(`\nwritten: ${summary.written}, overwritten: ${summary.overwritten}, unchanged: ${summary.unchanged}, preserved: ${summary.preserved}\n`);
121
+ // Preserved files indicate operator action needed; exit 1 to surface.
122
+ if (summary.preserved > 0)
123
+ process.exit(1);
13
124
  });
14
125
  }
15
126
  //# sourceMappingURL=install-shims.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"install-shims.js","sourceRoot":"","sources":["../../../src/commands/flywheel/install-shims.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,MAAM,UAAU,4BAA4B,CAAC,MAAe;IAC1D,MAAM;SACH,OAAO,CAAC,eAAe,CAAC;SACxB,WAAW,CAAC,qFAAqF,CAAC;SAClG,MAAM,CAAC,GAAG,EAAE;QACX,OAAO,CAAC,KAAK,CACX,0HAA0H,CAC3H,CAAC;QACF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC,CAAC,CAAC;AACP,CAAC"}
1
+ {"version":3,"file":"install-shims.js","sourceRoot":"","sources":["../../../src/commands/flywheel/install-shims.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACrG,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAE1C,OAAO,EAAE,UAAU,EAAE,YAAY,EAAiB,MAAM,6BAA6B,CAAC;AAEtF,MAAM,kBAAkB,GAAG,mDAAmD,CAAC;AAuB/E;;;;GAIG;AACH,MAAM,UAAU,YAAY,CAAC,OAA4B,EAAE;IACzD,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,IAAI,IAAI,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC;IAC1E,MAAM,OAAO,GAAwB,EAAE,CAAC;IACxC,IAAI,OAAO,GAAG,CAAC,CAAC;IAChB,IAAI,WAAW,GAAG,CAAC,CAAC;IACpB,IAAI,SAAS,GAAG,CAAC,CAAC;IAClB,IAAI,SAAS,GAAG,CAAC,CAAC;IAClB,KAAK,MAAM,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AAM,CAAC,UAAU,8DAA8D,CAAC,CAAC;oBAC7G,MAAM;YACV,CAAC;QACH,CAAC;QACD,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,iCAAiC,SAAS,IAAI,CAAC,CAAC;QACrE,KAAK,MAAM,IAAI,IAAI,KAAK;YAAE,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC;QAC5D,OAAO,CAAC,MAAM,CAAC,KAAK,CAClB,cAAc,OAAO,CAAC,OAAO,kBAAkB,OAAO,CAAC,WAAW,gBAAgB,OAAO,CAAC,SAAS,gBAAgB,OAAO,CAAC,SAAS,IAAI,CACzI,CAAC;QACF,sEAAsE;QACtE,IAAI,OAAO,CAAC,SAAS,GAAG,CAAC;YAAE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAC7C,CAAC,CAAC,CAAC;AACP,CAAC"}
@@ -1,6 +1,16 @@
1
1
  /**
2
- * `olam flywheel k10-measure` — stub registered in task A1.
3
- * Implementation lands in task A5 (port from `shared/engineering/scripts/k10_budget.py`).
2
+ * `olam flywheel k10-measure` — K10 token-budget measurement CLI.
3
+ *
4
+ * Reads `--upstream <path>` + optional `--overlay <path>`; counts tokens via
5
+ * the len/CHARS_PER_TOKEN heuristic; emits PASS/REJECT verdict matching the
6
+ * Python predecessor's compute_budget contract.
7
+ *
8
+ * Exit codes:
9
+ * 0 = PASS (within budget OR no overlay)
10
+ * 1 = REJECT (over budget)
11
+ * 2 = unexpected error (cannot read upstream file)
12
+ *
13
+ * Plan reference: docs/plans/olam-flywheel-cli-namespace/phase-a-tasks.md § A5
4
14
  */
5
15
  import type { Command } from 'commander';
6
16
  export declare function registerFlywheelK10Measure(parent: Command): void;
@@ -1 +1 @@
1
- {"version":3,"file":"k10-measure.d.ts","sourceRoot":"","sources":["../../../src/commands/flywheel/k10-measure.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEzC,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,OAAO,GAAG,IAAI,CAUhE"}
1
+ {"version":3,"file":"k10-measure.d.ts","sourceRoot":"","sources":["../../../src/commands/flywheel/k10-measure.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAGH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AASzC,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,OAAO,GAAG,IAAI,CAgDhE"}
@@ -1,14 +1,63 @@
1
1
  /**
2
- * `olam flywheel k10-measure` — stub registered in task A1.
3
- * Implementation lands in task A5 (port from `shared/engineering/scripts/k10_budget.py`).
2
+ * `olam flywheel k10-measure` — K10 token-budget measurement CLI.
3
+ *
4
+ * Reads `--upstream <path>` + optional `--overlay <path>`; counts tokens via
5
+ * the len/CHARS_PER_TOKEN heuristic; emits PASS/REJECT verdict matching the
6
+ * Python predecessor's compute_budget contract.
7
+ *
8
+ * Exit codes:
9
+ * 0 = PASS (within budget OR no overlay)
10
+ * 1 = REJECT (over budget)
11
+ * 2 = unexpected error (cannot read upstream file)
12
+ *
13
+ * Plan reference: docs/plans/olam-flywheel-cli-namespace/phase-a-tasks.md § A5
4
14
  */
15
+ import { readFileSync } from 'node:fs';
16
+ import { computeBudget, tokensFromText } from '@olam/core/src/lib/k10-budget.js';
5
17
  export function registerFlywheelK10Measure(parent) {
6
18
  parent
7
19
  .command('k10-measure')
8
- .description('Compute K1 budget ratio from plan + persona output (stub implemented in task A5)')
9
- .action(() => {
10
- console.error('olam flywheel k10-measure: not yet implemented (task A5). See docs/plans/olam-flywheel-cli-namespace/phase-a-tasks.md');
11
- process.exit(2);
20
+ .description('Measure K10 token budget for upstream + optional overlay; emit PASS/REJECT verdict')
21
+ .requiredOption('--upstream <path>', 'path to upstream file (e.g. persona prompt)')
22
+ .option('--overlay <path>', 'path to overlay file (omit if none — PASS without enforcement)')
23
+ .option('--json', 'emit verdict as JSON instead of human-readable')
24
+ .action((opts) => {
25
+ let upstreamText;
26
+ try {
27
+ upstreamText = readFileSync(opts.upstream, 'utf8');
28
+ }
29
+ catch (err) {
30
+ process.stderr.write(`[k10-measure-error] cannot read upstream ${opts.upstream}: ${err instanceof Error ? err.message : 'unknown'}\n`);
31
+ process.exit(2);
32
+ }
33
+ const upstreamTokens = tokensFromText(upstreamText);
34
+ let overlayTokens = null;
35
+ if (opts.overlay !== undefined) {
36
+ try {
37
+ const overlayText = readFileSync(opts.overlay, 'utf8');
38
+ overlayTokens = tokensFromText(overlayText);
39
+ }
40
+ catch (err) {
41
+ process.stderr.write(`[k10-measure-error] cannot read overlay ${opts.overlay}: ${err instanceof Error ? err.message : 'unknown'}\n`);
42
+ process.exit(2);
43
+ }
44
+ }
45
+ const result = computeBudget(upstreamTokens, overlayTokens);
46
+ if (opts.json) {
47
+ process.stdout.write(JSON.stringify(result) + '\n');
48
+ }
49
+ else {
50
+ process.stdout.write(`${result.verdict}: ${result.message}\n`);
51
+ process.stdout.write(` upstream_tokens: ${result.upstream_tokens}\n`);
52
+ if (result.overlay_tokens !== null) {
53
+ process.stdout.write(` overlay_tokens: ${result.overlay_tokens}\n`);
54
+ }
55
+ if (result.merged !== null) {
56
+ process.stdout.write(` merged: ${result.merged}\n`);
57
+ }
58
+ process.stdout.write(` remaining: ${result.remaining} of ${5500} cap\n`);
59
+ }
60
+ process.exit(result.verdict === 'PASS' ? 0 : 1);
12
61
  });
13
62
  }
14
63
  //# sourceMappingURL=k10-measure.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"k10-measure.js","sourceRoot":"","sources":["../../../src/commands/flywheel/k10-measure.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,MAAM,UAAU,0BAA0B,CAAC,MAAe;IACxD,MAAM;SACH,OAAO,CAAC,aAAa,CAAC;SACtB,WAAW,CAAC,oFAAoF,CAAC;SACjG,MAAM,CAAC,GAAG,EAAE;QACX,OAAO,CAAC,KAAK,CACX,uHAAuH,CACxH,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AAO,KAAK,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAClD,CAAC,CAAC,CAAC;AACP,CAAC"}
@@ -0,0 +1,115 @@
1
+ /**
2
+ * `olam flywheel migrate-overlays` — operator-local overlay-layer migration.
3
+ *
4
+ * Scans `~/.claude/{skills,agents}.overrides/` recursively for hardcoded
5
+ * `~/.claude/scripts/<name>` references matching the SHIM_TARGETS registry;
6
+ * sed-replaces each match with the corresponding `olam flywheel <subcmd>`
7
+ * invocation. Each operator runs this once to migrate THEIR layer 3
8
+ * (per-user overlay files) from the legacy script-path contract to the new
9
+ * flywheel CLI surface.
10
+ *
11
+ * Closes K1 OQ23 (pass-3 resolution): the migration helper that scales
12
+ * the namespace migration beyond just this operator's overlays. Each
13
+ * operator with their own `.overrides/` tree runs this command once.
14
+ *
15
+ * Replaces:
16
+ * `bash ~/.claude/scripts/emit-breadcrumb.sh ...` → `olam flywheel emit-breadcrumb ...`
17
+ * `python3 ~/.claude/scripts/sanitize-persona-output.py ...` → `olam flywheel sanitize-persona-output ...`
18
+ * `~/.claude/scripts/k5-rubric-helper.py` → `olam flywheel k5-validate`
19
+ * etc. (full set per SHIM_TARGETS registry at @olam/core/lib/shim-targets)
20
+ *
21
+ * Flags:
22
+ * --dry-run — preview changes without writing
23
+ * --target-dir <path> — override the search root (default: ~/.claude/); for tests
24
+ * --json — emit summary as JSON for tooling
25
+ *
26
+ * --push — PUSH mode: copy overlays into atlas-toolbox clone
27
+ * --target <name> — required with --push; name of a registered skill source
28
+ *
29
+ * Idempotent: re-runs against already-migrated overlays produce no diff.
30
+ *
31
+ * Plan reference: docs/plans/olam-flywheel-cli-namespace/phase-c-tasks.md § C7
32
+ * Phase B: docs/plans/member-overlays-sync/phase-b-tasks.md
33
+ */
34
+ import type { Command } from 'commander';
35
+ interface MigrateOverlaysOptions {
36
+ dryRun?: boolean;
37
+ targetDir?: string;
38
+ json?: boolean;
39
+ push?: boolean;
40
+ target?: string;
41
+ forceCurrentBranch?: boolean;
42
+ initMember?: string;
43
+ /** For tests: inject clone path directly instead of reading from registry. */
44
+ _testClonePath?: string;
45
+ /** For tests: inject atlas-user directly instead of reading ~/.claude/.atlas-user. */
46
+ _testAtlasUser?: string;
47
+ /** For tests: override OLAM_CLAUDE_DIR for resolveAtlasUser. */
48
+ _testClaudeDir?: string;
49
+ /** For tests: inject git URLs by source name. */
50
+ _testSkillSources?: Array<{
51
+ id: string;
52
+ name: string;
53
+ gitUrl: string;
54
+ branch: string;
55
+ addedAt: number;
56
+ }>;
57
+ }
58
+ interface FileMigrationResult {
59
+ path: string;
60
+ replacements: Array<{
61
+ basename: string;
62
+ count: number;
63
+ replacedBy: string;
64
+ }>;
65
+ totalReplacements: number;
66
+ }
67
+ interface MigrationSummary {
68
+ scanned: number;
69
+ modified: number;
70
+ unchanged: number;
71
+ totalReplacements: number;
72
+ perFile: FileMigrationResult[];
73
+ }
74
+ export interface PushSummary {
75
+ filesCopied: number;
76
+ filesUnchanged: number;
77
+ filesCreated: number;
78
+ branchName: string;
79
+ nextStepGhCommand: string;
80
+ /** Full copy-paste block for stdout in human mode; populated only on real (non-dry-run) run. */
81
+ _copyPasteBlock?: string;
82
+ }
83
+ export interface InitMemberSummary {
84
+ memberName: string;
85
+ branchName: string;
86
+ nextStepGhCommand: string;
87
+ /** Paths created or would-create in dry-run. */
88
+ createdPaths: string[];
89
+ /** Full copy-paste block for stdout in human mode; absent in dry-run. */
90
+ _copyPasteBlock?: string;
91
+ }
92
+ /**
93
+ * Error thrown by push-mode operations. Carries an exit code so callers
94
+ * can distinguish between different failure scenarios.
95
+ */
96
+ export declare class PushError extends Error {
97
+ readonly exitCode: number;
98
+ constructor(exitCode: number, message: string);
99
+ }
100
+ /**
101
+ * Core push-overlays implementation (Phase B).
102
+ * Returns PushSummary. Throws PushError on validation/pre-flight failures
103
+ * (lets callers handle process.exit vs test assertions cleanly).
104
+ */
105
+ export declare function pushOverlays(opts: MigrateOverlaysOptions): PushSummary;
106
+ /**
107
+ * Scaffold members/<name>/{skills,agents}.overrides/.gitkeep + README.md
108
+ * in the atlas-toolbox clone. Leaves the working tree dirty.
109
+ * Throws PushError on validation / pre-flight / idempotency failures.
110
+ */
111
+ export declare function initMember(opts: MigrateOverlaysOptions): InitMemberSummary;
112
+ export declare function migrateOverlays(opts?: MigrateOverlaysOptions): MigrationSummary;
113
+ export declare function registerFlywheelMigrateOverlays(parent: Command): void;
114
+ export {};
115
+ //# sourceMappingURL=migrate-overlays.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"migrate-overlays.d.ts","sourceRoot":"","sources":["../../../src/commands/flywheel/migrate-overlays.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAcH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAWzC,UAAU,sBAAsB;IAC9B,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,OAAO,CAAC;IAEf,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAE7B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,8EAA8E;IAC9E,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,sFAAsF;IACtF,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,gEAAgE;IAChE,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,iDAAiD;IACjD,iBAAiB,CAAC,EAAE,KAAK,CAAC;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CAC1G;AAED,UAAU,mBAAmB;IAC3B,IAAI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