@ecc-hgy/ae 0.5.0 → 0.6.0
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 -21
- package/README.md +168 -155
- package/bin/ae.js +2 -2
- package/package.json +43 -43
- package/skills/brainstorming/SKILL.md +133 -133
- package/skills/diagnose/SKILL.md +146 -146
- package/skills/diagnose/assets/issue-7-sections.md +35 -35
- package/skills/diagnose/scripts/hitl-loop.template.sh +41 -41
- package/skills/grill-me/SKILL.md +10 -10
- package/skills/handoff/SKILL.md +19 -19
- package/skills/improve-codebase-architecture/DEEPENING.md +37 -37
- package/skills/improve-codebase-architecture/HTML-REPORT.md +123 -123
- package/skills/improve-codebase-architecture/INTERFACE-DESIGN.md +44 -44
- package/skills/improve-codebase-architecture/LANGUAGE.md +53 -53
- package/skills/improve-codebase-architecture/SKILL.md +101 -101
- package/skills/karpathy-guidelines/SKILL.md +63 -63
- package/skills/powerautomate-email-to-sharepoint-excel/powerautomate-email-to-sharepoint-excel-skill.md +496 -496
- package/skills/review/SKILL.md +119 -119
- package/skills/tdd/SKILL.md +157 -157
- package/skills/tdd/deep-modules.md +33 -33
- package/skills/tdd/interface-design.md +31 -31
- package/skills/tdd/mocking.md +59 -59
- package/skills/tdd/refactoring.md +10 -10
- package/skills/tdd/tests.md +61 -61
- package/skills/to-issues/SKILL.md +79 -79
- package/skills/to-issues/todo-template.md +25 -25
- package/skills/to-prd/SKILL.md +108 -108
- package/skills/using-agentic-engineering/SKILL.md +62 -62
- package/skills/verification-before-completion/SKILL.md +153 -153
- package/skills/writing-plans/SKILL.md +115 -115
- package/skills/zoom-out/SKILL.md +7 -7
- package/src/cli.js +61 -61
- package/src/commands/init.js +137 -137
- package/src/commands/setup.js +162 -162
- package/src/platforms.js +132 -132
- package/src/skeleton.js +134 -99
- package/src/utils/copy.js +100 -100
- package/src/utils/paths.js +60 -60
- package/src/utils/report.js +30 -30
- package/templates/entries/AGENTS.md +2 -0
- package/templates/entries/CLAUDE.md +5 -5
- package/templates/entries/README.md +33 -31
- package/templates/entries/handoff.md +1 -1
- package/templates/entries/spec/ADR/AGENTS.md +30 -30
- package/templates/entries/spec/ADR/CLAUDE.md +5 -5
- package/templates/entries/spec/AGENTS.md +34 -34
- package/templates/entries/spec/CLAUDE.md +5 -5
- package/templates/entries/spec/INDEX.md +28 -28
- package/templates/entries/spec/README.md +23 -23
|
@@ -1,115 +1,115 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: writing-plans
|
|
3
|
-
description: Use when you have a PRD (`spec/needs/<need-name>/prd.md`) approved at S1 node A2, before touching code. Produces ONLY `design.md` — the task list lives in `todo.md` (A4 to-issues).
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# Writing Plans
|
|
7
|
-
|
|
8
|
-
## Hard Constraint (S1 node A3)
|
|
9
|
-
|
|
10
|
-
This skill produces ONLY `spec/needs/<need-name>/design.md`. It MUST NOT produce a `todo.md` or any task-level checklist — that is the job of A4 `to-issues`, which reads this `design.md` and breaks it into `todo.md`.
|
|
11
|
-
|
|
12
|
-
If the plan is not yet aligned with the user on key technical trade-offs (e.g. library choice, data model, integration seam), STOP and align before writing the design. A3 has a hard gate: undecided key trade-offs ⇒ do not advance to A4.
|
|
13
|
-
|
|
14
|
-
## Overview
|
|
15
|
-
|
|
16
|
-
Write comprehensive implementation plans assuming the engineer has zero context for our codebase and questionable taste. Document everything they need to know: which files to touch for each task, code, testing, docs they might need to check, how to test it. Give them the whole plan as bite-sized tasks. DRY. YAGNI. TDD. Frequent commits.
|
|
17
|
-
|
|
18
|
-
Assume they are a skilled developer, but know almost nothing about our toolset or problem domain. Assume they don't know good test design very well.
|
|
19
|
-
|
|
20
|
-
**Announce at start:** "I'm using the writing-plans skill to create the implementation plan."
|
|
21
|
-
|
|
22
|
-
**Input:** `spec/needs/<need-name>/prd.md` (produced by A2 `to-prd`). Also read `spec/INDEX.md`, related `spec/needs/*/design.md` if `related-needs` is set, and any `spec/ADR/` decisions that constrain this design.
|
|
23
|
-
|
|
24
|
-
**Save design to:** `spec/needs/<need-name>/design.md` (overwriting if present and `status: draft`; if `status: active`, ask the user before overwriting).
|
|
25
|
-
|
|
26
|
-
## Scope Check
|
|
27
|
-
|
|
28
|
-
If the spec covers multiple independent subsystems, it should have been broken into sub-project specs during brainstorming. If it wasn't, suggest breaking this into separate plans — one per subsystem. Each plan should produce working, testable software on its own.
|
|
29
|
-
|
|
30
|
-
## File Structure
|
|
31
|
-
|
|
32
|
-
Before defining tasks, map out which files will be created or modified and what each one is responsible for. This is where decomposition decisions get locked in.
|
|
33
|
-
|
|
34
|
-
- Design units with clear boundaries and well-defined interfaces. Each file should have one clear responsibility.
|
|
35
|
-
- You reason best about code you can hold in context at once, and your edits are more reliable when files are focused. Prefer smaller, focused files over large ones that do too much.
|
|
36
|
-
- Files that change together should live together. Split by responsibility, not by technical layer.
|
|
37
|
-
- In existing codebases, follow established patterns. If the codebase uses large files, don't unilaterally restructure - but if a file you're modifying has grown unwieldy, including a split in the plan is reasonable.
|
|
38
|
-
|
|
39
|
-
This structure informs the task decomposition. Each task should produce self-contained changes that make sense independently.
|
|
40
|
-
|
|
41
|
-
## Design Document Header
|
|
42
|
-
|
|
43
|
-
Every `design.md` MUST start with this frontmatter block followed by the header:
|
|
44
|
-
|
|
45
|
-
```yaml
|
|
46
|
-
---
|
|
47
|
-
status: draft # draft | active | archived
|
|
48
|
-
last-aligned: YYYY-MM-DD # ISO date of the most recent alignment with the user
|
|
49
|
-
related-needs: [] # other need-names whose design constrains this one; omit if none
|
|
50
|
-
---
|
|
51
|
-
```
|
|
52
|
-
|
|
53
|
-
```markdown
|
|
54
|
-
# [Need Name] Design
|
|
55
|
-
|
|
56
|
-
**Goal:** [One sentence describing what this builds — should match `prd.md` Problem/Solution]
|
|
57
|
-
|
|
58
|
-
**Architecture:** [2-3 sentences about approach]
|
|
59
|
-
|
|
60
|
-
**Tech Stack:** [Key technologies/libraries]
|
|
61
|
-
|
|
62
|
-
**Out of scope:** [Things this design explicitly does not address — usually inherited from `prd.md` Out of Scope]
|
|
63
|
-
|
|
64
|
-
---
|
|
65
|
-
```
|
|
66
|
-
|
|
67
|
-
State transitions:
|
|
68
|
-
|
|
69
|
-
- `draft` → `active` when the user has explicitly approved key technical trade-offs (A3 gate cleared)
|
|
70
|
-
- `active` → `archived` when superseded or the need is dropped (do not delete the file)
|
|
71
|
-
|
|
72
|
-
## No Placeholders
|
|
73
|
-
|
|
74
|
-
Every step must contain the actual content an engineer needs. These are **plan failures** — never write them:
|
|
75
|
-
- "TBD", "TODO", "implement later", "fill in details"
|
|
76
|
-
- "Add appropriate error handling" / "add validation" / "handle edge cases"
|
|
77
|
-
- "Write tests for the above" (without actual test code)
|
|
78
|
-
- "Similar to Task N" (repeat the code — the engineer may be reading tasks out of order)
|
|
79
|
-
- Steps that describe what to do without showing how (code blocks required for code steps)
|
|
80
|
-
- References to types, functions, or methods not defined in any task
|
|
81
|
-
|
|
82
|
-
## Remember
|
|
83
|
-
- Exact file paths always
|
|
84
|
-
- Complete code in every step — if a step changes code, show the code
|
|
85
|
-
- Exact commands with expected output
|
|
86
|
-
- DRY, YAGNI, TDD, frequent commits
|
|
87
|
-
|
|
88
|
-
## Self-Review
|
|
89
|
-
|
|
90
|
-
After writing the complete plan, look at the spec with fresh eyes and check the plan against it. This is a checklist you run yourself — not a subagent dispatch.
|
|
91
|
-
|
|
92
|
-
**1. PRD coverage:** Skim each section/requirement in `prd.md`. Can you point to a section of `design.md` that addresses it? List any gaps.
|
|
93
|
-
|
|
94
|
-
**2. Placeholder scan:** Search your design for red flags — any of the patterns from the "No Placeholders" section above. Fix them.
|
|
95
|
-
|
|
96
|
-
**3. Type consistency:** Do the types, method signatures, and property names you used across sections match? A function called `clearLayers()` in §3 but `clearFullLayers()` in §7 is a bug.
|
|
97
|
-
|
|
98
|
-
**4. ADR promotion check:** Does any decision in this design affect MORE THAN ONE need? If yes, it does not belong in `design.md` — promote it to `spec/ADR/NNNN-<title>.md` (frontmatter `status: proposed`) and reference the ADR from this design. Typical signals: "globally use X", "all needs share Y", "the project standard for Z is...".
|
|
99
|
-
|
|
100
|
-
If you find issues, fix them inline. No need to re-review — just fix and move on. If you find a spec requirement with no task, add the task.
|
|
101
|
-
|
|
102
|
-
## After Saving
|
|
103
|
-
|
|
104
|
-
1. Update `spec/INDEX.md`:
|
|
105
|
-
- Set the `design` column to `active` (or `draft` if key trade-offs still need user approval)
|
|
106
|
-
- Recompute the `当前节点` column per the rules in `spec/AGENTS.md` §INDEX 推导规则
|
|
107
|
-
- If unsure, run `ae index-rebuild` for an idempotent rescan
|
|
108
|
-
2. If you promoted any decision to `spec/ADR/`, also add a row under `## ADR` in `INDEX.md`.
|
|
109
|
-
3. Hand off to the next S1 node: A4 `to-issues` will read this `design.md` and produce `spec/needs/<need-name>/todo.md`. Tell the user the design is ready and recommend invoking `to-issues` next.
|
|
110
|
-
|
|
111
|
-
## Boundaries
|
|
112
|
-
|
|
113
|
-
- This skill writes ONLY `spec/needs/<need-name>/design.md` (plus the INDEX row, and optionally a new ADR). It does NOT write `todo.md` or any task-level checklist — that is A4.
|
|
114
|
-
- The design captures HOW (technical decisions, modules, interfaces, data flow, key trade-offs). It does NOT re-capture WHAT — refer back to `prd.md` instead.
|
|
115
|
-
- Decisions affecting MORE THAN ONE need belong in `spec/ADR/`, not here (see Self-Review step 4).
|
|
1
|
+
---
|
|
2
|
+
name: writing-plans
|
|
3
|
+
description: Use when you have a PRD (`spec/needs/<need-name>/prd.md`) approved at S1 node A2, before touching code. Produces ONLY `design.md` — the task list lives in `todo.md` (A4 to-issues).
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Writing Plans
|
|
7
|
+
|
|
8
|
+
## Hard Constraint (S1 node A3)
|
|
9
|
+
|
|
10
|
+
This skill produces ONLY `spec/needs/<need-name>/design.md`. It MUST NOT produce a `todo.md` or any task-level checklist — that is the job of A4 `to-issues`, which reads this `design.md` and breaks it into `todo.md`.
|
|
11
|
+
|
|
12
|
+
If the plan is not yet aligned with the user on key technical trade-offs (e.g. library choice, data model, integration seam), STOP and align before writing the design. A3 has a hard gate: undecided key trade-offs ⇒ do not advance to A4.
|
|
13
|
+
|
|
14
|
+
## Overview
|
|
15
|
+
|
|
16
|
+
Write comprehensive implementation plans assuming the engineer has zero context for our codebase and questionable taste. Document everything they need to know: which files to touch for each task, code, testing, docs they might need to check, how to test it. Give them the whole plan as bite-sized tasks. DRY. YAGNI. TDD. Frequent commits.
|
|
17
|
+
|
|
18
|
+
Assume they are a skilled developer, but know almost nothing about our toolset or problem domain. Assume they don't know good test design very well.
|
|
19
|
+
|
|
20
|
+
**Announce at start:** "I'm using the writing-plans skill to create the implementation plan."
|
|
21
|
+
|
|
22
|
+
**Input:** `spec/needs/<need-name>/prd.md` (produced by A2 `to-prd`). Also read `spec/INDEX.md`, related `spec/needs/*/design.md` if `related-needs` is set, and any `spec/ADR/` decisions that constrain this design.
|
|
23
|
+
|
|
24
|
+
**Save design to:** `spec/needs/<need-name>/design.md` (overwriting if present and `status: draft`; if `status: active`, ask the user before overwriting).
|
|
25
|
+
|
|
26
|
+
## Scope Check
|
|
27
|
+
|
|
28
|
+
If the spec covers multiple independent subsystems, it should have been broken into sub-project specs during brainstorming. If it wasn't, suggest breaking this into separate plans — one per subsystem. Each plan should produce working, testable software on its own.
|
|
29
|
+
|
|
30
|
+
## File Structure
|
|
31
|
+
|
|
32
|
+
Before defining tasks, map out which files will be created or modified and what each one is responsible for. This is where decomposition decisions get locked in.
|
|
33
|
+
|
|
34
|
+
- Design units with clear boundaries and well-defined interfaces. Each file should have one clear responsibility.
|
|
35
|
+
- You reason best about code you can hold in context at once, and your edits are more reliable when files are focused. Prefer smaller, focused files over large ones that do too much.
|
|
36
|
+
- Files that change together should live together. Split by responsibility, not by technical layer.
|
|
37
|
+
- In existing codebases, follow established patterns. If the codebase uses large files, don't unilaterally restructure - but if a file you're modifying has grown unwieldy, including a split in the plan is reasonable.
|
|
38
|
+
|
|
39
|
+
This structure informs the task decomposition. Each task should produce self-contained changes that make sense independently.
|
|
40
|
+
|
|
41
|
+
## Design Document Header
|
|
42
|
+
|
|
43
|
+
Every `design.md` MUST start with this frontmatter block followed by the header:
|
|
44
|
+
|
|
45
|
+
```yaml
|
|
46
|
+
---
|
|
47
|
+
status: draft # draft | active | archived
|
|
48
|
+
last-aligned: YYYY-MM-DD # ISO date of the most recent alignment with the user
|
|
49
|
+
related-needs: [] # other need-names whose design constrains this one; omit if none
|
|
50
|
+
---
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
```markdown
|
|
54
|
+
# [Need Name] Design
|
|
55
|
+
|
|
56
|
+
**Goal:** [One sentence describing what this builds — should match `prd.md` Problem/Solution]
|
|
57
|
+
|
|
58
|
+
**Architecture:** [2-3 sentences about approach]
|
|
59
|
+
|
|
60
|
+
**Tech Stack:** [Key technologies/libraries]
|
|
61
|
+
|
|
62
|
+
**Out of scope:** [Things this design explicitly does not address — usually inherited from `prd.md` Out of Scope]
|
|
63
|
+
|
|
64
|
+
---
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
State transitions:
|
|
68
|
+
|
|
69
|
+
- `draft` → `active` when the user has explicitly approved key technical trade-offs (A3 gate cleared)
|
|
70
|
+
- `active` → `archived` when superseded or the need is dropped (do not delete the file)
|
|
71
|
+
|
|
72
|
+
## No Placeholders
|
|
73
|
+
|
|
74
|
+
Every step must contain the actual content an engineer needs. These are **plan failures** — never write them:
|
|
75
|
+
- "TBD", "TODO", "implement later", "fill in details"
|
|
76
|
+
- "Add appropriate error handling" / "add validation" / "handle edge cases"
|
|
77
|
+
- "Write tests for the above" (without actual test code)
|
|
78
|
+
- "Similar to Task N" (repeat the code — the engineer may be reading tasks out of order)
|
|
79
|
+
- Steps that describe what to do without showing how (code blocks required for code steps)
|
|
80
|
+
- References to types, functions, or methods not defined in any task
|
|
81
|
+
|
|
82
|
+
## Remember
|
|
83
|
+
- Exact file paths always
|
|
84
|
+
- Complete code in every step — if a step changes code, show the code
|
|
85
|
+
- Exact commands with expected output
|
|
86
|
+
- DRY, YAGNI, TDD, frequent commits
|
|
87
|
+
|
|
88
|
+
## Self-Review
|
|
89
|
+
|
|
90
|
+
After writing the complete plan, look at the spec with fresh eyes and check the plan against it. This is a checklist you run yourself — not a subagent dispatch.
|
|
91
|
+
|
|
92
|
+
**1. PRD coverage:** Skim each section/requirement in `prd.md`. Can you point to a section of `design.md` that addresses it? List any gaps.
|
|
93
|
+
|
|
94
|
+
**2. Placeholder scan:** Search your design for red flags — any of the patterns from the "No Placeholders" section above. Fix them.
|
|
95
|
+
|
|
96
|
+
**3. Type consistency:** Do the types, method signatures, and property names you used across sections match? A function called `clearLayers()` in §3 but `clearFullLayers()` in §7 is a bug.
|
|
97
|
+
|
|
98
|
+
**4. ADR promotion check:** Does any decision in this design affect MORE THAN ONE need? If yes, it does not belong in `design.md` — promote it to `spec/ADR/NNNN-<title>.md` (frontmatter `status: proposed`) and reference the ADR from this design. Typical signals: "globally use X", "all needs share Y", "the project standard for Z is...".
|
|
99
|
+
|
|
100
|
+
If you find issues, fix them inline. No need to re-review — just fix and move on. If you find a spec requirement with no task, add the task.
|
|
101
|
+
|
|
102
|
+
## After Saving
|
|
103
|
+
|
|
104
|
+
1. Update `spec/INDEX.md`:
|
|
105
|
+
- Set the `design` column to `active` (or `draft` if key trade-offs still need user approval)
|
|
106
|
+
- Recompute the `当前节点` column per the rules in `spec/AGENTS.md` §INDEX 推导规则
|
|
107
|
+
- If unsure, run `ae index-rebuild` for an idempotent rescan
|
|
108
|
+
2. If you promoted any decision to `spec/ADR/`, also add a row under `## ADR` in `INDEX.md`.
|
|
109
|
+
3. Hand off to the next S1 node: A4 `to-issues` will read this `design.md` and produce `spec/needs/<need-name>/todo.md`. Tell the user the design is ready and recommend invoking `to-issues` next.
|
|
110
|
+
|
|
111
|
+
## Boundaries
|
|
112
|
+
|
|
113
|
+
- This skill writes ONLY `spec/needs/<need-name>/design.md` (plus the INDEX row, and optionally a new ADR). It does NOT write `todo.md` or any task-level checklist — that is A4.
|
|
114
|
+
- The design captures HOW (technical decisions, modules, interfaces, data flow, key trade-offs). It does NOT re-capture WHAT — refer back to `prd.md` instead.
|
|
115
|
+
- Decisions affecting MORE THAN ONE need belong in `spec/ADR/`, not here (see Self-Review step 4).
|
package/skills/zoom-out/SKILL.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: zoom-out
|
|
3
|
-
description: Tell the agent to zoom out and give broader context or a higher-level perspective. Use when you're unfamiliar with a section of code or need to understand how it fits into the bigger picture.
|
|
4
|
-
disable-model-invocation: true
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
I don't know this area of code well. Go up a layer of abstraction. Give me a map of all the relevant modules and callers, using the project's domain glossary vocabulary.
|
|
1
|
+
---
|
|
2
|
+
name: zoom-out
|
|
3
|
+
description: Tell the agent to zoom out and give broader context or a higher-level perspective. Use when you're unfamiliar with a section of code or need to understand how it fits into the bigger picture.
|
|
4
|
+
disable-model-invocation: true
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
I don't know this area of code well. Go up a layer of abstraction. Give me a map of all the relevant modules and callers, using the project's domain glossary vocabulary.
|
package/src/cli.js
CHANGED
|
@@ -1,61 +1,61 @@
|
|
|
1
|
-
import { readFile } from 'node:fs/promises';
|
|
2
|
-
import path from 'node:path';
|
|
3
|
-
import { packageRoot } from './utils/paths.js';
|
|
4
|
-
|
|
5
|
-
const HELP = `Usage: ae <command> [options]
|
|
6
|
-
|
|
7
|
-
Commands:
|
|
8
|
-
setup Install skills to selected AI coding platforms.
|
|
9
|
-
init [goal] Create
|
|
10
|
-
Requires \`ae setup\` to have run.
|
|
11
|
-
|
|
12
|
-
Options:
|
|
13
|
-
-h, --help Show help
|
|
14
|
-
-v, --version Show version
|
|
15
|
-
|
|
16
|
-
Typical workflow:
|
|
17
|
-
ae setup
|
|
18
|
-
ae init "<one-line project goal>"`;
|
|
19
|
-
|
|
20
|
-
export async function run(argv = []) {
|
|
21
|
-
try {
|
|
22
|
-
const [command, ...rest] = argv;
|
|
23
|
-
|
|
24
|
-
if (!command || command === '--help' || command === '-h') {
|
|
25
|
-
console.log(HELP);
|
|
26
|
-
return 0;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
if (command === '--version' || command === '-v') {
|
|
30
|
-
console.log(await readVersion());
|
|
31
|
-
return 0;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
if (command === 'setup') {
|
|
35
|
-
const mod = await import('./commands/setup.js');
|
|
36
|
-
return await mod.run(rest);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
if (command === 'init') {
|
|
40
|
-
const mod = await import('./commands/init.js');
|
|
41
|
-
return await mod.run(rest);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
console.error(`Unknown command: ${command}`);
|
|
45
|
-
console.error('');
|
|
46
|
-
console.error(HELP);
|
|
47
|
-
process.exitCode = 1;
|
|
48
|
-
return 1;
|
|
49
|
-
} catch (error) {
|
|
50
|
-
console.error(error instanceof Error ? error.message : String(error));
|
|
51
|
-
process.exitCode = 1;
|
|
52
|
-
return 1;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
async function readVersion() {
|
|
57
|
-
const packageJson = JSON.parse(
|
|
58
|
-
await readFile(path.join(packageRoot(), 'package.json'), 'utf8'),
|
|
59
|
-
);
|
|
60
|
-
return packageJson.version;
|
|
61
|
-
}
|
|
1
|
+
import { readFile } from 'node:fs/promises';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { packageRoot } from './utils/paths.js';
|
|
4
|
+
|
|
5
|
+
const HELP = `Usage: ae <command> [options]
|
|
6
|
+
|
|
7
|
+
Commands:
|
|
8
|
+
setup Install skills to selected AI coding platforms.
|
|
9
|
+
init [goal] Create the project skeleton and render entry files.
|
|
10
|
+
Requires \`ae setup\` to have run.
|
|
11
|
+
|
|
12
|
+
Options:
|
|
13
|
+
-h, --help Show help
|
|
14
|
+
-v, --version Show version
|
|
15
|
+
|
|
16
|
+
Typical workflow:
|
|
17
|
+
ae setup
|
|
18
|
+
ae init "<one-line project goal>"`;
|
|
19
|
+
|
|
20
|
+
export async function run(argv = []) {
|
|
21
|
+
try {
|
|
22
|
+
const [command, ...rest] = argv;
|
|
23
|
+
|
|
24
|
+
if (!command || command === '--help' || command === '-h') {
|
|
25
|
+
console.log(HELP);
|
|
26
|
+
return 0;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if (command === '--version' || command === '-v') {
|
|
30
|
+
console.log(await readVersion());
|
|
31
|
+
return 0;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (command === 'setup') {
|
|
35
|
+
const mod = await import('./commands/setup.js');
|
|
36
|
+
return await mod.run(rest);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (command === 'init') {
|
|
40
|
+
const mod = await import('./commands/init.js');
|
|
41
|
+
return await mod.run(rest);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
console.error(`Unknown command: ${command}`);
|
|
45
|
+
console.error('');
|
|
46
|
+
console.error(HELP);
|
|
47
|
+
process.exitCode = 1;
|
|
48
|
+
return 1;
|
|
49
|
+
} catch (error) {
|
|
50
|
+
console.error(error instanceof Error ? error.message : String(error));
|
|
51
|
+
process.exitCode = 1;
|
|
52
|
+
return 1;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
async function readVersion() {
|
|
57
|
+
const packageJson = JSON.parse(
|
|
58
|
+
await readFile(path.join(packageRoot(), 'package.json'), 'utf8'),
|
|
59
|
+
);
|
|
60
|
+
return packageJson.version;
|
|
61
|
+
}
|
package/src/commands/init.js
CHANGED
|
@@ -1,137 +1,137 @@
|
|
|
1
|
-
import { mkdir, stat } from 'node:fs/promises';
|
|
2
|
-
import path from 'node:path';
|
|
3
|
-
import { createDirectories, renderEntryFiles } from '../skeleton.js';
|
|
4
|
-
import { templatesPath } from '../utils/paths.js';
|
|
5
|
-
import { formatInitReport } from '../utils/report.js';
|
|
6
|
-
import { PLATFORMS, getPlatformSkillsDir } from '../platforms.js';
|
|
7
|
-
|
|
8
|
-
const DEFAULT_GOAL = 'TODO: 用一句话说明这个项目要解决什么问题。';
|
|
9
|
-
|
|
10
|
-
const HELP = `Usage: ae init [goal] [options]
|
|
11
|
-
|
|
12
|
-
Options:
|
|
13
|
-
--target <path> Initialize this project directory. Defaults to cwd.
|
|
14
|
-
--dry-run Show what would be created without writing files.
|
|
15
|
-
-h, --help Show help`;
|
|
16
|
-
|
|
17
|
-
export async function run(argv = []) {
|
|
18
|
-
const options = parseArgs(argv);
|
|
19
|
-
|
|
20
|
-
if (options.help) {
|
|
21
|
-
console.log(HELP);
|
|
22
|
-
return 0;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
const target = path.resolve(options.target ?? process.cwd());
|
|
26
|
-
|
|
27
|
-
try {
|
|
28
|
-
await ensureTargetDirectory(target, options.dryRun);
|
|
29
|
-
if (!(await hasInstalledAssets(target))) {
|
|
30
|
-
console.error(`Error: AE assets not found in ${target}.`);
|
|
31
|
-
console.error('Run `ae setup` first.');
|
|
32
|
-
process.exitCode = 1;
|
|
33
|
-
return 1;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const projectName = path.basename(target);
|
|
37
|
-
const projectGoal = options.goal ?? DEFAULT_GOAL;
|
|
38
|
-
const created = [];
|
|
39
|
-
const skipped = [];
|
|
40
|
-
|
|
41
|
-
const dirs = await createDirectories(target, { dryRun: options.dryRun });
|
|
42
|
-
created.push(...dirs.created);
|
|
43
|
-
skipped.push(...dirs.skipped);
|
|
44
|
-
|
|
45
|
-
const entries = await renderEntryFiles(target, templatesPath('entries'), {
|
|
46
|
-
projectName,
|
|
47
|
-
projectGoal,
|
|
48
|
-
dryRun: options.dryRun,
|
|
49
|
-
});
|
|
50
|
-
created.push(...entries.created);
|
|
51
|
-
skipped.push(...entries.skipped);
|
|
52
|
-
|
|
53
|
-
console.log(formatInitReport({ created, skipped, target, dryRun: options.dryRun }));
|
|
54
|
-
return 0;
|
|
55
|
-
} catch (error) {
|
|
56
|
-
console.error(`AE init failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
57
|
-
process.exitCode = 1;
|
|
58
|
-
return 1;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
function parseArgs(argv) {
|
|
63
|
-
const options = {
|
|
64
|
-
target: undefined,
|
|
65
|
-
goalParts: [],
|
|
66
|
-
dryRun: false,
|
|
67
|
-
help: false,
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
for (let index = 0; index < argv.length; index += 1) {
|
|
71
|
-
const arg = argv[index];
|
|
72
|
-
if (arg === '--help' || arg === '-h') {
|
|
73
|
-
options.help = true;
|
|
74
|
-
} else if (arg === '--dry-run') {
|
|
75
|
-
options.dryRun = true;
|
|
76
|
-
} else if (arg === '--target') {
|
|
77
|
-
const value = argv[index + 1];
|
|
78
|
-
if (!value) {
|
|
79
|
-
throw new Error('--target requires a path');
|
|
80
|
-
}
|
|
81
|
-
options.target = value;
|
|
82
|
-
index += 1;
|
|
83
|
-
} else if (arg.startsWith('-')) {
|
|
84
|
-
throw new Error(`Unknown option for init: ${arg}`);
|
|
85
|
-
} else {
|
|
86
|
-
options.goalParts.push(arg);
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
return {
|
|
91
|
-
target: options.target,
|
|
92
|
-
dryRun: options.dryRun,
|
|
93
|
-
help: options.help,
|
|
94
|
-
goal: options.goalParts.length > 0 ? options.goalParts.join(' ') : undefined,
|
|
95
|
-
};
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
async function ensureTargetDirectory(target, dryRun) {
|
|
99
|
-
try {
|
|
100
|
-
const current = await stat(target);
|
|
101
|
-
if (!current.isDirectory()) {
|
|
102
|
-
throw new Error(`target exists but is not a directory: ${target}`);
|
|
103
|
-
}
|
|
104
|
-
} catch (error) {
|
|
105
|
-
if (error?.code !== 'ENOENT') {
|
|
106
|
-
throw error;
|
|
107
|
-
}
|
|
108
|
-
if (!dryRun) {
|
|
109
|
-
await mkdir(target, { recursive: true });
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
async function hasInstalledAssets(target) {
|
|
115
|
-
for (const platform of PLATFORMS) {
|
|
116
|
-
if (await isDirectory(path.join(target, getPlatformSkillsDir(platform)))) {
|
|
117
|
-
return true;
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
return false;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
async function statMaybe(value) {
|
|
124
|
-
try {
|
|
125
|
-
return await stat(value);
|
|
126
|
-
} catch (error) {
|
|
127
|
-
if (error?.code === 'ENOENT') {
|
|
128
|
-
return undefined;
|
|
129
|
-
}
|
|
130
|
-
throw error;
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
async function isDirectory(value) {
|
|
135
|
-
const current = await statMaybe(value);
|
|
136
|
-
return Boolean(current?.isDirectory());
|
|
137
|
-
}
|
|
1
|
+
import { mkdir, stat } from 'node:fs/promises';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { createDirectories, renderEntryFiles } from '../skeleton.js';
|
|
4
|
+
import { templatesPath } from '../utils/paths.js';
|
|
5
|
+
import { formatInitReport } from '../utils/report.js';
|
|
6
|
+
import { PLATFORMS, getPlatformSkillsDir } from '../platforms.js';
|
|
7
|
+
|
|
8
|
+
const DEFAULT_GOAL = 'TODO: 用一句话说明这个项目要解决什么问题。';
|
|
9
|
+
|
|
10
|
+
const HELP = `Usage: ae init [goal] [options]
|
|
11
|
+
|
|
12
|
+
Options:
|
|
13
|
+
--target <path> Initialize this project directory. Defaults to cwd.
|
|
14
|
+
--dry-run Show what would be created without writing files.
|
|
15
|
+
-h, --help Show help`;
|
|
16
|
+
|
|
17
|
+
export async function run(argv = []) {
|
|
18
|
+
const options = parseArgs(argv);
|
|
19
|
+
|
|
20
|
+
if (options.help) {
|
|
21
|
+
console.log(HELP);
|
|
22
|
+
return 0;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const target = path.resolve(options.target ?? process.cwd());
|
|
26
|
+
|
|
27
|
+
try {
|
|
28
|
+
await ensureTargetDirectory(target, options.dryRun);
|
|
29
|
+
if (!(await hasInstalledAssets(target))) {
|
|
30
|
+
console.error(`Error: AE assets not found in ${target}.`);
|
|
31
|
+
console.error('Run `ae setup` first.');
|
|
32
|
+
process.exitCode = 1;
|
|
33
|
+
return 1;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const projectName = path.basename(target);
|
|
37
|
+
const projectGoal = options.goal ?? DEFAULT_GOAL;
|
|
38
|
+
const created = [];
|
|
39
|
+
const skipped = [];
|
|
40
|
+
|
|
41
|
+
const dirs = await createDirectories(target, { dryRun: options.dryRun });
|
|
42
|
+
created.push(...dirs.created);
|
|
43
|
+
skipped.push(...dirs.skipped);
|
|
44
|
+
|
|
45
|
+
const entries = await renderEntryFiles(target, templatesPath('entries'), {
|
|
46
|
+
projectName,
|
|
47
|
+
projectGoal,
|
|
48
|
+
dryRun: options.dryRun,
|
|
49
|
+
});
|
|
50
|
+
created.push(...entries.created);
|
|
51
|
+
skipped.push(...entries.skipped);
|
|
52
|
+
|
|
53
|
+
console.log(formatInitReport({ created, skipped, target, dryRun: options.dryRun }));
|
|
54
|
+
return 0;
|
|
55
|
+
} catch (error) {
|
|
56
|
+
console.error(`AE init failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
57
|
+
process.exitCode = 1;
|
|
58
|
+
return 1;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function parseArgs(argv) {
|
|
63
|
+
const options = {
|
|
64
|
+
target: undefined,
|
|
65
|
+
goalParts: [],
|
|
66
|
+
dryRun: false,
|
|
67
|
+
help: false,
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
for (let index = 0; index < argv.length; index += 1) {
|
|
71
|
+
const arg = argv[index];
|
|
72
|
+
if (arg === '--help' || arg === '-h') {
|
|
73
|
+
options.help = true;
|
|
74
|
+
} else if (arg === '--dry-run') {
|
|
75
|
+
options.dryRun = true;
|
|
76
|
+
} else if (arg === '--target') {
|
|
77
|
+
const value = argv[index + 1];
|
|
78
|
+
if (!value) {
|
|
79
|
+
throw new Error('--target requires a path');
|
|
80
|
+
}
|
|
81
|
+
options.target = value;
|
|
82
|
+
index += 1;
|
|
83
|
+
} else if (arg.startsWith('-')) {
|
|
84
|
+
throw new Error(`Unknown option for init: ${arg}`);
|
|
85
|
+
} else {
|
|
86
|
+
options.goalParts.push(arg);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
return {
|
|
91
|
+
target: options.target,
|
|
92
|
+
dryRun: options.dryRun,
|
|
93
|
+
help: options.help,
|
|
94
|
+
goal: options.goalParts.length > 0 ? options.goalParts.join(' ') : undefined,
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
async function ensureTargetDirectory(target, dryRun) {
|
|
99
|
+
try {
|
|
100
|
+
const current = await stat(target);
|
|
101
|
+
if (!current.isDirectory()) {
|
|
102
|
+
throw new Error(`target exists but is not a directory: ${target}`);
|
|
103
|
+
}
|
|
104
|
+
} catch (error) {
|
|
105
|
+
if (error?.code !== 'ENOENT') {
|
|
106
|
+
throw error;
|
|
107
|
+
}
|
|
108
|
+
if (!dryRun) {
|
|
109
|
+
await mkdir(target, { recursive: true });
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
async function hasInstalledAssets(target) {
|
|
115
|
+
for (const platform of PLATFORMS) {
|
|
116
|
+
if (await isDirectory(path.join(target, getPlatformSkillsDir(platform)))) {
|
|
117
|
+
return true;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
return false;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
async function statMaybe(value) {
|
|
124
|
+
try {
|
|
125
|
+
return await stat(value);
|
|
126
|
+
} catch (error) {
|
|
127
|
+
if (error?.code === 'ENOENT') {
|
|
128
|
+
return undefined;
|
|
129
|
+
}
|
|
130
|
+
throw error;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
async function isDirectory(value) {
|
|
135
|
+
const current = await statMaybe(value);
|
|
136
|
+
return Boolean(current?.isDirectory());
|
|
137
|
+
}
|