insta 0.0.17 → 0.0.18

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.
@@ -5,21 +5,13 @@ import { info, die, printJson, handleApproval, renderNextActions } from '../util
5
5
  import { installObserve } from '../observe/install.js';
6
6
  import { installSkills } from '../ensure-skills.js';
7
7
  // Generic directory names that make a useless project name ("projects", "~", "tmp", …). When the
8
- // cwd basename is one of these we auto-generate a friendly name instead of using it.
8
+ // cwd basename is one of these we DON'T invent a name — we guide the user to name it (or let their
9
+ // skill-equipped agent do it), rather than provisioning real resources under a junk name.
9
10
  const GENERIC_DIRS = new Set([
10
11
  'projects', 'project', 'home', 'tmp', 'temp', 'desktop', 'documents', 'downloads',
11
12
  'src', 'source', 'code', 'dev', 'work', 'workspace', 'repos', 'repo', 'git',
12
13
  'app', 'apps', 'users', 'user', 'bin', 'new', 'test', 'tests',
13
14
  ]);
14
- const ADJ = ['swift', 'brave', 'calm', 'bright', 'bold', 'quiet', 'warm', 'keen', 'wise',
15
- 'lucky', 'sunny', 'cosmic', 'gentle', 'rapid', 'vivid', 'amber', 'crisp', 'noble'];
16
- const NOUN = ['otter', 'falcon', 'maple', 'river', 'harbor', 'meadow', 'comet', 'cedar', 'lark',
17
- 'delta', 'summit', 'ember', 'willow', 'pixel', 'forge', 'harbor', 'atlas', 'quartz'];
18
- /** A friendly auto-generated name like `swift-meadow-482` (Vercel/Render style). */
19
- export function generateProjectName(rand = Math.random) {
20
- const pick = (a) => a[Math.floor(rand() * a.length)];
21
- return `${pick(ADJ)}-${pick(NOUN)}-${100 + Math.floor(rand() * 900)}`;
22
- }
23
15
  // Best-effort: wire the credential-audit hook into the project (no-op if assets aren't built).
24
16
  function tryInstallObserve() {
25
17
  try {
@@ -41,23 +33,31 @@ async function resolveOrg(api, given) {
41
33
  export function slugifyName(raw) {
42
34
  return raw.toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-+|-+$/g, '').slice(0, 40);
43
35
  }
44
- /** Name resolution so `insta project create` (no arg) NEVER blocks on a prompt — the whole point
45
- * of a paste-and-run one-liner. Explicit arg wins; else use the cwd basename when it's a real
46
- * project-dir name; else auto-generate a friendly name (e.g. in ~/projects, where the basename
47
- * "projects" is useless). You can always pass a name or rename later. */
48
- export async function resolveProjectName(nameArg, cwd = process.cwd(), generate = generateProjectName) {
36
+ /** Name resolution — NEVER prompts (a paste-and-run one-liner must not block on input). Returns
37
+ * the name to create, or `null` meaning "no sensible name; guide the user instead of inventing
38
+ * one". Explicit arg wins; else the cwd basename when it's a real project-dir name; else null
39
+ * (generic dir like ~/projects or /tmp, or the home dir itself). Agents pass a name via the skill,
40
+ * so null is only reached when a human runs bare `insta project create` somewhere generic. */
41
+ export function resolveProjectName(nameArg, cwd = process.cwd()) {
49
42
  if (nameArg)
50
43
  return slugifyName(nameArg);
51
44
  const base = slugifyName(cwd.split('/').filter(Boolean).pop() ?? '');
52
45
  const home = slugifyName(homedir().split('/').filter(Boolean).pop() ?? '');
53
46
  if (base && base !== home && !GENERIC_DIRS.has(base))
54
47
  return base;
55
- return generate();
48
+ return null;
56
49
  }
57
50
  export async function projectCreate(name, opts) {
51
+ const resolved = resolveProjectName(name, process.cwd());
52
+ if (!resolved) {
53
+ // No name given and the cwd name is generic — don't provision resources under a junk name.
54
+ // Guide instead (no hang, no error): name it explicitly, or just ask the skill-equipped agent.
55
+ info('name your project: insta project create <name>');
56
+ info(' (or just ask your coding agent — it has the insta skill and will do this for you)');
57
+ return;
58
+ }
58
59
  const api = await ApiClient.load();
59
60
  const orgId = await resolveOrg(api, opts.org);
60
- const resolved = await resolveProjectName(name, process.cwd());
61
61
  const out = await api.request('POST', `/orgs/${orgId}/projects`, { name: resolved });
62
62
  await writeProject({ projectId: out.project.id, orgId, branch: out.defaultBranch.name });
63
63
  info(`created project ${out.project.id} (${resolved})`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "insta",
3
- "version": "0.0.17",
3
+ "version": "0.0.18",
4
4
  "type": "module",
5
5
  "description": "InstaCloud CLI — a thin client of the platform control-plane API.",
6
6
  "keywords": [