@groundnuty/macf 0.2.0-rc.0

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 (124) hide show
  1. package/dist/.build-info.json +4 -0
  2. package/dist/cli/build-info.d.ts +38 -0
  3. package/dist/cli/build-info.d.ts.map +1 -0
  4. package/dist/cli/build-info.js +119 -0
  5. package/dist/cli/build-info.js.map +1 -0
  6. package/dist/cli/claude-sh.d.ts +42 -0
  7. package/dist/cli/claude-sh.d.ts.map +1 -0
  8. package/dist/cli/claude-sh.js +247 -0
  9. package/dist/cli/claude-sh.js.map +1 -0
  10. package/dist/cli/commands/cd.d.ts +6 -0
  11. package/dist/cli/commands/cd.d.ts.map +1 -0
  12. package/dist/cli/commands/cd.js +17 -0
  13. package/dist/cli/commands/cd.js.map +1 -0
  14. package/dist/cli/commands/certs.d.ts +33 -0
  15. package/dist/cli/commands/certs.d.ts.map +1 -0
  16. package/dist/cli/commands/certs.js +233 -0
  17. package/dist/cli/commands/certs.js.map +1 -0
  18. package/dist/cli/commands/doctor.d.ts +91 -0
  19. package/dist/cli/commands/doctor.d.ts.map +1 -0
  20. package/dist/cli/commands/doctor.js +235 -0
  21. package/dist/cli/commands/doctor.js.map +1 -0
  22. package/dist/cli/commands/init.d.ts +37 -0
  23. package/dist/cli/commands/init.d.ts.map +1 -0
  24. package/dist/cli/commands/init.js +279 -0
  25. package/dist/cli/commands/init.js.map +1 -0
  26. package/dist/cli/commands/list.d.ts +5 -0
  27. package/dist/cli/commands/list.d.ts.map +1 -0
  28. package/dist/cli/commands/list.js +21 -0
  29. package/dist/cli/commands/list.js.map +1 -0
  30. package/dist/cli/commands/migrate-ca-key.d.ts +36 -0
  31. package/dist/cli/commands/migrate-ca-key.d.ts.map +1 -0
  32. package/dist/cli/commands/migrate-ca-key.js +92 -0
  33. package/dist/cli/commands/migrate-ca-key.js.map +1 -0
  34. package/dist/cli/commands/peers.d.ts +8 -0
  35. package/dist/cli/commands/peers.d.ts.map +1 -0
  36. package/dist/cli/commands/peers.js +45 -0
  37. package/dist/cli/commands/peers.js.map +1 -0
  38. package/dist/cli/commands/repo-init.d.ts +43 -0
  39. package/dist/cli/commands/repo-init.d.ts.map +1 -0
  40. package/dist/cli/commands/repo-init.js +304 -0
  41. package/dist/cli/commands/repo-init.js.map +1 -0
  42. package/dist/cli/commands/rules-refresh.d.ts +14 -0
  43. package/dist/cli/commands/rules-refresh.d.ts.map +1 -0
  44. package/dist/cli/commands/rules-refresh.js +67 -0
  45. package/dist/cli/commands/rules-refresh.js.map +1 -0
  46. package/dist/cli/commands/self-update.d.ts +14 -0
  47. package/dist/cli/commands/self-update.d.ts.map +1 -0
  48. package/dist/cli/commands/self-update.js +112 -0
  49. package/dist/cli/commands/self-update.js.map +1 -0
  50. package/dist/cli/commands/status.d.ts +9 -0
  51. package/dist/cli/commands/status.d.ts.map +1 -0
  52. package/dist/cli/commands/status.js +90 -0
  53. package/dist/cli/commands/status.js.map +1 -0
  54. package/dist/cli/commands/update.d.ts +25 -0
  55. package/dist/cli/commands/update.d.ts.map +1 -0
  56. package/dist/cli/commands/update.js +316 -0
  57. package/dist/cli/commands/update.js.map +1 -0
  58. package/dist/cli/config.d.ts +103 -0
  59. package/dist/cli/config.d.ts.map +1 -0
  60. package/dist/cli/config.js +224 -0
  61. package/dist/cli/config.js.map +1 -0
  62. package/dist/cli/index.d.ts +3 -0
  63. package/dist/cli/index.d.ts.map +1 -0
  64. package/dist/cli/index.js +245 -0
  65. package/dist/cli/index.js.map +1 -0
  66. package/dist/cli/plugin-fetcher.d.ts +20 -0
  67. package/dist/cli/plugin-fetcher.d.ts.map +1 -0
  68. package/dist/cli/plugin-fetcher.js +83 -0
  69. package/dist/cli/plugin-fetcher.js.map +1 -0
  70. package/dist/cli/prompt.d.ts +17 -0
  71. package/dist/cli/prompt.d.ts.map +1 -0
  72. package/dist/cli/prompt.js +109 -0
  73. package/dist/cli/prompt.js.map +1 -0
  74. package/dist/cli/registry-helper.d.ts +11 -0
  75. package/dist/cli/registry-helper.d.ts.map +1 -0
  76. package/dist/cli/registry-helper.js +18 -0
  77. package/dist/cli/registry-helper.js.map +1 -0
  78. package/dist/cli/rules.d.ts +39 -0
  79. package/dist/cli/rules.d.ts.map +1 -0
  80. package/dist/cli/rules.js +112 -0
  81. package/dist/cli/rules.js.map +1 -0
  82. package/dist/cli/settings-writer.d.ts +97 -0
  83. package/dist/cli/settings-writer.d.ts.map +1 -0
  84. package/dist/cli/settings-writer.js +270 -0
  85. package/dist/cli/settings-writer.js.map +1 -0
  86. package/dist/cli/version-resolver.d.ts +73 -0
  87. package/dist/cli/version-resolver.d.ts.map +1 -0
  88. package/dist/cli/version-resolver.js +238 -0
  89. package/dist/cli/version-resolver.js.map +1 -0
  90. package/dist/index.d.ts +19 -0
  91. package/dist/index.d.ts.map +1 -0
  92. package/dist/index.js +22 -0
  93. package/dist/index.js.map +1 -0
  94. package/dist/plugin/bin/macf-plugin-cli.d.ts +13 -0
  95. package/dist/plugin/bin/macf-plugin-cli.d.ts.map +1 -0
  96. package/dist/plugin/bin/macf-plugin-cli.js +127 -0
  97. package/dist/plugin/bin/macf-plugin-cli.js.map +1 -0
  98. package/dist/plugin/lib/format.d.ts +40 -0
  99. package/dist/plugin/lib/format.d.ts.map +1 -0
  100. package/dist/plugin/lib/format.js +137 -0
  101. package/dist/plugin/lib/format.js.map +1 -0
  102. package/dist/plugin/lib/health.d.ts +2 -0
  103. package/dist/plugin/lib/health.d.ts.map +1 -0
  104. package/dist/plugin/lib/health.js +6 -0
  105. package/dist/plugin/lib/health.js.map +1 -0
  106. package/dist/plugin/lib/index.d.ts +7 -0
  107. package/dist/plugin/lib/index.d.ts.map +1 -0
  108. package/dist/plugin/lib/index.js +5 -0
  109. package/dist/plugin/lib/index.js.map +1 -0
  110. package/dist/plugin/lib/registry.d.ts +18 -0
  111. package/dist/plugin/lib/registry.d.ts.map +1 -0
  112. package/dist/plugin/lib/registry.js +17 -0
  113. package/dist/plugin/lib/registry.js.map +1 -0
  114. package/dist/plugin/lib/work.d.ts +13 -0
  115. package/dist/plugin/lib/work.d.ts.map +1 -0
  116. package/dist/plugin/lib/work.js +27 -0
  117. package/dist/plugin/lib/work.js.map +1 -0
  118. package/package.json +43 -0
  119. package/plugin/rules/coordination.md +224 -0
  120. package/scripts/check-gh-token.sh +102 -0
  121. package/scripts/macf-gh-token.sh +130 -0
  122. package/scripts/macf-whoami.sh +51 -0
  123. package/scripts/tmux-send-to-claude.sh +51 -0
  124. package/scripts/write-build-info.mjs +48 -0
@@ -0,0 +1,4 @@
1
+ {
2
+ "commit": "74319facbebf00ae73f5cde10a5b8f1b5af07bc0",
3
+ "built_at": "2026-04-22T16:51:29.683Z"
4
+ }
@@ -0,0 +1,38 @@
1
+ export interface BuildInfo {
2
+ readonly commit: string;
3
+ readonly built_at: string;
4
+ }
5
+ export interface StaleDistInfo {
6
+ /** The commit that was current when `dist/` was last built. */
7
+ readonly buildCommit: string;
8
+ /** The source repo's current HEAD. */
9
+ readonly currentCommit: string;
10
+ /** ISO timestamp of when `dist/` was built. */
11
+ readonly builtAt: string;
12
+ }
13
+ /**
14
+ * Load `<packageRoot>/dist/.build-info.json`. Returns null if the file
15
+ * is missing or malformed — never throws.
16
+ */
17
+ export declare function readBuildInfo(packageRoot: string): BuildInfo | null;
18
+ /**
19
+ * Compare the dist/ build stamp against the source repo's current
20
+ * HEAD. Returns null when the check can't run (no build info, no git,
21
+ * stamp is `unknown`) or when the dist is fresh. Returns non-null
22
+ * only when a real stale-dist condition is detected.
23
+ */
24
+ export declare function detectStaleDist(packageRoot: string): StaleDistInfo | null;
25
+ /**
26
+ * Non-null iff the source repo is a git-clone install (has `.git/`)
27
+ * AND the build-info is missing or its commit is "unknown". This is
28
+ * the "you built via `npx tsc` directly and skipped the postbuild
29
+ * hook" case — distinct from a stale-dist condition. Treat as a soft
30
+ * warning pointing at the canonical `npm run build`, not as a fail.
31
+ *
32
+ * Returns null for the legit cases: no git (tarball install), or the
33
+ * build stamp matches current HEAD (fresh).
34
+ */
35
+ export declare function detectUnknownFreshness(packageRoot: string): {
36
+ readonly reason: 'missing_build_info' | 'unknown_build_commit';
37
+ } | null;
38
+ //# sourceMappingURL=build-info.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"build-info.d.ts","sourceRoot":"","sources":["../../src/cli/build-info.ts"],"names":[],"mappings":"AA4BA,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC3B;AAED,MAAM,WAAW,aAAa;IAC5B,+DAA+D;IAC/D,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,sCAAsC;IACtC,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,+CAA+C;IAC/C,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,WAAW,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAoBnE;AAoBD;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,WAAW,EAAE,MAAM,GAAG,aAAa,GAAG,IAAI,CAezE;AAED;;;;;;;;;GASG;AACH,wBAAgB,sBAAsB,CACpC,WAAW,EAAE,MAAM,GAClB;IAAE,QAAQ,CAAC,MAAM,EAAE,oBAAoB,GAAG,sBAAsB,CAAA;CAAE,GAAG,IAAI,CAY3E"}
@@ -0,0 +1,119 @@
1
+ /**
2
+ * Stale-dist detection (#144).
3
+ *
4
+ * The installed `macf` CLI is typically `npm link`-ed to
5
+ * `<source-repo>/dist/cli/index.js`. When a CLI-behavior PR merges to
6
+ * main, operators must rebuild before the linked CLI reflects the
7
+ * change — forgetting the rebuild produces silent-no-op behavior.
8
+ *
9
+ * At build time, `scripts/write-build-info.mjs` writes the git HEAD
10
+ * into `dist/.build-info.json`. At runtime, `detectStaleDist()`
11
+ * compares that stamp against the source repo's current HEAD
12
+ * (via `git rev-parse HEAD`) and returns a non-null result when
13
+ * they differ.
14
+ *
15
+ * Fail-soft: if the build stamp is missing, is "unknown" (npm tarball
16
+ * install where git wasn't available at build time), or the source
17
+ * repo has no `.git/` directory, detection returns null. The detector
18
+ * never warns spuriously — it either catches a real drift or stays
19
+ * silent.
20
+ *
21
+ * Bootstrap limitation: detection only works from the CLI version
22
+ * that introduces it forward. Workspaces running pre-#144 CLIs won't
23
+ * get the warning until they rebuild once.
24
+ */
25
+ import { execFileSync } from 'node:child_process';
26
+ import { existsSync, readFileSync } from 'node:fs';
27
+ import { join } from 'node:path';
28
+ /**
29
+ * Load `<packageRoot>/dist/.build-info.json`. Returns null if the file
30
+ * is missing or malformed — never throws.
31
+ */
32
+ export function readBuildInfo(packageRoot) {
33
+ const path = join(packageRoot, 'dist', '.build-info.json');
34
+ if (!existsSync(path))
35
+ return null;
36
+ try {
37
+ const raw = readFileSync(path, 'utf-8');
38
+ const parsed = JSON.parse(raw);
39
+ if (parsed !== null &&
40
+ typeof parsed === 'object' &&
41
+ 'commit' in parsed &&
42
+ typeof parsed.commit === 'string' &&
43
+ 'built_at' in parsed &&
44
+ typeof parsed.built_at === 'string') {
45
+ return { commit: parsed.commit, built_at: parsed.built_at };
46
+ }
47
+ return null;
48
+ }
49
+ catch {
50
+ return null;
51
+ }
52
+ }
53
+ /**
54
+ * Run `git rev-parse HEAD` in `packageRoot`. Returns null if the repo
55
+ * has no `.git/` directory or git errors for any reason (e.g., no
56
+ * commits, command not installed).
57
+ */
58
+ function currentHeadCommit(packageRoot) {
59
+ if (!existsSync(join(packageRoot, '.git')))
60
+ return null;
61
+ try {
62
+ return execFileSync('git', ['rev-parse', 'HEAD'], {
63
+ cwd: packageRoot,
64
+ encoding: 'utf-8',
65
+ stdio: ['ignore', 'pipe', 'ignore'],
66
+ }).trim();
67
+ }
68
+ catch {
69
+ return null;
70
+ }
71
+ }
72
+ /**
73
+ * Compare the dist/ build stamp against the source repo's current
74
+ * HEAD. Returns null when the check can't run (no build info, no git,
75
+ * stamp is `unknown`) or when the dist is fresh. Returns non-null
76
+ * only when a real stale-dist condition is detected.
77
+ */
78
+ export function detectStaleDist(packageRoot) {
79
+ const info = readBuildInfo(packageRoot);
80
+ if (info === null)
81
+ return null;
82
+ if (info.commit === 'unknown')
83
+ return null;
84
+ const head = currentHeadCommit(packageRoot);
85
+ if (head === null)
86
+ return null;
87
+ if (head === info.commit)
88
+ return null;
89
+ return {
90
+ buildCommit: info.commit,
91
+ currentCommit: head,
92
+ builtAt: info.built_at,
93
+ };
94
+ }
95
+ /**
96
+ * Non-null iff the source repo is a git-clone install (has `.git/`)
97
+ * AND the build-info is missing or its commit is "unknown". This is
98
+ * the "you built via `npx tsc` directly and skipped the postbuild
99
+ * hook" case — distinct from a stale-dist condition. Treat as a soft
100
+ * warning pointing at the canonical `npm run build`, not as a fail.
101
+ *
102
+ * Returns null for the legit cases: no git (tarball install), or the
103
+ * build stamp matches current HEAD (fresh).
104
+ */
105
+ export function detectUnknownFreshness(packageRoot) {
106
+ // Only soft-warn for git-cloned installs. Tarball/npm-registry
107
+ // installs never have .git/ and can't benefit from `npm run build`.
108
+ if (!existsSync(join(packageRoot, '.git')))
109
+ return null;
110
+ const info = readBuildInfo(packageRoot);
111
+ if (info === null)
112
+ return { reason: 'missing_build_info' };
113
+ if (info.commit === 'unknown')
114
+ return { reason: 'unknown_build_commit' };
115
+ // Info is present and genuine — stale-detect is the right check for
116
+ // drift, not this function.
117
+ return null;
118
+ }
119
+ //# sourceMappingURL=build-info.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"build-info.js","sourceRoot":"","sources":["../../src/cli/build-info.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,MAAM,WAA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ACH,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,eAAe,CAAC,WAAmB;IACjD,MAAM,IAAI,GAAG,aAAa,CAAC,WAAW,CAAC,CAAC;IACxC,IAAI,IAAI,KAAK,IAAI;QAAE,OAAO,IAAI,CAAC;IAC/B,IAAI,IAAI,CAAC,MAAM,KAAK,SAAS;QAAE,OAAO,IAAI,CAAC;IAE3C,MAAM,IAAI,GAAG,iBAAiB,CAAC,WAAW,CAAC,CAAC;IAC5C,IAAI,IAAI,KAAK,IAAI;QAAE,OAAO,IAAI,CAAC;IAE/B,IAAI,IAAI,KAAK,IAAI,CAAC,MAAM;QAAE,OAAO,IAAI,CAAC;IAEtC,OAAO;QACL,WAAW,EAAE,IAAI,CAAC,MAAM;QACxB,aAAa,EAAE,IAAI;QACnB,OAAO,EAAE,IAAI,CAAC,QAAQ;KACvB,CAAC;AACJ,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,sBAAsB,CACpC,WAAmB;IAEnB,+DAA+D;IAC/D,oEAAoE;IACpE,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;QAAE,OAAO,IAAI,CAAC;IAExD,MAAM,IAAI,GAAG,aAAa,CAAC,WAAW,CAAC,CAAC;IACxC,IAAI,IAAI,KAAK,IAAI;QAAE,OAAO,EAAE,MAAM,EAAE,oBAAoB,EAAE,CAAC;IAC3D,IAAI,IAAI,CAAC,MAAM,KAAK,SAAS;QAAE,OAAO,EAAE,MAAM,EAAE,sBAAsB,EAAE,CAAC;IAEzE,oEAAoE;IACpE,4BAA4B;IAC5B,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -0,0 +1,42 @@
1
+ import type { MacfAgentConfig } from './config.js';
2
+ /**
3
+ * Emit the Claude Code native OTEL telemetry env block into the
4
+ * generated `claude.sh`. Three mandatory gates per Claude Code docs
5
+ * — missing any one of them → zero traces emit:
6
+ *
7
+ * CLAUDE_CODE_ENABLE_TELEMETRY=1 master gate
8
+ * CLAUDE_CODE_ENHANCED_TELEMETRY_BETA=1 additional gate (traces are beta)
9
+ * OTEL_TRACES_EXPORTER=otlp choose exporter (default is none)
10
+ *
11
+ * See code.claude.com/docs/en/monitoring-usage § Traces (beta).
12
+ *
13
+ * Knobs at `macf init` / `macf update` time (read from calling shell
14
+ * env, NOT persisted to macf-agent.json — observability is a
15
+ * deployment-topology concern, not a per-agent-identity setting):
16
+ *
17
+ * MACF_OTEL_DISABLED=1 → omit the block entirely. For
18
+ * deployments without an observability
19
+ * stack; avoids retry-spam to a
20
+ * non-existent collector. See macf#197.
21
+ * MACF_OTEL_ENDPOINT=<url> → override the default
22
+ * `http://localhost:4318`. For central
23
+ * obs hosts reachable over Tailscale /
24
+ * other network paths.
25
+ *
26
+ * Exported for unit tests.
27
+ *
28
+ * @param env — defaults to `process.env`; tests inject a fake.
29
+ */
30
+ export declare function otelTelemetryLines(config: MacfAgentConfig, env?: NodeJS.ProcessEnv): string[];
31
+ /**
32
+ * Build the full `claude.sh` content for a given agent config. Pure
33
+ * function — no I/O. Used by both `macf init` (first write) and
34
+ * `macf update` (refresh).
35
+ */
36
+ export declare function generateClaudeSh(config: MacfAgentConfig): string;
37
+ /**
38
+ * Write `claude.sh` into the workspace at 0755. Overwrites any existing
39
+ * content — the managed-file header warns users against hand-editing.
40
+ */
41
+ export declare function writeClaudeSh(workspaceDir: string, config: MacfAgentConfig): string;
42
+ //# sourceMappingURL=claude-sh.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"claude-sh.d.ts","sourceRoot":"","sources":["../../src/cli/claude-sh.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAiCnD;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,eAAe,EACvB,GAAG,GAAE,MAAM,CAAC,UAAwB,GACnC,MAAM,EAAE,CAqCV;AA4BD;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,eAAe,GAAG,MAAM,CAiGhE;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,YAAY,EAAE,MAAM,EAAE,MAAM,EAAE,eAAe,GAAG,MAAM,CAUnF"}
@@ -0,0 +1,247 @@
1
+ /**
2
+ * Generate and write the per-workspace `claude.sh` launcher. Extracted
3
+ * from `init.ts` so `macf update` can regenerate it when the template
4
+ * changes (see #63 — workspaces init'd on older CLI versions end up
5
+ * with stale launchers and no way to refresh short of re-running init).
6
+ *
7
+ * The launcher carries a "managed file" header telling users not to
8
+ * edit it — same pattern as the rules distribution (#54). `macf update`
9
+ * overwrites unconditionally; user customizations are expected to live
10
+ * elsewhere (e.g., `.claude/settings.local.json` for env tweaks).
11
+ */
12
+ import { chmodSync, writeFileSync } from 'node:fs';
13
+ import { join, resolve } from 'node:path';
14
+ /**
15
+ * Emit shell `export MACF_REGISTRY_*` lines matching the registry
16
+ * scope in `cfg`. The plugin's `src/config.ts` reads these three env
17
+ * vars (MACF_REGISTRY_TYPE + per-type ORG / USER / REPO) on startup;
18
+ * without them the plugin falls back to a hardcoded default repo and
19
+ * 403s every registry op on consumers in other scopes. See macf#178.
20
+ *
21
+ * Exhaustive switch on the discriminated union — if a new RegistryConfig
22
+ * variant is ever added, TypeScript fails the build here, forcing a
23
+ * paired env-line update.
24
+ */
25
+ function registryEnvLines(cfg) {
26
+ switch (cfg.registry.type) {
27
+ case 'repo':
28
+ return [
29
+ `export MACF_REGISTRY_TYPE="repo"`,
30
+ `export MACF_REGISTRY_REPO="${cfg.registry.owner}/${cfg.registry.repo}"`,
31
+ ];
32
+ case 'org':
33
+ return [
34
+ `export MACF_REGISTRY_TYPE="org"`,
35
+ `export MACF_REGISTRY_ORG="${cfg.registry.org}"`,
36
+ ];
37
+ case 'profile':
38
+ return [
39
+ `export MACF_REGISTRY_TYPE="profile"`,
40
+ `export MACF_REGISTRY_USER="${cfg.registry.user}"`,
41
+ ];
42
+ }
43
+ }
44
+ /**
45
+ * Emit the Claude Code native OTEL telemetry env block into the
46
+ * generated `claude.sh`. Three mandatory gates per Claude Code docs
47
+ * — missing any one of them → zero traces emit:
48
+ *
49
+ * CLAUDE_CODE_ENABLE_TELEMETRY=1 master gate
50
+ * CLAUDE_CODE_ENHANCED_TELEMETRY_BETA=1 additional gate (traces are beta)
51
+ * OTEL_TRACES_EXPORTER=otlp choose exporter (default is none)
52
+ *
53
+ * See code.claude.com/docs/en/monitoring-usage § Traces (beta).
54
+ *
55
+ * Knobs at `macf init` / `macf update` time (read from calling shell
56
+ * env, NOT persisted to macf-agent.json — observability is a
57
+ * deployment-topology concern, not a per-agent-identity setting):
58
+ *
59
+ * MACF_OTEL_DISABLED=1 → omit the block entirely. For
60
+ * deployments without an observability
61
+ * stack; avoids retry-spam to a
62
+ * non-existent collector. See macf#197.
63
+ * MACF_OTEL_ENDPOINT=<url> → override the default
64
+ * `http://localhost:4318`. For central
65
+ * obs hosts reachable over Tailscale /
66
+ * other network paths.
67
+ *
68
+ * Exported for unit tests.
69
+ *
70
+ * @param env — defaults to `process.env`; tests inject a fake.
71
+ */
72
+ export function otelTelemetryLines(config, env = process.env) {
73
+ if (env['MACF_OTEL_DISABLED'] === '1' || env['MACF_OTEL_DISABLED'] === 'true') {
74
+ return [];
75
+ }
76
+ const endpoint = env['MACF_OTEL_ENDPOINT'] ?? 'http://localhost:4318';
77
+ // The endpoint value gets embedded verbatim in a shell double-
78
+ // quoted export. Reject chars that would break quoting or trigger
79
+ // substitution: `"`, `$`, backtick, backslash, newline. Same
80
+ // allowlist pattern as validateInitOpts on keyPath.
81
+ if (/["$`\\\n\r]/.test(endpoint)) {
82
+ throw new Error(`MACF_OTEL_ENDPOINT contains a shell-unsafe character. ` +
83
+ `Got: ${JSON.stringify(endpoint)}. ` +
84
+ `Expected a plain URL like http://host:port.`);
85
+ }
86
+ return [
87
+ '',
88
+ '# macf#197: Claude Code native OTEL telemetry → observability stack.',
89
+ '# Three gates (all required, per code.claude.com/docs/en/monitoring-usage § Traces beta):',
90
+ '# CLAUDE_CODE_ENABLE_TELEMETRY — master telemetry gate',
91
+ '# CLAUDE_CODE_ENHANCED_TELEMETRY_BETA — additional gate for traces (still beta)',
92
+ '# OTEL_TRACES_EXPORTER=otlp — pick an exporter (default: none)',
93
+ '# Omit the whole block by setting MACF_OTEL_DISABLED=1 at `macf update`',
94
+ '# time — e.g. deployments without the obs stack running locally.',
95
+ '# Override endpoint via MACF_OTEL_ENDPOINT for central-collector setups.',
96
+ 'export CLAUDE_CODE_ENABLE_TELEMETRY=1',
97
+ 'export CLAUDE_CODE_ENHANCED_TELEMETRY_BETA=1',
98
+ 'export OTEL_TRACES_EXPORTER=otlp',
99
+ `export OTEL_EXPORTER_OTLP_ENDPOINT="${endpoint}"`,
100
+ 'export OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf',
101
+ `export OTEL_SERVICE_NAME="macf-agent-${config.agent_name}"`,
102
+ `export OTEL_RESOURCE_ATTRIBUTES="gen_ai.agent.name=${config.agent_name},gen_ai.agent.role=${config.agent_role},service.namespace=macf"`,
103
+ ];
104
+ }
105
+ /**
106
+ * Claude Code session-resume flags for the final `exec claude ...`.
107
+ * Permanent agents reattach to the prior session so context persists
108
+ * across relaunches (same ergonomics as macf-science-agent /
109
+ * macf-code-agent's existing tmux wrappers). Worker agents skip `-c`
110
+ * because every invocation is fresh by design. See macf#178 Gap 5.
111
+ *
112
+ * Exhaustive switch on `agent_type` so adding a new type is a compile
113
+ * error that forces a paired flag policy decision.
114
+ */
115
+ function resumeFlags(cfg) {
116
+ switch (cfg.agent_type) {
117
+ case 'permanent':
118
+ return ['-c'];
119
+ case 'worker':
120
+ return [];
121
+ }
122
+ }
123
+ const MANAGED_HEADER_LINES = [
124
+ '# This file is managed by `macf`. Do not edit directly — edits are',
125
+ '# overwritten on the next `macf update`. The template lives at',
126
+ '# groundnuty/macf:src/cli/claude-sh.ts. To change the launcher, file',
127
+ '# an issue or PR against that file, then run `macf update` here.',
128
+ ];
129
+ /**
130
+ * Build the full `claude.sh` content for a given agent config. Pure
131
+ * function — no I/O. Used by both `macf init` (first write) and
132
+ * `macf update` (refresh).
133
+ */
134
+ export function generateClaudeSh(config) {
135
+ return [
136
+ '#!/usr/bin/env bash',
137
+ 'set -euo pipefail',
138
+ '',
139
+ `# MACF Agent Launcher: ${config.agent_name}`,
140
+ ...MANAGED_HEADER_LINES,
141
+ '',
142
+ 'SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"',
143
+ 'cd "$SCRIPT_DIR"',
144
+ '',
145
+ // Export MACF_WORKSPACE_DIR so runtime agent templates
146
+ // (.claude/rules/agent-identity.md + plugin/agents/*.md) can
147
+ // reference the workspace root as an absolute path. Relative
148
+ // paths break the moment the agent cd's to another repo for
149
+ // cross-repo work — attribution trap fires. See #140 + the
150
+ // cross-repo cwd trap note in coordination.md Token & Git Hygiene.
151
+ 'export MACF_WORKSPACE_DIR="$SCRIPT_DIR"',
152
+ `export MACF_AGENT_NAME="${config.agent_name}"`,
153
+ `export MACF_PROJECT="${config.project}"`,
154
+ `export MACF_AGENT_TYPE="${config.agent_type}"`,
155
+ `export MACF_AGENT_ROLE="${config.agent_role}"`,
156
+ `export APP_ID="${config.github_app.app_id}"`,
157
+ `export INSTALL_ID="${config.github_app.install_id}"`,
158
+ `export KEY_PATH="${config.github_app.key_path}"`,
159
+ // Resolve KEY_PATH against $SCRIPT_DIR if it's relative. Absolute
160
+ // paths (e.g., operators who stored the key under /etc or /opt)
161
+ // pass through unchanged. Previously KEY_PATH stayed relative and
162
+ // broke the moment the agent cd'd to another repo — attribution
163
+ // trap fires on the next `gh` call. See #140 + coordination.md
164
+ // Token & Git Hygiene (cross-repo cwd trap note).
165
+ 'case "$KEY_PATH" in',
166
+ ' /*) ;; # already absolute',
167
+ ' *) KEY_PATH="$SCRIPT_DIR/$KEY_PATH" ;;',
168
+ 'esac',
169
+ 'export KEY_PATH',
170
+ `export MACF_CA_CERT="$HOME/.macf/certs/${config.project}/ca-cert.pem"`,
171
+ `export MACF_CA_KEY="$HOME/.macf/certs/${config.project}/ca-key.pem"`,
172
+ 'export MACF_AGENT_CERT="$SCRIPT_DIR/.macf/certs/agent-cert.pem"',
173
+ 'export MACF_AGENT_KEY="$SCRIPT_DIR/.macf/certs/agent-key.pem"',
174
+ 'export MACF_LOG_PATH="$SCRIPT_DIR/.macf/logs/channel.log"',
175
+ 'export MACF_DEBUG="${MACF_DEBUG:-false}"',
176
+ // Listen on all interfaces; advertise the routable host below. When
177
+ // advertise_host is unset in macf-agent.json, fall back to 127.0.0.1
178
+ // (the plugin's existing default — keeps backward compat for
179
+ // workspaces that haven't set the field yet). See macf#178.
180
+ 'export MACF_HOST="0.0.0.0"',
181
+ `export MACF_ADVERTISE_HOST="${config.advertise_host ?? '127.0.0.1'}"`,
182
+ // macf#185: tmux session:window for on-notify wake via
183
+ // tmux-send-to-claude.sh. If unset, the server auto-detects
184
+ // from $TMUX when launched inside a tmux pane. Explicit-env
185
+ // takes priority — handy when the agent is launched outside
186
+ // tmux by a supervisor and still wants to target a named pane.
187
+ ...(config.tmux_session !== undefined
188
+ ? [`export MACF_TMUX_SESSION="${config.tmux_session}"`]
189
+ : []),
190
+ ...(config.tmux_window !== undefined
191
+ ? [`export MACF_TMUX_WINDOW="${config.tmux_window}"`]
192
+ : []),
193
+ ...registryEnvLines(config),
194
+ ...otelTelemetryLines(config),
195
+ '',
196
+ '# Bot token generation — fail loud. The helper validates the ghs_ prefix',
197
+ '# and surfaces diagnostics (clock drift, bad key, wrong App/install ID).',
198
+ '# Do NOT inline the bare CLI here — without pipefail, a failed fetch piped',
199
+ '# through jq would succeed, GH_TOKEN would become "null", and Claude Code',
200
+ '# would silently fall back to stored `gh auth login` as the user. See the',
201
+ '# attribution-trap section of coordination.md Token & Git Hygiene.',
202
+ 'GH_TOKEN=$("$SCRIPT_DIR/.claude/scripts/macf-gh-token.sh" \\',
203
+ ' --app-id "$APP_ID" --install-id "$INSTALL_ID" --key "$KEY_PATH") || {',
204
+ ' echo "FATAL: bot token generation failed — see stderr above." >&2',
205
+ ' exit 1',
206
+ '}',
207
+ 'export GH_TOKEN',
208
+ '',
209
+ `export GIT_AUTHOR_NAME="${config.agent_name}[bot]"`,
210
+ `export GIT_COMMITTER_NAME="${config.agent_name}[bot]"`,
211
+ '',
212
+ `echo "Starting ${config.agent_name} (${config.agent_role})..."`,
213
+ // --plugin-dir loads the pinned macf-agent plugin from this workspace
214
+ // (per DR-013). Additive — user-scope plugins still load alongside.
215
+ // `-c` (for permanent agents) reattaches to the prior Claude Code
216
+ // session so context persists across relaunches; worker agents skip
217
+ // it so every invocation is fresh. See macf#178 Gap 5.
218
+ //
219
+ // MACF_TEST=1 bypasses the `-c` auto-resume for clean-state smoke
220
+ // tests — `-c` errors with "No deferred tool marker found" when the
221
+ // prior session state is missing/partial. Normal production runs
222
+ // (MACF_TEST unset) get the resume-by-default behavior. See
223
+ // macf#189 sub-item 4.
224
+ 'if [ -n "${MACF_TEST:-}" ]; then',
225
+ ` exec claude ${['--plugin-dir', '"$SCRIPT_DIR/.macf/plugin"'].join(' ')} "$@"`,
226
+ 'else',
227
+ ` exec claude ${[...resumeFlags(config), '--plugin-dir', '"$SCRIPT_DIR/.macf/plugin"'].join(' ')} "$@"`,
228
+ 'fi',
229
+ '',
230
+ ].join('\n');
231
+ }
232
+ /**
233
+ * Write `claude.sh` into the workspace at 0755. Overwrites any existing
234
+ * content — the managed-file header warns users against hand-editing.
235
+ */
236
+ export function writeClaudeSh(workspaceDir, config) {
237
+ const absDir = resolve(workspaceDir);
238
+ const path = join(absDir, 'claude.sh');
239
+ writeFileSync(path, generateClaudeSh(config), { mode: 0o755 });
240
+ // writeFileSync's `mode` option only applies when creating a new file.
241
+ // On overwrite, the existing mode (often 0o644 from a user's editor)
242
+ // is kept — so we must explicitly chmod to make sure the launcher
243
+ // stays executable after `macf update` rewrites it.
244
+ chmodSync(path, 0o755);
245
+ return path;
246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;QACjB,EAAE;QACF,2BAA2B,MAAM,CAAC,UAAU,QAAQ;QACpD,8BAA8B,MAAM,CAAC,UAAU,QAAQ;QACvD,EAAE;QACF,kBAAkB,MAAM,CAAC,UAAU,KAAK,MAAM,CAAC,UAAU,OAAO;QAChE,sEAAsE;QACtE,oEAAoE;QACpE,kEAAkE;QAClE,oEAAoE;QACpE,uDAAuD;QACvD,EAAE;QACF,kEAAkE;QAClE,oEAAoE;QACpE,iEAAiE;QACjE,4DAA4D;QAC5D,uBAAuB;QACvB,kCAAkC;QAClC,iBAAiB,CAAC,cAAc,EAAE,4BAA4B,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO;QAChF,MAAM;QACN,iBAAiB,CAAC,GAAG,WAAW,CAAC,MAAM,CAAC,EAAE,cAAc,EAAE,4BAA4B,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO;QACxG,IAAI;QACJ,EAAE;KACH,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACf,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,aAAa,CAAC,YAAoB,EAAE,MAAuB;IACzE,MAAM,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;IACrC,MAAM,IAAI,GAAG,IAAI,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IACvC,aAAa,CAAC,IAAI,EAAE,gBAAgB,CAAC,MAAM,CAAC,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;IAC/D,uEAAuE;IACvE,qEAAqE;IACrE,kEAAkE;IAClE,oDAAoD;IACpD,SAAS,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IACvB,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Print the project path for a given agent name.
3
+ * Usage: cd $(macf cd code-agent)
4
+ */
5
+ export declare function cdAgent(agentName: string): void;
6
+ //# sourceMappingURL=cd.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cd.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/cd.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,wBAAgB,OAAO,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAY/C"}
@@ -0,0 +1,17 @@
1
+ import { loadAllAgents } from '../config.js';
2
+ /**
3
+ * Print the project path for a given agent name.
4
+ * Usage: cd $(macf cd code-agent)
5
+ */
6
+ export function cdAgent(agentName) {
7
+ const agents = loadAllAgents();
8
+ const match = agents.find(a => a.config.agent_name === agentName);
9
+ if (!match) {
10
+ console.error(`Agent "${agentName}" not found in index.`);
11
+ process.exitCode = 1;
12
+ return;
13
+ }
14
+ // Print just the path — designed for shell substitution
15
+ console.log(match.path);
16
+ }
17
+ //# sourceMappingURL=cd.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cd.js","sourceRoot":"","sources":["../../../src/cli/commands/cd.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAE7C;;;GAGG;AACH,MAAM,UAAU,OAAO,CAAC,SAAiB;IACvC,MAAM,MAAM,GAAG,aAAa,EAAE,CAAC;IAC/B,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,UAAU,KAAK,SAAS,CAAC,CAAC;IAElE,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,OAAO,CAAC,KAAK,CAAC,UAAU,SAAS,uBAAuB,CAAC,CAAC;QAC1D,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;QACrB,OAAO;IACT,CAAC;IAED,wDAAwD;IACxD,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC"}
@@ -0,0 +1,33 @@
1
+ /**
2
+ * macf certs init: create CA, upload cert + encrypted key to registry
3
+ */
4
+ export declare function certsInit(projectDir: string): Promise<void>;
5
+ /**
6
+ * macf certs recover: download and decrypt CA key from registry
7
+ */
8
+ export declare function certsRecover(projectDir: string): Promise<void>;
9
+ /**
10
+ * macf certs rotate: regenerate agent cert with existing CA
11
+ */
12
+ export declare function certsRotate(projectDir: string): Promise<void>;
13
+ export interface IssueRoutingClientOptions {
14
+ readonly outDir?: string;
15
+ readonly validityDays?: number;
16
+ }
17
+ /**
18
+ * macf certs issue-routing-client: mint a CA-signed client cert with
19
+ * CN=routing-action for use by the macf-actions routing workflow
20
+ * (mTLS variant, macf-actions#8). The routing Action presents this
21
+ * cert when POSTing to each agent's /notify endpoint.
22
+ *
23
+ * Requires the CA key on disk — this command is local-only, never
24
+ * driven from the registry-encrypted backup. The resulting cert/key
25
+ * is meant to be pasted into the consumer repo's GHA secrets; the
26
+ * operator is expected to handle the paste securely (not commit it).
27
+ *
28
+ * If --out-dir is omitted, both PEMs are printed to stdout along with
29
+ * single-line base64 blobs for easy GHA-secret paste. If --out-dir
30
+ * is provided, files are written to disk at 0o600 / 0o644.
31
+ */
32
+ export declare function issueRoutingClient(projectDir: string, opts?: IssueRoutingClientOptions): Promise<void>;
33
+ //# sourceMappingURL=certs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"certs.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/certs.ts"],"names":[],"mappings":"AAoCA;;GAEG;AACH,wBAAsB,SAAS,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CA8CjE;AAED;;GAEG;AACH,wBAAsB,YAAY,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAiCpE;AAED;;GAEG;AACH,wBAAsB,WAAW,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAsCnE;AAED,MAAM,WAAW,yBAAyB;IACxC,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;CAChC;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,kBAAkB,CACtC,UAAU,EAAE,MAAM,EAClB,IAAI,GAAE,yBAA8B,GACnC,OAAO,CAAC,IAAI,CAAC,CAyFf"}