ccdesk 0.2.3 → 0.2.5

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 (46) hide show
  1. package/CHANGELOG.md +34 -0
  2. package/README.md +2 -2
  3. package/THIRD_PARTY_NOTICES.md +224 -0
  4. package/dist/core/agent-edit.d.ts +1 -1
  5. package/dist/core/agent-edit.js +2 -2
  6. package/dist/core/backups.d.ts +1 -1
  7. package/dist/core/backups.js +29 -5
  8. package/dist/core/index.d.ts +6 -6
  9. package/dist/core/index.js +14 -14
  10. package/dist/core/mcp-edit.d.ts +1 -3
  11. package/dist/core/mcp-edit.js +15 -11
  12. package/dist/core/mutations.d.ts +1 -1
  13. package/dist/core/mutations.js +2 -2
  14. package/dist/core/open.d.ts +2 -5
  15. package/dist/core/open.js +6 -8
  16. package/dist/core/scan/data.d.ts +6 -0
  17. package/dist/core/scan/data.js +8 -0
  18. package/dist/core/scan/env.d.ts +2 -0
  19. package/dist/core/scan/env.js +8 -1
  20. package/dist/core/scan/files.js +2 -2
  21. package/dist/core/scan/git.d.ts +6 -0
  22. package/dist/core/scan/git.js +8 -0
  23. package/dist/core/scan/index.js +5 -2
  24. package/dist/core/scan/mcp.js +2 -1
  25. package/dist/core/scan/projects.js +2 -1
  26. package/dist/core/scan/settings.d.ts +2 -0
  27. package/dist/core/scan/settings.js +12 -3
  28. package/dist/core/scan/usage.d.ts +0 -6
  29. package/dist/core/scan/usage.js +7 -4
  30. package/dist/core/secrets.d.ts +3 -2
  31. package/dist/core/secrets.js +49 -29
  32. package/dist/core/settings-edit.d.ts +3 -3
  33. package/dist/core/settings-edit.js +4 -4
  34. package/dist/core/write.d.ts +0 -2
  35. package/dist/core/write.js +2 -4
  36. package/dist/shared/memory.d.ts +5 -1
  37. package/dist/shared/memory.js +18 -2
  38. package/dist/shared/settings.schema.json +129 -1
  39. package/dist/shared/types.d.ts +7 -0
  40. package/dist/ui/assets/{index-CH1HoC38.js → index-CGpaJLzd.js} +4 -4
  41. package/dist/ui/assets/index-DM3TASgn.css +1 -0
  42. package/dist/ui/index.html +2 -2
  43. package/dist/view/sections/catalog.d.ts +4 -1
  44. package/dist/view/sections/catalog.js +9 -2
  45. package/package.json +4 -2
  46. package/dist/ui/assets/index-D5XqP5c_.css +0 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,39 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.2.5](https://github.com/ayagmar/ccdesk/compare/v0.2.4...v0.2.5) (2026-10-13)
4
+
5
+ ### Features
6
+
7
+ * **settings:** edit documented keys the SDK schema lacks, via SchemaStore ([d764c0e](https://github.com/ayagmar/ccdesk/commit/d764c0e0c84a80fe5a9d386ef83b11497e6e809c))
8
+
9
+ ### Bug Fixes
10
+
11
+ * **settings:** describe borrowed keys with the docs, not SchemaStore ([fbcd686](https://github.com/ayagmar/ccdesk/commit/fbcd68678c24c277fe721332b88303b62d0b2504))
12
+ * **settings:** give borrowed keys the docs' full text, not the summary ([5cd93c4](https://github.com/ayagmar/ccdesk/commit/5cd93c44612b0bc082d42fe6dfb0601050470a1a))
13
+ * **ui:** stop column heads covering section titles in Firefox ([7ccfce7](https://github.com/ayagmar/ccdesk/commit/7ccfce747c6271c282b3bc71c3b5a76acfa182d7))
14
+ * **view:** keep asterisks inside code spans when making docs text plain ([6c3255b](https://github.com/ayagmar/ccdesk/commit/6c3255b540811b062107c93675e8f178deaf8a17))
15
+
16
+ ## [0.2.4](https://github.com/ayagmar/ccdesk/compare/v0.2.3...v0.2.4) (2026-10-13)
17
+
18
+ ### Features
19
+
20
+ * **core:** warn when a higher managed source than the files is present ([cb04a30](https://github.com/ayagmar/ccdesk/commit/cb04a30e72293270bdf4e3529a938ef13188bb41))
21
+
22
+ ### Bug Fixes
23
+
24
+ * **core:** count Explorer as having opened the file on Windows ([eb1a120](https://github.com/ayagmar/ccdesk/commit/eb1a12090507be426765c38d2e71a5f5500622ef))
25
+ * **core:** hide header values and more secret flags in MCP server args ([3a9ee02](https://github.com/ayagmar/ccdesk/commit/3a9ee024a124602f486b3e8f41e23fffa7c84565))
26
+ * **core:** look up ~/.claude.json folders as Claude Code keys them on Windows ([67a445d](https://github.com/ayagmar/ccdesk/commit/67a445d2a569bccd8f1615e798af099ece5dbe38))
27
+ * **core:** name long project stores as Claude Code does ([98f4dd8](https://github.com/ayagmar/ccdesk/commit/98f4dd8f4efbe1ce0c2154e58b554c9a05baed95))
28
+ * **core:** read JSON files that start with a byte order mark ([6bb2fd3](https://github.com/ayagmar/ccdesk/commit/6bb2fd302d468f1603d2230270ce5c9999027e93))
29
+ * **core:** report a backup folder ccdesk cannot read instead of listing none ([1209b9c](https://github.com/ayagmar/ccdesk/commit/1209b9c0a360939a3247fd3e92ad9b0d41b579f6))
30
+ * **core:** say why claude did not start on Windows instead of "not on PATH" ([9c0d3ad](https://github.com/ayagmar/ccdesk/commit/9c0d3adcc0ad0cb1ff4ed6b66377b603c1b1f4da))
31
+
32
+ ### Performance Improvements
33
+
34
+ * **core:** group hand-approved calls without copying each group ([9ab7219](https://github.com/ayagmar/ccdesk/commit/9ab7219986690e08669f3aceacb93f3f48777e11))
35
+ * **ui:** refresh the overview on focus and saves, not on watched changes ([9010576](https://github.com/ayagmar/ccdesk/commit/901057643dfcded5f2463ccb09353a5d264f109d))
36
+
3
37
  ## [0.2.3](https://github.com/ayagmar/ccdesk/compare/v0.2.2...v0.2.3) (2026-10-13)
4
38
 
5
39
  ### Features
package/README.md CHANGED
@@ -113,7 +113,7 @@ ccdesk reads `~/.claude` and `~/.claude.json`, or `$CLAUDE_CONFIG_DIR` when it i
113
113
  ## Privacy and safety
114
114
 
115
115
  - The server listens on `127.0.0.1` only, and every API call needs a token generated for that run. Nothing leaves your machine.
116
- - Values under `env` and `headers`, and keys in an MCP server's `args` (after flags such as `--token` or `--api-key`, or starting like `sk-` or `ghp_`), are hidden everywhere in the UI, diffs included, and ccdesk refuses any edit that would change them.
116
+ - Values under `env` and `headers`, and keys in an MCP server's `args` (after flags such as `--token` or `--api-key`, in a `--header` such as `Authorization: Bearer …`, or starting like `sk-` or `ghp_`), are hidden everywhere in the UI, diffs included, and ccdesk refuses any edit that would change them.
117
117
  - ccdesk never reads `~/.claude/.credentials.json`.
118
118
  - From your transcripts, only counts and rule patterns (a command's program and subcommand, a fetch's domain) reach the page, never commands or file contents.
119
119
  - Backups are readable only by you on Linux and macOS.
@@ -129,7 +129,7 @@ pnpm dev:ui # UI with hot reload on localhost:4320
129
129
  pnpm check # typecheck, lint, format, tests, build
130
130
  ```
131
131
 
132
- Tests never touch your real `~/.claude`; each one builds a throwaway home directory. The settings schema, scopes and built-in tools are generated from [`@anthropic-ai/claude-agent-sdk`](https://www.npmjs.com/package/@anthropic-ai/claude-agent-sdk) and Claude Code's docs, and a daily workflow opens a pull request when they change. [Contributing](https://ayagmar.github.io/ccdesk/contributing/) covers the generators, the docs site and releases. [ARCHITECTURE.md](ARCHITECTURE.md) explains how the code fits together, and [`docs/`](docs/) holds the plan for splitting the core from the web server and feature ideas.
132
+ Tests never touch your real `~/.claude`; each one builds a throwaway home directory. The settings schema, scopes and built-in tools are generated from [`@anthropic-ai/claude-agent-sdk`](https://www.npmjs.com/package/@anthropic-ai/claude-agent-sdk), Claude Code's docs and, for documented keys the SDK lacks, [SchemaStore](https://json.schemastore.org/claude-code-settings.json), and a daily workflow opens a pull request when they change. [Contributing](https://ayagmar.github.io/ccdesk/contributing/) covers the generators, the docs site and releases. [ARCHITECTURE.md](ARCHITECTURE.md) explains how the code fits together, and [`docs/`](docs/) holds the plan for splitting the core from the web server and feature ideas.
133
133
 
134
134
  ## License
135
135
 
@@ -0,0 +1,224 @@
1
+ # Third-party notices
2
+
3
+ ## JSON Schema Store
4
+
5
+ `scripts/schemastore-claude-code-settings.json` in the repository is a copy of SchemaStore's schema
6
+ for Claude Code settings, <https://json.schemastore.org/claude-code-settings.json>, reformatted.
7
+ `src/shared/settings.schema.json` (`dist/shared/settings.schema.json` in the package) includes
8
+ definitions copied from it for documented keys that the Settings type in
9
+ `@anthropic-ai/claude-agent-sdk` does not define. In each copied definition, the top-level
10
+ `description` is replaced with the text from Claude Code's settings reference and a `$comment`
11
+ naming SchemaStore as its source is added; nothing else in it is changed.
12
+
13
+ SchemaStore's NOTICE file:
14
+
15
+ ```
16
+ JSON Schema Store
17
+ Copyright 2015-Current Mads Kristensen and Contributors
18
+ ```
19
+
20
+ SchemaStore is licensed under the Apache License, Version 2.0:
21
+
22
+ ```
23
+ Apache License
24
+ Version 2.0, January 2004
25
+ http://www.apache.org/licenses/
26
+
27
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
28
+
29
+ 1. Definitions.
30
+
31
+ "License" shall mean the terms and conditions for use, reproduction,
32
+ and distribution as defined by Sections 1 through 9 of this document.
33
+
34
+ "Licensor" shall mean the copyright owner or entity authorized by
35
+ the copyright owner that is granting the License.
36
+
37
+ "Legal Entity" shall mean the union of the acting entity and all
38
+ other entities that control, are controlled by, or are under common
39
+ control with that entity. For the purposes of this definition,
40
+ "control" means (i) the power, direct or indirect, to cause the
41
+ direction or management of such entity, whether by contract or
42
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
43
+ outstanding shares, or (iii) beneficial ownership of such entity.
44
+
45
+ "You" (or "Your") shall mean an individual or Legal Entity
46
+ exercising permissions granted by this License.
47
+
48
+ "Source" form shall mean the preferred form for making modifications,
49
+ including but not limited to software source code, documentation
50
+ source, and configuration files.
51
+
52
+ "Object" form shall mean any form resulting from mechanical
53
+ transformation or translation of a Source form, including but
54
+ not limited to compiled object code, generated documentation,
55
+ and conversions to other media types.
56
+
57
+ "Work" shall mean the work of authorship, whether in Source or
58
+ Object form, made available under the License, as indicated by a
59
+ copyright notice that is included in or attached to the work
60
+ (an example is provided in the Appendix below).
61
+
62
+ "Derivative Works" shall mean any work, whether in Source or Object
63
+ form, that is based on (or derived from) the Work and for which the
64
+ editorial revisions, annotations, elaborations, or other modifications
65
+ represent, as a whole, an original work of authorship. For the purposes
66
+ of this License, Derivative Works shall not include works that remain
67
+ separable from, or merely link (or bind by name) to the interfaces of,
68
+ the Work and Derivative Works thereof.
69
+
70
+ "Contribution" shall mean any work of authorship, including
71
+ the original version of the Work and any modifications or additions
72
+ to that Work or Derivative Works thereof, that is intentionally
73
+ submitted to Licensor for inclusion in the Work by the copyright owner
74
+ or by an individual or Legal Entity authorized to submit on behalf of
75
+ the copyright owner. For the purposes of this definition, "submitted"
76
+ means any form of electronic, verbal, or written communication sent
77
+ to the Licensor or its representatives, including but not limited to
78
+ communication on electronic mailing lists, source code control systems,
79
+ and issue tracking systems that are managed by, or on behalf of, the
80
+ Licensor for the purpose of discussing and improving the Work, but
81
+ excluding communication that is conspicuously marked or otherwise
82
+ designated in writing by the copyright owner as "Not a Contribution."
83
+
84
+ "Contributor" shall mean Licensor and any individual or Legal Entity
85
+ on behalf of whom a Contribution has been received by Licensor and
86
+ subsequently incorporated within the Work.
87
+
88
+ 2. Grant of Copyright License. Subject to the terms and conditions of
89
+ this License, each Contributor hereby grants to You a perpetual,
90
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
91
+ copyright license to reproduce, prepare Derivative Works of,
92
+ publicly display, publicly perform, sublicense, and distribute the
93
+ Work and such Derivative Works in Source or Object form.
94
+
95
+ 3. Grant of Patent License. Subject to the terms and conditions of
96
+ this License, each Contributor hereby grants to You a perpetual,
97
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
98
+ (except as stated in this section) patent license to make, have made,
99
+ use, offer to sell, sell, import, and otherwise transfer the Work,
100
+ where such license applies only to those patent claims licensable
101
+ by such Contributor that are necessarily infringed by their
102
+ Contribution(s) alone or by combination of their Contribution(s)
103
+ with the Work to which such Contribution(s) was submitted. If You
104
+ institute patent litigation against any entity (including a
105
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
106
+ or a Contribution incorporated within the Work constitutes direct
107
+ or contributory patent infringement, then any patent licenses
108
+ granted to You under this License for that Work shall terminate
109
+ as of the date such litigation is filed.
110
+
111
+ 4. Redistribution. You may reproduce and distribute copies of the
112
+ Work or Derivative Works thereof in any medium, with or without
113
+ modifications, and in Source or Object form, provided that You
114
+ meet the following conditions:
115
+
116
+ (a) You must give any other recipients of the Work or
117
+ Derivative Works a copy of this License; and
118
+
119
+ (b) You must cause any modified files to carry prominent notices
120
+ stating that You changed the files; and
121
+
122
+ (c) You must retain, in the Source form of any Derivative Works
123
+ that You distribute, all copyright, patent, trademark, and
124
+ attribution notices from the Source form of the Work,
125
+ excluding those notices that do not pertain to any part of
126
+ the Derivative Works; and
127
+
128
+ (d) If the Work includes a "NOTICE" text file as part of its
129
+ distribution, then any Derivative Works that You distribute must
130
+ include a readable copy of the attribution notices contained
131
+ within such NOTICE file, excluding those notices that do not
132
+ pertain to any part of the Derivative Works, in at least one
133
+ of the following places: within a NOTICE text file distributed
134
+ as part of the Derivative Works; within the Source form or
135
+ documentation, if provided along with the Derivative Works; or,
136
+ within a display generated by the Derivative Works, if and
137
+ wherever such third-party notices normally appear. The contents
138
+ of the NOTICE file are for informational purposes only and
139
+ do not modify the License. You may add Your own attribution
140
+ notices within Derivative Works that You distribute, alongside
141
+ or as an addendum to the NOTICE text from the Work, provided
142
+ that such additional attribution notices cannot be construed
143
+ as modifying the License.
144
+
145
+ You may add Your own copyright statement to Your modifications and
146
+ may provide additional or different license terms and conditions
147
+ for use, reproduction, or distribution of Your modifications, or
148
+ for any such Derivative Works as a whole, provided Your use,
149
+ reproduction, and distribution of the Work otherwise complies with
150
+ the conditions stated in this License.
151
+
152
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
153
+ any Contribution intentionally submitted for inclusion in the Work
154
+ by You to the Licensor shall be under the terms and conditions of
155
+ this License, without any additional terms or conditions.
156
+ Notwithstanding the above, nothing herein shall supersede or modify
157
+ the terms of any separate license agreement you may have executed
158
+ with Licensor regarding such Contributions.
159
+
160
+ 6. Trademarks. This License does not grant permission to use the trade
161
+ names, trademarks, service marks, or product names of the Licensor,
162
+ except as required for reasonable and customary use in describing the
163
+ origin of the Work and reproducing the content of the NOTICE file.
164
+
165
+ 7. Disclaimer of Warranty. Unless required by applicable law or
166
+ agreed to in writing, Licensor provides the Work (and each
167
+ Contributor provides its Contributions) on an "AS IS" BASIS,
168
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
169
+ implied, including, without limitation, any warranties or conditions
170
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
171
+ PARTICULAR PURPOSE. You are solely responsible for determining the
172
+ appropriateness of using or redistributing the Work and assume any
173
+ risks associated with Your exercise of permissions under this License.
174
+
175
+ 8. Limitation of Liability. In no event and under no legal theory,
176
+ whether in tort (including negligence), contract, or otherwise,
177
+ unless required by applicable law (such as deliberate and grossly
178
+ negligent acts) or agreed to in writing, shall any Contributor be
179
+ liable to You for damages, including any direct, indirect, special,
180
+ incidental, or consequential damages of any character arising as a
181
+ result of this License or out of the use or inability to use the
182
+ Work (including but not limited to damages for loss of goodwill,
183
+ work stoppage, computer failure or malfunction, or any and all
184
+ other commercial damages or losses), even if such Contributor
185
+ has been advised of the possibility of such damages.
186
+
187
+ 9. Accepting Warranty or Additional Liability. While redistributing
188
+ the Work or Derivative Works thereof, You may choose to offer,
189
+ and charge a fee for, acceptance of support, warranty, indemnity,
190
+ or other liability obligations and/or rights consistent with this
191
+ License. However, in accepting such obligations, You may act only
192
+ on Your own behalf and on Your sole responsibility, not on behalf
193
+ of any other Contributor, and only if You agree to indemnify,
194
+ defend, and hold each Contributor harmless for any liability
195
+ incurred by, or claims asserted against, such Contributor by reason
196
+ of your accepting any such warranty or additional liability.
197
+
198
+ END OF TERMS AND CONDITIONS
199
+
200
+ APPENDIX: How to apply the Apache License to your work.
201
+
202
+ To apply the Apache License to your work, attach the following
203
+ boilerplate notice, with the fields enclosed by brackets "[]"
204
+ replaced with your own identifying information. (Don't include
205
+ the brackets!) The text should be enclosed in the appropriate
206
+ comment syntax for the file format. We also recommend that a
207
+ file or class name and description of purpose be included on the
208
+ same "printed page" as the copyright notice for easier
209
+ identification within third-party archives.
210
+
211
+ Copyright [yyyy] [name of copyright owner]
212
+
213
+ Licensed under the Apache License, Version 2.0 (the "License");
214
+ you may not use this file except in compliance with the License.
215
+ You may obtain a copy of the License at
216
+
217
+ http://www.apache.org/licenses/LICENSE-2.0
218
+
219
+ Unless required by applicable law or agreed to in writing, software
220
+ distributed under the License is distributed on an "AS IS" BASIS,
221
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
222
+ See the License for the specific language governing permissions and
223
+ limitations under the License.
224
+ ```
@@ -3,4 +3,4 @@ import { type ScanEnv } from "./scan/env.ts";
3
3
  import { type Serially } from "./write.ts";
4
4
  export declare function previewAgentEdit(env: ScanEnv, edit: AgentEdit): Promise<SettingsEditPreview>;
5
5
  /** Writes or deletes an agent file, backed up first, only while it is as reviewed. */
6
- export declare function saveAgentEdit(env: ScanEnv, edit: AgentEdit, expectedRevision: string, queue?: Serially): Promise<Change>;
6
+ export declare function saveAgentEdit(env: ScanEnv, edit: AgentEdit, expectedRevision: string, queue: Serially): Promise<Change>;
@@ -6,7 +6,7 @@ import { gitRoot } from "./scan/git.js";
6
6
  import { shownText } from "./secrets.js";
7
7
  import { scanDirectory } from "./scan/index.js";
8
8
  import { agentProblems } from "./scan/inventory.js";
9
- import { RefusedError, readIfExists, recordChange, removeExactly, StaleError, saveReviewed, serially, writeAtomic, } from "./write.js";
9
+ import { RefusedError, readIfExists, recordChange, removeExactly, StaleError, saveReviewed, writeAtomic, } from "./write.js";
10
10
  /** The file an edit changes: an agent the scan shows here, or a new one in your or the project's folder. */
11
11
  async function targetOf(env, edit) {
12
12
  const dir = resolve(edit.dir);
@@ -71,6 +71,6 @@ export async function previewAgentEdit(env, edit) {
71
71
  return (await plan(env, edit)).preview;
72
72
  }
73
73
  /** Writes or deletes an agent file, backed up first, only while it is as reviewed. */
74
- export function saveAgentEdit(env, edit, expectedRevision, queue = serially) {
74
+ export function saveAgentEdit(env, edit, expectedRevision, queue) {
75
75
  return saveReviewed(queue, () => plan(env, edit), expectedRevision, "The agent changed since you reviewed this; review it again.");
76
76
  }
@@ -14,6 +14,6 @@ export declare function previewRestore(env: ScanEnv, id: string): Promise<Restor
14
14
  * Puts a backed-up file back, or removes a file ccdesk created, if the file is still as it was
15
15
  * when the restore was reviewed. A removed file is backed up first, so it can be put back too.
16
16
  */
17
- export declare function restoreBackup(env: ScanEnv, id: string, expectedRevision: string, queue?: Serially): Promise<{
17
+ export declare function restoreBackup(env: ScanEnv, id: string, expectedRevision: string, queue: Serially): Promise<{
18
18
  target: string;
19
19
  }>;
@@ -3,17 +3,27 @@ import { basename, dirname, join } from "node:path";
3
3
  import { Compile } from "typebox/compile";
4
4
  import {} from "../shared/types.js";
5
5
  import { assertMemoryDir, indexPathIn, revisionOfBoth } from "./mutations.js";
6
+ import { parseJson } from "./scan/data.js";
6
7
  import {} from "./scan/env.js";
7
8
  import { isWithin, revisionOf } from "./scan/files.js";
8
9
  import { hiddenValues, shown, shownText } from "./secrets.js";
9
- import { BackupManifestSchema, backupRoot, forgetChange, MANIFEST, RefusedError, readIfExists, recordChange, removeExactly, SHOWN_AFTER, SNAPSHOT, StaleError, serially, writeAtomic, } from "./write.js";
10
+ import { BackupManifestSchema, backupRoot, forgetChange, MANIFEST, RefusedError, readIfExists, recordChange, removeExactly, SHOWN_AFTER, SNAPSHOT, StaleError, writeAtomic, } from "./write.js";
10
11
  const backupManifest = Compile(BackupManifestSchema);
11
12
  /** A backup folder's manifest; anything that does not look like one ccdesk wrote is skipped. */
12
13
  async function readManifest(env, id) {
13
14
  // ccdesk's ids are letters, digits and dashes, so no id can name a folder outside the root.
14
15
  if (!/^[\w-]+$/.test(id))
15
16
  return null;
16
- const text = await readIfExists(env, join(backupRoot(env), id, MANIFEST)).catch(() => null);
17
+ let text;
18
+ try {
19
+ text = await readIfExists(env, join(backupRoot(env), id, MANIFEST));
20
+ }
21
+ catch (error) {
22
+ // A stray file in the backup folder is not a backup; a folder ccdesk cannot read is an error.
23
+ if (error.code === "ENOTDIR")
24
+ return null;
25
+ throw error;
26
+ }
17
27
  if (text === null)
18
28
  return null;
19
29
  let data;
@@ -25,9 +35,23 @@ async function readManifest(env, id) {
25
35
  }
26
36
  return backupManifest.Check(data) ? data : null;
27
37
  }
38
+ /**
39
+ * Backup folder names, newest first. No folder yet means no changes; one ccdesk cannot read, such
40
+ * as one a `sudo ccdesk` left owned by root, is an error rather than an empty list.
41
+ */
42
+ async function backupIds(env) {
43
+ try {
44
+ return (await readdir(backupRoot(env))).sort().reverse();
45
+ }
46
+ catch (error) {
47
+ if (error.code === "ENOENT")
48
+ return [];
49
+ throw error;
50
+ }
51
+ }
28
52
  /** The changes ccdesk made, newest first, a page at a time. */
29
53
  export async function listBackups(env, { before, limit }) {
30
- const ids = (await readdir(backupRoot(env)).catch(() => [])).sort().reverse();
54
+ const ids = await backupIds(env);
31
55
  const changes = [];
32
56
  for (const id of ids) {
33
57
  if (before !== undefined && id >= before)
@@ -69,7 +93,7 @@ function shownSettings(text) {
69
93
  if (text === null)
70
94
  return null;
71
95
  try {
72
- return shown(JSON.parse(text));
96
+ return shown(parseJson(text));
73
97
  }
74
98
  catch {
75
99
  return "(not valid JSON; open the file to see it)\n";
@@ -239,7 +263,7 @@ export async function previewRestore(env, id) {
239
263
  * Puts a backed-up file back, or removes a file ccdesk created, if the file is still as it was
240
264
  * when the restore was reviewed. A removed file is backed up first, so it can be put back too.
241
265
  */
242
- export function restoreBackup(env, id, expectedRevision, queue = serially) {
266
+ export function restoreBackup(env, id, expectedRevision, queue) {
243
267
  return queue(async () => {
244
268
  const plan = await planRestore(env, id);
245
269
  const { manifest, current, saved, index } = plan;
@@ -4,16 +4,16 @@ export { compareSettings } from "./scan/compare.ts";
4
4
  export { revisionOf } from "./scan/files.ts";
5
5
  export { scanDirectory, scanOverview } from "./scan/index.ts";
6
6
  export { testPath } from "./scan/path-test.ts";
7
- export { CountStopped, readUsage } from "./scan/usage.ts";
7
+ export { CountStopped } from "./scan/usage.ts";
8
8
  export { hasHiddenValues, redactSecrets, shown, shownText } from "./secrets.ts";
9
9
  export { Watcher } from "./watch.ts";
10
- export { previewAgentEdit, saveAgentEdit } from "./agent-edit.ts";
11
- export { claudeProgram, claudeRunner, previewMcpEdit, type RunClaude, runClaude, saveMcpEdit, } from "./mcp-edit.ts";
12
- export { changeMemory, isMemoryAction, previewMemoryChange } from "./mutations.ts";
10
+ export { previewAgentEdit } from "./agent-edit.ts";
11
+ export { claudeProgram, claudeRunner, previewMcpEdit, type RunClaude } from "./mcp-edit.ts";
12
+ export { isMemoryAction, previewMemoryChange } from "./mutations.ts";
13
13
  export { InvalidEditError, parseAgentEdit, parseHookEdit, parseMcpEdit, parsePermissionEdit, parseSettingsEdit, } from "./parse-edit.ts";
14
- export { previewHookEdit, previewPermissionEdit, previewSettingsEdit, saveHookEdit, savePermissionEdit, saveSettingsEdit, } from "./settings-edit.ts";
14
+ export { previewHookEdit, previewPermissionEdit, previewSettingsEdit } from "./settings-edit.ts";
15
15
  export { RefusedError, StaleError } from "./write.ts";
16
- export { listBackups, previewRestore, restoreBackup } from "./backups.ts";
16
+ export { listBackups, previewRestore } from "./backups.ts";
17
17
  export { openInEditor } from "./open.ts";
18
18
  export { REFERENCE } from "./reference.ts";
19
19
  export * from "../shared/compare.ts";
@@ -1,32 +1,32 @@
1
1
  // The core: everything a front end needs to read and change Claude Code's configuration, without
2
2
  // HTTP. It re-exports the modules in src/core and src/shared; see ARCHITECTURE.md for how they
3
3
  // fit together and docs/split-plan.md for where they are going.
4
- // The core for one machine: createCore(env) returns the reads and changes below with the env
5
- // already passed, its own change queue and usage cache, and the editor and claude its env names.
4
+ // The core for one machine: createCore(env) returns every read and change with the env already
5
+ // passed, its own change queue and usage cache, and the editor and claude its env names. Changes,
6
+ // usage counts and undo are made only through a core, so they run on its queue and cache.
6
7
  export { createCore } from "./core.js";
7
- // Environment: every function below takes the ScanEnv first. Called directly, they share one
8
- // change queue and one usage cache across the process; they stay for one release beside createCore.
8
+ // Environment: every function below takes the ScanEnv first.
9
9
  export { isConfigHome, scanEnvFromProcess } from "./scan/env.js";
10
10
  // Read.
11
11
  export { compareSettings } from "./scan/compare.js";
12
12
  export { revisionOf } from "./scan/files.js";
13
13
  export { scanDirectory, scanOverview } from "./scan/index.js";
14
14
  export { testPath } from "./scan/path-test.js";
15
- export { CountStopped, readUsage } from "./scan/usage.js";
15
+ export { CountStopped } from "./scan/usage.js";
16
16
  export { hasHiddenValues, redactSecrets, shown, shownText } from "./secrets.js";
17
17
  export { Watcher } from "./watch.js";
18
18
  // Edits: the parse functions turn input from outside (JSON, arguments) into an edit, or throw
19
- // InvalidEditError. Preview returns a revision, save takes it back. Both refuse with RefusedError,
20
- // also when the file changed since the preview; StaleError, a RefusedError, means it changed while
21
- // ccdesk was writing it.
22
- export { previewAgentEdit, saveAgentEdit } from "./agent-edit.js";
23
- export { claudeProgram, claudeRunner, previewMcpEdit, runClaude, saveMcpEdit, } from "./mcp-edit.js";
24
- export { changeMemory, isMemoryAction, previewMemoryChange } from "./mutations.js";
19
+ // InvalidEditError. Preview returns a revision, and a core's save takes it back. Both refuse with
20
+ // RefusedError, also when the file changed since the preview; StaleError, a RefusedError, means it
21
+ // changed while ccdesk was writing it.
22
+ export { previewAgentEdit } from "./agent-edit.js";
23
+ export { claudeProgram, claudeRunner, previewMcpEdit } from "./mcp-edit.js";
24
+ export { isMemoryAction, previewMemoryChange } from "./mutations.js";
25
25
  export { InvalidEditError, parseAgentEdit, parseHookEdit, parseMcpEdit, parsePermissionEdit, parseSettingsEdit, } from "./parse-edit.js";
26
- export { previewHookEdit, previewPermissionEdit, previewSettingsEdit, saveHookEdit, savePermissionEdit, saveSettingsEdit, } from "./settings-edit.js";
26
+ export { previewHookEdit, previewPermissionEdit, previewSettingsEdit } from "./settings-edit.js";
27
27
  export { RefusedError, StaleError } from "./write.js";
28
- // History: every change ccdesk saves is a backup that can be restored by its id.
29
- export { listBackups, previewRestore, restoreBackup } from "./backups.js";
28
+ // History: every change ccdesk saves is a backup that a core can restore by its id.
29
+ export { listBackups, previewRestore } from "./backups.js";
30
30
  // Host.
31
31
  export { openInEditor } from "./open.js";
32
32
  // Claude Code's settings schema, settings catalog and hook events.
@@ -16,10 +16,8 @@ export type RunClaude = (args: string[], cwd: string, configDir: string | undefi
16
16
  export declare function claudeProgram(path: string, platform: NodeJS.Platform): Promise<string>;
17
17
  /** Runs the claude on `host`'s PATH, with `host`'s environment. */
18
18
  export declare function claudeRunner(host: Pick<ScanEnv, "platform" | "processEnv">): RunClaude;
19
- /** claudeRunner for this process's PATH and environment, read on each run; use a core's instead. */
20
- export declare const runClaude: RunClaude;
21
19
  export declare function previewMcpEdit(env: ScanEnv, edit: McpEdit, run: RunClaude): Promise<SettingsEditPreview>;
22
20
  /** Makes a reviewed MCP edit, only while the servers are still as reviewed. */
23
- export declare function saveMcpEdit(env: ScanEnv, edit: McpEdit, expectedRevision: string, run: RunClaude, queue?: Serially): Promise<Change | {
21
+ export declare function saveMcpEdit(env: ScanEnv, edit: McpEdit, expectedRevision: string, run: RunClaude, queue: Serially): Promise<Change | {
24
22
  target: string;
25
23
  }>;
@@ -4,11 +4,11 @@ import { delimiter, join, resolve } from "node:path";
4
4
  import {} from "../shared/types.js";
5
5
  import {} from "./scan/env.js";
6
6
  import { revisionOf } from "./scan/files.js";
7
- import { isRecord } from "./scan/data.js";
8
- import { gitRoot, mainWorktreeRoot, trustKey } from "./scan/git.js";
7
+ import { isRecord, parseJson } from "./scan/data.js";
8
+ import { claudeJsonKey, gitRoot, mainWorktreeRoot, trustKey } from "./scan/git.js";
9
9
  import { serverProblems } from "./scan/mcp.js";
10
10
  import { hasHiddenValues, jsonSyntaxError, redactSecrets, secretTexts, shown } from "./secrets.js";
11
- import { RefusedError, readIfExists, readJsonObject, recordChange, recordClaudeMcpChange, saveReviewed, serially, writeAtomic, } from "./write.js";
11
+ import { RefusedError, readIfExists, readJsonObject, recordChange, recordClaudeMcpChange, saveReviewed, writeAtomic, } from "./write.js";
12
12
  const exists = (path) => access(path).then(() => true, () => false);
13
13
  /**
14
14
  * The program to run for `claude`. On Windows, npm installs Claude Code as a claude.cmd that starts
@@ -46,6 +46,14 @@ function secretsIn(args) {
46
46
  }
47
47
  });
48
48
  }
49
+ /**
50
+ * Why claude did not start. On Windows a claude.cmd that npm did not install, such as Scoop's,
51
+ * Volta's or pnpm's, is on PATH but cannot be run without a shell, so "not on PATH" would mislead.
52
+ */
53
+ const CLAUDE_NOT_FOUND = {
54
+ win32: "ccdesk changes your user and local MCP servers through the claude command and could not start it from PATH. On Windows it runs claude.exe, or the claude.exe inside npm's package when only npm's claude.cmd is there; another installer's claude.cmd or claude.ps1 cannot be started without a shell.",
55
+ other: "ccdesk changes your user and local MCP servers through the claude command, which is not on PATH.",
56
+ };
49
57
  /** Runs the claude on `host`'s PATH, with `host`'s environment. */
50
58
  export function claudeRunner(host) {
51
59
  return async (args, cwd, configDir) => {
@@ -57,7 +65,7 @@ export function claudeRunner(host) {
57
65
  return new Promise((done, fail) => {
58
66
  execFile(program, args, { cwd, env, timeout: 30_000 }, (error, stdout, stderr) => {
59
67
  if (error?.code === "ENOENT")
60
- return fail(new RefusedError("ccdesk changes your user and local MCP servers through the claude command, which is not on PATH."));
68
+ return fail(new RefusedError(CLAUDE_NOT_FOUND[host.platform === "win32" ? "win32" : "other"]));
61
69
  // Node's own message repeats the command, with the server's env and header values in it.
62
70
  if (error) {
63
71
  // claude's own message may quote the definition it was given.
@@ -71,10 +79,6 @@ export function claudeRunner(host) {
71
79
  });
72
80
  };
73
81
  }
74
- /** claudeRunner for this process's PATH and environment, read on each run; use a core's instead. */
75
- export const runClaude = (args, cwd, configDir) =>
76
- // biome-ignore lint/style/noProcessEnv: the documented default of the free runClaude; a core passes its own.
77
- claudeRunner({ platform: process.platform, processEnv: process.env })(args, cwd, configDir);
78
82
  /** Quotes a word for a POSIX shell, so a command shown to you can be pasted as it is. */
79
83
  function quoted(word) {
80
84
  return `'${word.replaceAll("'", "'\\''")}'`;
@@ -152,7 +156,7 @@ async function claudeJsonServers(env, edit) {
152
156
  const raw = await readIfExists(env, env.claudeJson);
153
157
  let data = {};
154
158
  try {
155
- const parsed = raw === null ? {} : JSON.parse(raw);
159
+ const parsed = raw === null ? {} : parseJson(raw);
156
160
  if (isRecord(parsed))
157
161
  data = parsed;
158
162
  }
@@ -166,7 +170,7 @@ async function claudeJsonServers(env, edit) {
166
170
  if (!(await stat(cwd).catch(() => null))?.isDirectory())
167
171
  throw new RefusedError(`${cwd} is not a directory on this machine.`);
168
172
  const projects = isRecord(data.projects) ? data.projects : {};
169
- const holder = edit.scope === "user" ? data : projects[cwd];
173
+ const holder = edit.scope === "user" ? data : projects[claudeJsonKey(env, cwd)];
170
174
  const servers = isRecord(holder) && isRecord(holder.mcpServers) ? holder.mcpServers : {};
171
175
  return { cwd, servers };
172
176
  }
@@ -279,6 +283,6 @@ export async function previewMcpEdit(env, edit, run) {
279
283
  return (await plan(env, edit, run)).preview;
280
284
  }
281
285
  /** Makes a reviewed MCP edit, only while the servers are still as reviewed. */
282
- export function saveMcpEdit(env, edit, expectedRevision, run, queue = serially) {
286
+ export function saveMcpEdit(env, edit, expectedRevision, run, queue) {
283
287
  return saveReviewed(queue, () => plan(env, edit, run), expectedRevision, "The servers changed since you reviewed this edit; review it again.");
284
288
  }
@@ -17,4 +17,4 @@ export declare function previewMemoryChange(env: ScanEnv, action: MemoryAction,
17
17
  * Makes a reviewed memory action. `path` is the memory file, or MEMORY.md for remove-dead; the
18
18
  * action runs only while everything its review was worked out from is unchanged.
19
19
  */
20
- export declare function changeMemory(env: ScanEnv, action: MemoryAction, path: string, expectedRevision: string, queue?: Serially): Promise<Change>;
20
+ export declare function changeMemory(env: ScanEnv, action: MemoryAction, path: string, expectedRevision: string, queue: Serially): Promise<Change>;
@@ -6,7 +6,7 @@ import { isWithin, revisionOf, stringField } from "./scan/files.js";
6
6
  import { parseFrontmatter } from "./scan/data.js";
7
7
  import { shownText } from "./secrets.js";
8
8
  import { deadLinks, indexMentions } from "./scan/memory.js";
9
- import { RefusedError, readIfExists, recordChange, removeExactly, saveReviewed, serially, writeAtomic, } from "./write.js";
9
+ import { RefusedError, readIfExists, recordChange, removeExactly, saveReviewed, writeAtomic, } from "./write.js";
10
10
  async function projectsRoot(env) {
11
11
  return realpath(join(env.claudeDir, "projects")).catch(() => {
12
12
  throw new RefusedError("There is no auto memory folder.");
@@ -181,6 +181,6 @@ export async function previewMemoryChange(env, action, path) {
181
181
  * Makes a reviewed memory action. `path` is the memory file, or MEMORY.md for remove-dead; the
182
182
  * action runs only while everything its review was worked out from is unchanged.
183
183
  */
184
- export function changeMemory(env, action, path, expectedRevision, queue = serially) {
184
+ export function changeMemory(env, action, path, expectedRevision, queue) {
185
185
  return saveReviewed(queue, () => PLANS[action](env, path), expectedRevision, REVIEW_AGAIN);
186
186
  }
@@ -23,9 +23,6 @@ export declare function spawnPlan(command: string, args: string[], path: string,
23
23
  * failed. On Windows `start` is a cmd.exe builtin, so cmd.exe is the command.
24
24
  */
25
25
  export declare function openBrowser(url: string, host: Host): Promise<string | null>;
26
- /**
27
- * Opens a file or folder in the first editor that starts on `host`; resolves with the command
28
- * used. Without `host` it uses this process's platform and environment; use a core's instead.
29
- */
30
- export declare function openInEditor(path: string, host?: Host): Promise<string>;
26
+ /** Opens a file or folder in the first editor that starts on `host`; resolves with the command used. */
27
+ export declare function openInEditor(path: string, host: Host): Promise<string>;
31
28
  export {};
package/dist/core/open.js CHANGED
@@ -121,7 +121,10 @@ function launch([command, args], path, host) {
121
121
  });
122
122
  child.once("exit", (code) => {
123
123
  clearTimeout(timer);
124
- resolve(code === 0 ? null : `${command} exited with code ${code}`);
124
+ // explorer.exe hands the file to the running shell and exits with 1 even when that worked.
125
+ if (code === 0 || command === "explorer")
126
+ return resolve(null);
127
+ resolve(`${command} exited with code ${code}`);
125
128
  });
126
129
  });
127
130
  }
@@ -148,13 +151,8 @@ function browserOpener(platform) {
148
151
  return ["cmd.exe", ["/c", "start", ""]];
149
152
  return ["xdg-open", []];
150
153
  }
151
- /**
152
- * Opens a file or folder in the first editor that starts on `host`; resolves with the command
153
- * used. Without `host` it uses this process's platform and environment; use a core's instead.
154
- */
155
- export async function openInEditor(path,
156
- // biome-ignore lint/style/noProcessEnv: the documented default of the free openInEditor; a core passes its own.
157
- host = { platform: process.platform, processEnv: process.env }) {
154
+ /** Opens a file or folder in the first editor that starts on `host`; resolves with the command used. */
155
+ export async function openInEditor(path, host) {
158
156
  const failures = [];
159
157
  for (const command of editorCommands(host.processEnv, host.platform)) {
160
158
  const failure = await launch(command, path, host);
@@ -3,6 +3,12 @@ interface Frontmatter {
3
3
  data: Record<string, unknown>;
4
4
  body: string;
5
5
  }
6
+ /**
7
+ * JSON.parse after dropping a leading byte order mark, as Claude Code does before it parses a
8
+ * settings, MCP or state file (observed in v2.1.296 and the SDK's safeParseJSON; the docs do not
9
+ * say). Windows PowerShell 5.1 and some editors write one.
10
+ */
11
+ export declare function parseJson(text: string): unknown;
6
12
  export declare const FRONTMATTER: RegExp;
7
13
  export declare function parseFrontmatter(text: string): Frontmatter;
8
14
  export {};