@aperant/framework 0.6.4 → 0.6.6
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/CHANGELOG.md +38 -0
- package/README.md +54 -234
- package/agents/apt-improver.md +99 -0
- package/agents/apt-planner.md +115 -10
- package/dist/__test-helpers/run-cmd.d.mts +4 -2
- package/dist/__test-helpers/run-cmd.d.mts.map +1 -1
- package/dist/__test-helpers/run-cmd.mjs +56 -15
- package/dist/__test-helpers/run-cmd.mjs.map +1 -1
- package/dist/cli/ci-watch/lock.d.mts +53 -0
- package/dist/cli/ci-watch/lock.d.mts.map +1 -0
- package/dist/cli/ci-watch/lock.mjs +172 -0
- package/dist/cli/ci-watch/lock.mjs.map +1 -0
- package/dist/cli/ci-watch/state.d.mts +36 -0
- package/dist/cli/ci-watch/state.d.mts.map +1 -0
- package/dist/cli/ci-watch/state.mjs +103 -0
- package/dist/cli/ci-watch/state.mjs.map +1 -0
- package/dist/cli/ci-watch/stop-matrix.d.mts +58 -0
- package/dist/cli/ci-watch/stop-matrix.d.mts.map +1 -0
- package/dist/cli/ci-watch/stop-matrix.mjs +164 -0
- package/dist/cli/ci-watch/stop-matrix.mjs.map +1 -0
- package/dist/cli/cli-wrappers/ci-watch.d.mts +2 -0
- package/dist/cli/cli-wrappers/ci-watch.d.mts.map +1 -0
- package/dist/cli/cli-wrappers/ci-watch.mjs +9 -0
- package/dist/cli/cli-wrappers/ci-watch.mjs.map +1 -0
- package/dist/cli/commands/adr.d.mts +5 -0
- package/dist/cli/commands/adr.d.mts.map +1 -0
- package/dist/cli/commands/adr.mjs +228 -0
- package/dist/cli/commands/adr.mjs.map +1 -0
- package/dist/cli/commands/ci-watch.d.mts +7 -0
- package/dist/cli/commands/ci-watch.d.mts.map +1 -0
- package/dist/cli/commands/ci-watch.mjs +465 -0
- package/dist/cli/commands/ci-watch.mjs.map +1 -0
- package/dist/cli/commands/commit.d.mts.map +1 -1
- package/dist/cli/commands/commit.mjs +25 -8
- package/dist/cli/commands/commit.mjs.map +1 -1
- package/dist/cli/commands/context.d.mts +7 -0
- package/dist/cli/commands/context.d.mts.map +1 -0
- package/dist/cli/commands/context.mjs +224 -0
- package/dist/cli/commands/context.mjs.map +1 -0
- package/dist/cli/commands/event.d.mts.map +1 -1
- package/dist/cli/commands/event.mjs +125 -24
- package/dist/cli/commands/event.mjs.map +1 -1
- package/dist/cli/commands/host-detect.d.mts +1 -1
- package/dist/cli/commands/host-detect.d.mts.map +1 -1
- package/dist/cli/commands/host-detect.mjs +30 -3
- package/dist/cli/commands/host-detect.mjs.map +1 -1
- package/dist/cli/commands/modes.d.mts +13 -0
- package/dist/cli/commands/modes.d.mts.map +1 -0
- package/dist/cli/commands/modes.mjs +221 -0
- package/dist/cli/commands/modes.mjs.map +1 -0
- package/dist/cli/commands/route.mjs +1 -1
- package/dist/cli/commands/route.mjs.map +1 -1
- package/dist/cli/commands/task.d.mts.map +1 -1
- package/dist/cli/commands/task.mjs +393 -145
- package/dist/cli/commands/task.mjs.map +1 -1
- package/dist/cli/commands/tokens.d.mts.map +1 -1
- package/dist/cli/commands/tokens.mjs +150 -6
- package/dist/cli/commands/tokens.mjs.map +1 -1
- package/dist/cli/commands/triage.d.mts +8 -0
- package/dist/cli/commands/triage.d.mts.map +1 -0
- package/dist/cli/commands/triage.mjs +263 -0
- package/dist/cli/commands/triage.mjs.map +1 -0
- package/dist/cli/config/post-merge-sweep.d.mts +18 -0
- package/dist/cli/config/post-merge-sweep.d.mts.map +1 -1
- package/dist/cli/config/post-merge-sweep.mjs +48 -3
- package/dist/cli/config/post-merge-sweep.mjs.map +1 -1
- package/dist/cli/consistency/registry.d.mts +11 -0
- package/dist/cli/consistency/registry.d.mts.map +1 -1
- package/dist/cli/consistency/registry.mjs +13 -0
- package/dist/cli/consistency/registry.mjs.map +1 -1
- package/dist/cli/coordination/agent-identity.d.mts +9 -0
- package/dist/cli/coordination/agent-identity.d.mts.map +1 -1
- package/dist/cli/coordination/agent-identity.mjs +11 -0
- package/dist/cli/coordination/agent-identity.mjs.map +1 -1
- package/dist/cli/coordination/auto-emit-artifact-ready.d.mts +16 -0
- package/dist/cli/coordination/auto-emit-artifact-ready.d.mts.map +1 -0
- package/dist/cli/coordination/auto-emit-artifact-ready.mjs +88 -0
- package/dist/cli/coordination/auto-emit-artifact-ready.mjs.map +1 -0
- package/dist/cli/coordination/event-log.d.mts +27 -0
- package/dist/cli/coordination/event-log.d.mts.map +1 -1
- package/dist/cli/coordination/event-log.mjs +72 -2
- package/dist/cli/coordination/event-log.mjs.map +1 -1
- package/dist/cli/coordination/event-schema.d.mts +16 -0
- package/dist/cli/coordination/event-schema.d.mts.map +1 -0
- package/dist/cli/coordination/event-schema.mjs +161 -0
- package/dist/cli/coordination/event-schema.mjs.map +1 -0
- package/dist/cli/coordination/store.d.mts +6 -0
- package/dist/cli/coordination/store.d.mts.map +1 -1
- package/dist/cli/coordination/store.mjs +14 -0
- package/dist/cli/coordination/store.mjs.map +1 -1
- package/dist/cli/dispatch.d.mts.map +1 -1
- package/dist/cli/dispatch.mjs +14 -1
- package/dist/cli/dispatch.mjs.map +1 -1
- package/dist/cli/gate/registry.d.mts +11 -0
- package/dist/cli/gate/registry.d.mts.map +1 -1
- package/dist/cli/gate/registry.mjs +13 -0
- package/dist/cli/gate/registry.mjs.map +1 -1
- package/dist/cli/help.d.mts.map +1 -1
- package/dist/cli/help.mjs +3 -2
- package/dist/cli/help.mjs.map +1 -1
- package/dist/cli/host/detect.d.mts +1 -0
- package/dist/cli/host/detect.d.mts.map +1 -1
- package/dist/cli/host/detect.mjs +5 -0
- package/dist/cli/host/detect.mjs.map +1 -1
- package/dist/cli/roadmap/conductor-view.d.mts +13 -0
- package/dist/cli/roadmap/conductor-view.d.mts.map +1 -0
- package/dist/cli/roadmap/conductor-view.mjs +31 -0
- package/dist/cli/roadmap/conductor-view.mjs.map +1 -0
- package/dist/cli/route/envelope.d.mts +68 -4
- package/dist/cli/route/envelope.d.mts.map +1 -1
- package/dist/cli/route/envelope.mjs +140 -103
- package/dist/cli/route/envelope.mjs.map +1 -1
- package/dist/cli/route/skill-discover.d.mts +9 -0
- package/dist/cli/route/skill-discover.d.mts.map +1 -1
- package/dist/cli/route/skill-discover.mjs +13 -1
- package/dist/cli/route/skill-discover.mjs.map +1 -1
- package/dist/cli/skill-author/contract.d.mts +1 -0
- package/dist/cli/skill-author/contract.d.mts.map +1 -1
- package/dist/cli/skill-author/contract.mjs +7 -0
- package/dist/cli/skill-author/contract.mjs.map +1 -1
- package/dist/cli/task/ids.d.mts +7 -4
- package/dist/cli/task/ids.d.mts.map +1 -1
- package/dist/cli/task/ids.mjs +11 -10
- package/dist/cli/task/ids.mjs.map +1 -1
- package/dist/cli/task/worktree-cleanup.d.mts +9 -1
- package/dist/cli/task/worktree-cleanup.d.mts.map +1 -1
- package/dist/cli/task/worktree-cleanup.mjs +190 -9
- package/dist/cli/task/worktree-cleanup.mjs.map +1 -1
- package/dist/plugin/.claude-plugin/plugin.json +1 -1
- package/dist/plugin/agents/apt-planner.md +1 -1
- package/dist/plugin/skills/apt/SKILL.md +111 -5
- package/dist/plugin/skills/apt-author-skill/SKILL.md +11 -0
- package/dist/plugin/skills/apt-bootstrap/SKILL.md +1 -0
- package/dist/plugin/skills/apt-classify/SKILL.md +1 -0
- package/dist/plugin/skills/apt-close-task/SKILL.md +1 -0
- package/dist/plugin/skills/apt-create-docs/SKILL.md +1 -0
- package/dist/plugin/skills/apt-debug/SKILL.md +2 -0
- package/dist/plugin/skills/apt-design/SKILL.md +2 -0
- package/dist/plugin/skills/apt-discuss/SKILL.md +2 -0
- package/dist/plugin/skills/apt-docs/SKILL.md +2 -0
- package/dist/plugin/skills/apt-execute/SKILL.md +1 -0
- package/dist/plugin/skills/apt-mockup/SKILL.md +2 -0
- package/dist/plugin/skills/apt-pause/SKILL.md +1 -0
- package/dist/plugin/skills/apt-personas/SKILL.md +1 -0
- package/dist/plugin/skills/apt-plan/SKILL.md +2 -0
- package/dist/plugin/skills/apt-pr-review/SKILL.md +1 -0
- package/dist/plugin/skills/apt-quick/SKILL.md +2 -0
- package/dist/plugin/skills/apt-resume/SKILL.md +1 -0
- package/dist/plugin/skills/apt-review/SKILL.md +1 -0
- package/dist/plugin/skills/apt-roadmap/SKILL.md +1 -0
- package/dist/plugin/skills/apt-roundtable/SKILL.md +2 -0
- package/dist/plugin/skills/apt-run/SKILL.md +1 -0
- package/dist/plugin/skills/apt-scan/SKILL.md +1 -0
- package/dist/plugin/skills/apt-setup/SKILL.md +1 -0
- package/dist/plugin/skills/apt-ship/SKILL.md +6 -5
- package/dist/plugin/skills/apt-stress-test/SKILL.md +1 -0
- package/dist/plugin/skills/apt-terminal/SKILL.md +1 -0
- package/dist/plugin/skills/apt-update/SKILL.md +5 -0
- package/dist/plugin/skills/apt-verify/SKILL.md +1 -0
- package/dist/plugin/skills/apt-verify-proof/SKILL.md +1 -0
- package/dist/types/config.d.ts +85 -0
- package/dist/types/config.d.ts.map +1 -1
- package/package.json +9 -1
- package/prompts/coder.md +2 -0
- package/prompts/conductor-status-check.md +23 -0
- package/prompts/conductor-sub-agent.md +57 -0
- package/prompts/conductor-system.md +172 -0
- package/prompts/planner.md +12 -0
- package/prompts/spec_writer.md +9 -0
- package/skills/apt/SKILL.md +1 -0
- package/skills/apt-close-task/SKILL.md +32 -1
- package/skills/apt-debug/SKILL.md +39 -6
- package/skills/apt-debug/appendices/diagnose-discipline.md +119 -0
- package/skills/apt-diagram/SKILL.md +342 -0
- package/skills/apt-diagram/appendices/design-discipline.md +97 -0
- package/skills/apt-discuss/SKILL.md +25 -0
- package/skills/apt-discuss/appendices/grill-discipline.md +104 -0
- package/skills/apt-discuss/appendices/zoom-out-helper.md +79 -0
- package/skills/apt-execute/SKILL.md +48 -5
- package/skills/apt-execute/appendices/tdd-mode.md +107 -0
- package/skills/apt-improve/DEEPENING.md +84 -0
- package/skills/apt-improve/INTERFACE-DESIGN.md +97 -0
- package/skills/apt-improve/LANGUAGE.md +104 -0
- package/skills/apt-improve/SKILL.md +141 -0
- package/skills/apt-plan/SKILL.md +159 -4
- package/skills/apt-plan/adapters/conductor.md +98 -0
- package/skills/apt-planner.md +42 -1
- package/skills/apt-pr-review/SKILL.md +46 -16
- package/skills/apt-prototype/LOGIC.md +109 -0
- package/skills/apt-prototype/SKILL.md +143 -0
- package/skills/apt-prototype/UI.md +90 -0
- package/skills/apt-quick/SKILL.md +30 -0
- package/skills/apt-review/SKILL.md +2 -0
- package/skills/apt-run/SKILL.md +32 -4
- package/skills/apt-setup/SKILL.md +130 -2
- package/skills/apt-ship/SKILL.md +63 -1
- package/skills/apt-spar/SKILL.md +290 -0
- package/skills/apt-triage/AGENT-BRIEF.md +84 -0
- package/skills/apt-triage/OUT-OF-SCOPE.md +75 -0
- package/skills/apt-triage/SKILL.md +169 -0
- package/skills/apt-verify/SKILL.md +3 -0
- package/skills/apt-verify-proof/SKILL.md +3 -0
- package/skills/apt-watch-ci/SKILL.md +163 -0
- package/skills/apt-zoom-out/SKILL.md +130 -0
- package/src/cli/ci-watch/lock.mjs +178 -0
- package/src/cli/ci-watch/state.mjs +103 -0
- package/src/cli/ci-watch/stop-matrix.mjs +181 -0
- package/src/cli/cli-wrappers/ci-watch.mjs +9 -0
- package/src/cli/commands/adr.mjs +243 -0
- package/src/cli/commands/ci-watch.mjs +503 -0
- package/src/cli/commands/commit.mjs +27 -8
- package/src/cli/commands/context.mjs +244 -0
- package/src/cli/commands/event.mjs +131 -24
- package/src/cli/commands/host-detect.mjs +33 -7
- package/src/cli/commands/modes.mjs +216 -0
- package/src/cli/commands/route.mjs +1 -1
- package/src/cli/commands/task.mjs +430 -170
- package/src/cli/commands/tokens.mjs +157 -6
- package/src/cli/commands/triage.mjs +286 -0
- package/src/cli/config/post-merge-sweep.mjs +49 -3
- package/src/cli/consistency/registry.mjs +14 -0
- package/src/cli/coordination/agent-identity.mjs +12 -0
- package/src/cli/coordination/auto-emit-artifact-ready.mjs +96 -0
- package/src/cli/coordination/event-log.mjs +73 -2
- package/src/cli/coordination/event-schema.d.ts +13 -0
- package/src/cli/coordination/event-schema.mjs +174 -0
- package/src/cli/coordination/store.mjs +14 -0
- package/src/cli/dispatch.mjs +15 -1
- package/src/cli/gate/registry.mjs +14 -0
- package/src/cli/help.mjs +3 -2
- package/src/cli/host/detect.mjs +5 -0
- package/src/cli/roadmap/conductor-view.d.ts +10 -0
- package/src/cli/roadmap/conductor-view.mjs +31 -0
- package/src/cli/route/envelope.mjs +140 -106
- package/src/cli/route/skill-discover.mjs +14 -1
- package/src/cli/skill-author/contract.mjs +7 -0
- package/src/cli/task/ids.mjs +15 -13
- package/src/cli/task/worktree-cleanup.mjs +191 -9
- package/templates/adr-format.md +56 -0
- package/templates/config.json +4 -0
- package/templates/context-format.md +34 -0
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* commands/modes.mjs — `apt-tools modes list` (Pocock adoption ST-13, AC12).
|
|
3
|
+
*
|
|
4
|
+
* Power-user discoverability tool. Returns a JSON envelope with one
|
|
5
|
+
* record per discovered skill, exposing modes / flags / content-formats /
|
|
6
|
+
* config-driven behavior so a power user can build a mental model of
|
|
7
|
+
* the framework without reading 30 SKILL.md files.
|
|
8
|
+
*
|
|
9
|
+
* Adding a new skill auto-appears in `modes list` output without any
|
|
10
|
+
* code changes — the discovery is filesystem-scan-based (mirrors the
|
|
11
|
+
* router's eager skill-discover module).
|
|
12
|
+
*
|
|
13
|
+
* CLI:
|
|
14
|
+
* apt-tools modes list [project-dir]
|
|
15
|
+
*
|
|
16
|
+
* Output envelope:
|
|
17
|
+
* { status: 'ok', command: 'modes-list',
|
|
18
|
+
* skills: [{ name, modes, flags, content_formats, config_keys, file_path }] }
|
|
19
|
+
*
|
|
20
|
+
* Field semantics:
|
|
21
|
+
* - name — frontmatter `name` (e.g. "apt:plan")
|
|
22
|
+
* - modes — frontmatter `execution_modes` (array)
|
|
23
|
+
* - flags — parsed from frontmatter `argument-hint`
|
|
24
|
+
* - content_formats — frontmatter `produces` (optional array; [] when absent)
|
|
25
|
+
* - config_keys — hardcoded skill→config-paths map maintained inline
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
import { existsSync, readdirSync, readFileSync, statSync } from 'node:fs'
|
|
29
|
+
import { join, resolve } from 'node:path'
|
|
30
|
+
import { parse as parseYaml } from 'yaml'
|
|
31
|
+
import { sanitizeAptVersionForYamlParse } from '../install/version-header.mjs'
|
|
32
|
+
import { ok } from '../util/result.mjs'
|
|
33
|
+
|
|
34
|
+
const FRONTMATTER_RE = /^---\s*([\s\S]*?)\s*---/
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Hardcoded skill→config-paths map. Maintained inline so adding a new
|
|
38
|
+
* config-dependent skill is a one-line change.
|
|
39
|
+
*
|
|
40
|
+
* Per AC12, this is the mapping `modes list` consumes to enumerate
|
|
41
|
+
* which config keys a skill cares about. Skills that don't touch
|
|
42
|
+
* config are omitted (their config_keys is `[]`).
|
|
43
|
+
*
|
|
44
|
+
* @type {Record<string, string[]>}
|
|
45
|
+
*/
|
|
46
|
+
const SKILL_CONFIG_KEYS = {
|
|
47
|
+
'apt:execute': ['coding.tdd_default', 'tdd.iron_law'],
|
|
48
|
+
'apt:triage': [
|
|
49
|
+
'task_tracking.backend',
|
|
50
|
+
'task_tracking.publish_to_tracker',
|
|
51
|
+
'task_tracking.tracker_url',
|
|
52
|
+
'task_tracking.tracker_label_vocabulary',
|
|
53
|
+
],
|
|
54
|
+
'apt:prototype': ['coding.prototype_discipline'],
|
|
55
|
+
'apt:verify': ['verification.evidence_capture', 'verification.max_iterations'],
|
|
56
|
+
'apt:verify-proof': ['verification.open_report', 'verification.report_formats'],
|
|
57
|
+
'apt:review': ['pipeline.skip_review'],
|
|
58
|
+
'apt:ship': ['pipeline.auto_branch', 'pipeline.branch_prefix'],
|
|
59
|
+
'apt:setup': ['*'], // setup edits config — wildcard surface
|
|
60
|
+
'apt:run': ['parallelization.enabled', 'parallelization.max_agents'],
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Parse the `argument-hint` frontmatter field for `--flag` tokens.
|
|
65
|
+
* Returns a deduplicated array.
|
|
66
|
+
*
|
|
67
|
+
* @param {string|undefined} hint
|
|
68
|
+
* @returns {string[]}
|
|
69
|
+
*/
|
|
70
|
+
function parseFlags(hint) {
|
|
71
|
+
if (typeof hint !== 'string') return []
|
|
72
|
+
const flags = new Set()
|
|
73
|
+
for (const m of hint.matchAll(/--[a-z][a-z0-9-]*/gi)) {
|
|
74
|
+
flags.add(m[0])
|
|
75
|
+
}
|
|
76
|
+
return [...flags]
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Walk a skills root and return every apt-<slug>/SKILL.md it contains.
|
|
81
|
+
*
|
|
82
|
+
* @param {string} root
|
|
83
|
+
*/
|
|
84
|
+
function walkSkillRoot(root) {
|
|
85
|
+
if (!existsSync(root)) return []
|
|
86
|
+
let stat
|
|
87
|
+
try {
|
|
88
|
+
stat = statSync(root)
|
|
89
|
+
} catch {
|
|
90
|
+
return []
|
|
91
|
+
}
|
|
92
|
+
if (!stat.isDirectory()) return []
|
|
93
|
+
let entries
|
|
94
|
+
try {
|
|
95
|
+
entries = readdirSync(root, { withFileTypes: true })
|
|
96
|
+
} catch {
|
|
97
|
+
return []
|
|
98
|
+
}
|
|
99
|
+
const out = []
|
|
100
|
+
for (const entry of entries) {
|
|
101
|
+
if (!entry.name.startsWith('apt')) continue
|
|
102
|
+
if (!entry.isDirectory()) continue
|
|
103
|
+
const skillFile = join(root, entry.name, 'SKILL.md')
|
|
104
|
+
if (existsSync(skillFile)) out.push(skillFile)
|
|
105
|
+
}
|
|
106
|
+
return out
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Parse a single SKILL.md into a modes-list record. Returns null if
|
|
111
|
+
* the frontmatter is unparseable.
|
|
112
|
+
*
|
|
113
|
+
* @param {string} file
|
|
114
|
+
*/
|
|
115
|
+
function readSkillForModes(file) {
|
|
116
|
+
let text
|
|
117
|
+
try {
|
|
118
|
+
text = readFileSync(file, 'utf-8')
|
|
119
|
+
} catch {
|
|
120
|
+
return null
|
|
121
|
+
}
|
|
122
|
+
const m = text.match(FRONTMATTER_RE)
|
|
123
|
+
if (!m) return null
|
|
124
|
+
let parsed
|
|
125
|
+
try {
|
|
126
|
+
parsed = parseYaml(sanitizeAptVersionForYamlParse(m[1]))
|
|
127
|
+
} catch {
|
|
128
|
+
return null
|
|
129
|
+
}
|
|
130
|
+
if (parsed === null || typeof parsed !== 'object') return null
|
|
131
|
+
|
|
132
|
+
const name = typeof parsed.name === 'string' ? parsed.name : null
|
|
133
|
+
if (name === null) return null
|
|
134
|
+
|
|
135
|
+
const modes = Array.isArray(parsed.execution_modes)
|
|
136
|
+
? parsed.execution_modes.filter((m) => typeof m === 'string')
|
|
137
|
+
: []
|
|
138
|
+
const flags = parseFlags(parsed['argument-hint'])
|
|
139
|
+
const content_formats = Array.isArray(parsed.produces)
|
|
140
|
+
? parsed.produces.filter((p) => typeof p === 'string')
|
|
141
|
+
: []
|
|
142
|
+
// config_keys: prefer frontmatter `config_keys:` field when present; fall back
|
|
143
|
+
// to the hardcoded SKILL_CONFIG_KEYS map so skills not yet migrated still work.
|
|
144
|
+
const config_keys = Array.isArray(parsed.config_keys)
|
|
145
|
+
? parsed.config_keys.filter((k) => typeof k === 'string')
|
|
146
|
+
: SKILL_CONFIG_KEYS[name] || []
|
|
147
|
+
|
|
148
|
+
return {
|
|
149
|
+
name,
|
|
150
|
+
modes,
|
|
151
|
+
flags,
|
|
152
|
+
content_formats,
|
|
153
|
+
config_keys,
|
|
154
|
+
file_path: file,
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* CLI entry: `apt-tools modes <subcommand> [project-dir]`.
|
|
160
|
+
*
|
|
161
|
+
* Subcommands: `list` (the only v1 subcommand).
|
|
162
|
+
*
|
|
163
|
+
* The trusted-skill-roots discovery follows the same pattern as the
|
|
164
|
+
* router's skill-discover module, but at minimum scans
|
|
165
|
+
* `packages/framework/skills/` relative to the framework checkout. For
|
|
166
|
+
* project-installed skills, the project's `.aperant/deps/.../skills`
|
|
167
|
+
* tree is also scanned when present.
|
|
168
|
+
*/
|
|
169
|
+
export function cmdModes(subcommand, projectDir, _extraArgs) {
|
|
170
|
+
const cmd = subcommand || 'list'
|
|
171
|
+
if (cmd !== 'list') {
|
|
172
|
+
return ok({
|
|
173
|
+
status: 'error',
|
|
174
|
+
command: 'modes',
|
|
175
|
+
error: `Unknown subcommand: ${cmd}. Use 'list'.`,
|
|
176
|
+
})
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
// Project-dir is optional for modes list — defaults to cwd.
|
|
180
|
+
const absProjectDir = projectDir ? resolve(projectDir) : process.cwd()
|
|
181
|
+
|
|
182
|
+
// Compute trusted skill roots. The framework's own skills root
|
|
183
|
+
// (relative to this file) is always included; project-installed
|
|
184
|
+
// roots (.aperant/deps/...) are added when present.
|
|
185
|
+
const roots = new Set()
|
|
186
|
+
// Framework checkout root: this file is at
|
|
187
|
+
// .../packages/framework/src/cli/commands/modes.mjs → 5 levels up
|
|
188
|
+
// to the framework root, then skills/.
|
|
189
|
+
const frameworkRoot = resolve(new URL('../../../skills', import.meta.url).pathname)
|
|
190
|
+
if (existsSync(frameworkRoot)) roots.add(frameworkRoot)
|
|
191
|
+
const projectSkillRoot = join(absProjectDir, 'packages/framework/skills')
|
|
192
|
+
if (existsSync(projectSkillRoot)) roots.add(projectSkillRoot)
|
|
193
|
+
const installedRoot = join(absProjectDir, '.aperant/deps/node_modules/@aperant/framework/skills')
|
|
194
|
+
if (existsSync(installedRoot)) roots.add(installedRoot)
|
|
195
|
+
|
|
196
|
+
const seen = new Set()
|
|
197
|
+
const skills = []
|
|
198
|
+
for (const root of roots) {
|
|
199
|
+
for (const file of walkSkillRoot(root)) {
|
|
200
|
+
const record = readSkillForModes(file)
|
|
201
|
+
if (!record) continue
|
|
202
|
+
if (seen.has(record.name)) continue // first-writer-wins
|
|
203
|
+
seen.add(record.name)
|
|
204
|
+
skills.push(record)
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
skills.sort((a, b) => a.name.localeCompare(b.name))
|
|
208
|
+
|
|
209
|
+
return ok({
|
|
210
|
+
status: 'ok',
|
|
211
|
+
command: 'modes-list',
|
|
212
|
+
project_dir: absProjectDir,
|
|
213
|
+
skills,
|
|
214
|
+
scanned_roots: [...roots],
|
|
215
|
+
})
|
|
216
|
+
}
|