codealmanac 0.2.6 → 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.
- package/LICENSE +21 -133
- package/README.md +20 -15
- package/dist/{agents-HYRWRHRX.js → agents-V2ZOIACP.js} +6 -5
- package/dist/{chunk-PDFS5VFE.js → chunk-447U3GQJ.js} +5 -17
- package/dist/chunk-447U3GQJ.js.map +1 -0
- package/dist/{chunk-3E7JNMTZ.js → chunk-5BWUMAOX.js} +4 -29
- package/dist/chunk-5BWUMAOX.js.map +1 -0
- package/dist/{chunk-KQUVMF27.js → chunk-BFIG2CXM.js} +2 -516
- package/dist/chunk-BFIG2CXM.js.map +1 -0
- package/dist/{chunk-K2JBCB7R.js → chunk-BQY5L3DL.js} +7 -43
- package/dist/chunk-BQY5L3DL.js.map +1 -0
- package/dist/{chunk-F53U6JQG.js → chunk-CQJVM34R.js} +2 -2
- package/dist/chunk-FUBE6KCO.js +124 -0
- package/dist/chunk-FUBE6KCO.js.map +1 -0
- package/dist/chunk-IZBXXAVL.js +524 -0
- package/dist/chunk-IZBXXAVL.js.map +1 -0
- package/dist/{chunk-7JUX4ADQ.js → chunk-IZT6RBHS.js} +1 -1
- package/dist/{chunk-DW32TL5W.js → chunk-JLQZELHQ.js} +18 -58
- package/dist/chunk-JLQZELHQ.js.map +1 -0
- package/dist/{chunk-2BNDNGUR.js → chunk-KZXWPG4P.js} +4 -8
- package/dist/{chunk-2BNDNGUR.js.map → chunk-KZXWPG4P.js.map} +1 -1
- package/dist/{chunk-GPFVEF6V.js → chunk-QIA22IAM.js} +6 -24
- package/dist/chunk-QIA22IAM.js.map +1 -0
- package/dist/{chunk-J7DNV2DH.js → chunk-RALBM6HZ.js} +43 -355
- package/dist/chunk-RALBM6HZ.js.map +1 -0
- package/dist/{chunk-HJ3WREGP.js → chunk-U5DLLWIC.js} +3 -3
- package/dist/chunk-WL4UE7Q6.js +1386 -0
- package/dist/chunk-WL4UE7Q6.js.map +1 -0
- package/dist/{chunk-VXDPUOQ5.js → chunk-ZUQN5Y3K.js} +129 -382
- package/dist/chunk-ZUQN5Y3K.js.map +1 -0
- package/dist/{chunk-ODJAAJGZ.js → chunk-ZZLLOAI6.js} +3 -3
- package/dist/{cli-MKXCNEMW.js → cli-XWPNARA6.js} +37 -20
- package/dist/cli-XWPNARA6.js.map +1 -0
- package/dist/codealmanac.js +1 -1
- package/dist/{config-F7FKEQ7F.js → config-KH3JUMG6.js} +4 -4
- package/dist/doctor-ENJT665Z.js +18 -0
- package/dist/{hook-4SVX446M.js → hook-2NP3UE7U.js} +2 -4
- package/dist/paths-O5CZADP2.js +14 -0
- package/dist/process-KFSLENL3.js +61 -0
- package/dist/{register-commands-2F6SXLDI.js → register-commands-LULZUSPO.js} +999 -1030
- package/dist/register-commands-LULZUSPO.js.map +1 -0
- package/dist/uninstall-BD4MMQ7M.js +16 -0
- package/dist/uninstall-BD4MMQ7M.js.map +1 -0
- package/dist/update-XSKPDFMJ.js +11 -0
- package/dist/update-XSKPDFMJ.js.map +1 -0
- package/dist/{wiki-IGNRNLUZ.js → wiki-O4RWMAE6.js} +8 -6
- package/dist/wiki-O4RWMAE6.js.map +1 -0
- package/guides/mini.md +8 -6
- package/guides/reference.md +89 -32
- package/hooks/almanac-capture.sh +7 -8
- package/package.json +3 -4
- package/prompts/agents/.gitkeep +1 -0
- package/prompts/base/notability.md +139 -0
- package/prompts/base/purpose.md +85 -0
- package/prompts/base/syntax.md +114 -0
- package/prompts/operations/absorb.md +43 -0
- package/prompts/operations/build.md +49 -0
- package/prompts/operations/garden.md +51 -0
- package/COMMERCIAL.md +0 -9
- package/dist/chunk-3E7JNMTZ.js.map +0 -1
- package/dist/chunk-DW32TL5W.js.map +0 -1
- package/dist/chunk-GPFVEF6V.js.map +0 -1
- package/dist/chunk-J7DNV2DH.js.map +0 -1
- package/dist/chunk-K2JBCB7R.js.map +0 -1
- package/dist/chunk-KQUVMF27.js.map +0 -1
- package/dist/chunk-PDFS5VFE.js.map +0 -1
- package/dist/chunk-VXDPUOQ5.js.map +0 -1
- package/dist/cli-MKXCNEMW.js.map +0 -1
- package/dist/doctor-37UH3HT5.js +0 -17
- package/dist/register-commands-2F6SXLDI.js.map +0 -1
- package/dist/uninstall-C62ZOK32.js +0 -17
- package/dist/update-2UGOFN5C.js +0 -11
- package/dist/wiki-IGNRNLUZ.js.map +0 -1
- package/prompts/bootstrap.md +0 -176
- package/prompts/reviewer.md +0 -129
- package/prompts/writer.md +0 -134
- /package/dist/{agents-HYRWRHRX.js.map → agents-V2ZOIACP.js.map} +0 -0
- /package/dist/{chunk-F53U6JQG.js.map → chunk-CQJVM34R.js.map} +0 -0
- /package/dist/{chunk-7JUX4ADQ.js.map → chunk-IZT6RBHS.js.map} +0 -0
- /package/dist/{chunk-HJ3WREGP.js.map → chunk-U5DLLWIC.js.map} +0 -0
- /package/dist/{chunk-ODJAAJGZ.js.map → chunk-ZZLLOAI6.js.map} +0 -0
- /package/dist/{config-F7FKEQ7F.js.map → config-KH3JUMG6.js.map} +0 -0
- /package/dist/{doctor-37UH3HT5.js.map → doctor-ENJT665Z.js.map} +0 -0
- /package/dist/{hook-4SVX446M.js.map → hook-2NP3UE7U.js.map} +0 -0
- /package/dist/{uninstall-C62ZOK32.js.map → paths-O5CZADP2.js.map} +0 -0
- /package/dist/{update-2UGOFN5C.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.
|
package/COMMERCIAL.md
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
# Commercial License
|
|
2
|
-
|
|
3
|
-
codealmanac is free for noncommercial use under the
|
|
4
|
-
[PolyForm Noncommercial License 1.0.0](./LICENSE).
|
|
5
|
-
|
|
6
|
-
Commercial use requires a separate paid commercial license from the copyright
|
|
7
|
-
holder.
|
|
8
|
-
|
|
9
|
-
To request a commercial license, contact Rohan Sheth.
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/update/config.ts"],"sourcesContent":["import { existsSync } from \"node:fs\";\nimport { mkdir, readFile, rename, writeFile } from \"node:fs/promises\";\nimport { dirname, join } from \"node:path\";\n\nimport {\n findNearestAlmanacDir,\n getGlobalAlmanacDir,\n getRepoAlmanacDir,\n} from \"../paths.js\";\n\nexport const ALL_AGENT_PROVIDER_IDS = [\"claude\", \"codex\", \"cursor\"] as const;\nexport type AgentProviderId = (typeof ALL_AGENT_PROVIDER_IDS)[number];\nexport const AGENT_PROVIDER_IDS = ALL_AGENT_PROVIDER_IDS;\nexport const DEFAULT_AGENT_PROVIDER_IDS = [\"claude\", \"codex\"] as const;\nexport type EnabledAgentProviderId =\n (typeof DEFAULT_AGENT_PROVIDER_IDS)[number] | AgentProviderId;\n\nexport function isCursorEnabled(env: NodeJS.ProcessEnv = process.env): boolean {\n return env.CODEALMANAC_ENABLE_CURSOR === \"1\";\n}\n\nexport function getEnabledAgentProviderIds(\n env: NodeJS.ProcessEnv = process.env,\n): AgentProviderId[] {\n return isCursorEnabled(env)\n ? [...ALL_AGENT_PROVIDER_IDS]\n : [...DEFAULT_AGENT_PROVIDER_IDS];\n}\n\nexport function isEnabledAgentProviderId(\n value: string,\n env: NodeJS.ProcessEnv = process.env,\n): value is AgentProviderId {\n return getEnabledAgentProviderIds(env).includes(value as AgentProviderId);\n}\n\nexport function formatEnabledAgentProviderList(\n env: NodeJS.ProcessEnv = process.env,\n): string {\n return getEnabledAgentProviderIds(env).join(\", \");\n}\n\nexport function disabledAgentProviderMessage(provider: string): string {\n if (provider === \"cursor\") {\n return \"cursor support is disabled. Set CODEALMANAC_ENABLE_CURSOR=1 to enable experimental Cursor support.\";\n }\n return `${provider} support is disabled.`;\n}\n\nexport function isAgentProviderId(value: string): value is AgentProviderId {\n return (ALL_AGENT_PROVIDER_IDS as readonly string[]).includes(value);\n}\n\nexport interface AgentConfig {\n /** Default provider for bootstrap/capture. Default: \"claude\". */\n default: AgentProviderId;\n /** Optional per-provider model override. `null` means provider default. */\n models: Partial<Record<AgentProviderId, string | null>>;\n}\n\n/**\n * `~/.almanac/config.toml` — global, cross-wiki configuration. Legacy\n * `config.json` is read and migrated forward on first normal access.\n *\n * Missing or malformed → defaults. Same tolerance as `UpdateState`:\n * the CLI must not be able to fail because this file drifted.\n */\nexport interface GlobalConfig {\n /** When `false`, suppress the pre-command update-nag banner. Default: true. */\n update_notifier: boolean;\n /** Agent-provider settings for bootstrap/capture. */\n agent: AgentConfig;\n}\n\nexport function defaultConfig(): GlobalConfig {\n return {\n update_notifier: true,\n agent: {\n default: \"claude\",\n models: {\n claude: null,\n codex: null,\n cursor: null,\n },\n },\n };\n}\n\nexport function getConfigPath(): string {\n return join(getGlobalAlmanacDir(), \"config.toml\");\n}\n\nexport function getLegacyConfigPath(): string {\n return join(getGlobalAlmanacDir(), \"config.json\");\n}\n\nexport function getProjectConfigPath(cwd: string): string | null {\n const repoRoot = findNearestAlmanacDir(cwd);\n return repoRoot === null ? null : join(getRepoAlmanacDir(repoRoot), \"config.toml\");\n}\n\nexport type ConfigOrigin = \"default\" | \"user\" | \"project\";\n\nexport interface ConfigReadOptions {\n path?: string;\n cwd?: string;\n}\n\nexport interface ConfigReadResult {\n config: GlobalConfig;\n origins: Record<string, ConfigOrigin>;\n raw: Record<string, unknown>;\n}\n\nexport async function readConfig(\n input?: string | ConfigReadOptions,\n): Promise<GlobalConfig> {\n return (await readConfigWithOrigins(input)).config;\n}\n\nexport async function readConfigWithOrigins(\n input?: string | ConfigReadOptions,\n): Promise<ConfigReadResult> {\n const opts = normalizeReadOptions(input);\n if (opts.path !== undefined) {\n const raw = await readRawConfigObject(opts.path);\n return {\n config: normalizeRawConfig(raw),\n origins: originsFromRaw(raw, \"user\"),\n raw,\n };\n }\n\n const file = getConfigPath();\n await migrateLegacyConfigIfNeeded(file);\n const userRaw = await readRawConfigObject(file);\n const mergedRaw = cloneJsonObject(userRaw);\n const origins = originsFromRaw(userRaw, \"user\");\n const projectPath = opts.cwd !== undefined ? getProjectConfigPath(opts.cwd) : null;\n if (projectPath !== null) {\n const projectRaw = await readRawConfigObject(projectPath);\n applyProjectConfig(mergedRaw, projectRaw);\n Object.assign(origins, originsFromRaw(projectRaw, \"project\", true));\n }\n return {\n config: normalizeRawConfig(mergedRaw),\n origins,\n raw: mergedRaw,\n };\n}\n\nfunction normalizeReadOptions(\n input?: string | ConfigReadOptions,\n): ConfigReadOptions {\n return typeof input === \"string\" ? { path: input } : input ?? {};\n}\n\nasync function migrateLegacyConfigIfNeeded(file: string): Promise<void> {\n if (existsSync(file)) return;\n const legacy = getLegacyConfigPath();\n if (!existsSync(legacy)) return;\n const raw = await readRawConfigObject(legacy);\n if (Object.keys(raw).length === 0) return;\n await writeConfig(normalizeRawConfig(raw), file);\n}\n\nfunction normalizeRawConfig(raw: Record<string, unknown>): GlobalConfig {\n const defaults = defaultConfig();\n const rawAgent =\n raw.agent !== undefined &&\n raw.agent !== null &&\n typeof raw.agent === \"object\" &&\n !Array.isArray(raw.agent)\n ? (raw.agent as Partial<AgentConfig>)\n : {};\n const rawDefault =\n typeof rawAgent.default === \"string\" &&\n isAgentProviderId(rawAgent.default)\n ? rawAgent.default\n : defaults.agent.default;\n const rawModels =\n rawAgent.models !== undefined &&\n rawAgent.models !== null &&\n typeof rawAgent.models === \"object\" &&\n !Array.isArray(rawAgent.models)\n ? (rawAgent.models as Record<string, unknown>)\n : {};\n const models: Partial<Record<AgentProviderId, string | null>> = {\n ...defaults.agent.models,\n };\n for (const id of AGENT_PROVIDER_IDS) {\n const value = rawModels[id];\n if (typeof value === \"string\" && value.length > 0) {\n models[id] = value === \"default\" || value === \"null\" ? null : value;\n } else if (value === null) {\n models[id] = null;\n }\n }\n return {\n update_notifier:\n typeof raw.update_notifier === \"boolean\"\n ? raw.update_notifier\n : defaults.update_notifier,\n agent: {\n default: rawDefault,\n models,\n },\n };\n}\n\nfunction applyProjectConfig(\n target: Record<string, unknown>,\n projectRaw: Record<string, unknown>,\n): void {\n const projectAgent =\n projectRaw.agent !== null &&\n typeof projectRaw.agent === \"object\" &&\n !Array.isArray(projectRaw.agent)\n ? projectRaw.agent as Record<string, unknown>\n : {};\n if (Object.keys(projectAgent).length === 0) return;\n const targetAgent =\n target.agent !== null &&\n typeof target.agent === \"object\" &&\n !Array.isArray(target.agent)\n ? target.agent as Record<string, unknown>\n : {};\n target.agent = targetAgent;\n if (typeof projectAgent.default === \"string\") {\n targetAgent.default = projectAgent.default;\n }\n const projectModels =\n projectAgent.models !== null &&\n typeof projectAgent.models === \"object\" &&\n !Array.isArray(projectAgent.models)\n ? projectAgent.models as Record<string, unknown>\n : {};\n if (Object.keys(projectModels).length === 0) return;\n const targetModels =\n targetAgent.models !== null &&\n typeof targetAgent.models === \"object\" &&\n !Array.isArray(targetAgent.models)\n ? targetAgent.models as Record<string, unknown>\n : {};\n targetAgent.models = targetModels;\n for (const id of AGENT_PROVIDER_IDS) {\n if (Object.prototype.hasOwnProperty.call(projectModels, id)) {\n targetModels[id] = projectModels[id];\n }\n }\n}\n\nfunction originsFromRaw(\n raw: Record<string, unknown>,\n origin: ConfigOrigin,\n agentOnly = false,\n): Record<string, ConfigOrigin> {\n const origins: Record<string, ConfigOrigin> = {};\n if (!agentOnly && Object.prototype.hasOwnProperty.call(raw, \"update_notifier\")) {\n origins.update_notifier = origin;\n }\n const agent =\n raw.agent !== null &&\n typeof raw.agent === \"object\" &&\n !Array.isArray(raw.agent)\n ? raw.agent as Record<string, unknown>\n : {};\n if (Object.prototype.hasOwnProperty.call(agent, \"default\")) {\n origins[\"agent.default\"] = origin;\n }\n const models =\n agent.models !== null &&\n typeof agent.models === \"object\" &&\n !Array.isArray(agent.models)\n ? agent.models as Record<string, unknown>\n : {};\n for (const id of AGENT_PROVIDER_IDS) {\n if (Object.prototype.hasOwnProperty.call(models, id)) {\n origins[`agent.models.${id}`] = origin;\n }\n }\n return origins;\n}\n\nasync function readSingleConfig(file: string): Promise<GlobalConfig> {\n let raw: string;\n try {\n raw = await readFile(file, \"utf8\");\n } catch {\n return defaultConfig();\n }\n const trimmed = raw.trim();\n if (trimmed.length === 0) return defaultConfig();\n try {\n return normalizeRawConfig(parseConfigText(trimmed, file));\n } catch {\n return defaultConfig();\n }\n}\n\nexport async function writeConfig(\n config: GlobalConfig | Partial<GlobalConfig>,\n path?: string,\n): Promise<void> {\n const file = path ?? getConfigPath();\n await mkdir(dirname(file), { recursive: true });\n const current = await readSingleConfig(file);\n const existingRaw = await readRawConfigObject(file);\n const stored = toStoredConfigPatch(config, current, existingRaw);\n const body = serializeConfig(stored, file);\n const tmp = `${file}.tmp`;\n await writeFile(tmp, body, \"utf8\");\n await rename(tmp, file);\n}\n\nfunction normalizeConfig(config: GlobalConfig | Partial<GlobalConfig>): GlobalConfig {\n const defaults = defaultConfig();\n return {\n update_notifier:\n typeof config.update_notifier === \"boolean\"\n ? config.update_notifier\n : defaults.update_notifier,\n agent: {\n default:\n config.agent !== undefined && isAgentProviderId(config.agent.default)\n ? config.agent.default\n : defaults.agent.default,\n models: {\n ...defaults.agent.models,\n ...(config.agent?.models ?? {}),\n },\n },\n };\n}\n\nasync function readRawConfigObject(\n path: string,\n): Promise<Record<string, unknown>> {\n try {\n return parseConfigText(await readFile(path, \"utf8\"), path);\n } catch {\n // Fall through to empty.\n }\n return {};\n}\n\nexport function parseConfigText(\n raw: string,\n path = \"config.toml\",\n): Record<string, unknown> {\n const trimmed = raw.trim();\n if (trimmed.length === 0) return {};\n if (path.endsWith(\".json\") || trimmed.startsWith(\"{\")) {\n const parsed = JSON.parse(trimmed) as unknown;\n return parsed !== null && typeof parsed === \"object\" && !Array.isArray(parsed)\n ? parsed as Record<string, unknown>\n : {};\n }\n return parseTomlConfig(trimmed);\n}\n\nexport function serializeConfig(\n raw: Record<string, unknown>,\n path = \"config.toml\",\n): string {\n return path.endsWith(\".json\")\n ? `${JSON.stringify(raw, null, 2)}\\n`\n : serializeTomlConfig(raw);\n}\n\nfunction parseTomlConfig(raw: string): Record<string, unknown> {\n const result: Record<string, unknown> = {};\n let section: string[] = [];\n for (const original of raw.split(/\\r?\\n/)) {\n const line = stripTomlComment(original).trim();\n if (line.length === 0) continue;\n const sectionMatch = line.match(/^\\[([A-Za-z0-9_.-]+)\\]$/);\n if (sectionMatch !== null) {\n section = sectionMatch[1]!.split(\".\");\n continue;\n }\n const eq = line.indexOf(\"=\");\n if (eq === -1) continue;\n const key = line.slice(0, eq).trim();\n const value = parseTomlValue(line.slice(eq + 1).trim());\n setObjectPath(result, [...section, key], value);\n }\n return result;\n}\n\nfunction serializeTomlConfig(raw: Record<string, unknown>): string {\n const lines: string[] = [];\n if (typeof raw.update_notifier === \"boolean\") {\n lines.push(`update_notifier = ${raw.update_notifier ? \"true\" : \"false\"}`);\n }\n const agent =\n raw.agent !== null &&\n typeof raw.agent === \"object\" &&\n !Array.isArray(raw.agent)\n ? raw.agent as Record<string, unknown>\n : {};\n if (typeof agent.default === \"string\") {\n if (lines.length > 0) lines.push(\"\");\n lines.push(\"[agent]\");\n lines.push(`default = ${tomlString(agent.default)}`);\n }\n const models =\n agent.models !== null &&\n typeof agent.models === \"object\" &&\n !Array.isArray(agent.models)\n ? agent.models as Record<string, unknown>\n : {};\n const modelLines: string[] = [];\n for (const id of AGENT_PROVIDER_IDS) {\n if (!Object.prototype.hasOwnProperty.call(models, id)) continue;\n const value = models[id] === null ? \"default\" : models[id];\n if (typeof value === \"string\" && value.length > 0) {\n modelLines.push(`${id} = ${tomlString(value)}`);\n }\n }\n if (modelLines.length > 0) {\n if (lines.length > 0) lines.push(\"\");\n lines.push(\"[agent.models]\", ...modelLines);\n }\n return `${lines.join(\"\\n\")}\\n`;\n}\n\nfunction stripTomlComment(line: string): string {\n let inString = false;\n let escaped = false;\n for (let i = 0; i < line.length; i++) {\n const ch = line[i];\n if (escaped) {\n escaped = false;\n continue;\n }\n if (ch === \"\\\\\") {\n escaped = true;\n continue;\n }\n if (ch === \"\\\"\") inString = !inString;\n if (ch === \"#\" && !inString) return line.slice(0, i);\n }\n return line;\n}\n\nfunction parseTomlValue(raw: string): string | boolean {\n if (raw === \"true\") return true;\n if (raw === \"false\") return false;\n if (raw.startsWith(\"\\\"\") && raw.endsWith(\"\\\"\")) {\n return JSON.parse(raw) as string;\n }\n return raw;\n}\n\nfunction tomlString(value: string): string {\n return JSON.stringify(value);\n}\n\nfunction setObjectPath(\n raw: Record<string, unknown>,\n path: string[],\n value: string | boolean,\n): void {\n let cursor = raw;\n for (const part of path.slice(0, -1)) {\n const next = cursor[part];\n if (next === null || typeof next !== \"object\" || Array.isArray(next)) {\n cursor[part] = {};\n }\n cursor = cursor[part] as Record<string, unknown>;\n }\n const leaf = path[path.length - 1];\n if (leaf !== undefined) cursor[leaf] = value;\n}\n\nfunction toStoredConfigPatch(\n config: GlobalConfig | Partial<GlobalConfig>,\n current: GlobalConfig,\n raw: Record<string, unknown>,\n): Record<string, unknown> {\n const normalized = normalizeConfig(config);\n const defaults = defaultConfig();\n const stored = cloneJsonObject(raw);\n\n if (\n config.update_notifier !== undefined &&\n normalized.update_notifier !== current.update_notifier\n ) {\n setStoredValue(\n stored,\n [\"update_notifier\"],\n normalized.update_notifier,\n defaults.update_notifier,\n );\n }\n\n if (config.agent !== undefined) {\n if (\n config.agent.default !== undefined &&\n normalized.agent.default !== current.agent.default\n ) {\n setStoredValue(\n stored,\n [\"agent\", \"default\"],\n normalized.agent.default,\n defaults.agent.default,\n );\n }\n\n const inputModels = config.agent.models ?? {};\n for (const id of AGENT_PROVIDER_IDS) {\n if (!Object.prototype.hasOwnProperty.call(inputModels, id)) continue;\n const value = normalized.agent.models[id] ?? null;\n const currentValue = current.agent.models[id] ?? null;\n const defaultValue = defaults.agent.models[id] ?? null;\n if (value !== currentValue) {\n setStoredValue(stored, [\"agent\", \"models\", id], value, defaultValue);\n }\n }\n }\n pruneEmptyObjects(stored);\n return stored;\n}\n\nfunction setStoredValue(\n raw: Record<string, unknown>,\n path: string[],\n value: string | boolean | null,\n defaultValue: string | boolean | null,\n): void {\n let cursor = raw;\n for (const part of path.slice(0, -1)) {\n const next = cursor[part];\n if (next === null || typeof next !== \"object\" || Array.isArray(next)) {\n cursor[part] = {};\n }\n cursor = cursor[part] as Record<string, unknown>;\n }\n const leaf = path[path.length - 1];\n if (leaf === undefined) return;\n cursor[leaf] = value;\n if (value !== defaultValue) return;\n // Keep explicit defaults only when the caller changed the value to the\n // default. Unchanged explicit defaults are preserved by cloning `raw`.\n}\n\nfunction cloneJsonObject(raw: Record<string, unknown>): Record<string, unknown> {\n return JSON.parse(JSON.stringify(raw)) as Record<string, unknown>;\n}\n\nfunction pruneEmptyObjects(raw: Record<string, unknown>): void {\n for (const [key, value] of Object.entries(raw)) {\n if (value === null || typeof value !== \"object\" || Array.isArray(value)) {\n continue;\n }\n pruneEmptyObjects(value as Record<string, unknown>);\n if (Object.keys(value).length === 0) delete raw[key];\n }\n}\n"],"mappings":";;;;;;;;AAAA,SAAS,kBAAkB;AAC3B,SAAS,OAAO,UAAU,QAAQ,iBAAiB;AACnD,SAAS,SAAS,YAAY;AAQvB,IAAM,yBAAyB,CAAC,UAAU,SAAS,QAAQ;AAE3D,IAAM,qBAAqB;AAC3B,IAAM,6BAA6B,CAAC,UAAU,OAAO;AAIrD,SAAS,gBAAgB,MAAyB,QAAQ,KAAc;AAC7E,SAAO,IAAI,8BAA8B;AAC3C;AAEO,SAAS,2BACd,MAAyB,QAAQ,KACd;AACnB,SAAO,gBAAgB,GAAG,IACtB,CAAC,GAAG,sBAAsB,IAC1B,CAAC,GAAG,0BAA0B;AACpC;AAEO,SAAS,yBACd,OACA,MAAyB,QAAQ,KACP;AAC1B,SAAO,2BAA2B,GAAG,EAAE,SAAS,KAAwB;AAC1E;AAEO,SAAS,+BACd,MAAyB,QAAQ,KACzB;AACR,SAAO,2BAA2B,GAAG,EAAE,KAAK,IAAI;AAClD;AAEO,SAAS,6BAA6B,UAA0B;AACrE,MAAI,aAAa,UAAU;AACzB,WAAO;AAAA,EACT;AACA,SAAO,GAAG,QAAQ;AACpB;AAEO,SAAS,kBAAkB,OAAyC;AACzE,SAAQ,uBAA6C,SAAS,KAAK;AACrE;AAuBO,SAAS,gBAA8B;AAC5C,SAAO;AAAA,IACL,iBAAiB;AAAA,IACjB,OAAO;AAAA,MACL,SAAS;AAAA,MACT,QAAQ;AAAA,QACN,QAAQ;AAAA,QACR,OAAO;AAAA,QACP,QAAQ;AAAA,MACV;AAAA,IACF;AAAA,EACF;AACF;AAEO,SAAS,gBAAw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-checks/format.ts","../src/commands/doctor-checks/install.ts","../src/commands/doctor-checks/probes.ts","../src/commands/doctor-checks/agents.ts","../src/commands/doctor-checks/updates.ts","../src/commands/doctor.ts"],"sourcesContent":["import { BLUE, BOLD, DIM, GREEN, RED, RST } from \"../../ansi.js\";\nimport type {\n AgentDoctorCheck,\n Check,\n CheckStatus,\n DoctorOptions,\n DoctorReport,\n} from \"./types.js\";\n\nexport function formatReport(\n report: DoctorReport,\n options: DoctorOptions,\n): string {\n const color = options.stdout === undefined && process.stdout.isTTY === true;\n const lines: string[] = [];\n lines.push(`codealmanac v${report.version}`);\n lines.push(\"\");\n if (report.install.length > 0) {\n lines.push(color ? `${BOLD}## Install${RST}` : \"## Install\");\n for (const c of report.install) {\n lines.push(formatCheck(c, color));\n }\n lines.push(\"\");\n }\n if (report.agents.length > 0) {\n lines.push(color ? `${BOLD}## Agents${RST}` : \"## Agents\");\n for (const c of report.agents.map(agentToCheck)) {\n lines.push(formatCheck(c, color));\n }\n lines.push(\"\");\n }\n if (report.updates.length > 0) {\n lines.push(color ? `${BOLD}## Updates${RST}` : \"## Updates\");\n for (const c of report.updates) {\n lines.push(formatCheck(c, color));\n }\n lines.push(\"\");\n }\n if (report.wiki.length > 0) {\n lines.push(color ? `${BOLD}## Current wiki${RST}` : \"## Current wiki\");\n for (const c of report.wiki) {\n lines.push(formatCheck(c, color));\n }\n lines.push(\"\");\n }\n return `${lines.join(\"\\n\")}\\n`;\n}\n\nfunction agentToCheck(agent: AgentDoctorCheck): Check {\n const message = [\n agent.label,\n agent.selected ? \"(default)\" : null,\n agent.recommended ? \"(recommended)\" : null,\n agent.status === \"ok\" ? \"ready\" : readinessMessage(agent),\n `model: ${agent.model ?? \"provider default\"}`,\n agent.account,\n ].filter((part): part is string => part !== null).join(\" \");\n return {\n status: agent.status,\n key: `agents.${agent.id}`,\n message,\n fix: agent.fix,\n };\n}\n\nfunction readinessMessage(agent: AgentDoctorCheck): string {\n if (!agent.installed) return \"missing\";\n if (!agent.authenticated) return `not ready: ${agent.detail}`;\n return agent.detail;\n}\n\nfunction formatCheck(c: Check, color: boolean): string {\n const { icon, tint } = iconFor(c.status, color);\n const head = ` ${tint}${icon}${color ? RST : \"\"} ${c.message}`;\n if (c.fix === undefined) return head;\n const fixLine = color\n ? ` ${DIM}${c.fix}${RST}`\n : ` ${c.fix}`;\n return `${head}\\n${fixLine}`;\n}\n\nfunction iconFor(\n status: CheckStatus,\n color: boolean,\n): { icon: string; tint: string } {\n switch (status) {\n case \"ok\":\n return { icon: \"\\u2713\", tint: color ? GREEN : \"\" };\n case \"problem\":\n return { icon: \"\\u2717\", tint: color ? RED : \"\" };\n case \"info\":\n return { icon: \"\\u25c7\", tint: color ? BLUE : \"\" };\n }\n}\n","import { existsSync } from \"node:fs\";\nimport { readFile } from \"node:fs/promises\";\nimport { homedir } from \"node:os\";\nimport path from \"node:path\";\n\nimport type { ClaudeAuthStatus } from \"../../agent/providers/claude/index.js\";\nimport {\n hasCodexInstructions,\n resolveCodexAgentsPath,\n} from \"../../agent/providers/codex-instructions.js\";\nimport {\n IMPORT_LINE,\n} from \"../setup.js\";\nimport {\n classifyInstallPath,\n detectInstallPath,\n probeBetterSqlite3,\n safeCheckAuth,\n} from \"./probes.js\";\nimport type { Check, DoctorOptions } from \"./types.js\";\n\nexport async function gatherInstallChecks(\n options: DoctorOptions,\n): Promise<Check[]> {\n const checks: Check[] = [];\n\n const rawPath = options.installPath ?? detectInstallPath();\n const { installPath, isEphemeral } = classifyInstallPath(rawPath);\n checks.push(describeInstallPath(installPath, isEphemeral));\n\n const nodeVersion = options.nodeVersion ?? process.version;\n const sqlite = options.sqliteProbe ?? probeBetterSqlite3();\n checks.push({\n status: sqlite.ok ? \"ok\" : \"problem\",\n key: \"install.sqlite\",\n message: sqlite.ok\n ? `better-sqlite3 native binding OK (Node ${nodeVersion})`\n : `better-sqlite3 native binding failed: ${sqlite.summary}`,\n fix: sqlite.ok\n ? undefined\n : \"run: npm rebuild better-sqlite3 (in the install directory)\",\n });\n\n const auth = await safeCheckAuth(options.spawnCli);\n checks.push(describeAuth(auth));\n\n const settingsPath =\n options.settingsPath ?? path.join(homedir(), \".claude\", \"settings.json\");\n checks.push(await describeHook(settingsPath));\n\n const claudeDir = options.claudeDir ?? path.join(homedir(), \".claude\");\n checks.push(describeGuides(claudeDir));\n checks.push(await describeImportLine(claudeDir));\n const codexDir = options.codexDir ?? path.join(homedir(), \".codex\");\n checks.push(await describeCodexInstructions(codexDir));\n\n return checks;\n}\n\nfunction describeInstallPath(\n installPath: string | null,\n isEphemeral: boolean,\n): Check {\n if (installPath === null) {\n return {\n status: \"problem\",\n key: \"install.path\",\n message: \"could not detect codealmanac install path\",\n fix: \"reinstall with: npm install -g codealmanac\",\n };\n }\n return {\n status: isEphemeral ? \"info\" : \"ok\",\n key: \"install.path\",\n message: isEphemeral\n ? `codealmanac running from ephemeral npx location: ${installPath}`\n : `codealmanac installed at ${installPath}`,\n fix: isEphemeral\n ? \"run: npm install -g codealmanac (to make the install permanent)\"\n : undefined,\n };\n}\n\nfunction describeAuth(auth: ClaudeAuthStatus): Check {\n if (auth.loggedIn) {\n if (auth.authMethod === \"apiKey\") {\n return {\n status: \"ok\",\n key: \"install.auth\",\n message: \"claude auth: ANTHROPIC_API_KEY set\",\n };\n }\n const who = auth.email ?? \"Claude account\";\n const plan =\n auth.subscriptionType !== undefined\n ? ` (${auth.subscriptionType} subscription)`\n : \"\";\n return {\n status: \"ok\",\n key: \"install.auth\",\n message: `claude auth: ${who}${plan}`,\n };\n }\n if (\n process.env.ANTHROPIC_API_KEY !== undefined &&\n process.env.ANTHROPIC_API_KEY.length > 0\n ) {\n return {\n status: \"ok\",\n key: \"install.auth\",\n message: \"claude auth: ANTHROPIC_API_KEY set\",\n };\n }\n return {\n status: \"problem\",\n key: \"install.auth\",\n message: \"claude auth: not signed in\",\n fix: \"run: claude auth login --claudeai (or export ANTHROPIC_API_KEY)\",\n };\n}\n\nasync function describeHook(settingsPath: string): Promise<Check> {\n if (!existsSync(settingsPath)) {\n return {\n status: \"problem\",\n key: \"install.hook\",\n message: \"SessionEnd hook not installed\",\n fix: \"run: almanac setup --yes\",\n };\n }\n try {\n const raw = await readFile(settingsPath, \"utf8\");\n const parsed = JSON.parse(raw) as {\n hooks?: {\n SessionEnd?: {\n command?: string;\n hooks?: { command?: string }[];\n }[];\n };\n };\n const entries = parsed.hooks?.SessionEnd ?? [];\n const found = entries.some((e) => {\n if (\n typeof e?.command === \"string\" &&\n e.command.endsWith(\"almanac-capture.sh\")\n ) {\n return true;\n }\n if (Array.isArray(e?.hooks)) {\n return e.hooks.some(\n (h) =>\n typeof h?.command === \"string\" &&\n h.command.endsWith(\"almanac-capture.sh\"),\n );\n }\n return false;\n });\n if (!found) {\n return {\n status: \"problem\",\n key: \"install.hook\",\n message: \"SessionEnd hook not installed\",\n fix: \"run: almanac setup --yes\",\n };\n }\n return {\n status: \"ok\",\n key: \"install.hook\",\n message: `SessionEnd hook installed at ${settingsPath}`,\n };\n } catch (err: unknown) {\n const msg = err instanceof Error ? err.message : String(err);\n return {\n status: \"problem\",\n key: \"install.hook\",\n message: `could not read ${settingsPath}: ${msg}`,\n fix: \"check the file for malformed JSON\",\n };\n }\n}\n\nfunction describeGuides(claudeDir: string): Check {\n const mini = path.join(claudeDir, \"codealmanac.md\");\n const ref = path.join(claudeDir, \"codealmanac-reference.md\");\n const haveMini = existsSync(mini);\n const haveRef = existsSync(ref);\n if (haveMini && haveRef) {\n return {\n status: \"ok\",\n key: \"install.guides\",\n message: `Agent guides installed (${path.basename(mini)}, ${path.basename(ref)})`,\n };\n }\n const missing = [\n haveMini ? null : \"codealmanac.md\",\n haveRef ? null : \"codealmanac-reference.md\",\n ].filter((s): s is string => s !== null);\n return {\n status: \"problem\",\n key: \"install.guides\",\n message: `Agent guides missing (${missing.join(\", \")})`,\n fix: \"run: almanac setup --yes\",\n };\n}\n\nasync function describeImportLine(claudeDir: string): Promise<Check> {\n const claudeMd = path.join(claudeDir, \"CLAUDE.md\");\n if (!existsSync(claudeMd)) {\n return {\n status: \"problem\",\n key: \"install.import\",\n message: \"CLAUDE.md import not present (no ~/.claude/CLAUDE.md)\",\n fix: \"run: almanac setup --yes\",\n };\n }\n try {\n const contents = await readFile(claudeMd, \"utf8\");\n const lines = contents.split(/\\r?\\n/).map((l) => l.trim());\n const present = lines.some((line) => {\n if (line === IMPORT_LINE) return true;\n if (!line.startsWith(IMPORT_LINE)) return false;\n const next = line[IMPORT_LINE.length];\n return next === \" \" || next === \"\\t\";\n });\n if (present) {\n return {\n status: \"ok\",\n key: \"install.import\",\n message: \"CLAUDE.md import present\",\n };\n }\n return {\n status: \"problem\",\n key: \"install.import\",\n message: \"CLAUDE.md import line missing\",\n fix: \"run: almanac setup --yes\",\n };\n } catch (err: unknown) {\n const msg = err instanceof Error ? err.message : String(err);\n return {\n status: \"problem\",\n key: \"install.import\",\n message: `could not read ${claudeMd}: ${msg}`,\n };\n }\n}\n\nasync function describeCodexInstructions(codexDir: string): Promise<Check> {\n const agentsFile = await resolveCodexAgentsPath(codexDir);\n if (!existsSync(agentsFile)) {\n return {\n status: \"problem\",\n key: \"install.codexInstructions\",\n message: `Codex AGENTS instructions missing (${path.basename(agentsFile)} not found)`,\n fix: \"run: almanac setup --yes\",\n };\n }\n try {\n const contents = await readFile(agentsFile, \"utf8\");\n if (hasCodexInstructions(contents)) {\n return {\n status: \"ok\",\n key: \"install.codexInstructions\",\n message: `Codex AGENTS instructions present (${path.basename(agentsFile)})`,\n };\n }\n } catch (err: unknown) {\n const msg = err instanceof Error ? err.message : String(err);\n return {\n status: \"problem\",\n key: \"install.codexInstructions\",\n message: `could not read ${agentsFile}: ${msg}`,\n };\n }\n\n return {\n status: \"problem\",\n key: \"install.codexInstructions\",\n message: `Codex AGENTS instructions missing (${path.basename(agentsFile)})`,\n fix: \"run: almanac setup --yes\",\n };\n}\n","import { existsSync, readFileSync } from \"node:fs\";\nimport { createRequire } from \"node:module\";\nimport { homedir } from \"node:os\";\nimport path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\n\nimport {\n checkClaudeAuth,\n type ClaudeAuthStatus,\n type SpawnCliFn,\n} from \"../../agent/providers/claude/index.js\";\nimport type { SqliteProbeResult } from \"./types.js\";\n\n// Single `createRequire` instance — used by package/binding probes.\nconst req = createRequire(import.meta.url);\n\n/**\n * Detect where codealmanac is installed by walking up from the running\n * module until we find a `package.json` whose `name` is `codealmanac`.\n */\nexport function detectInstallPath(): string | null {\n try {\n const here = fileURLToPath(import.meta.url);\n let dir = path.dirname(here);\n for (let i = 0; i < 6; i++) {\n const pkgPath = path.join(dir, \"package.json\");\n if (existsSync(pkgPath)) {\n try {\n const raw = readFileSync(pkgPath, \"utf-8\");\n const pkg = JSON.parse(raw) as { name?: unknown };\n if (pkg.name === \"codealmanac\") return dir;\n } catch {\n // ignore — keep walking\n }\n }\n const parent = path.dirname(dir);\n if (parent === dir) break;\n dir = parent;\n }\n return null;\n } catch {\n return null;\n }\n}\n\n/**\n * Classify the detected install path as permanent or ephemeral.\n * Ephemeral locations (npm npx cache, pnpm dlx cache, /tmp/) are valid\n * installs but will disappear when the cache is evicted or the machine\n * reboots. Doctor reports them as `info` rather than `ok`.\n */\nexport function classifyInstallPath(\n raw: string | null,\n): { installPath: string | null; isEphemeral: boolean } {\n if (raw === null) return { installPath: null, isEphemeral: false };\n const home = homedir();\n const ephemeralPrefixes = [\n path.join(home, \".npm\", \"_npx\"),\n path.join(home, \".local\", \"share\", \"pnpm\", \"dlx\"),\n \"/tmp/\",\n \"/var/folders/\",\n ];\n const isEphemeral = ephemeralPrefixes.some((p) => raw.startsWith(p));\n return { installPath: raw, isEphemeral };\n}\n\n/**\n * Probe the better-sqlite3 native binding by opening an in-memory DB.\n */\nexport function probeBetterSqlite3(): SqliteProbeResult {\n try {\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const Database = req(\"better-sqlite3\") as typeof import(\"better-sqlite3\");\n const db = new Database(\":memory:\");\n db.close();\n return { ok: true, summary: \"native binding loads cleanly\" };\n } catch (err: unknown) {\n const msg = err instanceof Error ? err.message : String(err);\n const firstLine = msg.split(\"\\n\")[0] ?? msg;\n return { ok: false, summary: firstLine };\n }\n}\n\nexport async function safeCheckAuth(\n spawnCli?: SpawnCliFn,\n): Promise<ClaudeAuthStatus> {\n try {\n return await checkClaudeAuth(spawnCli);\n } catch {\n return { loggedIn: false };\n }\n}\n\nexport function readPackageVersion(): string | null {\n const candidates = [\n \"../../../package.json\",\n \"../../package.json\",\n \"../package.json\",\n ];\n for (const candidate of candidates) {\n try {\n const pkg = req(candidate) as { version?: unknown };\n if (typeof pkg.version === \"string\" && pkg.version.length > 0) {\n return pkg.version;\n }\n } catch {\n // Fall through to the next runtime layout candidate.\n }\n }\n return null;\n}\n","import { buildProviderSetupView } from \"../../agent/provider-view.js\";\nimport { checkClaudeAuth } from \"../../agent/providers/claude/index.js\";\nimport type { ProviderStatus } from \"../../agent/types.js\";\nimport { isCursorEnabled } from \"../../update/config.js\";\nimport type { AgentDoctorCheck, DoctorOptions } from \"./types.js\";\n\nexport async function gatherAgentChecks(\n options: DoctorOptions,\n): Promise<AgentDoctorCheck[]> {\n const view = await buildProviderSetupView({\n spawnCli: options.spawnCli,\n statuses:\n options.providerStatuses ??\n (options.spawnCli === undefined\n ? undefined\n : await injectedProviderStatuses(options)),\n });\n return view.choices.map((choice) => {\n return {\n status: choice.ready ? \"ok\" : \"problem\",\n id: choice.id,\n label: choice.label,\n readiness: choice.readiness,\n selected: choice.selected,\n recommended: choice.recommended,\n installed: choice.installed,\n authenticated: choice.authenticated,\n model: choice.effectiveModel,\n providerDefaultModel: choice.providerDefaultModel,\n configuredModel: choice.configuredModel,\n account: choice.account,\n detail: choice.detail,\n fix: choice.fixCommand ?? undefined,\n };\n });\n}\n\nasync function injectedProviderStatuses(\n options: DoctorOptions,\n): Promise<ProviderStatus[]> {\n const auth = await checkClaudeAuth(options.spawnCli);\n const hasApiKey =\n process.env.ANTHROPIC_API_KEY !== undefined &&\n process.env.ANTHROPIC_API_KEY.length > 0;\n const claudeReady = auth.loggedIn || hasApiKey;\n const statuses: ProviderStatus[] = [\n {\n id: \"claude\",\n installed: true,\n authenticated: claudeReady,\n detail: claudeReady\n ? auth.email ?? (hasApiKey ? \"ANTHROPIC_API_KEY set\" : \"logged in\")\n : \"not logged in\",\n },\n {\n id: \"codex\",\n installed: false,\n authenticated: false,\n detail: \"codex status not injected\",\n },\n ];\n if (isCursorEnabled()) {\n statuses.push({\n id: \"cursor\",\n installed: false,\n authenticated: false,\n detail: \"cursor-agent status not injected\",\n });\n }\n return statuses;\n}\n","import { readConfig } from \"../../update/config.js\";\nimport { readStateForDoctor } from \"../../update/schedule.js\";\nimport { isNewer } from \"../../update/semver.js\";\nimport { formatDuration } from \"./duration.js\";\nimport type { Check, DoctorOptions } from \"./types.js\";\n\nexport async function gatherUpdateChecks(\n options: DoctorOptions,\n installedVersion: string,\n): Promise<Check[]> {\n const checks: Check[] = [];\n const state = readStateForDoctor(options.updateStatePath);\n const config = await readConfig(options.updateConfigPath);\n\n if (state === null || state.latest_version.length === 0) {\n checks.push({\n status: \"info\",\n key: \"update.status\",\n message: `on ${installedVersion}; no update check has run yet`,\n fix: \"run: almanac update --check\",\n });\n } else if (isNewer(state.latest_version, installedVersion)) {\n const dismissed = state.dismissed_versions.includes(state.latest_version)\n ? \" (dismissed — run `almanac update` to install anyway)\"\n : \"\";\n checks.push({\n status: \"problem\",\n key: \"update.status\",\n message:\n `${state.latest_version} available (you're on ${installedVersion})${dismissed}`,\n fix: \"run: almanac update\",\n });\n } else {\n checks.push({\n status: \"ok\",\n key: \"update.status\",\n message: `on latest (${installedVersion})`,\n });\n }\n\n if (state !== null && state.last_check_at > 0) {\n const now = (options.now?.() ?? new Date()).getTime();\n const ageMs = now - state.last_check_at * 1000;\n const failedSuffix =\n state.last_fetch_failed_at !== undefined &&\n state.last_fetch_failed_at === state.last_check_at\n ? \" (last attempt failed — will retry next invocation)\"\n : \"\";\n checks.push({\n status: \"info\",\n key: \"update.last_check\",\n message: `last checked: ${formatDuration(ageMs)} ago${failedSuffix}`,\n });\n } else {\n checks.push({\n status: \"info\",\n key: \"update.last_check\",\n message: \"last checked: never\",\n });\n }\n\n checks.push({\n status: \"info\",\n key: \"update.notifier\",\n message: `update notifier: ${config.update_notifier ? \"enabled\" : \"disabled\"}`,\n fix: config.update_notifier\n ? undefined\n : \"run: almanac config set update_notifier true\",\n });\n\n if (state !== null && state.dismissed_versions.length > 0) {\n checks.push({\n status: \"info\",\n key: \"update.dismissed\",\n message: `dismissed versions: ${state.dismissed_versions.join(\", \")}`,\n });\n }\n\n return checks;\n}\n","import { formatReport } from \"./doctor-checks/format.js\";\nimport { gatherInstallChecks } from \"./doctor-checks/install.js\";\nimport { readPackageVersion } from \"./doctor-checks/probes.js\";\nimport type {\n Check,\n CheckStatus,\n AgentDoctorCheck,\n DoctorOptions,\n DoctorReport,\n DoctorResult,\n SqliteProbeResult,\n} from \"./doctor-checks/types.js\";\nimport { gatherAgentChecks } from \"./doctor-checks/agents.js\";\nimport { gatherUpdateChecks } from \"./doctor-checks/updates.js\";\n\nexport type {\n Check,\n CheckStatus,\n DoctorOptions,\n DoctorReport,\n DoctorResult,\n SqliteProbeResult,\n};\n\n/**\n * `almanac doctor` — install + wiki health report.\n *\n * Separate from `almanac health` (which checks graph integrity of a\n * specific wiki). `doctor` answers the \"is this install even set up\n * correctly?\" question that users hit when first trying the tool or when\n * sessions silently stop getting captured.\n *\n * This file is the command composition root. The section-specific probes\n * and formatting live in `doctor-checks/` so each durable fact has one\n * obvious owner.\n */\nexport async function runDoctor(\n options: DoctorOptions,\n): Promise<DoctorResult> {\n const version =\n options.versionOverride ?? readPackageVersion() ?? \"unknown\";\n\n const install: Check[] = options.wikiOnly === true\n ? []\n : await gatherInstallChecks(options);\n\n const agents: AgentDoctorCheck[] = options.wikiOnly === true\n ? []\n : await gatherAgentChecks(options);\n\n const updates: Check[] = options.wikiOnly === true\n ? []\n : await gatherUpdateChecks(options, version);\n\n const wiki: Check[] = options.installOnly === true\n ? []\n : await safeGatherWikiChecks(options);\n\n const report: DoctorReport = { version, install, agents, updates, wiki };\n\n if (options.json === true) {\n return {\n stdout: `${JSON.stringify(report, null, 2)}\\n`,\n stderr: \"\",\n exitCode: 0,\n };\n }\n\n return {\n stdout: formatReport(report, options),\n stderr: \"\",\n exitCode: 0,\n };\n}\n\nasync function safeGatherWikiChecks(\n options: DoctorOptions,\n): Promise<Check[]> {\n try {\n const { gatherWikiChecks } = await import(\"./doctor-checks/wiki.js\");\n return await gatherWikiChecks(options);\n } catch (err: unknown) {\n const msg = err instanceof Error ? err.message : String(err);\n return [\n {\n status: \"problem\",\n key: \"wiki.checks\",\n message: `could not run wiki checks: ${msg.split(\"\\n\")[0] ?? msg}`,\n fix: \"run: npm rebuild better-sqlite3 (in the install directory)\",\n },\n ];\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASO,SAAS,aACd,QACA,SACQ;AACR,QAAM,QAAQ,QAAQ,WAAW,UAAa,QAAQ,OAAO,UAAU;AACvE,QAAM,QAAkB,CAAC;AACzB,QAAM,KAAK,gBAAgB,OAAO,OAAO,EAAE;AAC3C,QAAM,KAAK,EAAE;AACb,MAAI,OAAO,QAAQ,SAAS,GAAG;AAC7B,UAAM,KAAK,QAAQ,GAAG,IAAI,aAAa,GAAG,KAAK,YAAY;AAC3D,eAAW,KAAK,OAAO,SAAS;AAC9B,YAAM,KAAK,YAAY,GAAG,KAAK,CAAC;AAAA,IAClC;AACA,UAAM,KAAK,EAAE;AAAA,EACf;AACA,MAAI,OAAO,OAAO,SAAS,GAAG;AAC5B,UAAM,KAAK,QAAQ,GAAG,IAAI,YAAY,GAAG,KAAK,WAAW;AACzD,eAAW,KAAK,OAAO,OAAO,IAAI,YAAY,GAAG;AAC/C,YAAM,KAAK,YAAY,GAAG,KAAK,CAAC;AAAA,IAClC;AACA,UAAM,KAAK,EAAE;AAAA,EACf;AACA,MAA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U;AAAA,EACZ;AACF;AAEA,eAAe,qBACb,SACkB;AAClB,MAAI;AACF,UAAM,EAAE,iBAAiB,IAAI,MAAM,OAAO,oBAAyB;AACnE,WAAO,MAAM,iBAAiB,OAAO;AAAA,EACvC,SAAS,KAAc;AACrB,UAAM,MAAM,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG;AAC3D,WAAO;AAAA,MACL;AAAA,QACE,QAAQ;AAAA,QACR,KAAK;AAAA,QACL,SAAS,8BAA8B,IAAI,MAAM,IAAI,EAAE,CAAC,KAAK,GAAG;AAAA,QAChE,KAAK;AAAA,MACP;AAAA,IACF;AAAA,EACF;AACF;","names":["existsSync","homedir","path","path","homedir","existsSync"]}
|
|
@@ -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 disabledAgentProviderMessage,\n formatEnabledAgentProviderList,\n isAgentProviderId,\n isEnabledAgentProviderId,\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 lines = [\"codealmanac agents\\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 `\\nUse: almanac agents use <${formatEnabledAgentProviderList().replaceAll(\", \", \"|\")}>`,\n \"Set model: almanac agents model <provider> <model>\",\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: ${formatEnabledAgentProviderList()}.\\n`,\n exitCode: 1,\n };\n }\n const provider = parsed.provider;\n if (!isEnabledAgentProviderId(provider)) {\n return disabledProviderResult(provider);\n }\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 agent set to ${provider}.\\n`\n : `codealmanac: default agent 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: ${formatEnabledAgentProviderList()}.\\n`,\n exitCode: 1,\n };\n }\n if (!isEnabledAgentProviderId(opts.provider)) {\n return disabledProviderResult(opts.provider);\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 disabledProviderResult(provider: string): AgentsResult {\n return {\n stdout: \"\",\n stderr: `almanac: ${disabledAgentProviderMessage(provider)}\\n`,\n exitCode: 1,\n };\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":";;;;;;;;;;;;;;;AAqBA,eAAsB,gBAAuC;AAC3D,QAAM,OAAO,MAAM,uBAAuB;AAC1C,QAAM,QAAQ,CAAC,sBAAsB;AACrC,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;AAAA,2BAA8B,+BAA+B,EAAE,WAAW,MAAM,GAAG,CAAC;AAAA,IACpF;AAAA,EACF;AACA,SAAO,EAAE,QAAQ,GAAG,MAAM,KAAK,IAAI,C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