@specdest/devkit 0.4.13 → 0.4.15
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/README.md +1 -1
- package/dist/npm/automation-policy.d.ts +2 -0
- package/dist/npm/automation-policy.js +30 -0
- package/dist/npm/cli.js +6 -0
- package/dist/npm/host-automation.d.ts +9 -0
- package/dist/npm/host-automation.js +52 -0
- package/dist/npm/index.js +5 -1
- package/dist/npm/project-check.js +17 -0
- package/dist/npm/project-rules.js +36 -5
- package/dist/npm/snapshot-cli.d.ts +1 -0
- package/dist/npm/snapshot-cli.js +11 -12
- package/package.json +2 -3
package/README.md
CHANGED
|
@@ -39,7 +39,7 @@ npx @specdest/devkit flow complete
|
|
|
39
39
|
|
|
40
40
|
## AI usage
|
|
41
41
|
|
|
42
|
-
`npx @specdest/devkit ai-instruction` prints the
|
|
42
|
+
`npx @specdest/devkit ai-instruction` prints the development bootstrap for coding agents, including Controller/project instruction discovery, intent-based Flow usage, focused Devkit rule loading, implementation, verification, and commit guidance. Agents should inspect DevKit Flow state before repository work, while semantic task classification and worktree choice remain agent-policy decisions. DevKit Flow owns persisted task state, phase transitions, verification, and completion; DevKit rules/checks own deterministic repository enforcement. Agent-specific policy such as ChatGPT's `@specdest-development` skill belongs outside DevKit rather than being duplicated in the CLI.
|
|
43
43
|
|
|
44
44
|
The CLI resolves a project stack from supported Expo/Vite + Convex/Supabase package dependencies when possible; otherwise it uses the single committed requested `stack-*` root in `.spd/installed.json`. Explicit predefined-package registrations are committed as requested `kind: "package"` entries with separate `recipeVersion` and `detectedVersion` fields, and are preserved by canonical rule sync. Foundational adapters such as Vite use the same recipe mechanism as feature packages; `role` metadata distinguishes frontend/backend/foundation intent without a separate installer architecture. Canonical rules may declare `requiredPackages` (for example `vite` or `supabase`) instead of enumerating every compatible stack; legacy stack applicability remains supported during migration. Optional `.spd/rules.json` adds the project type/capabilities plus explicit rule includes/exclusions; every exclusion requires a reason. `.spd/installed.json` and `.spd/state.json` remain the committed project status used by the Base rules matrix.
|
|
45
45
|
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { readFileSync, existsSync } from 'node:fs';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
const FORBIDDEN = /(?:\b(?:pnpm\s+exec|npx|npm\s+exec|yarn\s+exec|bunx)\s+(?:agent-device|agent-browser|jev-browser)\b|\bhost-cli\s+(?:agent-device|agent-browser|jev-browser)\b|\b(?:SPECDEST_AGENT_DEVICE_BIN|node_modules\/\.bin\/(?:agent-device|agent-browser|jev-browser))\b)/u;
|
|
4
|
+
const DIRECT = new Set(['agent-device', 'agent-browser', 'jev-browser']);
|
|
5
|
+
/** Check project-owned entrypoints; Controller and Devkit are intentionally exempt. */
|
|
6
|
+
export function automationPolicyFindings(root, files) {
|
|
7
|
+
const findings = [];
|
|
8
|
+
const manifestPath = join(root, 'package.json');
|
|
9
|
+
if (existsSync(manifestPath)) {
|
|
10
|
+
const manifest = JSON.parse(readFileSync(manifestPath, 'utf8'));
|
|
11
|
+
for (const field of ['dependencies', 'devDependencies', 'optionalDependencies']) {
|
|
12
|
+
for (const name of Object.keys(manifest[field] ?? {})) {
|
|
13
|
+
if (DIRECT.has(name))
|
|
14
|
+
findings.push(`package.json: ${name} must be accessed via Devkit`);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
for (const file of files) {
|
|
19
|
+
if (!/^(?:scripts\/.*\.(?:sh|js|cjs|mjs|ts|py)|package-scripts\.yml)$/u.test(file))
|
|
20
|
+
continue;
|
|
21
|
+
if (/(?:^|\/)(?:test[^/]*|[^/]*\.test\.[^/]*)$/u.test(file))
|
|
22
|
+
continue;
|
|
23
|
+
const full = join(root, file);
|
|
24
|
+
if (!existsSync(full))
|
|
25
|
+
continue;
|
|
26
|
+
if (FORBIDDEN.test(readFileSync(full, 'utf8')))
|
|
27
|
+
findings.push(`${file}: invoke through specdest device/browser instead of direct host tools`);
|
|
28
|
+
}
|
|
29
|
+
return findings;
|
|
30
|
+
}
|
package/dist/npm/cli.js
CHANGED
|
@@ -3,12 +3,18 @@ import { createFlowCommandHandler, runCli } from "./index.js";
|
|
|
3
3
|
import { createCanonicalCommandHandlers } from "./canonical-project-operations.js";
|
|
4
4
|
import { runSupabaseLocal } from "./supabase-local.js";
|
|
5
5
|
import { sendSlackFiles } from "./slack.js";
|
|
6
|
+
import { runHostAutomation } from "./host-automation.js";
|
|
7
|
+
import { runSnapshot } from "./snapshot-cli.js";
|
|
6
8
|
try {
|
|
7
9
|
const exitCode = await runCli(process.argv.slice(2), process, {
|
|
8
10
|
...createCanonicalCommandHandlers(),
|
|
9
11
|
flow: createFlowCommandHandler(),
|
|
10
12
|
supabase: async (args) => runSupabaseLocal(args),
|
|
11
13
|
slack: async (args) => sendSlackFiles(args),
|
|
14
|
+
device: async (args) => runHostAutomation('device', args),
|
|
15
|
+
browser: async (args) => runHostAutomation('browser', args),
|
|
16
|
+
'jev-browser': async (args) => runHostAutomation('jev-browser', args),
|
|
17
|
+
snapshot: runSnapshot,
|
|
12
18
|
});
|
|
13
19
|
process.exitCode = exitCode;
|
|
14
20
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { spawnSync } from 'node:child_process';
|
|
2
|
+
declare const TOOLS: {
|
|
3
|
+
readonly device: "agent-device";
|
|
4
|
+
readonly browser: "agent-browser";
|
|
5
|
+
readonly 'jev-browser': "jev-browser";
|
|
6
|
+
};
|
|
7
|
+
/** Forward unchanged arguments through Controller's queue, or its trusted NPS host context. */
|
|
8
|
+
export declare function runHostAutomation(command: keyof typeof TOOLS, args: string[], cwd?: string, invoke?: typeof spawnSync, gatewayExists?: (path: string) => boolean, env?: Record<string, string | undefined>): number;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { spawnSync } from 'node:child_process';
|
|
2
|
+
import { existsSync } from 'node:fs';
|
|
3
|
+
import { projectFromCwd } from "./supabase-local.js";
|
|
4
|
+
const TOOLS = {
|
|
5
|
+
device: 'agent-device',
|
|
6
|
+
browser: 'agent-browser',
|
|
7
|
+
'jev-browser': 'jev-browser',
|
|
8
|
+
};
|
|
9
|
+
const NPS_BIN_ENV = {
|
|
10
|
+
device: 'SPECDEST_DEVKIT_AGENT_DEVICE_BIN',
|
|
11
|
+
browser: 'SPECDEST_DEVKIT_AGENT_BROWSER_BIN',
|
|
12
|
+
'jev-browser': 'SPECDEST_DEVKIT_JEV_BROWSER_BIN',
|
|
13
|
+
};
|
|
14
|
+
/** Forward unchanged arguments through Controller's queue, or its trusted NPS host context. */
|
|
15
|
+
export function runHostAutomation(command, args, cwd = process.cwd(), invoke = spawnSync, gatewayExists = existsSync, env = process.env) {
|
|
16
|
+
const project = projectFromCwd(cwd);
|
|
17
|
+
if (!project) {
|
|
18
|
+
process.stderr.write('Controller project registration required.\n');
|
|
19
|
+
return 2;
|
|
20
|
+
}
|
|
21
|
+
if (!args.length) {
|
|
22
|
+
process.stderr.write(`Usage: specdest ${command} <subcommand> [args...]\n`);
|
|
23
|
+
return 2;
|
|
24
|
+
}
|
|
25
|
+
// NPS executes inside the Mac gateway worker. Re-enqueuing to that worker
|
|
26
|
+
// would deadlock, so use the trusted host path injected by Controller.
|
|
27
|
+
if (env.SPECDEST_DEVKIT_GATEWAY_NPS === '1') {
|
|
28
|
+
const binary = env[NPS_BIN_ENV[command]];
|
|
29
|
+
if (!binary?.startsWith('/') || !gatewayExists(binary)) {
|
|
30
|
+
process.stderr.write('Controller did not authorize this host automation binary.\n');
|
|
31
|
+
return 1;
|
|
32
|
+
}
|
|
33
|
+
const result = invoke(binary, args, { stdio: 'inherit', shell: false });
|
|
34
|
+
if (result.error)
|
|
35
|
+
process.stderr.write(`${result.error.message}\n`);
|
|
36
|
+
return result.error ? 1 : (result.status ?? 1);
|
|
37
|
+
}
|
|
38
|
+
const client = '/usr/local/bin/host-cli';
|
|
39
|
+
if (!gatewayExists(client)) {
|
|
40
|
+
process.stderr.write('Controller gateway client unavailable.\n');
|
|
41
|
+
return 1;
|
|
42
|
+
}
|
|
43
|
+
const result = invoke(client, ['devkit-automation', project, TOOLS[command], ...args], {
|
|
44
|
+
stdio: 'inherit',
|
|
45
|
+
shell: false,
|
|
46
|
+
});
|
|
47
|
+
if (result.error) {
|
|
48
|
+
process.stderr.write(`${result.error.message}\n`);
|
|
49
|
+
return 1;
|
|
50
|
+
}
|
|
51
|
+
return result.status ?? 1;
|
|
52
|
+
}
|
package/dist/npm/index.js
CHANGED
|
@@ -11,8 +11,12 @@ export const COMMAND_NAMES = [
|
|
|
11
11
|
'flow',
|
|
12
12
|
'supabase',
|
|
13
13
|
'slack',
|
|
14
|
+
'device',
|
|
15
|
+
'browser',
|
|
16
|
+
'jev-browser',
|
|
17
|
+
'snapshot',
|
|
14
18
|
];
|
|
15
|
-
const HELP = `Usage: specdest <command> [options]\n\nCommands:\n status [--refresh] [--json] Show canonical applicability/install status\n add <package> Adopt/install a predefined package\n sync Refresh catalog/cache and install/update applicable rules\n check [--refresh] [--json] [--details] [--staged | --files <path...>] Run canonical checks, optionally targeted\n rules [options] Load applicable rule guidance for AI/task context\n ai-instruction Print the minimal AI bootstrap instruction\n doctor Diagnose project/cache setup\n flow <command> Manage local resumable development flow state\n supabase <status|start|stop> Local Supabase through restricted Controller\n slack send <files...> Upload files to configured Slack channel\n`;
|
|
19
|
+
const HELP = `Usage: specdest <command> [options]\n\nCommands:\n status [--refresh] [--json] Show canonical applicability/install status\n add <package> Adopt/install a predefined package\n sync Refresh catalog/cache and install/update applicable rules\n check [--refresh] [--json] [--details] [--staged | --files <path...>] Run canonical checks, optionally targeted\n rules [options] Load applicable rule guidance for AI/task context\n ai-instruction Print the minimal AI bootstrap instruction\n doctor Diagnose project/cache setup\n flow <command> Manage local resumable development flow state\n supabase <status|start|stop> Local Supabase through restricted Controller\n slack send <files...> Upload files to configured Slack channel\n device <args...> Forward to Controller agent-device\n browser <args...> Forward to Controller agent-browser\n jev-browser <args...> Forward to Controller jev-browser (if configured)\n snapshot verify <directory> Verify an offline snapshot bundle\n`;
|
|
16
20
|
export async function runCli(argv, io = process, handlers = {}) {
|
|
17
21
|
const [command, ...args] = argv;
|
|
18
22
|
if (!command || command === 'help' || command === '--help' || command === '-h') {
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import { spawn } from 'node:child_process';
|
|
2
|
+
import { readdirSync } from 'node:fs';
|
|
3
|
+
import { automationPolicyFindings } from "./automation-policy.js";
|
|
4
|
+
import { projectFromCwd } from "./supabase-local.js";
|
|
2
5
|
import { clientOnlyBoundaryViolations } from "./client-only-boundary.js";
|
|
3
6
|
import { readRuleProfile } from "./project-context.js";
|
|
4
7
|
import { loadCanonicalProjectContext, prepareCanonicalManifest } from "./project-runtime.js";
|
|
@@ -80,6 +83,20 @@ export async function canonicalCheck(projectRoot, source, options = {}) {
|
|
|
80
83
|
}
|
|
81
84
|
const normalizedTargetFiles = (targetFiles ?? []).map((file) => String(file).replaceAll('\\', '/'));
|
|
82
85
|
let exitCode = 0;
|
|
86
|
+
if (projectFromCwd(projectRoot)) {
|
|
87
|
+
const scripts = readdirSync(`${projectRoot}/scripts`, { recursive: true, withFileTypes: true })
|
|
88
|
+
.filter((entry) => entry.isFile())
|
|
89
|
+
.map((entry) => `scripts/${entry.parentPath.replace(`${projectRoot}/scripts/`, '')}/${entry.name}`.replace('scripts//', 'scripts/'));
|
|
90
|
+
const violations = automationPolicyFindings(projectRoot, ['package-scripts.yml', ...scripts]);
|
|
91
|
+
results['automation-gateway'] = {
|
|
92
|
+
status: violations.length ? 'fail' : 'pass',
|
|
93
|
+
exitCode: violations.length ? 1 : 0,
|
|
94
|
+
stderr: violations.join('\n'),
|
|
95
|
+
diagnostics: violations.map((message) => ({ message })),
|
|
96
|
+
};
|
|
97
|
+
if (violations.length)
|
|
98
|
+
exitCode = 1;
|
|
99
|
+
}
|
|
83
100
|
const profile = await readRuleProfile(projectRoot);
|
|
84
101
|
if (profile.capabilities.includes('client-only')) {
|
|
85
102
|
const findings = await clientOnlyBoundaryViolations(projectRoot);
|
|
@@ -24,12 +24,43 @@ function ruleSummary(entry) {
|
|
|
24
24
|
}
|
|
25
25
|
export function aiInstructionText() {
|
|
26
26
|
return [
|
|
27
|
+
'# Specdest Development Instructions',
|
|
28
|
+
'',
|
|
27
29
|
'Specdest Devkit governs repository engineering rules and deterministic development flow.',
|
|
28
|
-
'
|
|
29
|
-
'
|
|
30
|
-
'
|
|
31
|
-
'
|
|
32
|
-
'
|
|
30
|
+
'',
|
|
31
|
+
'## Environment and repository context',
|
|
32
|
+
'- Use Local Coder MCP for repository operations. On macOS it runs inside Docker; do not assume direct host access.',
|
|
33
|
+
'- Read `/workspace/specdest-company/tools/controller/AGENTS.md` for workspace/project structure, worktrees, host access, and supported development tools.',
|
|
34
|
+
'- Locate the target repository and read its `AGENTS.md` / `CLAUDE.md`; inspect its relevant structure, architecture, documentation, and tests.',
|
|
35
|
+
'- These instructions are the Devkit bootstrap. Do not duplicate Controller, project, or canonical Devkit rules.',
|
|
36
|
+
'',
|
|
37
|
+
'## Understand and prepare',
|
|
38
|
+
'- Understand the intended outcome and whether code changes are requested. Analysis does not authorize implementation.',
|
|
39
|
+
'- Inspect Git status and existing worktrees; use the agent development policy to classify the work and choose the appropriate worktree. Preserve unrelated changes.',
|
|
40
|
+
'- Before repository work, inspect persisted Flow state with `npx @specdest/devkit flow status`. Do not infer persisted Flow state from chat history.',
|
|
41
|
+
'- Follow an existing plan when provided, without recreating it. Ask only for clarification that materially blocks progress.',
|
|
42
|
+
'- Start or resume an appropriate task using `npx @specdest/devkit flow start --mode <feature|fix|inspect> --goal <text> [--task <id>]` when no matching task exists.',
|
|
43
|
+
'- Devkit Flow owns persisted task state, phase transitions, verification, and completion. Keep planning proportional to complexity.',
|
|
44
|
+
'- Do not preload the full rule catalog. Before changing code, use `npx @specdest/devkit rules --category <category>` for compact relevant summaries, then `npx @specdest/devkit rules --id <rule>` only when full guidance is needed.',
|
|
45
|
+
'',
|
|
46
|
+
'## Execute',
|
|
47
|
+
'- For implementation tasks, checkpoint with `npx @specdest/devkit flow checkpoint --phase implement` after planning.',
|
|
48
|
+
'- Create or update relevant tests first where practical (TDD); reproduce bugs before fixing them.',
|
|
49
|
+
'- Make the smallest change satisfying the request; reuse existing architecture, libraries, and conventions.',
|
|
50
|
+
'- Update documentation when behavior or contracts change. For investigation, establish reproducible evidence; for performance, measure first; for UI, inspect rendered appearance.',
|
|
51
|
+
'- Use relevant optional browser, device, screenshot, diagram, or other tooling through approved Controller/Devkit workflows only when needed.',
|
|
52
|
+
'',
|
|
53
|
+
'## Verify and complete',
|
|
54
|
+
'- Run focused tests first, then relevant lint, formatting, typechecks, and repository-required gates, including `npx @specdest/devkit check` when applicable.',
|
|
55
|
+
'- If Devkit checks fail, use `npx @specdest/devkit rules --failed` and fix violations without weakening rules.',
|
|
56
|
+
'- For implementation flows, run `npx @specdest/devkit flow verify` with the repository-configured gate; verify actual UI when relevant.',
|
|
57
|
+
'- Inspect the diff and stage only task changes; commit with existing Husky hooks enabled. Do not bypass failed checks.',
|
|
58
|
+
'- Ensure verification remains current and use `npx @specdest/devkit flow complete` when appropriate. A commit changes Git state; rerun verification after committing if needed.',
|
|
59
|
+
'- Do not push unless requested. Never commit secrets, runtime state, or unrelated changes.',
|
|
60
|
+
'',
|
|
61
|
+
'## Final response',
|
|
62
|
+
'- Report only the requested result: changes, verification, commit hash, or investigation findings and grounded recommendations.',
|
|
63
|
+
'- State actual blockers or remaining failures. Stop once the requested work and required verification are complete.',
|
|
33
64
|
].join('\n');
|
|
34
65
|
}
|
|
35
66
|
export async function canonicalRules(projectRoot, source, options = {}) {
|
package/dist/npm/snapshot-cli.js
CHANGED
|
@@ -29,18 +29,17 @@ export function verifyBundle(directory) {
|
|
|
29
29
|
reconcileStorageMetadata(input.storageManifest, json('storage-references.json'), config.storage.buckets, config.project);
|
|
30
30
|
return result;
|
|
31
31
|
}
|
|
32
|
-
|
|
33
|
-
if (
|
|
34
|
-
|
|
35
|
-
|
|
32
|
+
export async function runSnapshot(args, io = process) {
|
|
33
|
+
if (args.length !== 2 || args[0] !== 'verify') {
|
|
34
|
+
io.stderr.write('Usage: specdest snapshot verify <offline-bundle-directory>\n');
|
|
35
|
+
return 2;
|
|
36
36
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}
|
|
37
|
+
try {
|
|
38
|
+
io.stdout.write(JSON.stringify(verifyBundle(args[1])) + '\n');
|
|
39
|
+
return 0;
|
|
40
|
+
}
|
|
41
|
+
catch {
|
|
42
|
+
io.stderr.write('Snapshot verification rejected\n');
|
|
43
|
+
return 1;
|
|
45
44
|
}
|
|
46
45
|
}
|
package/package.json
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@specdest/devkit",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.15",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"bin": {
|
|
6
|
-
"specdest": "dist/npm/cli.js"
|
|
7
|
-
"specdest-snapshot": "dist/npm/snapshot-cli.js"
|
|
6
|
+
"specdest": "dist/npm/cli.js"
|
|
8
7
|
},
|
|
9
8
|
"exports": {
|
|
10
9
|
".": "./dist/npm/index.js"
|