@yeison.restrepo.r/code-conductor 1.23.2 → 1.24.1
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 -185
- package/README.md +56 -8
- package/bin/code-conductor.mjs +2 -1
- package/global/CLAUDE.md +2 -0
- package/global/commands/cc-checkpoint.md +5 -5
- package/global/commands/cc-compact.md +5 -5
- package/lib/installer/deploy.mjs +102 -9
- package/lib/installer/file-merge.mjs +87 -0
- package/lib/installer/merge-md.mjs +168 -0
- package/lib/installer/settings.mjs +19 -8
- package/package.json +1 -1
- package/project-template/.claude/commands/cc-implement.md +4 -4
- package/project-template/.claude/commands/cc-plan.md +3 -3
- package/project-template/.claude/commands/cc-spec.md +3 -3
- package/project-template/CLAUDE.md +2 -0
- package/project-template/gitignore +3 -0
- package/scripts/conductor-db.mjs +6 -3
- package/scripts/resume-read.mjs +5 -2
- package/scripts/session-id.mjs +5 -2
- package/skills/{code-simplifier.md → code-simplifier/SKILL.md} +6 -0
- package/skills/{verbosity.md → verbosity/SKILL.md} +6 -0
- /package/skills/{agent-delegation.md → agent-delegation/SKILL.md} +0 -0
- /package/skills/{critical-review.md → critical-review/SKILL.md} +0 -0
- /package/skills/{memory-first.md → memory-first/SKILL.md} +0 -0
package/LICENSE
CHANGED
|
@@ -1,185 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
-
exercising permissions granted by this License.
|
|
25
|
-
|
|
26
|
-
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
-
including but not limited to software source code, documentation
|
|
28
|
-
source, and configuration files.
|
|
29
|
-
|
|
30
|
-
"Object" form shall mean any form resulting from mechanical
|
|
31
|
-
transformation or translation of a Source form, including but
|
|
32
|
-
not limited to compiled object code, generated documentation,
|
|
33
|
-
and conversions to other media types.
|
|
34
|
-
|
|
35
|
-
"Work" shall mean the work of authorship made available under
|
|
36
|
-
the License, as indicated by a copyright notice that is included in
|
|
37
|
-
or attached to the work (an example is provided in the Appendix below).
|
|
38
|
-
|
|
39
|
-
"Derivative Works" shall mean any work, whether in Source or Object
|
|
40
|
-
form, that is based on (or derived from) the Work and for which the
|
|
41
|
-
editorial revisions, annotations, elaborations, or other modifications
|
|
42
|
-
represent, as a whole, an original work of authorship. For the purposes
|
|
43
|
-
of this License, Derivative Works shall not include works that remain
|
|
44
|
-
separable from, or merely link (or bind by name) to the interfaces of,
|
|
45
|
-
the Work and derivative works thereof.
|
|
46
|
-
|
|
47
|
-
"Contribution" shall mean, as submitted to the Licensor for inclusion
|
|
48
|
-
in the Work by the copyright owner or by an individual or Legal Entity
|
|
49
|
-
authorized to submit on behalf of the copyright owner. For the purposes
|
|
50
|
-
of this definition, "submitted" means any form of electronic, verbal,
|
|
51
|
-
or written communication sent to the Licensor or its representatives,
|
|
52
|
-
including but not limited to communication on electronic mailing lists,
|
|
53
|
-
source code control systems, and issue tracking systems that are managed
|
|
54
|
-
by, or on behalf of, the Licensor for the purpose of discussing and
|
|
55
|
-
improving the Work, but excluding communication that is conspicuously
|
|
56
|
-
marked or otherwise designated in writing by the copyright owner as
|
|
57
|
-
"Not a Contribution."
|
|
58
|
-
|
|
59
|
-
"Contributor" shall mean Licensor and any Legal Entity on behalf of
|
|
60
|
-
whom a Contribution has been received by the Licensor and subsequently
|
|
61
|
-
incorporated within the Work.
|
|
62
|
-
|
|
63
|
-
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
64
|
-
this License, each Contributor hereby grants to You a perpetual,
|
|
65
|
-
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
66
|
-
copyright license to reproduce, prepare Derivative Works of,
|
|
67
|
-
publicly display, publicly perform, sublicense, and distribute the
|
|
68
|
-
Work and such Derivative Works in Source or Object form.
|
|
69
|
-
|
|
70
|
-
3. Grant of Patent License. Subject to the terms and conditions of
|
|
71
|
-
this License, each Contributor hereby grants to You a perpetual,
|
|
72
|
-
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
73
|
-
(except as stated in this section) patent license to make, have made,
|
|
74
|
-
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
75
|
-
where such license applies only to those patent claims licensable
|
|
76
|
-
by such Contributor that are necessarily infringed by their
|
|
77
|
-
Contribution(s) alone or by combination of their Contributions
|
|
78
|
-
with the Work to which such Contributions were submitted. If You
|
|
79
|
-
institute patent litigation against any entity (including a cross-claim
|
|
80
|
-
or counterclaim in a lawsuit) alleging that the Work or any
|
|
81
|
-
Contribution incorporated within the Work constitutes direct or
|
|
82
|
-
contributory patent infringement, then any patent licenses granted
|
|
83
|
-
to You under this License for that Work shall terminate as of the
|
|
84
|
-
date such litigation is filed.
|
|
85
|
-
|
|
86
|
-
4. Redistribution. You may reproduce and distribute copies of the
|
|
87
|
-
Work or Derivative Works thereof in any medium, with or without
|
|
88
|
-
modifications, and in Source or Object form, provided that You
|
|
89
|
-
meet the following conditions:
|
|
90
|
-
|
|
91
|
-
(a) You must give any other recipients of the Work or Derivative
|
|
92
|
-
Works a copy of this License; and
|
|
93
|
-
|
|
94
|
-
(b) You must cause any modified files to carry prominent notices
|
|
95
|
-
stating that You changed the files; and
|
|
96
|
-
|
|
97
|
-
(c) You must retain, in the Source form of any Derivative Works
|
|
98
|
-
that You distribute, all copyright, patent, trademark, and
|
|
99
|
-
attribution notices from the Source form of the Work,
|
|
100
|
-
excluding those notices that do not pertain to any part of
|
|
101
|
-
the Derivative Works; and
|
|
102
|
-
|
|
103
|
-
(d) If the Work includes a "NOTICE" text file as part of its
|
|
104
|
-
distribution, You must include a readable copy of the
|
|
105
|
-
attribution notices contained within such NOTICE file, in
|
|
106
|
-
at least one of the following places: within a NOTICE text
|
|
107
|
-
file distributed as part of the Derivative Works; within
|
|
108
|
-
the Source form or documentation, if provided along with the
|
|
109
|
-
Derivative Works; or, within a display generated by the
|
|
110
|
-
Derivative Works, if and wherever such third-party notices
|
|
111
|
-
normally appear. The contents of the NOTICE file are for
|
|
112
|
-
informational purposes only and do not modify the License.
|
|
113
|
-
You may add Your own attribution notices within Derivative
|
|
114
|
-
Works that You distribute, alongside or as an additional
|
|
115
|
-
addendum to the NOTICE text from the Work, provided that
|
|
116
|
-
such additional attribution notices cannot be construed
|
|
117
|
-
as modifying the License.
|
|
118
|
-
|
|
119
|
-
You may add Your own license statement for Your modifications and
|
|
120
|
-
may provide additional grant of rights to use, copy, modify, merge,
|
|
121
|
-
publish, distribute, sublicense, and/or sell copies of the
|
|
122
|
-
Derivative Works, and to permit persons to whom the Derivative Works
|
|
123
|
-
are furnished to do so.
|
|
124
|
-
|
|
125
|
-
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
126
|
-
any Contribution intentionally submitted for inclusion in the Work
|
|
127
|
-
by You to the Licensor shall be under the terms and conditions of
|
|
128
|
-
this License, without any additional terms or conditions.
|
|
129
|
-
Notwithstanding the above, nothing herein shall supersede or modify
|
|
130
|
-
the terms of any separate license agreement you may have executed
|
|
131
|
-
with Licensor regarding such Contributions.
|
|
132
|
-
|
|
133
|
-
6. Trademarks. This License does not grant permission to use the trade
|
|
134
|
-
names, trademarks, service marks, or product names of the Licensor,
|
|
135
|
-
except as required for reasonable and customary use in describing the
|
|
136
|
-
origin of the Work and reproducing the content of the NOTICE file.
|
|
137
|
-
|
|
138
|
-
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
139
|
-
agreed to in writing, Licensor provides the Work (and each
|
|
140
|
-
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
141
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
142
|
-
implied, including, without limitation, any conditions of title,
|
|
143
|
-
merchantability, or fitness for a particular purpose. You are
|
|
144
|
-
solely responsible for determining the appropriateness of using
|
|
145
|
-
or redistributing the Work and assume any risks associated with
|
|
146
|
-
Your exercise of permissions under this License.
|
|
147
|
-
|
|
148
|
-
8. Limitation of Liability. In no event and under no legal theory,
|
|
149
|
-
whether in tort (including negligence), contract, or otherwise,
|
|
150
|
-
unless required by applicable law (such as deliberate and grossly
|
|
151
|
-
negligent acts) or agreed to in writing, shall any Contributor be
|
|
152
|
-
liable to You for damages, including any direct, indirect, special,
|
|
153
|
-
incidental, or exemplary damages of any character arising as a
|
|
154
|
-
result of this License or out of the use or inability to use the
|
|
155
|
-
Work (including but not limited to damages for loss of goodwill,
|
|
156
|
-
work stoppage, computer failure or malfunction, or all other
|
|
157
|
-
commercial damages or losses), even if such Contributor has been
|
|
158
|
-
advised of the possibility of such damages.
|
|
159
|
-
|
|
160
|
-
9. Accepting Warranty or Additional Liability. While redistributing
|
|
161
|
-
the Work or Derivative Works thereof, You may choose to offer,
|
|
162
|
-
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
163
|
-
or other liability obligations and/or rights consistent with this
|
|
164
|
-
License. However, in accepting such obligations, You may act only
|
|
165
|
-
on Your own behalf and on Your sole responsibility, not on behalf
|
|
166
|
-
of any other Contributor, and only if You agree to indemnify,
|
|
167
|
-
defend, and hold each Contributor harmless for any liability
|
|
168
|
-
incurred by, or claims asserted against, such Contributor by reason
|
|
169
|
-
of your accepting any warranty or additional liability.
|
|
170
|
-
|
|
171
|
-
END OF TERMS AND CONDITIONS
|
|
172
|
-
|
|
173
|
-
Copyright 2026 Yeison Restrepo
|
|
174
|
-
|
|
175
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
|
176
|
-
you may not use this file except in compliance with the License.
|
|
177
|
-
You may obtain a copy of the License at
|
|
178
|
-
|
|
179
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
|
180
|
-
|
|
181
|
-
Unless required by applicable law or agreed to in writing, software
|
|
182
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
|
183
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
184
|
-
implied. See the License for the specific language governing
|
|
185
|
-
permissions and limitations under the License.
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2011-2026 The Bootstrap Authors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# code-conductor
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.com/package/@yeison.restrepo.r/code-conductor)
|
|
4
|
-
[](LICENSE)
|
|
4
|
+
[](https://github.com/yeisonrestrepo/code-conductor/blob/main/LICENSE)
|
|
5
5
|
[](https://github.com/yeisonrestrepo/code-conductor/issues)
|
|
6
6
|
|
|
7
7
|
A spec-first, token-efficient Claude Code configuration that turns AI-assisted coding into a disciplined, repeatable engineering workflow.
|
|
@@ -281,6 +281,7 @@ code-conductor/
|
|
|
281
281
|
│ └── personal.md Template (never committed)
|
|
282
282
|
├── project-template/
|
|
283
283
|
│ ├── CLAUDE.md
|
|
284
|
+
│ ├── gitignore Merged into the host project's .gitignore
|
|
284
285
|
│ └── .claude/
|
|
285
286
|
│ ├── settings.json Hooks wiring (pre-tool-use, post-compact)
|
|
286
287
|
│ ├── commands/
|
|
@@ -309,11 +310,12 @@ code-conductor/
|
|
|
309
310
|
│ ├── session-id.mjs Stable session-id resolver
|
|
310
311
|
│ └── detect-stack.mjs Stack auto-detection scanner
|
|
311
312
|
└── skills/
|
|
312
|
-
├── code-simplifier.md
|
|
313
|
-
├── critical-review.md
|
|
314
|
-
├── verbosity.md
|
|
315
|
-
├── memory-first.md
|
|
316
|
-
└── agent-delegation.md
|
|
313
|
+
├── code-simplifier/SKILL.md Always active — complexity and simplicity rules
|
|
314
|
+
├── critical-review/SKILL.md Always active — 4-phase adversarial review protocol
|
|
315
|
+
├── verbosity/SKILL.md Always active — MIN/INFO/VERBOSE response rules
|
|
316
|
+
├── memory-first/SKILL.md Always active — memory → graph → grep → read chain
|
|
317
|
+
└── agent-delegation/SKILL.md Always active — sub-agent spawn rules
|
|
318
|
+
# Claude Code registers personal skills only at ~/.claude/skills/<name>/SKILL.md
|
|
317
319
|
# ui-ux-pro-max installed from github.com/nextlevelbuilder/ui-ux-pro-max-skill
|
|
318
320
|
```
|
|
319
321
|
|
|
@@ -321,7 +323,53 @@ code-conductor/
|
|
|
321
323
|
|
|
322
324
|
## .gitignore Note
|
|
323
325
|
|
|
324
|
-
When installed with `--project`, the installer appends
|
|
326
|
+
When installed with `--project`, the installer appends these rules to your project's
|
|
327
|
+
`.gitignore`, and only the ones you are missing — your own entries are never touched:
|
|
328
|
+
|
|
329
|
+
```
|
|
330
|
+
.claude/memory/turn-count.txt
|
|
331
|
+
*.installer-backup.*
|
|
332
|
+
*.installer-tmp.*
|
|
333
|
+
```
|
|
334
|
+
|
|
335
|
+
The last two keep the installer's own backups and crash-stranded temp files out of
|
|
336
|
+
`git status`. The rules ship inside the package as `project-template/gitignore`
|
|
337
|
+
(no leading dot) because npm strips any file literally named `.gitignore` from every
|
|
338
|
+
published tarball; the installer restores the dot when it writes to your project.
|
|
339
|
+
|
|
340
|
+
---
|
|
341
|
+
|
|
342
|
+
## How the installer treats your CLAUDE.md
|
|
343
|
+
|
|
344
|
+
`CLAUDE.md` and `.gitignore` are **merged**, never overwritten. Everything else the
|
|
345
|
+
installer ships (`settings.json`, hooks, commands, `scripts/`) is replaced on every run.
|
|
346
|
+
|
|
347
|
+
- **Managed sections** live between `<!-- cc:managed:start -->` and `<!-- cc:managed:end -->`.
|
|
348
|
+
Code Conductor owns that block and replaces its contents wholesale on every upgrade, so
|
|
349
|
+
released improvements reach existing installs. Edits inside the block are lost.
|
|
350
|
+
- **Everything outside the block is yours.** Existing sections are preserved byte-for-byte;
|
|
351
|
+
sections the template has and your file lacks are appended once, immediately above the
|
|
352
|
+
managed block. Sections you wrote that the template has never heard of are never touched.
|
|
353
|
+
- **Before any change, the installer copies your file to
|
|
354
|
+
`CLAUDE.md.installer-backup.<UTC timestamp>`** and keeps the five most recent.
|
|
355
|
+
|
|
356
|
+
> **One-time migration on your first 1.24 install.** If your `CLAUDE.md` predates the
|
|
357
|
+
> sentinel markers and already contains sections that the managed block also defines
|
|
358
|
+
> (`## Agent Identity`, `## Hard Constraints`, …), **those sections are removed** and
|
|
359
|
+
> replaced by the managed block, so you do not end up with two copies of each. This is the
|
|
360
|
+
> only path that discards content you wrote. **Your pre-migration file is preserved in the
|
|
361
|
+
> `.installer-backup.` copy beside it** — diff it after upgrading and move anything you
|
|
362
|
+
> want to keep into a section outside the managed block.
|
|
363
|
+
|
|
364
|
+
> **A cosmetic wart of that same migration, in `~/.claude/CLAUDE.md` only.** The managed
|
|
365
|
+
> block carries the file's intro sentence ("Applies to every project on this machine…"),
|
|
366
|
+
> and your pre-sentinel copy keeps its own above the block, so you will see that one
|
|
367
|
+
> sentence twice after the first upgrade. Delete the copy above the block — it is outside
|
|
368
|
+
> the managed region, so your deletion sticks.
|
|
369
|
+
|
|
370
|
+
If the markers in your file are damaged — a `start` with no `end`, two blocks, an `end`
|
|
371
|
+
before its `start` — the installer prints a warning, leaves the file completely untouched,
|
|
372
|
+
and finishes the rest of the install. Fix the markers and re-run.
|
|
325
373
|
|
|
326
374
|
---
|
|
327
375
|
|
|
@@ -330,4 +378,4 @@ When installed with `--project`, the installer appends `.claude/memory/personal.
|
|
|
330
378
|
> **`git revert` in non-repository environments (CI/CD, Docker, bare installs):**
|
|
331
379
|
> Uninstall steps that use `git checkout <tag>` or `git revert <sha>` require a git working tree. In CI/CD pipelines, Docker containers, or directories that are not git repositories, these commands will fail with `fatal: not a git repository`. This is expected and non-fatal.
|
|
332
380
|
>
|
|
333
|
-
> **In non-repo environments:** manually delete or restore `skills/verbosity.md` and remove the `verbosity-remind` entry from `~/.claude/settings.json`. Hook removal (`rm ~/.claude/hooks/verbosity-remind.sh`) and `settings.json` cleanup work identically in all environments — no git is required.
|
|
381
|
+
> **In non-repo environments:** manually delete or restore `skills/verbosity/SKILL.md` and remove the `verbosity-remind` entry from `~/.claude/settings.json`. Hook removal (`rm ~/.claude/hooks/verbosity-remind.sh`) and `settings.json` cleanup work identically in all environments — no git is required.
|
package/bin/code-conductor.mjs
CHANGED
|
@@ -3,7 +3,7 @@ import { readFileSync, realpathSync } from 'node:fs';
|
|
|
3
3
|
import { join } from 'node:path';
|
|
4
4
|
import { pathToFileURL } from 'node:url';
|
|
5
5
|
import { resolveAssetRoot, resolveHome, nodeMajorAtLeast } from '../lib/installer/env.mjs';
|
|
6
|
-
import { assertAssets, deployGlobal, deployProject, chmodHooks } from '../lib/installer/deploy.mjs';
|
|
6
|
+
import { assertAssets, assertMergeTargets, deployGlobal, deployProject, chmodHooks } from '../lib/installer/deploy.mjs';
|
|
7
7
|
import { verbosityHookCommand, mergeVerbosityHook } from '../lib/installer/settings.mjs';
|
|
8
8
|
import { writeVerbosity, seedMemoryFile, writeVersionFile } from '../lib/installer/config.mjs';
|
|
9
9
|
|
|
@@ -88,6 +88,7 @@ export function run(argv, env = process.env, { cwd = process.cwd(), log } = {})
|
|
|
88
88
|
let writing = false;
|
|
89
89
|
try {
|
|
90
90
|
assertAssets(assetRoot, ['global', 'skills', 'scripts', 'project-template']); // pre-flight
|
|
91
|
+
assertMergeTargets(home, cwd, opts.project); // pre-flight
|
|
91
92
|
writing = true; // copy phase begins
|
|
92
93
|
const claudeDir = deployGlobal(assetRoot, home);
|
|
93
94
|
chmodHooks(claudeDir);
|
package/global/CLAUDE.md
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
# Global Claude Configuration
|
|
2
2
|
|
|
3
|
+
<!-- cc:managed:start -->
|
|
3
4
|
Applies to every project on this machine. Project CLAUDE.md adds project-specific overrides on top.
|
|
4
5
|
|
|
5
6
|
## Workflow
|
|
@@ -91,3 +92,4 @@ Always tag responses:
|
|
|
91
92
|
## Loaded Profiles
|
|
92
93
|
|
|
93
94
|
`/cc-stack` detects your stack dynamically and writes the detected commands and a generated ruleset into the project `CLAUDE.md`. Never apply one language's conventions to another.
|
|
95
|
+
<!-- cc:managed:end -->
|
|
@@ -32,16 +32,16 @@ Run **only after** the `project.md` append succeeded (authoritative). Any failur
|
|
|
32
32
|
|
|
33
33
|
1. Ensure `.conductor/` exists (`mkdir -p .conductor`, best-effort); if that fails, skip the tail.
|
|
34
34
|
2. Derive `c` — the **full-40** `git rev-parse HEAD` (lowercased, `/^[0-9a-f]{7,40}$/`, `"0000000"` fallback on non-zero/timeout/git-absent/format-mismatch; shell `timeout` only if the binary exists).
|
|
35
|
-
3. Resolve the id: `id="$(node scripts/session-id.mjs 2>>.conductor/last-write.log)"`.
|
|
36
|
-
4. Derive `ph` by carry-forward: with a bounded ~5 s outer timeout (only if `timeout` exists; `conductor-db`'s internal 2 s `busy_timeout` bounds real contention otherwise), run `node <probe-flags> scripts/conductor-db.mjs get-session "$id"`; if it prints a row whose `phase` is a non-empty enum member, reuse it. On no row, empty phase, DB unavailable, or timeout, default to `"impl"`.
|
|
35
|
+
3. Resolve the id: `id="$(node .claude/scripts/session-id.mjs 2>>.conductor/last-write.log)"`.
|
|
36
|
+
4. Derive `ph` by carry-forward: with a bounded ~5 s outer timeout (only if `timeout` exists; `conductor-db`'s internal 2 s `busy_timeout` bounds real contention otherwise), run `node <probe-flags> .claude/scripts/conductor-db.mjs get-session "$id"`; if it prints a row whose `phase` is a non-empty enum member, reuse it. On no row, empty phase, DB unavailable, or timeout, default to `"impl"`.
|
|
37
37
|
5. Set `pr` to the **verbatim `## Checkpoint …` section body** just appended to `project.md` (the same in-context string) — so `project.md` and the snapshot's `pr` are byte-identical. `pr` is always non-empty here, so the blob is always **v2**.
|
|
38
38
|
6. Project `d` / `x` from that section (best-effort): match headings `/^#{2,4}[ \t]+(.+?)[ \t]*$/`; normalize the heading text by removing all `*`, `_`, `` ` `` then `.trim()` + lowercase; a heading containing `decision` or `convention` opens a `d` block, one containing `debt`, `workaround`, or `limitation` opens an `x` block. **The `d` set is tested first and wins** (a heading matching both opens one `d` block). The parent `## Checkpoint …` heading matches no keyword, so it opens no block and closes any open one. Within a block, bullet lines `/^[ \t]*[-*][ \t]+(\S.*?)[ \t]*$/` contribute their trimmed capture (line-based; continuation lines ignored — the full text survives in `pr`). If unstructured, `d`/`x` may be empty (valid).
|
|
39
39
|
7. Defaults: `n=[]`, `f=[]`, `s`= the active spec stem or `"none"`.
|
|
40
|
-
8. Build the v2 blob: pipe `{ph, c, s, n, f, d, x, pr}` on **stdin** to `node scripts/snap-build.mjs`; capture its stdout. If it exits non-zero, skip the DB write (fail-open).
|
|
40
|
+
8. Build the v2 blob: pipe `{ph, c, s, n, f, d, x, pr}` on **stdin** to `node .claude/scripts/snap-build.mjs`; capture its stdout. If it exits non-zero, skip the DB write (fail-open).
|
|
41
41
|
9. Write the rows (both argv double-quoted; blob on stdin; all output to the log):
|
|
42
42
|
|
|
43
|
-
`node <probe-flags> scripts/conductor-db.mjs session "$id" "$ph" "$s" "$c" >> .conductor/last-write.log 2>&1`
|
|
44
|
-
`printf '%s' "$snap_json" | node <probe-flags> scripts/conductor-db.mjs snapshot "$c" >> .conductor/last-write.log 2>&1`
|
|
43
|
+
`node <probe-flags> .claude/scripts/conductor-db.mjs session "$id" "$ph" "$s" "$c" >> .conductor/last-write.log 2>&1`
|
|
44
|
+
`printf '%s' "$snap_json" | node <probe-flags> .claude/scripts/conductor-db.mjs snapshot "$c" >> .conductor/last-write.log 2>&1`
|
|
45
45
|
|
|
46
46
|
All DB-tail redirects use **append mode (`>>`)** so concurrent runs never truncate a preceding trace. **Cross-platform note:** the forms above are Unix-canonical; on Windows/PowerShell realize the same semantics — set `$OutputEncoding = [System.Text.UTF8Encoding]::new($false)` before piping, capture `$id = node …`, pipe `$snap_json | node … snapshot "$c"`, append the log via `… 2>&1 | Out-File -Append -Encoding utf8 .conductor/last-write.log` (not `*>>`), and `New-Item -ItemType Directory -Force .conductor`.
|
|
47
47
|
|
|
@@ -15,7 +15,7 @@ Collect from the current conversation context:
|
|
|
15
15
|
|
|
16
16
|
For all four array fields: filter out empty/whitespace-only strings, deduplicate by exact case-sensitive string equality (first occurrence wins), then truncate each surviving element to its per-element cap (Unicode-safe: `Array.from(str).slice(0, cap).join('')`), then if the array still exceeds its cap, drop from the **head** (oldest first) until it fits. Empty arrays are valid and must still be serialized (never omitted).
|
|
17
17
|
|
|
18
|
-
Serialize by piping a flat JSON object `{ph, c, s, n, f, d, x}` (no `pr`) on **stdin** to `node scripts/snap-build.mjs`; its stdout is the canonical single-line **v1** SNAP JSON. `snap-build` performs all array normalization (filter/dedup/per-element cap/head-drop) and the 4096-char size trim internally — do not pre-serialize. If `snap-build` exits non-zero (malformed field object), report the error and stop; do not write the handoff file, do not run the DB tail, do not print the compact prompt.
|
|
18
|
+
Serialize by piping a flat JSON object `{ph, c, s, n, f, d, x}` (no `pr`) on **stdin** to `node .claude/scripts/snap-build.mjs`; its stdout is the canonical single-line **v1** SNAP JSON. `snap-build` performs all array normalization (filter/dedup/per-element cap/head-drop) and the 4096-char size trim internally — do not pre-serialize. If `snap-build` exits non-zero (malformed field object), report the error and stop; do not write the handoff file, do not run the DB tail, do not print the compact prompt.
|
|
19
19
|
|
|
20
20
|
Write the single JSON line, followed by exactly one trailing newline, to `.claude/memory/session-snapshot.json`.
|
|
21
21
|
|
|
@@ -36,14 +36,14 @@ Once the snapshot is written successfully, output exactly:
|
|
|
36
36
|
After the handoff file is written and the compact prompt is ready — and **only** if the authoritative write succeeded — run this synchronous, fail-open tail. Any failure here is non-fatal: never revert the handoff file, never suppress the compact prompt.
|
|
37
37
|
|
|
38
38
|
1. Ensure `.conductor/` exists (`mkdir -p .conductor`, best-effort). If that fails, skip the tail entirely.
|
|
39
|
-
2. Resolve the session id: `id="$(node scripts/session-id.mjs 2>>.conductor/last-write.log)"`.
|
|
39
|
+
2. Resolve the session id: `id="$(node .claude/scripts/session-id.mjs 2>>.conductor/last-write.log)"`.
|
|
40
40
|
3. Upsert the session row (Node-flag probe applies — same as the cc-implement Step 6 hook: no-flag-first, else `--experimental-sqlite --no-warnings`, else skip):
|
|
41
41
|
|
|
42
|
-
`node <probe-flags> scripts/conductor-db.mjs session "$id" "$ph" "$s" "$c" >> .conductor/last-write.log 2>&1`
|
|
42
|
+
`node <probe-flags> .claude/scripts/conductor-db.mjs session "$id" "$ph" "$s" "$c" >> .conductor/last-write.log 2>&1`
|
|
43
43
|
4. Insert the snapshot row, piping the v1 blob on **stdin** (never argv):
|
|
44
44
|
|
|
45
|
-
`printf '%s' "$snap_json" | node <probe-flags> scripts/conductor-db.mjs snapshot "$c" >> .conductor/last-write.log 2>&1`
|
|
45
|
+
`printf '%s' "$snap_json" | node <probe-flags> .claude/scripts/conductor-db.mjs snapshot "$c" >> .conductor/last-write.log 2>&1`
|
|
46
46
|
|
|
47
47
|
All argv scalars are double-quoted. **Every** DB-tail redirect uses **append mode (`>>`)** — never `>` — so a rapid or parallel second run never truncates a preceding trace; the log is gitignored, best-effort, and per-run growth is one line at most (rotation is out of scope). The lone `CONDUCTOR_DB:` degradation line (Node < 22.5 / `node:sqlite` absent) lands only in `.conductor/last-write.log`, never the UI. Finally print `> Snapshot written. Run /compact now to clear history.` regardless of the tail's outcome.
|
|
48
48
|
|
|
49
|
-
**Cross-platform note:** the incantations above are the **Unix (bash) canonical form**; the `.md` file is an agent instruction, not a literal script — realize the same semantics on the host shell. On Windows/PowerShell: **first set `$OutputEncoding = [System.Text.UTF8Encoding]::new($false)`** (no-BOM UTF-8, so the piped snapshot string reaches Node's UTF-8 `TextDecoder` byte-clean); capture the id via `$id = node scripts/session-id.mjs`; pipe the blob with `$snap_json | node … snapshot "$c"`; append the log with `… 2>&1 | Out-File -Append -Encoding utf8 .conductor/last-write.log` (explicit UTF-8 append — never the bare `*>>`, whose default encoding is UTF-16LE on PS 5.1 and would corrupt the trace); ensure the dir with `New-Item -ItemType Directory -Force .conductor`. The stdin-only-for-payloads, double-quoted-argv, append-log, and fail-open rules are identical on both platforms.
|
|
49
|
+
**Cross-platform note:** the incantations above are the **Unix (bash) canonical form**; the `.md` file is an agent instruction, not a literal script — realize the same semantics on the host shell. On Windows/PowerShell: **first set `$OutputEncoding = [System.Text.UTF8Encoding]::new($false)`** (no-BOM UTF-8, so the piped snapshot string reaches Node's UTF-8 `TextDecoder` byte-clean); capture the id via `$id = node .claude/scripts/session-id.mjs`; pipe the blob with `$snap_json | node … snapshot "$c"`; append the log with `… 2>&1 | Out-File -Append -Encoding utf8 .conductor/last-write.log` (explicit UTF-8 append — never the bare `*>>`, whose default encoding is UTF-16LE on PS 5.1 and would corrupt the trace); ensure the dir with `New-Item -ItemType Directory -Force .conductor`. The stdin-only-for-payloads, double-quoted-argv, append-log, and fail-open rules are identical on both platforms.
|
package/lib/installer/deploy.mjs
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
|
-
import { cpSync, mkdirSync, chmodSync, existsSync, readdirSync, statSync } from 'node:fs';
|
|
1
|
+
import { cpSync, mkdirSync, chmodSync, existsSync, lstatSync, readdirSync, readFileSync, statSync, rmSync, unlinkSync } from 'node:fs';
|
|
2
2
|
import { join, relative, sep } from 'node:path';
|
|
3
|
+
import { mergeFileInto, resolveRealTarget } from './file-merge.mjs';
|
|
4
|
+
import { mergeClaudeMdText, appendMissingLinesText } from './merge-md.mjs';
|
|
5
|
+
|
|
6
|
+
// Host-authored data, not managed assets: these are merged, never force-copied —
|
|
7
|
+
// everything else in the template keeps its overwrite. Keyed by the name the file
|
|
8
|
+
// carries INSIDE project-template/ and valued by the name the host project uses:
|
|
9
|
+
// npm strips any file literally called `.gitignore` from every published tarball,
|
|
10
|
+
// so the template ships it undotted and this map restores the dot on deploy.
|
|
11
|
+
// Keying on the source name is load-bearing — skipping the copy loop on the
|
|
12
|
+
// target name instead would let cpSync drop a stray `gitignore` at the project root.
|
|
13
|
+
const MERGED_ROOT_FILES = new Map([
|
|
14
|
+
['CLAUDE.md', { target: 'CLAUDE.md', merge: mergeClaudeMdText }],
|
|
15
|
+
['gitignore', { target: '.gitignore', merge: appendMissingLinesText }],
|
|
16
|
+
]);
|
|
3
17
|
|
|
4
18
|
// Verified at plan time: `find global skills project-template -type l` returns
|
|
5
19
|
// nothing — the bundled asset tree contains ZERO symlinks. `dereference: false`
|
|
@@ -25,28 +39,101 @@ export function assertAssets(assetRoot, dirs) {
|
|
|
25
39
|
|
|
26
40
|
// User data under global/memory (personal.md, verbosity.md) is preserved, so it
|
|
27
41
|
// is excluded from the forced overwrite and seeded write-if-absent by config.mjs.
|
|
42
|
+
// CLAUDE.md is excluded for a different reason: deployGlobal merges it instead.
|
|
28
43
|
// The filter matches on the path RELATIVE to the copy source, so a parent
|
|
29
44
|
// directory named e.g. "/memory/checkout/..." can never exclude every file.
|
|
30
|
-
function
|
|
45
|
+
function skipHostOwned(sourceRoot) {
|
|
31
46
|
return (src) => {
|
|
32
47
|
const rel = relative(sourceRoot, src);
|
|
48
|
+
if (rel === 'CLAUDE.md') return false;
|
|
33
49
|
return rel !== 'memory' && !rel.startsWith(`memory${sep}`);
|
|
34
50
|
};
|
|
35
51
|
}
|
|
36
52
|
|
|
53
|
+
// Derived from the shipped tree rather than a constant list: a hardcoded list
|
|
54
|
+
// silently drifts the day a skill is added or renamed.
|
|
55
|
+
function bundledSkillNames(assetRoot) {
|
|
56
|
+
return readdirSync(join(assetRoot, 'skills'), { withFileTypes: true })
|
|
57
|
+
.filter((e) => e.isDirectory())
|
|
58
|
+
.map((e) => e.name);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// MUST run before the skills cpSync: a plain file sitting at skills/<name> makes
|
|
62
|
+
// the directory copy throw mid-deploy. Deliberately NOT suppressed — if the
|
|
63
|
+
// unlink fails, the cpSync error that follows carries the real diagnosis.
|
|
64
|
+
function unblockSkillPaths(assetRoot, skillsDir) {
|
|
65
|
+
for (const name of bundledSkillNames(assetRoot)) {
|
|
66
|
+
const p = join(skillsDir, name);
|
|
67
|
+
let st;
|
|
68
|
+
try { st = lstatSync(p); } catch { continue; }
|
|
69
|
+
if (!st.isDirectory()) unlinkSync(p);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// Pre-1.24 installs left skills/<name>.md flat files that Claude Code never reads.
|
|
74
|
+
// Remove one only when its bytes are still the bundled content — with OR without
|
|
75
|
+
// the frontmatter block, since 1.24 added frontmatter to two of them and a
|
|
76
|
+
// single comparison would leave those shadow files behind forever.
|
|
77
|
+
function sweepStaleFlatSkills(assetRoot, skillsDir) {
|
|
78
|
+
for (const name of bundledSkillNames(assetRoot)) {
|
|
79
|
+
const flat = join(skillsDir, `${name}.md`);
|
|
80
|
+
if (!existsSync(flat) || !statSync(flat).isFile()) continue;
|
|
81
|
+
const bundled = readFileSync(join(assetRoot, 'skills', name, 'SKILL.md'), 'utf8');
|
|
82
|
+
const body = bundled.replace(/^---\n[\s\S]*?\n---\n\n?/, '');
|
|
83
|
+
const current = readFileSync(flat, 'utf8');
|
|
84
|
+
if (current !== bundled && current !== body) continue;
|
|
85
|
+
try { unlinkSync(flat); } catch { /* cosmetic leftover, never fatal */ }
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// Pre-flight (run from bin/ BEFORE the first write): a directory or a dangling
|
|
90
|
+
// symlink at either CLAUDE.md target is unusable, and discovering that mid-copy
|
|
91
|
+
// would report a partial write (exit 2) for what is really a precondition failure.
|
|
92
|
+
export function assertMergeTargets(home, cwd, project) {
|
|
93
|
+
const targets = [join(home, '.claude', 'CLAUDE.md')];
|
|
94
|
+
if (project) targets.push(join(cwd, 'CLAUDE.md'));
|
|
95
|
+
for (const p of targets) {
|
|
96
|
+
const t = resolveRealTarget(p);
|
|
97
|
+
if (!t.exists) continue;
|
|
98
|
+
if (t.isDir || t.dangling) {
|
|
99
|
+
const err = new Error(`cannot merge ${p}: the target is ${t.isDir ? 'a directory' : 'a dangling symlink'}`);
|
|
100
|
+
err.code = 'CLAUDE_MD_NOT_FILE';
|
|
101
|
+
throw err;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
37
106
|
export function deployGlobal(assetRoot, home) {
|
|
38
107
|
const target = join(home, '.claude');
|
|
39
108
|
const globalDir = join(assetRoot, 'global');
|
|
40
109
|
mkdirSync(target, { recursive: true });
|
|
41
|
-
cpSync(globalDir, target, { ...CP_OPTS, filter:
|
|
42
|
-
|
|
43
|
-
|
|
110
|
+
cpSync(globalDir, target, { ...CP_OPTS, filter: skipHostOwned(globalDir) });
|
|
111
|
+
mergeFileInto(join(globalDir, 'CLAUDE.md'), join(target, 'CLAUDE.md'), mergeClaudeMdText);
|
|
112
|
+
const skillsDir = join(target, 'skills');
|
|
113
|
+
unblockSkillPaths(assetRoot, skillsDir);
|
|
114
|
+
cpSync(join(assetRoot, 'skills'), skillsDir, CP_OPTS);
|
|
115
|
+
sweepStaleFlatSkills(assetRoot, skillsDir);
|
|
116
|
+
// skipHostOwned excludes global/memory from the copy, so cpSync never creates
|
|
44
117
|
// <target>/memory. Create it explicitly here so the write-if-absent seeding in
|
|
45
118
|
// config.mjs (and the version/verbosity writes) always has its parent dir.
|
|
46
119
|
mkdirSync(join(target, 'memory'), { recursive: true });
|
|
47
120
|
return target;
|
|
48
121
|
}
|
|
49
122
|
|
|
123
|
+
// 1.23.2 deployed scripts/ as a sibling of .claude at <cwd>/scripts instead of
|
|
124
|
+
// nesting it under .claude, colliding with any scripts/ the host project already
|
|
125
|
+
// owned. Only remove the stale dir when its contents are EXACTLY the bundled
|
|
126
|
+
// script file set (no extras) - anything else is presumed to be the host's own
|
|
127
|
+
// scripts/ and is left untouched.
|
|
128
|
+
function sweepStaleRootScripts(assetRoot, cwd) {
|
|
129
|
+
const staleDir = join(cwd, 'scripts');
|
|
130
|
+
if (!existsSync(staleDir) || !statSync(staleDir).isDirectory()) return;
|
|
131
|
+
const bundled = readdirSync(join(assetRoot, 'scripts')).sort();
|
|
132
|
+
const present = readdirSync(staleDir).sort();
|
|
133
|
+
const matches = bundled.length === present.length && bundled.every((f, i) => f === present[i]);
|
|
134
|
+
if (matches) rmSync(staleDir, { recursive: true, force: true });
|
|
135
|
+
}
|
|
136
|
+
|
|
50
137
|
export function deployProject(assetRoot, cwd) {
|
|
51
138
|
const target = join(cwd, '.claude');
|
|
52
139
|
const templateRoot = join(assetRoot, 'project-template');
|
|
@@ -64,12 +151,18 @@ export function deployProject(assetRoot, cwd) {
|
|
|
64
151
|
// destination instead of nesting the whole tree under target.
|
|
65
152
|
cpSync(join(templateRoot, '.claude'), target, CP_OPTS);
|
|
66
153
|
for (const name of readdirSync(templateRoot)) {
|
|
67
|
-
if (name === '.claude') continue;
|
|
154
|
+
if (name === '.claude' || MERGED_ROOT_FILES.has(name)) continue;
|
|
68
155
|
cpSync(join(templateRoot, name), join(cwd, name), CP_OPTS);
|
|
69
156
|
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
157
|
+
for (const [source, { target: dest, merge }] of MERGED_ROOT_FILES) {
|
|
158
|
+
mergeFileInto(join(templateRoot, source), join(cwd, dest), merge);
|
|
159
|
+
}
|
|
160
|
+
// scripts/ is a sibling of project-template/ under assetRoot (source layout),
|
|
161
|
+
// but is deployed as a CHILD of .claude/ (target) - it must stay inside the
|
|
162
|
+
// project's self-contained .claude footprint, not spill into the host's own
|
|
163
|
+
// project root where it could collide with a scripts/ dir the host already owns.
|
|
164
|
+
sweepStaleRootScripts(assetRoot, cwd);
|
|
165
|
+
cpSync(join(assetRoot, 'scripts'), join(target, 'scripts'), CP_OPTS);
|
|
73
166
|
return target;
|
|
74
167
|
}
|
|
75
168
|
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import {
|
|
2
|
+
existsSync, lstatSync, statSync, realpathSync, readFileSync,
|
|
3
|
+
writeFileSync, copyFileSync, renameSync, unlinkSync,
|
|
4
|
+
} from 'node:fs';
|
|
5
|
+
import { utcStamp, pruneBackups } from './settings.mjs';
|
|
6
|
+
|
|
7
|
+
const BACKUP_SUFFIX = '.installer-backup.';
|
|
8
|
+
const MAX_BACKUPS = 5;
|
|
9
|
+
|
|
10
|
+
// Symlinked CLAUDE.md into a dotfiles repo is a legitimate setup, so the writer
|
|
11
|
+
// works on the RESOLVED path: renameSync over the link itself would replace it
|
|
12
|
+
// with a regular file and silently detach the dotfiles checkout.
|
|
13
|
+
export function resolveRealTarget(p) {
|
|
14
|
+
let st;
|
|
15
|
+
try { st = lstatSync(p); } catch { return { realPath: p, exists: false, isDir: false, dangling: false }; }
|
|
16
|
+
if (!st.isSymbolicLink()) return { realPath: p, exists: true, isDir: st.isDirectory(), dangling: false };
|
|
17
|
+
let real;
|
|
18
|
+
try { real = realpathSync(p); } catch { return { realPath: p, exists: true, isDir: false, dangling: true }; }
|
|
19
|
+
return { realPath: real, exists: true, isDir: statSync(real).isDirectory(), dangling: false };
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// Two installs inside the same UTC second would make copyFileSync silently
|
|
23
|
+
// overwrite the earlier backup, so collisions get a -1/-2 suffix. The suffix
|
|
24
|
+
// sorts AFTER the bare stamp, keeping pruneBackups' lexical order chronological.
|
|
25
|
+
export function backupFile(realPath, now = new Date()) {
|
|
26
|
+
const base = `${realPath}${BACKUP_SUFFIX}${utcStamp(now)}`;
|
|
27
|
+
let dst = base;
|
|
28
|
+
for (let i = 1; existsSync(dst); i++) dst = `${base}-${i}`;
|
|
29
|
+
copyFileSync(realPath, dst);
|
|
30
|
+
pruneBackups(realPath, BACKUP_SUFFIX, MAX_BACKUPS);
|
|
31
|
+
return dst;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// The rename is the ONLY mutation of the target, so a crash mid-write leaves the
|
|
35
|
+
// host file untouched. The temp file lives in the target's own directory because
|
|
36
|
+
// a cross-device rename would throw.
|
|
37
|
+
export function writeAtomic(realPath, text) {
|
|
38
|
+
const tmp = `${realPath}.installer-tmp.${process.pid}`;
|
|
39
|
+
try {
|
|
40
|
+
writeFileSync(tmp, text, 'utf8');
|
|
41
|
+
renameSync(tmp, realPath);
|
|
42
|
+
} finally {
|
|
43
|
+
try { if (existsSync(tmp)) unlinkSync(tmp); } catch { /* best effort */ }
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export function mergeFileInto(templatePath, targetPath, mergeFn, { now = new Date(), warn } = {}) {
|
|
48
|
+
const emit = warn || ((m) => process.stderr.write(`${m}\n`));
|
|
49
|
+
const target = resolveRealTarget(targetPath);
|
|
50
|
+
if (target.isDir) {
|
|
51
|
+
emit(`code-conductor: skipping ${targetPath} — the target is a directory`);
|
|
52
|
+
return 'skipped-dir';
|
|
53
|
+
}
|
|
54
|
+
// Ruling R6: writing through a dangling link would renameSync a regular file
|
|
55
|
+
// over it, destroying the link. Leave it exactly as the user left it.
|
|
56
|
+
if (target.dangling) {
|
|
57
|
+
emit(`code-conductor: skipping ${targetPath} — it is a dangling symlink`);
|
|
58
|
+
return 'skipped-dangling';
|
|
59
|
+
}
|
|
60
|
+
// Defence in depth for a damaged or hand-edited package. The bundled ignore
|
|
61
|
+
// template used to vanish here for real — npm strips any file named
|
|
62
|
+
// `.gitignore` from a tarball — which is why it now ships undotted and is
|
|
63
|
+
// mapped on deploy. Nothing bundled is expected to be absent any more; an
|
|
64
|
+
// absent template is skipped rather than aborting the whole install.
|
|
65
|
+
if (!existsSync(templatePath)) {
|
|
66
|
+
return 'skipped-missing';
|
|
67
|
+
}
|
|
68
|
+
const templateText = readFileSync(templatePath, 'utf8');
|
|
69
|
+
// Ruling R7: a fresh target gets the template verbatim; mergeFn never runs, so
|
|
70
|
+
// the template's own sentinels are validated by templates.test.js, not here.
|
|
71
|
+
if (!target.exists) {
|
|
72
|
+
writeAtomic(target.realPath, templateText);
|
|
73
|
+
return 'created';
|
|
74
|
+
}
|
|
75
|
+
const hostText = readFileSync(target.realPath, 'utf8');
|
|
76
|
+
const { text, changed, warning } = mergeFn(templateText, hostText);
|
|
77
|
+
if (warning) {
|
|
78
|
+
emit(`code-conductor: skipping ${targetPath} — ${warning}; fix the cc:managed markers and re-run`);
|
|
79
|
+
return 'skipped-warning';
|
|
80
|
+
}
|
|
81
|
+
if (!changed) return 'unchanged';
|
|
82
|
+
// Backup BEFORE the rewrite and let a backup/prune failure propagate: an
|
|
83
|
+
// unrecoverable overwrite is worse than a failed install.
|
|
84
|
+
if (hostText.trim() !== '') backupFile(target.realPath, now);
|
|
85
|
+
writeAtomic(target.realPath, text);
|
|
86
|
+
return 'merged';
|
|
87
|
+
}
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
// Pure text engine for the CLAUDE.md / .gitignore merge. Deliberately imports
|
|
2
|
+
// nothing from node:fs — every function here is a string -> string transform, so
|
|
3
|
+
// the fence, sentinel and EOL rules are unit-testable without touching disk.
|
|
4
|
+
// The I/O half (backups, atomic write, symlinks) lives in file-merge.mjs.
|
|
5
|
+
|
|
6
|
+
export const SENTINEL_START = '<!-- cc:managed:start -->';
|
|
7
|
+
export const SENTINEL_END = '<!-- cc:managed:end -->';
|
|
8
|
+
|
|
9
|
+
const toLf = (t) => t.replace(/\r\n/g, '\n');
|
|
10
|
+
|
|
11
|
+
// Host EOL wins for everything this writer emits. A file with no terminator at
|
|
12
|
+
// all (one line, no trailing newline) offers no evidence either way -> LF.
|
|
13
|
+
export function detectEol(text) {
|
|
14
|
+
const i = text.indexOf('\n');
|
|
15
|
+
if (i === -1) return '\n';
|
|
16
|
+
return i > 0 && text[i - 1] === '\r' ? '\r\n' : '\n';
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// Comparison key for a `## ` heading: case, inner whitespace, a trailing CR and
|
|
20
|
+
// trailing #'s are all noise, so `## Conventions` matches `## conventions ##`.
|
|
21
|
+
export function normalizeHeading(line) {
|
|
22
|
+
return line
|
|
23
|
+
.replace(/\r$/, '')
|
|
24
|
+
.replace(/^##\s+/, '')
|
|
25
|
+
.replace(/\s*#*\s*$/, '')
|
|
26
|
+
.replace(/\s+/g, ' ')
|
|
27
|
+
.trim()
|
|
28
|
+
.toLowerCase();
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// One fence-aware pass over LF-normalized text. Returns line INDICES only, so
|
|
32
|
+
// callers slice `lines` themselves and no substring arithmetic is needed.
|
|
33
|
+
// A fence opens on ``` or ~~~ at column 0 (info string allowed) and closes on a
|
|
34
|
+
// bare run of the SAME marker char. An unclosed fence runs to EOF, so everything
|
|
35
|
+
// after it is body text — never a heading, never a sentinel.
|
|
36
|
+
export function scanLines(lfText) {
|
|
37
|
+
const lines = lfText.split('\n');
|
|
38
|
+
const headings = [];
|
|
39
|
+
const starts = [];
|
|
40
|
+
const ends = [];
|
|
41
|
+
let fence = null;
|
|
42
|
+
for (let i = 0; i < lines.length; i++) {
|
|
43
|
+
const line = lines[i].replace(/\r$/, '');
|
|
44
|
+
const marker = line.match(/^(`{3,}|~{3,})/);
|
|
45
|
+
if (fence) {
|
|
46
|
+
if (marker && marker[1][0] === fence && /^(`{3,}|~{3,})\s*$/.test(line)) fence = null;
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
49
|
+
if (marker) { fence = marker[1][0]; continue; }
|
|
50
|
+
const trimmed = line.trim();
|
|
51
|
+
if (trimmed === SENTINEL_START) { starts.push(i); continue; }
|
|
52
|
+
if (trimmed === SENTINEL_END) { ends.push(i); continue; }
|
|
53
|
+
if (/^## /.test(line)) headings.push({ index: i, key: normalizeHeading(line) });
|
|
54
|
+
}
|
|
55
|
+
const status =
|
|
56
|
+
starts.length === 0 && ends.length === 0 ? 'none'
|
|
57
|
+
: starts.length === 1 && ends.length === 1 && starts[0] < ends[0] ? 'balanced'
|
|
58
|
+
: 'unbalanced';
|
|
59
|
+
return { lines, headings, start: starts[0], end: ends[0], status };
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// A section runs from its `## ` line to the line before the next heading, or to
|
|
63
|
+
// `limit` (the sentinel start, or EOF) — whichever comes first.
|
|
64
|
+
function sectionRange(scan, n, limit) {
|
|
65
|
+
const from = scan.headings[n].index;
|
|
66
|
+
const next = scan.headings[n + 1];
|
|
67
|
+
return [from, Math.min(next ? next.index : limit, limit)];
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// Append `block` at EOF with exactly one blank separator line and exactly one
|
|
71
|
+
// trailing newline, collapsing whatever trailing blank lines the host had.
|
|
72
|
+
function appendBlock(lines, block) {
|
|
73
|
+
const out = lines.slice();
|
|
74
|
+
while (out.length && out[out.length - 1].trim() === '') out.pop();
|
|
75
|
+
if (out.length) out.push('');
|
|
76
|
+
out.push(...block);
|
|
77
|
+
if (out[out.length - 1] !== '') out.push('');
|
|
78
|
+
return out;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export function mergeClaudeMdText(templateText, hostText) {
|
|
82
|
+
const tpl = scanLines(toLf(templateText));
|
|
83
|
+
// Never mutate host content on the authority of a broken shipped template.
|
|
84
|
+
if (tpl.status !== 'balanced') {
|
|
85
|
+
return { text: hostText, changed: false, warning: 'TEMPLATE_SENTINEL_UNBALANCED' };
|
|
86
|
+
}
|
|
87
|
+
if (hostText.trim() === '') {
|
|
88
|
+
return { text: templateText, changed: templateText !== hostText, warning: null };
|
|
89
|
+
}
|
|
90
|
+
const host0 = scanLines(toLf(hostText));
|
|
91
|
+
// Guessing the intended block risks eating host content, so every malformed
|
|
92
|
+
// count takes the same path: touch nothing at all, not even a section append.
|
|
93
|
+
if (host0.status === 'unbalanced') {
|
|
94
|
+
return { text: hostText, changed: false, warning: 'CLAUDE_MD_SENTINEL_UNBALANCED' };
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const eol = detectEol(hostText);
|
|
98
|
+
const block = tpl.lines.slice(tpl.start, tpl.end + 1); // sentinels included
|
|
99
|
+
const interior = tpl.lines.slice(tpl.start + 1, tpl.end); // sentinels excluded
|
|
100
|
+
const managedKeys = new Set(
|
|
101
|
+
tpl.headings.filter((h) => h.index > tpl.start && h.index < tpl.end).map((h) => h.key),
|
|
102
|
+
);
|
|
103
|
+
|
|
104
|
+
let lines = host0.lines.slice();
|
|
105
|
+
if (host0.status === 'balanced') {
|
|
106
|
+
// Both sides are already LF here, so this comparison is EOL-normalized by
|
|
107
|
+
// construction — without that a CRLF host would "change" on every run.
|
|
108
|
+
const current = lines.slice(host0.start + 1, host0.end);
|
|
109
|
+
if (current.join('\n') !== interior.join('\n')) {
|
|
110
|
+
lines.splice(host0.start + 1, host0.end - host0.start - 1, ...interior);
|
|
111
|
+
}
|
|
112
|
+
} else {
|
|
113
|
+
// Migration — the ONE path that discards host content. Host sections whose
|
|
114
|
+
// heading matches a managed heading are dropped so the appended block does
|
|
115
|
+
// not duplicate them. The caller's backup file is the recovery.
|
|
116
|
+
const drop = [];
|
|
117
|
+
for (let n = 0; n < host0.headings.length; n++) {
|
|
118
|
+
if (managedKeys.has(host0.headings[n].key)) drop.push(sectionRange(host0, n, lines.length));
|
|
119
|
+
}
|
|
120
|
+
for (const [from, to] of drop.reverse()) lines.splice(from, to - from);
|
|
121
|
+
lines = appendBlock(lines, block);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// Host-owned template sections the host lacks, in template order, inserted
|
|
125
|
+
// immediately before the sentinel start so the block stays last across releases.
|
|
126
|
+
const host1 = scanLines(lines.join('\n'));
|
|
127
|
+
const have = new Set(host1.headings.map((h) => h.key));
|
|
128
|
+
const additions = [];
|
|
129
|
+
for (let n = 0; n < tpl.headings.length; n++) {
|
|
130
|
+
const h = tpl.headings[n];
|
|
131
|
+
if (h.index > tpl.start || have.has(h.key)) continue;
|
|
132
|
+
const [from, to] = sectionRange(tpl, n, tpl.start);
|
|
133
|
+
additions.push(...tpl.lines.slice(from, to));
|
|
134
|
+
}
|
|
135
|
+
if (additions.length) {
|
|
136
|
+
lines = host1.status === 'balanced'
|
|
137
|
+
? [...lines.slice(0, host1.start), ...additions, ...lines.slice(host1.start)]
|
|
138
|
+
: appendBlock(lines, additions);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
const text = lines.join(eol);
|
|
142
|
+
return { text, changed: text !== hostText, warning: null };
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// .gitignore is line-oriented, not section-oriented: compare trimmed, CR-stripped,
|
|
146
|
+
// non-empty lines and append the template lines the host lacks. Blank and
|
|
147
|
+
// comment-only template lines are never appended.
|
|
148
|
+
export function appendMissingLinesText(templateText, hostText) {
|
|
149
|
+
if (hostText.trim() === '') {
|
|
150
|
+
return { text: templateText, changed: templateText !== hostText, warning: null };
|
|
151
|
+
}
|
|
152
|
+
const eol = detectEol(hostText);
|
|
153
|
+
const lines = toLf(hostText).split('\n');
|
|
154
|
+
const have = new Set(lines.map((l) => l.replace(/\r$/, '').trim()).filter(Boolean));
|
|
155
|
+
const additions = [];
|
|
156
|
+
for (const raw of toLf(templateText).split('\n')) {
|
|
157
|
+
const t = raw.replace(/\r$/, '').trim();
|
|
158
|
+
if (!t || t.startsWith('#') || have.has(t)) continue;
|
|
159
|
+
have.add(t);
|
|
160
|
+
additions.push(t);
|
|
161
|
+
}
|
|
162
|
+
if (!additions.length) return { text: hostText, changed: false, warning: null };
|
|
163
|
+
const out = lines.slice();
|
|
164
|
+
while (out.length && out[out.length - 1].trim() === '') out.pop();
|
|
165
|
+
out.push(...additions, '');
|
|
166
|
+
const text = out.join(eol);
|
|
167
|
+
return { text, changed: text !== hostText, warning: null };
|
|
168
|
+
}
|
|
@@ -3,11 +3,14 @@ import { join, dirname, basename } from 'node:path';
|
|
|
3
3
|
|
|
4
4
|
const FINGERPRINT = 'verbosity-remind.sh';
|
|
5
5
|
const MAX_MALFORMED_BACKUPS = 5;
|
|
6
|
+
const MALFORMED_SUFFIX = '.malformed-backup.';
|
|
6
7
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
// Date.toISOString() is ALWAYS UTC (trailing Z). Strip the separators and the
|
|
9
|
+
// fractional millis: 2026-07-05T12:34:56.789Z -> 20260705T123456Z. Fixed width,
|
|
10
|
+
// so lexical filename order == chronological order (drives pruneBackups).
|
|
11
|
+
// Exported because the CLAUDE.md/.gitignore writer reuses it — duplicating this
|
|
12
|
+
// format would silently break the pruner's ordering assumption.
|
|
13
|
+
export function utcStamp(d) {
|
|
11
14
|
return d.toISOString().replace(/[-:]/g, '').replace(/\.\d+Z$/, 'Z');
|
|
12
15
|
}
|
|
13
16
|
|
|
@@ -25,20 +28,28 @@ function entryHasCommand(entry, predicate) {
|
|
|
25
28
|
}
|
|
26
29
|
|
|
27
30
|
function backupMalformed(settingsPath, now) {
|
|
28
|
-
const dst = `${settingsPath}
|
|
31
|
+
const dst = `${settingsPath}${MALFORMED_SUFFIX}${utcStamp(now)}`;
|
|
29
32
|
copyFileSync(settingsPath, dst);
|
|
30
33
|
pruneMalformedBackups(settingsPath);
|
|
31
34
|
}
|
|
32
35
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
+
// Generalized over the suffix family so one pruner serves both the malformed
|
|
37
|
+
// settings.json backups and the installer backups written beside CLAUDE.md and
|
|
38
|
+
// .gitignore. Sorting is lexical, which equals chronological only because every
|
|
39
|
+
// name embeds a fixed-width utcStamp.
|
|
40
|
+
export function pruneBackups(filePath, suffix, keep = MAX_MALFORMED_BACKUPS) {
|
|
41
|
+
const dir = dirname(filePath);
|
|
42
|
+
const prefix = `${basename(filePath)}${suffix}`;
|
|
36
43
|
const backups = readdirSync(dir).filter(n => n.startsWith(prefix)).sort();
|
|
37
44
|
for (const n of backups.slice(0, Math.max(0, backups.length - keep))) {
|
|
38
45
|
try { unlinkSync(join(dir, n)); } catch { /* best effort */ }
|
|
39
46
|
}
|
|
40
47
|
}
|
|
41
48
|
|
|
49
|
+
export function pruneMalformedBackups(settingsPath, keep = MAX_MALFORMED_BACKUPS) {
|
|
50
|
+
pruneBackups(settingsPath, MALFORMED_SUFFIX, keep);
|
|
51
|
+
}
|
|
52
|
+
|
|
42
53
|
export function mergeVerbosityHook(settingsPath, hookCmd, now = new Date()) {
|
|
43
54
|
// A missing settings.json (ENOENT) is not an error: initialize a fresh, empty
|
|
44
55
|
// config object and let the merge create the file. The existsSync check plus
|
package/package.json
CHANGED
|
@@ -4,12 +4,12 @@ description: "(Conductor) Execute implementation tasks from an approved plan"
|
|
|
4
4
|
|
|
5
5
|
## Phase entry - Resume Read
|
|
6
6
|
|
|
7
|
-
Before doing anything else, restore any stored context for the current commit by running
|
|
7
|
+
Before doing anything else, restore any stored context for the current commit by running `.claude/scripts/resume-read.mjs`. It resolves the current git hash, prefers a valid DB snapshot (`conductor-db get-snapshot`), falls back to the `.claude/memory/session-snapshot.json` handoff file, and prints a `RESUME_HIT` block on a hit / nothing on a miss. Capture its stdout **and** its exit code with the canonical per-platform form (each first probes for `node` and treats its absence as a clean miss, never an error):
|
|
8
8
|
|
|
9
9
|
- **Unix / Git Bash:**
|
|
10
10
|
```sh
|
|
11
11
|
if command -v node >/dev/null 2>&1; then
|
|
12
|
-
resume_out="$(node scripts/resume-read.mjs 2>>.conductor/last-write.log)"; resume_rc=$?
|
|
12
|
+
resume_out="$(node .claude/scripts/resume-read.mjs 2>>.conductor/last-write.log)"; resume_rc=$?
|
|
13
13
|
else resume_rc=3; resume_out=""; fi
|
|
14
14
|
```
|
|
15
15
|
- **PowerShell:**
|
|
@@ -20,7 +20,7 @@ Before doing anything else, restore any stored context for the current commit by
|
|
|
20
20
|
$__nap = $PSNativeCommandUseErrorActionPreference; $PSNativeCommandUseErrorActionPreference = $false
|
|
21
21
|
}
|
|
22
22
|
try {
|
|
23
|
-
$resume_out = node scripts/resume-read.mjs 2>> .conductor/last-write.log; $resume_rc = $LASTEXITCODE
|
|
23
|
+
$resume_out = node .claude/scripts/resume-read.mjs 2>> .conductor/last-write.log; $resume_rc = $LASTEXITCODE
|
|
24
24
|
} catch { $resume_rc = 3; $resume_out = "" }
|
|
25
25
|
finally {
|
|
26
26
|
$ErrorActionPreference = $__eap
|
|
@@ -133,7 +133,7 @@ Runs after both success (`[X]`) and failure (`[!]`) paths. Record the task's fin
|
|
|
133
133
|
Each probe is a disposable child; a non-zero exit — including a fatal `bad option: --experimental-sqlite` from a Node that does not recognize the flag — is caught and simply advances to the next branch. The fatal startup error is therefore always contained inside a probe whose failure is expected; it never propagates and never aborts the hook.
|
|
134
134
|
3. Launch the chosen form, from the repo root, with the active plan file path, the task ID, and the just-written state character (`X` or `!`):
|
|
135
135
|
|
|
136
|
-
`node <chosen-flags> scripts/conductor-db.mjs record "<plan_file>" "<task_id>" "<state>"`
|
|
136
|
+
`node <chosen-flags> .claude/scripts/conductor-db.mjs record "<plan_file>" "<task_id>" "<state>"`
|
|
137
137
|
|
|
138
138
|
All three arguments **must** be wrapped in double quotes exactly as shown. A repository path can contain spaces (e.g. `/Users/me/My Projects/repo/docs/plan.md`); unquoted, the shell word-splits it into several argv entries and the recorder sees `!== 3` positionals, silently rejecting a legitimate write. `--no-warnings` (in both probe and launch) suppresses Node's `ExperimentalWarning: SQLite is an experimental feature` line so it never pollutes hook stderr; it does not affect the recorder's own `CONDUCTOR_DB:` diagnostics (those are direct `process.stderr` writes, not process warnings).
|
|
139
139
|
|
|
@@ -4,12 +4,12 @@ description: "(Conductor) Map implementation steps from an approved spec"
|
|
|
4
4
|
|
|
5
5
|
## Phase entry - Resume Read
|
|
6
6
|
|
|
7
|
-
Before doing anything else, restore any stored context for the current commit by running
|
|
7
|
+
Before doing anything else, restore any stored context for the current commit by running `.claude/scripts/resume-read.mjs`. It resolves the current git hash, prefers a valid DB snapshot (`conductor-db get-snapshot`), falls back to the `.claude/memory/session-snapshot.json` handoff file, and prints a `RESUME_HIT` block on a hit / nothing on a miss. Capture its stdout **and** its exit code with the canonical per-platform form (each first probes for `node` and treats its absence as a clean miss, never an error):
|
|
8
8
|
|
|
9
9
|
- **Unix / Git Bash:**
|
|
10
10
|
```sh
|
|
11
11
|
if command -v node >/dev/null 2>&1; then
|
|
12
|
-
resume_out="$(node scripts/resume-read.mjs 2>>.conductor/last-write.log)"; resume_rc=$?
|
|
12
|
+
resume_out="$(node .claude/scripts/resume-read.mjs 2>>.conductor/last-write.log)"; resume_rc=$?
|
|
13
13
|
else resume_rc=3; resume_out=""; fi
|
|
14
14
|
```
|
|
15
15
|
- **PowerShell:**
|
|
@@ -20,7 +20,7 @@ Before doing anything else, restore any stored context for the current commit by
|
|
|
20
20
|
$__nap = $PSNativeCommandUseErrorActionPreference; $PSNativeCommandUseErrorActionPreference = $false
|
|
21
21
|
}
|
|
22
22
|
try {
|
|
23
|
-
$resume_out = node scripts/resume-read.mjs 2>> .conductor/last-write.log; $resume_rc = $LASTEXITCODE
|
|
23
|
+
$resume_out = node .claude/scripts/resume-read.mjs 2>> .conductor/last-write.log; $resume_rc = $LASTEXITCODE
|
|
24
24
|
} catch { $resume_rc = 3; $resume_out = "" }
|
|
25
25
|
finally {
|
|
26
26
|
$ErrorActionPreference = $__eap
|
|
@@ -4,12 +4,12 @@ description: "(Conductor) Define the problem and generate an approved spec"
|
|
|
4
4
|
|
|
5
5
|
## Phase entry - Resume Read
|
|
6
6
|
|
|
7
|
-
Before doing anything else, restore any stored context for the current commit by running
|
|
7
|
+
Before doing anything else, restore any stored context for the current commit by running `.claude/scripts/resume-read.mjs`. It resolves the current git hash, prefers a valid DB snapshot (`conductor-db get-snapshot`), falls back to the `.claude/memory/session-snapshot.json` handoff file, and prints a `RESUME_HIT` block on a hit / nothing on a miss. Capture its stdout **and** its exit code with the canonical per-platform form (each first probes for `node` and treats its absence as a clean miss, never an error):
|
|
8
8
|
|
|
9
9
|
- **Unix / Git Bash:**
|
|
10
10
|
```sh
|
|
11
11
|
if command -v node >/dev/null 2>&1; then
|
|
12
|
-
resume_out="$(node scripts/resume-read.mjs 2>>.conductor/last-write.log)"; resume_rc=$?
|
|
12
|
+
resume_out="$(node .claude/scripts/resume-read.mjs 2>>.conductor/last-write.log)"; resume_rc=$?
|
|
13
13
|
else resume_rc=3; resume_out=""; fi
|
|
14
14
|
```
|
|
15
15
|
- **PowerShell:**
|
|
@@ -20,7 +20,7 @@ Before doing anything else, restore any stored context for the current commit by
|
|
|
20
20
|
$__nap = $PSNativeCommandUseErrorActionPreference; $PSNativeCommandUseErrorActionPreference = $false
|
|
21
21
|
}
|
|
22
22
|
try {
|
|
23
|
-
$resume_out = node scripts/resume-read.mjs 2>> .conductor/last-write.log; $resume_rc = $LASTEXITCODE
|
|
23
|
+
$resume_out = node .claude/scripts/resume-read.mjs 2>> .conductor/last-write.log; $resume_rc = $LASTEXITCODE
|
|
24
24
|
} catch { $resume_rc = 3; $resume_out = "" }
|
|
25
25
|
finally {
|
|
26
26
|
$ErrorActionPreference = $__eap
|
|
@@ -29,6 +29,7 @@ Extends global CLAUDE.md. Project-specific rules take precedence over global one
|
|
|
29
29
|
|
|
30
30
|
---
|
|
31
31
|
|
|
32
|
+
<!-- cc:managed:start -->
|
|
32
33
|
## Agent Identity
|
|
33
34
|
You are a Senior Full-Stack Architect and Orchestrator specialized in spec-driven, modular engineering. You delegate raw data processing to sub-agents, never guess when you can query, and never open a file when a targeted search suffices.
|
|
34
35
|
|
|
@@ -102,3 +103,4 @@ VERBOSITY: MIN (default)
|
|
|
102
103
|
- Never skip the pre-tool-use.sh hook; if it blocks a tool invocation, investigate — do not bypass.
|
|
103
104
|
- Never write code without an approved /cc-spec; never implement without an approved /cc-plan.
|
|
104
105
|
- Never overwrite plan or tracking files in bulk; all state updates must be surgical single-line edits targeting one checkbox or field at a time (BUG-003 invariant).
|
|
106
|
+
<!-- cc:managed:end -->
|
package/scripts/conductor-db.mjs
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
|
|
14
14
|
import { execFileSync } from 'node:child_process';
|
|
15
15
|
import { mkdirSync, existsSync, renameSync, unlinkSync, statSync, readSync } from 'node:fs';
|
|
16
|
-
import { dirname, join, resolve, relative, sep } from 'node:path';
|
|
16
|
+
import { dirname, basename, join, resolve, relative, sep } from 'node:path';
|
|
17
17
|
import { fileURLToPath } from 'node:url';
|
|
18
18
|
|
|
19
19
|
const PREFIX = 'CONDUCTOR_DB:';
|
|
@@ -65,8 +65,11 @@ function resolveRoot() {
|
|
|
65
65
|
if (parent === dir) break; // filesystem root
|
|
66
66
|
dir = parent;
|
|
67
67
|
}
|
|
68
|
-
// 3. Fallback B: this script lives at <root>/scripts/conductor-db.mjs
|
|
69
|
-
|
|
68
|
+
// 3. Fallback B: this script lives at either <root>/scripts/conductor-db.mjs
|
|
69
|
+
// (dev checkout) or <root>/.claude/scripts/conductor-db.mjs (deployed project).
|
|
70
|
+
const scriptsDir = dirname(fileURLToPath(import.meta.url));
|
|
71
|
+
const parent = resolve(scriptsDir, '..');
|
|
72
|
+
return basename(parent) === '.claude' ? resolve(parent, '..') : parent;
|
|
70
73
|
}
|
|
71
74
|
|
|
72
75
|
function normalizePlanFile(planFile, root) {
|
package/scripts/resume-read.mjs
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
import { existsSync, readFileSync, writeFileSync, appendFileSync, unlinkSync, mkdirSync } from 'node:fs';
|
|
5
5
|
import { execFileSync, spawnSync } from 'node:child_process';
|
|
6
6
|
import { fileURLToPath } from 'node:url';
|
|
7
|
-
import { dirname, join } from 'node:path';
|
|
7
|
+
import { dirname, basename, join } from 'node:path';
|
|
8
8
|
|
|
9
9
|
const SENTINEL = '0000000';
|
|
10
10
|
const SCRIPT_DIR = dirname(fileURLToPath(import.meta.url));
|
|
@@ -24,7 +24,10 @@ function resolveRoot() {
|
|
|
24
24
|
dir = parent;
|
|
25
25
|
}
|
|
26
26
|
rootTier = 3;
|
|
27
|
-
|
|
27
|
+
// this script lives at <root>/scripts/resume-read.mjs (dev checkout) or
|
|
28
|
+
// <root>/.claude/scripts/resume-read.mjs (deployed project).
|
|
29
|
+
const parent = join(SCRIPT_DIR, '..');
|
|
30
|
+
return basename(parent) === '.claude' ? join(parent, '..') : parent;
|
|
28
31
|
}
|
|
29
32
|
|
|
30
33
|
const root = resolveRoot();
|
package/scripts/session-id.mjs
CHANGED
|
@@ -2,7 +2,7 @@ import { readFileSync, writeFileSync, renameSync, unlinkSync, mkdirSync, existsS
|
|
|
2
2
|
import { execFileSync } from 'node:child_process';
|
|
3
3
|
import { randomUUID } from 'node:crypto';
|
|
4
4
|
import { fileURLToPath } from 'node:url';
|
|
5
|
-
import { dirname, join } from 'node:path';
|
|
5
|
+
import { dirname, basename, join } from 'node:path';
|
|
6
6
|
|
|
7
7
|
// Repo root: git toplevel, else bounded .git upward walk, else this script's parent.
|
|
8
8
|
function resolveRoot() {
|
|
@@ -18,7 +18,10 @@ function resolveRoot() {
|
|
|
18
18
|
if (parent === dir) break;
|
|
19
19
|
dir = parent;
|
|
20
20
|
}
|
|
21
|
-
|
|
21
|
+
// this script lives at <root>/scripts/session-id.mjs (dev checkout) or
|
|
22
|
+
// <root>/.claude/scripts/session-id.mjs (deployed project).
|
|
23
|
+
const parent = join(dirname(fileURLToPath(import.meta.url)), '..');
|
|
24
|
+
return basename(parent) === '.claude' ? join(parent, '..') : parent;
|
|
22
25
|
}
|
|
23
26
|
|
|
24
27
|
function emit(id) { process.stdout.write(id + '\n'); }
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: code-simplifier
|
|
3
|
+
description: "Always-active simplicity rules: no speculative abstractions, one job per function, max 30 lines, flat over nested with early returns, descriptive names, comments explain why"
|
|
4
|
+
type: skill
|
|
5
|
+
---
|
|
6
|
+
|
|
1
7
|
# Code Simplifier
|
|
2
8
|
|
|
3
9
|
**Always active.** Apply these rules to every piece of code written or reviewed.
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: verbosity
|
|
3
|
+
description: "Response verbosity protocol: reads the level from ~/.claude/memory/verbosity.md and applies the MIN, INFO or VERBOSE output rules to every reply"
|
|
4
|
+
type: skill
|
|
5
|
+
---
|
|
6
|
+
|
|
1
7
|
# Verbosity
|
|
2
8
|
|
|
3
9
|
Read `~/.claude/memory/verbosity.md` once at the start of every session. Extract the value after `VERBOSITY:`. Default to MIN if the file is absent or the value is unrecognized.
|
|
File without changes
|
|
File without changes
|
|
File without changes
|