@pennixrv/trellis 0.7.2-beta.21 → 0.7.2-beta.23

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.
@@ -6,8 +6,8 @@ The goal is to discover the project's real architecture before writing rules. Do
6
6
 
7
7
  1. Read the existing `.trellis/spec/` tree and note which files are templates, outdated, or already project-specific.
8
8
  2. Inspect package manifests, build scripts, workspace config, and top-level documentation to identify packages and runtime layers.
9
- 3. Use GitNexus for execution flows, module clusters, dependency hubs, and impact-sensitive areas.
10
- 4. Use ABCoder or language-native tooling for exact signatures, types, class boundaries, and implementation examples.
9
+ 3. Use the project's approved code intelligence tools and usable indexes for execution flows, dependency hubs, and impact-sensitive areas. Check the returned project, checkout, and freshness before relying on relationships.
10
+ 4. Use available language tooling and current source for exact signatures, types, class boundaries, and implementation examples.
11
11
  5. Read representative source and test files directly before turning any finding into a spec rule.
12
12
 
13
13
  ## What To Capture
@@ -22,31 +22,11 @@ The goal is to discover the project's real architecture before writing rules. Do
22
22
  | Configuration | Where do defaults, environment config, generated files, and templates live? |
23
23
  | Tests | Which test styles are trusted examples for new work? |
24
24
 
25
- ## GitNexus Usage
25
+ ## Tool and Source Evidence
26
26
 
27
- Start broad, then inspect specific symbols:
27
+ Use the host's native discovery, MCP instructions, and CLI help for the selected tool's protocol. For an approved project with a usable CodeGraph index, its native exploration can identify source spans and call paths; other approved tools may serve the same purpose. No particular tool is required by this workflow.
28
28
 
29
- ```text
30
- gitnexus_query({query: "CLI command execution flow"})
31
- gitnexus_query({query: "template generation and migration"})
32
- gitnexus_context({name: "SymbolName"})
33
- gitnexus_cypher({query: "MATCH (n)-[r]->(m) RETURN n.name, type(r), m.name LIMIT 30"})
34
- ```
35
-
36
- Use GitNexus results to find important files and flows. Do not quote graph output as the final authority until you have checked the relevant source files.
37
-
38
- ## ABCoder Usage
39
-
40
- Use ABCoder when the spec needs exact code shapes:
41
-
42
- ```text
43
- list_repos()
44
- get_repo_structure({repo_name: "package-name"})
45
- get_file_structure({repo_name: "package-name", file_path: "src/example.ts"})
46
- get_ast_node({repo_name: "package-name", node_ids: [{mod_path: "...", pkg_path: "...", name: "SymbolName"}]})
47
- ```
48
-
49
- ABCoder is most valuable for documenting constructor patterns, function signatures, type contracts, and reference chains.
29
+ Start with package or symbol names, then inspect the relevant source and tests. Reuse current source spans already returned by a tool; verify omitted or stale material before making a rule. If an index is missing, stale, or bound to another checkout, record the limitation and use bounded source evidence. Do not install tools, create indexes, or query another project as a substitute for missing authorization.
50
30
 
51
31
  ## Analysis Notes
52
32
 
@@ -1,33 +1,16 @@
1
1
  <!-- TRELLIS:START -->
2
2
  # Trellis Instructions
3
3
 
4
- These instructions are for AI assistants working in this project.
5
-
6
- For a new session use `trellis-start`; for existing work use `trellis-continue`
7
- and resume the known unfinished action. Read `.trellis/workflow.md` for the
8
- native route and ownership rules. Task CLI owns task and phase state; specs
9
- describe engineering conventions, not implementation authorization.
4
+ Use `trellis-start` for a new session and `trellis-continue` to resume;
5
+ reuse already loaded context. Follow `.trellis/workflow.md`.
6
+ The Task CLI owns task and phase state.
10
7
 
8
+ Before editing, read the applicable `.trellis/spec/` guidelines.
11
9
  Without hook context, run `python3 ./.trellis/scripts/get_context.py --mode phase`
12
- and `python3 ./.trellis/scripts/task.py phase show <task>`, then explicitly read
13
- the applicable spec indexes and their referenced guidelines.
14
-
15
- This project is managed by Trellis. The working knowledge you need lives under `.trellis/`:
16
-
17
- - `.trellis/workflow.md` — development phases, when to create tasks, skill routing
18
- - `.trellis/spec/` — package- and layer-scoped coding guidelines (read before writing code in a given layer)
19
- - `.trellis/workspace/` — per-developer journals and session traces
20
- - `.trellis/tasks/` — task records and their planning, implementation, and review artifacts
21
-
22
- If a Trellis command is available on your platform (e.g. `/trellis:finish-work`, `/trellis:continue`), prefer it over manual steps. Not every platform exposes every command.
23
-
24
- Project-scoped helpers use these native owners:
25
- - `.agents/skills/` — reusable Trellis methods
26
- - `.trellis/agents/` — Teamwork role cards and Paseo node methods
27
-
28
- The main session owns task decisions and integration. Collaboration uses
29
- `trellis teamwork` or `paseo-based-parallelism` under the authorized contract.
10
+ and, when a task exists, `python3 ./.trellis/scripts/task.py phase show <task>`.
30
11
 
31
- Managed by Trellis. Edits outside this block are preserved; edits inside may be overwritten by a future `trellis update`.
12
+ Use the host's available Trellis skills or commands. If unavailable, read
13
+ `.trellis/workflow.md` for the native CLI route.
32
14
 
15
+ Managed by Trellis. Updates preserve content outside this block.
33
16
  <!-- TRELLIS:END -->
@@ -0,0 +1,26 @@
1
+ type ObjectValue = Record<string, unknown>;
2
+ export interface ProjectInitOptions {
3
+ trustCodex?: boolean;
4
+ codegraph?: boolean;
5
+ }
6
+ export interface ProjectInitPlan {
7
+ trustCodex: boolean;
8
+ codegraph: boolean;
9
+ codexCommand?: string;
10
+ graphCommand?: string;
11
+ }
12
+ export declare function resolveProjectPolicy(cwd: string, options: ProjectInitOptions): ProjectInitPlan;
13
+ export declare function preflightProjectInit(cwd: string, plan: ProjectInitPlan): Promise<void>;
14
+ export declare class CodexConfigClient {
15
+ private process;
16
+ private sequence;
17
+ private pending;
18
+ constructor(command: string, cwd: string);
19
+ private fail;
20
+ request(method: string, params: ObjectValue): Promise<unknown>;
21
+ initialize(): Promise<void>;
22
+ close(): Promise<void>;
23
+ }
24
+ export declare function completeProjectInit(cwd: string, plan: ProjectInitPlan): Promise<void>;
25
+ export {};
26
+ //# sourceMappingURL=project-init.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"project-init.d.ts","sourceRoot":"","sources":["../../src/utils/project-init.ts"],"names":[],"mappings":"AASA,KAAK,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAC3C,MAAM,WAAW,kBAAkB;IACjC,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AACD,MAAM,WAAW,eAAe;IAC9B,UAAU,EAAE,OAAO,CAAC;IACpB,SAAS,EAAE,OAAO,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AA2CD,wBAAgB,oBAAoB,CAClC,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,kBAAkB,GAC1B,eAAe,CA4CjB;AAiCD,wBAAsB,oBAAoB,CACxC,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,eAAe,GACpB,OAAO,CAAC,IAAI,CAAC,CAuFf;AAED,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,OAAO,CAAC;IAChB,OAAO,CAAC,QAAQ,CAAK;IACrB,OAAO,CAAC,OAAO,CAOX;gBACQ,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM;IA6BxC,OAAO,CAAC,IAAI;IAWN,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,OAAO,CAAC;IAW9D,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAO3B,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAkB7B;AA2PD,wBAAsB,mBAAmB,CACvC,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,eAAe,GACpB,OAAO,CAAC,IAAI,CAAC,CAsGf"}
@@ -0,0 +1,484 @@
1
+ import fs from "node:fs";
2
+ import os from "node:os";
3
+ import path from "node:path";
4
+ import { spawn, spawnSync } from "node:child_process";
5
+ import { createInterface } from "node:readline";
6
+ import { collectCodexTemplates } from "../configurators/codex.js";
7
+ import { renderTemplateMap } from "../configurators/shared.js";
8
+ import { getAllScripts } from "../templates/trellis/index.js";
9
+ function object(value) {
10
+ if (!value || typeof value !== "object" || Array.isArray(value))
11
+ throw new Error("Invalid project initialization response");
12
+ return value;
13
+ }
14
+ function executable(name, cwd) {
15
+ for (const dir of (process.env.PATH ?? "").split(path.delimiter)) {
16
+ if (!path.isAbsolute(dir))
17
+ continue;
18
+ const candidate = path.join(dir, name);
19
+ try {
20
+ fs.accessSync(candidate, fs.constants.X_OK);
21
+ const real = fs.realpathSync(candidate);
22
+ const rel = path.relative(cwd, real);
23
+ if (!rel ||
24
+ (!rel.startsWith(`..${path.sep}`) &&
25
+ rel !== ".." &&
26
+ !path.isAbsolute(rel)))
27
+ throw new Error(`Refusing project-provided executable: ${name}`);
28
+ return real;
29
+ }
30
+ catch (error) {
31
+ if (error instanceof Error && error.message.startsWith("Refusing"))
32
+ throw error;
33
+ }
34
+ }
35
+ return undefined;
36
+ }
37
+ function capture(command, args, cwd) {
38
+ const result = spawnSync(command, args, {
39
+ cwd,
40
+ encoding: "utf8",
41
+ timeout: 30_000,
42
+ maxBuffer: 4 * 1024 * 1024,
43
+ });
44
+ if (result.error)
45
+ throw new Error(`Could not run ${path.basename(command)}`);
46
+ return result;
47
+ }
48
+ export function resolveProjectPolicy(cwd, options) {
49
+ let policy = { codex_trust: false, codegraph: false };
50
+ const config = path.join(process.env.XDG_CONFIG_HOME ?? path.join(os.homedir(), ".config"), "pennix/workflow.config");
51
+ if ((options.trustCodex === undefined || options.codegraph === undefined) &&
52
+ fs.existsSync(config)) {
53
+ const pennix = executable("pennix", cwd);
54
+ if (!pennix)
55
+ throw new Error("Lifecycle declaration exists but pennix is unavailable");
56
+ const help = capture(pennix, ["config", "--help"], cwd);
57
+ if (!/\bpolicy\b/.test(help.stdout)) {
58
+ if (help.status !== 0)
59
+ throw new Error("Could not inspect Lifecycle policy capability");
60
+ console.warn("Lifecycle has no project policy capability; automatic project setup remains unselected.");
61
+ }
62
+ else {
63
+ const result = capture(pennix, ["config", "policy", "--json"], cwd);
64
+ if (result.status !== 0)
65
+ throw new Error("Lifecycle project policy query failed; check the declaration");
66
+ const value = object(JSON.parse(result.stdout));
67
+ const selected = object(value.project_init);
68
+ if (value.schema_version !== 1 ||
69
+ typeof selected.codex_trust !== "boolean" ||
70
+ typeof selected.codegraph !== "boolean")
71
+ throw new Error("Unsupported Lifecycle project policy response");
72
+ policy = {
73
+ codex_trust: selected.codex_trust,
74
+ codegraph: selected.codegraph,
75
+ };
76
+ }
77
+ }
78
+ return {
79
+ trustCodex: options.trustCodex ?? policy.codex_trust,
80
+ codegraph: options.codegraph ?? policy.codegraph,
81
+ };
82
+ }
83
+ function verifyAssets(cwd, complete) {
84
+ const templates = renderTemplateMap(collectCodexTemplates());
85
+ for (const [name, content] of renderTemplateMap(getAllScripts()))
86
+ templates.set(`.trellis/scripts/${name}`, content);
87
+ for (const [name, content] of templates) {
88
+ if (!(name.startsWith(".codex/hooks/") ||
89
+ name === ".codex/hooks.json" ||
90
+ name.startsWith(".trellis/scripts/")))
91
+ continue;
92
+ const file = path.join(cwd, name);
93
+ if (!fs.existsSync(file)) {
94
+ if (complete)
95
+ throw new Error(`Missing managed initialization asset: ${name}`);
96
+ continue;
97
+ }
98
+ if (!fs.lstatSync(file).isFile() ||
99
+ fs.realpathSync(file) !== file ||
100
+ fs.readFileSync(file, "utf8").replace(/\r\n/g, "\n") !==
101
+ content.replace(/\r\n/g, "\n"))
102
+ throw new Error(`Modified or redirected managed initialization asset: ${name}`);
103
+ }
104
+ }
105
+ export async function preflightProjectInit(cwd, plan) {
106
+ if (!plan.trustCodex && !plan.codegraph)
107
+ return;
108
+ if (process.platform !== "linux" ||
109
+ fs.realpathSync(cwd) === fs.realpathSync(os.homedir()) ||
110
+ path.dirname(cwd) === cwd ||
111
+ /^\/mnt\/[a-z](\/|$)/i.test(cwd))
112
+ throw new Error("Automatic project setup requires a specific Linux filesystem project directory");
113
+ const git = executable("git", cwd);
114
+ if (git) {
115
+ const root = capture(git, ["rev-parse", "--show-toplevel"], cwd);
116
+ const parent = capture(git, ["rev-parse", "--show-superproject-working-tree"], cwd);
117
+ if ((root.status === 0 && fs.realpathSync(root.stdout.trim()) !== cwd) ||
118
+ parent.stdout.trim())
119
+ throw new Error("Project initialization would use a broader Git trust root; select that root explicitly");
120
+ }
121
+ if (plan.trustCodex) {
122
+ const home = process.env.CODEX_HOME ?? path.join(os.homedir(), ".codex");
123
+ const actualHome = fs.existsSync(home)
124
+ ? fs.realpathSync(home)
125
+ : path.resolve(home);
126
+ if (!path.isAbsolute(home) ||
127
+ actualHome === cwd ||
128
+ actualHome.startsWith(cwd + path.sep) ||
129
+ cwd.startsWith(actualHome + path.sep))
130
+ throw new Error("CODEX_HOME must be an absolute configuration directory outside the project");
131
+ plan.codexCommand = executable("codex", cwd);
132
+ if (!plan.codexCommand)
133
+ throw new Error("Codex is unavailable; deploy it through its system owner first");
134
+ verifyAssets(cwd, false);
135
+ const client = new CodexConfigClient(plan.codexCommand, cwd);
136
+ try {
137
+ await client.initialize();
138
+ projectConfig(await client.request("config/read", { cwd, includeLayers: true }), cwd);
139
+ }
140
+ finally {
141
+ await client.close();
142
+ }
143
+ }
144
+ if (plan.codegraph) {
145
+ plan.graphCommand = executable("codegraph", cwd);
146
+ if (!plan.graphCommand)
147
+ throw new Error("CodeGraph is unavailable; deploy it through Lifecycle first");
148
+ for (const command of [
149
+ "init",
150
+ "index",
151
+ "sync",
152
+ "status",
153
+ "install",
154
+ "serve",
155
+ ]) {
156
+ const help = capture(plan.graphCommand, [command, "--help"], cwd);
157
+ if (help.status !== 0 ||
158
+ !help.stdout.includes("--project-only") ||
159
+ (command === "init" && !help.stdout.includes("--no-git-hooks")))
160
+ throw new Error("CodeGraph lacks project initialization capabilities; upgrade through Lifecycle first");
161
+ }
162
+ if (process.env.CODEGRAPH_NO_WATCH === "1")
163
+ throw new Error("CodeGraph file watching is explicitly disabled; automatic setup will not override it");
164
+ }
165
+ }
166
+ export class CodexConfigClient {
167
+ process;
168
+ sequence = 0;
169
+ pending = new Map();
170
+ constructor(command, cwd) {
171
+ this.process = spawn(command, ["app-server"], {
172
+ cwd,
173
+ stdio: ["pipe", "pipe", "ignore"],
174
+ });
175
+ const lines = createInterface({ input: this.process.stdout });
176
+ lines.on("line", (line) => {
177
+ try {
178
+ if (line.length > 4 * 1024 * 1024)
179
+ throw new Error("Oversized Codex response");
180
+ const response = object(JSON.parse(line));
181
+ const pending = this.pending.get(Number(response.id));
182
+ if (!pending)
183
+ return;
184
+ this.pending.delete(Number(response.id));
185
+ clearTimeout(pending.timer);
186
+ if (response.error)
187
+ pending.reject(new Error("Codex rejected the configuration request"));
188
+ else
189
+ pending.resolve(response.result);
190
+ }
191
+ catch {
192
+ this.fail();
193
+ }
194
+ });
195
+ this.process.on("error", () => this.fail());
196
+ this.process.stdin.on("error", () => this.fail());
197
+ this.process.on("exit", () => {
198
+ lines.close();
199
+ this.fail();
200
+ });
201
+ }
202
+ fail() {
203
+ for (const pending of this.pending.values()) {
204
+ clearTimeout(pending.timer);
205
+ pending.reject(new Error("Codex configuration service closed or returned invalid data"));
206
+ }
207
+ this.pending.clear();
208
+ }
209
+ async request(method, params) {
210
+ const id = ++this.sequence;
211
+ return new Promise((resolve, reject) => {
212
+ const timer = setTimeout(() => {
213
+ this.pending.delete(id);
214
+ reject(new Error(`Codex ${method} timed out`));
215
+ }, 30_000);
216
+ this.pending.set(id, { resolve, reject, timer });
217
+ this.process.stdin.write(JSON.stringify({ id, method, params }) + "\n");
218
+ });
219
+ }
220
+ async initialize() {
221
+ await this.request("initialize", {
222
+ clientInfo: { name: "trellis-project-init", version: "1" },
223
+ capabilities: { experimentalApi: true },
224
+ });
225
+ this.process.stdin.write('{"method":"initialized"}\n');
226
+ }
227
+ async close() {
228
+ this.fail();
229
+ this.process.stdin.end();
230
+ this.process.kill("SIGTERM");
231
+ if (!this.process.pid ||
232
+ this.process.exitCode !== null ||
233
+ this.process.signalCode !== null)
234
+ return;
235
+ await new Promise((resolve) => {
236
+ const timer = setTimeout(() => this.process.kill("SIGKILL"), 5000);
237
+ this.process.once("exit", () => {
238
+ clearTimeout(timer);
239
+ resolve();
240
+ });
241
+ });
242
+ }
243
+ }
244
+ function projectConfig(value, cwd) {
245
+ const response = object(value);
246
+ if (!Array.isArray(response.layers))
247
+ throw new Error("Codex did not return configuration provenance");
248
+ let user, version;
249
+ for (const item of response.layers) {
250
+ const layer = object(item), name = object(layer.name), config = object(layer.config);
251
+ if (name.type === "user") {
252
+ user = config;
253
+ if (typeof layer.version === "string")
254
+ version = layer.version;
255
+ }
256
+ if (name.type !== "project")
257
+ continue;
258
+ if (name.dotCodexFolder !== path.join(cwd, ".codex"))
259
+ throw new Error("Unexpected ancestor project configuration");
260
+ if (Object.keys(config).some((k) => !["agents", "project_doc_fallback_filenames", "mcp_servers"].includes(k)))
261
+ throw new Error("Unknown project configuration requires review");
262
+ if (config.agents &&
263
+ JSON.stringify(config.agents) !== JSON.stringify({ enabled: false }))
264
+ throw new Error("Custom project agent configuration requires review");
265
+ if (config.project_doc_fallback_filenames &&
266
+ JSON.stringify(config.project_doc_fallback_filenames) !==
267
+ JSON.stringify(["AGENTS.md"]))
268
+ throw new Error("Custom instruction fallback requires review");
269
+ if (config.mcp_servers) {
270
+ const servers = object(config.mcp_servers);
271
+ if (Object.keys(servers).some((k) => k !== "codegraph"))
272
+ throw new Error("Unknown project MCP configuration requires review");
273
+ const graph = object(servers.codegraph);
274
+ const command = executable("codegraph", cwd);
275
+ if (graph.enabled === false ||
276
+ !command ||
277
+ typeof graph.command !== "string" ||
278
+ (graph.command !== "codegraph" &&
279
+ (!path.isAbsolute(graph.command) ||
280
+ fs.realpathSync(graph.command) !== command)) ||
281
+ !Array.isArray(graph.args))
282
+ throw new Error("CodeGraph project connection is disabled or has an unexpected binding");
283
+ const args = [...graph.args];
284
+ if (args.shift() !== "serve" || args.shift() !== "--mcp")
285
+ throw new Error("Custom CodeGraph command requires review");
286
+ while (args.length) {
287
+ const flag = args.shift();
288
+ if (flag === "--project-only")
289
+ continue;
290
+ if ((flag === "--path" || flag === "--bound-worktree") &&
291
+ args.shift() === cwd)
292
+ continue;
293
+ throw new Error("Custom CodeGraph arguments require review");
294
+ }
295
+ if (Object.keys(graph).some((k) => !["command", "args", "enabled"].includes(k)))
296
+ throw new Error("Custom CodeGraph project configuration requires review");
297
+ }
298
+ }
299
+ if (!user || !version)
300
+ throw new Error("Codex user configuration version is unavailable");
301
+ if (object(user.features ?? {}).hooks !== true)
302
+ throw new Error("Codex hooks are disabled; retain the user choice and configure through its owner");
303
+ const projects = object(user.projects ?? {});
304
+ const selected = object(projects[cwd] ?? {});
305
+ if (selected.trust_level && selected.trust_level !== "trusted")
306
+ throw new Error("Project has an explicit untrusted choice");
307
+ if (selected.trust_level !== "trusted") {
308
+ for (const [parent, value] of Object.entries(projects)) {
309
+ if (path.isAbsolute(parent) &&
310
+ cwd.startsWith(parent + path.sep) &&
311
+ object(value).trust_level === "untrusted")
312
+ throw new Error("Project has an inherited explicit untrusted choice");
313
+ }
314
+ }
315
+ return { user, version };
316
+ }
317
+ async function trustProject(cwd, plan) {
318
+ verifyAssets(cwd, true);
319
+ if (!plan.codexCommand)
320
+ throw new Error("Codex capability was not checked");
321
+ const client = new CodexConfigClient(plan.codexCommand, cwd);
322
+ try {
323
+ await client.initialize();
324
+ const read = async () => projectConfig(await client.request("config/read", { cwd, includeLayers: true }), cwd);
325
+ let state = await read();
326
+ if (object(object(state.user.projects ?? {})[cwd] ?? {}).trust_level !==
327
+ "trusted") {
328
+ await client.request("config/batchWrite", {
329
+ edits: [
330
+ {
331
+ keyPath: `projects.${JSON.stringify(cwd)}.trust_level`,
332
+ value: "trusted",
333
+ mergeStrategy: "replace",
334
+ },
335
+ ],
336
+ expectedVersion: state.version,
337
+ reloadUserConfig: true,
338
+ });
339
+ state = await read();
340
+ }
341
+ const inventory = async () => {
342
+ const response = object(await client.request("hooks/list", { cwds: [cwd] }));
343
+ if (!Array.isArray(response.data))
344
+ throw new Error("Invalid Codex Hook inventory");
345
+ return response.data.flatMap((entry) => {
346
+ const item = object(entry);
347
+ if (item.cwd !== cwd ||
348
+ !Array.isArray(item.hooks) ||
349
+ (Array.isArray(item.errors) && item.errors.length))
350
+ throw new Error("Codex Hook inventory is incomplete");
351
+ return item.hooks.map(object);
352
+ });
353
+ };
354
+ const hooks = (await inventory()).filter((h) => h.source === "project" &&
355
+ h.sourcePath === path.join(cwd, ".codex/hooks.json"));
356
+ const expectedText = renderTemplateMap(collectCodexTemplates()).get(".codex/hooks.json");
357
+ if (!expectedText)
358
+ throw new Error("Bundled Trellis Hook definitions are unavailable");
359
+ const expected = object(JSON.parse(expectedText));
360
+ const count = Object.values(object(expected.hooks)).reduce((sum, groups) => sum +
361
+ groups.reduce((n, group) => n + group.hooks.length, 0), 0);
362
+ if (hooks.length !== count ||
363
+ hooks.some((h) => h.enabled !== true ||
364
+ h.handlerType !== "command" ||
365
+ typeof h.key !== "string" ||
366
+ typeof h.currentHash !== "string"))
367
+ throw new Error("Managed Trellis Hook inventory is disabled or incomplete");
368
+ const approvals = {};
369
+ for (const hook of hooks) {
370
+ if (hook.trustStatus !== "trusted")
371
+ approvals[String(hook.key)] = { trusted_hash: hook.currentHash };
372
+ }
373
+ if (Object.keys(approvals).length) {
374
+ verifyAssets(cwd, true);
375
+ await client.request("config/batchWrite", {
376
+ edits: [
377
+ { keyPath: "hooks.state", value: approvals, mergeStrategy: "upsert" },
378
+ ],
379
+ expectedVersion: state.version,
380
+ reloadUserConfig: true,
381
+ });
382
+ }
383
+ const after = await inventory();
384
+ if (hooks.some((h) => !after.some((a) => a.key === h.key &&
385
+ a.currentHash === h.currentHash &&
386
+ a.trustStatus === "trusted" &&
387
+ a.enabled === true)))
388
+ throw new Error("Codex Hook trust readback did not match");
389
+ console.log("Codex project trust and managed Trellis Hooks: ready");
390
+ }
391
+ finally {
392
+ await client.close();
393
+ }
394
+ }
395
+ function graphStatus(command, cwd) {
396
+ const result = capture(command, ["status", cwd, "--json", "--project-only"], cwd);
397
+ if (result.status !== 0)
398
+ throw new Error("CodeGraph status failed; inspect with its native CLI");
399
+ const status = object(JSON.parse(result.stdout));
400
+ if (status.projectPath !== cwd)
401
+ throw new Error("CodeGraph returned a different project root");
402
+ return status;
403
+ }
404
+ async function runGraph(command, args, cwd) {
405
+ await new Promise((resolve, reject) => {
406
+ const child = spawn(command, args, { cwd, stdio: "inherit" });
407
+ child.once("error", () => reject(new Error("Could not start CodeGraph")));
408
+ child.once("exit", (code) => code === 0
409
+ ? resolve()
410
+ : reject(new Error("CodeGraph initialization step failed; keep completed assets and retry native init")));
411
+ });
412
+ }
413
+ export async function completeProjectInit(cwd, plan) {
414
+ if (!plan.trustCodex && !plan.codegraph)
415
+ return;
416
+ if (!fs.existsSync(path.join(cwd, ".codex/config.toml")))
417
+ return;
418
+ await preflightProjectInit(cwd, plan);
419
+ if (plan.codegraph) {
420
+ if (!plan.graphCommand)
421
+ throw new Error("CodeGraph capability was not checked");
422
+ const args = [
423
+ "install",
424
+ "--target",
425
+ "codex",
426
+ "--location",
427
+ "local",
428
+ "--yes",
429
+ "--project-only",
430
+ ];
431
+ const git = executable("git", cwd);
432
+ if (git && capture(git, ["rev-parse", "--show-toplevel"], cwd).status === 0)
433
+ args.push("--bound-worktree", cwd);
434
+ await runGraph(plan.graphCommand, args, cwd);
435
+ }
436
+ if (plan.trustCodex)
437
+ await trustProject(cwd, plan);
438
+ if (plan.codegraph) {
439
+ const command = plan.graphCommand;
440
+ if (!command)
441
+ throw new Error("CodeGraph capability was not checked");
442
+ let status = graphStatus(command, cwd);
443
+ if (status.rebuildInProgress)
444
+ throw new Error("CodeGraph has an active writer; retry after it finishes");
445
+ if (!status.initialized)
446
+ await runGraph(command, [
447
+ "init",
448
+ cwd,
449
+ "--yes",
450
+ "--local-only",
451
+ "--project-only",
452
+ "--no-git-hooks",
453
+ ], cwd);
454
+ else {
455
+ const index = object(status.index);
456
+ if (index.state !== "complete" ||
457
+ index.reindexRecommended === true ||
458
+ Number(index.pendingRefs) > 0)
459
+ await runGraph(command, ["index", cwd, "--project-only", "--quiet"], cwd);
460
+ else if (Object.values(object(status.pendingChanges)).some((n) => typeof n === "number" && n > 0) ||
461
+ Number(index.filesNeedingReindex) > 0)
462
+ await runGraph(command, ["sync", cwd, "--project-only"], cwd);
463
+ }
464
+ status = graphStatus(command, cwd);
465
+ const strict = capture(command, ["status", cwd, "--json", "--strict", "--project-only"], cwd);
466
+ if (strict.status !== 0 || object(status.index).state !== "complete")
467
+ throw new Error("CodeGraph index is not ready; inspect its native status");
468
+ const inventory = capture(command, ["files", "--path", cwd, "--json"], cwd);
469
+ const files = JSON.parse(inventory.stdout);
470
+ if (inventory.status !== 0 || !Array.isArray(files))
471
+ throw new Error("CodeGraph file coverage could not be verified");
472
+ if (!files.some((file) => {
473
+ const name = object(file).path;
474
+ return (typeof name === "string" &&
475
+ ![".trellis/", ".codex/", ".agents/"].some((prefix) => name.startsWith(prefix)));
476
+ }))
477
+ console.log("No supported project source is indexed yet; workflow helpers do not establish business-code coverage.");
478
+ console.log("CodeGraph project connection and index: ready. MCP loading and live sync require a new host session.");
479
+ }
480
+ if (!fs.existsSync(path.join(cwd, ".trellis/.developer")))
481
+ throw new Error("Project tools prepared, but Trellis developer identity is incomplete; rerun init with --user");
482
+ console.log("Trellis assets: ready. Keep the native bootstrap/onboarding task for project guideline development.");
483
+ }
484
+ //# sourceMappingURL=project-init.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"project-init.js","sourceRoot":"","sources":["../../src/utils/project-init.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,KAAK,EAAE,SAAS,EAAyB,MAAM,oBAAoB,CAAC;AAC7E,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAClE,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAa9D,SAAS,MAAM,CAAC,KAAc;IAC5B,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QAC7D,MAAM,I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