codealmanac 0.2.5 → 0.2.7

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 (79) hide show
  1. package/README.md +25 -20
  2. package/dist/{agents-RVTQYE6A.js → agents-V2ZOIACP.js} +6 -5
  3. package/dist/{chunk-P5WGG4FJ.js → chunk-5BWUMAOX.js} +2 -2
  4. package/dist/chunk-5BWUMAOX.js.map +1 -0
  5. package/dist/{chunk-KQUVMF27.js → chunk-BFIG2CXM.js} +2 -516
  6. package/dist/chunk-BFIG2CXM.js.map +1 -0
  7. package/dist/{chunk-DL5BXZCX.js → chunk-BQY5L3DL.js} +3 -53
  8. package/dist/chunk-BQY5L3DL.js.map +1 -0
  9. package/dist/{chunk-F53U6JQG.js → chunk-CQJVM34R.js} +2 -2
  10. package/dist/chunk-FUBE6KCO.js +124 -0
  11. package/dist/chunk-FUBE6KCO.js.map +1 -0
  12. package/dist/chunk-IZBXXAVL.js +524 -0
  13. package/dist/chunk-IZBXXAVL.js.map +1 -0
  14. package/dist/{chunk-7JUX4ADQ.js → chunk-IZT6RBHS.js} +1 -1
  15. package/dist/{chunk-SMIK2YLU.js → chunk-JLQZELHQ.js} +82 -88
  16. package/dist/chunk-JLQZELHQ.js.map +1 -0
  17. package/dist/{chunk-TT6ZP4GS.js → chunk-KZXWPG4P.js} +2 -2
  18. package/dist/{chunk-6BJUYZ43.js → chunk-QIA22IAM.js} +8 -16
  19. package/dist/chunk-QIA22IAM.js.map +1 -0
  20. package/dist/{chunk-BGUID5BS.js → chunk-RALBM6HZ.js} +20 -139
  21. package/dist/chunk-RALBM6HZ.js.map +1 -0
  22. package/dist/{chunk-TILAKDN6.js → chunk-U5DLLWIC.js} +3 -3
  23. package/dist/chunk-WL4UE7Q6.js +1386 -0
  24. package/dist/chunk-WL4UE7Q6.js.map +1 -0
  25. package/dist/{chunk-GFUB57IT.js → chunk-ZUQN5Y3K.js} +48 -124
  26. package/dist/chunk-ZUQN5Y3K.js.map +1 -0
  27. package/dist/{chunk-MRRX4UQB.js → chunk-ZZLLOAI6.js} +3 -3
  28. package/dist/{cli-CL4ID7EO.js → cli-XWPNARA6.js} +35 -18
  29. package/dist/cli-XWPNARA6.js.map +1 -0
  30. package/dist/codealmanac.js +1 -1
  31. package/dist/{config-ML2RCR7J.js → config-KH3JUMG6.js} +4 -4
  32. package/dist/doctor-ENJT665Z.js +18 -0
  33. package/dist/paths-O5CZADP2.js +14 -0
  34. package/dist/process-KFSLENL3.js +61 -0
  35. package/dist/{register-commands-FBJ6XQ3L.js → register-commands-LULZUSPO.js} +993 -1015
  36. package/dist/register-commands-LULZUSPO.js.map +1 -0
  37. package/dist/uninstall-BD4MMQ7M.js +16 -0
  38. package/dist/uninstall-BD4MMQ7M.js.map +1 -0
  39. package/dist/update-XSKPDFMJ.js +11 -0
  40. package/dist/update-XSKPDFMJ.js.map +1 -0
  41. package/dist/{wiki-IGNRNLUZ.js → wiki-O4RWMAE6.js} +8 -6
  42. package/dist/wiki-O4RWMAE6.js.map +1 -0
  43. package/guides/mini.md +11 -9
  44. package/guides/reference.md +96 -39
  45. package/hooks/almanac-capture.sh +7 -8
  46. package/package.json +1 -1
  47. package/prompts/agents/.gitkeep +1 -0
  48. package/prompts/base/notability.md +139 -0
  49. package/prompts/base/purpose.md +85 -0
  50. package/prompts/base/syntax.md +114 -0
  51. package/prompts/operations/absorb.md +43 -0
  52. package/prompts/operations/build.md +49 -0
  53. package/prompts/operations/garden.md +51 -0
  54. package/dist/chunk-6BJUYZ43.js.map +0 -1
  55. package/dist/chunk-BGUID5BS.js.map +0 -1
  56. package/dist/chunk-DL5BXZCX.js.map +0 -1
  57. package/dist/chunk-GFUB57IT.js.map +0 -1
  58. package/dist/chunk-KQUVMF27.js.map +0 -1
  59. package/dist/chunk-P5WGG4FJ.js.map +0 -1
  60. package/dist/chunk-SMIK2YLU.js.map +0 -1
  61. package/dist/cli-CL4ID7EO.js.map +0 -1
  62. package/dist/doctor-DOLJRGS4.js +0 -17
  63. package/dist/register-commands-FBJ6XQ3L.js.map +0 -1
  64. package/dist/uninstall-DX6LFKMX.js +0 -15
  65. package/dist/update-P2IPG7RO.js +0 -11
  66. package/dist/wiki-IGNRNLUZ.js.map +0 -1
  67. package/prompts/bootstrap.md +0 -176
  68. package/prompts/reviewer.md +0 -129
  69. package/prompts/writer.md +0 -134
  70. /package/dist/{agents-RVTQYE6A.js.map → agents-V2ZOIACP.js.map} +0 -0
  71. /package/dist/{chunk-F53U6JQG.js.map → chunk-CQJVM34R.js.map} +0 -0
  72. /package/dist/{chunk-7JUX4ADQ.js.map → chunk-IZT6RBHS.js.map} +0 -0
  73. /package/dist/{chunk-TT6ZP4GS.js.map → chunk-KZXWPG4P.js.map} +0 -0
  74. /package/dist/{chunk-TILAKDN6.js.map → chunk-U5DLLWIC.js.map} +0 -0
  75. /package/dist/{chunk-MRRX4UQB.js.map → chunk-ZZLLOAI6.js.map} +0 -0
  76. /package/dist/{config-ML2RCR7J.js.map → config-KH3JUMG6.js.map} +0 -0
  77. /package/dist/{doctor-DOLJRGS4.js.map → doctor-ENJT665Z.js.map} +0 -0
  78. /package/dist/{uninstall-DX6LFKMX.js.map → paths-O5CZADP2.js.map} +0 -0
  79. /package/dist/{update-P2IPG7RO.js.map → process-KFSLENL3.js.map} +0 -0
@@ -0,0 +1,85 @@
1
+ # Wiki Purpose
2
+
3
+ CodeAlmanac is cultivated project memory.
4
+
5
+ The wiki is a deep-research cache over the project. It preserves the
6
+ understanding that an expert agent builds after reading, tracing, comparing,
7
+ and connecting raw inputs. Future agents should start from this reusable
8
+ understanding instead of repeatedly reorienting from zero.
9
+
10
+ The codebase is the anchor, not the boundary. The wiki may absorb code,
11
+ sessions, docs, research, market reads, product thinking, incidents,
12
+ conversations, external systems, laws, papers, team practices, and anything
13
+ else that materially shapes work on the project.
14
+
15
+ The page is not the raw input. The input is material to be distilled into the
16
+ project's memory.
17
+
18
+ ## The Core Test
19
+
20
+ A wiki change is valuable when it preserves durable, reusable project
21
+ understanding that would be costly, useful, or risky to reconstruct later.
22
+
23
+ That includes:
24
+
25
+ - how the codebase works
26
+ - what named entities mean in this project
27
+ - how subsystems, files, commands, and external systems interact
28
+ - what conclusions were drawn from reading docs or doing research
29
+ - what the project currently believes about product, users, market, or design
30
+ - what decisions, constraints, risks, and incidents should shape future work
31
+ - what is intentionally not used or not done
32
+
33
+ Do not reduce the wiki to a bug-prevention notebook. Avoiding future mistakes
34
+ matters, but the larger goal is reusable understanding.
35
+
36
+ ## Project-World Map
37
+
38
+ Pages may cover things outside the repo when they matter to the project.
39
+ `stripe.md`, `postgres.md`, `claude-agent-sdk.md`,
40
+ `anthropic-prompt-caching.md`, or `agent-tools-market.md` can all be valid
41
+ pages.
42
+
43
+ Do not copy the world. Preserve the useful understanding produced by engaging
44
+ with the world.
45
+
46
+ For an external thing, write about its role in this project:
47
+
48
+ - what we use
49
+ - what we do not use
50
+ - what assumptions we rely on
51
+ - what versions, APIs, contracts, or docs matter
52
+ - what conclusions we reached
53
+ - what pages, decisions, code, or project beliefs it connects to
54
+
55
+ Pure reference material is allowed when it is reusable project memory. It still
56
+ needs to be distilled, grounded, and connected to the project graph.
57
+
58
+ ## Synthesis Over Logs
59
+
60
+ Prefer evolving synthesis pages over chronological logs.
61
+
62
+ If an input says something about market sentiment, pricing, product
63
+ positioning, user trust, an external dependency, or an internal subsystem,
64
+ fold it into the durable page that tracks that idea.
65
+
66
+ Create a temporal page only when the time, event, or snapshot is itself part of
67
+ the meaning. A dated market read, incident, migration, API breaking change, or
68
+ launch-period observation may deserve a temporal page. If you create one, also
69
+ connect it to the synthesis page or hub it informs.
70
+
71
+ The wiki is not a diary, transcript store, or progress log. It is cultivated
72
+ project memory.
73
+
74
+ ## Inputs Are Starting Points
75
+
76
+ Build starts from the repo corpus.
77
+
78
+ Absorb starts from a concrete input: a session, file, folder, diff, document,
79
+ research note, market read, conversation, or other context.
80
+
81
+ Garden starts from the current wiki graph.
82
+
83
+ In every case, the starting point is not a boundary. Inspect related code,
84
+ wiki pages, docs, tests, history, or sources when useful. Keep the scope
85
+ proportional to what the input reveals.
@@ -0,0 +1,114 @@
1
+ # Page Syntax And Writing Conventions
2
+
3
+ Write markdown pages directly under `.almanac/pages/`. Use kebab-case slugs.
4
+ The filename is the stable page identity.
5
+
6
+ Use natural names. Prefer `stripe.md`, `postgres.md`,
7
+ `claude-agent-sdk.md`, `agent-tools-market.md`, and
8
+ `pricing-sensitivity.md` over genre-prefixed names such as
9
+ `dependency-stripe.md` or `research-agent-tools-market.md`.
10
+
11
+ ## Frontmatter
12
+
13
+ Use YAML frontmatter when it helps indexing and future agents.
14
+
15
+ Common fields:
16
+
17
+ ```yaml
18
+ ---
19
+ title: Human Readable Title
20
+ topics: [topic-one, topic-two]
21
+ files:
22
+ - src/path/to/file.ts
23
+ sources:
24
+ - https://example.com/docs
25
+ status: active
26
+ verified: 2026-05-10
27
+ external_version: "api-or-doc-version-if-relevant"
28
+ supersedes: old-page-slug
29
+ superseded_by: new-page-slug
30
+ archived_at: 2026-05-10
31
+ ---
32
+ ```
33
+
34
+ `title`, `topics`, `files`, `archived_at`, `supersedes`, and
35
+ `superseded_by` are understood by current tooling. Other fields are allowed as
36
+ durable prompt-level conventions and future index inputs.
37
+
38
+ Use `files:` for repo files and folders that support the page. Use `sources:`
39
+ for external docs, papers, URLs, transcripts, notes, market reads, research
40
+ inputs, commits, or other non-repo material that supports the page.
41
+
42
+ Do not add fields mechanically. Frontmatter should make the page more
43
+ retrievable, grounded, or maintainable.
44
+
45
+ ## Wikilinks
46
+
47
+ Use one `[[...]]` syntax:
48
+
49
+ - `[[page-slug]]` links to another wiki page.
50
+ - `[[src/indexer/schema.ts]]` references a repo file.
51
+ - `[[src/indexer/]]` references a repo folder.
52
+ - `[[other-wiki:page-slug]]` references another wiki.
53
+
54
+ Disambiguation is content-based:
55
+
56
+ - contains `:` before `/` means cross-wiki
57
+ - contains `/` means file or folder
58
+ - trailing `/` means folder
59
+ - otherwise it is a page slug
60
+
61
+ Link the first meaningful mention of a related page in a section. Do not link
62
+ every repeated word. A page with no inbound or outbound links is suspect.
63
+
64
+ ## Grounding
65
+
66
+ Ground non-obvious claims in code, tests, docs, sources, commits, prior wiki
67
+ pages, or explicit user-provided context.
68
+
69
+ Do not pretend uncertainty is fact. If a claim matters and cannot be grounded,
70
+ either omit it or mark it as an open question.
71
+
72
+ For external docs or research, cite the source and preserve the conclusion that
73
+ matters to this project. Do not copy long external passages into the wiki.
74
+
75
+ For code claims, prefer exact file references in `files:` and links in prose.
76
+ For behavior claims, inspect tests when available.
77
+
78
+ ## Page Shape
79
+
80
+ Start with a lead. The lead should stand alone: a future agent should know what
81
+ the page is about, why it exists, and whether to keep reading.
82
+
83
+ After the lead, use sections based on the page's job. Common sections include:
84
+
85
+ - What it is in this project
86
+ - Where it lives
87
+ - How it works
88
+ - What we use
89
+ - What we do not use
90
+ - Contracts and assumptions
91
+ - Related flows
92
+ - Current synthesis
93
+ - Open questions
94
+ - Verification
95
+ - Related pages
96
+
97
+ Use prose for explanation. Use bullets for real lists. Use tables only for
98
+ structured comparison.
99
+
100
+ ## Style
101
+
102
+ Be direct, factual, and dense. Write for future coding agents.
103
+
104
+ Avoid:
105
+
106
+ - generic library tutorials
107
+ - vague claims
108
+ - marketing prose
109
+ - unsupported rationale
110
+ - transcript language
111
+ - "this file contains" summaries
112
+ - conclusions that do not connect to future work
113
+
114
+ Every edit should make the graph easier to understand, navigate, or trust.
@@ -0,0 +1,43 @@
1
+ # Absorb Operation
2
+
3
+ You are improving an existing CodeAlmanac wiki from a starting context.
4
+
5
+ The base prompt modules define the wiki purpose, notability rules, page
6
+ structure, and writing syntax. Follow them.
7
+
8
+ The input may be a coding session, file, folder, diff, document, docs read,
9
+ research note, market read, product conversation, incident, user feedback, or
10
+ other concrete pointer. Treat that input as raw material, not as the output.
11
+
12
+ ## Algorithm
13
+
14
+ 1. Understand the starting context and what kind of input it is.
15
+ 2. Extract candidate durable learnings, conclusions, entities, changed
16
+ assumptions, project-world connections, risks, and synthesis updates.
17
+ 3. Inspect the current wiki for the right home before creating pages.
18
+ 4. Verify important claims against code, tests, docs, sources, git history, or
19
+ the provided context when useful.
20
+ 5. Prefer updating existing evolving pages over creating new pages.
21
+ 6. Create a new page only when the input reveals a durable concept that needs
22
+ its own anchor.
23
+ 7. Avoid temporal pages unless the date, event, or snapshot is part of the
24
+ meaning. If you create a temporal page, also update or link the synthesis
25
+ page or hub it informs.
26
+ 8. Update topics and links so the new understanding joins the graph.
27
+ 9. No-op when the input does not improve durable project memory.
28
+
29
+ Do not summarize sessions, files, docs, market reads, or conversations. Distill
30
+ their reusable project meaning.
31
+
32
+ Keep changes proportional to the input. Broad restructuring is valid when the
33
+ input reveals a real graph problem, but do not churn unrelated pages.
34
+
35
+ ## Helper Agents
36
+
37
+ Most Absorb runs should be single-agent. If the input spans multiple
38
+ independent areas, requires external verification, or is large enough that
39
+ parallel investigation will materially improve quality, use helper/subagents
40
+ for bounded research or draft fragments.
41
+
42
+ The main agent owns final integration, page boundaries, topics, links, hubs,
43
+ and final prose.
@@ -0,0 +1,49 @@
1
+ # Build Operation
2
+
3
+ You are building the first substantial CodeAlmanac wiki for this repository.
4
+
5
+ The base prompt modules define the wiki purpose, notability rules, page
6
+ structure, and writing syntax. Follow them.
7
+
8
+ Your job is to perform a deep first construction pass. Create a reusable
9
+ project memory layer, not a stub wiki and not a file-tree summary.
10
+
11
+ ## Algorithm
12
+
13
+ 1. Orient to the corpus: repo layout, commands, package/config files, docs,
14
+ entrypoints, generated outputs, tests, schemas, data files, and external
15
+ dependencies.
16
+ 2. Build a working map of the repo from multiple angles: entities,
17
+ subsystems, flows, contracts, data models, operations, external systems,
18
+ product/project concepts, and dense clusters.
19
+ 3. Investigate important areas deeply enough to explain how they work and how
20
+ they connect. Tests are often the clearest source of intended behavior.
21
+ 4. Compare code against existing docs and research. Do not copy docs; preserve
22
+ the applied conclusions and project-specific meaning.
23
+ 5. Identify page candidates by future value. Ask whether each page preserves
24
+ understanding that would be costly, useful, or risky to reconstruct later.
25
+ 6. Design the initial graph: pages, topics, links, and any local hubs.
26
+ 7. Write detailed, grounded pages directly under `.almanac/pages/`.
27
+ 8. Re-read the wiki as a future agent. Fix weak leads, duplicate pages,
28
+ unsupported claims, missing links, topic noise, and thin placeholders.
29
+
30
+ Be thorough. Create many pages when many pages are justified. Do not stay tiny
31
+ to be safe. The quality gate is not page count; it is whether each page earns
32
+ its place in the project graph.
33
+
34
+ ## Helper Agents
35
+
36
+ If the provider supports helper/subagents and the repo is broad enough, use
37
+ them for bounded investigation or draft fragments. Good helper tasks include
38
+ investigating one subsystem, tracing one flow, reading tests for one area,
39
+ checking an external dependency, or identifying page candidates for one
40
+ cluster.
41
+
42
+ The main agent owns final synthesis, page boundaries, topics, links, hubs, and
43
+ final prose. Do not let helpers independently create disconnected final wiki
44
+ structure.
45
+
46
+ ## Output Standard
47
+
48
+ The output is a coherent `.almanac/` wiki. It should let a future agent form a
49
+ working model of the project faster than by starting from raw files.
@@ -0,0 +1,51 @@
1
+ # Garden Operation
2
+
3
+ You are improving an existing CodeAlmanac wiki as a whole graph.
4
+
5
+ The base prompt modules define the wiki purpose, notability rules, page
6
+ structure, and writing syntax. Follow them.
7
+
8
+ Garden is cultivation. The goal is not to add activity; the goal is to make the
9
+ project memory more coherent, navigable, current, and trustworthy.
10
+
11
+ ## Algorithm
12
+
13
+ 1. Inspect pages, topics, links, hubs, archived pages, supersession chains,
14
+ referenced files, and cited sources where useful.
15
+ 2. Find graph problems: duplicate pages, thin placeholders, stale claims,
16
+ missing anchors, missing links, bloated pages, confusing topics, broken
17
+ references, unsupported claims, disconnected temporal notes, and clusters
18
+ that need hubs.
19
+ 3. Prefer synthesis over logs. Fold date-stamped fragments into evolving pages
20
+ when chronology is not itself important.
21
+ 4. Merge overlapping pages. Split pages that now contain multiple independent
22
+ concepts. Archive or supersede stale pages when history still matters.
23
+ 5. Improve topic neighborhoods. Prefer stable cluster names over bookkeeping
24
+ labels.
25
+ 6. Create or revise hubs when a dense cluster needs reading order and
26
+ interpretation.
27
+ 7. Re-read edited areas as a future agent. Verify that leads, links,
28
+ frontmatter, and page boundaries make the graph easier to use.
29
+
30
+ You may create, update, rewrite, merge, split, archive, supersede, retopic,
31
+ relink, or create hub/index pages when that improves the wiki. No-op is valid if
32
+ the wiki is already coherent enough for the current pass.
33
+
34
+ Do not churn the wiki just to show activity. Do not rewrite unrelated pages for
35
+ style. Make broad changes only when the graph shape justifies them.
36
+
37
+ ## Helper Agents
38
+
39
+ If the provider supports helper/subagents and the wiki is broad enough, use
40
+ them for bounded audits: duplicate detection, stale reference checks, topic
41
+ cluster review, hub candidates, source grounding, or one dense area of the
42
+ graph.
43
+
44
+ The main agent owns final synthesis, page boundaries, topics, links, hubs, and
45
+ final prose.
46
+
47
+ ## Output Standard
48
+
49
+ The output is a more coherent `.almanac/` wiki. Every edit should make the
50
+ project memory easier for a future coding agent to understand, navigate, or
51
+ trust.
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/commands/agents.ts"],"sourcesContent":["import {\n buildProviderSetupView,\n parseAgentSelection,\n type ProviderReadiness,\n} from \"../agent/provider-view.js\";\nimport {\n isAgentProviderId,\n readConfig,\n writeConfig,\n type AgentProviderId,\n} from \"../update/config.js\";\n\nexport interface AgentsResult {\n stdout: string;\n stderr: string;\n exitCode: number;\n}\n\nexport async function runAgentsList(): Promise<AgentsResult> {\n const view = await buildProviderSetupView();\n const active = view.choices.find((choice) => choice.selected);\n const activeModel = active?.effectiveModel ?? \"provider default\";\n const lines = [\n \"codealmanac agents\",\n `current: ${view.defaultProvider} (model: ${activeModel})`,\n \"\",\n ];\n for (const choice of view.choices) {\n const selected = choice.selected ? \"*\" : \" \";\n const recommended = choice.recommended ? \"recommended\" : \"\";\n const model = choice.effectiveModel ?? \"provider default\";\n const detail = choice.account ?? choice.fixCommand ?? choice.detail;\n lines.push(\n [\n selected,\n choice.label.padEnd(6),\n readinessLabel(choice.readiness).padEnd(15),\n recommended.padEnd(11),\n `model: ${model}`.padEnd(31),\n detail,\n ].join(\" \").trimEnd(),\n );\n }\n lines.push(\n \"\",\n \"Change provider: almanac agents use <claude|codex|cursor>\",\n \"Set model: almanac agents model <provider> <model>\",\n \"Reset model: almanac agents model <provider> --default\",\n );\n return { stdout: `${lines.join(\"\\n\")}\\n`, stderr: \"\", exitCode: 0 };\n}\n\nexport async function runAgentsDoctor(): Promise<AgentsResult> {\n const view = await buildProviderSetupView();\n const lines = [\"codealmanac agent doctor\\n\"];\n for (const choice of view.choices) {\n lines.push(`${choice.ready ? \"✓\" : \"✗\"} ${choice.label}`);\n lines.push(` status: ${readinessLabel(choice.readiness)}`);\n lines.push(` model: ${choice.effectiveModel ?? \"provider default\"}`);\n if (choice.account !== null) {\n lines.push(` account: ${choice.account}`);\n } else if (choice.detail.length > 0) {\n lines.push(` detail: ${choice.detail}`);\n }\n if (choice.fixCommand !== null) lines.push(` fix: ${choice.fixCommand}`);\n lines.push(\"\");\n }\n return { stdout: `${lines.join(\"\\n\").trimEnd()}\\n`, stderr: \"\", exitCode: 0 };\n}\n\nexport interface SetDefaultAgentOptions {\n provider: string;\n}\n\nexport async function runSetDefaultAgent(\n opts: SetDefaultAgentOptions,\n): Promise<AgentsResult> {\n return setDefaultAgent(opts);\n}\n\nexport async function runDeprecatedSetDefaultAgent(\n opts: SetDefaultAgentOptions,\n): Promise<AgentsResult> {\n return withDeprecation(\n await setDefaultAgent(opts),\n \"almanac set default-agent <provider>\",\n \"almanac agents use <provider>\",\n );\n}\n\nexport async function runAgentsUse(opts: SetDefaultAgentOptions): Promise<AgentsResult> {\n return setDefaultAgent(opts);\n}\n\nasync function setDefaultAgent(\n opts: SetDefaultAgentOptions,\n): Promise<AgentsResult> {\n const parsed = parseAgentSelection(opts.provider);\n if (parsed.provider === null) {\n return {\n stdout: \"\",\n stderr:\n `almanac: unknown agent '${opts.provider}'. ` +\n \"Expected one of: claude, codex, cursor.\\n\",\n exitCode: 1,\n };\n }\n const provider = parsed.provider;\n const config = await readConfig();\n const next = {\n ...config,\n agent: {\n ...config.agent,\n default: provider,\n models:\n parsed.model === undefined\n ? config.agent.models\n : {\n ...config.agent.models,\n [provider]: parsed.model,\n },\n },\n };\n await writeConfig(next);\n return {\n stdout:\n parsed.model === undefined\n ? `codealmanac: default provider set to ${provider}.\\n`\n : `codealmanac: default provider set to ${provider}; ${provider} model set to ${parsed.model}.\\n`,\n stderr: \"\",\n exitCode: 0,\n };\n}\n\nexport async function runSetAgentModel(opts: {\n provider: string;\n model?: string;\n defaultModel?: boolean;\n}): Promise<AgentsResult> {\n return setProviderModel(opts);\n}\n\nexport async function runDeprecatedSetAgentModel(opts: {\n provider: string;\n model?: string;\n defaultModel?: boolean;\n}): Promise<AgentsResult> {\n return withDeprecation(\n await setProviderModel(opts),\n \"almanac set model <provider> <model>\",\n \"almanac agents model <provider> <model>\",\n );\n}\n\nexport async function runAgentsModel(opts: {\n provider: string;\n model?: string;\n defaultModel?: boolean;\n}): Promise<AgentsResult> {\n return setProviderModel(opts);\n}\n\nasync function setProviderModel(opts: {\n provider: string;\n model?: string;\n defaultModel?: boolean;\n}): Promise<AgentsResult> {\n if (!isAgentProviderId(opts.provider)) {\n return {\n stdout: \"\",\n stderr:\n `almanac: unknown agent '${opts.provider}'. ` +\n \"Expected one of: claude, codex, cursor.\\n\",\n exitCode: 1,\n };\n }\n if (\n opts.defaultModel !== true &&\n (opts.model === undefined || opts.model.length === 0)\n ) {\n return {\n stdout: \"\",\n stderr:\n `almanac: missing model for ${opts.provider}. ` +\n \"Pass a model id or --default.\\n\",\n exitCode: 1,\n };\n }\n const provider = opts.provider as AgentProviderId;\n const config = await readConfig();\n const model = normalizeRequestedModel(opts);\n await writeConfig({\n ...config,\n agent: {\n ...config.agent,\n models: {\n ...config.agent.models,\n [provider]: model,\n },\n },\n });\n return {\n stdout:\n model === null\n ? `codealmanac: ${provider} model reset to provider default.\\n`\n : `codealmanac: ${provider} model set to ${model}.\\n`,\n stderr: \"\",\n exitCode: 0,\n };\n}\n\nfunction normalizeRequestedModel(opts: {\n provider: string;\n model?: string;\n defaultModel?: boolean;\n}): string | null {\n if (opts.defaultModel === true) return null;\n if (opts.model === undefined || opts.model.length === 0) return null;\n if (opts.model === \"default\" || opts.model === \"null\") return null;\n return opts.model;\n}\n\nfunction readinessLabel(readiness: ProviderReadiness): string {\n switch (readiness) {\n case \"ready\":\n return \"ready\";\n case \"missing\":\n return \"missing\";\n case \"not-authenticated\":\n return \"not ready\";\n }\n}\n\nfunction withDeprecation(\n result: AgentsResult,\n oldUsage: string,\n newUsage: string,\n): AgentsResult {\n return {\n ...result,\n stderr:\n `almanac: warning: \\`${oldUsage}\\` is deprecated; use \\`${newUsage}\\`.\\n` +\n result.stderr,\n };\n}\n"],"mappings":";;;;;;;;;;;;AAkBA,eAAsB,gBAAuC;AAC3D,QAAM,OAAO,MAAM,uBAAuB;AAC1C,QAAM,SAAS,KAAK,QAAQ,KAAK,CAAC,WAAW,OAAO,QAAQ;AAC5D,QAAM,cAAc,QAAQ,kBAAkB;AAC9C,QAAM,QAAQ;AAAA,IACZ;AAAA,IACA,YAAY,KAAK,eAAe,YAAY,WAAW;AAAA,IACvD;AAAA,EACF;AACA,aAAW,UAAU,KAAK,SAAS;AACjC,UAAM,WAAW,OAAO,WAAW,MAAM;AACzC,UAAM,cAAc,OAAO,cAAc,gBAAgB;AACzD,UAAM,QAAQ,OAAO,kBAAkB;AACvC,UAAM,SAAS,OAAO,WAAW,OAAO,cAAc,OAAO;AAC7D,UAAM;AAAA,MACJ;AAAA,QACE;AAAA,QACA,OAAO,MAAM,OAAO,CAAC;AAAA,QACrB,eAAe,OAAO,SAAS,EAAE,OAAO,EAAE;AAAA,QAC1C,YAAY,OAAO,EAAE;AAAA,QACrB,UAAU,KAAK,GAAG,OAAO,EAAE;AAAA,QAC3B;AAAA,MACF,EAAE,KAAK,GAAG,EAAE,QAAQ;AAAA,IACtB;AAAA,EACF;AACA,QAAM;AAAA,IACJ;AA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AM,YAAY;AAAA,IAChB,GAAG;AAAA,IACH,OAAO;AAAA,MACL,GAAG,OAAO;AAAA,MACV,QAAQ;AAAA,QACN,GAAG,OAAO,MAAM;AAAA,QAChB,CAAC,QAAQ,GAAG;AAAA,MACd;AAAA,IACF;AAAA,EACF,CAAC;AACD,SAAO;AAAA,IACL,QACE,UAAU,OACN,gBAAgB,QAAQ;AAAA,IACxB,gBAAgB,QAAQ,iBAAiB,KAAK;AAAA;AAAA,IACpD,QAAQ;AAAA,IACR,UAAU;AAAA,EACZ;AACF;AAEA,SAAS,wBAAwB,MAIf;AAChB,MAAI,KAAK,iBAAiB,KAAM,QAAO;AACvC,MAAI,KAAK,UAAU,UAAa,KAAK,MAAM,WAAW,EAAG,QAAO;AAChE,MAAI,KAAK,UAAU,aAAa,KAAK,UAAU,OAAQ,QAAO;AAC9D,SAAO,KAAK;AACd;AAEA,SAAS,eAAe,WAAsC;AAC5D,UAAQ,WAAW;AAAA,IACjB,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,EACX;AACF;AAEA,SAAS,gBACP,QACA,UACA,UACc;AACd,SAAO;AAAA,IACL,GAAG;AAAA,IACH,QACE,uBAAuB,QAAQ,2BAA2B,QAAQ;AAAA,IAClE,OAAO;AAAA,EACX;AACF;","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/agent/providers/claude/index.ts","../src/agent/providers/claude/auth.ts","../src/agent/providers/cli-status.ts","../src/agent/providers/jsonl-cli.ts","../src/agent/providers/prompt.ts","../src/agent/providers/codex-cli.ts","../src/agent/providers/cursor-cli.ts","../src/agent/providers/status.ts","../src/agent/providers/index.ts","../src/agent/provider-view.ts"],"sourcesContent":["import { query } from \"@anthropic-ai/claude-agent-sdk\";\n\nimport type {\n AgentProvider,\n AgentProviderMetadata,\n AgentResult,\n ProviderStatus,\n RunAgentOptions,\n SpawnCliFn,\n} from \"../../types.js\";\nimport {\n assertClaudeAuth,\n checkClaudeAuth,\n resolveClaudeExecutable,\n UNAUTHENTICATED_MESSAGE,\n type ClaudeAuthStatus,\n} from \"./auth.js\";\n\nexport const DEFAULT_AGENT_MODEL = \"claude-sonnet-4-6\";\n\nconst metadata: AgentProviderMetadata = {\n id: \"claude\",\n displayName: \"Claude\",\n defaultModel: DEFAULT_AGENT_MODEL,\n executable: \"claude\",\n capabilities: {\n transport: \"sdk\",\n writesFiles: true,\n supportsModelOverride: true,\n supportsStreaming: true,\n supportsSessionId: true,\n supportsUsage: false,\n supportsCost: true,\n supportsProviderReportedTurns: true,\n supportsProgrammaticSubagents: true,\n supportsStrictToolAllowlist: false,\n },\n};\n\nexport const claudeProvider: AgentProvider = {\n metadata,\n checkStatus,\n assertReady,\n run,\n};\n\nasync function run(opts: RunAgentOptions): Promise<AgentResult> {\n const claudeExecutable = resolveClaudeExecutable();\n\n const q = query({\n prompt: opts.prompt,\n options: {\n systemPrompt: opts.systemPrompt,\n allowedTools: opts.allowedTools,\n agents: opts.agents ?? {},\n cwd: opts.cwd,\n model: opts.model ?? metadata.defaultModel ?? undefined,\n maxTurns: opts.maxTurns ?? 100,\n ...(claudeExecutable !== undefined\n ? { pathToClaudeCodeExecutable: claudeExecutable }\n : {}),\n env: {\n ...process.env,\n CODEALMANAC_INTERNAL_SESSION: \"1\",\n },\n includePartialMessages: true,\n },\n });\n\n let cost = 0;\n let turns = 0;\n let result = \"\";\n let sessionId: string | undefined;\n let success = false;\n let errorMsg: string | undefined;\n\n try {\n for await (const msg of q) {\n opts.onMessage?.(msg);\n\n if (\n sessionId === undefined &&\n typeof (msg as { session_id?: unknown }).session_id === \"string\"\n ) {\n sessionId = (msg as { session_id: string }).session_id;\n }\n\n if (msg.type === \"result\") {\n cost = msg.total_cost_usd;\n turns = msg.num_turns;\n if (msg.subtype === \"success\") {\n success = true;\n result = msg.result;\n } else {\n success = false;\n errorMsg =\n (msg.errors?.join(\"; \") ?? \"\") || `agent error: ${msg.subtype}`;\n }\n }\n }\n } catch (err: unknown) {\n errorMsg = err instanceof Error ? err.message : String(err);\n success = false;\n }\n\n return { success, cost, turns, result, sessionId, error: errorMsg };\n}\n\nasync function checkStatus(spawnCli?: SpawnCliFn): Promise<ProviderStatus> {\n let auth: ClaudeAuthStatus = { loggedIn: false };\n try {\n auth = await checkClaudeAuth(spawnCli);\n } catch {\n auth = { loggedIn: false };\n }\n const hasApiKey =\n process.env.ANTHROPIC_API_KEY !== undefined &&\n process.env.ANTHROPIC_API_KEY.length > 0;\n const installed = resolveClaudeExecutable() !== undefined;\n const authenticated = auth.loggedIn || hasApiKey;\n const detail = authenticated\n ? auth.email ?? (hasApiKey ? \"ANTHROPIC_API_KEY set\" : \"logged in\")\n : installed\n ? \"not logged in\"\n : `${metadata.executable} not found on PATH`;\n return { id: metadata.id, installed, authenticated, detail };\n}\n\nasync function assertReady(spawnCli?: SpawnCliFn): Promise<void> {\n await assertClaudeAuth(spawnCli);\n}\n\nexport { assertClaudeAuth, checkClaudeAuth, UNAUTHENTICATED_MESSAGE };\nexport type { ClaudeAuthStatus } from \"./auth.js\";\nexport type { SpawnCliFn, SpawnedProcess } from \"../../types.js\";\n","import { spawn, spawnSync, type ChildProcess } from \"node:child_process\";\nimport { createRequire } from \"node:module\";\nimport { dirname, join } from \"node:path\";\n\nimport type { SpawnCliFn, SpawnedProcess } from \"../../types.js\";\n\n/**\n * Claude auth gate — accepts either an active Claude subscription login\n * OR an `ANTHROPIC_API_KEY` environment variable.\n *\n * Claude Code owns subscription OAuth credentials. Users who are logged in\n * via `claude auth login --claudeai` should be able to run bootstrap/capture\n * without exporting an API key. Conversely, users on pay-per-token API keys\n * shouldn't be required to go through the OAuth flow.\n *\n * Current Claude Agent SDK packages no longer ship the old private\n * `cli.js` entrypoint, so the primary probe is the public Claude Code CLI:\n * `claude auth status --json`. We keep the SDK `cli.js` probe as a legacy\n * fallback for older SDK layouts.\n */\n\nexport interface ClaudeAuthStatus {\n loggedIn: boolean;\n email?: string;\n subscriptionType?: string;\n authMethod?: string;\n}\n\nconst AUTH_TIMEOUT_MS = 10_000;\n\n/**\n * Resolve the installed Claude Code executable from PATH. The Agent SDK can\n * accept this path via `pathToClaudeCodeExecutable`, and the auth probe uses\n * the same binary so CodeAlmanac agrees with `claude auth status`.\n */\nexport function resolveClaudeExecutable(): string | undefined {\n const result = spawnSync(\"sh\", [\"-lc\", \"command -v claude\"], {\n encoding: \"utf8\",\n });\n if (result.status !== 0) return undefined;\n const found = result.stdout.trim().split(\"\\n\")[0]?.trim();\n return found !== undefined && found.length > 0 ? found : undefined;\n}\n\n/**\n * Resolve legacy `cli.js` from older `@anthropic-ai/claude-agent-sdk`\n * installs. SDK 0.2.129+ no longer ships this file; callers must treat\n * failure as expected and fall back to the public `claude` binary.\n */\nfunction resolveCliJsPath(): string {\n const require = createRequire(import.meta.url);\n const entry = require.resolve(\"@anthropic-ai/claude-agent-sdk\");\n return join(dirname(entry), \"cli.js\");\n}\n\n/**\n * Default subprocess spawner for production use — invokes the installed\n * Claude Code CLI.\n */\nexport const defaultSpawnCli: SpawnCliFn = (args: string[]) => {\n const command = resolveClaudeExecutable() ?? \"claude\";\n const child = spawn(command, args, {\n stdio: [\"ignore\", \"pipe\", \"pipe\"],\n });\n return child as unknown as SpawnedProcess;\n};\n\nexport const legacySdkSpawnCli: SpawnCliFn = (args: string[]) => {\n const cliPath = resolveCliJsPath();\n const child = spawn(process.execPath, [cliPath, ...args], {\n stdio: [\"ignore\", \"pipe\", \"pipe\"],\n });\n return child as unknown as SpawnedProcess;\n};\n\n/**\n * Check whether the user is authenticated via Claude subscription OAuth.\n *\n * Spawns `claude auth status --json`, falling back to the legacy SDK CLI\n * layout when available. On any failure (spawn error, non-JSON stdout,\n * non-zero exit, timeout) we return `{ loggedIn: false }` rather than\n * propagating the error — the caller will fall back to the\n * `ANTHROPIC_API_KEY` path and, if that's also missing, produce a clean\n * two-option error message.\n *\n * The 10s timeout guards against the CLI hanging on a broken network or\n * keychain prompt. In practice `auth status` is a cheap local read.\n */\nexport async function checkClaudeAuth(\n spawnCli: SpawnCliFn = defaultSpawnCli,\n): Promise<ClaudeAuthStatus> {\n if (spawnCli === defaultSpawnCli) {\n const status = await checkClaudeAuthWith(defaultSpawnCli);\n if (status.loggedIn) return status;\n return await checkClaudeAuthWith(legacySdkSpawnCli);\n }\n return await checkClaudeAuthWith(spawnCli);\n}\n\nasync function checkClaudeAuthWith(\n spawnCli: SpawnCliFn,\n): Promise<ClaudeAuthStatus> {\n let child: SpawnedProcess;\n try {\n child = spawnCli([\"auth\", \"status\", \"--json\"]);\n } catch {\n return { loggedIn: false };\n }\n\n return new Promise<ClaudeAuthStatus>((resolve) => {\n let stdout = \"\";\n let stderr = \"\";\n let settled = false;\n\n const settle = (value: ClaudeAuthStatus): void => {\n if (settled) return;\n settled = true;\n clearTimeout(timer);\n resolve(value);\n };\n\n const timer = setTimeout(() => {\n try {\n child.kill(\"SIGTERM\");\n } catch {\n // Kill can fail if the process already exited; nothing we can do.\n }\n settle({ loggedIn: false });\n }, AUTH_TIMEOUT_MS);\n\n child.stdout.on(\"data\", (data) => {\n stdout += data.toString();\n });\n child.stderr.on(\"data\", (data) => {\n stderr += data.toString();\n });\n\n child.on(\"error\", () => {\n settle({ loggedIn: false });\n });\n\n child.on(\"close\", (code) => {\n // The SDK writes `{\"loggedIn\": false, ...}` to stdout with a zero\n // exit code when the user isn't signed in, so we only reject on\n // non-zero + empty stdout. An empty stdout with zero exit (shouldn't\n // happen in practice) also fails safely to `loggedIn: false`.\n if (code !== 0 && stdout.trim().length === 0) {\n // `stderr` isn't surfaced to the user here — the caller's error\n // message covers both auth paths — but it would be captured by\n // `stderr` if we ever wanted to log it for debugging.\n void stderr;\n settle({ loggedIn: false });\n return;\n }\n try {\n settle(parseClaudeAuthStatus(stdout.trim()));\n } catch {\n settle({ loggedIn: false });\n }\n });\n });\n}\n\nfunction parseClaudeAuthStatus(raw: string): ClaudeAuthStatus {\n const parsed = JSON.parse(raw) as Record<string, unknown>;\n const loggedIn = parsed.loggedIn === true;\n const out: ClaudeAuthStatus = { loggedIn };\n if (typeof parsed.email === \"string\") out.email = parsed.email;\n if (typeof parsed.subscriptionType === \"string\") {\n out.subscriptionType = parsed.subscriptionType;\n }\n if (typeof parsed.authMethod === \"string\") {\n out.authMethod = parsed.authMethod;\n }\n return out;\n}\n\n/**\n * Human-readable error when neither auth path is available. The text is\n * deliberately verbose — users hitting this wall for the first time\n * deserve both options in front of them, not a terse hint.\n */\nexport const UNAUTHENTICATED_MESSAGE =\n \"not authenticated to Claude.\\n\\n\" +\n \"Option 1 — use your Claude subscription (Pro/Max):\\n\" +\n \" claude auth login --claudeai\\n\\n\" +\n \"Option 2 — use a pay-per-token API key:\\n\" +\n \" Get one at https://console.anthropic.com\\n\" +\n \" export ANTHROPIC_API_KEY=sk-ant-...\\n\\n\" +\n \"Verify with: claude auth status\";\n\n/**\n * Assert that at least one auth path is satisfied. Prefers subscription\n * auth (fewer surprises for Claude Pro/Max users) but accepts\n * `ANTHROPIC_API_KEY` as a fallback. On failure throws with\n * `code = \"CLAUDE_AUTH_MISSING\"` so callers can distinguish this from\n * other errors if they ever want to.\n *\n * Returns the resolved auth status so callers that want to display the\n * logged-in email in a preamble can do so without a second subprocess.\n */\nexport async function assertClaudeAuth(\n spawnCli: SpawnCliFn = defaultSpawnCli,\n): Promise<ClaudeAuthStatus> {\n const status = await checkClaudeAuth(spawnCli);\n if (status.loggedIn) {\n return status;\n }\n const apiKey = process.env.ANTHROPIC_API_KEY;\n if (apiKey !== undefined && apiKey.length > 0) {\n // Signal to callers that we're on the API-key path. Not \"loggedIn\"\n // in the OAuth sense, but the SDK will pick up the env var and\n // succeed — so we return a status that tells bootstrap/capture the\n // gate is open.\n return { loggedIn: true, authMethod: \"apiKey\" };\n }\n const err = new Error(UNAUTHENTICATED_MESSAGE);\n (err as { code?: string }).code = \"CLAUDE_AUTH_MISSING\";\n throw err;\n}\n\n// Internal re-export — helps keep the public type surface minimal while\n// still letting tests import the `ChildProcess` shape when needed.\nexport type { ChildProcess };\nexport type { SpawnCliFn, SpawnedProcess };\n","import { spawn, spawnSync, type ChildProcess } from \"node:child_process\";\n\nconst STATUS_TIMEOUT_MS = 3_000;\n\nexport function commandExists(command: string): boolean {\n const result = spawnSync(\"sh\", [\"-lc\", `command -v ${command}`], {\n encoding: \"utf8\",\n });\n return result.status === 0 && result.stdout.trim().length > 0;\n}\n\nexport function runStatusCommand(\n command: string,\n args: string[],\n): Promise<{ ok: boolean; detail: string }> {\n return new Promise((resolve) => {\n let stdout = \"\";\n let stderr = \"\";\n let child: ChildProcess;\n let settled = false;\n const settle = (value: { ok: boolean; detail: string }): void => {\n if (settled) return;\n settled = true;\n clearTimeout(timer);\n resolve(value);\n };\n try {\n child = spawn(command, args, { stdio: [\"ignore\", \"pipe\", \"pipe\"] });\n } catch (err: unknown) {\n const msg = err instanceof Error ? err.message : String(err);\n resolve({ ok: false, detail: msg });\n return;\n }\n const timer = setTimeout(() => {\n try {\n child.kill(\"SIGTERM\");\n setTimeout(() => {\n if (child.exitCode === null && child.signalCode === null) {\n try {\n child.kill(\"SIGKILL\");\n } catch {\n // already exited\n }\n }\n }, 500).unref();\n } catch {\n // already exited\n }\n settle({ ok: false, detail: `${command} status timed out` });\n }, STATUS_TIMEOUT_MS);\n child.stdout?.on(\"data\", (chunk) => {\n stdout += chunk.toString(\"utf8\");\n });\n child.stderr?.on(\"data\", (chunk) => {\n stderr += chunk.toString(\"utf8\");\n });\n child.on(\"error\", (err) => {\n settle({ ok: false, detail: err.message });\n });\n child.on(\"close\", (code) => {\n const text = `${stdout}\\n${stderr}`.trim();\n settle({\n ok: code === 0,\n detail:\n text\n .split(\"\\n\")\n .find((line) => line.trim().length > 0)\n ?.trim() ?? (code === 0 ? \"ready\" : `${command} exited ${code ?? 1}`),\n });\n });\n });\n}\n","import { spawn } from \"node:child_process\";\n\nimport type {\n AgentResult,\n AgentStreamMessage,\n AgentUsage,\n} from \"../types.js\";\n\nexport interface JsonlCliOptions {\n command: string;\n args: string[];\n cwd: string;\n env: NodeJS.ProcessEnv;\n onMessage?: (msg: AgentStreamMessage) => void;\n parseFinal: (msg: Record<string, unknown>) => Partial<AgentResult> | null;\n}\n\nexport function runJsonlCli(opts: JsonlCliOptions): Promise<AgentResult> {\n return new Promise((resolve) => {\n const child = spawn(opts.command, opts.args, {\n cwd: opts.cwd,\n env: opts.env,\n stdio: [\"ignore\", \"pipe\", \"pipe\"],\n });\n\n let stdoutBuf = \"\";\n let stderr = \"\";\n let cost = 0;\n let turns = 0;\n let result = \"\";\n let sessionId: string | undefined;\n let usage: AgentUsage | undefined;\n let success = false;\n let finalSeen = false;\n let error: string | undefined;\n\n const observe = (msg: Record<string, unknown>): void => {\n opts.onMessage?.(msg);\n if (\n sessionId === undefined &&\n typeof msg.session_id === \"string\" &&\n msg.session_id.length > 0\n ) {\n sessionId = msg.session_id;\n }\n if (\n sessionId === undefined &&\n typeof msg.thread_id === \"string\" &&\n msg.thread_id.length > 0\n ) {\n sessionId = msg.thread_id;\n }\n const final = opts.parseFinal(msg);\n if (final === null) return;\n finalSeen = true;\n if (final.cost !== undefined) cost = final.cost;\n if (final.turns !== undefined) turns = final.turns;\n if (final.result !== undefined) result = final.result;\n if (final.sessionId !== undefined) sessionId = final.sessionId;\n if (final.usage !== undefined) usage = final.usage;\n if (final.success !== undefined) success = final.success;\n if (final.error !== undefined) error = final.error;\n };\n\n const flushLines = (): void => {\n let idx = stdoutBuf.indexOf(\"\\n\");\n while (idx !== -1) {\n const rawLine = stdoutBuf.slice(0, idx);\n stdoutBuf = stdoutBuf.slice(idx + 1);\n const line = rawLine.trim();\n if (line.length > 0) {\n try {\n observe(JSON.parse(line) as Record<string, unknown>);\n } catch {\n // Ignore non-JSON chatter; stderr is captured for failures.\n }\n }\n idx = stdoutBuf.indexOf(\"\\n\");\n }\n };\n\n child.stdout.on(\"data\", (chunk) => {\n stdoutBuf += chunk.toString(\"utf8\");\n flushLines();\n });\n child.stderr.on(\"data\", (chunk) => {\n stderr += chunk.toString(\"utf8\");\n });\n child.on(\"error\", (err: NodeJS.ErrnoException) => {\n resolve({\n success: false,\n cost,\n turns,\n result,\n sessionId,\n usage,\n error:\n err.code === \"ENOENT\"\n ? `${opts.command} not found on PATH`\n : err.message,\n });\n });\n child.on(\"close\", (code) => {\n flushLines();\n if (stdoutBuf.trim().length > 0) {\n try {\n observe(JSON.parse(stdoutBuf.trim()) as Record<string, unknown>);\n } catch {\n // Ignore trailing non-JSON.\n }\n }\n\n if (code === 0 && finalSeen && success) {\n resolve({ success, cost, turns, result, sessionId, usage });\n return;\n }\n\n const firstStderr = stderr.trim().split(\"\\n\")[0];\n resolve({\n success: false,\n cost,\n turns,\n result,\n sessionId,\n usage,\n error:\n error ??\n (firstStderr !== undefined && firstStderr.length > 0\n ? firstStderr\n : `${opts.command} exited ${code ?? 1}`),\n });\n });\n });\n}\n\nexport function parseUsage(value: unknown): AgentUsage | undefined {\n if (value === null || typeof value !== \"object\") return undefined;\n const obj = value as Record<string, unknown>;\n return {\n inputTokens: numberField(obj, \"input_tokens\") ?? numberField(obj, \"inputTokens\"),\n cachedInputTokens:\n numberField(obj, \"cached_input_tokens\") ??\n numberField(obj, \"cachedInputTokens\") ??\n numberField(obj, \"cacheReadTokens\"),\n outputTokens:\n numberField(obj, \"output_tokens\") ?? numberField(obj, \"outputTokens\"),\n reasoningOutputTokens:\n numberField(obj, \"reasoning_output_tokens\") ??\n numberField(obj, \"reasoningOutputTokens\"),\n };\n}\n\nfunction numberField(\n input: Record<string, unknown>,\n key: string,\n): number | undefined {\n const value = input[key];\n return typeof value === \"number\" ? value : undefined;\n}\n","import type { AgentProviderMetadata, RunAgentOptions } from \"../types.js\";\n\nexport function combinedPrompt(\n opts: RunAgentOptions,\n metadata: AgentProviderMetadata,\n): string {\n const reviewerFallback = buildReviewerFallback(opts, metadata);\n return `${opts.systemPrompt}${reviewerFallback}\\n\\n---\\n\\n${opts.prompt}`;\n}\n\nfunction buildReviewerFallback(\n opts: RunAgentOptions,\n metadata: AgentProviderMetadata,\n): string {\n if (metadata.capabilities.supportsProgrammaticSubagents) return \"\";\n\n const reviewer = opts.agents?.reviewer;\n if (reviewer === undefined) return \"\";\n return (\n \"\\n\\nNon-Claude provider note: this runtime does not receive Claude's \" +\n \"nested Agent tool contract. When the writer prompt asks you to invoke \" +\n \"the reviewer subagent, perform that review pass yourself before final \" +\n \"wiki edits. Treat this reviewer prompt as read-only review guidance:\\n\\n\" +\n reviewer.prompt\n );\n}\n","import type {\n AgentProvider,\n AgentProviderMetadata,\n AgentResult,\n ProviderStatus,\n RunAgentOptions,\n} from \"../types.js\";\nimport { commandExists, runStatusCommand } from \"./cli-status.js\";\nimport { parseUsage, runJsonlCli } from \"./jsonl-cli.js\";\nimport { combinedPrompt } from \"./prompt.js\";\n\nconst metadata: AgentProviderMetadata = {\n id: \"codex\",\n displayName: \"Codex\",\n defaultModel: null,\n executable: \"codex\",\n capabilities: {\n transport: \"cli-jsonl\",\n writesFiles: true,\n supportsModelOverride: true,\n supportsStreaming: true,\n supportsSessionId: false,\n supportsUsage: true,\n supportsCost: false,\n supportsProviderReportedTurns: false,\n supportsProgrammaticSubagents: false,\n supportsStrictToolAllowlist: false,\n },\n};\n\nexport const codexProvider: AgentProvider = {\n metadata,\n checkStatus,\n assertReady,\n run,\n};\n\nasync function run(opts: RunAgentOptions): Promise<AgentResult> {\n const args = [\n \"exec\",\n \"--json\",\n \"--sandbox\",\n \"workspace-write\",\n \"--skip-git-repo-check\",\n \"-C\",\n opts.cwd,\n ];\n if (opts.model !== undefined && opts.model.length > 0) {\n args.push(\"--model\", opts.model);\n }\n args.push(combinedPrompt({ ...opts, provider: \"codex\" }, metadata));\n\n return await runJsonlCli({\n command: metadata.executable,\n args,\n cwd: opts.cwd,\n env: { ...process.env, CODEALMANAC_INTERNAL_SESSION: \"1\" },\n onMessage: opts.onMessage,\n parseFinal: parseCodexFinal,\n });\n}\n\nasync function checkStatus(): Promise<ProviderStatus> {\n if (!commandExists(metadata.executable)) {\n return {\n id: metadata.id,\n installed: false,\n authenticated: false,\n detail: `${metadata.executable} not found on PATH`,\n };\n }\n\n const auth = await runStatusCommand(metadata.executable, [\"login\", \"status\"]);\n return {\n id: metadata.id,\n installed: true,\n authenticated: auth.ok,\n detail: auth.detail,\n };\n}\n\nasync function assertReady(): Promise<void> {\n const status = await checkStatus();\n if (!status.installed || !status.authenticated) {\n const err = new Error(`${status.id} not ready: ${status.detail}`);\n (err as { code?: string }).code = \"AGENT_AUTH_MISSING\";\n throw err;\n }\n}\n\nfunction parseCodexFinal(\n msg: Record<string, unknown>,\n): Partial<AgentResult> | null {\n if (msg.type === \"item.completed\") {\n const item = msg.item;\n if (item !== null && typeof item === \"object\") {\n const obj = item as Record<string, unknown>;\n if (obj.type === \"agent_message\" && typeof obj.text === \"string\") {\n return { result: obj.text };\n }\n }\n return null;\n }\n if (msg.type === \"turn.completed\") {\n return { success: true, turns: 1, usage: parseUsage(msg.usage) };\n }\n if (msg.type === \"turn.failed\" || msg.type === \"error\") {\n return {\n success: false,\n error:\n typeof msg.message === \"string\"\n ? msg.message\n : typeof msg.error === \"string\"\n ? msg.error\n : \"codex turn failed\",\n };\n }\n return null;\n}\n","import type {\n AgentProvider,\n AgentProviderMetadata,\n AgentResult,\n ProviderStatus,\n RunAgentOptions,\n} from \"../types.js\";\nimport { commandExists, runStatusCommand } from \"./cli-status.js\";\nimport { parseUsage, runJsonlCli } from \"./jsonl-cli.js\";\nimport { combinedPrompt } from \"./prompt.js\";\n\nconst metadata: AgentProviderMetadata = {\n id: \"cursor\",\n displayName: \"Cursor\",\n defaultModel: null,\n executable: \"cursor-agent\",\n capabilities: {\n transport: \"cli-jsonl\",\n writesFiles: true,\n supportsModelOverride: true,\n supportsStreaming: true,\n supportsSessionId: true,\n supportsUsage: true,\n supportsCost: false,\n supportsProviderReportedTurns: false,\n supportsProgrammaticSubagents: false,\n supportsStrictToolAllowlist: false,\n },\n};\n\nexport const cursorProvider: AgentProvider = {\n metadata,\n checkStatus,\n assertReady,\n run,\n};\n\nasync function run(opts: RunAgentOptions): Promise<AgentResult> {\n const args = [\n \"--print\",\n \"--output-format\",\n \"stream-json\",\n \"--stream-partial-output\",\n \"--trust\",\n \"--workspace\",\n opts.cwd,\n ];\n if (opts.model !== undefined && opts.model.length > 0) {\n args.push(\"--model\", opts.model);\n }\n args.push(combinedPrompt({ ...opts, provider: \"cursor\" }, metadata));\n\n return await runJsonlCli({\n command: metadata.executable,\n args,\n cwd: opts.cwd,\n env: { ...process.env, CODEALMANAC_INTERNAL_SESSION: \"1\" },\n onMessage: opts.onMessage,\n parseFinal: parseCursorFinal,\n });\n}\n\nasync function checkStatus(): Promise<ProviderStatus> {\n if (!commandExists(metadata.executable)) {\n return {\n id: metadata.id,\n installed: false,\n authenticated: false,\n detail: `${metadata.executable} not found on PATH`,\n };\n }\n\n const auth = await runStatusCommand(metadata.executable, [\"status\"]);\n return {\n id: metadata.id,\n installed: true,\n authenticated: auth.ok,\n detail: auth.detail,\n };\n}\n\nasync function assertReady(): Promise<void> {\n const status = await checkStatus();\n if (!status.installed || !status.authenticated) {\n const err = new Error(`${status.id} not ready: ${status.detail}`);\n (err as { code?: string }).code = \"AGENT_AUTH_MISSING\";\n throw err;\n }\n}\n\nfunction parseCursorFinal(\n msg: Record<string, unknown>,\n): Partial<AgentResult> | null {\n if (msg.type !== \"result\") return null;\n const isError = msg.is_error === true || msg.subtype !== \"success\";\n return {\n success: !isError,\n turns: 1,\n result: typeof msg.result === \"string\" ? msg.result : \"\",\n sessionId:\n typeof msg.session_id === \"string\" ? msg.session_id : undefined,\n usage: parseUsage(msg.usage),\n error: isError\n ? typeof msg.result === \"string\"\n ? msg.result\n : `cursor result: ${String(msg.subtype ?? \"error\")}`\n : undefined,\n };\n}\n","import {\n AGENT_PROVIDER_IDS,\n type AgentProviderId,\n} from \"../../update/config.js\";\nimport type { ProviderStatus, SpawnCliFn } from \"../types.js\";\nimport { getAgentProvider } from \"./index.js\";\n\nexport async function assertAgentAuth(args: {\n provider: AgentProviderId;\n spawnCli?: SpawnCliFn;\n}): Promise<void> {\n await getAgentProvider(args.provider).assertReady(args.spawnCli);\n}\n\nexport async function listProviderStatuses(\n spawnCli?: SpawnCliFn,\n): Promise<ProviderStatus[]> {\n const out: ProviderStatus[] = [];\n for (const id of AGENT_PROVIDER_IDS) {\n out.push(await getAgentProvider(id).checkStatus(spawnCli));\n }\n return out;\n}\n","import type { AgentProvider } from \"../types.js\";\nimport { claudeProvider, DEFAULT_AGENT_MODEL } from \"./claude/index.js\";\nimport { codexProvider } from \"./codex-cli.js\";\nimport { cursorProvider } from \"./cursor-cli.js\";\n\nconst AGENT_PROVIDERS = {\n claude: claudeProvider,\n codex: codexProvider,\n cursor: cursorProvider,\n} satisfies Record<string, AgentProvider>;\n\nexport function getAgentProvider(id: keyof typeof AGENT_PROVIDERS): AgentProvider {\n return AGENT_PROVIDERS[id];\n}\n\nexport const AGENT_PROVIDER_METADATA = {\n claude: claudeProvider.metadata,\n codex: codexProvider.metadata,\n cursor: cursorProvider.metadata,\n};\nexport { DEFAULT_AGENT_MODEL };\nexport { assertAgentAuth, listProviderStatuses } from \"./status.js\";\n","import {\n AGENT_PROVIDER_METADATA,\n listProviderStatuses,\n} from \"./providers.js\";\nimport type { ProviderStatus, SpawnCliFn } from \"./types.js\";\nimport {\n AGENT_PROVIDER_IDS,\n isAgentProviderId,\n readConfig,\n type AgentProviderId,\n type GlobalConfig,\n} from \"../update/config.js\";\n\nexport type ProviderReadiness = \"ready\" | \"not-authenticated\" | \"missing\";\n\nexport interface ProviderSetupChoice {\n id: AgentProviderId;\n label: string;\n selected: boolean;\n recommended: boolean;\n readiness: ProviderReadiness;\n ready: boolean;\n installed: boolean;\n authenticated: boolean;\n effectiveModel: string | null;\n providerDefaultModel: string | null;\n configuredModel: string | null;\n account: string | null;\n detail: string;\n fixCommand: string | null;\n modelChoices: ProviderModelChoice[];\n}\n\nexport interface ProviderModelChoice {\n value: string | null;\n label: string;\n recommended: boolean;\n source: \"configured\" | \"provider-default\" | \"custom\";\n}\n\nexport interface ProviderSetupView {\n defaultProvider: AgentProviderId;\n recommendedProvider: AgentProviderId;\n choices: ProviderSetupChoice[];\n}\n\nexport interface ProviderViewOptions {\n config?: GlobalConfig;\n statuses?: ProviderStatus[];\n spawnCli?: SpawnCliFn;\n}\n\nconst LOGIN_FIXES: Record<AgentProviderId, string> = {\n claude: \"run: claude auth login --claudeai\",\n codex: \"run: codex login\",\n cursor: \"run: cursor-agent login\",\n};\n\nconst INSTALL_FIXES: Record<AgentProviderId, string> = {\n claude: \"install Claude Code, then run: claude auth login --claudeai\",\n codex: \"install Codex CLI, then run: codex login\",\n cursor: \"install cursor-agent, then run: cursor-agent login\",\n};\n\nexport function getProviderLabel(id: AgentProviderId): string {\n return AGENT_PROVIDER_METADATA[id].displayName;\n}\n\nexport function getProviderDefaultModel(id: AgentProviderId): string | null {\n return AGENT_PROVIDER_METADATA[id].defaultModel;\n}\n\nexport async function buildProviderSetupView(\n opts: ProviderViewOptions = {},\n): Promise<ProviderSetupView> {\n const config = opts.config ?? await readConfig();\n const statuses = opts.statuses ?? await listProviderStatuses(opts.spawnCli);\n const statusById = new Map(statuses.map((status) => [status.id, status]));\n const recommendedProvider = chooseRecommendedProvider(statuses);\n const choices = AGENT_PROVIDER_IDS.map((id) => {\n const status = statusById.get(id) ?? missingStatus(id);\n const readiness = getReadiness(status);\n const configuredModel = normalizeModel(config.agent.models[id]);\n const providerDefaultModel = getProviderDefaultModel(id);\n const effectiveModel = configuredModel ?? providerDefaultModel;\n return {\n id,\n label: getProviderLabel(id),\n selected: id === config.agent.default,\n recommended: id === recommendedProvider,\n readiness,\n ready: readiness === \"ready\",\n installed: status.installed,\n authenticated: status.authenticated,\n effectiveModel,\n providerDefaultModel,\n configuredModel,\n account: status.authenticated ? accountFromDetail(status.detail) : null,\n detail: status.detail,\n fixCommand: fixFor(id, readiness),\n modelChoices: buildProviderModelChoices(id, configuredModel),\n };\n });\n return {\n defaultProvider: config.agent.default,\n recommendedProvider,\n choices,\n };\n}\n\nexport function buildProviderModelChoices(\n id: AgentProviderId,\n configuredModel: string | null = null,\n): ProviderModelChoice[] {\n const choices: ProviderModelChoice[] = [];\n if (configuredModel !== null) {\n choices.push({\n value: configuredModel,\n label: configuredModel,\n recommended: false,\n source: \"configured\",\n });\n }\n\n const providerDefault = getProviderDefaultModel(id);\n if (providerDefault !== null) {\n if (!choices.some((choice) => choice.value === providerDefault)) {\n choices.push({\n value: providerDefault,\n label: providerDefault,\n recommended: true,\n source: \"provider-default\",\n });\n } else {\n choices[0] = { ...choices[0]!, recommended: true };\n }\n } else {\n choices.push({\n value: null,\n label: \"provider default\",\n recommended: true,\n source: \"provider-default\",\n });\n }\n\n choices.push({\n value: \"__custom__\",\n label: \"custom model id\",\n recommended: false,\n source: \"custom\",\n });\n return choices;\n}\n\nexport function chooseRecommendedProvider(\n statuses: ProviderStatus[],\n): AgentProviderId {\n const ready = statuses\n .filter((status) => status.installed && status.authenticated)\n .map((status) => status.id);\n if (ready.includes(\"claude\")) return \"claude\";\n for (const id of AGENT_PROVIDER_IDS) {\n if (ready.includes(id)) return id;\n }\n return \"claude\";\n}\n\nexport function parseAgentSelection(value: string): {\n provider: AgentProviderId | null;\n model?: string;\n} {\n const [rawProvider, ...modelParts] = value.split(\"/\");\n if (rawProvider === undefined || !isAgentProviderId(rawProvider)) {\n return { provider: null };\n }\n const model = modelParts.join(\"/\");\n return {\n provider: rawProvider,\n model: model.length > 0 ? model : undefined,\n };\n}\n\nfunction getReadiness(status: ProviderStatus): ProviderReadiness {\n if (!status.installed) return \"missing\";\n if (!status.authenticated) return \"not-authenticated\";\n return \"ready\";\n}\n\nfunction fixFor(\n id: AgentProviderId,\n readiness: ProviderReadiness,\n): string | null {\n if (readiness === \"ready\") return null;\n if (readiness === \"missing\") return INSTALL_FIXES[id];\n return LOGIN_FIXES[id];\n}\n\nfunction accountFromDetail(detail: string): string | null {\n const clean = detail.trim();\n if (\n clean.length === 0 ||\n clean === \"ready\" ||\n clean === \"logged in\" ||\n clean === \"ANTHROPIC_API_KEY set\"\n ) {\n return null;\n }\n return clean;\n}\n\nfunction normalizeModel(value: string | null | undefined): string | null {\n return typeof value === \"string\" && value.length > 0 ? value : null;\n}\n\nfunction missingStatus(id: AgentProviderId): ProviderStatus {\n return {\n id,\n installed: false,\n authenticated: false,\n detail: \"provider status unavailable\",\n };\n}\n"],"mappings":";;;;;;;;AAAA,SAAS,aAAa;;;ACAtB,SAAS,OAAO,iBAAoC;AACpD,SAAS,qBAAqB;AAC9B,SAAS,SAAS,YAAY;AA0B9B,IAAM,kBAAkB;AAOjB,SAAS,0BAA8C;AAC5D,QAAM,SAAS,UAAU,MAAM,CAAC,OAAO,mBAAmB,GAAG;AAAA,IAC3D,UAAU;AAAA,EACZ,CAAC;AACD,MAAI,OAAO,WAAW,EAAG,QAAO;AAChC,QAAM,QAAQ,OAAO,OAAO,KAAK,EAAE,MAAM,IAAI,EAAE,CAAC,GAAG,KAAK;AACxD,SAAO,UAAU,UAAa,MAAM,SAAS,IAAI,QAAQ;AAC3D;AAOA,SAAS,mBAA2B;AAClC,QAAMA,WAAU,cAAc,YAAY,GAAG;AAC7C,QAAM,QAAQA,SAAQ,QAAQ,gCAAgC;AAC9D,SAAO,KAAK,QAAQ,KAAK,GAAG,QAAQ;AACtC;AAMO,IAAM,kBAA8B,CAAC,SAAmB;AAC7D,QAAM,UAAU,wBAAwB,KAAK;AAC7C,QAAM,QAAQ,MAAM,SAAS,MAAM;AAAA,IACjC,OAAO,CAAC,UAAU,QAAQ,MAAM;AAAA,EAClC,CAAC;AACD,SAAO;AACT;AAEO,IAAM,oBAAgC,CAAC,SAAmB;AAC/D,QAAM,UAAU,iBAAiB;AACjC,QAAM,QAAQ,MAAM,QAAQ,UAAU,CAAC,SAAS,GAAG,IAAI,GAAG;AAAA,IACxD,OAAO,CAAC,UAAU,QAAQ,MAAM;AAAA,EAClC,CAAC;AACD,SAAO;AACT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AAC5B,MAAI,MAAM,SAAS,QAAQ,EAAG,QAAO;AACrC,aAAW,MAAM,oBAAoB;AACnC,QAAI,MAAM,SAAS,EAAE,EAAG,QAAO;AAAA,EACjC;AACA,SAAO;AACT;AAEO,SAAS,oBAAoB,OAGlC;AACA,QAAM,CAAC,aAAa,GAAG,UAAU,IAAI,MAAM,MAAM,GAAG;AACpD,MAAI,gBAAgB,UAAa,CAAC,kBAAkB,WAAW,GAAG;AAChE,WAAO,EAAE,UAAU,KAAK;AAAA,EAC1B;AACA,QAAM,QAAQ,WAAW,KAAK,GAAG;AACjC,SAAO;AAAA,IACL,UAAU;AAAA,IACV,OAAO,MAAM,SAAS,IAAI,QAAQ;AAAA,EACpC;AACF;AAEA,SAAS,aAAa,QAA2C;AAC/D,MAAI,CAAC,OAAO,UAAW,QAAO;AAC9B,MAAI,CAAC,OAAO,cAAe,QAAO;AAClC,SAAO;AACT;AAEA,SAAS,OACP,IACA,WACe;AACf,MAAI,cAAc,QAAS,QAAO;AAClC,MAAI,cAAc,UAAW,QAAO,cAAc,EAAE;AACpD,SAAO,YAAY,EAAE;AACvB;AAEA,SAAS,kBAAkB,QAA+B;AACxD,QAAM,QAAQ,OAAO,KAAK;AAC1B,MACE,MAAM,WAAW,KACjB,UAAU,WACV,UAAU,eACV,UAAU,yBACV;AACA,WAAO;AAAA,EACT;AACA,SAAO;AACT;AAEA,SAAS,eAAe,OAAiD;AACvE,SAAO,OAAO,UAAU,YAAY,MAAM,SAAS,IAAI,QAAQ;AACjE;AAEA,SAAS,cAAc,IAAqC;AAC1D,SAAO;AAAA,IACL;AAAA,IACA,WAAW;AAAA,IACX,eAAe;AAAA,IACf,QAAQ;AAAA,EACV;AACF;","names":["require","spawn","spawnSync","spawn","metadata","metadata","checkStatus","assertReady","run","metadata","checkStatus","assertReady","run"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/commands/uninstall.ts"],"sourcesContent":["import { existsSync } from \"node:fs\";\nimport { readFile, rm, writeFile } from \"node:fs/promises\";\nimport { homedir } from \"node:os\";\nimport path from \"node:path\";\n\nimport { runHookUninstall } from \"./hook.js\";\nimport { IMPORT_LINE } from \"./setup.js\";\n\n/**\n * `almanac uninstall` — the reverse of `setup`.\n *\n * Idempotent and order-insensitive: each step is a no-op if that\n * artifact was never installed. We remove exactly the things setup added,\n * nothing else:\n *\n * 1. The `@~/.claude/codealmanac.md` line from `~/.claude/CLAUDE.md`.\n * Other content stays untouched. If removing our line leaves the\n * file empty, we delete the file so our fingerprint doesn't persist\n * as zero bytes.\n * 2. The guide files `~/.claude/codealmanac.md` and\n * `~/.claude/codealmanac-reference.md`.\n * 3. The SessionEnd hook entry (delegated to `runHookUninstall`, which\n * already knows how to leave foreign entries alone).\n *\n * Flags:\n * --yes skip confirmations; remove everything\n * --keep-hook leave the hook alone\n * --keep-guides leave guides and provider imports/rules alone\n *\n * Non-interactive (no TTY) → behaves as if `--yes` was passed. Same\n * contract as `setup`.\n */\n\nexport interface UninstallOptions {\n yes?: boolean;\n keepHook?: boolean;\n keepGuides?: boolean;\n\n // ─── Injection points ────────────────────────────────────────────\n settingsPath?: string;\n hookScriptPath?: string;\n claudeDir?: string;\n isTTY?: boolean;\n stdout?: NodeJS.WritableStream;\n}\n\nexport interface UninstallResult {\n stdout: string;\n stderr: string;\n exitCode: number;\n}\n\nconst BLUE = \"\\x1b[38;5;75m\";\nconst DIM = \"\\x1b[2m\";\nconst RST = \"\\x1b[0m\";\n\nexport async function runUninstall(\n options: UninstallOptions = {},\n): Promise<UninstallResult> {\n const out = options.stdout ?? process.stdout;\n const isTTY =\n options.isTTY ?? (process.stdin.isTTY === true);\n const interactive = isTTY && options.yes !== true;\n const claudeDir = options.claudeDir ?? path.join(homedir(), \".claude\");\n\n out.write(\"\\n\");\n\n // Hook removal.\n let removeHook = true;\n if (options.keepHook === true) {\n removeHook = false;\n } else if (interactive) {\n removeHook = await confirm(\n out,\n \"Remove the SessionEnd hook from ~/.claude/settings.json?\",\n true,\n );\n }\n if (removeHook) {\n const res = await runHookUninstall({\n settingsPath: options.settingsPath,\n hookScriptPath: options.hookScriptPath,\n });\n if (res.exitCode !== 0) {\n return { stdout: \"\", stderr: res.stderr, exitCode: res.exitCode };\n }\n out.write(` ${BLUE}\\u25c7${RST} ${res.stdout.trim()}\\n`);\n } else {\n out.write(` ${DIM}\\u25cb Hook kept${RST}\\n`);\n }\n\n // Guide + import removal.\n let removeGuides = true;\n if (options.keepGuides === true) {\n removeGuides = false;\n } else if (interactive) {\n removeGuides = await confirm(\n out,\n \"Remove guides and provider imports/rules?\",\n true,\n );\n }\n if (removeGuides) {\n const summary = await removeGuideFiles(claudeDir);\n if (summary.anyChanges) {\n out.write(\n ` ${BLUE}\\u25c7${RST} Guides removed (${summary.filesTouched.join(\", \")})\\n`,\n );\n } else {\n out.write(` ${DIM}\\u25cb Guides not installed${RST}\\n`);\n }\n } else {\n out.write(` ${DIM}\\u25cb Guides kept${RST}\\n`);\n }\n\n out.write(`\\n ${BLUE}\\u25c7${RST} ${BLUE}Uninstall complete${RST}\\n\\n`);\n\n return { stdout: \"\", stderr: \"\", exitCode: 0 };\n}\n\ninterface RemoveGuidesResult {\n anyChanges: boolean;\n filesTouched: string[];\n}\n\nasync function removeGuideFiles(\n claudeDir: string,\n): Promise<RemoveGuidesResult> {\n const touched: string[] = [];\n\n const mini = path.join(claudeDir, \"codealmanac.md\");\n const ref = path.join(claudeDir, \"codealmanac-reference.md\");\n const claudeMd = path.join(claudeDir, \"CLAUDE.md\");\n\n if (existsSync(mini)) {\n await rm(mini, { force: true });\n touched.push(\"codealmanac.md\");\n }\n if (existsSync(ref)) {\n await rm(ref, { force: true });\n touched.push(\"codealmanac-reference.md\");\n }\n\n if (existsSync(claudeMd)) {\n const existing = await readFile(claudeMd, \"utf8\");\n const { changed, body } = removeImportLine(existing);\n if (changed) {\n // If the file is now content-free, delete it outright so our\n // installation leaves no trace. A user who was using CLAUDE.md\n // before we touched it still has their content; only the case\n // where CLAUDE.md contained nothing but our line gets cleaned up.\n if (body.trim().length === 0) {\n await rm(claudeMd, { force: true });\n touched.push(\"CLAUDE.md (deleted)\");\n } else {\n await writeFile(claudeMd, body, \"utf8\");\n touched.push(\"CLAUDE.md\");\n }\n }\n }\n\n touched.push(...await removeCodexGuides());\n touched.push(...await removeCursorGuides(process.cwd()));\n\n return { anyChanges: touched.length > 0, filesTouched: touched };\n}\n\nasync function removeCodexGuides(): Promise<string[]> {\n const touched: string[] = [];\n const codexDir = path.join(homedir(), \".codex\");\n const mini = path.join(codexDir, \"codealmanac.md\");\n const ref = path.join(codexDir, \"codealmanac-reference.md\");\n const agents = path.join(codexDir, \"AGENTS.md\");\n if (existsSync(mini)) {\n await rm(mini, { force: true });\n touched.push(\"~/.codex/codealmanac.md\");\n }\n if (existsSync(ref)) {\n await rm(ref, { force: true });\n touched.push(\"~/.codex/codealmanac-reference.md\");\n }\n if (existsSync(agents)) {\n const existing = await readFile(agents, \"utf8\");\n const body = removeManagedBlock(\n existing,\n \"<!-- codealmanac:start -->\",\n \"<!-- codealmanac:end -->\",\n );\n if (body !== existing) {\n if (body.trim().length === 0) {\n await rm(agents, { force: true });\n touched.push(\"~/.codex/AGENTS.md (deleted)\");\n } else {\n await writeFile(agents, body, \"utf8\");\n touched.push(\"~/.codex/AGENTS.md\");\n }\n }\n }\n return touched;\n}\n\nasync function removeCursorGuides(cwd: string): Promise<string[]> {\n const rule = path.join(cwd, \".cursor\", \"rules\", \"codealmanac.mdc\");\n if (!existsSync(rule)) return [];\n await rm(rule, { force: true });\n return [\".cursor/rules/codealmanac.mdc\"];\n}\n\nfunction removeManagedBlock(\n contents: string,\n start: string,\n end: string,\n): string {\n const pattern = new RegExp(\n `\\\\n?${escapeRegex(start)}[\\\\s\\\\S]*?${escapeRegex(end)}\\\\n?`,\n );\n return contents.replace(pattern, \"\\n\").replace(/\\n\\n\\n+/g, \"\\n\\n\");\n}\n\nfunction escapeRegex(value: string): string {\n return value.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n}\n\n/**\n * Remove the import line from a CLAUDE.md body. Match is line-anchored\n * (trimmed equality) so we don't munge a line that happens to include\n * the token as part of a longer string. Returns the unchanged body (and\n * `changed: false`) if the line isn't present — this is what makes the\n * command safe to run repeatedly.\n */\nexport function removeImportLine(contents: string): {\n changed: boolean;\n body: string;\n} {\n const eol = contents.includes(\"\\r\\n\") ? \"\\r\\n\" : \"\\n\";\n const lines = contents.split(/\\r?\\n/);\n\n const indices: number[] = [];\n for (let i = 0; i < lines.length; i++) {\n if (lines[i]!.trim() === IMPORT_LINE) indices.push(i);\n }\n if (indices.length === 0) return { changed: false, body: contents };\n\n // Remove the line(s). Iterate from the end so earlier indices stay\n // valid as we splice.\n for (let i = indices.length - 1; i >= 0; i--) {\n lines.splice(indices[i]!, 1);\n }\n\n let body = lines.join(eol);\n\n // Cleanup: collapse any double-blank that our removal created at the\n // spot the line used to live. A best-effort tidy — we don't try to\n // normalize the whole file.\n body = body.replace(/\\n\\n\\n+/g, \"\\n\\n\");\n\n return { changed: true, body };\n}\n\nfunction confirm(\n out: NodeJS.WritableStream,\n question: string,\n defaultYes: boolean,\n): Promise<boolean> {\n return new Promise((resolve) => {\n const hint = defaultYes ? \"[Y/n]\" : \"[y/N]\";\n out.write(` ${BLUE}\\u25c6${RST} ${question} ${DIM}${hint}${RST} `);\n\n let buf = \"\";\n const onData = (chunk: Buffer): void => {\n buf += chunk.toString(\"utf8\");\n const nl = buf.indexOf(\"\\n\");\n if (nl === -1) return;\n process.stdin.removeListener(\"data\", onData);\n process.stdin.pause();\n\n const answer = buf.slice(0, nl).trim().toLowerCase();\n const accepted =\n answer.length === 0\n ? defaultYes\n : answer === \"y\" || answer === \"yes\";\n resolve(accepted);\n };\n\n process.stdin.resume();\n process.stdin.on(\"data\", onData);\n });\n}\n"],"mappings":";;;;;;;;;AAAA,SAAS,kBAAkB;AAC3B,SAAS,UAAU,IAAI,iBAAiB;AACxC,SAAS,eAAe;AACxB,OAAO,UAAU;A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