nightralph 0.0.21 → 0.0.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +77 -8
- package/dist/index.js.map +2 -2
- package/dist/meta.json +10 -10
- package/dist/orchestrator.js +56 -6
- package/dist/orchestrator.js.map +2 -2
- package/dist/setup.js +2 -1
- package/dist/setup.js.map +2 -2
- package/dist/skills/codebase-design/DEEPENING.md +37 -0
- package/dist/skills/codebase-design/DESIGN-IT-TWICE.md +44 -0
- package/dist/skills/codebase-design/SKILL.md +114 -0
- package/dist/skills/codebase-design/agents/openai.yaml +3 -0
- package/dist/src/orchestrator.d.ts.map +1 -1
- package/dist/src/setup.d.ts +1 -1
- package/dist/src/setup.d.ts.map +1 -1
- package/dist/src/testcmd.d.ts +1 -0
- package/dist/src/testcmd.d.ts.map +1 -1
- package/dist/src/worktree.d.ts.map +1 -1
- package/dist/testcmd.js +9 -0
- package/dist/testcmd.js.map +2 -2
- package/dist/worktree.js +10 -1
- package/dist/worktree.js.map +2 -2
- package/package.json +1 -1
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: codebase-design
|
|
3
|
+
description: Shared vocabulary for designing deep modules. Use when the user wants to design or improve a module's interface, find deepening opportunities, decide where a seam goes, make code more testable or AI-navigable, or when another skill needs the deep-module vocabulary.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Codebase Design
|
|
7
|
+
|
|
8
|
+
Design **deep modules**: a lot of behaviour behind a small interface, placed at a clean seam, testable through that interface. Use this language and these principles wherever code is being designed or restructured. The aim is leverage for callers, locality for maintainers, and testability for everyone.
|
|
9
|
+
|
|
10
|
+
## Glossary
|
|
11
|
+
|
|
12
|
+
Use these terms exactly: don't substitute "component," "service," "API," or "boundary." Consistent language is the whole point.
|
|
13
|
+
|
|
14
|
+
**Module**: anything with an interface and an implementation. Deliberately scale-agnostic: a function, class, package, or tier-spanning slice. _Avoid_: unit, component, service.
|
|
15
|
+
|
|
16
|
+
**Interface**: everything a caller must know to use the module correctly: the type signature, but also invariants, ordering constraints, error modes, required configuration, and performance characteristics. _Avoid_: API, signature (too narrow, they refer only to the type-level surface).
|
|
17
|
+
|
|
18
|
+
**Implementation**: what's inside a module, its body of code. Distinct from **Adapter**: a thing can be a small adapter with a large implementation (a Postgres repo) or a large adapter with a small implementation (an in-memory fake). Reach for "adapter" when the seam is the topic; "implementation" otherwise.
|
|
19
|
+
|
|
20
|
+
**Depth**: leverage at the interface. The amount of behaviour a caller (or test) can exercise per unit of interface they have to learn. A module is **deep** when a large amount of behaviour sits behind a small interface, **shallow** when the interface is nearly as complex as the implementation.
|
|
21
|
+
|
|
22
|
+
**Seam** _(Michael Feathers)_: a place where you can alter behaviour without editing in that place; the *location* at which a module's interface lives. Where to put the seam is its own design decision, distinct from what goes behind it. _Avoid_: boundary (overloaded with DDD's bounded context).
|
|
23
|
+
|
|
24
|
+
**Adapter**: a concrete thing that satisfies an interface at a seam. Describes *role* (what slot it fills), not substance (what's inside).
|
|
25
|
+
|
|
26
|
+
**Leverage**: what callers get from depth. More capability per unit of interface they learn. One implementation pays back across N call sites and M tests.
|
|
27
|
+
|
|
28
|
+
**Locality**: what maintainers get from depth. Change, bugs, knowledge, and verification concentrate in one place rather than spreading across callers. Fix once, fixed everywhere.
|
|
29
|
+
|
|
30
|
+
## Deep vs shallow
|
|
31
|
+
|
|
32
|
+
**Deep module** = small interface + lots of implementation:
|
|
33
|
+
|
|
34
|
+
```
|
|
35
|
+
┌─────────────────────┐
|
|
36
|
+
│ Small Interface │ ← Few methods, simple params
|
|
37
|
+
├─────────────────────┤
|
|
38
|
+
│ │
|
|
39
|
+
│ Deep Implementation│ ← Complex logic hidden
|
|
40
|
+
│ │
|
|
41
|
+
└─────────────────────┘
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
**Shallow module** = large interface + little implementation (avoid):
|
|
45
|
+
|
|
46
|
+
```
|
|
47
|
+
┌─────────────────────────────────┐
|
|
48
|
+
│ Large Interface │ ← Many methods, complex params
|
|
49
|
+
├─────────────────────────────────┤
|
|
50
|
+
│ Thin Implementation │ ← Just passes through
|
|
51
|
+
└─────────────────────────────────┘
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
When designing an interface, ask:
|
|
55
|
+
|
|
56
|
+
- Can I reduce the number of methods?
|
|
57
|
+
- Can I simplify the parameters?
|
|
58
|
+
- Can I hide more complexity inside?
|
|
59
|
+
|
|
60
|
+
## Principles
|
|
61
|
+
|
|
62
|
+
- **Depth is a property of the interface, not the implementation.** A deep module can be internally composed of small, mockable, swappable parts; they just aren't part of the interface. A module can have **internal seams** (private to its implementation, used by its own tests) as well as the **external seam** at its interface.
|
|
63
|
+
- **The deletion test.** Imagine deleting the module. If complexity vanishes, it was a pass-through. If complexity reappears across N callers, it was earning its keep.
|
|
64
|
+
- **The interface is the test surface.** Callers and tests cross the same seam. If you want to test *past* the interface, the module is probably the wrong shape.
|
|
65
|
+
- **One adapter means a hypothetical seam. Two adapters means a real one.** Don't introduce a seam unless something actually varies across it.
|
|
66
|
+
|
|
67
|
+
## Designing for testability
|
|
68
|
+
|
|
69
|
+
Good interfaces make testing natural:
|
|
70
|
+
|
|
71
|
+
1. **Accept dependencies, don't create them.**
|
|
72
|
+
|
|
73
|
+
```typescript
|
|
74
|
+
// Testable
|
|
75
|
+
function processOrder(order, paymentGateway) {}
|
|
76
|
+
|
|
77
|
+
// Hard to test
|
|
78
|
+
function processOrder(order) {
|
|
79
|
+
const gateway = new StripeGateway();
|
|
80
|
+
}
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
2. **Return results, don't produce side effects.**
|
|
84
|
+
|
|
85
|
+
```typescript
|
|
86
|
+
// Testable
|
|
87
|
+
function calculateDiscount(cart): Discount {}
|
|
88
|
+
|
|
89
|
+
// Hard to test
|
|
90
|
+
function applyDiscount(cart): void {
|
|
91
|
+
cart.total -= discount;
|
|
92
|
+
}
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
3. **Small surface area.** Fewer methods = fewer tests needed. Fewer params = simpler test setup.
|
|
96
|
+
|
|
97
|
+
## Relationships
|
|
98
|
+
|
|
99
|
+
- A **Module** has exactly one **Interface** (the surface it presents to callers and tests).
|
|
100
|
+
- **Depth** is a property of a **Module**, measured against its **Interface**.
|
|
101
|
+
- A **Seam** is where a **Module**'s **Interface** lives.
|
|
102
|
+
- An **Adapter** sits at a **Seam** and satisfies the **Interface**.
|
|
103
|
+
- **Depth** produces **Leverage** for callers and **Locality** for maintainers.
|
|
104
|
+
|
|
105
|
+
## Rejected framings
|
|
106
|
+
|
|
107
|
+
- **Depth as ratio of implementation-lines to interface-lines** (Ousterhout): rewards padding the implementation. We use depth-as-leverage instead.
|
|
108
|
+
- **"Interface" as the TypeScript `interface` keyword or a class's public methods**: too narrow: interface here includes every fact a caller must know.
|
|
109
|
+
- **"Boundary"**: overloaded with DDD's bounded context. Say **seam** or **interface**.
|
|
110
|
+
|
|
111
|
+
## Going deeper
|
|
112
|
+
|
|
113
|
+
- **Deepening a cluster given its dependencies**, see [DEEPENING.md](DEEPENING.md): dependency categories, seam discipline, and replace-don't-layer testing.
|
|
114
|
+
- **Exploring alternative interfaces**, see [DESIGN-IT-TWICE.md](DESIGN-IT-TWICE.md): spin up parallel sub-agents to design the interface several radically different ways, then compare on depth, locality, and seam placement.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"orchestrator.d.ts","sourceRoot":"","sources":["../../src/orchestrator.ts"],"names":[],"mappings":"AA+BA,OAAO,EAIH,KAAK,qBAAqB,EAC7B,MAAM,YAAY,CAAA;AACnB,OAAO,EAGH,KAAK,OAAO,EACf,MAAM,cAAc,CAAA;AAGrB,MAAM,MAAM,MAAM,GAAG;IACjB,GAAG,EAAC,MAAM,CAAA;IACV,IAAI,EAAC,MAAM,CAAA;IACX,QAAQ,EAAC,MAAM,CAAA;IACf,QAAQ,EAAC,MAAM,CAAA;IACf,IAAI,EAAC,MAAM,C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AAO,CAAC,EAAC,MAAM,EACf,UAAU,CAAC,EAAC,MAAM,GACpB,OAAO,CAAC;IAAE,OAAO,EAAC,OAAO,CAAA;CAAE,CAAC,CAmJ7B;AAED,wBAAsB,gBAAgB,CAAE,IAAI,EAAC;IACzC,OAAO,EAAC,KAAK,CAAC,MAAM,CAAC,CAAA;IACrB,QAAQ,EAAC,MAAM,CAAA;IACf,QAAQ,EAAC,MAAM,CAAA;IACf,KAAK,EAAC,MAAM,GAAC,IAAI,CAAA;IACjB,OAAO,EAAC,MAAM,CAAA;IACd,OAAO,EAAC,MAAM,CAAA;IACd,WAAW,EAAC,MAAM,CAAA;IAClB,gBAAgB,EAAC,qBAAqB,CAAA;IACtC,OAAO,CAAC,EAAC,OAAO,CAAA;IAChB,OAAO,CAAC,EAAC,MAAM,GAAC,IAAI,CAAA;IACpB,QAAQ,CAAC,EAAC,MAAM,CAAA;IAEhB,QAAQ,CAAC,EAAC,aAAa,CAAA;IAEvB,OAAO,CAAC,EAAC,MAAM,CAAA;IAEf,UAAU,CAAC,EAAC,MAAM,CAAA;CACrB,GAAE,OAAO,CAAC;IAAE,OAAO,EAAC,OAAO,CAAA;CAAE,CAAC,CA8Y9B"}
|
package/dist/src/setup.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const SKILL_DIRS: readonly ["grill", "grilling", "domain-modeling", "to-spec", "to-tickets", "tdd"];
|
|
1
|
+
export declare const SKILL_DIRS: readonly ["grill", "grilling", "domain-modeling", "to-spec", "to-tickets", "tdd", "codebase-design"];
|
|
2
2
|
export declare const DOC_TEMPLATES: readonly ["triage-labels.md", "domain.md"];
|
|
3
3
|
export declare function writeManagedSection(filePath: string, content: string): void;
|
|
4
4
|
export declare function checkGhAuth(): boolean;
|
package/dist/src/setup.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setup.d.ts","sourceRoot":"","sources":["../../src/setup.ts"],"names":[],"mappings":"AAYA,eAAO,MAAM,UAAU,
|
|
1
|
+
{"version":3,"file":"setup.d.ts","sourceRoot":"","sources":["../../src/setup.ts"],"names":[],"mappings":"AAYA,eAAO,MAAM,UAAU,sGAIb,CAAA;AAEV,eAAO,MAAM,aAAa,4CAGhB,CAAA;AAKV,wBAAgB,mBAAmB,CAC/B,QAAQ,EAAC,MAAM,EACf,OAAO,EAAC,MAAM,GAChB,IAAI,CA0BL;AAED,wBAAgB,WAAW,IAAI,OAAO,CAOrC;AAED,MAAM,MAAM,WAAW,GAAG,QAAQ,GAAC,OAAO,CAAA;AAE1C,MAAM,MAAM,SAAS,GAAG;IACpB,gBAAgB,EAAC,MAAM,CAAA;IACvB,gBAAgB,EAAC,MAAM,CAAA;IACvB,UAAU,EAAC,MAAM,CAAA;IACjB,MAAM,CAAC,EAAC,OAAO,CAAA;IACf,OAAO,EAAC,WAAW,CAAA;CACtB,CAAA;AAOD,wBAAgB,KAAK,CAAE,IAAI,EAAC,SAAS,GAAE,IAAI,CA8G1C"}
|
package/dist/src/testcmd.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"testcmd.d.ts","sourceRoot":"","sources":["../../src/testcmd.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,UAAU,GAAG;IACrB,QAAQ,EAAC,MAAM,CAAA;IACf,MAAM,EAAC,MAAM,CAAA;CAChB,CAAA;AAID,wBAAgB,aAAa,CAAE,UAAU,EAAC,MAAM,GAAE,MAAM,GAAC,IAAI,CAa5D;AAED,wBAAgB,UAAU,CAAE,IAAI,EAAC;IAC7B,GAAG,EAAC,MAAM,CAAA;IACV,GAAG,EAAC,MAAM,CAAA;IACV,OAAO,EAAC,MAAM,CAAA;
|
|
1
|
+
{"version":3,"file":"testcmd.d.ts","sourceRoot":"","sources":["../../src/testcmd.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,UAAU,GAAG;IACrB,QAAQ,EAAC,MAAM,CAAA;IACf,MAAM,EAAC,MAAM,CAAA;CAChB,CAAA;AAID,wBAAgB,aAAa,CAAE,UAAU,EAAC,MAAM,GAAE,MAAM,GAAC,IAAI,CAa5D;AAED,wBAAgB,UAAU,CAAE,IAAI,EAAC;IAC7B,GAAG,EAAC,MAAM,CAAA;IACV,GAAG,EAAC,MAAM,CAAA;IACV,OAAO,EAAC,MAAM,CAAA;IACd,QAAQ,CAAC,EAAC,GAAG,CAAC,MAAM,CAAC,CAAA;CACxB,GAAE,OAAO,CAAC,UAAU,CAAC,CAwDrB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"worktree.d.ts","sourceRoot":"","sources":["../../src/worktree.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAI/C,wBAAgB,WAAW,IAAI,MAAM,CAOpC;AAED,wBAAgB,WAAW,IAAI,MAAM,CAEpC;AAED,wBAAgB,gBAAgB,IAAI,MAAM,CAOzC;AAwFD,wBAAgB,cAAc,CAC1B,IAAI,EAAC;IACD,QAAQ,EAAC,MAAM,CAAA;IACf,QAAQ,EAAC,MAAM,CAAA;IACf,UAAU,EAAC,MAAM,CAAA;IACjB,MAAM,EAAC,MAAM,CAAA;CAChB,GACH,OAAO,CAAC;IAAE,YAAY,EAAC,MAAM,CAAC;IAAC,UAAU,EAAC,MAAM,CAAA;CAAE,CAAC,CAIpD;
|
|
1
|
+
{"version":3,"file":"worktree.d.ts","sourceRoot":"","sources":["../../src/worktree.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAI/C,wBAAgB,WAAW,IAAI,MAAM,CAOpC;AAED,wBAAgB,WAAW,IAAI,MAAM,CAEpC;AAED,wBAAgB,gBAAgB,IAAI,MAAM,CAOzC;AAwFD,wBAAgB,cAAc,CAC1B,IAAI,EAAC;IACD,QAAQ,EAAC,MAAM,CAAA;IACf,QAAQ,EAAC,MAAM,CAAA;IACf,UAAU,EAAC,MAAM,CAAA;IACjB,MAAM,EAAC,MAAM,CAAA;CAChB,GACH,OAAO,CAAC;IAAE,YAAY,EAAC,MAAM,CAAC;IAAC,UAAU,EAAC,MAAM,CAAA;CAAE,CAAC,CAIpD;AAeD,wBAAgB,cAAc,CAC1B,YAAY,EAAC,MAAM,EACnB,IAAI,CAAC,EAAC;IAAE,KAAK,CAAC,EAAC,OAAO,CAAA;CAAE,GAC1B,OAAO,CAAC,IAAI,CAAC,CAMd;AAED,wBAAgB,aAAa,CACzB,QAAQ,EAAC,MAAM,EACf,IAAI,EAAC,MAAM,EACX,MAAM,EAAC,MAAM,GACf,OAAO,CAOR;AAED,wBAAgB,OAAO,CAAE,GAAG,EAAC,MAAM,GAAE,OAAO,CAO3C;AAED,wBAAsB,WAAW,CAC7B,GAAG,EAAC,MAAM,EACV,OAAO,CAAC,EAAC,MAAM,GACjB,OAAO,CAAC,OAAO,CAAC,CAsBjB;AAED,wBAAsB,aAAa,CAC/B,QAAQ,EAAC,MAAM,GACjB,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAWvB"}
|
package/dist/testcmd.js
CHANGED
|
@@ -24,6 +24,9 @@ function runTestCmd(opts) {
|
|
|
24
24
|
stdio: ["ignore", "pipe", "pipe"],
|
|
25
25
|
detached: true
|
|
26
26
|
});
|
|
27
|
+
if (child.pid !== void 0 && opts.registry) {
|
|
28
|
+
opts.registry.add(child.pid);
|
|
29
|
+
}
|
|
27
30
|
const chunks = [];
|
|
28
31
|
child.stdout.on("data", (d) => chunks.push(String(d)));
|
|
29
32
|
child.stderr.on("data", (d) => chunks.push(String(d)));
|
|
@@ -42,6 +45,9 @@ function runTestCmd(opts) {
|
|
|
42
45
|
if (settled) return;
|
|
43
46
|
settled = true;
|
|
44
47
|
clearTimeout(timer);
|
|
48
|
+
if (child.pid !== void 0 && opts.registry) {
|
|
49
|
+
opts.registry.delete(child.pid);
|
|
50
|
+
}
|
|
45
51
|
chunks.push(String(err));
|
|
46
52
|
resolve({
|
|
47
53
|
exitCode: 1,
|
|
@@ -52,6 +58,9 @@ function runTestCmd(opts) {
|
|
|
52
58
|
if (settled) return;
|
|
53
59
|
settled = true;
|
|
54
60
|
clearTimeout(timer);
|
|
61
|
+
if (child.pid !== void 0 && opts.registry) {
|
|
62
|
+
opts.registry.delete(child.pid);
|
|
63
|
+
}
|
|
55
64
|
resolve({
|
|
56
65
|
exitCode: code ?? 1,
|
|
57
66
|
output: chunks.join("")
|
package/dist/testcmd.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/testcmd.ts"],
|
|
4
|
-
"sourcesContent": ["import { spawn } from 'node:child_process'\nimport { existsSync, readFileSync } from 'node:fs'\nimport { join } from 'node:path'\n\nexport type TestResult = {\n exitCode:number\n output:string\n}\n\n// Returns the command to run the project's tests, or null\n// when the project does not declare one.\nexport function detectTestCmd (projectDir:string):string|null {\n const pkgPath = join(projectDir, 'package.json')\n if (!existsSync(pkgPath)) return null\n try {\n const pkg = JSON.parse(\n readFileSync(pkgPath, 'utf8')\n ) as { scripts?:Record<string, string> }\n return pkg.scripts?.test ?\n 'npm test' :\n null\n } catch {\n return null\n }\n}\n\nexport function runTestCmd (opts:{\n cmd:string\n cwd:string\n timeout:number\n}):Promise<TestResult> {\n return new Promise(resolve => {\n let settled = false\n const child = spawn('sh', ['-c', opts.cmd], {\n cwd:opts.cwd,\n stdio:['ignore', 'pipe', 'pipe'],\n detached:true,\n })\n const chunks:string[] = []\n child.stdout.on('data', d => chunks.push(String(d)))\n child.stderr.on('data', d => chunks.push(String(d)))\n\n const timer = setTimeout(() => {\n if (child.pid) {\n try {\n process.kill(-child.pid, 'SIGKILL')\n } catch {\n
|
|
5
|
-
"mappings": ";;AAAA,SAAS,aAAa;AACtB,SAAS,YAAY,oBAAoB;AACzC,SAAS,YAAY;AASd,SAAS,cAAe,YAA+B;AAC1D,QAAM,UAAU,KAAK,YAAY,cAAc;AAC/C,MAAI,CAAC,WAAW,OAAO,EAAG,QAAO;AACjC,MAAI;AACA,UAAM,MAAM,KAAK;AAAA,MACb,aAAa,SAAS,MAAM;AAAA,IAChC;AACA,WAAO,IAAI,SAAS,OAChB,aACA;AAAA,EACR,QAAQ;AACJ,WAAO;AAAA,EACX;AACJ;AAbgB;AAeT,SAAS,WAAY,
|
|
4
|
+
"sourcesContent": ["import { spawn } from 'node:child_process'\nimport { existsSync, readFileSync } from 'node:fs'\nimport { join } from 'node:path'\n\nexport type TestResult = {\n exitCode:number\n output:string\n}\n\n// Returns the command to run the project's tests, or null\n// when the project does not declare one.\nexport function detectTestCmd (projectDir:string):string|null {\n const pkgPath = join(projectDir, 'package.json')\n if (!existsSync(pkgPath)) return null\n try {\n const pkg = JSON.parse(\n readFileSync(pkgPath, 'utf8')\n ) as { scripts?:Record<string, string> }\n return pkg.scripts?.test ?\n 'npm test' :\n null\n } catch {\n return null\n }\n}\n\nexport function runTestCmd (opts:{\n cmd:string\n cwd:string\n timeout:number\n registry?:Set<number>\n}):Promise<TestResult> {\n return new Promise(resolve => {\n let settled = false\n const child = spawn('sh', ['-c', opts.cmd], {\n cwd:opts.cwd,\n stdio:['ignore', 'pipe', 'pipe'],\n detached:true,\n })\n\n if (child.pid !== undefined && opts.registry) {\n opts.registry.add(child.pid)\n }\n\n const chunks:string[] = []\n child.stdout.on('data', d => chunks.push(String(d)))\n child.stderr.on('data', d => chunks.push(String(d)))\n\n const timer = setTimeout(() => {\n if (child.pid) {\n try {\n process.kill(-child.pid, 'SIGKILL')\n } catch {\n child.kill('SIGKILL')\n }\n } else {\n child.kill('SIGKILL')\n }\n }, opts.timeout * 1000)\n\n child.on('error', err => {\n if (settled) return\n settled = true\n clearTimeout(timer)\n if (child.pid !== undefined && opts.registry) {\n opts.registry.delete(child.pid)\n }\n chunks.push(String(err))\n resolve({\n exitCode:1,\n output:chunks.join(''),\n })\n })\n\n child.on('close', code => {\n if (settled) return\n settled = true\n clearTimeout(timer)\n if (child.p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AS,SAAO;AACrB,UAAI,QAAS;AACb,gBAAU;AACV,mBAAa,KAAK;AAClB,UAAI,MAAM,QAAQ,UAAa,KAAK,UAAU;AAC1C,aAAK,SAAS,OAAO,MAAM,GAAG;AAAA,MAClC;AACA,aAAO,KAAK,OAAO,GAAG,CAAC;AACvB,cAAQ;AAAA,QACJ,UAAS;AAAA,QACT,QAAO,OAAO,KAAK,EAAE;AAAA,MACzB,CAAC;AAAA,IACL,CAAC;AAED,UAAM,GAAG,SAAS,UAAQ;AACtB,UAAI,QAAS;AACb,gBAAU;AACV,mBAAa,KAAK;AAClB,UAAI,MAAM,QAAQ,UAAa,KAAK,UAAU;AAC1C,aAAK,SAAS,OAAO,MAAM,GAAG;AAAA,MAClC;AACA,cAAQ;AAAA,QACJ,UAAS,QAAQ;AAAA,QACjB,QAAO,OAAO,KAAK,EAAE;AAAA,MACzB,CAAC;AAAA,IACL,CAAC;AAAA,EACL,CAAC;AACL;AA7DgB;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/worktree.js
CHANGED
|
@@ -100,7 +100,7 @@ function createWorktree(opts) {
|
|
|
100
100
|
return result;
|
|
101
101
|
}
|
|
102
102
|
__name(createWorktree, "createWorktree");
|
|
103
|
-
async function
|
|
103
|
+
async function removeWorktreeNow(worktreePath, opts) {
|
|
104
104
|
const args = [
|
|
105
105
|
"-C",
|
|
106
106
|
worktreePath,
|
|
@@ -111,6 +111,15 @@ async function removeWorktree(worktreePath, opts) {
|
|
|
111
111
|
args.push(worktreePath);
|
|
112
112
|
await execFileAsync("git", args);
|
|
113
113
|
}
|
|
114
|
+
__name(removeWorktreeNow, "removeWorktreeNow");
|
|
115
|
+
function removeWorktree(worktreePath, opts) {
|
|
116
|
+
const result = worktreeQueue.then(
|
|
117
|
+
() => removeWorktreeNow(worktreePath, opts)
|
|
118
|
+
);
|
|
119
|
+
worktreeQueue = result.catch(() => {
|
|
120
|
+
});
|
|
121
|
+
return result;
|
|
122
|
+
}
|
|
114
123
|
__name(removeWorktree, "removeWorktree");
|
|
115
124
|
function hasNewCommits(repoRoot, base, branch) {
|
|
116
125
|
const stdout = execFileSync(
|
package/dist/worktree.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/worktree.ts"],
|
|
4
|
-
"sourcesContent": ["import { execFile, execFileSync } from 'node:child_process'\nimport { promisify } from 'node:util'\nimport { basename, join } from 'node:path'\nimport { existsSync } from 'node:fs'\nimport type { Ticket } from './orchestrator.js'\n\nconst execFileAsync = promisify(execFile)\n\nexport function getRepoRoot ():string {\n const stdout = execFileSync(\n 'git',\n ['rev-parse', '--show-toplevel'],\n { encoding:'utf8' }\n )\n return stdout.trim()\n}\n\nexport function getRepoName ():string {\n return basename(getRepoRoot())\n}\n\nexport function getCurrentBranch ():string {\n const stdout = execFileSync(\n 'git',\n ['rev-parse', '--abbrev-ref', 'HEAD'],\n { encoding:'utf8' }\n )\n return stdout.trim()\n}\n\nasync function branchExists (\n repoRoot:string,\n branchName:string\n):Promise<boolean> {\n try {\n await execFileAsync(\n 'git',\n ['show-ref', '--verify', '--quiet', `refs/heads/${branchName}`],\n { cwd:repoRoot }\n )\n return true\n } catch {\n return false\n }\n}\n\nasync function createWorktreeNow (\n opts:{\n repoRoot:string\n repoName:string\n baseBranch:string\n ticket:Ticket\n }\n):Promise<{ worktreePath:string; branchName:string }> {\n const { repoRoot, repoName, baseBranch, ticket } = opts\n const branchName = `${repoName}/${String(\n ticket.num\n ).padStart(2, '0')}-${ticket.slug}`\n const worktreePath = join(\n repoRoot,\n '..',\n `${repoName}.${String(\n ticket.num\n ).padStart(2, '0')}-${ticket.slug}`\n )\n\n if (existsSync(worktreePath)) {\n try {\n await execFileAsync(\n 'git',\n ['worktree', 'remove', '--force', worktreePath],\n { cwd:repoRoot }\n )\n } catch {\n // directory may not be a registered worktree anymore;\n // prune stale entries below and let worktree add fail\n // loudly if the path is still unusable\n }\n }\n\n try {\n await execFileAsync(\n 'git',\n ['worktree', 'prune'],\n { cwd:repoRoot }\n )\n } catch {\n // best-effort cleanup of stale worktree metadata\n }\n\n if (await branchExists(repoRoot, branchName)) {\n await execFileAsync(\n 'git',\n ['branch', '-D', branchName],\n { cwd:repoRoot }\n )\n }\n\n await execFileAsync(\n 'git',\n [\n 'worktree',\n 'add',\n '-b',\n branchName,\n worktreePath,\n baseBranch,\n ],\n { cwd:repoRoot }\n )\n\n return { worktreePath, branchName }\n}\n\nlet worktreeQueue:Promise<unknown> = Promise.resolve()\n\nexport function createWorktree (\n opts:{\n repoRoot:string\n repoName:string\n baseBranch:string\n ticket:Ticket\n }\n):Promise<{ worktreePath:string; branchName:string }> {\n const result = worktreeQueue.then(() => createWorktreeNow(opts))\n worktreeQueue = result.catch(() => {})\n return result\n}\n\
|
|
5
|
-
"mappings": ";;AAAA,SAAS,UAAU,oBAAoB;AACvC,SAAS,iBAAiB;AAC1B,SAAS,UAAU,YAAY;AAC/B,SAAS,kBAAkB;AAG3B,MAAM,gBAAgB,UAAU,QAAQ;AAEjC,SAAS,cAAsB;AAClC,QAAM,SAAS;AAAA,IACX;AAAA,IACA,CAAC,aAAa,iBAAiB;AAAA,IAC/B,EAAE,UAAS,OAAO;AAAA,EACtB;AACA,SAAO,OAAO,KAAK;AACvB;AAPgB;AAST,SAAS,cAAsB;AAClC,SAAO,SAAS,YAAY,CAAC;AACjC;AAFgB;AAIT,SAAS,mBAA2B;AACvC,QAAM,SAAS;AAAA,IACX;AAAA,IACA,CAAC,aAAa,gBAAgB,MAAM;AAAA,IACpC,EAAE,UAAS,OAAO;AAAA,EACtB;AACA,SAAO,OAAO,KAAK;AACvB;AAPgB;AAShB,eAAe,aACX,UACA,YACe;AACf,MAAI;AACA,UAAM;AAAA,MACF;AAAA,MACA,CAAC,YAAY,YAAY,WAAW,cAAc,UAAU,EAAE;AAAA,MAC9D,EAAE,KAAI,SAAS;AAAA,IACnB;AACA,WAAO;AAAA,EACX,QAAQ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C;AACrC,SAAO;AACX;AAXgB;AAahB,
|
|
4
|
+
"sourcesContent": ["import { execFile, execFileSync } from 'node:child_process'\nimport { promisify } from 'node:util'\nimport { basename, join } from 'node:path'\nimport { existsSync } from 'node:fs'\nimport type { Ticket } from './orchestrator.js'\n\nconst execFileAsync = promisify(execFile)\n\nexport function getRepoRoot ():string {\n const stdout = execFileSync(\n 'git',\n ['rev-parse', '--show-toplevel'],\n { encoding:'utf8' }\n )\n return stdout.trim()\n}\n\nexport function getRepoName ():string {\n return basename(getRepoRoot())\n}\n\nexport function getCurrentBranch ():string {\n const stdout = execFileSync(\n 'git',\n ['rev-parse', '--abbrev-ref', 'HEAD'],\n { encoding:'utf8' }\n )\n return stdout.trim()\n}\n\nasync function branchExists (\n repoRoot:string,\n branchName:string\n):Promise<boolean> {\n try {\n await execFileAsync(\n 'git',\n ['show-ref', '--verify', '--quiet', `refs/heads/${branchName}`],\n { cwd:repoRoot }\n )\n return true\n } catch {\n return false\n }\n}\n\nasync function createWorktreeNow (\n opts:{\n repoRoot:string\n repoName:string\n baseBranch:string\n ticket:Ticket\n }\n):Promise<{ worktreePath:string; branchName:string }> {\n const { repoRoot, repoName, baseBranch, ticket } = opts\n const branchName = `${repoName}/${String(\n ticket.num\n ).padStart(2, '0')}-${ticket.slug}`\n const worktreePath = join(\n repoRoot,\n '..',\n `${repoName}.${String(\n ticket.num\n ).padStart(2, '0')}-${ticket.slug}`\n )\n\n if (existsSync(worktreePath)) {\n try {\n await execFileAsync(\n 'git',\n ['worktree', 'remove', '--force', worktreePath],\n { cwd:repoRoot }\n )\n } catch {\n // directory may not be a registered worktree anymore;\n // prune stale entries below and let worktree add fail\n // loudly if the path is still unusable\n }\n }\n\n try {\n await execFileAsync(\n 'git',\n ['worktree', 'prune'],\n { cwd:repoRoot }\n )\n } catch {\n // best-effort cleanup of stale worktree metadata\n }\n\n if (await branchExists(repoRoot, branchName)) {\n await execFileAsync(\n 'git',\n ['branch', '-D', branchName],\n { cwd:repoRoot }\n )\n }\n\n await execFileAsync(\n 'git',\n [\n 'worktree',\n 'add',\n '-b',\n branchName,\n worktreePath,\n baseBranch,\n ],\n { cwd:repoRoot }\n )\n\n return { worktreePath, branchName }\n}\n\nlet worktreeQueue:Promise<unknown> = Promise.resolve()\n\nexport function createWorktree (\n opts:{\n repoRoot:string\n repoName:string\n baseBranch:string\n ticket:Ticket\n }\n):Promise<{ worktreePath:string; branchName:string }> {\n const result = worktreeQueue.then(() => createWorktreeNow(opts))\n worktreeQueue = result.catch(() => {})\n return result\n}\n\nasync function removeWorktreeNow (\n worktreePath:string,\n opts?:{ force?:boolean }\n):Promise<void> {\n const args = [\n '-C', worktreePath,\n 'worktree', 'remove',\n ]\n if (opts?.force) args.push('--force')\n args.push(worktreePath)\n await execFileAsync('git', args)\n}\n\nexport function removeWorktree (\n worktreePath:string,\n opts?:{ force?:boolean }\n):Promise<void> {\n const result = worktreeQueue.then(\n () => removeWorktreeNow(worktreePath, opts)\n )\n worktreeQueue = result.catch(() => {})\n return result\n}\n\nexport function hasNewCommits (\n repoRoot:string,\n base:string,\n branch:string\n):boolean {\n const stdout = execFileSync(\n 'git',\n ['rev-list', '--count', `${base}..${branch}`],\n { cwd:repoRoot, encoding:'utf8' }\n )\n return Number(stdout.trim()) > 0\n}\n\nexport function isDirty (cwd:string):boolean {\n const stdout = execFileSync(\n 'git',\n ['status', '--porcelain'],\n { cwd, encoding:'utf8' }\n )\n return stdout.trim().length > 0\n}\n\nexport async function commitDirty (\n cwd:string,\n message?:string\n):Promise<boolean> {\n if (!isDirty(cwd)) return false\n await execFileAsync(\n 'git',\n ['add', '-A'],\n { cwd }\n )\n try {\n await execFileAsync(\n 'git',\n [\n 'commit', '-m',\n message ??\n 'nightralph: auto-commit ' +\n 'remaining changes',\n ],\n { cwd }\n )\n return true\n } catch {\n return false\n }\n}\n\nexport async function listWorktrees (\n repoRoot:string\n):Promise<Array<string>> {\n const { stdout } = await execFileAsync(\n 'git',\n ['worktree', 'list', '--porcelain'],\n { cwd:repoRoot }\n )\n return stdout\n .trim()\n .split('\\n')\n .filter(line => line.startsWith('worktree '))\n .map(line => line.substring('worktree '.length))\n}\n"],
|
|
5
|
+
"mappings": ";;AAAA,SAAS,UAAU,oBAAoB;AACvC,SAAS,iBAAiB;AAC1B,SAAS,UAAU,YAAY;AAC/B,SAAS,kBAAkB;AAG3B,MAAM,gBAAgB,UAAU,QAAQ;AAEjC,SAAS,cAAsB;AAClC,QAAM,SAAS;AAAA,IACX;AAAA,IACA,CAAC,aAAa,iBAAiB;AAAA,IAC/B,EAAE,UAAS,OAAO;AAAA,EACtB;AACA,SAAO,OAAO,KAAK;AACvB;AAPgB;AAST,SAAS,cAAsB;AAClC,SAAO,SAAS,YAAY,CAAC;AACjC;AAFgB;AAIT,SAAS,mBAA2B;AACvC,QAAM,SAAS;AAAA,IACX;AAAA,IACA,CAAC,aAAa,gBAAgB,MAAM;AAAA,IACpC,EAAE,UAAS,OAAO;AAAA,EACtB;AACA,SAAO,OAAO,KAAK;AACvB;AAPgB;AAShB,eAAe,aACX,UACA,YACe;AACf,MAAI;AACA,UAAM;AAAA,MACF;AAAA,MACA,CAAC,YAAY,YAAY,WAAW,cAAc,UAAU,EAAE;AAAA,MAC9D,EAAE,KAAI,SAAS;AAAA,IACnB;AACA,WAAO;AAAA,EACX,QAAQ;AACJ,WAAO;AAAA,EACX;AACJ;AAde;AAgBf,eAAe,kBACX,MAMkD;AAClD,QAAM,EAAE,UAAU,UAAU,YAAY,OAAO,IAAI;AACnD,QAAM,aAAa,GAAG,QAAQ,IAAI;AAAA,IAC9B,OAAO;AAAA,EACX,EAAE,SAAS,GAAG,GAAG,CAAC,IAAI,OAAO,IAAI;AACjC,QAAM,eAAe;AAAA,IACjB;AAAA,IACA;AAAA,IACA,GAAG,QAAQ,IAAI;AAAA,MACX,OAAO;AAAA,IACX,EAAE,SAAS,GAAG,GAAG,CAAC,IAAI,OAAO,IAAI;AAAA,EACrC;AAEA,MAAI,WAAW,YAAY,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